diff options
Diffstat (limited to 'src/compiler/nir/nir_builtin_builder.h')
-rw-r--r-- | src/compiler/nir/nir_builtin_builder.h | 37 |
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)); |