projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4266932
)
nir/builder: Assert that intN_t immediates fit
author
Jason Ekstrand
<jason.ekstrand@intel.com>
Mon, 12 Nov 2018 22:02:23 +0000
(16:02 -0600)
committer
Jason Ekstrand
<jason.ekstrand@intel.com>
Fri, 16 Nov 2018 01:59:26 +0000
(19:59 -0600)
This assert won't catch all mistakes with this helper but it will at
least ensure that the top bits are all zero or all one which should help
catch bugs.
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
src/compiler/nir/nir_builder.h
patch
|
blob
|
history
diff --git
a/src/compiler/nir/nir_builder.h
b/src/compiler/nir/nir_builder.h
index 3271a480520ee2d53e802b15301fafc995dfc5b4..3be630ab3dd92a36f984f97e733f6b75fa225040 100644
(file)
--- a/
src/compiler/nir/nir_builder.h
+++ b/
src/compiler/nir/nir_builder.h
@@
-330,6
+330,10
@@
nir_imm_intN_t(nir_builder *build, uint64_t x, unsigned bit_size)
{
nir_const_value v;
+ assert(bit_size == 64 ||
+ (int64_t)x >> bit_size == 0 ||
+ (int64_t)x >> bit_size == -1);
+
memset(&v, 0, sizeof(v));
assert(bit_size <= 64);
v.i64[0] = x & (~0ull >> (64 - bit_size));