[Mlir-commits] [mlir] [mlir][EmitC] Add rank-0 MemRef conversion (PR #205774)

Gil Rapaport llvmlistbot at llvm.org
Fri Jul 3 06:09:20 PDT 2026


================
@@ -80,26 +89,29 @@ struct ConvertAlloca final : public OpConversionPattern<memref::AllocaOp> {
           op.getLoc(), "cannot transform alloca with alignment requirement");
     }
 
-    auto resultTy = getTypeConverter()->convertType(op.getType());
-    if (!resultTy) {
+    auto resultTy = convertMemRefType(op.getType(), getTypeConverter());
+    if (!resultTy)
       return rewriter.notifyMatchFailure(op.getLoc(), "cannot convert type");
-    }
+
     auto noInit = emitc::OpaqueAttr::get(getContext(), "");
+    // Rank-0 path
+    if (op.getType().getRank() == 0) {
+      auto var = emitc::VariableOp::create(
+          rewriter, op.getLoc(), emitc::LValueType::get(resultTy), noInit);
----------------
aniragil wrote:

Here you could use the type converter and then query whether the type you got is an array or a pointer.

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


More information about the Mlir-commits mailing list