IndexAssemblerasmjit::Operand_

asmjit::Operand_ Struct Reference [¶]

Inheritance diagram for asmjit::Operand_:
asmjit::Operand asmjit::BaseMem asmjit::BaseRegList asmjit::Imm asmjit::Label asmjit::Reg asmjit::a64::Mem asmjit::x86::Mem asmjit::RegListT< RegT > asmjit::UniGp asmjit::UniVec asmjit::x86::Bnd asmjit::x86::CReg asmjit::x86::DReg asmjit::x86::KReg asmjit::x86::Mm asmjit::x86::Rip asmjit::x86::SReg asmjit::x86::St asmjit::x86::Tmm

Base class representing an operand in AsmJit (non-default constructed version).

Contains no initialization code and can be used safely to define an array of operands that won't be initialized. This is a Operand base structure designed to be statically initialized, static const, or to be used by user code to define an array of operands without having them default initialized at construction time.

The key difference between Operand and Operand_ is:

Operand_ x_array[10]; // Not initialized, contains garbage.
Operand_ y_array[10] {}; // All operands initialized to none explicitly (zero initialized).
Operand y_array[10]; // All operands initialized to none implicitly (zero initialized).

Public Members

Members

Static Public Attributes

Constants

Public Types

Types

Member Functions

Construction & Destruction
Overloaded Operators
Cast
Equality
Generic Accessors
Register Accessors
Register-List Accessors
X86-Specific Accessors

Static Functions

bool Operand_::is_virt_id(
uint32_t virt_id
)constexprstaticnodiscardnoexcept[¶]

Tests whether the given id is a valid virtual register id. Since AsmJit supports both physical and virtual registers it must be able to distinguish between these two. The idea is that physical registers are always limited in size, so virtual identifiers start from kVirtIdMin and end at kVirtIdMax.

uint32_t Operand_::virt_index_to_virt_id(
uint32_t virt_index
)constexprstaticnodiscardnoexcept[¶]

Converts a real-id into a packed-id that can be stored in Operand.

uint32_t Operand_::virt_id_to_index(
uint32_t virt_id
)constexprstaticnodiscardnoexcept[¶]

Converts a packed-id back to real-id.

void Operand_::copy_from(
const Operand_& other
)constexprnoexcept[¶]

Initializes the operand from other operand (used by operator overloads).

void Operand_::reset()constexprnoexcept[¶]

Resets the Operand to none.

None operand is defined the following way:

  • Its signature is zero (OperandType::kNone, and the rest zero as well).
  • Its id is 0.
  • The reserved8_4 field is set to 0.
  • The reserved12_4 field is set to zero.

In other words, reset operands have all members set to zero. Reset operand must match the Operand state right after its construction. Alternatively, if you have an array of operands, you can simply use memset().

using namespace asmjit;
assert(a == b);
b = x86::eax;
assert(a != b);
b.reset();
assert(a == b);
memset(&b, 0, sizeof(Operand));
assert(a == b);

bool Operand_::operator==(
const Operand_& other
) constnodiscardconstexprnoexcept[¶]

Tests whether this operand is the same as other.

bool Operand_::operator!=(
const Operand_& other
) constnodiscardconstexprnoexcept[¶]

Tests whether this operand is not the same as other.

template<typename T>
T& Operand_::as()nodiscardconstexprnoexcept[1/2][¶]

Casts this operand to T type.

template<typename T>
const T& Operand_::as() constnodiscardconstexprnoexcept[2/2][¶]

Casts this operand to T type (const).

bool Operand_::equals(
const Operand_& other
) constnodiscardconstexprnoexcept[¶]

Tests whether the operand is 100% equal to other operand.

Note

This basically performs a binary comparison, if aby bit is different the operands are not equal.

Signature Operand_::signature() constnodiscardconstexprnoexcept[¶]

Returns operand signature as unsigned 32-bit integer.

Signature is first 4 bytes of the operand data. It's used mostly for operand checking as it's much faster to check packed 4 bytes at once than having to check these bytes individually.

bool Operand_::has_signature(
const Operand_& other
) constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the operand's signature matches the signature of the other operand.

bool Operand_::has_signature() constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the operand's signature matches the given signature sign.

void Operand_::set_signature(
const Signature& signature
)constexprnoexcept[1/2][¶]

Sets the operand signature, see signature().

Note

Improper use of set_signature() can lead to hard-to-debug errors.

void Operand_::set_signature(
uint32_t signature
)constexprnoexcept[2/2][¶]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

OperandType Operand_::op_type() constnodiscardconstexprnoexcept[¶]

Returns the type of the operand, see OpType.

bool Operand_::is_op_type() constnodiscardconstexprnoexcept[¶]

Tests whether the operand's type matches the given type.

