summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2021-11-23 10:13:42 +0200
committerMarge Bot <emma+marge@anholt.net>2022-02-02 17:09:46 +0000
commite227bb9fd58268788a79449ed247311744210279 (patch)
tree1f67d2db00c7343039a508e3b6182876eaf4c2e7 /src
parent3ab7f4471c933767dff79638e79739323d938177 (diff)
nir/builder: add ishl_imm helper
v2: add (y >= x->bit_size) condition (Caio) Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13739>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_builder.h12
1 files changed, 12 insertions, 0 deletions
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
@@ -732,6 +732,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)
{
if (y == 0) {