src/lima/pp_lir/reg_pressure_scheduler.c
//Note: this function is similar to the one in combine_scheduler.c, except
//we can't assume the ordering of the instructions is correct since the
//peephole optimizations may have left the instructions in the wrong order.
this function is similar to the one in combine_scheduler.c, except
we can't assume the ordering of the instructions is correct since the
peephole optimizations may have left the instructions in the wrong order.
this function is similar to the one in combine_scheduler . c except we can ' t assume the ordering of the instructions is correct since the peephole optimizations may have left the instructions in the wrong order .
static void calc_max_dist(lima_pp_lir_block_t* block)
{
	fixed_queue_t work_queue = fixed_queue_create(block->num_instrs);
	lima_pp_lir_scheduled_instr_t* instr;
	pp_lir_block_for_each_instr(block, instr)
	{
		if (ptrset_size(instr->preds) == 0)
		{
			fixed_queue_push(&work_queue, instr);
		}
		instr->visited = false;
		instr->max_dist = 0;
	}
	while (!fixed_queue_is_empty(work_queue))
	{
		instr = fixed_queue_pop(&work_queue);
		if (ptrset_size(instr->preds) != 0)
		{
			ptrset_iter_t iter = ptrset_iter_create(instr->preds);
			lima_pp_lir_scheduled_instr_t* pred;
			ptrset_iter_for_each(iter, pred)
			{
				if (pred->max_dist > instr->max_dist)
					instr->max_dist = pred->max_dist;
				instr->max_dist++;
			}
		}
		instr->visited = true;
		ptrset_iter_t iter = ptrset_iter_create(instr->succs);
		lima_pp_lir_scheduled_instr_t* succ;
		ptrset_iter_for_each(iter, succ)
		{
			bool preds_visited = true;
			ptrset_iter_t iter2 = ptrset_iter_create(succ->preds);
			lima_pp_lir_scheduled_instr_t* pred;
			ptrset_iter_for_each(iter2, pred)
			{
				if (!pred->visited)
				{
					preds_visited = false;
					break;
				}
			}
			if (preds_visited)
			{
				fixed_queue_push(&work_queue, succ);
			}
		}
	}
	fixed_queue_delete(work_queue);
}
static void calc_max_dist ( lima_pp_lir_block_t * block ) { fixed_queue_t work_queue = fixed_queue_create ( block -> num_instrs ) ; lima_pp_lir_scheduled_instr_t * instr ; pp_lir_block_for_each_instr ( block , instr ) { if ( ptrset_size ( instr -> preds ) == 0 ) { fixed_queue_push ( & work_queue , instr ) ; } instr -> visited = false ; instr -> max_dist = 0 ; } while ( ! fixed_queue_is_empty ( work_queue ) ) { instr = fixed_queue_pop ( & work_queue ) ; if ( ptrset_size ( instr -> preds ) != 0 ) { ptrset_iter_t iter = ptrset_iter_create ( instr -> preds ) ; lima_pp_lir_scheduled_instr_t * pred ; ptrset_iter_for_each ( iter , pred ) { if ( pred -> max_dist > instr -> max_dist ) instr -> max_dist = pred -> max_dist ; instr -> max_dist ++ ; } } instr -> visited = true ; ptrset_iter_t iter = ptrset_iter_create ( instr -> succs ) ; lima_pp_lir_scheduled_instr_t * succ ; ptrset_iter_for_each ( iter , succ ) { bool preds_visited = true ; ptrset_iter_t iter2 = ptrset_iter_create ( succ -> preds ) ; lima_pp_lir_scheduled_instr_t * pred ; ptrset_iter_for_each ( iter2 , pred ) { if ( ! pred -> visited ) { preds_visited = false ; break ; } } if ( preds_visited ) { fixed_queue_push ( & work_queue , succ ) ; } } } fixed_queue_delete ( work_queue ) ; }
Note: this function is similar to the one in combine_scheduler.c, except
we can't assume the ordering of the instructions is correct since the
peephole optimizations may have left the instructions in the wrong order.
Note : this function is similar to the one in combine_scheduler . c except we can ' t assume the ordering of the instructions is correct since the peephole optimizations may have left the instructions in the wrong order .