aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_opcodes.py
diff options
context:
space:
mode:
authorNeil Roberts <[email protected]>2019-01-30 10:58:48 +0100
committerNeil Roberts <[email protected]>2019-11-20 14:09:43 +0100
commit2ec97e78a9ae4da59f175a5f24c3d6c062f36ca7 (patch)
tree724d640822350a11098990341dcf40b734c1146d /src/compiler/nir/nir_opcodes.py
parent9a96afb97e207134cc92ac38ecbcfcd6cd5282bb (diff)
nir/opcodes: Add a helper function to generate reduce opcodes
Adds binop_reduce_all_sizes which generates both 1-bit and 32-bit versions of the reduce operation. This reduces the code duplication a bit and will make it easier to later add 16-bit versions as well. Reviewed-by: Rob Clark <[email protected]> Acked-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_opcodes.py')
-rw-r--r--src/compiler/nir/nir_opcodes.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index 17c6824ae56..fd8b56063f0 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -529,6 +529,13 @@ def binop_reduce(name, output_size, output_type, src_type, prereduce_expr,
[4, 4], [src_type, src_type], False, _2src_commutative,
final(reduce_(reduce_(src0, src1), reduce_(src2, src3))))
+def binop_reduce_all_sizes(name, output_size, src_type, prereduce_expr,
+ reduce_expr, final_expr):
+ binop_reduce(name, output_size, tbool1, src_type,
+ prereduce_expr, reduce_expr, final_expr)
+ binop_reduce("b32" + name[1:], output_size, tbool32, src_type,
+ prereduce_expr, reduce_expr, final_expr)
+
binop("fadd", tfloat, _2src_commutative + associative,"""
if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
if (bit_size == 64)
@@ -710,23 +717,14 @@ binop_compare_all_sizes("uge", tuint, "", "src0 >= src1")
# integer-aware GLSL-style comparisons that compare floats and ints
-binop_reduce("ball_fequal", 1, tbool1, tfloat, "{src0} == {src1}",
- "{src0} && {src1}", "{src}")
-binop_reduce("bany_fnequal", 1, tbool1, tfloat, "{src0} != {src1}",
- "{src0} || {src1}", "{src}")
-binop_reduce("ball_iequal", 1, tbool1, tint, "{src0} == {src1}",
- "{src0} && {src1}", "{src}")
-binop_reduce("bany_inequal", 1, tbool1, tint, "{src0} != {src1}",
- "{src0} || {src1}", "{src}")
-
-binop_reduce("b32all_fequal", 1, tbool32, tfloat, "{src0} == {src1}",
- "{src0} && {src1}", "{src}")
-binop_reduce("b32any_fnequal", 1, tbool32, tfloat, "{src0} != {src1}",
- "{src0} || {src1}", "{src}")
-binop_reduce("b32all_iequal", 1, tbool32, tint, "{src0} == {src1}",
- "{src0} && {src1}", "{src}")
-binop_reduce("b32any_inequal", 1, tbool32, tint, "{src0} != {src1}",
- "{src0} || {src1}", "{src}")
+binop_reduce_all_sizes("ball_fequal", 1, tfloat, "{src0} == {src1}",
+ "{src0} && {src1}", "{src}")
+binop_reduce_all_sizes("bany_fnequal", 1, tfloat, "{src0} != {src1}",
+ "{src0} || {src1}", "{src}")
+binop_reduce_all_sizes("ball_iequal", 1, tint, "{src0} == {src1}",
+ "{src0} && {src1}", "{src}")
+binop_reduce_all_sizes("bany_inequal", 1, tint, "{src0} != {src1}",
+ "{src0} || {src1}", "{src}")
# non-integer-aware GLSL-style comparisons that return 0.0 or 1.0