From 8b288a207254112a3b42ecbef46cecef9f28e811 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 20 Jan 2018 16:16:59 +0000 Subject: [PATCH] Reimplement opt stage --- build.bat | 4 +-- examples/demo.odin | 6 +---- src/main.cpp | 64 +++++++++++++++++++++++----------------------- 3 files changed, 34 insertions(+), 40 deletions(-) diff --git a/build.bat b/build.bat index 1d0503868..1a51f153b 100644 --- a/build.bat +++ b/build.bat @@ -41,12 +41,10 @@ set linker_settings=%libs% %linker_flags% del *.pdb > NUL 2> NUL del *.ilk > NUL 2> NUL -rem odin run examples/node-lang/node-lang.odin && goto end_of_build - cl %compiler_settings% "src\main.cpp" ^ /link %linker_settings% -OUT:%exe_name% ^ - && odin build examples/demo.odin -show-timings + && odin run examples/demo.odin rem && odin docs core/fmt.odin del *.obj > NUL 2> NUL diff --git a/examples/demo.odin b/examples/demo.odin index 60b981a71..a3d43acae 100644 --- a/examples/demo.odin +++ b/examples/demo.odin @@ -665,11 +665,7 @@ named_proc_parameters :: proc() { } main :: proc() { - Foo :: union { - - } - - when false { + when true { general_stuff(); default_struct_values(); union_type(); diff --git a/src/main.cpp b/src/main.cpp index 512a67f14..be5dd4669 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -719,42 +719,42 @@ int main(int arg_count, char **arg_ptr) { i32 exit_code = 0; - // timings_start_section(&timings, str_lit("llvm-opt")); - // #if defined(GB_SYSTEM_WINDOWS) - // // For more passes arguments: http://llvm.org/docs/Passes.html - // exit_code = system_exec_command_line_app("llvm-opt", false, - // "\"%.*sbin/opt\" \"%.*s\".ll -o \"%.*s\".bc %.*s " - // "-mem2reg " - // "-memcpyopt " - // "-die " - // "", - // LIT(build_context.ODIN_ROOT), - // LIT(output_base), LIT(output_base), - // LIT(build_context.opt_flags)); - // if (exit_code != 0) { - // return exit_code; - // } - // #else - // // NOTE(zangent): This is separate because it seems that LLVM tools are packaged - // // with the Windows version, while they will be system-provided on MacOS and GNU/Linux - // exit_code = system_exec_command_line_app("llvm-opt", false, - // "opt \"%.*s.ll\" -o \"%.*s\".bc %.*s " - // "-mem2reg " - // "-memcpyopt " - // "-die " - // "", - // LIT(output_base), LIT(output_base), - // LIT(build_context.opt_flags)); - // if (exit_code != 0) { - // return exit_code; - // } - // #endif + timings_start_section(&timings, str_lit("llvm-opt")); + #if defined(GB_SYSTEM_WINDOWS) + // For more passes arguments: http://llvm.org/docs/Passes.html + exit_code = system_exec_command_line_app("llvm-opt", false, + "\"%.*sbin/opt\" \"%.*s\".ll -o \"%.*s\".bc %.*s " + "-mem2reg " + "-memcpyopt " + "-die " + "", + LIT(build_context.ODIN_ROOT), + LIT(output_base), LIT(output_base), + LIT(build_context.opt_flags)); + if (exit_code != 0) { + return exit_code; + } + #else + // NOTE(zangent): This is separate because it seems that LLVM tools are packaged + // with the Windows version, while they will be system-provided on MacOS and GNU/Linux + exit_code = system_exec_command_line_app("llvm-opt", false, + "opt \"%.*s.ll\" -o \"%.*s\".bc %.*s " + "-mem2reg " + "-memcpyopt " + "-die " + "", + LIT(output_base), LIT(output_base), + LIT(build_context.opt_flags)); + if (exit_code != 0) { + return exit_code; + } + #endif #if defined(GB_SYSTEM_WINDOWS) timings_start_section(&timings, str_lit("llvm-llc")); // For more arguments: http://llvm.org/docs/CommandGuide/llc.html exit_code = system_exec_command_line_app("llvm-llc", false, - "\"%.*sbin/llc\" \"%.*s.ll\" -filetype=obj -O%d " + "\"%.*sbin/llc\" \"%.*s.bc\" -filetype=obj -O%d " "-o \"%.*s.obj\" " "%.*s " // "-debug-pass=Arguments " @@ -829,7 +829,7 @@ int main(int arg_count, char **arg_ptr) { timings_start_section(&timings, str_lit("llvm-llc")); // For more arguments: http://llvm.org/docs/CommandGuide/llc.html exit_code = system_exec_command_line_app("llc", false, - "llc \"%.*s.ll\" -filetype=obj -relocation-model=pic -O%d " + "llc \"%.*s.bc\" -filetype=obj -relocation-model=pic -O%d " "%.*s " // "-debug-pass=Arguments " "%s"