Generating assembler instructions
The instruction selection implemented in the previous sections lowers the IR instructions into MachineInstr
instances. This is already a much lower representation of instruction, but it is not yet the machine code itself. The last pass in the backend pipeline is to emit the instructions, either as assembly text or into an object file. The M88kAsmPrinter
machine pass is responsible for this task.
Basically, this pass lowers a MachineInstr
instance to an MCInst
instance, which is then emitted to a streamer. The MCInst
class represents the real machine code instruction. This additional lowering is required because the MachineInstr
class still does not have all the required details.
For the first approach, we can limit our implementation to overriding the emitInstruction()
method. You need to override more methods for supporting several operand types, mainly to emit the correct relocations. This class is also responsible for handling inline assemblers...