#include "array.h"
#include "benode_t.h"
-static int my_value_dominates(const ir_node *a, const ir_node *b);
static int my_values_interfere(const ir_node *a, const ir_node *b);
typedef struct be_verify_register_pressure_env_t_ {
/* check that all delay branches are filled (at least with NOPs) */
if (cfchange_found && delay_branches != 0) {
- ir_fprintf(stderr, "Not all delay slots filled after jump (%d/%d) in block %+F (%s)\n",
+ ir_fprintf(stderr, "Verify warning: Not all delay slots filled after jump (%d/%d) in block %+F (%s)\n",
block, get_irg_dump_name(env->irg));
env->problem_found = 1;
}
}
+static int should_be_scheduled(ir_node *node) {
+ if(is_Block(node))
+ return -1;
+
+ if(get_irn_mode(node) == mode_M) {
+ if(is_Proj(node))
+ return -1;
+ if(is_Phi(node) || is_Sync(node) || get_irn_opcode(node) == iro_Pin)
+ return 0;
+ }
+ if(is_Proj(node) && get_irn_mode(node) == mode_X)
+ return 0;
+ if(be_is_Keep(node) && get_irn_opcode(get_nodes_block(node)) == iro_Bad)
+ return 0;
+
+ switch(get_irn_opcode(node)) {
+ case iro_End:
+ case iro_NoMem:
+ case iro_Bad:
+ return 0;
+ default:
+ break;
+ }
+
+ return 1;
+}
+
+static void check_schedule(ir_node *node, void *data) {
+ be_verify_schedule_env_t *env = data;
+ int should_be;
+
+ should_be = should_be_scheduled(node);
+ if(should_be == -1)
+ return;
+
+ if(should_be ? !sched_is_scheduled(node) : sched_is_scheduled(node)) {
+ ir_fprintf(stderr, "Verify warning: Node %+F in block %+F(%s) should%s be scheduled\n",
+ node, get_nodes_block(node), get_irg_dump_name(env->irg), should_be ? "" : " not");
+ env->problem_found = 1;
+ }
+}
+
/**
* Start a walk over the irg and check schedule.
*/
env.irg = irg;
irg_block_walk_graph(irg, verify_schedule_walker, NULL, &env);
+ // check if all nodes are scheduled
+ irg_walk_graph(irg, check_schedule, NULL, &env);
return ! env.problem_found;
}
} spill_t;
typedef struct {
+ be_lv_t *lv;
ir_graph *irg;
set *spills;
ir_node **reloads;
sp1->spill, get_nodes_block(sp1->spill), get_irg_dump_name(env->irg),
sp2->spill, get_nodes_block(sp2->spill), get_irg_dump_name(env->irg));
env->problem_found = 1;
+ my_values_interfere(sp1->spill, sp2->spill);
+ printf("Intf: %d\n", values_interfere(env->lv, sp1->spill, sp2->spill));
}
}
}
env.spills = new_set(cmp_spill, 10);
env.reloads = NEW_ARR_F(ir_node*, 0);
env.problem_found = 0;
+ env.lv = be_liveness(irg);
irg_walk_graph(irg, collect_spills_walker, NULL, &env);
check_spillslot_interference(&env);
+ be_liveness_free(env.lv);
DEL_ARR_F(env.reloads);
del_set(env.spills);
-static int my_value_dominates(const ir_node *a, const ir_node *b)
-{
- int res = 0;
- const ir_node *ba = get_block(a);
- const ir_node *bb = get_block(b);
-
- /*
- * a and b are not in the same block,
- * so dominance is determined by the dominance of the blocks.
- */
- if(ba != bb) {
- res = block_dominates(ba, bb);
-
- /*
- * Dominance is determined by the time steps of the schedule.
- */
- } else {
- sched_timestep_t as = sched_get_time_step(a);
- sched_timestep_t bs = sched_get_time_step(b);
- res = as <= bs;
- }
-
- return res;
-}
-
/**
* Check, if two values interfere.
* @param a The first value.
{
const ir_edge_t *edge;
ir_node *bb;
- int a2b = my_value_dominates(a, b);
- int b2a = my_value_dominates(b, a);
+ int a2b = value_dominates(a, b);
+ int b2a = value_dominates(b, a);
/* If there is no dominance relation, they do not interfere. */
if(!a2b && !b2a)
if(b == user)
continue;
+ if(get_irn_opcode(user) == iro_End)
+ continue;
+
// in case of phi arguments we compare with the block the value comes from
if(is_Phi(user)) {
ir_node *phiblock = get_nodes_block(user);
+ if(phiblock == bb)
+ continue;
user = get_irn_n(phiblock, get_edge_src_pos(edge));
}
- if(my_value_dominates(b, user))
+ if(value_dominates(b, user))
return 1;
}