[llvm] [RISCV][GlobalISel] Select G_GLOBAL_VALUE (PR #70091)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 13:25:17 PDT 2023


================
@@ -483,6 +489,78 @@ bool RISCVInstructionSelector::selectConstant(MachineInstr &MI,
   return true;
 }
 
+bool RISCVInstructionSelector::selectGlobalValue(
+    MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI) const {
+  assert(MI.getOpcode() == TargetOpcode::G_GLOBAL_VALUE &&
+         "Expected G_GLOBAL_VALUE");
+  auto GV = MI.getOperand(1).getGlobal();
+  if (GV->isThreadLocal()) {
+    // TODO: implement this case.
+    return false;
+  }
+
+  switch (TM.getCodeModel()) {
+  default: {
+    reportGISelFailure(const_cast<MachineFunction &>(*MF), *TPC, *MORE,
+                       getName(), "Unsupported code model for lowering", MI);
+    return false;
+  }
+  case CodeModel::Small: {
+    // Must lie within a single 2 GiB address range and must lie between
----------------
topperc wrote:

Still missing the `isPositionIndependent()` from the top of SelectionDAG's `getAddr` that uses LGA/LLA even for the small code model.

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


More information about the llvm-commits mailing list