Commit 52abe23f authored by Matthias Braun's avatar Matthias Braun
Browse files

remove to_appear_in_schedule function, use flags instead

parent 2fafc006
......@@ -35,12 +35,13 @@
#include "irdump_t.h"
#include "error.h"
static copy_attr_func old_phi_copy_attr;
static copy_attr_func old_phi_copy_attr;
void be_info_new_node(ir_node *node)
{
struct obstack *obst;
backend_info_t *info;
unsigned opcode;
/* Projs need no be info, their tuple holds all information */
if (is_Proj(node))
......@@ -56,11 +57,28 @@ void be_info_new_node(ir_node *node)
a bad decision back then), which have no register constraints.
Set some none_requirements here.
*/
if (get_irn_mode(node) != mode_T
&& get_irn_opcode(node) <= iro_Last) {
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
info->out_infos[0].req = arch_no_register_req;
opcode = get_irn_opcode(node);
if (opcode <= iro_Last) {
ir_mode *mode = get_irn_mode(node);
if (mode != mode_T) {
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
info->out_infos[0].req = arch_no_register_req;
}
switch (opcode) {
case iro_Anchor:
case iro_Bad:
case iro_Block:
case iro_Dummy:
case iro_End:
case iro_NoMem:
case iro_Pin:
case iro_Sync:
case iro_Unknown:
info->flags |= arch_irn_flags_not_scheduled;
break;
}
}
}
......
......@@ -114,7 +114,7 @@ static inline void set_already_scheduled(block_sched_env_t *env, ir_node *n)
env->sched_info[idx].already_sched = 1;
}
static void add_to_sched(block_sched_env_t *env, ir_node *irn);
static void selected(block_sched_env_t *env, ir_node *irn);
/**
* Try to put a node in the ready set.
......@@ -153,8 +153,8 @@ static inline int make_ready(block_sched_env_t *env, ir_node *pred, ir_node *irn
return 0;
}
if (! to_appear_in_schedule(irn)) {
add_to_sched(env, irn);
if (is_Proj(irn) || (arch_irn_get_flags(irn) & arch_irn_flags_not_scheduled)) {
selected(env, irn);
DB((dbg, LEVEL_3, "\tmaking immediately available: %+F\n", irn));
} else {
ir_nodeset_insert(&env->cands, irn);
......@@ -301,6 +301,18 @@ static void update_sched_liveness(block_sched_env_t *env, ir_node *irn)
}
}
static void selected(block_sched_env_t *env, ir_node *node)
{
/* notify the selector about the finally selected node. */
if (env->selector->node_selected)
env->selector->node_selected(env->selector_block_env, node);
/* Insert the node in the set of all available scheduled nodes. */
set_already_scheduled(env, node);
make_users_ready(env, node);
}
/**
* Append an instruction to a schedule.
* @param env The block scheduling environment.
......@@ -309,26 +321,17 @@ static void update_sched_liveness(block_sched_env_t *env, ir_node *irn)
*/
static void add_to_sched(block_sched_env_t *env, ir_node *irn)
{
/* If the node consumes/produces data, it is appended to the schedule
* list, otherwise, it is not put into the list */
if (to_appear_in_schedule(irn)) {
update_sched_liveness(env, irn);
sched_add_before(env->block, irn);
DBG((dbg, LEVEL_2, "\tadding %+F\n", irn));
assert(! (arch_irn_get_flags(irn) & arch_irn_flags_not_scheduled));
/* Remove the node from the ready set */
ir_nodeset_remove(&env->cands, irn);
}
update_sched_liveness(env, irn);
sched_add_before(env->block, irn);
/* notify the selector about the finally selected node. */
if (env->selector->node_selected)
env->selector->node_selected(env->selector_block_env, irn);
DBG((dbg, LEVEL_2, "\tadding %+F\n", irn));
/* Insert the node in the set of all available scheduled nodes. */
set_already_scheduled(env, irn);
/* Remove the node from the ready set */
ir_nodeset_remove(&env->cands, irn);
make_users_ready(env, irn);
selected(env, irn);
}
/**
......@@ -380,9 +383,10 @@ static void list_sched_block(ir_node *block, void *env_ptr)
}
users = get_irn_n_edges(irn);
if (users == 0)
if (users == 0) {
continue;
else if (users == 1) { /* ignore nodes that are only hold by the anchor */
} else if (users == 1) {
/* ignore nodes that are only hold by the anchor */
const ir_edge_t *edge = get_irn_out_edge_first_kind(irn, EDGE_KIND_NORMAL);
ir_node *user = get_edge_src_irn(edge);
if (is_Anchor(user))
......@@ -390,10 +394,8 @@ static void list_sched_block(ir_node *block, void *env_ptr)
}
if (is_Phi(irn)) {
/*
Phi functions are scheduled immediately, since they only
transfer data flow from the predecessors to this block.
*/
/* Phi functions are scheduled immediately, since they only
* transfer data flow from the predecessors to this block. */
add_to_sched(&be, irn);
} else if (be_is_Start(irn)) {
/* The start block will be scheduled as the first node */
......@@ -435,8 +437,7 @@ static void list_sched_block(ir_node *block, void *env_ptr)
}
}
if (! irn) {
/* Keeps must be immediately scheduled */
if (irn == NULL) {
irn = be.selector->select(be.selector_block_env, &be.cands, &be.live);
}
......
......@@ -35,34 +35,6 @@
#include "bearch.h"
#include "beirg.h"
/**
* Checks, if a node is to appear in a schedule. Such nodes either
* consume real data (mode datab) or produce such.
* @param irn The node to check for.
* @return 1, if the node consumes/produces data, false if not.
*/
static inline bool to_appear_in_schedule(const ir_node *irn)
{
switch(get_irn_opcode(irn)) {
case iro_Anchor:
case iro_Bad:
case iro_Block:
case iro_Confirm:
case iro_Dummy:
case iro_End:
case iro_NoMem:
case iro_Pin:
case iro_Proj:
case iro_Sync:
case iro_Unknown:
return false;
case iro_Phi:
return mode_is_data(get_irn_mode(irn));
default:
return ! (arch_irn_get_flags(irn) & arch_irn_flags_not_scheduled);
}
}
/**
* A selector interface which is used by the list schedule framework.
* You can implement your own list scheduler by implementing these
......@@ -74,9 +46,9 @@ typedef struct list_sched_selector_t {
* Called before a graph is being scheduled.
* May be NULL.
*
* @param vtab The selector vtab.
* @param irg The backend graph.
* @return The environment pointer that is passed to all other functions in this struct.
* @return The environment pointer that is passed to all other
* functions in this struct.
*/
void *(*init_graph)(ir_graph *irg);
......
......@@ -188,21 +188,19 @@ static void *reg_pressure_block_init(void *graph_env, ir_node *bl)
* Collect usage statistics.
*/
sched_foreach(bl, irn) {
if (to_appear_in_schedule(irn)) {
int i, n;
int i, n;
if (is_Proj(irn)
|| (arch_irn_get_flags(irn) & arch_irn_flags_not_scheduled))
continue;
for (i = 0, n = get_irn_arity(irn); i < n; ++i) {
//ir_node *op = get_irn_n(irn, i);
if (to_appear_in_schedule(irn)) {
usage_stats_t *us = get_or_set_usage_stats(env, irn);
for (i = 0, n = get_irn_arity(irn); i < n; ++i) {
usage_stats_t *us = get_or_set_usage_stats(env, irn);
#if 0 /* Liveness is not computed here! */
if (is_live_end(bl, op))
us->uses_in_block = 99999;
else
if (is_live_end(bl, op))
us->uses_in_block = 99999;
else
#endif
us->uses_in_block++;
}
}
us->uses_in_block++;
}
}
......@@ -247,8 +245,11 @@ static inline int reg_pr_costs(reg_pressure_selector_env_t *env, ir_node *irn)
for (i = 0, n = get_irn_arity(irn); i < n; ++i) {
ir_node *op = get_irn_n(irn, i);
if (to_appear_in_schedule(op))
sum += compute_max_hops(env, op);
if (is_Proj(op)
|| (arch_irn_get_flags(op) & arch_irn_flags_not_scheduled))
continue;
sum += compute_max_hops(env, op);
}
sum += get_result_hops_sum(env, irn);
......
......@@ -282,7 +282,7 @@ static void verify_schedule_walker(ir_node *block, void *data)
static void check_schedule(ir_node *node, void *data)
{
be_verify_schedule_env_t *env = (be_verify_schedule_env_t*)data;
bool should_be = to_appear_in_schedule(node);
bool should_be = !is_Proj(node) && !(arch_irn_get_flags(node) & arch_irn_flags_not_scheduled);
bool scheduled = bitset_is_set(env->scheduled, get_irn_idx(node));
if (should_be != scheduled) {
......
Supports Markdown
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