From 719bfe87c407f6bbafd996dd48be7b2a624e0d69 Mon Sep 17 00:00:00 2001 From: Moritz Kroll Date: Fri, 6 Feb 2009 00:48:26 +0000 Subject: [PATCH] Added --export-ir parameter and support for .ir input files (at least one simple programm with two functions already survives a round trip) [r25441] --- main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.c b/main.c index b4600e7..dd38dae 100644 --- a/main.c +++ b/main.c @@ -141,6 +141,7 @@ typedef enum filetype_t { FILETYPE_ASSEMBLER, FILETYPE_PREPROCESSED_ASSEMBLER, FILETYPE_OBJECT, + FILETYPE_IR, FILETYPE_UNKNOWN } filetype_t; @@ -500,6 +501,7 @@ typedef enum compile_mode_t { ParseOnly, Compile, CompileDump, + CompileExportIR, CompileAssemble, CompileAssembleLink, LexTest, @@ -1055,6 +1057,8 @@ int main(int argc, char **argv) } dumpfunction = argv[i]; mode = CompileDump; + } else if (streq(option, "export-ir")) { + mode = CompileExportIR; } else { fprintf(stderr, "error: unknown argument '%s'\n", arg); argument_errors = true; @@ -1082,6 +1086,7 @@ int main(int argc, char **argv) streq(suffix, "cpp") ? FILETYPE_CXX : streq(suffix, "cxx") ? FILETYPE_CXX : streq(suffix, "h") ? FILETYPE_C : + streq(suffix, "ir") ? FILETYPE_IR : streq(suffix, "o") ? FILETYPE_OBJECT : streq(suffix, "s") ? FILETYPE_PREPROCESSED_ASSEMBLER : streq(suffix, "so") ? FILETYPE_OBJECT : @@ -1184,6 +1189,10 @@ int main(int argc, char **argv) ".vcg"); outname = outnamebuf; break; + case CompileExportIR: + get_output_name(outnamebuf, sizeof(outnamebuf), filename, ".ir"); + outname = outnamebuf; + break; case CompileAssembleLink: #ifdef _WIN32 outname = "a.exe"; @@ -1365,6 +1374,7 @@ do_parsing: translation_unit_to_firm(unit); +graph_built: if (mode == ParseOnly) { continue; } @@ -1394,11 +1404,21 @@ do_parsing: exit(0); } + if (mode == CompileExportIR) { + fclose(out); + ir_export(outname); + exit(0); + } + gen_firm_finish(asm_out, filename, /*c_mode=*/1, have_const_functions); if (asm_out != out) { fclose(asm_out); } + } else if (filetype == FILETYPE_IR) { + fclose(in); + ir_import(filename); + goto graph_built; } else if (filetype == FILETYPE_PREPROCESSED_ASSEMBLER) { copy_file(asm_out, in); if (in == preprocessed_in) { -- 2.20.1