2 * Scheduling algorithms.
3 * Just a simple list scheduling algorithm is here.
5 * @author Sebastian Hack
23 #include "iredges_t.h"
28 #include "irprintf_t.h"
33 #include "besched_t.h"
36 #include "belistsched.h"
37 #include "beschedmris.h"
42 * All scheduling info needed per node.
44 typedef struct _sched_irn_t {
45 sched_timestep_t delay; /**< The delay for this node if already calculated, else 0. */
46 sched_timestep_t etime; /**< The earliest time of this node. */
47 unsigned already_sched : 1; /**< Set if this node is already scheduled */
48 unsigned is_root : 1; /**< is a root node of a block */
52 * Scheduling environment for the whole graph.
54 typedef struct _sched_env_t {
55 sched_irn_t *sched_info; /**< scheduling info per node */
56 const list_sched_selector_t *selector; /**< The node selector. */
57 const arch_env_t *arch_env; /**< The architecture environment. */
58 const ir_graph *irg; /**< The graph to schedule. */
59 void *selector_env; /**< A pointer to give to the selector. */
64 * Ugly global variable for the compare function
65 * since qsort(3) does not pass an extra pointer.
67 static ir_node *curr_bl = NULL;
69 static int cmp_usage(const void *a, const void *b)
71 struct trivial_sched_env *env;
76 res = is_live_end(env->curr_bl, a) - is_live_end(env->curr_bl, b);
79 * One of them is live at the end of the block.
80 * Then, that one shall be scheduled at after the other
91 * The trivial selector:
92 * Just assure that branches are executed last, otherwise select
93 * the first node ready.
95 static ir_node *trivial_select(void *block_env, nodeset *ready_set)
97 const arch_env_t *arch_env = block_env;
101 /* assure that branches and constants are executed last */
102 for (irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
103 arch_irn_class_t irn_class = arch_irn_classify(arch_env, irn);
105 if (irn_class != arch_irn_class_branch && (const_last ? (irn_class != arch_irn_class_const) : 1)) {
106 nodeset_break(ready_set);
111 /* assure that constants are executed before branches */
113 for (irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
114 if (arch_irn_classify(arch_env, irn) != arch_irn_class_branch) {
115 nodeset_break(ready_set);
122 /* at last: schedule branches */
123 irn = nodeset_first(ready_set);
124 nodeset_break(ready_set);
129 static void *trivial_init_graph(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg)
131 return (void *) arch_env;
134 static void *trivial_init_block(void *graph_env, ir_node *bl)
139 static INLINE int must_appear_in_schedule(const list_sched_selector_t *sel, void *block_env, const ir_node *irn)
143 if(sel->to_appear_in_schedule)
144 res = sel->to_appear_in_schedule(block_env, irn);
146 return res >= 0 ? res : (to_appear_in_schedule(irn) || be_is_Keep(irn) || be_is_RegParams(irn));
149 static const list_sched_selector_t trivial_selector_struct = {
153 NULL, /* to_appear_in_schedule */
156 NULL, /* finish_block */
157 NULL /* finish_graph */
160 const list_sched_selector_t *trivial_selector = &trivial_selector_struct;
162 typedef struct _usage_stats_t {
164 struct _usage_stats_t *next;
166 int uses_in_block; /**< Number of uses inside the current block. */
167 int already_consumed; /**< Number of insns using this value already
172 const list_sched_selector_t *vtab;
173 const arch_env_t *arch_env;
174 } reg_pressure_main_env_t;
178 const reg_pressure_main_env_t *main_env;
180 nodeset *already_scheduled;
181 } reg_pressure_selector_env_t;
183 static INLINE usage_stats_t *get_or_set_usage_stats(reg_pressure_selector_env_t *env, ir_node *irn)
185 usage_stats_t *us = get_irn_link(irn);
188 us = obstack_alloc(&env->obst, sizeof(us[0]));
190 us->already_consumed = 0;
191 us->max_hops = INT_MAX;
192 us->next = env->root;
194 set_irn_link(irn, us);
200 static INLINE usage_stats_t *get_usage_stats(ir_node *irn)
202 usage_stats_t *us = get_irn_link(irn);
203 assert(us && "This node must have usage stats");
207 static int max_hops_walker(reg_pressure_selector_env_t *env, ir_node *irn, ir_node *curr_bl, int depth, unsigned visited_nr)
209 ir_node *bl = get_nodes_block(irn);
211 * If the reached node is not in the block desired,
212 * return the value passed for this situation.
214 if(get_nodes_block(irn) != bl)
215 return block_dominates(bl, curr_bl) ? 0 : INT_MAX;
218 * If the node is in the current block but not
219 * yet scheduled, we keep on searching from that node.
221 if(!nodeset_find(env->already_scheduled, irn)) {
224 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
225 ir_node *operand = get_irn_n(irn, i);
227 if(get_irn_visited(operand) < visited_nr) {
230 set_irn_visited(operand, visited_nr);
231 tmp = max_hops_walker(env, operand, bl, depth + 1, visited_nr);
240 * If the node is in the current block and scheduled, return
241 * the depth which indicates the number of steps to the
242 * region of scheduled nodes.
247 static int compute_max_hops(reg_pressure_selector_env_t *env, ir_node *irn)
249 ir_node *bl = get_nodes_block(irn);
250 ir_graph *irg = get_irn_irg(bl);
253 const ir_edge_t *edge;
255 foreach_out_edge(irn, edge) {
256 ir_node *user = get_edge_src_irn(edge);
257 unsigned visited_nr = get_irg_visited(irg) + 1;
260 set_irg_visited(irg, visited_nr);
261 max_hops = max_hops_walker(env, user, irn, 0, visited_nr);
262 res = MAX(res, max_hops);
268 static void *reg_pressure_graph_init(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg)
270 reg_pressure_main_env_t *main_env = xmalloc(sizeof(main_env[0]));
272 main_env->arch_env = arch_env;
273 main_env->vtab = vtab;
274 irg_walk_graph(irg, firm_clear_link, NULL, NULL);
279 static void *reg_pressure_block_init(void *graph_env, ir_node *bl)
282 reg_pressure_selector_env_t *env = xmalloc(sizeof(env[0]));
284 obstack_init(&env->obst);
285 env->already_scheduled = new_nodeset(32);
287 env->main_env = graph_env;
290 * Collect usage statistics.
292 sched_foreach(bl, irn) {
293 if(must_appear_in_schedule(env->main_env->vtab, env, irn)) {
296 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
297 ir_node *op = get_irn_n(irn, i);
298 if(must_appear_in_schedule(env->main_env->vtab, env, irn)) {
299 usage_stats_t *us = get_or_set_usage_stats(env, irn);
300 #if 0 /* Liveness is not computed here! */
301 if(is_live_end(bl, op))
302 us->uses_in_block = 99999;
314 static void reg_pressure_block_free(void *block_env)
316 reg_pressure_selector_env_t *env = block_env;
319 for(us = env->root; us; us = us->next)
320 set_irn_link(us->irn, NULL);
322 obstack_free(&env->obst, NULL);
323 del_nodeset(env->already_scheduled);
327 static int get_result_hops_sum(reg_pressure_selector_env_t *env, ir_node *irn)
330 if(get_irn_mode(irn) == mode_T) {
331 const ir_edge_t *edge;
333 foreach_out_edge(irn, edge)
334 res += get_result_hops_sum(env, get_edge_src_irn(edge));
337 else if(mode_is_data(get_irn_mode(irn)))
338 res = compute_max_hops(env, irn);
344 static INLINE int reg_pr_costs(reg_pressure_selector_env_t *env, ir_node *irn)
349 for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
350 ir_node *op = get_irn_n(irn, i);
352 if(must_appear_in_schedule(env->main_env->vtab, env, op))
353 sum += compute_max_hops(env, op);
356 sum += get_result_hops_sum(env, irn);
361 static ir_node *reg_pressure_select(void *block_env, nodeset *ready_set)
363 reg_pressure_selector_env_t *env = block_env;
364 ir_node *irn, *res = NULL;
365 int curr_cost = INT_MAX;
367 assert(nodeset_count(ready_set) > 0);
369 for (irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
371 Ignore branch instructions for the time being.
372 They should only be scheduled if there is nothing else.
374 if (arch_irn_classify(env->main_env->arch_env, irn) != arch_irn_class_branch) {
375 int costs = reg_pr_costs(env, irn);
376 if (costs <= curr_cost) {
384 There was no result so we only saw a branch.
389 res = nodeset_first(ready_set);
390 nodeset_break(ready_set);
392 assert(res && "There must be a node scheduled.");
395 nodeset_insert(env->already_scheduled, res);
400 * Environment for a block scheduler.
402 typedef struct _block_sched_env_t {
403 sched_irn_t *sched_info; /**< scheduling info per node, copied from the global scheduler object */
404 sched_timestep_t curr_time; /**< current time of the scheduler */
405 nodeset *cands; /**< the set of candidates */
406 ir_node *block; /**< the current block */
407 sched_env_t *sched_env; /**< the scheduler environment */
408 const list_sched_selector_t *selector;
409 void *selector_block_env;
410 DEBUG_ONLY(firm_dbg_module_t *dbg;)
414 * Returns non-zero if the node is already scheduled
416 static INLINE int is_already_scheduled(block_sched_env_t *env, ir_node *n)
418 int idx = get_irn_idx(n);
420 assert(idx < ARR_LEN(env->sched_info));
421 return env->sched_info[idx].already_sched;
425 * Mark a node as already scheduled
427 static INLINE void mark_already_scheduled(block_sched_env_t *env, ir_node *n)
429 int idx = get_irn_idx(n);
431 assert(idx < ARR_LEN(env->sched_info));
432 env->sched_info[idx].already_sched = 1;
436 * Returns non-zero if the node is a root node
438 static INLINE unsigned is_root_node(block_sched_env_t *env, ir_node *n)
440 int idx = get_irn_idx(n);
442 assert(idx < ARR_LEN(env->sched_info));
443 return env->sched_info[idx].is_root;
447 * Mark a node as roto node
449 static INLINE void mark_root_node(block_sched_env_t *env, ir_node *n)
451 int idx = get_irn_idx(n);
453 assert(idx < ARR_LEN(env->sched_info));
454 env->sched_info[idx].is_root = 1;
458 * Get the current delay.
460 static sched_timestep_t get_irn_delay(block_sched_env_t *env, ir_node *n) {
461 int idx = get_irn_idx(n);
463 assert(idx < ARR_LEN(env->sched_info));
464 return env->sched_info[idx].delay;
468 * Set the current delay.
470 static void set_irn_delay(block_sched_env_t *env, ir_node *n, sched_timestep_t delay) {
471 int idx = get_irn_idx(n);
473 assert(idx < ARR_LEN(env->sched_info));
474 env->sched_info[idx].delay = delay;
478 * Get the current etime.
480 static sched_timestep_t get_irn_etime(block_sched_env_t *env, ir_node *n) {
481 int idx = get_irn_idx(n);
483 assert(idx < ARR_LEN(env->sched_info));
484 return env->sched_info[idx].etime;
488 * Set the current etime.
490 static void set_irn_etime(block_sched_env_t *env, ir_node *n, sched_timestep_t etime) {
491 int idx = get_irn_idx(n);
493 assert(idx < ARR_LEN(env->sched_info));
494 env->sched_info[idx].etime = etime;
498 * returns the exec-time for node n.
500 static sched_timestep_t exectime(sched_env_t *env, ir_node *n) {
501 if (be_is_Keep(n) || is_Proj(n))
503 if (env->selector->exectime)
504 return env->selector->exectime(env->selector_env, n);
509 * Calculates the latency for between two ops
511 static sched_timestep_t latency(sched_env_t *env, ir_node *pred, int pred_cycle, ir_node *curr, int curr_cycle) {
512 /* a Keep hides a root */
513 if (be_is_Keep(curr))
514 return exectime(env, pred);
516 /* Proj's are executed immediately */
520 /* predecessors Proj's must be skipped */
522 pred = get_Proj_pred(pred);
524 if (env->selector->latency)
525 return env->selector->latency(env->selector_env, pred, pred_cycle, curr, curr_cycle);
530 * Try to put a node in the ready set.
531 * @param env The block scheduler environment.
532 * @param pred The previous scheduled node.
533 * @param irn The node to make ready.
534 * @return 1, if the node could be made ready, 0 else.
536 static INLINE int make_ready(block_sched_env_t *env, ir_node *pred, ir_node *irn)
539 sched_timestep_t etime_p, etime;
541 /* Blocks cannot be scheduled. */
546 * Check, if the given ir node is in a different block as the
547 * currently scheduled one. If that is so, don't make the node ready.
549 if (env->block != get_nodes_block(irn))
552 for (i = 0, n = get_irn_arity(irn); i < n; ++i) {
553 ir_node *op = get_irn_n(irn, i);
555 /* if irn is an End we have keep-alives and op might be a block, skip that */
557 assert(get_irn_op(irn) == op_End);
561 /* If the operand is local to the scheduled block and not yet
562 * scheduled, this nodes cannot be made ready, so exit. */
563 if (!is_already_scheduled(env, op) && get_nodes_block(op) == env->block)
567 nodeset_insert(env->cands, irn);
569 /* calculate the etime of this node */
570 etime = env->curr_time;
572 etime_p = get_irn_etime(env, pred);
573 etime += latency(env->sched_env, pred, 1, irn, 0);
575 etime = etime_p > etime ? etime_p : etime;
578 set_irn_etime(env, irn, etime);
580 DB((env->dbg, LEVEL_2, "\tmaking ready: %+F etime %u\n", irn, etime));
586 * Try, to make all users of a node ready.
587 * In fact, a usage node can only be made ready, if all its operands
588 * have already been scheduled yet. This is checked my make_ready().
589 * @param env The block schedule environment.
590 * @param irn The node, which usages (successors) are to be made ready.
592 static INLINE void make_users_ready(block_sched_env_t *env, ir_node *irn)
594 const ir_edge_t *edge;
596 foreach_out_edge(irn, edge) {
597 ir_node *user = edge->src;
599 make_ready(env, irn, user);
604 * Compare to nodes using pointer equality.
605 * @param p1 Node one.
606 * @param p2 Node two.
607 * @return 0 if they are identical.
609 static int node_cmp_func(const void *p1, const void *p2)
615 * Append an instruction to a schedule.
616 * @param env The block scheduling environment.
617 * @param irn The node to add to the schedule.
618 * @return The given node.
620 static ir_node *add_to_sched(block_sched_env_t *env, ir_node *irn)
622 /* If the node consumes/produces data, it is appended to the schedule
623 * list, otherwise, it is not put into the list */
624 if(must_appear_in_schedule(env->selector, env->selector_block_env, irn)) {
625 sched_info_t *info = get_irn_sched_info(irn);
626 INIT_LIST_HEAD(&info->list);
628 sched_add_before(env->block, irn);
630 DBG((env->dbg, LEVEL_2, "\tadding %+F\n", irn));
633 /* Insert the node in the set of all already scheduled nodes. */
634 mark_already_scheduled(env, irn);
636 /* Remove the node from the ready set */
637 if(nodeset_find(env->cands, irn))
638 nodeset_remove(env->cands, irn);
644 * Add the proj nodes of a tuple-mode irn to the schedule immediately
645 * after the tuple-moded irn. By pinning the projs after the irn, no
646 * other nodes can create a new lifetime between the tuple-moded irn and
647 * one of its projs. This should render a realistic image of a
648 * tuple-moded irn, which in fact models a node which defines multiple
651 * @param irn The tuple-moded irn.
653 static void add_tuple_projs(block_sched_env_t *env, ir_node *irn)
655 const ir_edge_t *edge;
657 assert(get_irn_mode(irn) == mode_T && "Mode of node must be tuple");
662 foreach_out_edge(irn, edge) {
663 ir_node *out = edge->src;
665 assert(is_Proj(out) && "successor of a modeT node must be a proj");
667 if (get_irn_mode(out) == mode_T)
668 add_tuple_projs(env, out);
670 add_to_sched(env, out);
671 make_users_ready(env, out);
677 * Execute the heuristic function,
679 static ir_node *select_node_heuristic(block_sched_env_t *be, nodeset *ns)
683 for (irn = nodeset_first(ns); irn; irn = nodeset_next(ns)) {
684 if (be_is_Keep(irn)) {
690 return be->selector->select(be->selector_block_env, ns);
694 * Returns non-zero if root is a root in the block block.
696 static int is_root(ir_node *root, ir_node *block) {
697 const ir_edge_t *edge;
699 foreach_out_edge(root, edge) {
700 ir_node *succ = get_edge_src_irn(edge);
704 /* Phi nodes are always in "another block */
707 if (get_nodes_block(succ) == block)
713 /* we need a special mark */
717 static firm_dbg_module_t *xxxdbg;
720 * descent into a dag and create a pre-order list.
722 static void descent(ir_node *root, ir_node *block, ir_node **list) {
725 if (! is_Phi(root)) {
726 /* Phi nodes always leave the block */
727 for (i = get_irn_arity(root) - 1; i >= 0; --i) {
728 ir_node *pred = get_irn_n(root, i);
730 DBG((xxxdbg, LEVEL_3, " node %+F\n", pred));
731 /* Blocks may happen as predecessors of End nodes */
735 /* already seen nodes are not marked */
736 if (get_irn_link(pred) != MARK)
739 /* don't leave our block */
740 if (get_nodes_block(pred) != block)
743 set_irn_link(pred, NULL);
745 descent(pred, block, list);
748 set_irn_link(root, *list);
753 * Perform list scheduling on a block.
755 * Note, that the caller must compute a linked list of nodes in the block
756 * using the link field before calling this function.
758 * Also the outs must have been computed.
760 * @param block The block node.
761 * @param env Scheduling environment.
763 static void list_sched_block(ir_node *block, void *env_ptr)
765 sched_env_t *env = env_ptr;
766 const list_sched_selector_t *selector = env->selector;
767 ir_node *start_node = get_irg_start(get_irn_irg(block));
768 sched_info_t *info = get_irn_sched_info(block);
770 block_sched_env_t be;
771 const ir_edge_t *edge;
775 ir_node *root = NULL, *preord = NULL;
778 /* Initialize the block's list head that will hold the schedule. */
779 INIT_LIST_HEAD(&info->list);
781 /* Initialize the block scheduling environment */
782 be.sched_info = env->sched_info;
785 be.cands = new_nodeset(get_irn_n_edges(block));
786 be.selector = selector;
788 FIRM_DBG_REGISTER(be.dbg, "firm.be.sched");
789 FIRM_DBG_REGISTER(xxxdbg, "firm.be.sched");
791 // firm_dbg_set_mask(be.dbg, SET_LEVEL_3);
793 if (selector->init_block)
794 be.selector_block_env = selector->init_block(env->selector_env, block);
796 DBG((be.dbg, LEVEL_1, "scheduling %+F\n", block));
798 /* First step: Find the root set. */
799 foreach_out_edge(block, edge) {
800 ir_node *succ = get_edge_src_irn(edge);
802 if (is_root(succ, block)) {
803 mark_root_node(&be, succ);
804 set_irn_link(succ, root);
808 set_irn_link(succ, MARK);
811 /* Second step: calculate the pre-order list. */
813 for (curr = root; curr; curr = irn) {
814 irn = get_irn_link(curr);
815 DBG((be.dbg, LEVEL_2, " DAG root %+F\n", curr));
816 descent(curr, block, &preord);
820 /* Third step: calculate the Delay. Note that our
821 * list is now in pre-order, starting at root
823 for (curr = root; curr; curr = get_irn_link(curr)) {
826 if (arch_irn_classify(env->arch_env, curr) == arch_irn_class_branch) {
827 /* assure, that branches can be executed last */
831 if (is_root_node(&be, curr))
832 d = exectime(env, curr);
835 foreach_out_edge(curr, edge) {
836 ir_node *n = get_edge_src_irn(edge);
838 if (get_nodes_block(n) == block) {
841 ld = latency(env, curr, 1, n, 0) + get_irn_delay(&be, n);
847 set_irn_delay(&be, curr, d);
848 DB((be.dbg, LEVEL_2, "\t%+F delay %u\n", curr, d));
850 /* set the etime of all nodes to 0 */
851 set_irn_etime(&be, curr, 0);
855 /* Then one can add all nodes are ready to the set. */
856 foreach_out_edge(block, edge) {
857 ir_node *irn = get_edge_src_irn(edge);
859 /* Skip the end node because of keepalive edges. */
860 if (get_irn_opcode(irn) == iro_End)
864 /* Phi functions are scheduled immediately, since they only transfer
865 * data flow from the predecessors to this block. */
867 /* Increase the time step. */
868 be.curr_time += get_irn_etime(&be, irn);
869 add_to_sched(&be, irn);
870 make_users_ready(&be, irn);
872 else if (irn == start_node) {
873 /* The start block will be scheduled as the first node */
874 be.curr_time += get_irn_etime(&be, irn);
876 add_to_sched(&be, irn);
877 add_tuple_projs(&be, irn);
880 /* Other nodes must have all operands in other blocks to be made
884 /* Check, if the operands of a node are not local to this block */
885 for (j = 0, m = get_irn_arity(irn); j < m; ++j) {
886 ir_node *operand = get_irn_n(irn, j);
888 if (get_nodes_block(operand) == block) {
894 /* Make the node ready, if all operands live in a foreign block */
896 DBG((be.dbg, LEVEL_2, "\timmediately ready: %+F\n", irn));
897 make_ready(&be, NULL, irn);
902 while (nodeset_count(be.cands) > 0) {
903 nodeset *mcands; /**< the set of candidates with maximum delay time */
904 nodeset *ecands; /**< the set of nodes in mcands whose etime <= curr_time */
905 sched_timestep_t max_delay = 0;
907 /* collect statistics about amount of ready nodes */
908 be_do_stat_sched_ready(block, be.cands);
910 /* calculate the max delay of all candidates */
911 foreach_nodeset(be.cands, irn) {
912 sched_timestep_t d = get_irn_delay(&be, irn);
914 max_delay = d > max_delay ? d : max_delay;
916 mcands = new_nodeset(8);
917 ecands = new_nodeset(8);
919 /* calculate mcands and ecands */
920 foreach_nodeset(be.cands, irn) {
921 if (be_is_Keep(irn)) {
922 nodeset_break(be.cands);
925 if (get_irn_delay(&be, irn) == max_delay) {
926 nodeset_insert(mcands, irn);
927 if (get_irn_etime(&be, irn) <= be.curr_time)
928 nodeset_insert(ecands, irn);
933 /* Keeps must be immediately scheduled */
936 DB((be.dbg, LEVEL_2, "\tbe.curr_time = %u\n", be.curr_time));
938 /* select a node to be scheduled and check if it was ready */
939 if (nodeset_count(mcands) == 1) {
940 DB((be.dbg, LEVEL_3, "\tmcand = 1, max_delay = %u\n", max_delay));
941 irn = nodeset_first(mcands);
944 int cnt = nodeset_count(ecands);
946 arch_irn_class_t irn_class;
948 irn = nodeset_first(ecands);
949 irn_class = arch_irn_classify(env->arch_env, irn);
951 if (irn_class == arch_irn_class_branch) {
952 /* BEWARE: don't select a JUMP if others are still possible */
955 DB((be.dbg, LEVEL_3, "\tecand = 1, max_delay = %u\n", max_delay));
958 DB((be.dbg, LEVEL_3, "\tecand = %d, max_delay = %u\n", cnt, max_delay));
959 irn = select_node_heuristic(&be, ecands);
963 DB((be.dbg, LEVEL_3, "\tmcand = %d\n", nodeset_count(mcands)));
964 irn = select_node_heuristic(&be, mcands);
971 DB((be.dbg, LEVEL_2, "\tpicked node %+F\n", irn));
973 /* Increase the time step. */
974 be.curr_time += exectime(env, irn);
976 /* Add the node to the schedule. */
977 add_to_sched(&be, irn);
979 if (get_irn_mode(irn) == mode_T)
980 add_tuple_projs(&be, irn);
982 make_users_ready(&be, irn);
984 /* remove the scheduled node from the ready list. */
985 if (nodeset_find(be.cands, irn))
986 nodeset_remove(be.cands, irn);
989 if (selector->finish_block)
990 selector->finish_block(be.selector_block_env);
992 del_nodeset(be.cands);
995 static const list_sched_selector_t reg_pressure_selector_struct = {
996 reg_pressure_graph_init,
997 reg_pressure_block_init,
999 NULL, /* to_appear_in_schedule */
1000 NULL, /* exectime */
1002 reg_pressure_block_free,
1006 const list_sched_selector_t *reg_pressure_selector = ®_pressure_selector_struct;
1008 /* List schedule a graph. */
1009 void list_sched(const be_irg_t *birg, int enable_mris)
1011 const arch_env_t *arch_env = birg->main_env->arch_env;
1012 ir_graph *irg = birg->irg;
1018 /* Assure, that the out edges are computed */
1022 mris = be_sched_mris_preprocess(birg);
1024 num_nodes = get_irg_last_idx(irg);
1026 memset(&env, 0, sizeof(env));
1027 env.selector = arch_env->isa->impl->get_list_sched_selector(arch_env->isa);
1028 env.arch_env = arch_env;
1030 env.sched_info = NEW_ARR_F(sched_irn_t, num_nodes);
1032 memset(env.sched_info, 0, num_nodes * sizeof(*env.sched_info));
1034 if (env.selector->init_graph)
1035 env.selector_env = env.selector->init_graph(env.selector, arch_env, irg);
1037 /* Schedule each single block. */
1038 irg_block_walk_graph(irg, list_sched_block, NULL, &env);
1040 if (env.selector->finish_graph)
1041 env.selector->finish_graph(env.selector_env);
1044 be_sched_mris_free(mris);
1046 DEL_ARR_F(env.sched_info);