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 | 0cefb0ecbc995f53fc8724105fa4a42bebbf4110 (patch) | |
tree | 3919f48eb3c4ff9ef3b48f6986c62db2109beb0a /lib/CodeGen/AsmPrinter/DIE.h | |
parent | 268e96a8a61cecfc7000e300b8e39e9e15ce756b (diff) | |
download | llvm-0cefb0ecbc995f53fc8724105fa4a42bebbf4110.tar.gz llvm-0cefb0ecbc995f53fc8724105fa4a42bebbf4110.tar.bz2 llvm-0cefb0ecbc995f53fc8724105fa4a42bebbf4110.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201481 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DIE.h')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DIE.h | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/lib/CodeGen/AsmPrinter/DIE.h b/lib/CodeGen/AsmPrinter/DIE.h index 40b496d3ad..a35229da91 100644 --- a/lib/CodeGen/AsmPrinter/DIE.h +++ b/lib/CodeGen/AsmPrinter/DIE.h @@ -197,7 +197,8 @@ namespace llvm { isDelta, isEntry, isTypeSignature, - isBlock + isBlock, + isLoc }; protected: /// Type - Type of data stored in the value. @@ -441,14 +442,53 @@ namespace llvm { }; //===--------------------------------------------------------------------===// - /// DIEBlock - A block of values. Primarily used for location expressions. + /// DIELoc - Represents an expression location. + // + class DIELoc : public DIEValue, public DIE { + unsigned Size; // Size in bytes excluding size header. + public: + DIELoc() : DIEValue(isLoc), DIE(0), Size(0) {} + + /// ComputeSize - Calculate the size of the location expression. + /// + unsigned ComputeSize(AsmPrinter *AP); + + /// BestForm - Choose the best form for data. + /// + dwarf::Form BestForm(unsigned DwarfVersion) const { + if (DwarfVersion > 3) return dwarf::DW_FORM_exprloc; + // Pre-DWARF4 location expressions were blocks and not exprloc. + if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1; + if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2; + if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4; + return dwarf::DW_FORM_block; + } + + /// EmitValue - Emit location data. + /// + virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const; + + /// SizeOf - Determine size of location data in bytes. + /// + virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const; + + // Implement isa/cast/dyncast. + static bool classof(const DIEValue *E) { return E->getType() == isLoc; } + +#ifndef NDEBUG + virtual void print(raw_ostream &O) const; +#endif + }; + + //===--------------------------------------------------------------------===// + /// DIEBlock - Represents a block of values. // class DIEBlock : public DIEValue, public DIE { unsigned Size; // Size in bytes excluding size header. public: DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {} - /// ComputeSize - calculate the size of the block. + /// ComputeSize - Calculate the size of the location expression. /// unsigned ComputeSize(AsmPrinter *AP); @@ -461,22 +501,21 @@ namespace llvm { return dwarf::DW_FORM_block; } - /// EmitValue - Emit block data. + /// EmitValue - Emit location data. /// virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const; - /// SizeOf - Determine size of block data in bytes. + /// SizeOf - Determine size of location data in bytes. /// virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const; // Implement isa/cast/dyncast. static bool classof(const DIEValue *E) { return E->getType() == isBlock; } -#ifndef NDEBUG + #ifndef NDEBUG virtual void print(raw_ostream &O) const; -#endif + #endif }; - } // end llvm namespace #endif |