projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added missing include
[libfirm]
/
ir
/
be
/
belistsched.c
diff --git
a/ir/be/belistsched.c
b/ir/be/belistsched.c
index
9a9c690
..
7668732
100644
(file)
--- a/
ir/be/belistsched.c
+++ b/
ir/be/belistsched.c
@@
-41,10
+41,10
@@
* Scheduling environment for the whole graph.
*/
typedef struct _sched_env_t {
* Scheduling environment for the whole graph.
*/
typedef struct _sched_env_t {
- const list_sched_selector_t *selector; /**< The node selector. */
+
const list_sched_selector_t *selector; /**< The node selector. */
const arch_env_t *arch_env; /**< The architecture enviromnent. */
const ir_graph *irg; /**< The graph to schedule. */
const arch_env_t *arch_env; /**< The architecture enviromnent. */
const ir_graph *irg; /**< The graph to schedule. */
- void *selector_env; /**< A pointer to give to the selector. */
+
void *selector_env; /**< A pointer to give to the selector. */
} sched_env_t;
#if 0
} sched_env_t;
#if 0
@@
-75,20
+75,26
@@
static int cmp_usage(const void *a, const void *b)
}
#endif
}
#endif
-static ir_node *trivial_select(void *block_env, pset *ready_set)
+/**
+ * The trivial selector:
+ * Just assure that branches are executed last, otherwise select
+ * the first node ready.
+ */
+static ir_node *trivial_select(void *block_env, nodeset *ready_set)
{
const arch_env_t *arch_env = block_env;
ir_node *irn = NULL;
{
const arch_env_t *arch_env = block_env;
ir_node *irn = NULL;
- for(irn = pset_first(ready_set); irn; irn = pset_next(ready_set)) {
- if(arch_irn_classify(arch_env, irn) != arch_irn_class_branch) {
- pset_break(ready_set);
+ /* assure that branches are executed last */
+ for (irn = nodeset_first(ready_set); irn; irn = nodeset_next(ready_set)) {
+ if (arch_irn_classify(arch_env, irn) != arch_irn_class_branch) {
+ nodeset_break(ready_set);
return irn;
}
}
return irn;
}
}
- irn =
p
set_first(ready_set);
-
p
set_break(ready_set);
+ irn =
node
set_first(ready_set);
+
node
set_break(ready_set);
return irn;
}
return irn;
}
@@
-142,7
+148,7
@@
typedef struct {
struct obstack obst;
const reg_pressure_main_env_t *main_env;
usage_stats_t *root;
struct obstack obst;
const reg_pressure_main_env_t *main_env;
usage_stats_t *root;
-
p
set *already_scheduled;
+
node
set *already_scheduled;
} reg_pressure_selector_env_t;
static INLINE usage_stats_t *get_or_set_usage_stats(reg_pressure_selector_env_t *env, ir_node *irn)
} reg_pressure_selector_env_t;
static INLINE usage_stats_t *get_or_set_usage_stats(reg_pressure_selector_env_t *env, ir_node *irn)
@@
-183,7
+189,7
@@
static int max_hops_walker(reg_pressure_selector_env_t *env, ir_node *irn, ir_no
* If the node is in the current block but not
* yet scheduled, we keep on searching from that node.
*/
* If the node is in the current block but not
* yet scheduled, we keep on searching from that node.
*/
- if(!
pset_find_ptr
(env->already_scheduled, irn)) {
+ if(!
nodeset_find
(env->already_scheduled, irn)) {
int i, n;
int res = 0;
for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
int i, n;
int res = 0;
for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
@@
-247,7
+253,7
@@
static void *reg_pressure_block_init(void *graph_env, ir_node *bl)
reg_pressure_selector_env_t *env = xmalloc(sizeof(env[0]));
obstack_init(&env->obst);
reg_pressure_selector_env_t *env = xmalloc(sizeof(env[0]));
obstack_init(&env->obst);
- env->already_scheduled =
pset_new_ptr
(32);
+ env->already_scheduled =
new_nodeset
(32);
env->root = NULL;
env->main_env = graph_env;
env->root = NULL;
env->main_env = graph_env;
@@
-283,7
+289,7
@@
static void reg_pressure_block_free(void *block_env)
set_irn_link(us->irn, NULL);
obstack_free(&env->obst, NULL);
set_irn_link(us->irn, NULL);
obstack_free(&env->obst, NULL);
- del_
p
set(env->already_scheduled);
+ del_
node
set(env->already_scheduled);
free(env);
}
free(env);
}
@@
-321,22
+327,22
@@
static INLINE int reg_pr_costs(reg_pressure_selector_env_t *env, ir_node *irn)
return sum;
}
return sum;
}
-static ir_node *reg_pressure_select(void *block_env,
p
set *ready_set)
+static ir_node *reg_pressure_select(void *block_env,
node
set *ready_set)
{
reg_pressure_selector_env_t *env = block_env;
ir_node *irn, *res = NULL;
int curr_cost = INT_MAX;
{
reg_pressure_selector_env_t *env = block_env;
ir_node *irn, *res = NULL;
int curr_cost = INT_MAX;
- assert(
p
set_count(ready_set) > 0);
+ assert(
node
set_count(ready_set) > 0);
- for
(irn = pset_first(ready_set); irn; irn = p
set_next(ready_set)) {
+ for
(irn = nodeset_first(ready_set); irn; irn = node
set_next(ready_set)) {
/*
Ignore branch instructions for the time being.
They should only be scheduled if there is nothing else.
*/
/*
Ignore branch instructions for the time being.
They should only be scheduled if there is nothing else.
*/
- if(arch_irn_classify(env->main_env->arch_env, irn) != arch_irn_class_branch) {
+ if
(arch_irn_classify(env->main_env->arch_env, irn) != arch_irn_class_branch) {
int costs = reg_pr_costs(env, irn);
int costs = reg_pr_costs(env, irn);
- if(costs <= curr_cost) {
+ if
(costs <= curr_cost) {
res = irn;
curr_cost = costs;
}
res = irn;
curr_cost = costs;
}
@@
-349,13
+355,13
@@
static ir_node *reg_pressure_select(void *block_env, pset *ready_set)
*/
if(!res) {
*/
if(!res) {
- res =
p
set_first(ready_set);
-
p
set_break(ready_set);
+ res =
node
set_first(ready_set);
+
node
set_break(ready_set);
assert(res && "There must be a node scheduled.");
}
assert(res && "There must be a node scheduled.");
}
-
pset_insert_ptr
(env->already_scheduled, res);
+
nodeset_insert
(env->already_scheduled, res);
return res;
}
return res;
}
@@
-400,12
+406,12
@@
void list_sched(const arch_env_t *arch_env, ir_graph *irg)
*/
typedef struct _block_sched_env_t {
int curr_time;
*/
typedef struct _block_sched_env_t {
int curr_time;
-
p
set *ready_set;
-
p
set *already_scheduled;
+
node
set *ready_set;
+
node
set *already_scheduled;
ir_node *block;
ir_node *block;
- firm_dbg_module_t *dbg;
const list_sched_selector_t *selector;
void *selector_block_env;
const list_sched_selector_t *selector;
void *selector_block_env;
+ DEBUG_ONLY(firm_dbg_module_t *dbg;)
} block_sched_env_t;
/**
} block_sched_env_t;
/**
@@
-434,12
+440,12
@@
static INLINE int make_ready(block_sched_env_t *env, ir_node *irn)
/* If the operand is local to the scheduled block and not yet
* scheduled, this nodes cannot be made ready, so exit. */
/* If the operand is local to the scheduled block and not yet
* scheduled, this nodes cannot be made ready, so exit. */
- if(!
pset_find_ptr
(env->already_scheduled, op) && get_nodes_block(op) == env->block)
+ if(!
nodeset_find
(env->already_scheduled, op) && get_nodes_block(op) == env->block)
return 0;
}
DBG((env->dbg, LEVEL_2, "\tmaking ready: %+F\n", irn));
return 0;
}
DBG((env->dbg, LEVEL_2, "\tmaking ready: %+F\n", irn));
-
pset_insert_ptr
(env->ready_set, irn);
+
nodeset_insert
(env->ready_set, irn);
return 1;
}
return 1;
}
@@
-451,7
+457,7
@@
static INLINE int make_ready(block_sched_env_t *env, ir_node *irn)
* @return 1 if the node was ready, 0 if not.
*/
#define is_ready(env,irn) \
* @return 1 if the node was ready, 0 if not.
*/
#define is_ready(env,irn) \
- (
pset_find_ptr
((env)->ready_set, irn) != NULL)
+ (
nodeset_find
((env)->ready_set, irn) != NULL)
/**
* Check, if a node has already been schedules.
/**
* Check, if a node has already been schedules.
@@
-460,7
+466,7
@@
static INLINE int make_ready(block_sched_env_t *env, ir_node *irn)
* @return 1 if the node was already scheduled, 0 if not.
*/
#define is_scheduled(env,irn) \
* @return 1 if the node was already scheduled, 0 if not.
*/
#define is_scheduled(env,irn) \
- (
pset_find_ptr
((env)->already_scheduled, irn) != NULL)
+ (
nodeset_find
((env)->already_scheduled, irn) != NULL)
/**
* Try, to make all users of a node ready.
/**
* Try, to make all users of a node ready.
@@
-511,11
+517,11
@@
static ir_node *add_to_sched(block_sched_env_t *env, ir_node *irn)
}
/* Insert the node in the set of all already scheduled nodes. */
}
/* Insert the node in the set of all already scheduled nodes. */
-
pset_insert_ptr
(env->already_scheduled, irn);
+
nodeset_insert
(env->already_scheduled, irn);
/* Remove the node from the ready set */
/* Remove the node from the ready set */
- if(
pset_find_ptr
(env->ready_set, irn))
-
pset_remove_ptr
(env->ready_set, irn);
+ if(
nodeset_find
(env->ready_set, irn))
+
nodeset_remove
(env->ready_set, irn);
return irn;
}
return irn;
}
@@
-562,9
+568,9
@@
static ir_node *select_node(block_sched_env_t *be)
{
ir_node *irn;
{
ir_node *irn;
- for
(irn = pset_first(be->ready_set); irn; irn = p
set_next(be->ready_set)) {
- if(be_is_Keep(irn)) {
-
p
set_break(be->ready_set);
+ for
(irn = nodeset_first(be->ready_set); irn; irn = node
set_next(be->ready_set)) {
+ if
(be_is_Keep(irn)) {
+
node
set_break(be->ready_set);
return irn;
}
}
return irn;
}
}
@@
-600,12
+606,12
@@
static void list_sched_block(ir_node *block, void *env_ptr)
INIT_LIST_HEAD(&info->list);
/* Initialize the block scheduling environment */
INIT_LIST_HEAD(&info->list);
/* Initialize the block scheduling environment */
- be.dbg = firm_dbg_register("firm.be.sched");
be.block = block;
be.curr_time = 0;
be.block = block;
be.curr_time = 0;
- be.ready_set = new_
pset(node_cmp_func,
get_irn_n_edges(block));
- be.already_scheduled = new_
pset(node_cmp_func,
get_irn_n_edges(block));
+ be.ready_set = new_
nodeset(
get_irn_n_edges(block));
+ be.already_scheduled = new_
nodeset(
get_irn_n_edges(block));
be.selector = selector;
be.selector = selector;
+ FIRM_DBG_REGISTER(be.dbg, "firm.be.sched");
if(selector->init_block)
be.selector_block_env = selector->init_block(env->selector_env, block);
if(selector->init_block)
be.selector_block_env = selector->init_block(env->selector_env, block);
@@
-661,7
+667,7
@@
static void list_sched_block(ir_node *block, void *env_ptr)
/* Increase the time, if some phi functions have been scheduled */
be.curr_time += phi_seen;
/* Increase the time, if some phi functions have been scheduled */
be.curr_time += phi_seen;
- while
(p
set_count(be.ready_set) > 0) {
+ while
(node
set_count(be.ready_set) > 0) {
/* select a node to be scheduled and check if it was ready */
irn = select_node(&be);
/* select a node to be scheduled and check if it was ready */
irn = select_node(&be);
@@
-679,13
+685,13
@@
static void list_sched_block(ir_node *block, void *env_ptr)
be.curr_time += 1;
/* remove the scheduled node from the ready list. */
be.curr_time += 1;
/* remove the scheduled node from the ready list. */
- if
(pset_find_ptr
(be.ready_set, irn))
-
pset_remove_ptr
(be.ready_set, irn);
+ if
(nodeset_find
(be.ready_set, irn))
+
nodeset_remove
(be.ready_set, irn);
}
if(selector->finish_block)
selector->finish_block(be.selector_block_env);
}
if(selector->finish_block)
selector->finish_block(be.selector_block_env);
- del_
p
set(be.ready_set);
- del_
p
set(be.already_scheduled);
+ del_
node
set(be.ready_set);
+ del_
node
set(be.already_scheduled);
}
}