return deref;
}
+static inline nir_deref_instr *
+nir_build_deref_array_imm(nir_builder *build, nir_deref_instr *parent,
+ int64_t index)
+{
+ assert(parent->dest.is_ssa);
+ nir_ssa_def *idx_ssa = nir_imm_intN_t(build, index,
+ parent->dest.ssa.bit_size);
+
+ return nir_build_deref_array(build, parent, idx_ssa);
+}
+
static inline nir_deref_instr *
nir_build_deref_ptr_as_array(nir_builder *build, nir_deref_instr *parent,
nir_ssa_def *index)
nir_load_const_instr_create(b->shader, rows, bit_size);
load->value = c->values[i];
nir_builder_instr_insert(b, &load->instr);
- nir_store_deref(b, nir_build_deref_array(b, deref, nir_imm_int(b, i)),
+ nir_store_deref(b, nir_build_deref_array_imm(b, deref, i),
&load->def, ~0);
}
} else if (glsl_type_is_struct_or_ifc(deref->type)) {
unsigned len = glsl_get_length(deref->type);
for (unsigned i = 0; i < len; i++) {
build_constant_load(b,
- nir_build_deref_array(b, deref, nir_imm_int(b, i)),
+ nir_build_deref_array_imm(b, deref, i),
c->elements[i]);
}
}
{
assert(start < end);
if (start == end - 1) {
- nir_ssa_def *index = nir_imm_int(b, start);
emit_load_store_deref(b, orig_instr,
- nir_build_deref_array(b, parent, index),
+ nir_build_deref_array_imm(b, parent, start),
deref_arr + 1, dest, src);
} else {
int mid = start + (end - start) / 2;
assert(length > 0);
for (unsigned i = 0; i < length; i++) {
- nir_ssa_def *index = nir_imm_int(b, i);
emit_deref_copy_load_store(b,
- nir_build_deref_array(b, dst_deref, index),
+ nir_build_deref_array_imm(b, dst_deref, i),
dst_deref_arr + 1,
- nir_build_deref_array(b, src_deref, index),
+ nir_build_deref_array_imm(b, src_deref, i),
src_deref_arr + 1);
}
} else {
glsl_get_length(src_path->path[src_level]->type));
unsigned len = glsl_get_length(dst_path->path[dst_level]->type);
for (unsigned i = 0; i < len; i++) {
- nir_ssa_def *idx = nir_imm_int(b, i);
emit_split_copies(b, dst_info, dst_path, dst_level + 1,
- nir_build_deref_array(b, dst, idx),
+ nir_build_deref_array_imm(b, dst, i),
src_info, src_path, src_level + 1,
- nir_build_deref_array(b, src, idx));
+ nir_build_deref_array_imm(b, src, i));
}
} else {
/* Neither side is being split so we just keep going */
/* This load will be dropped, as vec.y (or vec[1]) is already known. */
nir_deref_instr *deref =
- nir_build_deref_array(b, nir_build_deref_var(b, vec), nir_imm_int(b, 1));
+ nir_build_deref_array_imm(b, nir_build_deref_var(b, vec), 1);
nir_ssa_def *loaded_from_deref = nir_load_deref(b, deref);
/* This store should use the value loaded from in1. */
/* This load will be replaced with one from in0. */
nir_deref_instr *deref =
- nir_build_deref_array(b, nir_build_deref_var(b, vec), nir_imm_int(b, 1));
+ nir_build_deref_array_imm(b, nir_build_deref_var(b, vec), 1);
nir_load_deref(b, deref);
nir_validate_shader(b->shader, NULL);
/* Loading "vec[1]" deref will save the information about vec.y. */
nir_deref_instr *deref =
- nir_build_deref_array(b, nir_build_deref_var(b, vec), nir_imm_int(b, 1));
+ nir_build_deref_array_imm(b, nir_build_deref_var(b, vec), 1);
nir_load_deref(b, deref);
/* Store to vec.x. */
/* Store to "vec[1]" and "vec[0]". */
nir_deref_instr *store_deref_y =
- nir_build_deref_array(b, nir_build_deref_var(b, vec), nir_imm_int(b, 1));
+ nir_build_deref_array_imm(b, nir_build_deref_var(b, vec), 1);
nir_store_deref(b, store_deref_y, nir_imm_int(b, 20), 1);
nir_deref_instr *store_deref_x =
- nir_build_deref_array(b, nir_build_deref_var(b, vec), nir_imm_int(b, 0));
+ nir_build_deref_array_imm(b, nir_build_deref_var(b, vec), 0);
nir_store_deref(b, store_deref_x, nir_imm_int(b, 10), 1);
/* Both loads below will be dropped, because the values are already known. */
nir_deref_instr *load_deref_y =
- nir_build_deref_array(b, nir_build_deref_var(b, vec), nir_imm_int(b, 1));
+ nir_build_deref_array_imm(b, nir_build_deref_var(b, vec), 1);
nir_store_var(b, out0, nir_load_deref(b, load_deref_y), 1);
nir_store_var(b, out1, nir_load_var(b, vec), 1);
unsigned elems = glsl_get_length(deref->type);
for (unsigned i = 0; i < elems; i++) {
nir_deref_instr *child =
- nir_build_deref_array(&b->nb, deref, nir_imm_int(&b->nb, i));
+ nir_build_deref_array_imm(&b->nb, deref, i);
_vtn_local_load_store(b, load, child, inout->elems[i]);
}
} else {
nir_deref_instr *deref = nir_build_deref_var(b, idx_var);
if (glsl_type_is_array(type))
- deref = nir_build_deref_array(b, deref, nir_imm_int(b, 0));
+ deref = nir_build_deref_array_imm(b, deref, 0);
state->view_index = nir_load_deref(b, deref);
}