#include "firm_cmdline.h"
#include "firm_timing.h"
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
#if defined(_DEBUG) || defined(FIRM_DEBUG)
#define DBG(x) dbg_printf x
#else
ir_graph *irg;
unsigned aa_opt;
+ /* FIXME: cloning might ADD new graphs. */
irg_dump_no = calloc(get_irp_last_idx(), sizeof(*irg_dump_no));
set_opt_strength_red(firm_opt.strength_red);
CHECK_ALL(firm_opt.check_all);
}
- if (firm_opt.tail_rec) {
- timer_push(TV_TAIL_REC);
- opt_tail_recursion();
+ /* first step: kill dead code */
+ for (i = 0; i < get_irp_n_irgs(); i++) {
+ irg = current_ir_graph = get_irp_irg(i);
+ /* Confirm construction currently can only handle blocks with only one control
+ flow predecessor. Calling optimize_cf here removes Bad predecessors and help
+ the optimization of switch constructs. */
+ timer_push(TV_CF_OPT);
+ optimize_graph_df(irg);
+ optimize_cf(irg);
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);
+ optimize_funccalls(firm_const_exists, NULL);
timer_pop();
DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "func_call");
CHECK_ALL(firm_opt.check_all);
}
- if (firm_opt.do_inline) {
- timer_push(TV_INLINE);
- inline_leave_functions(500, 80, 30, FALSE);
- timer_pop();
- DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "inl");
- CHECK_ALL(firm_opt.check_all);
- }
+ /* do lowering on the const code irg */
+ lower_const_code();
for (i = 0; i < get_irp_n_irgs(); i++) {
irg = current_ir_graph = 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)
if (firm_opt.luffig) {
opt_ldst2(irg);
DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "ldst2");
+ CHECK_ONE(firm_opt.check_all, irg);
}
timer_push(TV_CF_OPT);
irg_verify(irg, VRFY_ENFORCE_SSA);
}
- if (firm_opt.loop_unrolling) {
- timer_push(TV_LOOP_UNROLL);
- optimize_loop_unrolling(irg);
- timer_pop();
- DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "loop");
- CHECK_ONE(firm_opt.check_all, irg);
- }
-
if (firm_opt.load_store) {
timer_push(TV_LOAD_STORE);
optimize_load_store(irg);
}
timer_push(TV_OSR);
- opt_osr(current_ir_graph, osr_flag_default /*| osr_flag_ignore_x86_shift*/);
+ opt_osr(current_ir_graph, osr_flag_default | osr_flag_keep_reg_pressure | osr_flag_ignore_x86_shift);
timer_pop();
DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, irg, "stred");
CHECK_ONE(firm_opt.check_all, irg);
CHECK_ONE(firm_opt.check_all, irg);
}
+ if (firm_opt.do_inline) {
+ inline_functions(500, 50);
+ DUMP_ALL_C(firm_dump.ir_graph && firm_dump.all_phases, "inl");
+ CHECK_ALL(firm_opt.check_all);
+ }
if (firm_opt.cloning) {
proc_cloning((float)firm_opt.clone_threshold);
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_dump.ir_graph) {
DUMP_ALL(firm_dump.ir_graph, "-opt");
/* verify optimized graphs */
- for (i = get_irp_n_irgs() - 1; i >= 0; --i)
- irg_verify(get_irp_irg(i), VRFY_ENFORCE_SSA);
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *irg = get_irp_irg(i);
+ irg_verify(irg, VRFY_ENFORCE_SSA);
+ }
if (firm_dump.statistic & STAT_AFTER_OPT)
stat_dump_snapshot(input_filename, "opt");
} /* compute_type_size */
/**
- * layout all types of the Firm graph
+ * layout all non-frame types of the Firm graph
*/
static void compute_type_sizes(void)
{
int i;
ir_type *tp;
- ir_graph *irg;
- /* all frame types */
- for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- irg = get_irp_irg(i);
- /* do not optimize away variables in debug mode */
- if (firm_opt.debug_mode == DBG_MODE_NONE)
- opt_frame_irg(irg);
- compute_type_size(get_irg_frame_type(irg));
- }
-
- /* all other types */
+ /* all non-frame other types */
for (i = get_irp_n_types() - 1; i >= 0; --i) {
tp = get_irp_type(i);
compute_type_size(tp);
}
} /* compute_type_sizes */
+/**
+ * layout all frame-types of the Firm graph
+ */
+static void compute_frame_type_sizes(void)
+{
+ int i;
+ ir_graph *irg;
+
+ /* all frame types */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ irg = get_irp_irg(i);
+ /* do not optimize away variables in debug mode */
+ if (firm_opt.debug_mode == DBG_MODE_NONE)
+ opt_frame_irg(irg);
+ compute_type_size(get_irg_frame_type(irg));
+ }
+} /* compute_frame_type_sizes */
+
/**
* do Firm lowering
*
}
timer_push(TV_DW_LOWER);
lower_dw_ops(&init);
- DUMP_ALL(firm_dump.ir_graph, "-dw");
timer_pop();
}
CHECK_ONE(firm_opt.check_all, current_ir_graph);
}
-// set_opt_global_cse(0);
timer_push(TV_LOAD_STORE);
optimize_load_store(current_ir_graph);
timer_pop();
set_opt_precise_exc_context(firm_opt.precise_exc);
set_opt_fragile_ops(firm_opt.fragile_ops);
+ /* Sel node cannot produce NULL pointers */
+ set_opt_sel_based_null_check_elim(1);
+
/* dynamic dispatch works currently only if whole world scenarios */
set_opt_dyn_meth_dispatch(0);
/* computes the sizes of all types that are still not computed */
compute_type_sizes();
+ /* lower copyb nodes */
+ for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+ ir_graph *irg = get_irp_irg(i);
+ lower_CopyB(irg, 128, 4);
+ }
+
if (firm_dump.statistic & STAT_BEFORE_OPT) {
stat_dump_snapshot(input_filename, "noopt");
}
if (firm_opt.lower)
do_firm_lowering(input_filename);
+ /* computes the sizes of all frame types */
+ compute_frame_type_sizes();
+
/* set the phase to low */
for (i = get_irp_n_irgs() - 1; i >= 0; --i)
set_irg_phase_low(get_irp_irg(i));