[llvm] [RISCV] Remove SEW operand for load/store and SEW-aware pseudos (PR #90396)

Yeting Kuo via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 18:36:43 PDT 2024


================
@@ -191,6 +215,28 @@ static inline unsigned getSEWOpNum(const MCInstrDesc &Desc) {
   return Desc.getNumOperands() - Offset;
 }
 
+static inline unsigned getLog2SEW(uint64_t TSFlags) {
+  return 3 + RISCVII::getVSEW(TSFlags);
+}
+
+static inline MachineOperand getSEWOp(const MachineInstr &MI) {
+  uint64_t TSFlags = MI.getDesc().TSFlags;
+  assert(hasSEW(TSFlags) && "The instruction doesn't have SEW value!");
+  if (hasSEWOp(TSFlags))
+    return MI.getOperand(getSEWOpNum(MI.getDesc()));
+
+  return MachineOperand::CreateImm(getLog2SEW(TSFlags));
+}
+
+static inline unsigned getLog2SEW(const MachineInstr &MI) {
+  uint64_t TSFlags = MI.getDesc().TSFlags;
----------------
yetingk wrote:

How about to implement `getLog2SEW` with `getSEWOp`?

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


More information about the llvm-commits mailing list