IndexAssemblerasmjit::BaseAssembler

asmjit::BaseAssembler Class Reference [¶]

Inheritance diagram for asmjit::BaseAssembler:
asmjit::BaseEmitter asmjit::a64::Assembler asmjit::x86::Assembler

Base assembler.

This is a base class that provides interface used by architecture specific assembler implementations. Assembler doesn't hold any data, instead it's attached to CodeHolder, which provides all the data that Assembler needs and which can be altered by it.

Check out architecture specific assemblers for more details and examples:

Public Types

Member Functions

Construction & Destruction

Code-Buffer Management

Section Management

Label Management

Embed

Comment

Events

Public Member Functions inherited from asmjit::BaseEmitter

BaseAssembler::BaseAssembler()noexcept[¶]

Creates a new BaseAssembler instance.

BaseAssembler::~BaseAssembler()overridenoexcept[¶]

Destroys the BaseAssembler instance.

size_t BaseAssembler::buffer_capacity() constnodiscardnoexcept[¶]

Returns the capacity of the current CodeBuffer.

size_t BaseAssembler::remaining_space() constnodiscardnoexcept[¶]

Returns the number of remaining bytes in the current CodeBuffer.

size_t BaseAssembler::offset() constnodiscardnoexcept[¶]

Returns the current position in the CodeBuffer.

Error BaseAssembler::set_offset(
size_t offset
)[¶]

Sets the current position in the CodeBuffer to offset.

Note

The offset cannot be greater than buffer size even if it's within the buffer's capacity.

uint8_t* BaseAssembler::buffer_data() constnodiscardnoexcept[¶]

Returns the start of the CodeBuffer in the current section.

uint8_t* BaseAssembler::buffer_end() constnodiscardnoexcept[¶]

Returns the end (first invalid byte) in the current section.

uint8_t* BaseAssembler::buffer_ptr() constnodiscardnoexcept[¶]

Returns the current pointer in the CodeBuffer in the current section.

Section* BaseAssembler::current_section() constnodiscardnoexcept[¶]

Returns the current section.

Error BaseAssembler::section(
Section* section
)override[¶]

Switches the given section.

Once switched, everything is added to the given section.

Reimplemented from asmjit::BaseEmitter.

Label BaseAssembler::new_label()override[¶]

Creates a new label.

Reimplemented from asmjit::BaseEmitter.

Label BaseAssembler::new_named_label(
const char* name,
size_t name_size = SIZE_MAX,
uint32_t parent_id = Globals::kInvalidId
)override[¶]

Creates a new named label.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::bind(
const Label& label
)override[¶]

Binds the label to the current position of the current section.

Note

Attempt to bind the same label multiple times will return an error.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::embed(
const void* data,
size_t data_size
)override[¶]

Embeds raw data into the CodeBuffer.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::embed_data_array(
TypeId type_id,
const void* data,
size_t item_count,
size_t repeat_count = 1
)override[¶]

Embeds a typed data array.

This is the most flexible function for embedding data as it allows to:

  • Assign a type_id to the data, so the emitter knows the type of items stored in data. Binary data should use TypeId::kUInt8.
  • Repeat the given data repeat_count times, so the data can be used as a fill pattern for example, or as a pattern used by SIMD instructions.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::embed_const_pool(
const Label& label,
const ConstPool& pool
)override[¶]

Embeds a constant pool at the current offset by performing the following:

  1. Aligns by using AlignMode::kData to the minimum pool alignment.
  2. Binds the ConstPool label so it's bound to an aligned location.
  3. Emits ConstPool content.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::embed_label(
const Label& label,
size_t data_size = 0
)override[¶]

Embeds an absolute label address as data.

The data_size is an optional argument that can be used to specify the size of the address data. If it's zero (default) the address size is deduced from the target architecture (either 4 or 8 bytes).

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::embed_label_delta(
const Label& label,
const Label& base,
size_t data_size = 0
)override[¶]

Embeds a delta (distance) between the label and base calculating it as label - base. This function was designed to make it easier to embed lookup tables where each index is a relative distance of two labels.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::comment(
const char* data,
size_t size = SIZE_MAX
)override[¶]

Emits a comment stored in data with an optional size parameter.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::on_attach()overridenoexcept[¶]

Called after the emitter was attached to CodeHolder.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::on_detach()overridenoexcept[¶]

Called after the emitter was detached from CodeHolder.

Reimplemented from asmjit::BaseEmitter.

Error BaseAssembler::on_reinit()overridenoexcept[¶]

Called when CodeHolder is reinitialized when the emitter is attached.

Reimplemented from asmjit::BaseEmitter.

Section* BaseAssembler::_section = nullptr[¶]

Current section where the assembling happens.

uint8_t* BaseAssembler::_buffer_data = nullptr[¶]

Start of the CodeBuffer of the current section.

uint8_t* BaseAssembler::_buffer_end = nullptr[¶]

End (first invalid byte) of the current section.

uint8_t* BaseAssembler::_buffer_ptr = nullptr[¶]

Pointer in the CodeBuffer of the current section.