[Mlir-commits] [mlir] [MLIR][NVVM] Improve inline_ptx, add readwrite support (PR #154358)

Durgadoss R llvmlistbot at llvm.org
Wed Aug 20 05:07:24 PDT 2025


================
@@ -59,19 +62,36 @@ static char getRegisterType(Value v) {
   return getRegisterType(v.getType());
 }
 
+/// Extract every element of a struct value.
+static SmallVector<Value> extractStructElements(PatternRewriter &rewriter,
+                                                Location loc, Value agg) {
+  auto structTy = cast<LLVM::LLVMStructType>(agg.getType());
+  SmallVector<Value> elems;
+  elems.reserve(structTy.getBody().size());
+  for (auto [i, t] : llvm::enumerate(structTy.getBody())) {
+    (void)t;
+    Value e = LLVM::ExtractValueOp::create(rewriter, loc, agg, i);
+    elems.push_back(e);
+  }
+  return elems;
+}
+
 void PtxBuilder::insertValue(Value v, PTXRegisterMod itype) {
-  LLVM_DEBUG(DBGS() << v << "\t Modifier : " << &itype << "\n");
+  LLVM_DEBUG(DBGS() << v << "\t Modifier : " << itype << "\n");
+  registerModifiers.push_back(itype);
+
   auto getModifier = [&]() -> const char * {
     if (itype == PTXRegisterMod::ReadWrite) {
-      assert(false && "Read-Write modifier is not supported. Try setting the "
-                      "same value as Write and Read separately.");
+      // "Read-Write modifier is not supported
+      // Interface canonicalize it later
       return "+";
     }
     if (itype == PTXRegisterMod::Write) {
       return "=";
     }
     return "";
   };
----------------
durga4github wrote:

Now that the assert is gone, will a switch-case on Mod: :Types be cleaner here?

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


More information about the Mlir-commits mailing list