aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-04-21 23:25:08 +0100
committergingerBill <bill@gingerbill.org>2021-04-21 23:25:08 +0100
commit2fb0383e82e34d5bf0dd222f03649ce7abb1288f (patch)
tree6ce0214339bba863c7ef2645cf4a603ffa8a197f /src/llvm_backend.cpp
parent8077d5f5657e93625a5c04ce8b36832790d84196 (diff)
Add `-build-mode:llvm-ir` for `-llvm-api` backend
Diffstat (limited to 'src/llvm_backend.cpp')
-rw-r--r--src/llvm_backend.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 62d5a58a6..1a4e5db55 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -9692,6 +9692,7 @@ bool lb_is_const_nil(lbValue value) {
String lb_get_const_string(lbModule *m, lbValue value) {
GB_ASSERT(lb_is_const(value));
+ GB_ASSERT(LLVMIsConstant(value.value));
Type *t = base_type(value.type);
GB_ASSERT(are_types_identical(t, t_string));
@@ -14220,13 +14221,18 @@ void lb_generate_code(lbGenerator *gen) {
return;
}
llvm_error = nullptr;
- if (build_context.keep_temp_files) {
+ if (build_context.keep_temp_files ||
+ build_context.build_mode == BuildMode_LLVM_IR) {
TIME_SECTION("LLVM Print Module to File");
if (LLVMPrintModuleToFile(mod, cast(char const *)filepath_ll.text, &llvm_error)) {
gb_printf_err("LLVM Error: %s\n", llvm_error);
gb_exit(1);
return;
}
+ if (build_context.build_mode == BuildMode_LLVM_IR) {
+ gb_exit(0);
+ return;
+ }
}
TIME_SECTION("LLVM Object Generation");