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

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


================
@@ -60,6 +59,16 @@ void mlir::registerConvertMemRefToEmitCInterface(DialectRegistry &registry) {
 // Conversion Patterns
 //===----------------------------------------------------------------------===//
 
+Type convertMemRefType(MemRefType opTy, const TypeConverter *typeConverter) {
+  Type resultTy;
+  if (opTy.getRank() == 0) {
+    resultTy = typeConverter->convertType(mlir::getElementTypeOrSelf(opTy));
----------------
aniragil wrote:

Sorry, I wasn't clear: I meant the return value is somewhat inconsistent: for rank>0 it returns the actual type the memref is converted to (ArrayType), but for rank==0 it returns the element type, not the type the memref is converted to. The name "convertMemRefType" got me expecting the function to consistently return the type the memref is converted to, which for rank==0 is `emitc::ptr`, as done in the TypeConverter (TBH I'm not sure why we need this wrapper around the type converter ...)

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


More information about the Mlir-commits mailing list