summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2018-09-12 17:05:14 -0700
committerMarge Bot <[email protected]>2020-01-23 00:18:57 +0000
commitdb649fd5822569e1f33b058c0f4d38c27a47b083 (patch)
tree20f4fa5ed67f3afa825e7f95da0b4320ea183c23
parentd3d970166cad7d834811fd1f8bcd6c53db706bce (diff)
compiler: Translate GLSL IR to NIR for new INTEL_shader_integer_functions2 expressions
v2: Rebase on 272e927d0e9 ("nir/spirv: initial handling of OpenCL.std extension opcodes") Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/767>
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index a3a85786fcd..57c07978493 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -1995,6 +1995,9 @@ nir_visitor::visit(ir_expression *ir)
result = type_is_float(types[0]) ? nir_fabs(&b, srcs[0])
: nir_iabs(&b, srcs[0]);
break;
+ case ir_unop_clz:
+ result = nir_uclz(&b, srcs[0]);
+ break;
case ir_unop_saturate:
assert(type_is_float(types[0]));
result = nir_fsat(&b, srcs[0]);
@@ -2213,10 +2216,37 @@ nir_visitor::visit(ir_expression *ir)
result = type_is_float(out_type) ? nir_fadd(&b, srcs[0], srcs[1])
: nir_iadd(&b, srcs[0], srcs[1]);
break;
+ case ir_binop_add_sat:
+ result = type_is_signed(out_type) ? nir_iadd_sat(&b, srcs[0], srcs[1])
+ : nir_uadd_sat(&b, srcs[0], srcs[1]);
+ break;
case ir_binop_sub:
result = type_is_float(out_type) ? nir_fsub(&b, srcs[0], srcs[1])
: nir_isub(&b, srcs[0], srcs[1]);
break;
+ case ir_binop_sub_sat:
+ result = type_is_signed(out_type) ? nir_isub_sat(&b, srcs[0], srcs[1])
+ : nir_usub_sat(&b, srcs[0], srcs[1]);
+ break;
+ case ir_binop_abs_sub:
+ /* out_type is always unsigned for ir_binop_abs_sub, so we have to key
+ * on the type of the sources.
+ */
+ result = type_is_signed(types[0]) ? nir_uabs_isub(&b, srcs[0], srcs[1])
+ : nir_uabs_usub(&b, srcs[0], srcs[1]);
+ break;
+ case ir_binop_avg:
+ result = type_is_signed(out_type) ? nir_ihadd(&b, srcs[0], srcs[1])
+ : nir_uhadd(&b, srcs[0], srcs[1]);
+ break;
+ case ir_binop_avg_round:
+ result = type_is_signed(out_type) ? nir_irhadd(&b, srcs[0], srcs[1])
+ : nir_urhadd(&b, srcs[0], srcs[1]);
+ break;
+ case ir_binop_mul_32x16:
+ result = type_is_signed(out_type) ? nir_imul_32x16(&b, srcs[0], srcs[1])
+ : nir_umul_32x16(&b, srcs[0], srcs[1]);
+ break;
case ir_binop_mul:
if (type_is_float(out_type))
result = nir_fmul(&b, srcs[0], srcs[1]);