AsmJit
Low-Latency Machine Code Generation
Code emitter that uses virtual registers and performs register allocation.
Compiler is a high-level code-generation tool that provides register allocation and automatic handling of function calling conventions. It was primarily designed for merging multiple parts of code into a function without worrying about registers and function calling conventions.
BaseCompiler can be used, with a minimum effort, to handle 32-bit and 64-bit code generation within a single code base.
BaseCompiler is based on BaseBuilder and contains all the features it provides. It means that the code it stores can be modified (removed, added, injected) and analyzed. When the code is finalized the compiler can emit the code into an Assembler to translate the abstract representation into a machine code.
Check out architecture specific compilers for more details and examples:
Creates a new BaseCompiler
instance.
Destroys the BaseCompiler
instance.
Creates a new FuncNode.
Creates a new FuncNode adds it to the instruction stream.
Creates a new FuncRetNode.
Creates a new FuncRetNode and adds it to the instruction stream.
Returns the current function.
Creates a new FuncNode with the given signature
and returns it.
Creates a new FuncNode with the given signature
, adds it to the instruction stream by using the addFunc(FuncNode*) overload, and returns it.
Adds a function node
to the instruction stream.
Emits a sentinel that marks the end of the current function.
Creates a new InvokeNode.
Creates a new InvokeNode and adds it to the instruction stream.
Creates a new virtual register representing the given typeId
and signature
.
newReg()
functionality instead or functions like _newReg() and _newRegFmt(). nullptr
)[1/2]◆ Creates a new virtual register of the given typeId
and stores it to out
operand.
Creates a new virtual register of the given typeId
and stores it to out
operand.
fmt
followed by a variadic arguments. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
nullptr
)[2/2]◆ Creates a new virtual register compatible with the provided reference register ref
.
Creates a new virtual register compatible with the provided reference register ref
.
fmt
followed by a variadic arguments. Tests whether the given id
is a valid virtual register id.
Tests whether the given reg
is a virtual register having a valid id.
Returns VirtReg associated with the given id
.
Returns VirtReg associated with the given reg
.
Returns VirtReg associated with the given virtual register index
.
Returns an array of all virtual registers managed by the Compiler.
nullptr
)◆ Creates a new stack of the given size
and alignment
and stores it to out
.
name
can be used to give the stack a name, for debugging purposes. 0
)[1/2]◆ Updates the stack size of a stack created by _newStack()
by its virtId
.
0
)[2/2]◆ Updates the stack size of a stack created by _newStack()
.
Creates a new constant of the given scope
(see ConstPoolScope).
This function adds a constant of the given size
to the built-in ConstPool and stores the reference to that constant to the out
operand.
Rename the given virtual register reg
to a formatted string fmt
.
Returns a new JumpAnnotation
instance, which can be used to aggregate possible targets of a jump where the target is not a label, for example to implement jump tables.
Called after the emitter was attached to CodeHolder
.
Reimplemented from asmjit::BaseBuilder.
Reimplemented in asmjit::x86::Compiler.
Called after the emitter was detached from CodeHolder
.
Reimplemented from asmjit::BaseBuilder.
Reimplemented in asmjit::x86::Compiler.
Current function.
Allocates VirtReg
objects.
Stores array of VirtReg
pointers.
Stores jump annotations.
Local and global constant pools.
Local constant pool is flushed with each function, global constant pool is flushed only by finalize().