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
7ff1ee79
Commit
7ff1ee79
authored
Jan 10, 2015
by
Christoph Mallon
Browse files
be: Use be_new_Phi0() and be_complete_Phi() instead of using dummy/unknown inputs.
parent
41d66eda
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/be/bespillutil.c
View file @
7ff1ee79
...
...
@@ -298,35 +298,31 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
DBG
((
dbg
,
LEVEL_1
,
"spilling Phi %+F:
\n
"
,
phi
));
/* build a new PhiM */
int
const
arity
=
get_Phi_n_preds
(
phi
);
ir_node
**
const
ins
=
ALLOCAN
(
ir_node
*
,
arity
);
ir_graph
*
const
irg
=
env
->
irg
;
ir_node
*
const
unknown
=
new_r_Unknown
(
irg
,
mode_M
);
for
(
int
i
=
0
;
i
<
arity
;
++
i
)
{
ins
[
i
]
=
unknown
;
}
ir_node
*
const
block
=
get_nodes_block
(
phi
);
ir_node
*
const
phim
=
be_new_Phi0
(
block
,
mode_M
,
arch_no_register_req
);
sched_add_after
(
block
,
phim
);
/* override or replace spills list... */
ir_node
*
block
=
get_nodes_block
(
phi
);
spill_t
*
spill
=
OALLOC
(
&
env
->
obst
,
spill_t
);
spill
->
after
=
be_move_after_schedule_first
(
phi
);
spill
->
spill
=
be_new_Phi
(
block
,
arity
,
ins
,
mode_M
,
arch_no_register_req
);
spill
->
next
=
NULL
;
sched_add_after
(
block
,
spill
->
spill
);
spill
->
after
=
be_move_after_schedule_first
(
phi
);
spill
->
spill
=
phim
;
spill
->
next
=
NULL
;
spillinfo
->
spills
=
spill
;
env
->
spilled_phi_count
++
;
unsigned
const
arity
=
get_Phi_n_preds
(
phi
);
ir_node
**
const
ins
=
ALLOCAN
(
ir_node
*
,
arity
);
foreach_irn_in
(
phi
,
i
,
arg
)
{
spill_info_t
*
arg_info
=
get_spillinfo
(
env
,
arg
);
determine_spill_costs
(
env
,
arg_info
);
spill_node
(
env
,
arg_info
);
set_irn_n
(
spill
->
spill
,
i
,
arg_info
->
spills
->
spill
)
;
ins
[
i
]
=
arg_info
->
spills
->
spill
;
}
DBG
((
dbg
,
LEVEL_1
,
"... done spilling Phi %+F, created PhiM %+F
\n
"
,
phi
,
spill
->
spill
));
be_complete_Phi
(
phim
,
arity
,
ins
);
DBG
((
dbg
,
LEVEL_1
,
"... done spilling Phi %+F, created PhiM %+F
\n
"
,
phi
,
phim
));
}
/**
...
...
ir/be/bessaconstr.c
View file @
7ff1ee79
...
...
@@ -193,26 +193,16 @@ static void mark_iterated_dominance_frontiers(
/**
* Inserts a new phi at the given block.
*
* The constructed phi has o
nly Dummy
operands,
* The constructed phi has
n
o operands,
* but can be used as definition for other nodes.
*
* @see fix_phi_arguments
*/
static
ir_node
*
insert_dummy_phi
(
be_ssa_construction_env_t
*
env
,
ir_node
*
block
)
{
int
n_preds
=
get_Block_n_cfgpreds
(
block
);
ir_graph
*
irg
=
get_irn_irg
(
block
);
ir_node
**
ins
=
ALLOCAN
(
ir_node
*
,
n_preds
);
DBG
((
dbg
,
LEVEL_3
,
"
\t
...create phi at block %+F
\n
"
,
block
));
assert
(
n_preds
>
1
);
ir_node
*
dummy
=
new_r_Dummy
(
irg
,
env
->
mode
);
for
(
int
i
=
0
;
i
<
n_preds
;
++
i
)
{
ins
[
i
]
=
dummy
;
}
ir_node
*
phi
=
be_new_Phi
(
block
,
n_preds
,
ins
,
env
->
mode
,
env
->
phi_req
);
ir_node
*
const
phi
=
be_new_Phi0
(
block
,
env
->
mode
,
env
->
phi_req
);
sched_add_after
(
block
,
phi
);
ARR_APP1
(
ir_node
*
,
env
->
new_phis
,
phi
);
...
...
@@ -474,14 +464,25 @@ static void fix_phi_arguments(be_ssa_construction_env_t *const env, ir_node *con
DBG
((
dbg
,
LEVEL_3
,
"
\t
fixing phi arguments %+F
\n
"
,
phi
));
ir_node
*
const
block
=
get_nodes_block
(
phi
);
foreach_irn_in
(
phi
,
i
,
op
)
{
if
(
is_definition
(
env
,
op
)
||
is_Dummy
(
op
))
{
ir_node
*
pred_block
=
get_Block_cfgpred_block
(
block
,
i
);
ir_node
*
pred_def
=
search_def_end_of_block
(
env
,
pred_block
);
if
(
get_Phi_n_preds
(
phi
)
!=
0
)
{
foreach_irn_in
(
phi
,
i
,
op
)
{
if
(
is_definition
(
env
,
op
))
{
ir_node
*
const
pred_block
=
get_Block_cfgpred_block
(
block
,
i
);
ir_node
*
const
pred_def
=
search_def_end_of_block
(
env
,
pred_block
);
DBG
((
dbg
,
LEVEL_1
,
"
\t
...%+F(%d) -> %+F
\n
"
,
phi
,
i
,
pred_def
));
set_irn_n
(
phi
,
i
,
pred_def
);
}
}
}
else
{
unsigned
const
arity
=
get_Block_n_cfgpreds
(
block
);
ir_node
**
const
ins
=
ALLOCAN
(
ir_node
*
,
arity
);
for
(
unsigned
i
=
0
;
i
!=
arity
;
++
i
)
{
ir_node
*
const
pred_block
=
get_Block_cfgpred_block
(
block
,
i
);
ir_node
*
const
pred_def
=
search_def_end_of_block
(
env
,
pred_block
);
DBG
((
dbg
,
LEVEL_1
,
"
\t
...%+F(%d) -> %+F
\n
"
,
phi
,
i
,
pred_def
));
set_irn_n
(
phi
,
i
,
pred_def
)
;
ins
[
i
]
=
pred_def
;
}
be_complete_Phi
(
phi
,
arity
,
ins
);
}
info
->
already_processed
=
true
;
...
...
ir/be/bestate.c
View file @
7ff1ee79
...
...
@@ -131,12 +131,7 @@ static void create_reload(minibelady_env_t *env, ir_node *state,
static
void
spill_phi
(
minibelady_env_t
*
env
,
ir_node
*
phi
)
{
ir_graph
*
irg
=
get_irn_irg
(
phi
);
ir_node
*
block
=
get_nodes_block
(
phi
);
int
arity
=
get_irn_arity
(
phi
);
ir_node
**
phi_in
=
ALLOCAN
(
ir_node
*
,
arity
);
ir_node
*
dummy
=
new_r_Dummy
(
irg
,
mode_M
);
ir_node
*
spill_to_kill
=
NULL
;
ir_node
*
spill_to_kill
=
NULL
;
/* does a spill exist for the phis value? */
spill_info_t
*
spill_info
=
get_spill_info
(
env
,
phi
);
...
...
@@ -146,28 +141,27 @@ static void spill_phi(minibelady_env_t *env, ir_node *phi)
spill_info
=
create_spill_info
(
env
,
phi
);
}
/* create a new phi-M with bad preds */
for
(
int
i
=
0
;
i
<
arity
;
++
i
)
{
phi_in
[
i
]
=
dummy
;
}
DBG
((
dbg
,
LEVEL_2
,
"
\t
create Phi-M for %+F
\n
"
,
phi
));
/* create a Phi-M */
spill_info
->
spill
=
be_new_Phi
(
block
,
arity
,
phi_in
,
mode_M
,
arch_no_register_req
);
sched_add_after
(
block
,
spill_info
->
spill
);
ir_node
*
const
block
=
get_nodes_block
(
phi
);
ir_node
*
const
phim
=
be_new_Phi0
(
block
,
mode_M
,
arch_no_register_req
);
spill_info
->
spill
=
phim
;
sched_add_after
(
block
,
phim
);
if
(
spill_to_kill
!=
NULL
)
{
exchange
(
spill_to_kill
,
spill_info
->
spill
);
sched_remove
(
spill_to_kill
);
exchange
(
spill_to_kill
,
phim
);
}
/* create spills for the phi values */
unsigned
const
arity
=
get_irn_arity
(
phi
);
ir_node
**
const
phi_in
=
ALLOCAN
(
ir_node
*
,
arity
);
foreach_irn_in
(
phi
,
i
,
in
)
{
spill_info_t
*
pred_spill
=
create_spill
(
env
,
in
,
true
);
set_irn_n
(
spill_info
->
spill
,
i
,
pred_spill
->
spill
)
;
phi_in
[
i
]
=
pred_spill
->
spill
;
}
be_complete_Phi
(
phim
,
arity
,
phi_in
);
}
static
void
belady
(
minibelady_env_t
*
env
,
ir_node
*
block
);
...
...
Write
Preview
Markdown
is supported
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