@@ -5,8 +5,22 @@ InstructionSelect
55-----------------
66
77This pass transforms generic machine instructions into equivalent
8- target-specific instructions. It traverses the ``MachineFunction `` bottom-up,
9- selecting uses before definitions, enabling trivial dead code elimination.
8+ target-specific instructions.
9+
10+ The legacy instruction selector, SelectionDAG, iterated over each function's
11+ basic block and constructed a dataflow graph. Every backend defines
12+ tree patterns in the ``XXXInstrInfo.td ``. The legacy selector started
13+ at the bottom and replaced the SDNodes greedily.
14+
15+ The GlobalISel's instruction selector traverses the ``MachineFunction ``
16+ bottom-up, selecting uses before definitions, enabling trivial dead code
17+ elimination. It does that by iterating over the basic blocks in post-order.
18+ Each gMIR instruction is then replaced by a MIR instruction when a matching
19+ pattern is found. So, when there is a 1:1 mapping between gMIR and MIR, where
20+ is the benefit of the global scope? Even in the case of a 1:1 mapping,
21+ GlobalISel includes a combiner that can match and fuse multiple gMIR
22+ instructions. The scope of the combination is not limited to a basic block,
23+ but can extend across the entire function.
1024
1125.. _api-instructionselector :
1226
0 commit comments