src/lima/pp_lir/regalloc.c
//Calculates the spill cost of a register
//The benefit is defined as in the paper, and the cost is simply
//the number of defs + uses (for now)
Calculates the spill cost of a register
The benefit is defined as in the paper, and the cost is simply
the number of defs + uses (for now)
Calculates the spill cost of a register The benefit is defined as in the paper and the cost is simply the number of defs + uses ( for now )
static double calc_spill_cost(lima_pp_lir_reg_t* reg)
{
	if (reg->precolored || reg->spilled)
		return INFINITY;
	double spill_benefit = 0;
	unsigned i;
	for (i = 0; i < ptr_vector_size(reg->adjacent); i++)
	{
		lima_pp_lir_reg_t* temp_reg = ptr_vector_get(reg->adjacent, i);
		spill_benefit += (double) q[get_reg_class(temp_reg)][get_reg_class(reg)]
		/ p[get_reg_class(temp_reg)];
	}
	return (ptrset_size(reg->defs) + ptrset_size(reg->uses)) / spill_benefit;
}
static double calc_spill_cost ( lima_pp_lir_reg_t * reg ) { if ( reg -> precolored || reg -> spilled ) return INFINITY ; double spill_benefit = 0 ; unsigned i ; for ( i = 0 ; i < ptr_vector_size ( reg -> adjacent ) ; i ++ ) { lima_pp_lir_reg_t * temp_reg = ptr_vector_get ( reg -> adjacent , i ) ; spill_benefit += ( double ) q [ get_reg_class ( temp_reg ) ] [ get_reg_class ( reg ) ] / p [ get_reg_class ( temp_reg ) ] ; } return ( ptrset_size ( reg -> defs ) + ptrset_size ( reg -> uses ) ) / spill_benefit ; }
Calculates the spill cost of a register
The benefit is defined as in the paper, and the cost is simply
the number of defs + uses (for now)
Calculates the spill cost of a register The benefit is defined as in the paper and the cost is simply the number of defs + uses ( for now )
//precolored registers and registers created from spilling another register //cannot be spilled