LLVM: llvm::DwarfExpression Class Reference (original) (raw)
Base class containing the logic for constructing DWARF expressions independently of whether they are emitted into a DIE or into a .debug_loc entry. More...
#include "[CodeGen/AsmPrinter/DwarfExpression.h](DwarfExpression%5F8h%5Fsource.html)"
| Classes | |
|---|---|
| struct | Register |
| Holds information about all subregisters comprising a register location. More... |
| Public Member Functions | |
|---|---|
| void | setLocation (const MachineLocation &Loc, const DIExpression *DIExpr) |
| Set the location (Loc) and DIExpression (DIExpr) to describe. | |
| bool | isUnknownLocation () const |
| bool | isMemoryLocation () const |
| bool | isRegisterLocation () const |
| bool | isImplicitLocation () const |
| bool | isEntryValue () const |
| bool | isIndirect () const |
| bool | isParameterValue () |
| DwarfExpression (unsigned DwarfVersion, DwarfCompileUnit &CU) | |
| void | finalize () |
| This needs to be called last to commit any pending changes. | |
| void | addBooleanConstant (int64_t Value) |
| Emit a boolean constant. | |
| void | addSignedConstant (int64_t Value) |
| Emit a signed constant. | |
| void | addUnsignedConstant (uint64_t Value) |
| Emit an unsigned constant. | |
| void | addUnsignedConstant (const APInt &Value) |
| Emit an unsigned constant. | |
| void | addConstantFP (const APFloat &Value, const AsmPrinter &AP) |
| Emit an floating point constant. | |
| void | setMemoryLocationKind () |
| Lock this down to become a memory location description. | |
| void | setEntryValueFlags (const MachineLocation &Loc) |
| Lock this down to become an entry value location. | |
| void | setCallSiteParamValueFlag () |
| Lock this down to become a call site parameter location. | |
| bool | addMachineRegExpression (const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0) |
| Emit a machine register location. | |
| void | beginEntryValueExpression (DIExpressionCursor &ExprCursor) |
| Begin emission of an entry value dwarf operation. | |
| unsigned | getOrCreateBaseType (unsigned BitSize, dwarf::TypeKind Encoding) |
| Return the index of a base type with the given properties and create one if necessary. | |
| void | addExpression (DIExpressionCursor &&Expr) |
| Emit all remaining operations in the DIExpressionCursor. | |
| bool | addExpression (DIExpressionCursor &&Expr, llvm::function_ref< bool(unsigned, DIExpressionCursor &)> InsertArg) |
| Emit all remaining operations in the DIExpressionCursor. | |
| void | addFragmentOffset (const DIExpression *Expr) |
| If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Expr. | |
| void | emitLegacySExt (unsigned FromBits) |
| void | emitLegacyZExt (unsigned FromBits) |
| void | addWasmLocation (unsigned Index, uint64_t Offset) |
| Emit location information expressed via WebAssembly location + offset The Index is an identifier for locals, globals or operand stack. |
| Public Attributes | |
|---|---|
| std::optional< uint8_t > | TagOffset |
| Protected Types | |
|---|---|
| enum | { Unknown = 0 , Register, Memory, Implicit } |
| The kind of location description being produced. More... | |
| enum | { EntryValue = 1 << 0 , Indirect = 1 << 1 , CallSiteParamValue = 1 << 2 } |
| Additional location flags which may be combined with any location kind. More... |
| Protected Member Functions | |
|---|---|
| void | setSubRegisterPiece (unsigned SizeInBits, unsigned OffsetInBits) |
| Push a DW_OP_piece / DW_OP_bit_piece for emitting later, if one is needed to represent a subregister. | |
| void | maskSubRegister () |
| Add masking operations to stencil out a subregister. | |
| virtual void | emitOp (uint8_t Op, const char *Comment=nullptr)=0 |
| Output a dwarf operand and an optional assembler comment. | |
| virtual void | emitSigned (int64_t Value)=0 |
| Emit a raw signed value. | |
| virtual void | emitUnsigned (uint64_t Value)=0 |
| Emit a raw unsigned value. | |
| virtual void | emitData1 (uint8_t Value)=0 |
| virtual void | emitBaseTypeRef (uint64_t Idx)=0 |
| virtual void | enableTemporaryBuffer ()=0 |
| Start emitting data to the temporary buffer. | |
| virtual void | disableTemporaryBuffer ()=0 |
| Disable emission to the temporary buffer. | |
| virtual unsigned | getTemporaryBufferSize ()=0 |
| Return the emitted size, in number of bytes, for the data stored in the temporary buffer. | |
| virtual void | commitTemporaryBuffer ()=0 |
| Commit the data stored in the temporary buffer to the main output. | |
| void | emitConstu (uint64_t Value) |
| Emit a normalized unsigned constant. | |
| virtual bool | isFrameRegister (const TargetRegisterInfo &TRI, llvm::Register MachineReg)=0 |
| Return whether the given machine register is the frame register in the current function. | |
| void | addReg (int64_t DwarfReg, const char *Comment=nullptr) |
| Emit a DW_OP_reg operation. | |
| void | addBReg (int64_t DwarfReg, int64_t Offset) |
| Emit a DW_OP_breg operation. | |
| void | addFBReg (int64_t Offset) |
| Emit DW_OP_fbreg . | |
| bool | addMachineReg (const TargetRegisterInfo &TRI, llvm::Register MachineReg, unsigned MaxSize=~1U) |
| Emit a partial DWARF register operation. | |
| void | addOpPiece (unsigned SizeInBits, unsigned OffsetInBits=0) |
| Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment. | |
| void | addShr (unsigned ShiftBy) |
| Emit a shift-right dwarf operation. | |
| void | addAnd (unsigned Mask) |
| Emit a bitwise and dwarf operation. | |
| void | addStackValue () |
| Emit a DW_OP_stack_value, if supported. | |
| void | finalizeEntryValue () |
| Finalize an entry value by emitting its size operand, and committing the DWARF block which has been emitted to the temporary buffer. | |
| void | cancelEntryValue () |
| Cancel the emission of an entry value. | |
| ~DwarfExpression ()=default |
| Protected Attributes | |
|---|---|
| bool | IsEmittingEntryValue = false |
| Whether we are currently emitting an entry value operation. | |
| DwarfCompileUnit & | CU |
| SmallVector< Register, 2 > | DwarfRegs |
| The register location, if any. | |
| uint64_t | OffsetInBits = 0 |
| Current Fragment Offset in Bits. | |
| unsigned | SubRegisterSizeInBits: 16 |
| Sometimes we need to add a DW_OP_bit_piece to describe a subregister. | |
| unsigned | SubRegisterOffsetInBits: 16 |
| unsigned | LocationKind: 3 |
| unsigned | SavedLocationKind: 3 |
| unsigned | LocationFlags: 3 |
| unsigned | DwarfVersion: 4 |
Base class containing the logic for constructing DWARF expressions independently of whether they are emitted into a DIE or into a .debug_loc entry.
Some DWARF operations, e.g. DW_OP_entry_value, need to calculate the size of a succeeding DWARF block before the latter is emitted to the output. To handle such cases, data can conditionally be emitted to a temporary buffer, which can later on be committed to the main output. The size of the temporary buffer is queryable, allowing for the size of the data to be emitted before the data is committed.
Definition at line 43 of file DwarfExpression.h.
◆ anonymous enum
Additional location flags which may be combined with any location kind.
Currently, entry values are not supported for the Memory location kind.
| Enumerator |
|---|
| EntryValue |
| Indirect |
| CallSiteParamValue |
Definition at line 85 of file DwarfExpression.h.
◆ anonymous enum
The kind of location description being produced.
| Enumerator |
|---|
| Unknown |
| Register |
| Memory |
| Implicit |
Definition at line 81 of file DwarfExpression.h.
| llvm::DwarfExpression::~DwarfExpression ( ) | protecteddefault |
|---|
◆ DwarfExpression()
◆ addAnd()
| void DwarfExpression::addAnd ( unsigned Mask) | protected |
|---|
◆ addBooleanConstant()
| void DwarfExpression::addBooleanConstant | ( | int64_t | Value | ) |
|---|
◆ addBReg()
| void DwarfExpression::addBReg ( int64_t DwarfReg, int64_t Offset ) | protected |
|---|
◆ addConstantFP()
Emit an floating point constant.
Definition at line 239 of file DwarfExpression.cpp.
References assert(), llvm::APFloat::bitcastToAPInt(), llvm::APInt::byteSwap(), llvm::dbgs(), emitData1(), emitOp(), emitUnsigned(), llvm::APInt::getBitWidth(), llvm::AsmPrinter::getDataLayout(), llvm::APInt::getZExtValue(), llvm::DataLayout::isBigEndian(), isImplicitLocation(), isUnknownLocation(), LLVM_DEBUG, and llvm::APInt::lshr().
Referenced by llvm::DwarfDebug::emitDebugLocValue().
◆ addExpression() [1/2]
◆ addExpression() [2/2]
Emit all remaining operations in the DIExpressionCursor.
DW_OP_LLVM_arg operations are resolved by calling (InsertArg).
Returns
false if any call to (InsertArg) returns false.
Definition at line 507 of file DwarfExpression.cpp.
References addBReg(), addOpPiece(), addStackValue(), llvm::alignTo(), assert(), llvm::dwarf::DW_OP_LLVM_arg, llvm::dwarf::DW_OP_LLVM_convert, llvm::dwarf::DW_OP_LLVM_extract_bits_sext, llvm::dwarf::DW_OP_LLVM_extract_bits_zext, llvm::dwarf::DW_OP_LLVM_fragment, llvm::dwarf::DW_OP_LLVM_tag_offset, DwarfVersion, emitBaseTypeRef(), emitConstu(), emitData1(), emitLegacySExt(), emitLegacyZExt(), emitOp(), emitSigned(), emitUnsigned(), getOrCreateBaseType(), Implicit, IsEmittingEntryValue, isImplicitLocation(), isMemoryLocation(), isParameterValue(), isRegisterLocation(), llvm_unreachable, LocationKind, Memory, OffsetInBits, setSubRegisterPiece(), SubRegisterOffsetInBits, SubRegisterSizeInBits, TagOffset, and Unknown.
◆ addFBReg()
| void DwarfExpression::addFBReg ( int64_t Offset) | protected |
|---|
◆ addFragmentOffset()
◆ addMachineReg()
Emit a partial DWARF register operation.
Parameters
| MachineReg | The register number. |
|---|---|
| MaxSize | If the register must be composed from sub-registers this is an upper bound for how many bits the emitted DW_OP_piece may cover. |
If size and offset is zero an operation for the entire register is emitted: Some targets do not provide a DWARF register number for every register. If this is the case, this function will attempt to emit a DWARF register by emitting a fragment of a super-register or by piecing together multiple subregisters that alias the register.
Returns
false if no DWARF register exists for MachineReg.
Definition at line 100 of file DwarfExpression.cpp.
References llvm::DwarfExpression::Register::createRegister(), llvm::DwarfExpression::Register::createSubRegister(), DwarfRegs, isFrameRegister(), llvm::Register::isPhysical(), llvm::Offset, Reg, RegSize, llvm::SmallBitVector::set(), setSubRegisterPiece(), Size, llvm::SmallBitVector::test(), and TRI.
Referenced by addMachineRegExpression().
◆ addMachineRegExpression()
Emit a machine register location.
As an optimization this may also consume the prefix of a DwarfExpression if a more efficient representation for combining the register location and the first operation exists.
Parameters
| FragmentOffsetInBits | If this is one fragment out of a fragmented location, this is the offset of the fragment inside the entire variable. |
|---|
Returns
false if no DWARF register exists for MachineReg.
Definition at line 266 of file DwarfExpression.cpp.
References addBReg(), addFBReg(), addMachineReg(), addOpPiece(), addReg(), llvm::any_of(), assert(), cancelEntryValue(), llvm::DIExpressionCursor::consume(), llvm::dbgs(), llvm::dwarf::DW_OP_LLVM_fragment, DwarfRegs, DwarfVersion, emitOp(), finalizeEntryValue(), llvm::DIExpressionCursor::getFragmentInfo(), IsEmittingEntryValue, isEntryValue(), isFrameRegister(), isIndirect(), isMemoryLocation(), isParameterValue(), LLVM_DEBUG, LocationKind, maskSubRegister(), N, llvm::Offset, llvm::DIExpressionCursor::peek(), llvm::DIExpressionCursor::peekNext(), RegSize, SubRegisterSizeInBits, llvm::DIExpressionCursor::take(), TRI, and Unknown.
Referenced by llvm::DwarfCompileUnit::addAddress(), llvm::DwarfCompileUnit::addComplexAddress(), and llvm::DwarfDebug::emitDebugLocValue().
◆ addOpPiece()
| void DwarfExpression::addOpPiece ( unsigned SizeInBits, unsigned OffsetInBits = 0 ) | protected |
|---|
◆ addReg()
| void DwarfExpression::addReg ( int64_t DwarfReg, const char * Comment = nullptr ) | protected |
|---|
◆ addShr()
| void DwarfExpression::addShr ( unsigned ShiftBy) | protected |
|---|
◆ addSignedConstant()
| void DwarfExpression::addSignedConstant | ( | int64_t | Value | ) |
|---|
◆ addStackValue()
| void DwarfExpression::addStackValue ( ) | protected |
|---|
Emit a DW_OP_stack_value, if supported.
The proper way to describe a constant value is DW_OP_constu , DW_OP_stack_value. Unfortunately, DW_OP_stack_value was not available until DWARF 4, so we will continue to generate DW_OP_constu for DWARF 2 and DWARF 3. Technically, this is incorrect since DW_OP_const actually describes a value at a constant address, not a constant value. However, in the past there was no better way to describe a constant value, so the producers and consumers started to rely on heuristics to disambiguate the value vs. location status of the expression. See PR21176 for more details.
Definition at line 192 of file DwarfExpression.cpp.
References DwarfVersion, and emitOp().
Referenced by addExpression(), and addUnsignedConstant().
◆ addUnsignedConstant() [1/2]
| void DwarfExpression::addUnsignedConstant | ( | const APInt & | Value | ) |
|---|
Emit an unsigned constant.
Definition at line 219 of file DwarfExpression.cpp.
References addOpPiece(), addStackValue(), addUnsignedConstant(), assert(), llvm::Data, Implicit, isImplicitLocation(), isUnknownLocation(), LocationKind, llvm::Offset, and Size.
◆ addUnsignedConstant() [2/2]
| void DwarfExpression::addUnsignedConstant | ( | uint64_t | Value | ) |
|---|
◆ addWasmLocation()
◆ beginEntryValueExpression()
Begin emission of an entry value dwarf operation.
The entry value's first operand is the size of the DWARF block (its second operand), which needs to be calculated at time of emission, so we don't emit any operands here.
Definition at line 422 of file DwarfExpression.cpp.
References assert(), llvm::dwarf::DW_OP_LLVM_entry_value, enableTemporaryBuffer(), EntryValue, IsEmittingEntryValue, LocationFlags, LocationKind, SavedLocationKind, and llvm::DIExpressionCursor::take().
Referenced by llvm::DwarfCompileUnit::addComplexAddress(), and llvm::DwarfDebug::emitDebugLocValue().
◆ cancelEntryValue()
| void DwarfExpression::cancelEntryValue ( ) | protected |
|---|
◆ commitTemporaryBuffer()
| virtual void llvm::DwarfExpression::commitTemporaryBuffer ( ) | protectedpure virtual |
|---|
Commit the data stored in the temporary buffer to the main output.
Referenced by finalizeEntryValue().
◆ disableTemporaryBuffer()
| virtual void llvm::DwarfExpression::disableTemporaryBuffer ( ) | protectedpure virtual |
|---|
◆ emitBaseTypeRef()
| virtual void llvm::DwarfExpression::emitBaseTypeRef ( uint64_t Idx) | protectedpure virtual |
|---|
◆ emitConstu()
| void DwarfExpression::emitConstu ( uint64_t Value) | protected |
|---|
◆ emitData1()
| virtual void llvm::DwarfExpression::emitData1 ( uint8_t Value) | protectedpure virtual |
|---|
◆ emitLegacySExt()
| void DwarfExpression::emitLegacySExt | ( | unsigned | FromBits | ) |
|---|
◆ emitLegacyZExt()
| void DwarfExpression::emitLegacyZExt | ( | unsigned | FromBits | ) |
|---|
◆ emitOp()
| virtual void llvm::DwarfExpression::emitOp ( uint8_t Op, const char * Comment = nullptr ) | protectedpure virtual |
|---|
Output a dwarf operand and an optional assembler comment.
Referenced by addAnd(), addBooleanConstant(), addBReg(), addConstantFP(), addExpression(), addFBReg(), addMachineRegExpression(), addOpPiece(), addReg(), addShr(), addSignedConstant(), addStackValue(), addWasmLocation(), emitConstu(), emitLegacySExt(), emitLegacyZExt(), and finalizeEntryValue().
◆ emitSigned()
| virtual void llvm::DwarfExpression::emitSigned ( int64_t Value) | protectedpure virtual |
|---|
◆ emitUnsigned()
| virtual void llvm::DwarfExpression::emitUnsigned ( uint64_t Value) | protectedpure virtual |
|---|
◆ enableTemporaryBuffer()
| virtual void llvm::DwarfExpression::enableTemporaryBuffer ( ) | protectedpure virtual |
|---|
Start emitting data to the temporary buffer.
The data stored in the temporary buffer can be committed to the main output using commitTemporaryBuffer().
Referenced by beginEntryValueExpression().
◆ finalize()
| void DwarfExpression::finalize | ( | ) |
|---|
◆ finalizeEntryValue()
| void DwarfExpression::finalizeEntryValue ( ) | protected |
|---|
Finalize an entry value by emitting its size operand, and committing the DWARF block which has been emitted to the temporary buffer.
Definition at line 438 of file DwarfExpression.cpp.
References assert(), commitTemporaryBuffer(), disableTemporaryBuffer(), emitOp(), emitUnsigned(), EntryValue, getTemporaryBufferSize(), IsEmittingEntryValue, LocationFlags, LocationKind, SavedLocationKind, and Size.
Referenced by addMachineRegExpression().
◆ getOrCreateBaseType()
◆ getTemporaryBufferSize()
| virtual unsigned llvm::DwarfExpression::getTemporaryBufferSize ( ) | protectedpure virtual |
|---|
◆ isEntryValue()
| bool llvm::DwarfExpression::isEntryValue ( ) const | inline |
|---|
◆ isFrameRegister()
◆ isImplicitLocation()
| bool llvm::DwarfExpression::isImplicitLocation ( ) const | inline |
|---|
◆ isIndirect()
| bool llvm::DwarfExpression::isIndirect ( ) const | inline |
|---|
◆ isMemoryLocation()
| bool llvm::DwarfExpression::isMemoryLocation ( ) const | inline |
|---|
◆ isParameterValue()
| bool llvm::DwarfExpression::isParameterValue ( ) | inline |
|---|
◆ isRegisterLocation()
| bool llvm::DwarfExpression::isRegisterLocation ( ) const | inline |
|---|
◆ isUnknownLocation()
| bool llvm::DwarfExpression::isUnknownLocation ( ) const | inline |
|---|
◆ maskSubRegister()
| void DwarfExpression::maskSubRegister ( ) | protected |
|---|
◆ setCallSiteParamValueFlag()
| void llvm::DwarfExpression::setCallSiteParamValueFlag ( ) | inline |
|---|
◆ setEntryValueFlags()
◆ setLocation()
◆ setMemoryLocationKind()
| void llvm::DwarfExpression::setMemoryLocationKind ( ) | inline |
|---|
◆ setSubRegisterPiece()
| void llvm::DwarfExpression::setSubRegisterPiece ( unsigned SizeInBits, unsigned OffsetInBits ) | inlineprotected |
|---|
◆ CU
◆ DwarfRegs
◆ DwarfVersion
| unsigned llvm::DwarfExpression::DwarfVersion | protected |
|---|
◆ IsEmittingEntryValue
| bool llvm::DwarfExpression::IsEmittingEntryValue = false | protected |
|---|
◆ LocationFlags
| unsigned llvm::DwarfExpression::LocationFlags | protected |
|---|
◆ LocationKind
| unsigned llvm::DwarfExpression::LocationKind | protected |
|---|
Definition at line 87 of file DwarfExpression.h.
Referenced by addBooleanConstant(), addExpression(), addMachineRegExpression(), addReg(), addSignedConstant(), addUnsignedConstant(), addUnsignedConstant(), addWasmLocation(), beginEntryValueExpression(), cancelEntryValue(), DwarfExpression(), finalizeEntryValue(), isImplicitLocation(), isMemoryLocation(), isRegisterLocation(), isUnknownLocation(), and setMemoryLocationKind().
◆ OffsetInBits
| uint64_t llvm::DwarfExpression::OffsetInBits = 0 | protected |
|---|
◆ SavedLocationKind
| unsigned llvm::DwarfExpression::SavedLocationKind | protected |
|---|
◆ SubRegisterOffsetInBits
| unsigned llvm::DwarfExpression::SubRegisterOffsetInBits | protected |
|---|
◆ SubRegisterSizeInBits
| unsigned llvm::DwarfExpression::SubRegisterSizeInBits | protected |
|---|
◆ TagOffset
std::optional<uint8_t> llvm::DwarfExpression::TagOffset
The documentation for this class was generated from the following files:
- lib/CodeGen/AsmPrinter/DwarfExpression.h
- lib/CodeGen/AsmPrinter/DwarfExpression.cpp