IndexCompilerasmjit::VirtReg

asmjit::VirtReg Class Reference [¶]

Public virtual register interface, managed by BaseCompiler.

When a virtual register is created by BaseCompiler a VirtReg is linked with the register operand id it returns. This VirtReg can be accessed via BaseCompiler::virtRegByReg() function, which returns a pointer to VirtReg.

In general, VirtReg should be only introspected as it contains important variables that are needed and managed by AsmJit, however, the VirtReg API can also be used to influence register allocation. For example there is a VirtReg::setWeight() function, which could be used to increase a weight of a virtual register (thus make it hard to spill, for example). In addition, there is a VirtReg::setHomeIdHint() function, which can be used to do an initial assignment of a physical register of a virtual register. However, AsmJit could still override the physical register assigned in some special cases.

Public Members

Members

Member Functions

Construction & Destruction
Accessors

uint32_t VirtReg::id() constnoexcept[¶]

Returns the virtual register id.

const char* VirtReg::name() constnoexcept[¶]

Returns the virtual register name.

uint32_t VirtReg::nameSize() constnoexcept[¶]

Returns the size of the virtual register name.

OperandSignature VirtReg::signature() constnoexcept[¶]

Returns a register signature of this virtual register.

RegType VirtReg::type() constnoexcept[¶]

Returns a virtual register type (maps to the physical register type as well).

RegGroup VirtReg::group() constnoexcept[¶]

Returns a virtual register group (maps to the physical register group as well).

uint32_t VirtReg::regSize() constnoexcept[¶]

Returns a real size of the register this virtual register maps to.

For example if this is a 128-bit SIMD register used for a scalar single precision floating point value then its virtSize would be 4, however, the regSize would still say 16 (128-bits), because it's the smallest size of that register type.

uint32_t VirtReg::virtSize() constnoexcept[¶]

Returns the virtual register size.

The virtual register size describes how many bytes the virtual register needs to store its content. It can be smaller than the physical register size, see regSize().

uint32_t VirtReg::alignment() constnoexcept[¶]

Returns the virtual register alignment.

TypeId VirtReg::typeId() constnoexcept[¶]

Returns the virtual register type id.

uint32_t VirtReg::weight() constnoexcept[¶]

Returns the virtual register weight - the register allocator can use it as explicit hint for alloc/spill decisions.

void VirtReg::setWeight(
uint32_t weight
)noexcept[¶]

Sets the virtual register weight (0 to 255) - the register allocator can use it as explicit hint for alloc/spill decisions and initial bin-packing.

bool VirtReg::isFixed() constnoexcept[¶]

Returns whether the virtual register is always allocated to a fixed physical register (and never reallocated).

Note
This is only used for special purposes and it's mostly internal.

bool VirtReg::isStack() constnoexcept[¶]

Tests whether the virtual register is in fact a stack that only uses the virtual register id.

Note
It's an error if a stack is accessed as a register.

bool VirtReg::hasStackSlot() constnoexcept[¶]

Tests whether this virtual register (or stack) has assigned a stack offset.

If this is a virtual register that was never allocated on stack, it would return false, otherwise if it's a virtual register that was spilled or explicitly allocated stack, the return value would be true.

void VirtReg::assignStackSlot(
int32_t stackOffset
)noexcept[¶]

Assigns a stack offset of this virtual register to stackOffset and sets _hasStackSlot to true.

bool VirtReg::hasHomeIdHint() constnoexcept[¶]

Tests whether this virtual register has assigned a physical register as a hint to the register allocator.

uint32_t VirtReg::homeIdHint() constnoexcept[¶]

Returns a physical register hint, which will be used by the register allocator.

void VirtReg::setHomeIdHint(
uint32_t homeId
)noexcept[¶]

Assigns a physical register hint, which will be used by the register allocator.

void VirtReg::resetHomeIdHint()noexcept[¶]

Resets a physical register hint.

int32_t VirtReg::stackOffset() constnoexcept[¶]

Returns a stack offset associated with a virtual register or explicit stack allocation.

Note
Always verify that the stack offset has been assigned by calling hasStackSlot(). The return value will be zero when the stack offset was not assigned.

bool VirtReg::hasWorkReg() constnoexcept[¶]

Tests whether the virtual register has an associated RAWorkReg at the moment.

RAWorkReg* VirtReg::workReg() constnoexcept[¶]

Returns an associated RAWorkReg with this virtual register (only valid during register allocation).

void VirtReg::setWorkReg(
RAWorkReg* workReg
)noexcept[¶]

Associates a RAWorkReg with this virtual register (used by register allocator).

void VirtReg::resetWorkReg()noexcept[¶]

Reset the RAWorkReg association (used by register allocator).

OperandSignature VirtReg::_signature {}[¶]

Virtual register signature.

uint32_t VirtReg::_id = 0[¶]

Virtual register id.

uint32_t VirtReg::_virtSize = 0[¶]

Virtual register size (can be smaller than _signature._size).

uint8_t VirtReg::_alignment = 0[¶]

Virtual register alignment (for spilling).

TypeId VirtReg::_typeId = TypeId::kVoid[¶]

Type-id.

uint8_t VirtReg::_weight = 1[¶]

Virtual register weight for alloc/spill decisions.

uint8_t VirtReg::_isFixed[¶]

True if this is a fixed register, never reallocated.

uint8_t VirtReg::_isStack[¶]

True if the virtual register is only used as a stack (never accessed as register).

uint8_t VirtReg::_hasStackSlot[¶]

True if this virtual register has assigned stack offset (can be only valid after register allocation pass).

uint8_t VirtReg::_homeIdHint = BaseReg::kIdBad[¶]

Home register hint for the register allocator (initially unassigned).

int32_t VirtReg::_stackOffset = 0[¶]

Stack offset assigned by the register allocator relative to stack pointer (can be negative as well).

uint32_t VirtReg::_reservedU32 = 0[¶]

Reserved for future use (padding).

ZoneString<16>VirtReg::_name {}[¶]

Virtual register name (user provided or automatically generated).

RAWorkReg* VirtReg::_workReg = nullptr[¶]

Reference to RAWorkReg, used during register allocation.