|
LLVM
4.0.0
|
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 <DwarfExpression.h>
Public Member Functions | |
| DwarfExpression (unsigned DwarfVersion) | |
| virtual | ~DwarfExpression () |
| void | finalize () |
| This needs to be called last to commit any pending changes. More... | |
| virtual void | EmitOp (uint8_t Op, const char *Comment=nullptr)=0 |
| Output a dwarf operand and an optional assembler comment. More... | |
| virtual void | EmitSigned (int64_t Value)=0 |
| Emit a raw signed value. More... | |
| virtual void | EmitUnsigned (uint64_t Value)=0 |
| Emit a raw unsigned value. More... | |
| virtual bool | isFrameRegister (const TargetRegisterInfo &TRI, unsigned MachineReg)=0 |
| Return whether the given machine register is the frame register in the current function. More... | |
| void | AddReg (int DwarfReg, const char *Comment=nullptr) |
| Emit a dwarf register operation. More... | |
| void | AddRegIndirect (int DwarfReg, int Offset, bool Deref=false) |
| Emit an (double-)indirect dwarf register operation. More... | |
| void | AddOpPiece (unsigned SizeInBits, unsigned OffsetInBits=0) |
| Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment. More... | |
| void | AddShr (unsigned ShiftBy) |
| Emit a shift-right dwarf expression. More... | |
| void | AddStackValue () |
| Emit a DW_OP_stack_value, if supported. More... | |
| bool | AddMachineRegIndirect (const TargetRegisterInfo &TRI, unsigned MachineReg, int Offset=0) |
| Emit an indirect dwarf register operation for the given machine register. More... | |
| bool | AddMachineReg (const TargetRegisterInfo &TRI, unsigned MachineReg, unsigned MaxSize=~1U) |
| Emit a partial DWARF register operation. More... | |
| void | AddSignedConstant (int64_t Value) |
| Emit a signed constant. More... | |
| void | AddUnsignedConstant (uint64_t Value) |
| Emit an unsigned constant. More... | |
| void | AddUnsignedConstant (const APInt &Value) |
| Emit an unsigned constant. More... | |
| bool | AddMachineRegExpression (const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, unsigned MachineReg, unsigned FragmentOffsetInBits=0) |
| Emit a machine register location. More... | |
| void | AddExpression (DIExpressionCursor &&Expr, unsigned FragmentOffsetInBits=0) |
| Emit all remaining operations in the DIExpressionCursor. More... | |
| 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. 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. More... | |
Protected Attributes | |
| unsigned | DwarfVersion |
| uint64_t | OffsetInBits = 0 |
| Current Fragment Offset in Bits. More... | |
| unsigned | SubRegisterSizeInBits = 0 |
| Sometimes we need to add a DW_OP_bit_piece to describe a subregister. More... | |
| unsigned | SubRegisterOffsetInBits = 0 |
Base class containing the logic for constructing DWARF expressions independently of whether they are emitted into a DIE or into a .debug_loc entry.
Definition at line 85 of file DwarfExpression.h.
|
inline |
Definition at line 103 of file DwarfExpression.h.
|
inlinevirtual |
Definition at line 104 of file DwarfExpression.h.
| void DwarfExpression::AddExpression | ( | DIExpressionCursor && | Expr, |
| unsigned | FragmentOffsetInBits = 0 |
||
| ) |
Emit all remaining operations in the DIExpressionCursor.
| FragmentOffsetInBits | If this is one fragment out of multiple locations, this is the offset of the fragment inside the entire variable. |
Definition at line 231 of file DwarfExpression.cpp.
References AddOpPiece(), AddStackValue(), assert(), llvm::dwarf::DW_OP_LLVM_fragment, EmitOp(), EmitUnsigned(), llvm_unreachable, OffsetInBits, setSubRegisterPiece(), SubRegisterOffsetInBits, and SubRegisterSizeInBits.
Referenced by llvm::DwarfUnit::addBlockByrefAddress(), llvm::DwarfCompileUnit::addComplexAddress(), and emitDebugLocValue().
| void DwarfExpression::addFragmentOffset | ( | const DIExpression * | Expr | ) |
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Expr.
Definition at line 289 of file DwarfExpression.cpp.
References AddOpPiece(), assert(), llvm::DIExpression::getFragmentInfo(), llvm::DIExpression::isFragment(), and OffsetInBits.
Referenced by llvm::DwarfCompileUnit::addComplexAddress(), and emitDebugLocValue().
| bool DwarfExpression::AddMachineReg | ( | const TargetRegisterInfo & | TRI, |
| unsigned | MachineReg, | ||
| unsigned | MaxSize = ~1U |
||
| ) |
Emit a partial DWARF register operation.
| 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.
Definition at line 88 of file DwarfExpression.cpp.
References AddOpPiece(), AddReg(), llvm::SmallBitVector::any(), llvm::MCRegisterInfo::getDwarfRegNum(), llvm::TargetRegisterInfo::getMinimalPhysRegClass(), llvm::TargetRegisterClass::getSize(), llvm::MCRegisterInfo::getSubRegIdxOffset(), llvm::MCRegisterInfo::getSubRegIdxSize(), llvm::MCRegisterInfo::getSubRegIndex(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::MCRegisterInfo::DiffListIterator::isValid(), Offset, llvm::SmallBitVector::set(), and setSubRegisterPiece().
Referenced by llvm::DwarfCompileUnit::addAddress(), llvm::DwarfUnit::addBlockByrefAddress(), and AddMachineRegExpression().
| bool DwarfExpression::AddMachineRegExpression | ( | const TargetRegisterInfo & | TRI, |
| DIExpressionCursor & | Expr, | ||
| unsigned | MachineReg, | ||
| unsigned | FragmentOffsetInBits = 0 |
||
| ) |
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.
| FragmentOffsetInBits | If this is one fragment out of a fragmented location, this is the offset of the fragment inside the entire variable. |
Definition at line 189 of file DwarfExpression.cpp.
References AddMachineReg(), AddMachineRegIndirect(), llvm::DIExpressionCursor::consume(), llvm::DIExpressionCursor::getFragmentInfo(), N, Offset, llvm::DIExpressionCursor::peek(), llvm::DIExpressionCursor::peekNext(), and llvm::DIExpressionCursor::take().
Referenced by llvm::DwarfCompileUnit::addComplexAddress(), and emitDebugLocValue().
| bool DwarfExpression::AddMachineRegIndirect | ( | const TargetRegisterInfo & | TRI, |
| unsigned | MachineReg, | ||
| int | Offset = 0 |
||
| ) |
Emit an indirect dwarf register operation for the given machine register.
Definition at line 71 of file DwarfExpression.cpp.
References AddRegIndirect(), EmitOp(), EmitSigned(), llvm::MCRegisterInfo::getDwarfRegNum(), and isFrameRegister().
Referenced by llvm::DwarfCompileUnit::addAddress(), llvm::DwarfUnit::addBlockByrefAddress(), llvm::DwarfCompileUnit::addComplexAddress(), AddMachineRegExpression(), and emitDebugLocValue().
Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment.
| OffsetInBits | This is an optional offset into the location that is at the top of the DWARF stack. |
Definition at line 48 of file DwarfExpression.cpp.
References EmitOp(), and EmitUnsigned().
Referenced by AddExpression(), addFragmentOffset(), AddMachineReg(), AddUnsignedConstant(), and finalize().
| void DwarfExpression::AddReg | ( | int | DwarfReg, |
| const char * | Comment = nullptr |
||
| ) |
Emit a dwarf register operation.
Definition at line 25 of file DwarfExpression.cpp.
References assert(), EmitOp(), and EmitUnsigned().
Referenced by AddMachineReg().
Emit an (double-)indirect dwarf register operation.
Definition at line 35 of file DwarfExpression.cpp.
References assert(), EmitOp(), EmitSigned(), and EmitUnsigned().
Referenced by AddMachineRegIndirect().
| void DwarfExpression::AddShr | ( | unsigned | ShiftBy | ) |
Emit a shift-right dwarf expression.
Definition at line 65 of file DwarfExpression.cpp.
References EmitOp(), and EmitUnsigned().
| void DwarfExpression::AddSignedConstant | ( | int64_t | Value | ) |
Emit a signed constant.
Definition at line 161 of file DwarfExpression.cpp.
References AddStackValue(), EmitOp(), and EmitSigned().
Referenced by emitDebugLocValue().
| void DwarfExpression::AddStackValue | ( | ) |
Emit a DW_OP_stack_value, if supported.
The proper way to describe a constant value is DW_OP_constu <const>, DW_OP_stack_value. Unfortunately, DW_OP_stack_value was not available until DWARF 4, so we will continue to generate DW_OP_constu <const> for DWARF 2 and DWARF 3. Technically, this is incorrect since DW_OP_const <const> actually describes a value at a constant addess, 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 156 of file DwarfExpression.cpp.
References DwarfVersion, and EmitOp().
Referenced by AddExpression(), AddSignedConstant(), and AddUnsignedConstant().
| void DwarfExpression::AddUnsignedConstant | ( | uint64_t | Value | ) |
Emit an unsigned constant.
Definition at line 167 of file DwarfExpression.cpp.
References AddStackValue(), EmitOp(), and EmitUnsigned().
Referenced by AddUnsignedConstant(), and emitDebugLocValue().
Emit an unsigned constant.
Definition at line 173 of file DwarfExpression.cpp.
References AddOpPiece(), AddUnsignedConstant(), llvm::APInt::getBitWidth(), llvm::APInt::getRawData(), fuzzer::min(), and Offset.
|
pure virtual |
Output a dwarf operand and an optional assembler comment.
Implemented in llvm::DIEDwarfExpression, and llvm::DebugLocDwarfExpression.
Referenced by AddExpression(), AddMachineRegIndirect(), AddOpPiece(), AddReg(), AddRegIndirect(), AddShr(), AddSignedConstant(), AddStackValue(), and AddUnsignedConstant().
|
pure virtual |
Emit a raw signed value.
Implemented in llvm::DIEDwarfExpression, and llvm::DebugLocDwarfExpression.
Referenced by AddMachineRegIndirect(), AddRegIndirect(), and AddSignedConstant().
|
pure virtual |
Emit a raw unsigned value.
Implemented in llvm::DIEDwarfExpression, and llvm::DebugLocDwarfExpression.
Referenced by AddExpression(), AddOpPiece(), AddReg(), AddRegIndirect(), AddShr(), and AddUnsignedConstant().
| void DwarfExpression::finalize | ( | ) |
This needs to be called last to commit any pending changes.
Definition at line 284 of file DwarfExpression.cpp.
References AddOpPiece(), SubRegisterOffsetInBits, and SubRegisterSizeInBits.
Referenced by llvm::DIEDwarfExpression::finalize().
|
pure virtual |
Return whether the given machine register is the frame register in the current function.
Implemented in llvm::DIEDwarfExpression, and llvm::DebugLocDwarfExpression.
Referenced by AddMachineRegIndirect().
|
inlineprotected |
Push a DW_OP_piece / DW_OP_bit_piece for emitting later, if one is needed to represent a subregister.
Definition at line 97 of file DwarfExpression.h.
References OffsetInBits, SubRegisterOffsetInBits, and SubRegisterSizeInBits.
Referenced by AddExpression(), and AddMachineReg().
|
protected |
Definition at line 87 of file DwarfExpression.h.
Referenced by AddStackValue().
|
protected |
Current Fragment Offset in Bits.
Definition at line 89 of file DwarfExpression.h.
Referenced by AddExpression(), addFragmentOffset(), and setSubRegisterPiece().
|
protected |
Definition at line 93 of file DwarfExpression.h.
Referenced by AddExpression(), finalize(), and setSubRegisterPiece().
|
protected |
Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
Definition at line 92 of file DwarfExpression.h.
Referenced by AddExpression(), finalize(), and setSubRegisterPiece().
1.8.6