X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=driver%2Ffirm_opt.c;h=5843af7b88c21fa2a9184aa300d5ffcf80bd9206;hb=ce2e13de664ebd52daf7de055790546ecfece6ff;hp=03560ce2e4c8a2e251d9f3fb3d4a07bdcd04c5ed;hpb=186aa71df8323431eaaa29f93e9602aa2ffff0c0;p=cparser diff --git a/driver/firm_opt.c b/driver/firm_opt.c index 03560ce..5843af7 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -6,6 +6,9 @@ * * $Id$ */ + +#include + #include #include #include @@ -19,15 +22,12 @@ #include "firm_codegen.h" #include "firm_cmdline.h" #include "firm_timing.h" - -#ifdef _WIN32 -#define snprintf _snprintf -#endif +#include "ast2firm.h" #if defined(_DEBUG) || defined(FIRM_DEBUG) #define DBG(x) dbg_printf x #else -#define DBG(x) +#define DBG(x) ((void)0) #endif /* _DEBUG || FIRM_DEBUG */ @@ -112,8 +112,6 @@ static create_intrinsic_fkt *arch_create_intrinsic = NULL; static void *create_intrinsic_ctx = NULL; static const ir_settings_if_conv_t *if_conv_info = NULL; -ir_mode *firm_imm_fp_mode = NULL; - /* entities of runtime functions */ ir_entity_ptr rts_entities[rts_max]; @@ -309,6 +307,7 @@ static void do_optimize_funccalls(void) static void do_gcse(ir_graph *irg) { set_opt_global_cse(1); + optimize_graph_df(irg); place_code(irg); set_opt_global_cse(0); } @@ -330,7 +329,7 @@ static void do_stred(ir_graph *irg) static void do_inline(void) { - inline_functions(500, 50); + inline_functions(firm_opt.inline_maxsize, firm_opt.inline_threshold); } static void do_cloning(void) @@ -378,7 +377,7 @@ static opt_config_t opts[] = { { OPT_TARGET_IRG, "place", (func_ptr_t) place_code, true, true, true, TV_CODE_PLACE }, { OPT_TARGET_IRG, "confirm", (func_ptr_t) construct_confirms, true, true, true, TV_CONFIRM_CREATE }, { OPT_TARGET_IRG, "ldst", (func_ptr_t) optimize_load_store, true, true, true, TV_LOAD_STORE }, - { OPT_TARGET_IRG, "ldst2", (func_ptr_t) opt_ldst2, true, true, true, -1 }, + { OPT_TARGET_IRG, "sync", (func_ptr_t) opt_sync, true, true, true, -1 }, { OPT_TARGET_IRG, "lower", (func_ptr_t) do_lower_highlevel, true, true, true, -1 }, { OPT_TARGET_IRG, "deconv", (func_ptr_t) conv_opt, true, true, true, TV_DECONV }, { OPT_TARGET_IRG, "condeval", (func_ptr_t) opt_cond_eval, true, true, true, TV_COND_EVAL }, @@ -386,6 +385,7 @@ static opt_config_t opts[] = { { OPT_TARGET_IRG, "gvnpre", (func_ptr_t) do_gvn_pre, true, true, true, -1 }, { OPT_TARGET_IRG, "ifconv", (func_ptr_t) do_if_conv, true, true, true, TV_IF_CONV }, { OPT_TARGET_IRG, "bool", (func_ptr_t) opt_bool, true, true, true, -1 }, + { OPT_TARGET_IRG, "shape-blocks",(func_ptr_t) shape_blocks, true, true, true, TV_END_MELT }, { OPT_TARGET_IRG, "stred", (func_ptr_t) do_stred, true, true, true, TV_OSR }, { OPT_TARGET_IRG, "dead", (func_ptr_t) dead_node_elimination, true, false, true, TV_DEAD_NODE }, { OPT_TARGET_IRP, "inline", (func_ptr_t) do_inline, true, true, true, -1 }, @@ -478,6 +478,7 @@ static void do_firm_optimizations(const char *input_filename) set_opt_scalar_replacement(firm_opt.scalar_replace); set_opt_auto_create_sync(firm_opt.auto_sync); set_opt_alias_analysis(firm_opt.alias_analysis); + set_opt_combo(firm_opt.combo); aa_opt = aa_opt_no_opt; if (firm_opt.strict_alias) @@ -496,13 +497,14 @@ static void do_firm_optimizations(const char *input_filename) set_opt_enabled("place", !firm_opt.gcse); set_opt_enabled("confirm", firm_opt.confirm); set_opt_enabled("remove_confirms", firm_opt.confirm); - set_opt_enabled("ldst2", firm_opt.luffig); + set_opt_enabled("sync", firm_opt.sync); set_opt_enabled("ldst", firm_opt.load_store); set_opt_enabled("deconv", firm_opt.deconv); set_opt_enabled("condeval", firm_opt.cond_eval); set_opt_enabled("gvnpre", firm_opt.gvn_pre); set_opt_enabled("ifconv", firm_opt.if_conversion); set_opt_enabled("bool", firm_opt.bool_opt); + set_opt_enabled("shape-blocks", firm_opt.shape_blocks); set_opt_enabled("inline", firm_opt.do_inline); set_opt_enabled("clone", firm_opt.cloning); set_opt_enabled("combo", firm_opt.combo); @@ -533,12 +535,6 @@ static void do_firm_optimizations(const char *input_filename) for (i = 0; i < get_irp_n_irgs(); i++) { ir_graph *irg = get_irp_irg(i); -#ifdef FIRM_EXT_GRS - /* If SIMD optimization is on, make sure we have only 1 return */ - if (firm_ext_grs.create_pattern || firm_ext_grs.simd_opt) - do_irg_opt("onereturn"); -#endif - do_irg_opt(irg, "scalar"); do_irg_opt(irg, "local"); do_irg_opt(irg, "reassoc"); @@ -554,13 +550,11 @@ static void do_firm_optimizations(const char *input_filename) do_irg_opt(irg, "local"); } - do_irg_opt(irg, "ldst2"); do_irg_opt(irg, "controlflow"); do_irg_opt(irg, "ldst"); do_irg_opt(irg, "lower"); do_irg_opt(irg, "deconv"); do_irg_opt(irg, "condeval"); - do_irg_opt(irg, "lower_switch"); do_irg_opt(irg, "remove_confirms"); do_irg_opt(irg, "gvnpre"); do_irg_opt(irg, "place"); @@ -573,6 +567,8 @@ static void do_firm_optimizations(const char *input_filename) } do_irg_opt(irg, "bool"); + do_irg_opt(irg, "shape-blocks"); + do_irg_opt(irg, "lower_switch"); do_irg_opt(irg, "stred"); do_irg_opt(irg, "local"); do_irg_opt(irg, "dead"); @@ -797,21 +793,14 @@ static void do_firm_lowering(const char *input_filename) { int i; - /* do class lowering and vtbl creation */ -// lower_classes_to_struct("vtbl", "m"); - -#if 0 - timer_push(TV_LOWER); - lower_highlevel(); - timer_pop(); -#endif - if (firm_opt.lower_ll) { lwrdw_param_t init = { 1, 1, - mode_Ls, mode_Lu, - mode_Is, mode_Iu, + get_atomic_mode(ATOMIC_TYPE_LONGLONG), + get_atomic_mode(ATOMIC_TYPE_ULONGLONG), + get_atomic_mode(ATOMIC_TYPE_INT), + get_atomic_mode(ATOMIC_TYPE_UINT), def_create_intrinsic_fkt, NULL }; @@ -843,14 +832,9 @@ static void do_firm_lowering(const char *input_filename) /* run reassociation first on all graphs BEFORE the architecture dependent optimizations are enabled */ for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - current_ir_graph = get_irp_irg(i); - - timer_push(TV_REASSOCIATION); - optimize_reassociation(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "reassoc"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - } + ir_graph *irg = get_irp_irg(i); + do_irg_opt(irg, "reassoc"); + } /* enable architecture dependent optimizations */ arch_dep_set_opts((arch_dep_opts_t) @@ -859,61 +843,23 @@ static void do_firm_lowering(const char *input_filename) (firm_opt.mods ? arch_dep_mod_by_const : arch_dep_none) )); for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - current_ir_graph = get_irp_irg(i); - - if (firm_opt.gcse) - set_opt_global_cse(1); - - timer_push(TV_LOCAL_OPT); - optimize_graph_df(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "lopt"); - if (! firm_opt.gcse) - CHECK_ONE(firm_opt.check_all, current_ir_graph); - - if (firm_opt.gcse) { - timer_push(TV_CODE_PLACE); - place_code(current_ir_graph); - set_opt_global_cse(0); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "place"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - } - - timer_push(TV_LOAD_STORE); - optimize_load_store(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "ldst"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - + ir_graph *irg = get_irp_irg(i); - timer_push(TV_LOCAL_OPT); - optimize_graph_df(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "lopt"); + current_ir_graph = irg; - timer_push(TV_CF_OPT); - optimize_cf(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "cf"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "gcse"); + do_irg_opt(irg, "ldst"); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "controlflow"); if (firm_opt.if_conversion) { - timer_push(TV_IF_CONV); - opt_if_conv(current_ir_graph, if_conv_info); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "if"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - - timer_push(TV_LOCAL_OPT); - optimize_graph_df(current_ir_graph); - timer_pop(); - timer_push(TV_CF_OPT); - optimize_cf(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "after_if"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - } + do_irg_opt(irg, "ifconv"); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "controlflow"); + } + + do_irg_opt(current_ir_graph, "sync"); } timer_stop(TV_ALL_OPT); @@ -960,47 +906,22 @@ void gen_firm_init(void) params.cc_mask = 0; /* no regparam, cdecl */ params.builtin_dbg = NULL; - #ifdef FIRM_EXT_GRS - /* Activate Graph rewriting if SIMD optimization is turned on */ - /* This has to be done before init_firm() is called! */ - if (firm_ext_grs.simd_opt) - ext_grs_activate(); -#endif - - init_firm(¶ms); + ir_init(¶ms); if (firm_be_opt.selection == BE_FIRM_BE) { const backend_params *be_params = be_get_backend_param(); firm_opt.lower_ll = (a_byte) be_params->do_dw_lowering; - params.arch_op_settings = be_params->arch_op_settings; arch_create_intrinsic = be_params->arch_create_intrinsic_fkt; create_intrinsic_ctx = be_params->create_intrinsic_ctx; ad_param = be_params->dep_param; if_conv_info = be_params->if_conv_info; - - if (be_params->has_imm_fp_mode) - firm_imm_fp_mode = be_params->imm_fp_mode; - } - /* OS option must be set to the backend */ - switch (firm_opt.os_support) { - case OS_SUPPORT_MINGW: - firm_be_option("ia32-gasmode=mingw"); - break; - case OS_SUPPORT_MACHO: - firm_be_option("ia32-gasmode=macho"); - break; - case OS_SUPPORT_LINUX: - default: - firm_be_option("ia32-gasmode=linux"); - break; } dbg_init(NULL, NULL, dbg_snprint); edges_init_dbg(firm_opt.vrfy_edges); - //cbackend_set_debug_retrieve(dbg_retrieve); set_opt_precise_exc_context(firm_opt.precise_exc); set_opt_fragile_ops(firm_opt.fragile_ops); @@ -1135,23 +1056,6 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int new_ for (i = get_irp_n_irgs() - 1; i >= 0; --i) set_irg_phase_low(get_irp_irg(i)); - -#ifdef FIRM_EXT_GRS - /** SIMD Optimization Extensions **/ - - /* Pattern creation step. No code has to be generated, so - exit after pattern creation */ - if (firm_ext_grs.create_pattern) { - ext_grs_create_pattern(); - exit(0); - } - - /* SIMD optimization step. Uses graph patterns to find - rich instructions and rewrite */ - if (firm_ext_grs.simd_opt) - ext_grs_simd_opt(); -#endif - if (firm_dump.statistic & STAT_FINAL_IR) stat_dump_snapshot(input_filename, "final-ir"); @@ -1161,18 +1065,13 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int new_ if (firm_dump.statistic & STAT_FINAL) stat_dump_snapshot(input_filename, "final"); - -#if 0 - if (firm_opt.ycomp_dbg) - firm_finish_ycomp_debugger(); -#endif -} /* gen_firm_finish */ +} /** * Do very early initializations */ -void firm_early_init(void) { +void firm_early_init(void) +{ /* arg: need this here for command line options */ be_opt_register(); - firm_init_options(NULL, 0, NULL); -} /* firm_early_init */ +}