#include "bearch.h"
#include "beuses.h"
-#define SCAN_INTERBLOCK_USES
-
-typedef struct _be_use_t {
+typedef struct be_use_t {
const ir_node *block;
const ir_node *node;
int outermost_loop;
unsigned visited;
} be_use_t;
-struct _be_uses_t {
- set *uses;
+struct be_uses_t {
+ set *uses;
ir_graph *irg;
const be_lv_t *lv;
unsigned visited_counter;
{
ir_node *node;
ir_node *succ_block = NULL;
- const ir_edge_t *edge;
int arity, i;
#if 1
#endif
return 0;
- foreach_block_succ(block, edge) {
- succ_block = get_edge_src_irn(edge);
- break;
- }
+ succ_block = get_first_block_succ(block);
arity = get_Block_n_cfgpreds(succ_block);
if (arity <= 1)
return 0;
}
-static inline
-unsigned get_step(const ir_node *node)
+static inline unsigned get_step(const ir_node *node)
{
return PTR_TO_INT(get_irn_link(node));
}
unsigned next_use_step;
const ir_edge_t *edge;
-#if 1
assert(skip_from_uses == 0 || skip_from_uses == 1);
if (skip_from_uses) {
from = sched_next(from);
node = sched_last(block);
step = get_step(node) + 1 + timestep + skip_from_uses;
-#else
- if (skip_from_uses) {
- from = sched_next(from);
- ++step;
- }
-
- sched_foreach_from(from, node) {
- int i, arity;
-
- if (is_Phi(node)) {
- step++;
- continue;
- }
-
- arity = get_irn_arity(node);
- for (i = 0; i < arity; ++i) {
- const ir_node *operand = get_irn_n(node, i);
-
- if (operand == def) {
- be_next_use_t result;
-
- DBG((env->dbg, LEVEL_3, "found use of %+F at %+F\n", operand, node));
-
- /**
- * Spills/Reloads are a special case, they're not really a
- * usage of a value, continue searching
- */
- if (be_is_Spill(node) || be_is_Reload(node)) {
- return be_get_next_use(env, node, step, node, 1);
- }
-
- result.time = step;
- result.outermost_loop = get_loop_depth(get_irn_loop(block));
- result.before = node;
- return result;
- }
- }
-
- step++;
- }
-#endif
-
if (be_is_phi_argument(block, def)) {
// TODO we really should continue searching the uses of the phi,
// as a phi isn't a real use that implies a reload (because we could
return result;
}
-#ifdef SCAN_INTERBLOCK_USES
{
unsigned next_use = USES_INFINITY;
int outermost_loop;
DBG((env->dbg, LEVEL_5, "Result: %d (outerloop: %d)\n", result.time, result.outermost_loop));
return result;
}
-#else
- return USES_INFINITY;
-#endif
}
be_next_use_t be_get_next_use(be_uses_t *env, ir_node *from,
return get_next_use(env, from, from_step, def, skip_from_uses);
}
-static
-void set_sched_step_walker(ir_node *block, void *data)
+static void set_sched_step_walker(ir_node *block, void *data)
{
ir_node *node;
unsigned step = 0;