#include "irgmod.h"
#include "irnodeset.h"
#include "irnodehashmap.h"
-#include "adt/cpset.h"
+#include "cpset.h"
#include "bearch.h"
+#include "beirg.h"
#include "beuses.h"
#include "besched.h"
#include "belive_t.h"
#include "bemodule.h"
#include "benode.h"
#include "beirgmod.h"
+#include "bespillutil.h"
#include "bessaconstr.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static inline spill_info_t *get_spill_info(minibelady_env_t *env, const ir_node *node)
{
- spill_info_t *spill_info
- = (spill_info_t*) ir_nodehashmap_get(&env->spill_infos, node);
+ spill_info_t *spill_info = ir_nodehashmap_get(spill_info_t, &env->spill_infos, node);
//ir_fprintf(stderr, "Get %+F -> %p\n", node, spill_info);
return spill_info;
}
do {
after = next;
next = sched_next(after);
- } while (is_Proj(next) || is_Phi(next) || be_is_Keep(next));
+ } while (is_Phi(next) || be_is_Keep(next));
} else {
after = state;
}
be_next_use_t next_use;
ir_loop *loop;
ir_node *best_starter, *first;
- ir_node *node;
int n_cfgpreds;
unsigned best_time;
int outer_loop_allowed;
- int i;
/* Create the block info for this block. */
block_info = new_block_info(&env->obst, block);
}
/* check all Live-Ins */
- be_lv_foreach(env->lv, block, be_lv_state_in, i) {
- node = be_lv_get_irn(env->lv, block, i);
-
- if (!mode_is_data(get_irn_mode(node)))
- continue;
-
+ be_lv_foreach_cls(env->lv, block, be_lv_state_in, env->reg->reg_class, node) {
if (arch_get_irn_register(node) != env->reg)
continue;
static void belady(minibelady_env_t *env, ir_node *block)
{
ir_node *current_state;
- ir_node *node;
block_info_t *block_info;
/* Don't do a block twice */
int i, arity;
ir_node *need_val = NULL;
- /* projs are handled with the tuple value.
- * Phis are no real instr (see insert_starters()) */
- if (is_Proj(node) || is_Phi(node)) {
+ /* Phis are no real instr (see insert_starters()) */
+ if (is_Phi(node))
continue;
- }
/* check which state is desired for the node */
arity = get_irn_arity(node);
DBG((dbg, LEVEL_3, " ...%+F\n", node));
/* record state changes by the node */
- if (get_irn_mode(node) == mode_T) {
- foreach_out_edge(node, edge) {
- const arch_register_t *reg;
- ir_node *proj = get_edge_src_irn(edge);
-
- if (!mode_is_data(get_irn_mode(proj)))
- continue;
-
- reg = arch_get_irn_register(proj);
- if (reg == env->reg) {
- current_state = proj;
- DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state));
- }
- }
- } else {
- if (mode_is_data(get_irn_mode(node))) {
- const arch_register_t *reg = arch_get_irn_register(node);
- if (reg == env->reg) {
- current_state = node;
- DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state));
- }
- }
- }
+ be_foreach_value(node, value,
+ if (!mode_is_data(get_irn_mode(value)))
+ continue;
+ arch_register_t const *const reg = arch_get_irn_register(value);
+ if (reg != env->reg)
+ continue;
+ current_state = value;
+ DBG((dbg, LEVEL_3, "\t... current_state <- %+F\n", current_state));
+ );
}
/* Remember end-workset for this block */
belady((minibelady_env_t*) data, block);
}
-static ir_node *get_end_of_block_insertion_point(ir_node *block)
-{
- ir_node *last = sched_last(block);
-
- /* skip Projs and Keep-alikes behind the jump... */
- while (is_Proj(last) || be_is_Keep(last)) {
- last = sched_prev(last);
- }
-
- if (!is_cfop(last)) {
- last = sched_next(last);
- /* last node must be a cfop, only exception is the start block */
- assert(last == get_irg_start_block(get_irn_irg(block)));
- }
-
- return last;
-}
-
/**
* We must adapt the live-outs to the live-ins at each block-border.
*/
pred_info->end_state, need_state));
if (pred_info->end_state != need_state) {
- ir_node *insert_point = get_end_of_block_insertion_point(pred);
-
-
DBG((dbg, LEVEL_3, " Creating reload for %+F\n", need_state));
+ ir_node *const insert_point = be_get_end_of_block_insertion_point(pred);
create_reload(env, need_state, insert_point, pred_info->end_state);
}
}