AsmJit
Low-Latency Machine Code Generation
Builder interface, nodes, and passes.
Both BaseBuilder and BaseCompiler interfaces describe emitters that emit into a representation that allows further processing. The code stored in such representation is completely safe to be patched, simplified, reordered, obfuscated, removed, injected, analyzed, or processed some other way. Each instruction, label, directive, or other building block is stored as BaseNode (or derived class like InstNode or LabelNode) and contains all the information necessary to pass that node later to the assembler.
BaseBuilder is an emitter that inherits from BaseEmitter interface. It was designed to provide a maximum compatibility with the existing BaseAssembler emitter so users can move from assembler to builder when needed, for example to implement post-processing, which is not possible with Assembler.
BaseBuilder doesn't generate machine code directly, it uses an intermediate representation based on nodes, however, it allows to serialize to BaseAssembler when the code is ready to be encoded.
There are multiple node types used by both BaseBuilder and BaseCompiler :
Type of node used by BaseBuilder and BaseCompiler.
Constant | Description |
---|---|
kNone | Invalid node (internal, don't use). |
kInst | Node is InstNode. |
kSection | Node is SectionNode. |
kLabel | Node is LabelNode. |
kAlign | Node is AlignNode. |
kEmbedData | Node is EmbedDataNode. |
kEmbedLabel | Node is EmbedLabelNode. |
kEmbedLabelDelta | Node is EmbedLabelDeltaNode. |
kConstPool | Node is ConstPoolNode. |
kComment | Node is CommentNode. |
kSentinel | Node is SentinelNode. |
kJump | Node is JumpNode (acts as InstNode). |
kFunc | Node is FuncNode (acts as LabelNode). |
kFuncRet | Node is FuncRetNode (acts as InstNode). |
kInvoke | Node is InvokeNode (acts as InstNode). |
kUser | First id of a user-defined node. |
Node flags, specify what the node is and/or does.
Type of the sentinel (purely informative purpose).
Constant | Description |
---|---|
kUnknown | Type of the sentinel is not known. |
kFuncEnd | This is a sentinel used at the end of FuncNode. |