summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_builtin_builder.h
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-04-30 06:57:11 +1000
committerDave Airlie <[email protected]>2019-11-22 04:37:25 +1000
commit12913bcf86031cefbfcb70cca5e0565be36eef5f (patch)
tree8bca919ff9b0cd46125e9b3e539aef3948239107 /src/compiler/nir/nir_builtin_builder.h
parent5375c302347396666aa325bf67fbf7b972f7aca2 (diff)
spirv/nir/opencl: handle some multiply instructions.
This adds support for some missing 24-bit and hi multiply variants. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_builtin_builder.h')
-rw-r--r--src/compiler/nir/nir_builtin_builder.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builtin_builder.h b/src/compiler/nir/nir_builtin_builder.h
index 2ec300c4474..e2fbf02b3ea 100644
--- a/src/compiler/nir/nir_builtin_builder.h
+++ b/src/compiler/nir/nir_builtin_builder.h
@@ -83,6 +83,43 @@ nir_uabs_diff(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y)
}
static inline nir_ssa_def *
+nir_umul24(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y)
+{
+ nir_ssa_def *mask = nir_imm_int(b, 0xffffff);
+ nir_ssa_def *x_24 = nir_iand(b, x, mask);
+ nir_ssa_def *y_24 = nir_iand(b, y, mask);
+ return nir_imul(b, x_24, y_24);
+}
+
+static inline nir_ssa_def *
+nir_umad24(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *z)
+{
+ nir_ssa_def *temp = nir_umul24(b, x, y);
+ return nir_iadd(b, temp, z);
+}
+
+static inline nir_ssa_def *
+nir_imad24(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *z)
+{
+ nir_ssa_def *temp = nir_imul24(b, x, y);
+ return nir_iadd(b, temp, z);
+}
+
+static inline nir_ssa_def *
+nir_imad_hi(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *z)
+{
+ nir_ssa_def *temp = nir_imul_high(b, x, y);
+ return nir_iadd(b, temp, z);
+}
+
+static inline nir_ssa_def *
+nir_umad_hi(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *z)
+{
+ nir_ssa_def *temp = nir_umul_high(b, x, y);
+ return nir_iadd(b, temp, z);
+}
+
+static inline nir_ssa_def *
nir_bitselect(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *s)
{
return nir_ior(b, nir_iand(b, nir_inot(b, s), x), nir_iand(b, s, y));