bool Operand_::is_none() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is none (OperandType::kNone).

bool Operand_::is_reg() constnodiscardconstexprnoexcept[1/5][¶]

Tests whether the operand is a register (OperandType::kReg).

bool Operand_::is_reg_list() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the operand is a register-list.

Note

Register-list is currently only used by 32-bit ARM architecture.

bool Operand_::is_mem() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a memory location (OperandType::kMem).

bool Operand_::is_imm() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is an immediate (OperandType::kImm).

bool Operand_::is_label() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a label (OperandType::kLabel).

bool Operand_::is_reg_or_mem() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a register or memory.

Note

This is useful on X86 and X86_64 architectures as many instructions support Reg/Mem operand combination. So if the user code works with just Operand, it's possible to check whether the operand is either a register or memory location with a single check.

bool Operand_::is_reg_or_reg_list_or_mem() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a register, register-list, or memory.

Note

This is useful on 32-bit ARM architecture to check whether an operand references a register. It can be used in other architectures too, but it would work identically to is_reg_or_mem() as other architectures don't provide register lists.

uint32_t Operand_::id() constnodiscardconstexprnoexcept[¶]

Returns the operand id.

The value returned should be interpreted accordingly to the operand type:

  • None - Should be 0.
  • Reg - Physical or virtual register id.
  • Mem - Multiple meanings - BASE address (register or label id), or high value of a 64-bit absolute address.
  • Imm - Should be 0.
  • Label - Label id if it was created by using new_label() or Globals::kInvalidId if the label is invalid or not initialized.

bool Operand_::is_phys_reg() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a physical register.

bool Operand_::is_virt_reg() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a virtual register.

bool Operand_::is_reg(
RegType reg_type
) constnodiscardconstexprnoexcept[2/5][¶]

Tests whether the operand is a register matching the given register type.

bool Operand_::is_reg(
RegType reg_type,
uint32_t reg_id
) constnodiscardconstexprnoexcept[3/5][¶]

Tests whether the operand is register and of register type reg_type and reg_id.

bool Operand_::is_reg(
RegGroup reg_group
) constnodiscardconstexprnoexcept[4/5][¶]

Tests whether the operand is a register of the provided register group reg_group.

bool Operand_::is_reg(
RegGroup reg_group,
uint32_t reg_id
) constnodiscardconstexprnoexcept[5/5][¶]

Tests whether the operand is register and of register group reg_group and reg_id.

bool Operand_::is_pc() constnodiscardconstexprnoexcept[¶]

Tests whether the operand is a general purpose register of any type.

bool Operand_::is_gp() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the operand is a general purpose register of any type.

