After legalization and DAG combination, the SelectionDAG
representation is in the optimized phase. However, the instructions represented are still target-independent and need to be mapped on target-specific instructions. The instruction selection phase takes the target-independent DAG nodes as the input, matches patterns in them, and gives the output DAG nodes, which are target-specific.
The TableGen
DAG instruction selector generator reads the instruction patterns from the .td
file, and automatically builds parts of the pattern matching code.
SelectionDAGISel
is the common base class used for pattern-matching instruction selectors that are based on SelectionDAG
. It inherits the MachineFunctionPass
class. It has various functions used to determine the legality and profitability of operations such as folding. The basic skeleton of this class is as follows:
class SelectionDAGISel : public MachineFunctionPass { public: const TargetMachine &TM...