[MLIR][Python] expose translate_module_to_llvmir (#163881)

This PR exposes `translate_module_to_llvmir` in the Python bindings.
This commit is contained in:
Maksim Levental
2025-10-20 12:14:52 -04:00
committed by GitHub
parent 8c826066e9
commit 5a112dedff
5 changed files with 45 additions and 1 deletions

View File

@@ -150,3 +150,22 @@ def testIntrinsics():
result = llvm.intr_memset(alloca, c_0, c_128, False)
# CHECK: "llvm.intr.memset"(%[[ALLOCA]], %[[CST0]], %[[CST128]]) <{isVolatile = false}> : (!llvm.ptr, i8, i32) -> ()
print(result)
# CHECK-LABEL: testTranslateToLLVMIR
@constructAndPrintInModule
def testTranslateToLLVMIR():
with Context(), Location.unknown():
module = Module.parse(
"""\
llvm.func @add(%arg0: i64, %arg1: i64) -> i64 {
%0 = llvm.add %arg0, %arg1 : i64
llvm.return %0 : i64
}
"""
)
# CHECK: define i64 @add(i64 %0, i64 %1) {
# CHECK: %3 = add i64 %0, %1
# CHECK: ret i64 %3
# CHECK: }
print(llvm.translate_module_to_llvmir(module.operation))