[llvm] [X86InstrInfo] support memfold on spillable inline asm (PR #70832)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 13:29:59 PDT 2023


================
@@ -10333,5 +10333,15 @@ void X86InstrInfo::genAlternativeCodeSequence(
   }
 }
 
+// See also: X86DAGToDAGISel::SelectInlineAsmMemoryOperand().
+void X86InstrInfo::getFrameIndexOperands(SmallVectorImpl<MachineOperand> &Ops) const {
+  Ops.append({
+    MachineOperand::CreateImm(1),        // Scale
+    MachineOperand::CreateReg(0, false), // Index
+    MachineOperand::CreateImm(0),        // Disp
+    MachineOperand::CreateReg(0, false), // Segment
+  });
----------------
nickdesaulniers wrote:

oh! yeah it does look potentially reusable.

Though the class seems very x86 specific.  Would be nice if there was a target independent interface I could call from `foldInlineAsmMemOperand` (added in) https://github.com/llvm/llvm-project/pull/70743/files to get this info.

Let me check the users of `X86AddressMode`... worst case I could call it and drop the first operand.

> and have this function add the frame index operand as well. That would also help if a target has a different order of operands...

I guess if `X86AddressMode` isn't a per-target interface, then in `foldInlineAsmMemOperand` I'd have to do some target specific hack, then we back to adding this interface?

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


More information about the llvm-commits mailing list