Lowering Std, Affine, Vector Mix Operations to LLVM IR


I am having an intermediate IR having mix of memref (memref.get_global), std(addf, mulf) and vector(transfer_read, transfer_write, extract, transpose, insert etc) dialect operations. I want to lower it to LLVM IR. What is the best way to lower this IR to LLVM IR?

  • M

Typically, you’d need something like --expand-strided-metadata --finalize-memref-to-llvm --convert-vector-to-llvm --convert-arith-to-llvm --reconcile-unrealized-casts should do the trick. This llvm-project/TestLowerToLLVM.cpp at main · llvm/llvm-project · GitHub has a longer pipeline that covers the most common usecase.

Now, the mention of “std” suggests that you are using an extremely outdated version of MLIR. There are some --convert-X-to-llvm passes where X is the name of the dialect, but at this point, I don’t remember what they are.