[llvm] [InstrRef][AArch64]Add Target hooks for InstrRef on AArch64 (PR #162327)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 05:16:56 PDT 2025


================
@@ -2394,16 +2397,55 @@ Register AArch64InstrInfo::isStoreToStackSlot(const MachineInstr &MI,
   case AArch64::STRDui:
   case AArch64::STRQui:
   case AArch64::STR_PXI:
+    return true;
+  }
+}
+
+Register AArch64InstrInfo::isStoreToStackSlot(const MachineInstr &MI,
+                                              int &FrameIndex) const {
+  if (isFrameStoreOpcode(MI.getOpcode())) {
     if (MI.getOperand(0).getSubReg() == 0 && MI.getOperand(1).isFI() &&
         MI.getOperand(2).isImm() && MI.getOperand(2).getImm() == 0) {
       FrameIndex = MI.getOperand(1).getIndex();
       return MI.getOperand(0).getReg();
     }
-    break;
   }
   return 0;
 }
 
+Register AArch64InstrInfo::isStoreToStackSlotPostFE(const MachineInstr &MI,
+                                                    int &FrameIndex) const {
+  if (isFrameStoreOpcode(MI.getOpcode())) {
+    SmallVector<const MachineMemOperand *, 1> Accesses;
+    if (Register Reg = isStoreToStackSlot(MI, FrameIndex))
+      return Reg;
+
+    if (hasStoreToStackSlot(MI, Accesses)) {
+      FrameIndex =
+          cast<FixedStackPseudoSourceValue>(Accesses.front()->getPseudoValue())
+              ->getFrameIndex();
+      return 1;
----------------
jmorse wrote:

Hmm -- I understand this is how ARM works (versus aarch64), however I think this will run into difficulty with InstrRef. `InstrRefBasedLDV::isLocationSpill` stores the return value of this function into its `Reg` reference, which is then used to determine which register is being spilt. That's significant as it determines what value is being transferred onto the stack.

If it's impossible to determine that information this late in compilation, it might be sufficient to just use the earlier clause, those for which `isStoreToStackSlot` returns a register?

(Similarly for isLoadFromStackSlotPostFE).

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


More information about the llvm-commits mailing list