Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
4cdd9d65
Commit
4cdd9d65
authored
Mar 26, 2006
by
Michael Beck
Browse files
added sched_create_block_schedule() to create a simple extended block based block schedule
parent
418e3622
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/besched.c
View file @
4cdd9d65
...
...
@@ -188,6 +188,7 @@ int sched_skip_phi_predicator(const ir_node *irn, void *data) {
return
is_Phi
(
irn
);
}
/* Skip nodes in a schedule. */
ir_node
*
sched_skip
(
ir_node
*
from
,
int
forward
,
sched_predicator_t
*
predicator
,
void
*
data
)
{
const
ir_node
*
bl
=
get_block
(
from
);
...
...
@@ -200,3 +201,61 @@ ir_node *sched_skip(ir_node *from, int forward, sched_predicator_t *predicator,
return
curr
;
}
/** A simple forward single linked list. */
typedef
struct
{
ir_node
*
start
;
/**< start of the list */
ir_node
*
end
;
/**< last block in the list */
unsigned
n_blks
;
/**< number of blocks in the list */
}
anchor
;
/**
* Ext-Block walker: create a block schedule
*/
static
void
create_block_list
(
ir_extblk
*
blk
,
void
*
env
)
{
anchor
*
list
=
env
;
int
i
,
n
;
for
(
i
=
0
,
n
=
get_extbb_n_blocks
(
blk
);
i
<
n
;
++
i
)
{
ir_node
*
block
=
get_extbb_block
(
blk
,
i
);
set_irn_link
(
block
,
NULL
);
if
(
list
->
start
)
set_irn_link
(
list
->
end
,
block
);
else
list
->
start
=
block
;
list
->
end
=
block
;
++
list
->
n_blks
;
}
}
/*
* Calculates a block schedule. The schedule is stored as a linked
* list starting at the start_block of the irg.
*/
ir_node
**
sched_create_block_schedule
(
ir_graph
*
irg
)
{
anchor
list
;
ir_node
**
blk_list
,
*
b
,
*
n
;
unsigned
i
;
/* schedule extended basic blocks */
compute_extbb
(
irg
);
list
.
start
=
NULL
;
list
.
end
=
NULL
;
list
.
n_blks
=
0
;
irg_extblock_walk_graph
(
irg
,
NULL
,
create_block_list
,
&
list
);
/** create an array, so we can go forward and backward */
blk_list
=
NEW_ARR_D
(
ir_node
*
,
irg
->
obst
,
list
.
n_blks
);
for
(
i
=
0
,
b
=
list
.
start
;
b
;
b
=
n
,
++
i
)
{
n
=
get_irn_link
(
b
);
set_irn_link
(
b
,
INT_TO_PTR
(
i
));
blk_list
[
i
]
=
b
;
}
return
blk_list
;
}
ir/be/besched.h
View file @
4cdd9d65
...
...
@@ -53,4 +53,17 @@ ir_node *sched_irg_first(const ir_graph *irg);
#define sched_foreach_reverse(block,irn) \
sched_foreach_reverse_from(sched_last(block), irn)
/**
* Calculates a block schedule. The schedule is returned as
* an array allocated on the irg's obstack.
*
* @param irg the graph to be scheduled
*
* @return A list of all blocks in schedule order. This list is
* allocated on irg's obstack and is freed if the graph is destroyed.
*
* This function implements a simple extended block scheduling algorithm.
*/
ir_node
**
sched_create_block_schedule
(
ir_graph
*
irg
);
#endif
/* _BESCHED_H */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment