timer_start(TV_ALL_OPT);
- if (firm_opt.remove_unused) {
- ir_entity **keep_methods;
- int arr_len;
-
- /* Analysis that finds the free methods,
- i.e. methods that are dereferenced.
- Optimizes polymorphic calls :-). */
- cgana(&arr_len, &keep_methods);
-
- /* Remove methods that are never called. */
- gc_irgs(arr_len, keep_methods);
-
- free(keep_methods);
- }
-
if (! firm_opt.freestanding) {
rts_map();
DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "rts");
CHECK_ALL(firm_opt.check_all);
}
+ if (firm_opt.combo) {
+ for (i = 0; i < get_irp_n_irgs(); i++) {
+ timer_push(TV_COMBO);
+ irg = get_irp_irg(i);
+ combo(irg);
+ timer_pop();
+ DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "combo");
+ CHECK_ONE(firm_opt.check_all, irg);
+ }
+ }
+
/* first step: kill dead code */
for (i = 0; i < get_irp_n_irgs(); i++) {
irg = current_ir_graph = get_irp_irg(i);
timer_pop();
}
+ if (firm_opt.remove_unused) {
+ ir_entity **keep_methods;
+ int arr_len;
+
+ timer_push(TV_CGANA);
+ /* Analysis that finds the free methods,
+ i.e. methods that are dereferenced.
+ Optimizes polymorphic calls :-). */
+ cgana(&arr_len, &keep_methods);
+
+ /* Remove methods that are never called. */
+ gc_irgs(arr_len, keep_methods);
+
+ free(keep_methods);
+ timer_pop();
+ }
+
+ if (firm_opt.tail_rec) {
+ timer_push(TV_TAIL_REC);
+ opt_tail_recursion();
+ timer_pop();
+
+ DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "tail_rec");
+ CHECK_ALL(firm_opt.check_all);
+ }
if (firm_opt.func_calls) {
timer_push(TV_REAL_FUNC_CALL);
optimize_funccalls(firm_const_exists, NULL);
compute_doms(irg);
CHECK_ONE(firm_opt.check_all, irg);
- if (firm_opt.code_place) {
+ if (firm_opt.gcse) {
timer_push(TV_CODE_PLACE);
set_opt_global_cse(1);
optimize_graph_df(irg);
DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "cfopt");
CHECK_ONE(firm_opt.check_all, irg);
- irg_verify(irg, VRFY_ENFORCE_SSA);
- if (firm_opt.gvn_pre) {
- do_gvn_pre(irg);
- DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "pre");
- CHECK_ONE(firm_opt.check_all, irg);
- irg_verify(irg, VRFY_ENFORCE_SSA);
- }
-
if (firm_opt.load_store) {
timer_push(TV_LOAD_STORE);
optimize_load_store(irg);
CHECK_ONE(firm_opt.check_all, irg);
}
+ lower_Switch(irg, 128);
+ DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "lower_switch");
+
/* should we really remove the Confirm here? */
if (firm_opt.confirm) {
timer_push(TV_CONFIRM_CREATE);
timer_pop();
}
+ if (firm_opt.gvn_pre) {
+ do_gvn_pre(irg);
+ DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "pre");
+ CHECK_ONE(firm_opt.check_all, irg);
+ irg_verify(irg, VRFY_ENFORCE_SSA);
+ }
+
+ if (! firm_opt.gcse) {
+ timer_push(TV_CODE_PLACE);
+ optimize_graph_df(irg);
+ place_code(irg);
+ timer_pop();
+ DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "place");
+ CHECK_ONE(firm_opt.check_all, irg);
+ }
+
compute_doms(irg);
compute_postdoms(irg);
DUMP_ONE_CFG_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "dom");
DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "clone");
CHECK_ALL(firm_opt.check_all);
}
- if (firm_opt.tail_rec) {
- timer_push(TV_TAIL_REC);
- opt_tail_recursion();
- timer_pop();
-
- DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "tail_rec");
- CHECK_ALL(firm_opt.check_all);
- }
if (firm_opt.cond_eval) {
for (i = 0; i < get_irp_n_irgs(); i++) {
timer_pop();
DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "cond_eval");
CHECK_ONE(firm_opt.check_all, irg);
-
- timer_push(TV_CF_OPT);
- optimize_cf(irg);
- timer_pop();
- DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "cfopt");
- CHECK_ONE(firm_opt.check_all, irg);
}
}
+ /* final run of local optimizations */
+ for (i = 0; i < get_irp_n_irgs(); i++) {
+ irg = get_irp_irg(i);
+ timer_push(TV_LOCAL_OPT);
+ optimize_graph_df(irg);
+ timer_pop();
+ DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "local_opt");
+ CHECK_ONE(firm_opt.check_all, irg);
+
+ timer_push(TV_CF_OPT);
+ optimize_cf(irg);
+ timer_pop();
+ DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "cfopt");
+ CHECK_ONE(firm_opt.check_all, irg);
+ }
+
if (firm_dump.ir_graph) {
/* recompute backedges for nicer dumps */
for (i = 0; i < get_irp_n_irgs(); i++)
ir_entity **keep_methods;
int arr_len;
+ timer_push(TV_CGANA);
/* Analysis that finds the free methods,
i.e. methods that are dereferenced.
Optimizes polymorphic calls :-). */
gc_irgs(arr_len, keep_methods);
free(keep_methods);
+ timer_pop();
}
save_optimization_state(&state);
set_optimize(1);
set_opt_constant_folding(1);
+ set_opt_algebraic_simplification(1);
for (i = 0; i < dims; ++i) {
ir_node *lower = get_array_lower_bound(ty, i);
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
current_ir_graph = get_irp_irg(i);
- if (firm_opt.code_place)
+ 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.code_place)
+ if (! firm_opt.gcse)
CHECK_ONE(firm_opt.check_all, current_ir_graph);
- if (firm_opt.code_place) {
+ if (firm_opt.gcse) {
timer_push(TV_CODE_PLACE);
place_code(current_ir_graph);
set_opt_global_cse(0);
void gen_firm_init(void)
{
firm_parameter_t params;
- char *dump_filter;
unsigned pattern = 0;
/* the automatic state is only set if inlining is enabled */
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);
if (firm_opt.enabled) {
set_optimize(1);
set_opt_constant_folding(firm_opt.const_folding);
+ set_opt_algebraic_simplification(firm_opt.const_folding);
set_opt_cse(firm_opt.cse);
- set_opt_global_cse (0);
+ set_opt_global_cse(0);
set_opt_unreachable_code(1);
set_opt_control_flow(firm_opt.control_flow);
set_opt_control_flow_weak_simplification(1);
set_opt_control_flow_strong_simplification(1);
- }
- else
+ } else {
set_optimize(0);
-
- dump_filter = getenv("FIRM_DUMP_FILTER");
- if (dump_filter)
- only_dump_method_with_name(new_id_from_str(dump_filter));
+ }
/* do not dump entity ld names */
dump_ld_names(0);
/* all graphs are finalized, set the irp phase to high */
set_irp_phase_state(phase_high);
+ /* BEWARE: kill unreachable code before doing compound lowering */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *irg = get_irp_irg(i);
+ optimize_cf(irg);
+ }
+
/* lower all compound call return values */
lower_compound_params();