asmjit::BaseMem Class Reference
Inheritance diagram for asmjit::BaseMem:
asmjit::Operand asmjit::Operand_ asmjit::arm::Mem asmjit::x86::Mem

Base class for all memory operands.

The data is split into the following parts:

  • BASE - Base register or label - requires 36 bits total. 4 bits are used to encode the type of the BASE operand (label vs. register type) and the remaining 32 bits define the BASE id, which can be a physical or virtual register index. If BASE type is zero, which is never used as a register type and label doesn't use it as well then BASE field contains a high DWORD of a possible 64-bit absolute address, which is possible on X64.
  • INDEX - Index register (or theoretically Label, which doesn't make sense). Encoding is similar to BASE - it also requires 36 bits and splits the encoding to INDEX type (4 bits defining the register type) and 32-bit id.
  • OFFSET - A relative offset of the address. Basically if BASE is specified the relative displacement adjusts BASE and an optional INDEX. if BASE is not specified then the OFFSET should be considered as ABSOLUTE address (at least on X86). In that case its low 32 bits are stored in DISPLACEMENT field and the remaining high 32 bits are stored in BASE.
  • OTHER - There is rest 8 bits that can be used for whatever purpose. For example x86::Mem operand uses these bits to store segment override prefix and index shift (or scale).

Member Functions

Construction & Destruction
Overloaded Operators
Accessors
- Public Member Functions inherited from asmjit::Operand
- Public Member Functions inherited from asmjit::Operand_

Additional Inherited Members

- Public Attributes inherited from asmjit::Operand_
- Public Types inherited from asmjit::Operand_
- Static Public Member Functions inherited from asmjit::Operand_

Constructor & Destructor Documentation

BaseMem::BaseMem()constexprconstexprnoexcept[1/4]◆ 

Creates a default BaseMem operand, that points to [0].

BaseMem::BaseMem(const BaseMem& other)constexprconstexprnoexcept[2/4]◆ 

Creates a BaseMem operand that is a clone of other.

BaseMem::BaseMem(const BaseReg& baseReg, int32_t offset = 0)constexprexplicitconstexprnoexcept[3/4]◆ 

Creates a BaseMem operand from baseReg and offset.

Note
This is an architecture independent constructor that can be used to create an architecture independent memory operand to be used in portable code that can handle multiple architectures.

BaseMem::BaseMem(Globals::NoInit_)explicitnoexcept[4/4]◆ 

Creates a completely uninitialized BaseMem operand.

Member Function Documentation

void BaseMem::reset()noexcept◆ 

Resets the memory operand - after the reset the memory points to [0].

BaseMem BaseMem::clone() constconstexprconstexprnoexcept◆ 

Clones the memory operand.

BaseMem BaseMem::cloneAdjusted(int64_t off) constnoexcept◆ 

Creates a new copy of this memory operand adjusted by off.

bool BaseMem::isRegHome() constconstexprconstexprnoexcept◆ 

Tests whether this memory operand is a register home (only used by Compiler)

void BaseMem::setRegHome()noexcept◆ 

Mark this memory operand as register home (only used by Compiler).

void BaseMem::clearRegHome()noexcept◆ 

Marks this operand to not be a register home (only used by Compiler).

bool BaseMem::hasBase() constconstexprconstexprnoexcept◆ 

Tests whether the memory operand has a BASE register or label specified.

bool BaseMem::hasIndex() constconstexprconstexprnoexcept◆ 

Tests whether the memory operand has an INDEX register specified.

bool BaseMem::hasBaseOrIndex() constconstexprconstexprnoexcept◆ 

Tests whether the memory operand has BASE or INDEX register.

bool BaseMem::hasBaseAndIndex() constconstexprconstexprnoexcept◆ 

Tests whether the memory operand has BASE and INDEX register.

bool BaseMem::hasBaseLabel() constconstexprconstexprnoexcept◆ 

Tests whether the BASE operand is a label.

bool BaseMem::hasBaseReg() constconstexprconstexprnoexcept◆ 

Tests whether the BASE operand is a register (registers start after RegType::kLabelTag).

bool BaseMem::hasIndexReg() constconstexprconstexprnoexcept◆ 

Tests whether the INDEX operand is a register (registers start after RegType::kLabelTag).

RegType BaseMem::baseType() constconstexprconstexprnoexcept◆ 

Returns the type of the BASE register (0 if this memory operand doesn't use the BASE register).

Note
If the returned type is one (a value never associated to a register type) the BASE is not register, but it is a label. One equals to kLabelTag. You should always check hasBaseLabel() before using baseId() result.

RegType BaseMem::indexType() constconstexprconstexprnoexcept◆ 

Returns the type of an INDEX register (0 if this memory operand doesn't use the INDEX register).

uint32_t BaseMem::baseAndIndexTypes() constconstexprconstexprnoexcept◆ 

This is used internally for BASE+INDEX validation.

uint32_t BaseMem::baseId() constconstexprconstexprnoexcept◆ 

Returns both BASE (4:0 bits) and INDEX (9:5 bits) types combined into a single value.

Remarks
Returns id of the BASE register or label (if the BASE was specified as label).

uint32_t BaseMem::indexId() constconstexprconstexprnoexcept◆ 

Returns the id of the INDEX register.

void BaseMem::setBaseId(uint32_t id)noexcept◆ 

Sets the id of the BASE register (without modifying its type).

void BaseMem::setIndexId(uint32_t id)noexcept◆ 

Sets the id of the INDEX register (without modifying its type).

void BaseMem::setBase(const BaseReg& base)noexcept◆ 

Sets the base register to type and id of the given base operand.

void BaseMem::setIndex(const BaseReg& index)noexcept◆ 

Sets the index register to type and id of the given index operand.

void BaseMem::resetBase()noexcept◆ 

Resets the memory operand's BASE register or label.

void BaseMem::resetIndex()noexcept◆ 

Resets the memory operand's INDEX register.

void BaseMem::setSize(uint32_t size)noexcept◆ 

Sets the memory operand size (in bytes).

bool BaseMem::isOffset64Bit() constconstexprconstexprnoexcept◆ 

Tests whether the memory operand has a 64-bit offset or absolute address.

If this is true then hasBase() must always report false.

bool BaseMem::hasOffset() constconstexprconstexprnoexcept◆ 

Tests whether the memory operand has a non-zero offset or absolute address.

int64_t BaseMem::offset() constconstexprconstexprnoexcept◆ 

Returns either relative offset or absolute address as 64-bit integer.

int32_t BaseMem::offsetLo32() constconstexprconstexprnoexcept◆ 

Returns a 32-bit low part of a 64-bit offset or absolute address.

int32_t BaseMem::offsetHi32() constconstexprconstexprnoexcept◆ 

Returns a 32-but high part of a 64-bit offset or absolute address.

Note
This function is UNSAFE and returns garbage if isOffset64Bit() returns false. Never use it blindly without checking it first.

void BaseMem::setOffset(int64_t offset)noexcept◆ 

Sets a 64-bit offset or an absolute address to offset.

Note
This functions attempts to set both high and low parts of a 64-bit offset, however, if the operand has a BASE register it will store only the low 32 bits of the offset / address as there is no way to store both BASE and 64-bit offset, and there is currently no architecture that has such capability targeted by AsmJit.

void BaseMem::setOffsetLo32(int32_t offset)noexcept◆ 

Sets a low 32-bit offset to offset (don't use without knowing how BaseMem works).

void BaseMem::addOffset(int64_t offset)noexcept◆ 

Adjusts the offset by offset.

Note
This is a fast function that doesn't use the HI 32-bits of a 64-bit offset. Use it only if you know that there is a BASE register and the offset is only 32 bits anyway. Adjusts the memory operand offset by a offset.

void BaseMem::addOffsetLo32(int32_t offset)noexcept◆ 

Adds offset to a low 32-bit offset part (don't use without knowing how BaseMem works).

void BaseMem::resetOffset()noexcept◆ 

Resets the memory offset to zero.

void BaseMem::resetOffsetLo32()noexcept◆ 

Resets the lo part of the memory offset to zero (don't use without knowing how BaseMem works).