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:106

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 SavedLocationKind
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:286

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:261

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:229

Parameters

int DwarfReg
int Offset

void addConstantFP(const llvm::APFloat& Value,
                   const llvm::AsmPrinter& AP)

Description

Emit an floating point constant.

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

Parameters

const llvm::APFloat& Value
const llvm::AsmPrinter& AP

bool addExpression(
    llvm::DIExpressionCursor&& Expr,
    llvm::function_ref<bool(unsigned int,
                            DIExpressionCursor&)>
        InsertArg)

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

Parameters

llvm::DIExpressionCursor&& Expr
llvm::function_ref<bool(unsigned int, DIExpressionCursor&)> InsertArg

Returns

false if any call to (\p InsertArg) returns false.

void addExpression(
    llvm::DIExpressionCursor&& Expr)

Description

Emit all remaining operations in the DIExpressionCursor. The cursor must not contain any DW_OP_LLVM_arg operations.

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

Parameters

llvm::DIExpressionCursor&& Expr

void addFBReg(int Offset)

Description

Emit DW_OP_fbreg <Offset >.

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

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:357

Parameters

const llvm::DIExpression* Expr

bool addMachineReg(
    const llvm::TargetRegisterInfo& TRI,
    llvm::Register 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:249

Parameters

const llvm::TargetRegisterInfo& TRI
llvm::Register 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,
    llvm::Register 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:328

Parameters

const llvm::TargetRegisterInfo& TRI
llvm::DIExpressionCursor& Expr
llvm::Register 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:255

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:226

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:258

Parameters

unsigned int ShiftBy

void addSignedConstant(int64_t Value)

Description

Emit a signed constant.

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

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:274

void addUnsignedConstant(uint64_t Value)

Description

Emit an unsigned constant.

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

Parameters

uint64_t Value

void addUnsignedConstant(const llvm::APInt& Value)

Description

Emit an unsigned constant.

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

Parameters

const llvm::APInt& Value

void addWasmLocation(unsigned int Index,
                     uint64_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:364

Parameters

unsigned int Index
uint64_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:337

Parameters

llvm::DIExpressionCursor& ExprCursor

void cancelEntryValue()

Description

Cancel the emission of an entry value.

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

virtual void commitTemporaryBuffer()

Description

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

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

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:207

virtual void emitBaseTypeRef(uint64_t Idx)

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

Parameters

uint64_t Idx

void emitConstu(uint64_t Value)

Description

Emit a normalized unsigned constant.

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

Parameters

uint64_t Value

virtual void emitData1(uint8_t Value)

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

Parameters

uint8_t Value

void emitLegacySExt(unsigned int FromBits)

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

Parameters

unsigned int FromBits

void emitLegacyZExt(unsigned int FromBits)

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

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:188

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:191

Parameters

int64_t Value

virtual void emitUnsigned(uint64_t Value)

Description

Emit a raw unsigned value.

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

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:203

void finalize()

Description

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

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

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:278

unsigned int getOrCreateBaseType(
    unsigned int BitSize,
    dwarf::TypeKind Encoding)

Description

Return the index of a base type with the given properties and create one if necessary.

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

Parameters

unsigned int BitSize
dwarf::TypeKind Encoding

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:211

bool isEntryValue() const

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

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

Description

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

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

Parameters

const llvm::TargetRegisterInfo& TRI
llvm::Register MachineReg

bool isImplicitLocation() const

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

bool isIndirect() const

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

bool isMemoryLocation() const

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

bool isParameterValue()

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

bool isRegisterLocation() const

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

bool isUnknownLocation() const

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

void maskSubRegister()

Description

Add masking operations to stencil out a subregister.

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

void setCallSiteParamValueFlag()

Description

Lock this down to become a call site parameter location.

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

void setEntryValueFlags(
    const llvm::MachineLocation& Loc)

Description

Lock this down to become an entry value location.

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

Parameters

const llvm::MachineLocation& Loc

void setLocation(const llvm::MachineLocation& Loc,
                 const llvm::DIExpression* DIExpr)

Description

Set the location (\p Loc) and \ref DIExpression (\p DIExpr) to describe.

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

Parameters

const llvm::MachineLocation& Loc
const llvm::DIExpression* DIExpr

void setMemoryLocationKind()

Description

Lock this down to become a memory location description.

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

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:178

Parameters

unsigned int SizeInBits
unsigned int OffsetInBits

~DwarfExpression()

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