diff options
author | Jason Ekstrand <[email protected]> | 2017-03-07 19:54:37 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-03-14 07:36:40 -0700 |
commit | 762a6333f21fd8606f69db6060027c4522d46678 (patch) | |
tree | f77c695fa16a5d869175773229d0195c22060c93 /src/amd | |
parent | 7107b321557e421e33fe92221133cf4a08eb7c6c (diff) |
nir: Rework conversion opcodes
The NIR story on conversion opcodes is a mess. We've had way too many
of them, naming is inconsistent, and which ones have explicit sizes was
sort-of random. This commit re-organizes things and makes them all
consistent:
- All non-bool conversion opcodes now have the explicit size in the
destination and are named <src_type>2<dst_type><size>.
- Integer <-> integer conversion opcodes now only come in i2i and u2u
forms (i2u and u2i have been removed) since the only difference
between the different integer conversions is whether or not they
sign-extend when up-converting.
- Boolean conversion opcodes all have the explicit size on the bool and
are named <src_type>2<dst_type>.
Making things consistent also allows nir_type_conversion_op to be moved
to nir_opcodes.c and auto-generated using mako. This will make adding
int8, int16, and float16 versions much easier when the time comes.
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 24 | ||||
-rw-r--r-- | src/amd/vulkan/radv_meta_blit2d.c | 6 |
2 files changed, 13 insertions, 17 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 0aba6797e7c..58f512ea997 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1449,41 +1449,37 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr) src[i] = to_integer(ctx, src[i]); result = ac_build_gather_values(&ctx->ac, src, num_components); break; - case nir_op_d2i: - case nir_op_f2i: + case nir_op_f2i32: + case nir_op_f2i64: src[0] = to_float(ctx, src[0]); result = LLVMBuildFPToSI(ctx->builder, src[0], def_type, ""); break; - case nir_op_d2u: - case nir_op_f2u: + case nir_op_f2u32: + case nir_op_f2u64: src[0] = to_float(ctx, src[0]); result = LLVMBuildFPToUI(ctx->builder, src[0], def_type, ""); break; - case nir_op_i2d: - case nir_op_i2f: + case nir_op_i2f32: + case nir_op_i2f64: result = LLVMBuildSIToFP(ctx->builder, src[0], to_float_type(ctx, def_type), ""); break; - case nir_op_u2d: - case nir_op_u2f: + case nir_op_u2f32: + case nir_op_u2f64: result = LLVMBuildUIToFP(ctx->builder, src[0], to_float_type(ctx, def_type), ""); break; - case nir_op_f2d: + case nir_op_f2f64: result = LLVMBuildFPExt(ctx->builder, src[0], to_float_type(ctx, def_type), ""); break; - case nir_op_d2f: + case nir_op_f2f32: result = LLVMBuildFPTrunc(ctx->builder, src[0], to_float_type(ctx, def_type), ""); break; case nir_op_u2u32: case nir_op_u2u64: - case nir_op_u2i32: - case nir_op_u2i64: if (get_elem_bits(ctx, LLVMTypeOf(src[0])) < get_elem_bits(ctx, def_type)) result = LLVMBuildZExt(ctx->builder, src[0], def_type, ""); else result = LLVMBuildTrunc(ctx->builder, src[0], def_type, ""); break; - case nir_op_i2u32: - case nir_op_i2u64: case nir_op_i2i32: case nir_op_i2i64: if (get_elem_bits(ctx, LLVMTypeOf(src[0])) < get_elem_bits(ctx, def_type)) diff --git a/src/amd/vulkan/radv_meta_blit2d.c b/src/amd/vulkan/radv_meta_blit2d.c index 225b4b2d412..d0cf5885bdb 100644 --- a/src/amd/vulkan/radv_meta_blit2d.c +++ b/src/amd/vulkan/radv_meta_blit2d.c @@ -586,7 +586,7 @@ build_nir_copy_fragment_shader(struct radv_device *device, vec4, "f_color"); color_out->data.location = FRAG_RESULT_DATA0; - nir_ssa_def *pos_int = nir_f2i(&b, nir_load_var(&b, tex_pos_in)); + nir_ssa_def *pos_int = nir_f2i32(&b, nir_load_var(&b, tex_pos_in)); unsigned swiz[4] = { 0, 1 }; nir_ssa_def *tex_pos = nir_swizzle(&b, pos_int, swiz, 2, false); @@ -615,7 +615,7 @@ build_nir_copy_fragment_shader_depth(struct radv_device *device, vec4, "f_color"); color_out->data.location = FRAG_RESULT_DEPTH; - nir_ssa_def *pos_int = nir_f2i(&b, nir_load_var(&b, tex_pos_in)); + nir_ssa_def *pos_int = nir_f2i32(&b, nir_load_var(&b, tex_pos_in)); unsigned swiz[4] = { 0, 1 }; nir_ssa_def *tex_pos = nir_swizzle(&b, pos_int, swiz, 2, false); @@ -644,7 +644,7 @@ build_nir_copy_fragment_shader_stencil(struct radv_device *device, vec4, "f_color"); color_out->data.location = FRAG_RESULT_STENCIL; - nir_ssa_def *pos_int = nir_f2i(&b, nir_load_var(&b, tex_pos_in)); + nir_ssa_def *pos_int = nir_f2i32(&b, nir_load_var(&b, tex_pos_in)); unsigned swiz[4] = { 0, 1 }; nir_ssa_def *tex_pos = nir_swizzle(&b, pos_int, swiz, 2, false); |