[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)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 24 03:07:34 PDT 2025


LekkalaSravya3 wrote:

> Yes I think so. We need to be careful with allocas and globals though (and maybe function signatures, not sure), they need to be kept as Arrays so that the memory is allocated.
> 
> Alloca can be converted to an Array variable and a Cast that decays the outer Dimension.

@simon-camp, I wanted to get your thoughts on the current implementation of ConvertAlloca in the MemRef-to-EmitC conversion.

Currently, I use SubscriptOp + ApplyOp("&") to produce a pointer to the first element (!emitc.ptr<f32>). This is valid in EmitC, but it results in an unrealized_conversion_cast in later load/store operations because the TypeConverter expects !emitc.ptr<!emitc.array<...>> (pointer-to-array), while the emitted pointer is !emitc.ptr<f32> (pointer-to-element).

Could you advise on the most appropriate approach to resolve this mismatch?

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


More information about the Mlir-commits mailing list