Translating array into memref in MLIR

Hi, I am implementing a C frontend that translates C code into MLIR SCF dialect. However, I am not sure how a portion of memref is represented in MLIR.

For instance:

  int b[1][1];
  foo(b[0]); // b[0] is a 1xi32 array

which results in the following output from my tool:

  %0 = constant 0 : index
  %b = alloc() : memref<1x1xi32>
  %3 = load %b[%0] : memref<1x1xi32>
  call @foo(%3) : (memref<1xi32>) -> ()

However, the MLIR verifier sees that %3 has a type of i32 and reports an error.

I checked the documentation for std dialect, and it seems like that we only have casting ops that converts a memref type into an equivalent type. Does anyone know if there is a work-around?

Thanks!

I suspect that subview is what you’re looking for?

1 Like

Oh Thanks! Sorry about missing this…

No worries! Happy to help with anything here :slight_smile: