[llvm] [RISCV][GISel] Move G_BRJT expansion to legalization (PR #73711)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 21:14:36 PST 2023


================
@@ -317,6 +318,61 @@ bool RISCVLegalizerInfo::legalizeShlAshrLshr(
   return true;
 }
 
+bool RISCVLegalizerInfo::legalizeBRJT(MachineInstr &MI,
+                                      MachineIRBuilder &MIRBuilder) const {
+  MachineRegisterInfo &MRI = *MIRBuilder.getMRI();
----------------
topperc wrote:

I think the EK_LabelDifference32 case might not be generic either. SelectionDAG calls a virtual function `getPICJumpTableRelocBase`.

>From LegalizeDAG.cpp
```
    if (TLI.isJumpTableRelative()) {                                             
      // For PIC, the sequence is:                                               
      // BRIND(load(Jumptable + index) + RelocBase)                              
      // RelocBase can be JumpTable, GOT or some sort of global base.            
      Addr = DAG.getNode(ISD::ADD, dl, PTy, Addr,                                
                          TLI.getPICJumpTableRelocBase(Table, DAG));             
    }

https://github.com/llvm/llvm-project/pull/73711


More information about the llvm-commits mailing list