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 ...

Get LLVM Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.