AsmJit
Low-Latency Machine Code Generation
Compiler interface.
BaseCompiler is a high-level interface, which provides register allocation and support for defining and invoking functions, built on top of BaseBuilder interface At the moment it's the easiest way of generating code in AsmJit as most architecture and OS specifics is properly abstracted and handled by AsmJit automatically. However, abstractions also mean restrictions, which means that BaseCompiler has more limitations than BaseAssembler or BaseBuilder.
Since BaseCompiler provides register allocation it also establishes the concept of functions - a function in Compiler sense is a unit in which virtual registers are allocated into physical registers by the register allocator. In addition, it enables to use such virtual registers in function invocations.
BaseCompiler automatically handles function calling conventions. It's still architecture dependent, but makes the code generation much easies. Functions are essential; the first-step to generate some code is to define a signature of the function to be generated (before generating the function body itself). Function arguments and return value(s) are handled by assigning virtual registers to them. Similarly, function calls are handled the same way.
BaseCompiler adds some nodes that are required for function generation and invocation:
BaseCompiler also makes the use of passes (Pass) and automatically adds an architecture-dependent register allocator pass to the list of passes when attached to CodeHolder.
Users of AsmJit have done mistakes in the past, this section should provide some useful tips for beginners: