Commit ea051bcf authored by Matthias Braun's avatar Matthias Braun
Browse files

be: simplify verify code

parent 03e9d58f
......@@ -12,6 +12,7 @@
#define FIRM_BE_BE_T_H
#include <assert.h>
#include <stdbool.h>
#include "be.h"
#include "be_types.h"
......@@ -35,12 +36,6 @@ enum {
BE_TIME_ON
};
enum {
BE_VERIFY_OFF,
BE_VERIFY_WARN,
BE_VERIFY_ASSERT
};
/** Backend options */
struct be_options_t {
unsigned dump_flags; /**< backend dumping flags */
......@@ -49,7 +44,7 @@ struct be_options_t {
int opt_profile_use; /**< use existing profile data */
int omit_fp; /**< try to omit the frame pointer */
int pic; /**< create position independent code */
int verify_option; /**< backend verify option */
int do_verify; /**< backend verify option */
char ilp_server[128]; /**< the ilp server name */
char ilp_solver[128]; /**< the ilp solver name */
int verbose_asm; /**< dump verbose assembler */
......
......@@ -67,7 +67,6 @@
static be_ra_chordal_opts_t options = {
BE_CH_DUMP_NONE,
BE_CH_LOWER_PERM_SWAP,
BE_CH_VRFY_WARN
};
static const lc_opt_enum_int_items_t lower_perm_items[] = {
......@@ -93,13 +92,6 @@ static const lc_opt_enum_mask_items_t dump_items[] = {
{ NULL, 0 }
};
static const lc_opt_enum_int_items_t be_ch_vrfy_items[] = {
{ "off", BE_CH_VRFY_OFF },
{ "warn", BE_CH_VRFY_WARN },
{ "assert", BE_CH_VRFY_ASSERT },
{ NULL, 0 }
};
static lc_opt_enum_int_var_t lower_perm_var = {
&options.lower_perm_opt, lower_perm_items
};
......@@ -108,14 +100,9 @@ static lc_opt_enum_mask_var_t dump_var = {
&options.dump_flags, dump_items
};
static lc_opt_enum_int_var_t be_ch_vrfy_var = {
&options.vrfy_option, be_ch_vrfy_items
};
static const lc_opt_table_entry_t be_chordal_options[] = {
LC_OPT_ENT_ENUM_INT ("perm", "perm lowering options", &lower_perm_var),
LC_OPT_ENT_ENUM_MASK("dump", "select dump phases", &dump_var),
LC_OPT_ENT_ENUM_INT ("verify", "verify options", &be_ch_vrfy_var),
LC_OPT_LAST
};
......@@ -241,15 +228,12 @@ static void post_spill(be_chordal_env_t *const chordal_env, ir_graph *const irg)
be_timer_pop(T_RA_SPILL_APPLY);
/* verify schedule and register pressure */
be_timer_push(T_VERIFY);
if (chordal_env->opts->vrfy_option == BE_CH_VRFY_WARN) {
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
be_verify_schedule(irg);
be_verify_register_pressure(irg, chordal_env->cls);
} else if (chordal_env->opts->vrfy_option == BE_CH_VRFY_ASSERT) {
assert(be_verify_schedule(irg) && "Schedule verification failed");
assert(be_verify_register_pressure(irg, chordal_env->cls) && "Register pressure verification failed");
be_timer_pop(T_VERIFY);
}
be_timer_pop(T_VERIFY);
/* Color the graph. */
be_timer_push(T_RA_COLOR);
......@@ -292,7 +276,7 @@ static void post_spill(be_chordal_env_t *const chordal_env, ir_graph *const irg)
dump(BE_CH_DUMP_SSADESTR, irg, chordal_env->cls, "ssadestr");
if (chordal_env->opts->vrfy_option != BE_CH_VRFY_OFF) {
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
be_ssa_destruction_check(chordal_env);
be_timer_pop(T_VERIFY);
......@@ -375,15 +359,6 @@ static void be_ra_chordal_main(ir_graph *irg)
}
}
be_timer_push(T_VERIFY);
if (chordal_env.opts->vrfy_option == BE_CH_VRFY_WARN) {
be_verify_register_allocation(irg);
} else if (chordal_env.opts->vrfy_option == BE_CH_VRFY_ASSERT) {
assert(be_verify_register_allocation(irg)
&& "Register allocation invalid");
}
be_timer_pop(T_VERIFY);
be_timer_push(T_RA_EPILOG);
lower_nodes_after_ra(irg, options.lower_perm_opt == BE_CH_LOWER_PERM_COPY);
dump(BE_CH_DUMP_LOWER, irg, NULL, "belower-after-ra");
......
......@@ -75,17 +75,11 @@ enum {
/* lower perm options */
BE_CH_LOWER_PERM_SWAP = 1,
BE_CH_LOWER_PERM_COPY = 2,
/* verify options */
BE_CH_VRFY_OFF = 1,
BE_CH_VRFY_WARN = 2,
BE_CH_VRFY_ASSERT = 3,
};
struct be_ra_chordal_opts_t {
unsigned dump_flags;
int lower_perm_opt;
int vrfy_option;
};
void check_for_memory_operands(ir_graph *irg);
......
......@@ -66,7 +66,7 @@ be_options_t be_options = {
false, /* profile_use */
0, /* try to omit frame pointer */
0, /* create PIC code */
BE_VERIFY_WARN, /* verification level: warn */
true, /* do verification */
"", /* ilp server */
"", /* ilp solver */
1, /* verbose assembler output */
......@@ -88,27 +88,15 @@ static const lc_opt_enum_mask_items_t dump_items[] = {
{ NULL, 0 }
};
/* verify options. */
static const lc_opt_enum_int_items_t verify_items[] = {
{ "off", BE_VERIFY_OFF },
{ "warn", BE_VERIFY_WARN },
{ "assert", BE_VERIFY_ASSERT },
{ NULL, 0 }
};
static lc_opt_enum_mask_var_t dump_var = {
&be_options.dump_flags, dump_items
};
static lc_opt_enum_int_var_t verify_var = {
&be_options.verify_option, verify_items
};
static const lc_opt_table_entry_t be_main_options[] = {
LC_OPT_ENT_ENUM_MASK("dump", "dump irg on several occasions", &dump_var),
LC_OPT_ENT_BOOL ("omitfp", "omit frame pointer", &be_options.omit_fp),
LC_OPT_ENT_BOOL ("pic", "create PIC code", &be_options.pic),
LC_OPT_ENT_ENUM_INT ("verify", "verify the backend irg", &verify_var),
LC_OPT_ENT_BOOL ("verify", "verify the backend irg", &be_options.do_verify),
LC_OPT_ENT_BOOL ("time", "get backend timing statistics", &be_options.timing),
LC_OPT_ENT_BOOL ("profilegenerate", "instrument the code for execution count profiling", &be_options.opt_profile_generate),
LC_OPT_ENT_BOOL ("profileuse", "use existing profile data", &be_options.opt_profile_use),
......@@ -274,12 +262,12 @@ int be_parse_arg(const char *arg)
}
/* Perform schedule verification if requested. */
static void be_sched_verify(ir_graph *irg, int verify_opt)
static void be_sched_verify(ir_graph *irg)
{
if (verify_opt == BE_VERIFY_WARN) {
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
be_verify_schedule(irg);
} else if (verify_opt == BE_VERIFY_ASSERT) {
assert(be_verify_schedule(irg) && "Schedule verification failed.");
be_timer_pop(T_VERIFY);
}
}
......@@ -546,13 +534,11 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_timer_push(T_OTHER);
/* Verify the initial graph */
be_timer_push(T_VERIFY);
if (be_options.verify_option == BE_VERIFY_WARN) {
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
irg_verify(irg, VERIFY_ENFORCE_SSA);
} else if (be_options.verify_option == BE_VERIFY_ASSERT) {
assert(irg_verify(irg, VERIFY_ENFORCE_SSA) && "irg verification failed");
be_timer_pop(T_VERIFY);
}
be_timer_pop(T_VERIFY);
/* prepare and perform codeselection */
if (arch_env->impl->prepare_graph != NULL)
......@@ -566,9 +552,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_dump(DUMP_SCHED, irg, "sched");
/* check schedule */
be_timer_push(T_VERIFY);
be_sched_verify(irg, be_options.verify_option);
be_timer_pop(T_VERIFY);
be_sched_verify(irg);
/* introduce patterns to assure constraints */
be_timer_push(T_CONSTR);
......@@ -599,9 +583,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_dump(DUMP_SCHED, irg, "fix_stack");
/* check schedule */
be_timer_push(T_VERIFY);
be_sched_verify(irg, be_options.verify_option);
be_timer_pop(T_VERIFY);
be_sched_verify(irg);
if (stat_ev_enabled) {
stat_ev_dbl("bemain_costs_before_ra", be_estimate_irg_costs(irg));
......@@ -612,6 +594,12 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
/* Do register allocation */
be_allocate_registers(irg);
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
be_verify_register_allocation(irg);
be_timer_pop(T_VERIFY);
}
stat_ev_dbl("bemain_costs_before_ra", be_estimate_irg_costs(irg));
be_dump(DUMP_RA, irg, "ra");
......@@ -629,19 +617,13 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
}
/* check schedule and register allocation */
be_timer_push(T_VERIFY);
if (be_options.verify_option == BE_VERIFY_WARN) {
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
irg_verify(irg, VERIFY_ENFORCE_SSA);
be_verify_schedule(irg);
be_verify_register_allocation(irg);
} else if (be_options.verify_option == BE_VERIFY_ASSERT) {
assert(irg_verify(irg, VERIFY_ENFORCE_SSA) && "irg verification failed");
assert(be_verify_schedule(irg) && "Schedule verification failed");
assert(be_verify_register_allocation(irg)
&& "register allocation verification failed");
be_timer_pop(T_VERIFY);
}
be_timer_pop(T_VERIFY);
/* emit assembler code */
be_timer_push(T_EMIT);
......
......@@ -1858,16 +1858,12 @@ static void be_pref_alloc(ir_graph *new_irg)
spill();
/* verify schedule and register pressure */
be_timer_push(T_VERIFY);
if (be_options.verify_option == BE_VERIFY_WARN) {
if (be_options.do_verify) {
be_timer_push(T_VERIFY);
be_verify_schedule(irg);
be_verify_register_pressure(irg, cls);
} else if (be_options.verify_option == BE_VERIFY_ASSERT) {
assert(be_verify_schedule(irg) && "Schedule verification failed");
assert(be_verify_register_pressure(irg, cls)
&& "Register pressure verification failed");
be_timer_pop(T_VERIFY);
}
be_timer_pop(T_VERIFY);
be_timer_push(T_RA_COLOR);
be_pref_alloc_cls();
......@@ -1887,15 +1883,6 @@ static void be_pref_alloc(ir_graph *new_irg)
be_abi_fix_stack_nodes(irg);
be_timer_pop(T_RA_SPILL_APPLY);
be_timer_push(T_VERIFY);
if (be_options.verify_option == BE_VERIFY_WARN) {
be_verify_register_allocation(irg);
} else if (be_options.verify_option == BE_VERIFY_ASSERT) {
assert(be_verify_register_allocation(irg)
&& "Register allocation invalid");
}
be_timer_pop(T_VERIFY);
obstack_free(&obst, NULL);
}
......
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