Code Emission
We started from LLVM IR in the first section and converted it to SelectioDAG and then to MachineInstr. Now, we need to emit this code. Currently, we have LLVM JIT and MC to do so. LLVM JIT is the traditional way of generating the object code for a target on the go directly in the memory. What we are more interested in is the LLVM MC layer.
The MC layer is responsible for generation of assembly file/object file from the MachineInstr passed on to it from the previous step. In the MC Layer, the instructions are represented as MCInst, which are lightweight, as in they don't carry much information about the program as MachineInstr.
The code emission starts with the AsmPrinter class, which is overloaded by the target specific AsmPrinter ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access