2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Common functions for creating listscheduling algorithms
9 * @author Sebastian Hack
12 #ifndef FIRM_BE_BELISTSCHED_H
13 #define FIRM_BE_BELISTSCHED_H
15 #include "firm_types.h"
16 #include "irnodeset.h"
23 * A selector interface which is used by the list schedule framework.
24 * You can implement your own list scheduler by implementing these
27 typedef struct list_sched_selector_t {
30 * Called before a graph is being scheduled.
33 * @param irg The backend graph.
34 * @return The environment pointer that is passed to all other
35 * functions in this struct.
37 void *(*init_graph)(ir_graph *irg);
40 * Called before scheduling starts on a block.
43 * @param graph_env The environment.
44 * @param block The block which is to be scheduled.
45 * @return A per-block pointer that is additionally passed to select.
47 void *(*init_block)(void *graph_env, ir_node *block);
50 * The selection function.
51 * It picks one node out of the ready list to be scheduled next.
52 * The function does not have to delete the node from the ready set.
53 * MUST be implemented.
55 * @param block_env Some private information as returned by init_block().
56 * @param sched_head The schedule so far.
57 * @param ready_set A set containing all ready nodes. Pick one of these nodes.
58 * @return The chosen node.
60 ir_node *(*select)(void *block_env, ir_nodeset_t *ready_set);
63 * This function gets executed after a node finally has been made ready.
66 * @param block_env The block environment.
67 * @param irn The node made ready.
68 * @param pred The previously scheduled node.
70 void (*node_ready)(void *block_env, ir_node *irn, ir_node *pred);
73 * This function gets executed after a node finally has been selected.
76 * @param block_env The block environment.
77 * @param irn The selected node.
79 void (*node_selected)(void *block_env, ir_node *irn);
82 * Called after a block has been scheduled.
85 * @param env The environment.
86 * @param block_env The per block environment as returned by init_block().
88 void (*finish_block)(void *block_env);
91 * Called after a whole graph has been scheduled.
94 * @param env The environment.
96 void (*finish_graph)(void *env);
97 } list_sched_selector_t;
100 * List schedule a graph.
101 * Each block in the graph gets a list head to its link field being the
102 * head of the schedule. You can walk this list using the functions in
105 * @param irg The backend irg.
107 void be_list_sched_graph(ir_graph *irg, const list_sched_selector_t *selector);