Commit 03e9d58f authored by Matthias Braun's avatar Matthias Braun
Browse files

be: add convenience function for flagtest+dump

parent 97aa32b4
......@@ -83,8 +83,7 @@ static void TEMPLATE_prepare_graph(ir_graph *irg)
be_timer_push(T_CODEGEN);
TEMPLATE_transform_graph(irg);
be_timer_pop(T_CODEGEN);
if (be_options.dump_flags & DUMP_BE)
dump_ir_graph(irg, "code-selection");
be_dump(DUMP_BE, irg, "code-selection");
}
......
......@@ -245,16 +245,13 @@ static void amd64_end_codegeneration(void *self)
static void amd64_prepare_graph(ir_graph *irg)
{
be_abi_introduce(irg);
if (be_options.dump_flags & DUMP_BE) {
dump_ir_graph(irg, "abi");
}
be_dump(DUMP_BE, irg, "abi");
be_timer_push(T_CODEGEN);
amd64_transform_graph(irg);
be_timer_pop(T_CODEGEN);
if (be_options.dump_flags & DUMP_BE)
dump_ir_graph(irg, "code-selection");
be_dump(DUMP_BE, irg, "code-selection");
}
/**
......
......@@ -110,8 +110,7 @@ static void arm_prepare_graph(ir_graph *irg)
be_timer_push(T_CODEGEN);
arm_transform_graph(irg);
be_timer_pop(T_CODEGEN);
if (be_options.dump_flags & DUMP_BE)
dump_ir_graph(irg, "code-selection");
be_dump(DUMP_BE, irg, "code-selection");
/* do local optimizations (mainly CSE) */
local_optimize_graph(irg);
......
......@@ -18,6 +18,7 @@
#include "firm_types.h"
#include "pmap.h"
#include "timing.h"
#include "irdump.h"
enum {
DUMP_NONE = 0,
......@@ -124,4 +125,17 @@ static inline void be_timer_pop(be_timer_id_t id)
ir_timer_pop(be_timers[id]);
}
/**
* A wrapper around a firm dumper. Dumps only, if flags are enabled.
*
* @param mask a bitmask containing the reason what will be dumped
* @param irg the IR graph to dump
* @param suffix the suffix for the dumper
*/
static inline void be_dump(int mask, ir_graph *irg, const char *suffix)
{
if (be_options.dump_flags & mask)
dump_ir_graph(irg, suffix);
}
#endif
......@@ -369,21 +369,6 @@ static void be_done_env(be_main_env_t *env)
free_type(env->pic_symbols_type);
}
/**
* A wrapper around a firm dumper. Dumps only, if
* flags are enabled.
*
* @param mask a bitmask containing the reason what will be dumped
* @param irg the IR graph to dump
* @param suffix the suffix for the dumper
* @param dumper the dumper to be called
*/
static void dump(int mask, ir_graph *irg, const char *suffix)
{
if (be_options.dump_flags & mask)
dump_ir_graph(irg, suffix);
}
/**
* Prepare a backend graph for code generation and initialize its irg
*/
......@@ -392,7 +377,7 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
/* don't duplicate locals in backend when dumping... */
ir_remove_dump_flags(ir_dump_flag_consts_local);
dump(DUMP_INITIAL, irg, "begin");
be_dump(DUMP_INITIAL, irg, "begin");
assure_irg_properties(irg,
IR_GRAPH_PROPERTY_NO_BADS
......@@ -408,7 +393,7 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
be_info_init_irg(irg);
birg->lv = be_liveness_new(irg);
dump(DUMP_INITIAL, irg, "prepared");
be_dump(DUMP_INITIAL, irg, "prepared");
}
int be_timing;
......@@ -578,7 +563,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_schedule_graph(irg);
be_timer_pop(T_SCHED);
dump(DUMP_SCHED, irg, "sched");
be_dump(DUMP_SCHED, irg, "sched");
/* check schedule */
be_timer_push(T_VERIFY);
......@@ -598,7 +583,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
assure_constraints(irg);
be_timer_pop(T_CONSTR);
dump(DUMP_SCHED, irg, "assured");
be_dump(DUMP_SCHED, irg, "assured");
/* stuff needs to be done after scheduling but before register allocation */
be_timer_push(T_RA_PREPARATION);
......@@ -611,7 +596,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_abi_fix_stack_nodes(irg);
be_timer_pop(T_ABI);
dump(DUMP_SCHED, irg, "fix_stack");
be_dump(DUMP_SCHED, irg, "fix_stack");
/* check schedule */
be_timer_push(T_VERIFY);
......@@ -629,14 +614,14 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
stat_ev_dbl("bemain_costs_before_ra", be_estimate_irg_costs(irg));
dump(DUMP_RA, irg, "ra");
be_dump(DUMP_RA, irg, "ra");
be_timer_push(T_FINISH);
if (arch_env->impl->finish_graph != NULL)
arch_env->impl->finish_graph(irg);
be_timer_pop(T_FINISH);
dump(DUMP_FINAL, irg, "finish");
be_dump(DUMP_FINAL, irg, "finish");
if (stat_ev_enabled) {
stat_ev_ull("bemain_insns_finish", be_count_insns(irg));
......@@ -664,7 +649,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
arch_env->impl->emit(irg);
be_timer_pop(T_EMIT);
dump(DUMP_FINAL, irg, "end");
be_dump(DUMP_FINAL, irg, "end");
restore_optimization_state(&state);
......
......@@ -209,7 +209,7 @@ typedef void (*schedule_func) (ir_graph *irg);
void be_register_scheduler(const char *name, schedule_func func);
/**
* schedule a graph with the currenty selected scheduler.
* schedule a graph with the currently selected scheduler.
*/
void be_schedule_graph(ir_graph *irg);
......
......@@ -1074,7 +1074,6 @@ static void ia32_prepare_graph(ir_graph *irg)
struct obstack *obst = be_get_be_obst(irg);
ia32_irg_data_t *irg_data = OALLOCZ(obst, ia32_irg_data_t);
irg_data->dump = (be_options.dump_flags & DUMP_BE) ? 1 : 0;
be_birg_from_irg(irg)->isa_link = irg_data;
if (gprof) {
......@@ -1097,8 +1096,7 @@ static void ia32_prepare_graph(ir_graph *irg)
}
be_abi_introduce(irg);
if (irg_data->dump)
dump_ir_graph(irg, "abi");
be_dump(DUMP_BE, irg, "abi");
be_timer_push(T_CODEGEN);
#ifdef FIRM_GRGEN_BE
......@@ -1122,8 +1120,7 @@ static void ia32_prepare_graph(ir_graph *irg)
#endif
be_timer_pop(T_CODEGEN);
if (irg_data->dump)
dump_ir_graph(irg, "code-selection");
be_dump(DUMP_BE, irg, "code-selection");
/* do local optimizations (mainly CSE) */
optimize_graph_df(irg);
......@@ -1133,8 +1130,7 @@ static void ia32_prepare_graph(ir_graph *irg)
/* optimize address mode */
ia32_optimize_graph(irg);
if (irg_data->dump)
dump_ir_graph(irg, "opt");
be_dump(DUMP_BE, irg, "opt");
/* do code placement, to optimize the position of constants */
place_code(irg);
......@@ -1142,8 +1138,7 @@ static void ia32_prepare_graph(ir_graph *irg)
/* backend code expects that outedges are always enabled */
assure_edges(irg);
if (irg_data->dump)
dump_ir_graph(irg, "place");
be_dump(DUMP_BE, irg, "place");
}
static const tarval_mode_info mo_integer = {
......
......@@ -27,7 +27,6 @@ typedef struct ia32_intrinsic_env_t ia32_intrinsic_env_t;
typedef struct ia32_irg_data_t {
ir_node **blk_sched; /**< an array containing the scheduled blocks */
unsigned do_x87_sim:1; /**< set to 1 if x87 simulation should be enforced */
unsigned dump:1; /**< set to 1 if graphs should be dumped */
ir_node *noreg_gp; /**< unique NoReg_GP node */
ir_node *noreg_fp; /**< unique NoReg_FP node */
ir_node *noreg_xmm; /**< unique NoReg_XMM node */
......
......@@ -188,8 +188,7 @@ static void sparc_prepare_graph(ir_graph *irg)
be_timer_push(T_CODEGEN);
sparc_transform_graph(irg);
be_timer_pop(T_CODEGEN);
if (be_options.dump_flags & DUMP_BE)
dump_ir_graph(irg, "code-selection");
be_dump(DUMP_BE, irg, "code-selection");
}
static bool sparc_modifies_flags(const ir_node *node)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment