src/lima/gp_ir/if_conversion.c
//Creates a register that holds the condition of the branch
Creates a register that holds the condition of the branch
Creates a register that holds the condition of the branch
static lima_gp_ir_reg_t* create_condition_reg(lima_gp_ir_block_t* entry)
{
	assert(!gp_ir_block_is_empty(entry));
	lima_gp_ir_root_node_t* last = gp_ir_block_last_node(entry);
	assert(last->node.op == lima_gp_ir_op_branch_cond);
	lima_gp_ir_branch_node_t* branch = gp_ir_node_to_branch(&last->node);
	lima_gp_ir_reg_t* reg = lima_gp_ir_reg_create(entry->prog);
	if (!reg)
		return NULL;
	reg->size = 1;
	lima_gp_ir_store_reg_node_t* store_node = lima_gp_ir_store_reg_node_create();
	if (!store_node)
	{
		lima_gp_ir_reg_delete(reg);
		return NULL;
	}
	store_node->reg = reg;
	lima_gp_ir_block_insert_before(&store_node->root_node, last);
	store_node->mask[0] = true;
	store_node->children[0] = branch->condition;
	lima_gp_ir_node_link(&store_node->root_node.node, branch->condition);
	return reg;
}
static lima_gp_ir_reg_t * create_condition_reg ( lima_gp_ir_block_t * entry ) { assert ( ! gp_ir_block_is_empty ( entry ) ) ; lima_gp_ir_root_node_t * last = gp_ir_block_last_node ( entry ) ; assert ( last -> node . op == lima_gp_ir_op_branch_cond ) ; lima_gp_ir_branch_node_t * branch = gp_ir_node_to_branch ( & last -> node ) ; lima_gp_ir_reg_t * reg = lima_gp_ir_reg_create ( entry -> prog ) ; if ( ! reg ) return NULL ; reg -> size = 1 ; lima_gp_ir_store_reg_node_t * store_node = lima_gp_ir_store_reg_node_create ( ) ; if ( ! store_node ) { lima_gp_ir_reg_delete ( reg ) ; return NULL ; } store_node -> reg = reg ; lima_gp_ir_block_insert_before ( & store_node -> root_node , last ) ; store_node -> mask [ 0 ] = true ; store_node -> children [ 0 ] = branch -> condition ; lima_gp_ir_node_link ( & store_node -> root_node . node , branch -> condition ) ; return reg ; }
Creates a register that holds the condition of the branch
Creates a register that holds the condition of the branch