projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed a bunch of warnings
[libfirm]
/
ir
/
be
/
bespill.c
diff --git
a/ir/be/bespill.c
b/ir/be/bespill.c
index
1a52c02
..
577b56d
100644
(file)
--- a/
ir/be/bespill.c
+++ b/
ir/be/bespill.c
@@
-69,6
+69,7
@@
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
typedef struct reloader_t reloader_t;
struct reloader_t {
reloader_t *next;
typedef struct reloader_t reloader_t;
struct reloader_t {
reloader_t *next;
+ ir_node *can_spill_after;
ir_node *reloader;
ir_node *rematted_node;
int remat_cost_delta; /** costs needed for rematerialization,
ir_node *reloader;
ir_node *rematted_node;
int remat_cost_delta; /** costs needed for rematerialization,
@@
-209,7
+210,7
@@
void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before,
to_spill, before));
}
to_spill, before));
}
-void be_add_reload
(spill_env_t *env, ir_node *to_spill, ir_node *before
,
+void be_add_reload
2(spill_env_t *env, ir_node *to_spill, ir_node *before, ir_node *can_spill_after
,
const arch_register_class_t *reload_cls, int allow_remat)
{
spill_info_t *info;
const arch_register_class_t *reload_cls, int allow_remat)
{
spill_info_t *info;
@@
-244,15
+245,12
@@
void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before,
assert(!is_Proj(before) && !be_is_Keep(before));
/* put reload into list */
assert(!is_Proj(before) && !be_is_Keep(before));
/* put reload into list */
- rel = obstack_alloc(&env->obst, sizeof(rel[0]));
- rel->next = info->reloaders;
- rel->reloader = before;
- rel->rematted_node = NULL;
- if(!allow_remat) {
- rel->remat_cost_delta = REMAT_COST_INFINITE;
- } else {
- rel->remat_cost_delta = 0;
- }
+ rel = obstack_alloc(&env->obst, sizeof(rel[0]));
+ rel->next = info->reloaders;
+ rel->reloader = before;
+ rel->rematted_node = NULL;
+ rel->can_spill_after = can_spill_after;
+ rel->remat_cost_delta = allow_remat ? 0 : REMAT_COST_INFINITE;
info->reloaders = rel;
assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
info->reloaders = rel;
assert(info->reload_cls == NULL || info->reload_cls == reload_cls);
@@
-262,12
+260,19
@@
void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before,
to_spill, before, allow_remat ? "" : " not"));
}
to_spill, before, allow_remat ? "" : " not"));
}
+void be_add_reload(spill_env_t *senv, ir_node *to_spill, ir_node *before,
+ const arch_register_class_t *reload_cls, int allow_remat)
+{
+ be_add_reload2(senv, to_spill, before, to_spill, reload_cls, allow_remat);
+
+}
+
ir_node *be_get_end_of_block_insertion_point(const ir_node *block)
{
ir_node *last = sched_last(block);
/* we might have projs and keepanys behind the jump... */
ir_node *be_get_end_of_block_insertion_point(const ir_node *block)
{
ir_node *last = sched_last(block);
/* we might have projs and keepanys behind the jump... */
- while(
is_Proj(last) ||
be_is_Keep(last)) {
+ while(be_is_Keep(last)) {
last = sched_prev(last);
assert(!sched_is_end(last));
}
last = sched_prev(last);
assert(!sched_is_end(last));
}
@@
-304,7
+309,7
@@
ir_node *get_block_insertion_point(ir_node *block, int pos)
return be_get_end_of_block_insertion_point(predblock);
}
return be_get_end_of_block_insertion_point(predblock);
}
-void be_add_reload_at_end(spill_env_t *env, ir_node *to_spill, ir_node *block,
+void be_add_reload_at_end(spill_env_t *env, ir_node *to_spill,
const
ir_node *block,
const arch_register_class_t *reload_cls,
int allow_remat)
{
const arch_register_class_t *reload_cls,
int allow_remat)
{
@@
-463,8
+468,9
@@
void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
/* build a new PhiM */
ins = alloca(sizeof(ir_node*) * arity);
for(i = 0; i < arity; ++i) {
/* build a new PhiM */
ins = alloca(sizeof(ir_node*) * arity);
for(i = 0; i < arity; ++i) {
- ins[i] =
get_irg_bad(env->irg
);
+ ins[i] =
new_r_Unknown(env->irg, mode_M
);
}
}
+ assert(!get_opt_cse());
spillinfo->spill = new_r_Phi(env->irg, block, arity, ins, mode_M);
#ifdef FIRM_STATISTICS
env->spilled_phi_count++;
spillinfo->spill = new_r_Phi(env->irg, block, arity, ins, mode_M);
#ifdef FIRM_STATISTICS
env->spilled_phi_count++;
@@
-542,7
+548,7
@@
void spill_node(spill_env_t *env, spill_info_t *spillinfo)
* @returns 1 if value is available, 0 otherwise
*/
static
* @returns 1 if value is available, 0 otherwise
*/
static
-int is_value_available(spill_env_t *env,
ir_node *arg,
ir_node *reloader)
+int is_value_available(spill_env_t *env,
const ir_node *arg, const
ir_node *reloader)
{
if(is_Unknown(arg) || arg == new_NoMem())
return 1;
{
if(is_Unknown(arg) || arg == new_NoMem())
return 1;
@@
-594,7
+600,7
@@
int is_value_available(spill_env_t *env, ir_node *arg, ir_node *reloader)
* Checks whether the node can principally be rematerialized
*/
static
* Checks whether the node can principally be rematerialized
*/
static
-int is_remat_node(spill_env_t *env, ir_node *node)
+int is_remat_node(spill_env_t *env,
const
ir_node *node)
{
const arch_env_t *arch_env = env->arch_env;
{
const arch_env_t *arch_env = env->arch_env;
@@
-617,8
+623,8
@@
int is_remat_node(spill_env_t *env, ir_node *node)
* >= REMAT_COST_INFINITE if remat is not possible.
*/
static
* >= REMAT_COST_INFINITE if remat is not possible.
*/
static
-int check_remat_conditions_costs(spill_env_t *env, ir_node *spilled,
- ir_node *reloader, int parentcosts)
+int check_remat_conditions_costs(spill_env_t *env,
const
ir_node *spilled,
+
const
ir_node *reloader, int parentcosts)
{
int i, arity;
int argremats;
{
int i, arity;
int argremats;
@@
-635,6
+641,9
@@
int check_remat_conditions_costs(spill_env_t *env, ir_node *spilled,
if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
return REMAT_COST_INFINITE;
}
if(parentcosts + costs >= env->reload_cost + env->spill_cost) {
return REMAT_COST_INFINITE;
}
+ if(arch_irn_is(env->arch_env, spilled, modify_flags)) {
+ return REMAT_COST_INFINITE;
+ }
argremats = 0;
for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
argremats = 0;
for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
@@
-741,6
+750,11
@@
double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
return env->reload_cost * freq;
}
return env->reload_cost * freq;
}
+int be_is_rematerializable(spill_env_t *env, const ir_node *to_remat, const ir_node *before)
+{
+ return check_remat_conditions_costs(env, to_remat, before, 0) < REMAT_COST_INFINITE;
+}
+
double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
ir_node *block, int pos)
{
double be_get_reload_costs_on_edge(spill_env_t *env, ir_node *to_spill,
ir_node *block, int pos)
{