src/lima/pp_lir/regalloc.c
//Brigg's conservative coalescing heuristic, modified to use the <p, q> test
Brigg's conservative coalescing heuristic, modified to use the  test
Brigg ' s conservative coalescing heuristic modified to use the test
static bool can_coalesce(lima_pp_lir_reg_t* reg1, lima_pp_lir_reg_t* reg2,
						 bitset_t matrix, lima_pp_lir_prog_t* prog,
						 unsigned num_regs)
{
	unsigned size = reg1->size > reg2->size ? reg1->size : reg2->size;
	unsigned reg_class =
		(reg1->beginning || reg2->beginning) ? size + 3 : size - 1;
	unsigned q_total = 0;
	unsigned i;
	for (i = 0; i < prog->num_regs; i++)
	{
		lima_pp_lir_reg_t* other = prog->regs[i];
		if (other->precolored && other->index != 0)
			continue;
		if (!reg_interferes(matrix, num_regs, reg1, other) &&
			!reg_interferes(matrix, num_regs, reg2, other))
			continue;
		if (other->q_total >= p[get_reg_class(other)])
		{
			q_total += q[reg_class][get_reg_class(other)];
		}
	}
	return q_total < p[reg_class];
}
static bool can_coalesce ( lima_pp_lir_reg_t * reg1 , lima_pp_lir_reg_t * reg2 , bitset_t matrix , lima_pp_lir_prog_t * prog , unsigned num_regs ) { unsigned size = reg1 -> size > reg2 -> size ? reg1 -> size : reg2 -> size ; unsigned reg_class = ( reg1 -> beginning || reg2 -> beginning ) ? size + 3 : size - 1 ; unsigned q_total = 0 ; unsigned i ; for ( i = 0 ; i < prog -> num_regs ; i ++ ) { lima_pp_lir_reg_t * other = prog -> regs [ i ] ; if ( other -> precolored && other -> index != 0 ) continue ; if ( ! reg_interferes ( matrix , num_regs , reg1 , other ) && ! reg_interferes ( matrix , num_regs , reg2 , other ) ) continue ; if ( other -> q_total >= p [ get_reg_class ( other ) ] ) { q_total += q [ reg_class ] [ get_reg_class ( other ) ] ; } } return q_total < p [ reg_class ] ; }
Brigg's conservative coalescing heuristic, modified to use the <p, q> test
Brigg ' s conservative coalescing heuristic modified to use the <p q > test
//calculate register class of combined register