diff options
| author | Eric Christopher <echristo@gmail.com> | 2014-02-16 08:46:55 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2014-02-16 08:46:55 +0000 |
| commit | 4a74104933feab37d8ca6b55bcd14d5c2b7f90d3 (patch) | |
| tree | c9351340a5fadae92f486ef9b4cf726529eda690 /llvm/lib/CodeGen/AsmPrinter/DIE.cpp | |
| parent | 4f6428030dd98cdbc10632ed67ddc39055380ece (diff) | |
| download | bcm5719-llvm-4a74104933feab37d8ca6b55bcd14d5c2b7f90d3.tar.gz bcm5719-llvm-4a74104933feab37d8ca6b55bcd14d5c2b7f90d3.zip | |
Add a DIELoc class to cover the DW_FORM_exprloc set of expressions
alongside DIEBlock and replace uses accordingly. Use DW_FORM_exprloc
in DWARF4 and later code. Update testcases.
Adding a DIELoc instead of using extra forms inside DIEBlock so
that we can keep location expressions separate from other uses. No
direct use at the moment, however, it's not a lot of code and
using a separately named class keeps it somewhat more obvious
what's going on in various locations.
llvm-svn: 201481
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DIE.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index 90d46630a90..79c4b438f8e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -419,6 +419,61 @@ void DIETypeSignature::dump() const { print(dbgs()); } #endif //===----------------------------------------------------------------------===// +// DIELoc Implementation +//===----------------------------------------------------------------------===// + +/// ComputeSize - calculate the size of the location expression. +/// +unsigned DIELoc::ComputeSize(AsmPrinter *AP) { + if (!Size) { + const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData(); + for (unsigned i = 0, N = Values.size(); i < N; ++i) + Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm()); + } + + return Size; +} + +/// EmitValue - Emit location data. +/// +void DIELoc::EmitValue(AsmPrinter *Asm, dwarf::Form Form) const { + switch (Form) { + default: llvm_unreachable("Improper form for block"); + case dwarf::DW_FORM_block1: Asm->EmitInt8(Size); break; + case dwarf::DW_FORM_block2: Asm->EmitInt16(Size); break; + case dwarf::DW_FORM_block4: Asm->EmitInt32(Size); break; + case dwarf::DW_FORM_block: + case dwarf::DW_FORM_exprloc: + Asm->EmitULEB128(Size); break; + } + + const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData(); + for (unsigned i = 0, N = Values.size(); i < N; ++i) + Values[i]->EmitValue(Asm, AbbrevData[i].getForm()); +} + +/// SizeOf - Determine size of location data in bytes. +/// +unsigned DIELoc::SizeOf(AsmPrinter *AP, dwarf::Form Form) const { + switch (Form) { + case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); + case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); + case dwarf::DW_FORM_block4: return Size + sizeof(int32_t); + case dwarf::DW_FORM_block: + case dwarf::DW_FORM_exprloc: + return Size + MCAsmInfo::getULEB128Size(Size); + default: llvm_unreachable("Improper form for block"); + } +} + +#ifndef NDEBUG +void DIELoc::print(raw_ostream &O) const { + O << "ExprLoc: "; + DIE::print(O, 5); +} +#endif + +//===----------------------------------------------------------------------===// // DIEBlock Implementation //===----------------------------------------------------------------------===// |

