Skip to content

Commit ac18649

Browse files
kpermahesh-attarde
authored andcommitted
[DOC][GlobalISel] Add more explanation to InstructionSelect (llvm#160510)
1 parent b1b3c2c commit ac18649

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

llvm/docs/GlobalISel/InstructionSelect.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ InstructionSelect
55
-----------------
66

77
This 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

Comments
 (0)