I am trying to type cast an llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> to a memref<1000xf16> type.
If I try to use the llvm.bitcast MLIR instruction it gives the following error:
‘llvm.bitcast’ op operand #0 must be LLVM-compatible non-aggregate type, but got '!llvm.struct<(ptr, ptr, i64, array<1 xi64>, array<1 x i64>)>
Also the memref is not an LLVM-compatible non-aggregate type.
Could you please tell me if there is another MLIR instruction (maybe in a different dialect than LLVM) that can convert the llvm.struct to the memref.
The lowering from memref to LLVM struct is not a cast, so you can’t just bitcast the value back to memref. Upstream, AFAIK, there aren’t “raising” instruction from LLVM back to memref, so you’ll probably have to write one if you need this.
Polygeist doesn’t necessarily convert LLVM dialect into memref, but it handles both scf and LLVM dialects at the same time, so it might have some inspiration.
I don’t know of any other project that works at that level, but there may be some around.
Thank you very much for both your answers. In the end I created a special call operation, which has the following arguments and results:
let arguments = (ins SymbolRefAttr:$c, Variadic:$opnds);
let results = (outs Variadic);