diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | 74 |
1 files changed, 44 insertions, 30 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h index 46c07b1d5b6b..757b17511453 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -30,6 +30,7 @@ class APInt; class DwarfCompileUnit; class DIELoc; class TargetRegisterInfo; +class MachineLocation; /// Holds a DIExpression and keeps track of how many operands have been consumed /// so far. @@ -107,8 +108,21 @@ protected: /// Holds information about all subregisters comprising a register location. struct Register { int DwarfRegNo; - unsigned Size; + unsigned SubRegSize; const char *Comment; + + /// Create a full register, no extra DW_OP_piece operators necessary. + static Register createRegister(int RegNo, const char *Comment) { + return {RegNo, 0, Comment}; + } + + /// Create a subregister that needs a DW_OP_piece operator with SizeInBits. + static Register createSubRegister(int RegNo, unsigned SizeInBits, + const char *Comment) { + return {RegNo, SizeInBits, Comment}; + } + + bool isSubRegister() const { return SubRegSize; } }; /// Whether we are currently emitting an entry value operation. @@ -129,37 +143,31 @@ protected: /// The kind of location description being produced. enum { Unknown = 0, Register, Memory, Implicit }; - /// The flags of location description being produced. - enum { EntryValue = 1, CallSiteParamValue }; + /// Additional location flags which may be combined with any location kind. + /// Currently, entry values are not supported for the Memory location kind. + enum { EntryValue = 1 << 0, Indirect = 1 << 1, CallSiteParamValue = 1 << 2 }; unsigned LocationKind : 3; - unsigned LocationFlags : 2; + unsigned LocationFlags : 3; unsigned DwarfVersion : 4; public: - bool isUnknownLocation() const { - return LocationKind == Unknown; - } + /// Set the location (\p Loc) and \ref DIExpression (\p DIExpr) to describe. + void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr); - bool isMemoryLocation() const { - return LocationKind == Memory; - } + bool isUnknownLocation() const { return LocationKind == Unknown; } - bool isRegisterLocation() const { - return LocationKind == Register; - } + bool isMemoryLocation() const { return LocationKind == Memory; } - bool isImplicitLocation() const { - return LocationKind == Implicit; - } + bool isRegisterLocation() const { return LocationKind == Register; } - bool isEntryValue() const { - return LocationFlags & EntryValue; - } + bool isImplicitLocation() const { return LocationKind == Implicit; } - bool isParameterValue() { - return LocationFlags & CallSiteParamValue; - } + bool isEntryValue() const { return LocationFlags & EntryValue; } + + bool isIndirect() const { return LocationFlags & Indirect; } + + bool isParameterValue() { return LocationFlags & CallSiteParamValue; } Optional<uint8_t> TagOffset; @@ -209,7 +217,8 @@ protected: /// Return whether the given machine register is the frame register in the /// current function. - virtual bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) = 0; + virtual bool isFrameRegister(const TargetRegisterInfo &TRI, + unsigned MachineReg) = 0; /// Emit a DW_OP_reg operation. Note that this is only legal inside a DWARF /// register location description. @@ -267,6 +276,9 @@ protected: /// DWARF block which has been emitted to the temporary buffer. void finalizeEntryValue(); + /// Cancel the emission of an entry value. + void cancelEntryValue(); + ~DwarfExpression() = default; public: @@ -294,14 +306,10 @@ public: } /// Lock this down to become an entry value location. - void setEntryValueFlag() { - LocationFlags |= EntryValue; - } + void setEntryValueFlags(const MachineLocation &Loc); /// Lock this down to become a call site parameter location. - void setCallSiteParamValueFlag() { - LocationFlags |= CallSiteParamValue; - } + void setCallSiteParamValueFlag() { LocationFlags |= CallSiteParamValue; } /// Emit a machine register location. As an optimization this may also consume /// the prefix of a DwarfExpression if a more efficient representation for @@ -323,6 +331,10 @@ public: /// any operands here. void beginEntryValueExpression(DIExpressionCursor &ExprCursor); + /// Return the index of a base type with the given properties and + /// create one if necessary. + unsigned getOrCreateBaseType(unsigned BitSize, dwarf::TypeKind Encoding); + /// Emit all remaining operations in the DIExpressionCursor. /// /// \param FragmentOffsetInBits If this is one fragment out of multiple @@ -340,7 +352,7 @@ public: /// Emit location information expressed via WebAssembly location + offset /// The Index is an identifier for locals, globals or operand stack. - void addWasmLocation(unsigned Index, int64_t Offset); + void addWasmLocation(unsigned Index, uint64_t Offset); }; /// DwarfExpression implementation for .debug_loc entries. @@ -374,6 +386,7 @@ class DebugLocDwarfExpression final : public DwarfExpression { bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) override; + public: DebugLocDwarfExpression(unsigned DwarfVersion, BufferByteStreamer &BS, DwarfCompileUnit &CU) @@ -403,6 +416,7 @@ class DIEDwarfExpression final : public DwarfExpression { bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) override; + public: DIEDwarfExpression(const AsmPrinter &AP, DwarfCompileUnit &CU, DIELoc &DIE); |