diff options
author | Jason Ekstrand <[email protected]> | 2018-11-12 16:02:23 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-11-15 19:59:26 -0600 |
commit | 1f29f4db1e867357a119c0c7c34fb54dc27fb682 (patch) | |
tree | b23af73d180e92c5b9b06ac9dd82c52f89606552 /src | |
parent | 4266932c0b301005dcc747fb6c2fef36a3af6ffe (diff) |
nir/builder: Assert that intN_t immediates fit
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir_builder.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 3271a480520..3be630ab3dd 100644 --- 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)); |