diff options
author | Jason Ekstrand <[email protected]> | 2019-05-06 11:26:27 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-05-24 08:38:11 -0500 |
commit | 22421ca7be608f38ce701a43e3f6b7f3132b7aab (patch) | |
tree | cf0995e67b47c17850c0b207ac86d83abb248348 | |
parent | cd73b6174b093b75f581c3310bf784bed7c74c1f (diff) |
nir/builder: Merge nir_[if]mov_alu into one nir_mov_alu helper
Unless source modifiers are present, fmov and imov are the same.
There's no good reason for having two helpers.
Reviewed-by: Kristian H. Kristensen <[email protected]>
Acked-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/compiler/nir/nir_builder.h | 26 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_double_ops.c | 10 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_remove_phis.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_search.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/nir/tgsi_to_nir.c | 8 | ||||
-rw-r--r-- | src/mesa/program/prog_to_nir.c | 4 |
6 files changed, 18 insertions, 36 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 68cf886fa1c..e14151ab7b5 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -492,26 +492,10 @@ nir_vec(nir_builder *build, nir_ssa_def **comp, unsigned num_components) return nir_build_alu_src_arr(build, nir_op_vec(num_components), comp); } -/** - * Similar to nir_fmov, but takes a nir_alu_src instead of a nir_ssa_def. - */ -static inline nir_ssa_def * -nir_fmov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) -{ - nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_fmov); - nir_ssa_dest_init(&mov->instr, &mov->dest.dest, num_components, - nir_src_bit_size(src.src), NULL); - mov->exact = build->exact; - mov->dest.write_mask = (1 << num_components) - 1; - mov->src[0] = src; - nir_builder_instr_insert(build, &mov->instr); - - return &mov->dest.dest.ssa; -} - static inline nir_ssa_def * -nir_imov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) +nir_mov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) { + assert(!src.abs && !src.negate); nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_imov); nir_ssa_dest_init(&mov->instr, &mov->dest.dest, num_components, nir_src_bit_size(src.src), NULL); @@ -544,7 +528,7 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, const unsigned *swiz, if (num_components == src->num_components && is_identity_swizzle) return src; - return nir_imov_alu(build, alu_src, num_components); + return nir_mov_alu(build, alu_src, num_components); } /* Selects the right fdot given the number of components in each source. */ @@ -838,7 +822,7 @@ nir_ssa_for_src(nir_builder *build, nir_src src, int num_components) for (int j = 0; j < 4; j++) alu.swizzle[j] = j; - return nir_imov_alu(build, alu, num_components); + return nir_mov_alu(build, alu, num_components); } /** @@ -859,7 +843,7 @@ nir_ssa_for_alu_src(nir_builder *build, nir_alu_instr *instr, unsigned srcn) (memcmp(src->swizzle, trivial_swizzle, num_components) == 0)) return src->src.ssa; - return nir_imov_alu(build, *src, num_components); + return nir_mov_alu(build, *src, num_components); } static inline unsigned diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c index 04ec2a82801..4ddd91f9054 100644 --- a/src/compiler/nir/nir_lower_double_ops.c +++ b/src/compiler/nir/nir_lower_double_ops.c @@ -581,7 +581,7 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr, assert(nir_op_infos[instr->op].num_inputs + 1 == func->num_params); for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { assert(i + 1 < ARRAY_SIZE(params)); - params[i + 1] = nir_imov_alu(b, instr->src[i], 1); + params[i + 1] = nir_mov_alu(b, instr->src[i], 1); } nir_inline_function_impl(b, func->impl, params); @@ -633,8 +633,8 @@ lower_doubles_instr(nir_builder *b, nir_alu_instr *instr, b->cursor = nir_before_instr(&instr->instr); - nir_ssa_def *src = nir_fmov_alu(b, instr->src[0], - instr->dest.dest.ssa.num_components); + nir_ssa_def *src = nir_mov_alu(b, instr->src[0], + instr->dest.dest.ssa.num_components); nir_ssa_def *result; @@ -665,8 +665,8 @@ lower_doubles_instr(nir_builder *b, nir_alu_instr *instr, break; case nir_op_fmod: { - nir_ssa_def *src1 = nir_fmov_alu(b, instr->src[1], - instr->dest.dest.ssa.num_components); + nir_ssa_def *src1 = nir_mov_alu(b, instr->src[1], + instr->dest.dest.ssa.num_components); result = lower_mod(b, src, src1); } break; diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c index 9efbf422624..3643112d976 100644 --- a/src/compiler/nir/nir_opt_remove_phis.c +++ b/src/compiler/nir/nir_opt_remove_phis.c @@ -124,9 +124,7 @@ remove_phis_block(nir_block *block, nir_builder *b) */ b->cursor = nir_after_phis(block); - def = mov->op == nir_op_imov ? - nir_imov_alu(b, mov->src[0], def->num_components) : - nir_fmov_alu(b, mov->src[0], def->num_components); + def = nir_mov_alu(b, mov->src[0], def->num_components); } assert(phi->dest.is_ssa); diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 4838825d7b4..b8bedaa2013 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -669,7 +669,7 @@ nir_replace_instr(nir_builder *build, nir_alu_instr *instr, * and rewrite swizzles ourselves. */ nir_ssa_def *ssa_val = - nir_imov_alu(build, val, instr->dest.dest.ssa.num_components); + nir_mov_alu(build, val, instr->dest.dest.ssa.num_components); nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(ssa_val)); /* We know this one has no more uses because we just rewrote them all, diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index aae74111840..94d863d6815 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -177,7 +177,7 @@ ttn_src_for_dest(nir_builder *b, nir_alu_dest *dest) for (int i = 0; i < 4; i++) src.swizzle[i] = i; - return nir_fmov_alu(b, src, 4); + return nir_mov_alu(b, src, 4); } static enum glsl_interp_mode @@ -681,7 +681,7 @@ ttn_src_for_indirect(struct ttn_compile *c, struct tgsi_ind_register *indirect) indirect->File, indirect->Index, NULL, NULL, NULL); - return nir_imov_alu(b, src, 1); + return nir_mov_alu(b, src, 1); } static nir_alu_dest @@ -793,7 +793,7 @@ ttn_get_src(struct ttn_compile *c, struct tgsi_full_src_register *tgsi_fsrc, src.swizzle[2] = tgsi_src->SwizzleZ; src.swizzle[3] = tgsi_src->SwizzleW; - nir_ssa_def *def = nir_fmov_alu(b, src, 4); + nir_ssa_def *def = nir_mov_alu(b, src, 4); if (tgsi_src->Absolute) { if (src_is_float) @@ -1446,7 +1446,7 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src) instr->src[src_number].src_type = nir_tex_src_offset; instr->src[src_number].src = nir_src_for_ssa( - nir_fmov_alu(b, src, nir_tex_instr_src_size(instr, src_number))); + nir_mov_alu(b, src, nir_tex_instr_src_size(instr, src_number))); src_number++; } diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index 36e9b689b6b..9e45181beed 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -83,7 +83,7 @@ ptn_src_for_dest(struct ptn_compile *c, nir_alu_dest *dest) for (int i = 0; i < 4; i++) src.swizzle[i] = i; - return nir_fmov_alu(b, src, 4); + return nir_mov_alu(b, src, 4); } static nir_alu_dest @@ -205,7 +205,7 @@ ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src) for (int i = 0; i < 4; i++) src.swizzle[i] = GET_SWZ(prog_src->Swizzle, i); - def = nir_fmov_alu(b, src, 4); + def = nir_mov_alu(b, src, 4); if (prog_src->Negate) def = nir_fneg(b, def); |