Adding a machine code descriptor
The LLVM IR has functions, which have basic blocks. Basic blocks in turn have instructions. The next logical step is to convert those IR abstract blocks into machine-specific blocks. LLVM code is translated into a machine-specific representation formed from the MachineFunction
, MachineBasicBlock
, and MachineInstr
instances. This representation contains instructions in their most abstract form—that is, having an opcode and a series of operands.
How it's done…
Now the LLVM IR instruction has to be represented in the machine instruction. Machine instructions are instances of the MachineInstr
class. This class is an extremely abstract way of representing machine instructions. In particular, it only keeps track of an opcode number and a set of operands. The opcode number is a simple unsigned integer that has a meaning only for a specific backend.
Let's look at some important functions defined in the MachineInstr.cpp
file:
The MachineInstr
constructor:
MachineInstr...