src/lima/gp_ir/scheduler.c
/* eliminates each move node in the set & fixes up scheduling info */
eliminates each move node in the set & fixes up scheduling info
eliminates each move node in the set & fixes up scheduling info
static bool undo_moves(ptrset_t* moves)
{
	lima_gp_ir_node_t* node;
	ptrset_iter_t iter = ptrset_iter_create(*moves);
	ptrset_iter_for_each(iter, node)
	{
		lima_gp_ir_instr_t* instr = get_instr(node->successor->block,
											  node->sched_instr);
		lima_gp_ir_instr_remove_alu_node(instr, node);
		lima_gp_ir_alu_node_t* alu_node = gp_ir_node_to_alu(node);
		lima_gp_ir_node_t* child = alu_node->children[0];
		ptrset_t succs;
		if (!ptrset_copy(&succs, node->succs))
			return false;
		lima_gp_ir_dep_info_t* dep_info;
		ptrset_iter_t succ_iter = ptrset_iter_create(succs);
		ptrset_iter_for_each(succ_iter, dep_info)
		{
			lima_gp_ir_child_node_iter_t child_iter;
			gp_ir_node_for_each_child(dep_info->succ, child_iter)
			{
				if (*child_iter.child == node)
					*child_iter.child = child;
			}
			lima_gp_ir_dep_info_t* new_dep_info =
				malloc(sizeof(lima_gp_ir_dep_info_t));
			if (!new_dep_info)
				return false;
			new_dep_info->pred = child;
			new_dep_info->succ = dep_info->succ;
			new_dep_info->is_child_dep = true;
			new_dep_info->is_offset = dep_info->is_offset;
			if (!lima_gp_ir_dep_info_insert(new_dep_info))
				return false;
			lima_gp_ir_node_link(dep_info->succ, child);
			lima_gp_ir_node_unlink(dep_info->succ, node);
		}
		ptrset_delete(succs);
		ptrset_remove(moves, node);
	}
	return true;
}
static bool undo_moves ( ptrset_t * moves ) { lima_gp_ir_node_t * node ; ptrset_iter_t iter = ptrset_iter_create ( * moves ) ; ptrset_iter_for_each ( iter , node ) { lima_gp_ir_instr_t * instr = get_instr ( node -> successor -> block , node -> sched_instr ) ; lima_gp_ir_instr_remove_alu_node ( instr , node ) ; lima_gp_ir_alu_node_t * alu_node = gp_ir_node_to_alu ( node ) ; lima_gp_ir_node_t * child = alu_node -> children [ 0 ] ; ptrset_t succs ; if ( ! ptrset_copy ( & succs , node -> succs ) ) return false ; lima_gp_ir_dep_info_t * dep_info ; ptrset_iter_t succ_iter = ptrset_iter_create ( succs ) ; ptrset_iter_for_each ( succ_iter , dep_info ) { lima_gp_ir_child_node_iter_t child_iter ; gp_ir_node_for_each_child ( dep_info -> succ , child_iter ) { if ( * child_iter . child == node ) * child_iter . child = child ; } lima_gp_ir_dep_info_t * new_dep_info = malloc ( sizeof ( lima_gp_ir_dep_info_t ) ) ; if ( ! new_dep_info ) return false ; new_dep_info -> pred = child ; new_dep_info -> succ = dep_info -> succ ; new_dep_info -> is_child_dep = true ; new_dep_info -> is_offset = dep_info -> is_offset ; if ( ! lima_gp_ir_dep_info_insert ( new_dep_info ) ) return false ; lima_gp_ir_node_link ( dep_info -> succ , child ) ; lima_gp_ir_node_unlink ( dep_info -> succ , node ) ; } ptrset_delete ( succs ) ; ptrset_remove ( moves , node ) ; } return true ; }
eliminates each move node in the set & fixes up scheduling info
eliminates each move node in the set & fixes up scheduling info
/*printf("removing node:\n");
		printf("\tsched_instr: %u, sched_pos: %u\n", node->sched_instr,
			   node->sched_pos);*/