/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
- *
* This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
#include "belive_t.h"
#include "benode.h"
#include "bechordal_t.h"
-#include "bestatevent.h"
+#include "statev_t.h"
#include "bessaconstr.h"
#include "beirg.h"
#include "beirgmod.h"
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,
set *spills; /**< all spill_info_t's, which must be
placed */
spill_info_t **mem_phis; /**< set of all spilled phis. */
- ir_exec_freq *exec_freq;
unsigned spill_count;
unsigned reload_count;
env->mem_phis = NEW_ARR_F(spill_info_t*, 0);
env->spill_cost = arch_env->spill_cost;
env->reload_cost = arch_env->reload_cost;
- env->exec_freq = be_get_irg_exec_freq(irg);
obstack_init(&env->obst);
env->spill_count = 0;
spill_info->spills = spill;
}
-void be_add_reload2(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)
+void be_add_reload(spill_env_t *env, ir_node *to_spill, ir_node *before, const arch_register_class_t *reload_cls, int allow_remat)
{
spill_info_t *info;
reloader_t *rel;
}
}
- assert(!is_Proj(before) && !be_is_Keep(before));
+ assert(!be_is_Keep(before));
/* put reload into list */
rel = OALLOC(&env->obst, reloader_t);
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;
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);
return be_get_end_of_block_insertion_point(predblock);
}
-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)
-{
- ir_node *before = be_get_end_of_block_insertion_point(block);
- be_add_reload(env, to_spill, before, reload_cls, allow_remat);
-}
-
void be_add_reload_on_edge(spill_env_t *env, ir_node *to_spill, ir_node *block,
int pos, const arch_register_class_t *reload_cls,
int allow_remat)
ir_graph *irg = env->irg;
ir_node *phi = spillinfo->to_spill;
ir_node *block = get_nodes_block(phi);
- ir_node *unknown;
- ir_node **ins;
spill_t *spill;
int i;
- int arity;
- assert(is_Phi(phi));
assert(!get_opt_cse());
DBG((dbg, LEVEL_1, "spilling Phi %+F:\n", phi));
/* build a new PhiM */
- arity = get_irn_arity(phi);
- ins = ALLOCAN(ir_node*, arity);
- unknown = new_r_Unknown(irg, mode_M);
+ int const arity = get_Phi_n_preds(phi);
+ ir_node **const ins = ALLOCAN(ir_node*, arity);
+ ir_node *const unknown = new_r_Unknown(irg, mode_M);
for (i = 0; i < arity; ++i) {
ins[i] = unknown;
}
if (is_Unknown(arg) || is_NoMem(arg))
return 1;
- if (be_is_Spill(skip_Proj_const(arg)))
+ if (arch_irn_is(skip_Proj_const(arg), spill))
return 1;
if (arg == get_irg_frame(env->irg))
{
int i, arity;
ir_node *res;
- ir_node *bl;
ir_node **ins;
- if (is_Block(reloader)) {
- bl = reloader;
- } else {
- bl = get_nodes_block(reloader);
- }
-
ins = ALLOCAN(ir_node*, get_irn_arity(spilled));
for (i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
ir_node *arg = get_irn_n(spilled, i);
}
/* create a copy of the node */
+ ir_node *const bl = get_nodes_block(reloader);
res = new_ir_node(get_irn_dbg_info(spilled), env->irg, bl,
get_irn_op(spilled), get_irn_mode(spilled),
get_irn_arity(spilled), ins);
double be_get_spill_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
{
ir_node *block = get_nodes_block(before);
- double freq = get_block_execfreq(env->exec_freq, block);
+ double freq = get_block_execfreq(block);
(void) to_spill;
return env->spill_cost * freq;
double be_get_reload_costs(spill_env_t *env, ir_node *to_spill, ir_node *before)
{
- ir_node *block = get_nodes_block(before);
- double freq = get_block_execfreq(env->exec_freq, block);
+ ir_node *block = get_nodes_block(before);
+ double freq = get_block_execfreq(block);
if (be_do_remats) {
/* is the node rematerializable? */
}
spill_block = get_nodes_block(insn);
- spill_execfreq = get_block_execfreq(env->exec_freq, spill_block);
+ spill_execfreq = get_block_execfreq(spill_block);
if (spillinfo->spilled_phi) {
/* TODO calculate correct costs...
s = spillinfo->spills;
for ( ; s != NULL; s = s->next) {
ir_node *spill_block = get_block(s->after);
- double freq = get_block_execfreq(env->exec_freq, spill_block);
+ double freq = get_block_execfreq(spill_block);
spills_execfreq += freq;
}
void be_insert_spills_reloads(spill_env_t *env)
{
- const ir_exec_freq *exec_freq = env->exec_freq;
- size_t n_mem_phis = ARR_LEN(env->mem_phis);
- size_t i;
+ size_t n_mem_phis = ARR_LEN(env->mem_phis);
+ size_t i;
be_timer_push(T_RA_SPILL_APPLY);
remat_cost_delta = remat_cost - env->reload_cost;
rld->remat_cost_delta = remat_cost_delta;
block = is_Block(reloader) ? reloader : get_nodes_block(reloader);
- freq = get_block_execfreq(exec_freq, block);
+ freq = get_block_execfreq(block);
all_remat_costs += remat_cost_delta * freq;
DBG((dbg, LEVEL_2, "\tremat costs delta before %+F: "
"%d (rel %f)\n", reloader, remat_cost_delta,
be_ssa_construction_add_copies(&senv, copies, ARR_LEN(copies));
be_ssa_construction_fix_users(&senv, to_spill);
-#if 0
- /* no need to enable this as long as we invalidate liveness
- after this function... */
- be_ssa_construction_update_liveness_phis(&senv);
- be_liveness_update(to_spill);
- len = ARR_LEN(copies);
- for (i = 0; i < len; ++i) {
- be_liveness_update(lv, copies[i]);
- }
-#endif
be_ssa_construction_destroy(&senv);
}
/* need to reconstruct SSA form if we had multiple spills */