From ca0e4ae4bc00040809d13e0817c0926c3853f0bf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 3 Dec 2018 08:35:50 -0800 Subject: [PATCH] v3d: Convert to using nir_src_as_uint() from const_value derefs. Follows 16870de8a0aa ("nir: Use nir_src_is_const and nir_src_as_* in core code") to clean up v3d. --- src/broadcom/compiler/nir_to_vir.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index fbe8af376a7..13109d4f88f 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -1511,15 +1511,14 @@ ntq_emit_ssa_undef(struct v3d_compile *c, nir_ssa_undef_instr *instr) static void ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) { - nir_const_value *const_offset; unsigned offset; switch (instr->intrinsic) { case nir_intrinsic_load_uniform: assert(instr->num_components == 1); - const_offset = nir_src_as_const_value(instr->src[0]); - if (const_offset) { - offset = nir_intrinsic_base(instr) + const_offset->u32[0]; + if (nir_src_is_const(instr->src[0])) { + offset = (nir_intrinsic_base(instr) + + nir_src_as_uint(instr->src[0])); assert(offset % 4 == 0); /* We need dwords */ offset = offset / 4; @@ -1534,7 +1533,7 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) case nir_intrinsic_load_ubo: for (int i = 0; i < instr->num_components; i++) { - int ubo = nir_src_as_const_value(instr->src[0])->u32[0]; + int ubo = nir_src_as_uint(instr->src[0]); /* Adjust for where we stored the TGSI register base. */ vir_ADD_dest(c, @@ -1550,9 +1549,9 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) } break; - const_offset = nir_src_as_const_value(instr->src[0]); - if (const_offset) { - offset = nir_intrinsic_base(instr) + const_offset->u32[0]; + if (nir_src_is_const(instr->src[0])) { + offset = (nir_intrinsic_base(instr) + + nir_src_as_uint(instr->src[0])); assert(offset % 4 == 0); /* We need dwords */ offset = offset / 4; @@ -1603,10 +1602,9 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) break; case nir_intrinsic_load_input: - const_offset = nir_src_as_const_value(instr->src[0]); - assert(const_offset && "v3d doesn't support indirect inputs"); for (int i = 0; i < instr->num_components; i++) { - offset = nir_intrinsic_base(instr) + const_offset->u32[0]; + offset = (nir_intrinsic_base(instr) + + nir_src_as_uint(instr->src[0])); int comp = nir_intrinsic_component(instr) + i; ntq_store_dest(c, &instr->dest, i, vir_MOV(c, c->inputs[offset * 4 + comp])); @@ -1614,10 +1612,8 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) break; case nir_intrinsic_store_output: - const_offset = nir_src_as_const_value(instr->src[1]); - assert(const_offset && "v3d doesn't support indirect outputs"); offset = ((nir_intrinsic_base(instr) + - const_offset->u32[0]) * 4 + + nir_src_as_uint(instr->src[1])) * 4 + nir_intrinsic_component(instr)); for (int i = 0; i < instr->num_components; i++) { -- 2.30.2