
AsmJit Project
Low-Latency Machine Code Generation
Provides a base foundation to emitting code - specialized by BaseAssembler and BaseBuilder.
Returns the type of this emitter, see EmitterType
.
Returns emitter flags , see Flags
.
Tests whether the emitter inherits from BaseAssembler
.
Tests whether the emitter inherits from BaseBuilder
.
true
. Tests whether the emitter inherits from BaseCompiler
.
Tests whether the emitter has the given flag
enabled.
Tests whether the emitter is finalized.
Tests whether the emitter is destroyed (only used during destruction).
Returns the CodeHolder this emitter is attached to.
Returns the target environment.
The returned Environment reference matches CodeHolder::environment().
Tests whether the target architecture is 32-bit.
Tests whether the target architecture is 64-bit.
Returns the target architecture type.
Returns the target architecture sub-type.
Returns the target architecture's GP register size (4 or 8 bytes).
Tests whether the emitter is initialized (i.e. attached to CodeHolder).
Finalizes this emitter.
Materializes the content of the emitter by serializing it to the attached CodeHolder through an architecture specific BaseAssembler. This function won't do anything if the emitter inherits from BaseAssembler as assemblers emit directly to a CodeBuffer held by CodeHolder. However, if this is an emitter that inherits from BaseBuilder or BaseCompiler then these emitters need the materialization phase as they store their content in a representation not visible to CodeHolder.
Reimplemented in asmjit::a64::Builder, asmjit::a64::Compiler, asmjit::x86::Builder, and asmjit::x86::Compiler.
Tests whether the emitter has a logger.
Tests whether the emitter has its own logger.
Own logger means that it overrides the possible logger that may be used by CodeHolder this emitter is attached to.
Returns the logger this emitter uses.
The returned logger is either the emitter's own logger or it's logger used by CodeHolder this emitter is attached to.
Sets or resets the logger of the emitter.
If the logger
argument is non-null then the logger will be considered emitter's own logger, see hasOwnLogger() for more details. If the given logger
is null then the emitter will automatically use logger that is attached to the CodeHolder this emitter is attached to.
Resets the logger of this emitter.
The emitter will bail to using a logger attached to CodeHolder this emitter is attached to, or no logger at all if CodeHolder doesn't have one.
Tests whether the emitter has an error handler attached.
Tests whether the emitter has its own error handler.
Own error handler means that it overrides the possible error handler that may be used by CodeHolder this emitter is attached to.
Returns the error handler this emitter uses.
The returned error handler is either the emitter's own error handler or it's error handler used by CodeHolder this emitter is attached to.
Sets or resets the error handler of the emitter.
Resets the error handler.
nullptr
)◆ Handles the given error in the following way:
handleError()
function may throw.Returns encoding options.
Tests whether the encoding option
is set.
Enables the given encoding options
.
Disables the given encoding options
.
Returns the emitter's diagnostic options.
Tests whether the given option
is present in the emitter's diagnostic options.
Activates the given diagnostic options
.
This function is used to activate explicit validation options that will be then used by all emitter implementations. There are in general two possibilities:
Architecture specific assembler is used. In this case a DiagnosticOptions::kValidateAssembler can be used to turn on explicit validation that will be used before an instruction is emitted. This means that internally an extra step will be performed to make sure that the instruction is correct. This is needed, because by default assemblers prefer speed over strictness.
This option should be used in debug builds as it's pretty expensive.
Deactivates the given validation options
.
See addDiagnosticOptions() and DiagnosticOptions for more details.
Returns forced instruction options.
Forced instruction options are merged with next instruction options before the instruction is encoded. These options have some bits reserved that are used by error handling, logging, and instruction validation purposes. Other options are globals that affect each instruction.
Returns options of the next instruction.
Returns options of the next instruction.
Adds options of the next instruction.
Resets options of the next instruction.
Tests whether the extra register operand is valid.
Returns an extra operand that will be used by the next instruction (architecture specific).
Sets an extra operand that will be used by the next instruction (architecture specific).
Sets an extra operand that will be used by the next instruction (architecture specific).
Resets an extra operand that will be used by the next instruction (architecture specific).
Returns comment/annotation of the next instruction.
Sets comment/annotation of the next instruction.
_emit()
, but until that it has to remain valid as the Emitter is not required to make a copy of it (and it would be slow to do that for each instruction). Resets the comment/annotation to nullptr.
Creates a new label.
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
SIZE_MAX
, LabelType type = LabelType::kGlobal
, uint32_t parentId = Globals::kInvalidId
)pure virtual◆ Creates a new named label.
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
SIZE_MAX
)◆ Creates a new anonymous label with a name, which can only be used for debugging purposes.
SIZE_MAX
)◆ Creates a new external label.
SIZE_MAX
, uint32_t parentId = Globals::kInvalidId
)noexcept◆ Returns Label
by name
.
Returns invalid Label in case that the name is invalid or label was not found.
Label
returned. Binds the label
to the current position of the current section.
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
Tests whether the label id
is valid (i.e. registered).
Tests whether the label
is valid (i.e. registered).
Emits an instruction (internal).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Emits an instruction instId
with the given operands
.
Aligns the current CodeBuffer position to the alignment
specified.
The sequence that is used to fill the gap between the aligned location and the current location depends on the align mode
, see AlignMode. The alignment
argument specifies alignment in bytes, so for example when it's 32
it means that the code buffer will be aligned to 32
bytes.
Implemented in asmjit::a64::Assembler, asmjit::BaseBuilder, and asmjit::x86::Assembler.
Embeds raw data into the CodeBuffer.
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
1
)pure virtual◆ Embeds a typed data array.
This is the most flexible function for embedding data as it allows to:
typeId
to the data, so the emitter knows the type of items stored in data
. Binary data should use TypeId::kUInt8.repeatCount
times, so the data can be used as a fill pattern for example, or as a pattern used by SIMD instructions. Implemented in asmjit::BaseBuilder, and asmjit::BaseAssembler.
1
)◆ Embeds int8_t value
repeated by repeatCount
.
1
)◆ Embeds uint8_t value
repeated by repeatCount
.
1
)◆ Embeds int16_t value
repeated by repeatCount
.
1
)◆ Embeds uint16_t value
repeated by repeatCount
.
1
)◆ Embeds int32_t value
repeated by repeatCount
.
1
)◆ Embeds uint32_t value
repeated by repeatCount
.
1
)◆ Embeds int64_t value
repeated by repeatCount
.
1
)◆ Embeds uint64_t value
repeated by repeatCount
.
1
)◆ Embeds a floating point value
repeated by repeatCount
.
1
)◆ Embeds a floating point value
repeated by repeatCount
.
Embeds a constant pool at the current offset by performing the following:
pool
alignment.Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
0
)pure virtual◆ Embeds an absolute label
address as data.
The dataSize
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).
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
0
)pure virtual◆ 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.
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
SIZE_MAX
)pure virtual◆ Emits a comment stored in data
with an optional size
parameter.
Implemented in asmjit::BaseAssembler, and asmjit::BaseBuilder.
Emits a formatted comment specified by fmt
and variable number of arguments.
Emits a formatted comment specified by fmt
and ap
.
Called after the emitter was attached to CodeHolder
.
Reimplemented in asmjit::a64::Assembler, asmjit::a64::Builder, asmjit::a64::Compiler, asmjit::BaseAssembler, asmjit::BaseBuilder, asmjit::BaseCompiler, asmjit::x86::Assembler, asmjit::x86::Builder, and asmjit::x86::Compiler.
Called after the emitter was detached from CodeHolder
.
Reimplemented in asmjit::a64::Assembler, asmjit::a64::Builder, asmjit::a64::Compiler, asmjit::BaseAssembler, asmjit::BaseBuilder, asmjit::BaseCompiler, asmjit::x86::Assembler, asmjit::x86::Builder, and asmjit::x86::Compiler.
Called when CodeHolder has updated an important setting, which involves the following:
This function ensures that the settings are properly propagated from CodeHolder to the emitter.
See EmitterType.
See EmitterFlags.
Validation flags in case validation is used.
Validation options.
All supported architectures in a bit-mask, where LSB is the bit with a zero index.
Encoding options.
Forced instruction options, combined with _instOptions by emit().
Internal private data used freely by any emitter.
CodeHolder the emitter is attached to.
Attached Logger.
Attached ErrorHandler.
Describes the target environment, matches CodeHolder::environment().
Native GP register signature and signature related information.
Next instruction options (affects the next instruction).
Extra register (op-mask {k} on AVX-512) (affects the next instruction).
Inline comment of the next instruction (affects the next instruction).