diff options
author | Pavel Labath <labath@google.com> | 2018-03-14 09:39:54 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2018-03-14 09:39:54 +0000 |
commit | 322711f5290715b1e6f3da6c215e91760e93b408 (patch) | |
tree | d22f7cc01859a2789548c625f27bbb6d0ccfb3e8 /llvm/lib/CodeGen/AsmPrinter/DIE.cpp | |
parent | bc683cced825ac6fc31c73cc7a539021c9c14284 (diff) | |
download | bcm5719-llvm-322711f5290715b1e6f3da6c215e91760e93b408.tar.gz bcm5719-llvm-322711f5290715b1e6f3da6c215e91760e93b408.zip |
DWARF: Unify form size handling code
Summary:
This patch replaces the two switches which are deducing the size of
various forms with a single implementation. I have put the new
implementation into BinaryFormat, to avoid introducing dependencies
between the two independent libraries (DebugInfo and CodeGen) that need
this functionality.
Reviewers: aprantl, JDevlieghere, dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44418
llvm-svn: 327486
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DIE.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 54 |
1 files changed, 8 insertions, 46 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index 0832544c0d6..d935c05dcc6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -425,51 +425,15 @@ void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { /// SizeOf - Determine size of integer value in bytes. /// unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { + dwarf::FormParams Params; + if (AP) + Params = {AP->getDwarfVersion(), uint8_t(AP->getPointerSize()), + AP->OutStreamer->getContext().getDwarfFormat()}; + + if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params)) + return *FixedSize; + switch (Form) { - case dwarf::DW_FORM_implicit_const: - case dwarf::DW_FORM_flag_present: - return 0; - case dwarf::DW_FORM_flag: - case dwarf::DW_FORM_ref1: - case dwarf::DW_FORM_data1: - case dwarf::DW_FORM_strx1: - case dwarf::DW_FORM_addrx1: - return sizeof(int8_t); - case dwarf::DW_FORM_ref2: - case dwarf::DW_FORM_data2: - case dwarf::DW_FORM_strx2: - case dwarf::DW_FORM_addrx2: - return sizeof(int16_t); - case dwarf::DW_FORM_strx3: - return 3; - case dwarf::DW_FORM_ref4: - case dwarf::DW_FORM_data4: - case dwarf::DW_FORM_ref_sup4: - case dwarf::DW_FORM_strx4: - case dwarf::DW_FORM_addrx4: - return sizeof(int32_t); - case dwarf::DW_FORM_ref8: - case dwarf::DW_FORM_ref_sig8: - case dwarf::DW_FORM_data8: - case dwarf::DW_FORM_ref_sup8: - return sizeof(int64_t); - case dwarf::DW_FORM_ref_addr: - if (AP->getDwarfVersion() == 2) - return AP->getPointerSize(); - LLVM_FALLTHROUGH; - case dwarf::DW_FORM_strp: - case dwarf::DW_FORM_GNU_ref_alt: - case dwarf::DW_FORM_GNU_strp_alt: - case dwarf::DW_FORM_line_strp: - case dwarf::DW_FORM_sec_offset: - case dwarf::DW_FORM_strp_sup: - switch (AP->OutStreamer->getContext().getDwarfFormat()) { - case dwarf::DWARF32: - return 4; - case dwarf::DWARF64: - return 8; - } - llvm_unreachable("Invalid DWARF format"); case dwarf::DW_FORM_GNU_str_index: case dwarf::DW_FORM_GNU_addr_index: case dwarf::DW_FORM_ref_udata: @@ -478,8 +442,6 @@ unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { return getULEB128Size(Integer); case dwarf::DW_FORM_sdata: return getSLEB128Size(Integer); - case dwarf::DW_FORM_addr: - return AP->getPointerSize(); default: llvm_unreachable("DIE Value form not supported yet"); } } |