private:
void create_overload(ir_function_signature *ir, nir_function *function);
void add_instr(nir_instr *instr, unsigned num_components);
- nir_src evaluate_rvalue(ir_rvalue *ir);
+ nir_ssa_def *evaluate_rvalue(ir_rvalue *ir);
nir_alu_instr *emit(nir_op op, unsigned dest_size, nir_src *srcs);
nir_alu_instr *emit(nir_op op, unsigned dest_size, nir_src src1);
void
nir_visitor::visit(ir_if *ir)
{
- nir_src condition = evaluate_rvalue(ir->condition);
+ nir_src condition =
+ nir_src_for_ssa(evaluate_rvalue(ir->condition));
exec_list *old_list = this->cf_node_list;
if (ir->condition) {
discard = nir_intrinsic_instr_create(this->shader,
nir_intrinsic_discard_if);
- discard->src[0] = evaluate_rvalue(ir->condition);
+ discard->src[0] =
+ nir_src_for_ssa(evaluate_rvalue(ir->condition));
} else {
discard = nir_intrinsic_instr_create(this->shader, nir_intrinsic_discard);
}
/* Set the address argument, extending the coordinate vector to four
* components.
*/
- const nir_src src_addr = evaluate_rvalue((ir_dereference *)param);
+ const nir_src src_addr =
+ nir_src_for_ssa(evaluate_rvalue((ir_dereference *)param));
nir_alu_instr *instr_addr = nir_alu_instr_create(shader, nir_op_vec4);
nir_ssa_dest_init(&instr_addr->instr, &instr_addr->dest.dest, 4, NULL);
* images.
*/
if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS) {
- instr->src[1] = evaluate_rvalue((ir_dereference *)param);
+ instr->src[1] =
+ nir_src_for_ssa(evaluate_rvalue((ir_dereference *)param));
param = param->get_next();
} else {
instr->src[1] = nir_src_for_ssa(&instr_undef->def);
/* Set the intrinsic parameters. */
if (!param->is_tail_sentinel()) {
- instr->src[2] = evaluate_rvalue((ir_dereference *)param);
+ instr->src[2] =
+ nir_src_for_ssa(evaluate_rvalue((ir_dereference *)param));
param = param->get_next();
}
if (!param->is_tail_sentinel()) {
- instr->src[3] = evaluate_rvalue((ir_dereference *)param);
+ instr->src[3] =
+ nir_src_for_ssa(evaluate_rvalue((ir_dereference *)param));
param = param->get_next();
}
nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr);
op = nir_intrinsic_store_ssbo_indirect;
ralloc_free(instr);
instr = nir_intrinsic_instr_create(shader, op);
- instr->src[2] = evaluate_rvalue(offset);
+ instr->src[2] = nir_src_for_ssa(evaluate_rvalue(offset));
instr->const_index[0] = 0;
} else {
instr->const_index[0] = const_offset->value.u[0];
instr->const_index[1] = write_mask->value.u[0];
- instr->src[0] = evaluate_rvalue(val);
+ instr->src[0] = nir_src_for_ssa(evaluate_rvalue(val));
instr->num_components = val->type->vector_elements;
- instr->src[1] = evaluate_rvalue(block);
+ instr->src[1] = nir_src_for_ssa(evaluate_rvalue(block));
nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr);
break;
}
op = nir_intrinsic_load_ssbo_indirect;
ralloc_free(instr);
instr = nir_intrinsic_instr_create(shader, op);
- instr->src[1] = evaluate_rvalue(offset);
+ instr->src[1] = nir_src_for_ssa(evaluate_rvalue(offset));
instr->const_index[0] = 0;
dest = &instr->dest;
} else {
instr->const_index[0] = const_offset->value.u[0];
}
- instr->src[0] = evaluate_rvalue(block);
+ instr->src[0] = nir_src_for_ssa(evaluate_rvalue(block));
const glsl_type *type = ir->return_deref->var->type;
instr->num_components = type->vector_elements;
/* Block index */
exec_node *param = ir->actual_parameters.get_head();
ir_instruction *inst = (ir_instruction *) param;
- instr->src[0] = evaluate_rvalue(inst->as_rvalue());
+ instr->src[0] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
/* Offset */
param = param->get_next();
inst = (ir_instruction *) param;
- instr->src[1] = evaluate_rvalue(inst->as_rvalue());
+ instr->src[1] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
/* data1 parameter (this is always present) */
param = param->get_next();
inst = (ir_instruction *) param;
- instr->src[2] = evaluate_rvalue(inst->as_rvalue());
+ instr->src[2] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
/* data2 parameter (only with atomic_comp_swap) */
if (param_count == 4) {
assert(op == nir_intrinsic_ssbo_atomic_comp_swap);
param = param->get_next();
inst = (ir_instruction *) param;
- instr->src[3] = evaluate_rvalue(inst->as_rvalue());
+ instr->src[3] = nir_src_for_ssa(evaluate_rvalue(inst->as_rvalue()));
}
/* Atomic result */
if (ir->condition) {
nir_if *if_stmt = nir_if_create(this->shader);
- if_stmt->condition = evaluate_rvalue(ir->condition);
+ if_stmt->condition = nir_src_for_ssa(evaluate_rvalue(ir->condition));
nir_cf_node_insert_end(this->cf_node_list, &if_stmt->cf_node);
nir_instr_insert_after_cf_list(&if_stmt->then_list, ©->instr);
} else {
ir->lhs->accept(this);
nir_deref_var *lhs_deref = this->deref_head;
- nir_src src = evaluate_rvalue(ir->rhs);
+ nir_src src = nir_src_for_ssa(evaluate_rvalue(ir->rhs));
if (ir->write_mask != (1 << num_components) - 1 && ir->write_mask != 0) {
/*
if (ir->condition) {
nir_if *if_stmt = nir_if_create(this->shader);
- if_stmt->condition = evaluate_rvalue(ir->condition);
+ if_stmt->condition = nir_src_for_ssa(evaluate_rvalue(ir->condition));
nir_cf_node_insert_end(this->cf_node_list, &if_stmt->cf_node);
nir_instr_insert_after_cf_list(&if_stmt->then_list, &store->instr);
} else {
this->result = instr;
}
-nir_src
+nir_ssa_def *
nir_visitor::evaluate_rvalue(ir_rvalue* ir)
{
ir->accept(this);
nir_dest *dest = get_instr_dest(this->result);
assert(dest->is_ssa);
- return nir_src_for_ssa(&dest->ssa);
+ return &dest->ssa;
}
nir_alu_instr *
nir_intrinsic_instr *load = nir_intrinsic_instr_create(this->shader, op);
load->num_components = ir->type->vector_elements;
load->const_index[0] = const_index ? const_index->value.u[0] : 0; /* base offset */
- load->src[0] = evaluate_rvalue(ir->operands[0]);
+ load->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[0]));
if (!const_index)
- load->src[1] = evaluate_rvalue(ir->operands[1]);
+ load->src[1] = nir_src_for_ssa(evaluate_rvalue(ir->operands[1]));
add_instr(&load->instr, ir->type->vector_elements);
/*
if (intrin->intrinsic == nir_intrinsic_interp_var_at_offset ||
intrin->intrinsic == nir_intrinsic_interp_var_at_sample)
- intrin->src[0] = evaluate_rvalue(ir->operands[1]);
+ intrin->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[1]));
add_instr(&intrin->instr, deref->type->vector_elements);
nir_src srcs[4];
for (unsigned i = 0; i < ir->get_num_operands(); i++)
- srcs[i] = evaluate_rvalue(ir->operands[i]);
+ srcs[i] = nir_src_for_ssa(evaluate_rvalue(ir->operands[i]));
glsl_base_type types[4];
for (unsigned i = 0; i < ir->get_num_operands(); i++)
this->shader,
nir_intrinsic_get_buffer_size);
load->num_components = ir->type->vector_elements;
- load->src[0] = evaluate_rvalue(ir->operands[0]);
+ load->src[0] = nir_src_for_ssa(evaluate_rvalue(ir->operands[0]));
add_instr(&load->instr, ir->type->vector_elements);
return;
}
{
nir_alu_instr *instr = emit(supports_ints ? nir_op_imov : nir_op_fmov,
ir->type->vector_elements,
- evaluate_rvalue(ir->val));
+ nir_src_for_ssa(evaluate_rvalue(ir->val)));
unsigned swizzle[4] = { ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w };
for (unsigned i = 0; i < ir->type->vector_elements; i++)
if (ir->coordinate != NULL) {
instr->coord_components = ir->coordinate->type->vector_elements;
- instr->src[src_number].src = evaluate_rvalue(ir->coordinate);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->coordinate));
instr->src[src_number].src_type = nir_tex_src_coord;
src_number++;
}
if (ir->projector != NULL) {
- instr->src[src_number].src = evaluate_rvalue(ir->projector);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->projector));
instr->src[src_number].src_type = nir_tex_src_projector;
src_number++;
}
if (ir->shadow_comparitor != NULL) {
- instr->src[src_number].src = evaluate_rvalue(ir->shadow_comparitor);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->shadow_comparitor));
instr->src[src_number].src_type = nir_tex_src_comparitor;
src_number++;
}
for (unsigned i = 0; i < const_offset->type->vector_elements; i++)
instr->const_offset[i] = const_offset->value.i[i];
} else {
- instr->src[src_number].src = evaluate_rvalue(ir->offset);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->offset));
instr->src[src_number].src_type = nir_tex_src_offset;
src_number++;
}
switch (ir->op) {
case ir_txb:
- instr->src[src_number].src = evaluate_rvalue(ir->lod_info.bias);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->lod_info.bias));
instr->src[src_number].src_type = nir_tex_src_bias;
src_number++;
break;
case ir_txf:
case ir_txs:
if (ir->lod_info.lod != NULL) {
- instr->src[src_number].src = evaluate_rvalue(ir->lod_info.lod);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->lod_info.lod));
instr->src[src_number].src_type = nir_tex_src_lod;
src_number++;
}
break;
case ir_txd:
- instr->src[src_number].src = evaluate_rvalue(ir->lod_info.grad.dPdx);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->lod_info.grad.dPdx));
instr->src[src_number].src_type = nir_tex_src_ddx;
src_number++;
- instr->src[src_number].src = evaluate_rvalue(ir->lod_info.grad.dPdy);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->lod_info.grad.dPdy));
instr->src[src_number].src_type = nir_tex_src_ddy;
src_number++;
break;
case ir_txf_ms:
- instr->src[src_number].src = evaluate_rvalue(ir->lod_info.sample_index);
+ instr->src[src_number].src =
+ nir_src_for_ssa(evaluate_rvalue(ir->lod_info.sample_index));
instr->src[src_number].src_type = nir_tex_src_ms_index;
src_number++;
break;
deref->base_offset = const_index->value.u[0];
} else {
deref->deref_array_type = nir_deref_array_type_indirect;
- deref->indirect = evaluate_rvalue(ir->array_index);
+ deref->indirect =
+ nir_src_for_ssa(evaluate_rvalue(ir->array_index));
}
ir->array->accept(this);