Some instruction selection patterns required for ALU GPR instructions have already been automatically imported from existing TableGen descriptions - this patch simply adds testing for them. Logic for selecting constants and copies has been added, along with the first of the GIComplexPatternEquiv definitions required to select the shiftMaskXLen ComplexPattern. New patterns have been added to directly select RV64 W instructions from gMIR rather than using custom gMIR operations earlier in the pipeline. In future this could also support the checks present in the DAGToDAGISel for finding ops whose users only require the lower 32 bits.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Add custom selection for copies and for constants. Significantly expand tests over more types.
Missing copy tests for all permutations of virtual and physical registers
llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp | ||
---|---|---|
114–115 | This can't early return, it still needs to constrain a virtual source |
Rebased. Added the first GIComplexPatternEquiv definition in order to handle the operands to shifts, which are now covered by a ComplexPattern in SelectionDAG. Updated the tests to match the output of the regbank selector.
llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp | ||
---|---|---|
95–106 | This function name is misleading. Can you restructure to use something more like getRegClassForTypeOnBank (which AArch64 has a FIXME to make a generic TargetRegisterInfo method) |
Restructure slightly, add more cases for selectCopy along with tests, add selection patterns for RV64 W instructions.
llvm/lib/Target/RISCV/RISCVGISel.td | ||
---|---|---|
30 ↗ | (On Diff #404931) | Should sext_inreg be legal? |
llvm/lib/Target/RISCV/RISCVInstructionSelector.cpp | ||
45 | What is this parameter? | |
107 | SrcReg.isPhysical() | |
118 | Why not just print the whole instruction? | |
143 | Should not construct one off MachineIRBuilders. The selector usually just directly uses BuildMI | |
169 | Didn't erase the instruction |
llvm/lib/Target/RISCV/RISCVGISel.td | ||
---|---|---|
30 ↗ | (On Diff #404931) | This is what I'm stuck on right now. It really should to match the SelectionDAG code, at least for i32 -> i64. However there is no way to map G_SEXT_INREG to sext_inreg because sext_inreg uses a value type as a DAG operand, whereas G_SEXT_INREG uses a constant which indicates the size of the original type. So no patterns defined which use sext_inreg will work for GlobalISel. I think my only option left is to do custom selection code. |
llvm/lib/Target/RISCV/RISCVGISel.td | ||
---|---|---|
30 ↗ | (On Diff #404931) | You can either do custom selection code, or you could add support for sext_inreg in GlobalISelEmitter. It's a special case so it requires special support |