nir_const_value *nir_src_as_const_value(nir_src src);
-static inline struct nir_instr *
-nir_src_instr(const struct nir_src *src)
-{
- return src->is_ssa ? src->ssa->parent_instr : NULL;
-}
-
#define NIR_SRC_AS_(name, c_type, type_enum, cast_macro) \
static inline c_type * \
nir_src_as_ ## name (nir_src src) \
}
NIR_SRC_AS_(alu_instr, nir_alu_instr, nir_instr_type_alu, nir_instr_as_alu)
+NIR_SRC_AS_(intrinsic, nir_intrinsic_instr,
+ nir_instr_type_intrinsic, nir_instr_as_intrinsic)
bool nir_src_is_dynamically_uniform(nir_src src);
bool nir_srcs_equal(nir_src src1, nir_src src2);
nir_alu_instr *vec = nir_src_as_alu_instr(combined->src[1]);
ASSERT_TRUE(vec);
for (int i = 0; i < 4; i++) {
- nir_intrinsic_instr *load =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[i].src));
+ nir_intrinsic_instr *load = nir_src_as_intrinsic(vec->src[i].src);
ASSERT_EQ(load->intrinsic, nir_intrinsic_load_deref);
ASSERT_EQ(nir_intrinsic_get_var(load, 0), v[i])
<< "Source value for component " << i << " of store is wrong";
ASSERT_TRUE(vec);
/* Component x comes from v[0]. */
- nir_intrinsic_instr *load_for_x =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[0].src));
+ nir_intrinsic_instr *load_for_x = nir_src_as_intrinsic(vec->src[0].src);
ASSERT_EQ(nir_intrinsic_get_var(load_for_x, 0), v[0]);
ASSERT_EQ(vec->src[0].swizzle[0], 0);
/* Component y comes from v[1]. */
- nir_intrinsic_instr *load_for_y =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[1].src));
+ nir_intrinsic_instr *load_for_y = nir_src_as_intrinsic(vec->src[1].src);
ASSERT_EQ(nir_intrinsic_get_var(load_for_y, 0), v[1]);
ASSERT_EQ(vec->src[1].swizzle[0], 1);
/* Components z and w come from v[2]. */
- nir_intrinsic_instr *load_for_z =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[2].src));
- nir_intrinsic_instr *load_for_w =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[3].src));
+ nir_intrinsic_instr *load_for_z = nir_src_as_intrinsic(vec->src[2].src);
+ nir_intrinsic_instr *load_for_w = nir_src_as_intrinsic(vec->src[3].src);
ASSERT_EQ(load_for_z, load_for_w);
ASSERT_EQ(nir_intrinsic_get_var(load_for_z, 0), v[2]);
ASSERT_EQ(vec->src[2].swizzle[0], 2);
ASSERT_TRUE(vec);
/* Component x comes from v[0]. */
- nir_intrinsic_instr *load_for_x =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[0].src));
+ nir_intrinsic_instr *load_for_x = nir_src_as_intrinsic(vec->src[0].src);
ASSERT_EQ(nir_intrinsic_get_var(load_for_x, 0), v[0]);
ASSERT_EQ(vec->src[0].swizzle[0], 0);
/* Component y comes from v[1]. */
- nir_intrinsic_instr *load_for_y =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[1].src));
+ nir_intrinsic_instr *load_for_y = nir_src_as_intrinsic(vec->src[1].src);
ASSERT_EQ(nir_intrinsic_get_var(load_for_y, 0), v[1]);
ASSERT_EQ(vec->src[1].swizzle[0], 1);
/* Components z comes from s[0]. */
- nir_intrinsic_instr *load_for_z =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[2].src));
+ nir_intrinsic_instr *load_for_z = nir_src_as_intrinsic(vec->src[2].src);
ASSERT_EQ(nir_intrinsic_get_var(load_for_z, 0), s[0]);
ASSERT_EQ(vec->src[2].swizzle[0], 0);
/* Component w comes from s[1]. */
- nir_intrinsic_instr *load_for_w =
- nir_instr_as_intrinsic(nir_src_instr(&vec->src[3].src));
+ nir_intrinsic_instr *load_for_w = nir_src_as_intrinsic(vec->src[3].src);
ASSERT_EQ(nir_intrinsic_get_var(load_for_w, 0), s[1]);
ASSERT_EQ(vec->src[3].swizzle[0], 0);
}
fs_visitor::optimize_frontfacing_ternary(nir_alu_instr *instr,
const fs_reg &result)
{
- if (!instr->src[0].src.is_ssa ||
- instr->src[0].src.ssa->parent_instr->type != nir_instr_type_intrinsic)
- return false;
-
- nir_intrinsic_instr *src0 =
- nir_instr_as_intrinsic(instr->src[0].src.ssa->parent_instr);
-
- if (src0->intrinsic != nir_intrinsic_load_front_face)
+ nir_intrinsic_instr *src0 = nir_src_as_intrinsic(instr->src[0].src);
+ if (src0 == NULL || src0->intrinsic != nir_intrinsic_load_front_face)
return false;
if (!nir_src_is_const(instr->src[1].src) ||
retype(brw_vec1_grf(1 + (vertex >> 3), vertex & 7),
BRW_REGISTER_TYPE_UD));
} else if (tcs_prog_data->instances == 1 &&
- vertex_src.is_ssa &&
- vertex_src.ssa->parent_instr->type == nir_instr_type_intrinsic &&
- nir_instr_as_intrinsic(vertex_src.ssa->parent_instr)->intrinsic == nir_intrinsic_load_invocation_id) {
+ nir_src_as_intrinsic(vertex_src) != NULL &&
+ nir_src_as_intrinsic(vertex_src)->intrinsic == nir_intrinsic_load_invocation_id) {
/* For the common case of only 1 instance, an array index of
* gl_InvocationID means reading g1. Skip all the indirect work.
*/