diff options
author | Jason Ekstrand <[email protected]> | 2017-10-31 14:42:33 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-11-07 10:37:52 -0800 |
commit | 8c2bf020fd649957597d074cf2390d6de029ddd0 (patch) | |
tree | ebefd22e62614b59c3f69798814e804dd5e0725e /src/compiler/nir | |
parent | 9b35faba426acc111741aa69752cb87185e548aa (diff) |
nir/builder: Add a nir_imm_intN_t helper
This lets you easily build integer immediates of arbitrary bit size.
Reviewed-by: Iago Toral Quiroga <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir_builder.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 4bd5628ff7d..36e0ae3ac63 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -264,6 +264,18 @@ nir_imm_int64(nir_builder *build, int64_t x) } static inline nir_ssa_def * +nir_imm_intN_t(nir_builder *build, uint64_t x, unsigned bit_size) +{ + nir_const_value v; + + memset(&v, 0, sizeof(v)); + assert(bit_size <= 64); + v.i64[0] = x & (~0ull >> (64 - bit_size)); + + return nir_build_imm(build, 1, bit_size, v); +} + +static inline nir_ssa_def * nir_imm_ivec4(nir_builder *build, int x, int y, int z, int w) { nir_const_value v; |