Mesa (main): nir/builder: add ishl_imm helper
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 2 17:39:54 UTC 2022
Module: Mesa
Branch: main
Commit: e227bb9fd58268788a79449ed247311744210279
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e227bb9fd58268788a79449ed247311744210279
Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date: Tue Nov 23 10:13:42 2021 +0200
nir/builder: add ishl_imm helper
v2: add (y >= x->bit_size) condition (Caio)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13739>
---
src/compiler/nir/nir_builder.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 0ee4e76600d..6225579e286 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -731,6 +731,18 @@ nir_iand_imm(nir_builder *build, nir_ssa_def *x, uint64_t y)
}
}
+static inline nir_ssa_def *
+nir_ishl_imm(nir_builder *build, nir_ssa_def *x, uint32_t y)
+{
+ if (y == 0) {
+ return x;
+ } else if (y >= x->bit_size) {
+ return nir_imm_intN_t(build, 0, x->bit_size);
+ } else {
+ return nir_ishl(build, x, nir_imm_int(build, y));
+ }
+}
+
static inline nir_ssa_def *
nir_ishr_imm(nir_builder *build, nir_ssa_def *x, uint32_t y)
{
More information about the mesa-commit
mailing list