Similar to the LLVM IR FunctionBlock
class, a MachineFunction
class contains a series of MachineBasicBlocks
classes. These MachineFunction
classes map to LLVM IR functions that are given as input to the instruction selector. In addition to a list of basic blocks, the MachineFunction
class contains the MachineConstantPool
, MachineFrameInfo
, MachineFunctionInfo
, and MachineRegisterInfo
classes.
Many functions are defined in the MachineFunction
class, which does specific tasks. There are also many class member objects that keep information, such as the following:
RegInfo
keeps information about each register that is in use in the function:MachineRegisterInfo *RegInfo;
MachineFrameInfo
keeps track of objects allocated on the stack:MachineFrameInfo *FrameInfo;
ConstantPool
keeps track of constants that have been spilled to the memory:MachineConstantPool *ConstantPool;
JumpTableInfo
keeps track of jump tables for switch instructions:MachineJumpTableInfo *JumpTableInfo;
typedef ilist<MachineBasicBlock> BasicBlockListType; BasicBlockListType BasicBlocks;
getFunction
function returns the LLVM function that the current machine code represents:const Function *getFunction() const { return Fn; }
CreateMachineInstr
allocates a new MachineInstr
class:MachineInstr *CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImp = false);
The MachineFunction
class primarily contains a list of MachineBasicBlock
objects (typedef ilist<MachineBasicBlock> BasicBlockListType; BasicBlockListType BasicBlocks;
), and defines various methods for retrieving information about the machine function and manipulating the objects in the basic blocks member. A very important point to note is that the MachineFunction
class maintains the control flow graph (CFG) of all basic blocks in a function. Control flow information in CFG is crucial for many optimizations and analyses. So, it is important to know how the MachineFunction
objects and the corresponding CFGs are constructed.
3.144.97.216