[llvm] [X86] Add MI-layer routine for getting the index of the first address operand. NFC (PR #78019)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 13 20:08:28 PST 2024


================
@@ -289,10 +289,8 @@ static unsigned getYMMtoXMMStoreOpcode(unsigned StoreOpcode) {
 }
 
 static int getAddrOffset(const MachineInstr *MI) {
-  const MCInstrDesc &Descl = MI->getDesc();
-  int AddrOffset = X86II::getMemoryOperandNo(Descl.TSFlags);
+  const int AddrOffset = X86::getFirstAddrOperandIdx(*MI);
----------------
phoebewang wrote:

We usually don't use `const` for integer tpye. I think you may want to highlight `AddrOffset` is the final offset with bias and don't change it anymore by using `const`. In that way, it doesn't work here, because the function doesn't consume `AddrOffset` but return it in a non-const int.

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


More information about the llvm-commits mailing list