mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Add -build-mode:llvm-ir for -llvm-api backend
This commit is contained in:
@@ -104,6 +104,7 @@ enum BuildModeKind {
|
|||||||
BuildMode_DynamicLibrary,
|
BuildMode_DynamicLibrary,
|
||||||
BuildMode_Object,
|
BuildMode_Object,
|
||||||
BuildMode_Assembly,
|
BuildMode_Assembly,
|
||||||
|
BuildMode_LLVM_IR,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CommandKind : u32 {
|
enum CommandKind : u32 {
|
||||||
|
|||||||
@@ -9692,6 +9692,7 @@ bool lb_is_const_nil(lbValue value) {
|
|||||||
|
|
||||||
String lb_get_const_string(lbModule *m, lbValue value) {
|
String lb_get_const_string(lbModule *m, lbValue value) {
|
||||||
GB_ASSERT(lb_is_const(value));
|
GB_ASSERT(lb_is_const(value));
|
||||||
|
GB_ASSERT(LLVMIsConstant(value.value));
|
||||||
|
|
||||||
Type *t = base_type(value.type);
|
Type *t = base_type(value.type);
|
||||||
GB_ASSERT(are_types_identical(t, t_string));
|
GB_ASSERT(are_types_identical(t, t_string));
|
||||||
@@ -14220,13 +14221,18 @@ void lb_generate_code(lbGenerator *gen) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
llvm_error = nullptr;
|
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");
|
TIME_SECTION("LLVM Print Module to File");
|
||||||
if (LLVMPrintModuleToFile(mod, cast(char const *)filepath_ll.text, &llvm_error)) {
|
if (LLVMPrintModuleToFile(mod, cast(char const *)filepath_ll.text, &llvm_error)) {
|
||||||
gb_printf_err("LLVM Error: %s\n", llvm_error);
|
gb_printf_err("LLVM Error: %s\n", llvm_error);
|
||||||
gb_exit(1);
|
gb_exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (build_context.build_mode == BuildMode_LLVM_IR) {
|
||||||
|
gb_exit(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TIME_SECTION("LLVM Object Generation");
|
TIME_SECTION("LLVM Object Generation");
|
||||||
|
|||||||
@@ -1109,6 +1109,8 @@ bool parse_build_flags(Array<String> args) {
|
|||||||
build_context.build_mode = BuildMode_Executable;
|
build_context.build_mode = BuildMode_Executable;
|
||||||
} else if (str == "asm" || str == "assembly" || str == "assembler") {
|
} else if (str == "asm" || str == "assembly" || str == "assembler") {
|
||||||
build_context.build_mode = BuildMode_Assembly;
|
build_context.build_mode = BuildMode_Assembly;
|
||||||
|
} else if (str == "llvm" || str == "llvm-ir") {
|
||||||
|
build_context.build_mode = BuildMode_LLVM_IR;
|
||||||
} else {
|
} else {
|
||||||
gb_printf_err("Unknown build mode '%.*s'\n", LIT(str));
|
gb_printf_err("Unknown build mode '%.*s'\n", LIT(str));
|
||||||
bad_flags = true;
|
bad_flags = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user