bool Operand_::is_gp(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the operand is a general purpose register of any type having the given id reg_id.

bool Operand_::is_gp8() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is an 8-bit low or high general purpose register (X86|X86_64).

bool Operand_::is_gp8(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is an 8-bit low or high general purpose register having the given id reg_id (X86|X86_64).

bool Operand_::is_gp8_lo() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is an 8-bit low general purpose register (X86|X86_64).

bool Operand_::is_gp8_lo(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is an 8-bit low general purpose register having the given id reg_id (X86|X86_64).

bool Operand_::is_gp8_hi() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is an 8-bit high general purpose register (X86|X86_64 only - AH, BH, CH, DH).

bool Operand_::is_gp8_hi(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is an 8-bit high general purpose register having the given id reg_id (X86|X86_64).

bool Operand_::is_gp16() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 16-bit general purpose register (X86|X86_64).

bool Operand_::is_gp16(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 16-bit general purpose register having the given id reg_id (X86|X86_64).

bool Operand_::is_gp32() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 32-bit general purpose register.

bool Operand_::is_gp32(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 32-bit general purpose register having the given id reg_id.

bool Operand_::is_gp64() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 64-bit general purpose register.

bool Operand_::is_gp64(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 64-bit general purpose register having the given id reg_id.

bool Operand_::is_vec() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a vector register of any size.

bool Operand_::is_vec(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a vector register of any size having the given id reg_id.

bool Operand_::is_vec8() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is an 8-bit vector register or view (AArch64).

bool Operand_::is_vec8(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is an 8-bit vector register or view having the given id reg_id (AArch64).

bool Operand_::is_vec16() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 16-bit vector register or view (AArch64).

bool Operand_::is_vec16(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 16-bit vector register or view having the given id reg_id (AArch64).

bool Operand_::is_vec32() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 32-bit vector register or view (AArch32, AArch64).

bool Operand_::is_vec32(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 32-bit vector register or view having the given id reg_id (AArch32/AArch64).

bool Operand_::is_vec64() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 64-bit vector register or view (AArch32/AArch64).

bool Operand_::is_vec64(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 64-bit vector register or view having the given id reg_id (AArch32/AArch64).

bool Operand_::is_vec128() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 128-bit vector register or view (X86|X86_64/AArch32/AArch64).

bool Operand_::is_vec128(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 128-bit vector register or view having the given id reg_id (X86|X86_64/AArch32/AArch64).

bool Operand_::is_vec256() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 256-bit vector register or view (X86|X86_64).

bool Operand_::is_vec256(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 256-bit vector register or view having the given id reg_id (X86|X86_64).

bool Operand_::is_vec512() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a 512-bit vector register or view (X86|X86_64).

bool Operand_::is_vec512(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a 512-bit vector register or view having the given id reg_id (X86|X86_64).

bool Operand_::is_mask_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a mask register of any size.

bool Operand_::is_mask_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a mask register of any size having the given id reg_id (X86|X86_64/AArch64).

bool Operand_::is_kreg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a mask register (K register on X86|X86_64) - alias of is_mask_reg().

bool Operand_::is_kreg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a mask register (K register on X86|X86_64) of any size having the given id reg_id (X86|X86_64/AArch64).

bool Operand_::is_tile_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a tile register.

bool Operand_::is_tile_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a tile register of the given id reg_id.

bool Operand_::is_tmm_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a tile register (TMM register on X86_64) - alias of is_tile_reg().

bool Operand_::is_tmm_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a tile register (TMM register on X86_64) of the given id reg_id - alias of is_tile_reg().

bool Operand_::is_segment_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a segment register (X86|X86_64).

bool Operand_::is_segment_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a segment register having the given id reg_id (X86|X86_64).

bool Operand_::is_control_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a control register (X86|X86_64).

bool Operand_::is_control_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a control register having the given id reg_id (X86|X86_64).

bool Operand_::is_debug_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a debug register (X86|X86_64).

bool Operand_::is_debug_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a debug register of the given id reg_id (X86|X86_64).

bool Operand_::is_mm_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is an MMX register (X86|X64).

bool Operand_::is_mm_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is an MMX register of the given id reg_id (X86|X64).

bool Operand_::is_st_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is an FPU register (ST register on X86|X86_64) (X86|X64).

bool Operand_::is_st_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is an FPU register (ST register on X86|X86_64) of the given id reg_id (X86|X64).

bool Operand_::is_bnd_reg() constnodiscardconstexprnoexcept[1/2][¶]

Tests whether the register is a BND register (X86|X64).

bool Operand_::is_bnd_reg(
uint32_t reg_id
) constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the register is a BND register of the given id reg_id (X86|X64).

bool Operand_::is_reg_list() constnodiscardconstexprnoexcept[2/2][¶]

Tests whether the operand is a register matching the given register type.

uint32_t Operand_::x86_rm_size() constnodiscardconstexprnoexcept[¶]

Returns a size of a register or an X86 memory operand.

Remarks

At the moment only X86 and X86_64 memory operands have a size - other memory operands can use bits that represent size as an additional payload. This means that memory size is architecture specific and should be accessed via x86::Mem::size(). Sometimes when the user knows that the operand is either a register or memory operand this function can be helpful as it avoids casting, but it only works when it targets X86 and X86_64.

uint32_t Operand_::kDataMemIndexId = 0staticconstexpr[¶]

Memory index offset in a _data[2] array.

uint32_t Operand_::kDataMemOffsetLo = 1staticconstexpr[¶]

Low 32-bit offset value a _data[2] array.

uint32_t Operand_::kDataImmValueLo = Support::ByteOrder::kNative == Support::ByteOrder::kLE ? 0 : 1staticconstexpr[¶]

Low 32-bit immediate value in a _data[2] array.

uint32_t Operand_::kDataImmValueHi = Support::ByteOrder::kNative == Support::ByteOrder::kLE ? 1 : 0staticconstexpr[¶]

High 32-bit immediate value in a _data[2] array.

uint32_t Operand_::kVirtIdMin = 256staticconstexpr[¶]

Minimum valid packed-id.

uint32_t Operand_::kVirtIdMax = Globals::kInvalidId - 1staticconstexpr[¶]

Maximum valid packed-id, excludes Globals::kInvalidId.

uint32_t Operand_::kVirtIdCount = uint32_t(

Count of valid packed-ids.

Signature Operand_::_signature[¶]

Provides operand type and additional payload.

uint32_t Operand_::_base_id[¶]

Either base id as used by memory operand or any id as used by others.

uint32_t Operand_::_data[2][¶]

Data specific to the operand type.

The reason we don't use union is that we have constexpr constructors that construct operands and other constexpr functions that return whether another Operand or something else. These cannot generally work with unions so we also cannot use union if we want to be standard compliant.