src/lima/gp_ir/if_conversion.c
//Really hacky way to merge two basic blocks into one
//Moves all the nodes in block2 to the end of block1
//Rather than actually copy the nodes, we simply move them and update the lists
//directly, which is a lot simpler than copying and faster but more hacky.
Really hacky way to merge two basic blocks into one
Moves all the nodes in block2 to the end of block1
Rather than actually copy the nodes, we simply move them and update the lists
directly, which is a lot simpler than copying and faster but more hacky.
Really hacky way to merge two basic blocks into one Moves all the nodes in block2 to the end of block1 Rather than actually copy the nodes we simply move them and update the lists directly which is a lot simpler than copying and faster but more hacky .
static void merge_blocks(lima_gp_ir_block_t* block1, lima_gp_ir_block_t* block2)
{
	if (!gp_ir_block_is_empty(block1))
	{
		lima_gp_ir_root_node_t* last = gp_ir_block_last_node(block1);
		if (last->node.op == lima_gp_ir_op_branch_cond ||
			last->node.op == lima_gp_ir_op_branch_uncond)
			lima_gp_ir_block_remove(last);
	}
	while (!gp_ir_block_is_empty(block2))
	{
		lima_gp_ir_root_node_t* node = gp_ir_block_first_node(block2);
		list_del(&node->node_list);
		block2->num_nodes--;
		node->block = block1;
		list_add(&node->node_list, block1->node_list.prev);
		block1->num_nodes++;
	}
	lima_gp_ir_prog_remove(block2);
}
static void merge_blocks ( lima_gp_ir_block_t * block1 , lima_gp_ir_block_t * block2 ) { if ( ! gp_ir_block_is_empty ( block1 ) ) { lima_gp_ir_root_node_t * last = gp_ir_block_last_node ( block1 ) ; if ( last -> node . op == lima_gp_ir_op_branch_cond || last -> node . op == lima_gp_ir_op_branch_uncond ) lima_gp_ir_block_remove ( last ) ; } while ( ! gp_ir_block_is_empty ( block2 ) ) { lima_gp_ir_root_node_t * node = gp_ir_block_first_node ( block2 ) ; list_del ( & node -> node_list ) ; block2 -> num_nodes -- ; node -> block = block1 ; list_add ( & node -> node_list , block1 -> node_list . prev ) ; block1 -> num_nodes ++ ; } lima_gp_ir_prog_remove ( block2 ) ; }
Really hacky way to merge two basic blocks into one
Moves all the nodes in block2 to the end of block1
Rather than actually copy the nodes, we simply move them and update the lists
directly, which is a lot simpler than copying and faster but more hacky.
Really hacky way to merge two basic blocks into one Moves all the nodes in block2 to the end of block1 Rather than actually copy the nodes we simply move them and update the lists directly which is a lot simpler than copying and faster but more hacky .