In this chapter, we will cover the following recipes:
The life of an LLVM IR instruction
Visualizing the LLVM IR CFG using GraphViz
Describing the target using TableGen
Defining an instruction set
Adding a machine code descriptor
Implementing the MachineInstrBuilder class
Implementing the MachineBasicBlock class
Implementing the MachineFunction class
Writing an instruction selector
Legalizing SelectionDAG
Optimizing SelectionDAG
Selecting instructions from the DAG
Scheduling instructions in SelectionDAG
Introduction
After optimizing the LLVM IR, it needs to be converted into machine instructions for execution. The machine-independent code generator interface gives an abstract layer that helps convert IR into machine instructions. In this phase, the IR is converted into SelectionDAG (DAGstands for Directed Acyclic Graph). Various phases work on the nodes of SelectionDAG. This chapter describes the important phases in target-independent code generation.