- be_add_spill(env, arg, insert);
- }
-}
-
-/*
- * ____ _ ____ _ _ _
- * / ___|_ __ ___ __ _| |_ ___ / ___| _ __ (_) | |___
- * | | | '__/ _ \/ _` | __/ _ \ \___ \| '_ \| | | / __|
- * | |___| | | __/ (_| | || __/ ___) | |_) | | | \__ \
- * \____|_| \___|\__,_|\__\___| |____/| .__/|_|_|_|___/
- * |_|
- */
-
-static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo);
-
-/**
- * Creates a spill.
- *
- * @param senv the spill environment
- * @param irn the node that should be spilled
- * @param ctx_irn an user of the spilled node
- *
- * @return a be_Spill node
- */
-static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
-{
- ir_node *to_spill = spillinfo->to_spill;
- spill_t *spill;
-
- /* determine_spill_costs must have been run before */
- assert(spillinfo->spill_costs >= 0);
-
- /* some backends have virtual noreg/unknown nodes that are not scheduled
- * and simply always available. */
- if(!sched_is_scheduled(to_spill)) {
- /* override spillinfos or create a new one */
- spillinfo->spills->spill = new_NoMem();
- DB((dbg, LEVEL_1, "don't spill %+F use NoMem\n", to_spill));
- return;
- }
-
- DBG((dbg, LEVEL_1, "spilling %+F ... \n", to_spill));
- spill = spillinfo->spills;
- for( ; spill != NULL; spill = spill->next) {
- ir_node *after = spill->after;
- ir_node *block = get_block(after);
-
- after = skip_keeps_phis(after);
-
- spill->spill = be_spill(block, to_spill);
- sched_add_after(after, spill->spill);
- DB((dbg, LEVEL_1, "\t%+F after %+F\n", spill->spill, after));
-#ifdef FIRM_STATISTICS
- env->spill_count++;
-#endif
- }
- DBG((dbg, LEVEL_1, "\n"));
-}
-
-static void spill_node(spill_env_t *env, spill_info_t *spillinfo);
-
-/**
- * If the first usage of a Phi result would be out of memory
- * there is no sense in allocating a register for it.
- * Thus we spill it and all its operands to the same spill slot.
- * Therefore the phi/dataB becomes a phi/Memory
- *
- * @param senv the spill environment
- * @param phi the Phi node that should be spilled
- * @param ctx_irn an user of the spilled node
- */
-static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
-{
- 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 = alloca(sizeof(ir_node*) * arity);
- unknown = new_r_Unknown(irg, mode_M);
- for(i = 0; i < arity; ++i) {
- ins[i] = unknown;
- }
-
- /* override or replace spills list... */
- spill = obstack_alloc(&env->obst, sizeof(spill[0]));
- spill->after = skip_keeps_phis(phi);
- spill->spill = new_r_Phi(irg, block, arity, ins, mode_M);
- spill->next = NULL;
-
- spillinfo->spills = spill;
-#ifdef FIRM_STATISTICS
- env->spilled_phi_count++;
-#endif
-
- for(i = 0; i < arity; ++i) {
- ir_node *arg = get_irn_n(phi, i);
- 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);
- }
- DBG((dbg, LEVEL_1, "... done spilling Phi %+F, created PhiM %+F\n", phi,
- spill->spill));
-}
-
-/**
- * Spill a node.
- *
- * @param senv the spill environment
- * @param to_spill the node that should be spilled
- */
-static void spill_node(spill_env_t *env, spill_info_t *spillinfo)
-{
- ir_node *to_spill;
-
- /* node is already spilled */
- if(spillinfo->spills != NULL && spillinfo->spills->spill != NULL)