diff options
| author | Baitinq <[email protected]> | 2025-07-15 17:24:28 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-07-15 17:24:28 +0200 |
| commit | a9f40d08702a7ea945dc60948e74896f2b6ff602 (patch) | |
| tree | e592170608b1788d7b89c3800d2dc76df9d9a7aa /src/bootstrap/codegen.pry | |
| parent | Boostrap: Fix bug storing last function return type (diff) | |
| download | pry-lang-a9f40d08702a7ea945dc60948e74896f2b6ff602.tar.gz pry-lang-a9f40d08702a7ea945dc60948e74896f2b6ff602.tar.bz2 pry-lang-a9f40d08702a7ea945dc60948e74896f2b6ff602.zip | |
Boostrap: Support generating LLVM IR file
Diffstat (limited to 'src/bootstrap/codegen.pry')
| -rw-r--r-- | src/bootstrap/codegen.pry | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bootstrap/codegen.pry b/src/bootstrap/codegen.pry index 5b415c6..cb054ec 100644 --- a/src/bootstrap/codegen.pry +++ b/src/bootstrap/codegen.pry @@ -1393,14 +1393,19 @@ let codegen_generate = (c: *codegen, ast: *Node) => i64 { return 0; }; -let codegen_compile = (c: *codegen) => i64 { +let codegen_compile = (c: *codegen, dump_ir: bool) => i64 { /* Dump module */ LLVMDumpModule((*c).llvm_module); + let message = cast(**i8, null); + + if dump_ir { + LLVMPrintModuleToFile((*c).llvm_module, "output.ll", message); + return 0; + }; /* Generate code */ let triple = LLVMGetDefaultTargetTriple(); let target_ref = cast(*LLVMTargetRef, arena_alloc((*c).arena, sizeof(*LLVMTargetRef))); - let message = cast(**i8, null); let result = LLVMGetTargetFromTriple(triple, target_ref, message); if result != 0 { printf("Target output: %s\n", *message); |