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::virt_reg_by_reg() 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::set_weight() 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::set_home_id_hint() 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

Constants

uint32_t VirtReg::id() constnodiscardnoexcept[¶]

Returns the virtual register id.

RegType VirtReg::reg_type() constnodiscardnoexcept[¶]

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

VirtRegFlags VirtReg::reg_flags() constnodiscardnoexcept[¶]

Returns a virtual register flags.

uint32_t VirtReg::virt_size() constnodiscardnoexcept[¶]

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 register_size().

uint32_t VirtReg::alignment() constnodiscardnoexcept[¶]

Returns the virtual register alignment required for memory operations (load/spill).

TypeId VirtReg::type_id() constnodiscardnoexcept[¶]

Returns the virtual register type id.

uint32_t VirtReg::weight() constnodiscardnoexcept[¶]

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

void VirtReg::set_weight(
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::is_fixed() constnodiscardnoexcept[¶]

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::is_stack_area() constnodiscardnoexcept[¶]

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::has_stack_slot() constnodiscardnoexcept[¶]

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::assign_stack_slot(
int32_t stack_offset
)noexcept[¶]

Assigns a stack offset of this virtual register to stack_offset and adds VirtRegFlags::kHasStackSlot flag.

bool VirtReg::has_home_id_hint() constnodiscardnoexcept[¶]

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

uint32_t VirtReg::home_id_hint() constnodiscardnoexcept[¶]

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

void VirtReg::set_home_id_hint(
uint32_t home_id
)noexcept[¶]

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

void VirtReg::reset_home_id_hint()noexcept[¶]

Resets a physical register hint.

int32_t VirtReg::stack_offset() constnodiscardnoexcept[¶]

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 has_stack_slot(). The return value will be zero when the stack offset was not assigned.

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

Returns the virtual register name.

uint32_t VirtReg::name_size() constnodiscardnoexcept[¶]

Returns the size of the virtual register name.

bool VirtReg::has_work_reg() constnodiscardnoexcept[¶]

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

RAWorkReg* VirtReg::work_reg() constnodiscardnoexcept[¶]

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

void VirtReg::set_work_reg(
RAWorkReg* work_reg
)noexcept[¶]

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

void VirtReg::reset_work_reg()noexcept[¶]

Reset the RAWorkReg association (used by register allocator).

uint32_t VirtReg::_id = 0[¶]

Virtual register id.

uint32_t VirtReg::_virt_size = 0[¶]

Virtual register size (can be smaller than a real register size if only a part of the register is used).

RegType VirtReg::_reg_type = RegType::kNone[¶]

Virtual register type.

VirtRegFlags VirtReg::_reg_flags = VirtRegFlags::kNone[¶]

Virtual register flags.

uint8_t VirtReg::_weight = 0[¶]

Virtual register weight.

Weight is used for alloc/spill decisions. Higher weight means a higher priority to keep the virtual register always allocated as a physical register. The default weight is zero, which means standard weight (no weight is added to the initial priority, which is calculated based on the number of uses divided by the sum of widths of all live spans).

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

Type id.

uint8_t VirtReg::_home_id_hint = Reg::kIdBad[¶]

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

int32_t VirtReg::_stack_offset = 0[¶]

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

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

Virtual register name (either empty or user provided).

RAWorkReg* VirtReg::_work_reg = nullptr[¶]

Reference to RAWorkReg, used during register allocation.