-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
LLVM Code Generation
By :
Like a lot of things in the LLVM infrastructure, there’s not one but two ways of building MachineInstr objects.
Note
There’s actually a third way of creating MachineInstr objects: you can use the bare APIs of the MachineOperand and MachineInstr class – for instance, using the MachineOperand::CreateXXX family of methods or the MachineFunction::CreateMachineInstr method. We won’t describe this way of building these objects because it’s very verbose and barely used.
The first way of building such objects is via the MachineIRBuilder class, which you briefly used in Chapter 4. This class is usually used at the beginning of the MachineFunction passes pipeline, when the produced code is still in SSA. Indeed, it abstracts you away from creating the virtual registers (you can still do this if you want to, though) and instead provides an API that feels more like the IRBuilder class of the LLVM IR.