Can we automate the conversion of LLVM IR from MLIR?

As we have many dialects and passes to convert them to LLVM IR, currently I am selecting which pass(es) to run on the MLIR(specially TOSA and linalg dialects) by inspecting the code. Is there anyway to automate the process?

mlir-opt file.mlir --arith-bufferize --linalg-bufferize --tensor-bufferize --func-bufferize --empty-tensor-to-alloc-tensor --finalizing-bufferize --buffer-deallocation --convert-linalg-to-loops --convert-linalg-to-llvm --finalize-memref-to-llvm --convert-func-to-llvm

You can try -test-lower-to-llvm (see e.g. llvm-project/lower-to-llvm-e2e.mlir at main · llvm/llvm-project · GitHub).


test-lower-to-llvm can’t be a generic replacement, it is handling the “late stages” of the pipeline. For example it won’t include things like bufferization, async, gpu, etc.

1 Like