Tag llvm.emit_c_interface for polynomial-to-llvm pipeline
- Dominant language
- MLIR
- Stars
- 906
- Forks
- 171
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 32
Description
HEIR has two places that use LLVM lowering/backend, the polynomial backend (the whole set of `polynomial`/`mod_arith` dialect) and the plaintext backend.
In plaintext backend, we directly call MLIR functions from C; we may also want to do so (for test harness?) for polynomial backend, so the signature/ABI of MLIR functions matters.
https://mlir.llvm.org/docs/TargetLLVMIR/ tells us that `llvm.emit_c_interface` will produce a wrapper function `@_mlir_ciface_foo(result0_memref, result2_memref, arg0_memref)` for function `@foo(arg0_memref) -> (result0_memref, result1_memref)`. The former is callable from C, while the latter is not callable in some architecture (see #2111).
The way to tag `llvm.emit_c_interface` is simple: just write a small pass that tags all _non-external_ functions with such attribute.
Potential issues we will have
* External functions, like the debug function or vendor-specific function called from MLIR.
Contributor guide
Assessment
This issue has not been assessed yet.