X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeschednormal.c;h=2b39047162c3217f42fa4503e7300fbbcd90ff4f;hb=6f068af98daa4725d60e5d23a8f98ec2841cfa44;hp=22bc29aa7e1cb811bdc56626e6dbaff56210ced1;hpb=f46792d0e49d452ef92de2a802ae894c0ce30bbb;p=libfirm diff --git a/ir/be/beschednormal.c b/ir/be/beschednormal.c index 22bc29aa7..2b3904716 100644 --- a/ir/be/beschednormal.c +++ b/ir/be/beschednormal.c @@ -34,6 +34,7 @@ #include "irtools.h" #include "irgwalk.h" #include "benode.h" +#include "bemodule.h" #include "array_t.h" // XXX there is no one time init for schedulers @@ -53,19 +54,16 @@ static int must_be_scheduled(const ir_node* const irn) } -static ir_node *normal_select(void *block_env, ir_nodeset_t *ready_set, - ir_nodeset_t *live_set) +static ir_node *normal_select(void *block_env, ir_nodeset_t *ready_set) { - instance_t* inst = block_env; + instance_t* inst = (instance_t*)block_env; ir_node* irn; ir_node* next; ir_node* last = NULL; ir_nodeset_iterator_t iter; - (void)live_set; - for (irn = inst->curr_list; irn != NULL; last = irn, irn = next) { - next = get_irn_link(irn); + next = (ir_node*)get_irn_link(irn); if (ir_nodeset_contains(ready_set, irn)) { #if defined NORMAL_DBG ir_fprintf(stderr, "scheduling %+F\n", irn); @@ -91,8 +89,8 @@ typedef struct irn_cost_pair { static int cost_cmp(const void* a, const void* b) { - const irn_cost_pair* const a1 = a; - const irn_cost_pair* const b1 = b; + const irn_cost_pair* const a1 = (const irn_cost_pair*)a; + const irn_cost_pair* const b1 = (const irn_cost_pair*)b; int ret = b1->cost - a1->cost; if (ret == 0) ret = (int)get_irn_idx(a1->irn) - (int)get_irn_idx(b1->irn); @@ -174,7 +172,6 @@ static int normal_tree_cost(ir_node* irn, instance_t *inst) ir_node* real_pred; cost = normal_tree_cost(pred, inst); - if (be_is_Barrier(pred)) cost = 1; // XXX hack: the barrier causes all users to have a reguse of #regs if (!arch_irn_is_ignore(pred)) { real_pred = (is_Proj(pred) ? get_Proj_pred(pred) : pred); pred_fc = get_irn_fc(real_pred); @@ -222,7 +219,7 @@ static int normal_tree_cost(ir_node* irn, instance_t *inst) static void normal_cost_walker(ir_node* irn, void* env) { - instance_t *inst = env; + instance_t *inst = (instance_t*)env; #if defined NORMAL_DBG ir_fprintf(stderr, "cost walking node %+F\n", irn); @@ -250,7 +247,7 @@ static void collect_roots(ir_node* irn, void* env) if (is_root) { ir_node* block = get_nodes_block(irn); - ir_node** roots = get_irn_link(block); + ir_node** roots = (ir_node**)get_irn_link(block); if (roots == NULL) { roots = NEW_ARR_F(ir_node*, 0); } @@ -288,8 +285,8 @@ static ir_node** sched_node(ir_node** sched, ir_node* irn) static int root_cmp(const void* a, const void* b) { - const irn_cost_pair* const a1 = a; - const irn_cost_pair* const b1 = b; + const irn_cost_pair* const a1 = (const irn_cost_pair*)a; + const irn_cost_pair* const b1 = (const irn_cost_pair*)b; int ret; if (is_irn_forking(a1->irn)) { ret = 1; @@ -311,8 +308,8 @@ static int root_cmp(const void* a, const void* b) static void normal_sched_block(ir_node* block, void* env) { - ir_node** roots = get_irn_link(block); - ir_heights_t* heights = env; + ir_node** roots = (ir_node**)get_irn_link(block); + ir_heights_t* heights = (ir_heights_t*)env; int root_count; irn_cost_pair* root_costs; int i; @@ -376,14 +373,11 @@ static void normal_sched_block(ir_node* block, void* env) } -static void *normal_init_graph(const list_sched_selector_t *vtab, - ir_graph *irg) +static void *normal_init_graph(ir_graph *irg) { instance_t *inst = XMALLOC(instance_t); ir_heights_t *heights; - (void)vtab; - be_clear_links(irg); obstack_init(&inst->obst); @@ -406,8 +400,8 @@ static void *normal_init_graph(const list_sched_selector_t *vtab, static void *normal_init_block(void *graph_env, ir_node *block) { - instance_t* inst = graph_env; - ir_node** sched = get_irn_link(block); + instance_t* inst = (instance_t*)graph_env; + ir_node** sched = (ir_node**)get_irn_link(block); ir_node* first = NULL; int i; @@ -430,7 +424,7 @@ static void *normal_init_block(void *graph_env, ir_node *block) static void normal_finish_graph(void *env) { - instance_t *inst = env; + instance_t *inst = (instance_t*)env; /* block uses the link field to store the schedule */ ir_free_resources(inst->irg, IR_RESOURCE_IRN_LINK); @@ -438,14 +432,22 @@ static void normal_finish_graph(void *env) xfree(inst); } -const list_sched_selector_t normal_selector = { - normal_init_graph, - normal_init_block, - normal_select, - NULL, /* node_ready */ - NULL, /* node_selected */ - NULL, /* exectime */ - NULL, /* latency */ - NULL, /* finish_block */ - normal_finish_graph -}; +static void sched_normal(ir_graph *irg) +{ + static const list_sched_selector_t normal_selector = { + normal_init_graph, + normal_init_block, + normal_select, + NULL, /* node_ready */ + NULL, /* node_selected */ + NULL, /* finish_block */ + normal_finish_graph + }; + be_list_sched_graph(irg, &normal_selector); +} + +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_sched_normal) +void be_init_sched_normal(void) +{ + be_register_scheduler("normal", sched_normal); +}