FILETYPE_ASSEMBLER,
FILETYPE_PREPROCESSED_ASSEMBLER,
FILETYPE_OBJECT,
+ FILETYPE_IR,
FILETYPE_UNKNOWN
} filetype_t;
ParseOnly,
Compile,
CompileDump,
+ CompileExportIR,
CompileAssemble,
CompileAssembleLink,
LexTest,
}
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;
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 :
".vcg");
outname = outnamebuf;
break;
+ case CompileExportIR:
+ get_output_name(outnamebuf, sizeof(outnamebuf), filename, ".ir");
+ outname = outnamebuf;
+ break;
case CompileAssembleLink:
#ifdef _WIN32
outname = "a.exe";
translation_unit_to_firm(unit);
+graph_built:
if (mode == ParseOnly) {
continue;
}
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) {