[Mlir-commits] [mlir] [MLIR][EmitC] Add support for pointer-array types in the TypeConverter and related MemRef-to-EmitC operations, and update the C emitter. (PR #160159)

Simon Camphausen llvmlistbot at llvm.org
Wed Oct 29 08:41:03 PDT 2025


================
@@ -51,9 +57,15 @@ module @globals {
   // CHECK-LABEL: use_global
   func.func @use_global() {
     // CHECK-NEXT: emitc.get_global @public_global : !emitc.array<3x7xf32>
+    // CHECK-NEXT: "emitc.constant"() <{value = 0 : index}> : () -> index
----------------
simon-camp wrote:

I thought instead of taking the address of the array as ptr to array one could just decay the array to pointer directly (i.e. generating a ptr to a rank reduced array). And then loosening some op verifiers:

- allow the decay in the cast op
- accept nested pointer and array types in the subscript op
- allow implicit array decay in type checks on calls
- enhance the emitter 

For alloca you would only have the explicit cast as additional operation and a different variable on use sites 

But I didn't have time to prototype and test this yet to see if/how this breaks other things.

Anyhow, having a switch to opt in/out for this would be good.

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


More information about the Mlir-commits mailing list