Step 1. Lower axpy.mlir to axpy.ll
mlir-opt -lower-affine -convert-loop-to-std -convert-std-to-llvm='emit-c-wrappers=1' axpy.mlir | mlir-translate --mlir-to-llvmir -o axpy.ll
Step 2. Get bitcode for the caller C
.
clang -emit-llvm call_axpy.c -S -o call_axpy.bc
Step 3. axpy.ll -> axpy.bc
llvm-as axpy.ll -o axpy.bc
Step 4. Link the bitcodes
llvm-link call_axpy.bc axpy.bc -o result.bc
Step 5. Run the bitcode
$ lli result.bc
x: {0.0, 1.0, 4.0, 9.0}
y: {0.0, 1.0, 2.0, 3.0}
2.00x + y: {0.0, 3.0, 10.0, 21.0}