summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/nir/nir.c')
-rw-r--r--src/compiler/nir/nir.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 249b9357c3f..3c80e03a091 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -638,6 +638,7 @@ const_value_int(int64_t i, unsigned bit_size)
{
nir_const_value v;
switch (bit_size) {
+ case 1: v.b[0] = i & 1; break;
case 8: v.i8[0] = i; break;
case 16: v.i16[0] = i; break;
case 32: v.i32[0] = i; break;
@@ -1206,6 +1207,8 @@ nir_src_comp_as_int(nir_src src, unsigned comp)
assert(comp < load->def.num_components);
switch (load->def.bit_size) {
+ /* int1_t uses 0/-1 convention */
+ case 1: return -(int)load->value.b[comp];
case 8: return load->value.i8[comp];
case 16: return load->value.i16[comp];
case 32: return load->value.i32[comp];
@@ -1223,6 +1226,7 @@ nir_src_comp_as_uint(nir_src src, unsigned comp)
assert(comp < load->def.num_components);
switch (load->def.bit_size) {
+ case 1: return load->value.b[comp];
case 8: return load->value.u8[comp];
case 16: return load->value.u16[comp];
case 32: return load->value.u32[comp];
@@ -1235,15 +1239,12 @@ nir_src_comp_as_uint(nir_src src, unsigned comp)
bool
nir_src_comp_as_bool(nir_src src, unsigned comp)
{
- assert(nir_src_is_const(src));
- nir_load_const_instr *load = nir_instr_as_load_const(src.ssa->parent_instr);
+ int64_t i = nir_src_comp_as_int(src, comp);
- assert(comp < load->def.num_components);
- assert(load->def.bit_size == 32);
- assert(load->value.u32[comp] == NIR_TRUE ||
- load->value.u32[comp] == NIR_FALSE);
+ /* Booleans of any size use 0/-1 convention */
+ assert(i == 0 || i == -1);
- return load->value.u32[comp];
+ return i;
}
double