class DwarfExpression

Declaration

class DwarfExpression { /* full declaration omitted */ };

Description

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.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:105

Member Variables

protected bool IsEmittingEntryValue = false
Whether we are currently emitting an entry value operation.
protected llvm::DwarfCompileUnit& CU
protected SmallVector<llvm::DwarfExpression::Register, 2> DwarfRegs
The register location, if any.
protected uint64_t OffsetInBits = 0
Current Fragment Offset in Bits.
protected unsigned int SubRegisterSizeInBits
Sometimes we need to add a DW_OP_bit_piece to describe a subregister.
protected unsigned int SubRegisterOffsetInBits
protected unsigned int LocationKind
protected unsigned int LocationFlags
protected unsigned int DwarfVersion
public Optional<uint8_t> TagOffset

Method Overview

Methods

DwarfExpression(unsigned int DwarfVersion,
                llvm::DwarfCompileUnit& CU)

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:273

Parameters

unsigned int DwarfVersion
llvm::DwarfCompileUnit& CU

void addAnd(unsigned int Mask)

Description

Emit a bitwise and dwarf operation.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:251

Parameters

unsigned int Mask

void addBReg(int DwarfReg, int Offset)

Description

Emit a DW_OP_breg operation.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:219

Parameters

int DwarfReg
int Offset

void addExpression(
    llvm::DIExpressionCursor&& Expr,
    unsigned int FragmentOffsetInBits = 0)

Description

Emit all remaining operations in the DIExpressionCursor.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:331

Parameters

llvm::DIExpressionCursor&& Expr
unsigned int FragmentOffsetInBits = 0
If this is one fragment out of multiple locations, this is the offset of the fragment inside the entire variable.

void addFBReg(int Offset)

Description

Emit DW_OP_fbreg <Offset >.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:222

Parameters

int Offset

void addFragmentOffset(
    const llvm::DIExpression* Expr)

Description

If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by \c Expr.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:336

Parameters

const llvm::DIExpression* Expr

bool addMachineReg(
    const llvm::TargetRegisterInfo& TRI,
    unsigned int MachineReg,
    unsigned int MaxSize = ~1U)

Description

Emit a partial DWARF register operation. 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.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:239

Parameters

const llvm::TargetRegisterInfo& TRI
unsigned int MachineReg
The register number.
unsigned int MaxSize = ~1U
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.

Returns

false if no DWARF register exists for MachineReg.

bool addMachineRegExpression(
    const llvm::TargetRegisterInfo& TRI,
    llvm::DIExpressionCursor& Expr,
    unsigned int MachineReg,
    unsigned int FragmentOffsetInBits = 0)

Description

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.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:316

Parameters

const llvm::TargetRegisterInfo& TRI
llvm::DIExpressionCursor& Expr
unsigned int MachineReg
unsigned int FragmentOffsetInBits = 0
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.

void addOpPiece(unsigned int SizeInBits,
                unsigned int OffsetInBits = 0)

Description

Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:245

Parameters

unsigned int SizeInBits
unsigned int OffsetInBits = 0
This is an optional offset into the location that is at the top of the DWARF stack.

void addReg(int DwarfReg,
            const char* Comment = nullptr)

Description

Emit a DW_OP_reg operation. Note that this is only legal inside a DWARF register location description.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:216

Parameters

int DwarfReg
const char* Comment = nullptr

void addShr(unsigned int ShiftBy)

Description

Emit a shift-right dwarf operation.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:248

Parameters

unsigned int ShiftBy

void addSignedConstant(int64_t Value)

Description

Emit a signed constant.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:282

Parameters

int64_t Value

void addStackValue()

Description

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 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.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:264

void addUnsignedConstant(const llvm::APInt& Value)

Description

Emit an unsigned constant.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:288

Parameters

const llvm::APInt& Value

void addUnsignedConstant(uint64_t Value)

Description

Emit an unsigned constant.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:285

Parameters

uint64_t Value

void addWasmLocation(unsigned int Index,
                     int64_t Offset)

Description

Emit location information expressed via WebAssembly location + offset The Index is an identifier for locals, globals or operand stack.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:343

Parameters

unsigned int Index
int64_t Offset

void beginEntryValueExpression(
    llvm::DIExpressionCursor& ExprCursor)

Description

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.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:324

Parameters

llvm::DIExpressionCursor& ExprCursor

virtual void commitTemporaryBuffer()

Description

Commit the data stored in the temporary buffer to the main output.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:205

virtual void disableTemporaryBuffer()

Description

Disable emission to the temporary buffer. This does not commit data in the temporary buffer to the main output.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:198

virtual void emitBaseTypeRef(uint64_t Idx)

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:189

Parameters

uint64_t Idx

void emitConstu(uint64_t Value)

Description

Emit a normalized unsigned constant.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:208

Parameters

uint64_t Value

virtual void emitData1(uint8_t Value)

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:187

Parameters

uint8_t Value

void emitLegacySExt(unsigned int FromBits)

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:338

Parameters

unsigned int FromBits

void emitLegacyZExt(unsigned int FromBits)

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:339

Parameters

unsigned int FromBits

virtual void emitOp(uint8_t Op,
                    const char* Comment = nullptr)

Description

Output a dwarf operand and an optional assembler comment.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:179

Parameters

uint8_t Op
const char* Comment = nullptr

virtual void emitSigned(int64_t Value)

Description

Emit a raw signed value.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:182

Parameters

int64_t Value

virtual void emitUnsigned(uint64_t Value)

Description

Emit a raw unsigned value.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:185

Parameters

uint64_t Value

virtual void enableTemporaryBuffer()

Description

Start emitting data to the temporary buffer. The data stored in the temporary buffer can be committed to the main output using commitTemporaryBuffer().

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:194

void finalize()

Description

This needs to be called last to commit any pending changes.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:279

void finalizeEntryValue()

Description

Finalize an entry value by emitting its size operand, and committing the DWARF block which has been emitted to the temporary buffer.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:268

virtual unsigned int getTemporaryBufferSize()

Description

Return the emitted size, in number of bytes, for the data stored in the temporary buffer.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:202

bool isEntryValue() const

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:156

virtual bool isFrameRegister(
    const llvm::TargetRegisterInfo& TRI,
    unsigned int MachineReg)

Description

Return whether the given machine register is the frame register in the current function.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:212

Parameters

const llvm::TargetRegisterInfo& TRI
unsigned int MachineReg

bool isImplicitLocation() const

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:152

bool isMemoryLocation() const

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:144

bool isParameterValue()

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:160

bool isRegisterLocation() const

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:148

bool isUnknownLocation() const

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:140

void maskSubRegister()

Description

Add masking operations to stencil out a subregister.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:176

void setCallSiteParamValueFlag()

Description

Lock this down to become a call site parameter location.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:302

void setEntryValueFlag()

Description

Lock this down to become an entry value location.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:297

void setMemoryLocationKind()

Description

Lock this down to become a memory location description.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:291

void setSubRegisterPiece(
    unsigned int SizeInBits,
    unsigned int OffsetInBits)

Description

Push a DW_OP_piece / DW_OP_bit_piece for emitting later, if one is needed to represent a subregister.

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:169

Parameters

unsigned int SizeInBits
unsigned int OffsetInBits

~DwarfExpression()

Declared at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h:270