aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-05-01 14:44:15 -0700
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-05-20 10:53:38 -0700
commitf051fa6ad7363556408f69594a487a84523871a9 (patch)
treec2f5b79bd8ad42a3dce118791a4439095f0d6e34 /src/compiler/nir
parent31a7476335f911ae4fc95b77b6badc83bacacfb3 (diff)
nir: Add nir_address_format_null_value()
Returns the nir_const_value * with the representation of the NULL pointer for each address format. Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_lower_io.c20
2 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 3d46250eade..7e51501e913 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3165,6 +3165,8 @@ nir_address_format_to_glsl_type(nir_address_format addr_format)
nir_address_format_num_components(addr_format));
}
+const nir_const_value *nir_address_format_null_value(nir_address_format addr_format);
+
nir_ssa_def * nir_explicit_io_address_from_deref(struct nir_builder *b,
nir_deref_instr *deref,
nir_ssa_def *base_addr,
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 153cd931f26..6f370173387 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -1230,3 +1230,23 @@ nir_get_io_vertex_index_src(nir_intrinsic_instr *instr)
return NULL;
}
}
+
+/**
+ * Return the numeric constant that identify a NULL pointer for each address
+ * format.
+ */
+const nir_const_value *
+nir_address_format_null_value(nir_address_format addr_format)
+{
+ const static nir_const_value null_values[][NIR_MAX_VEC_COMPONENTS] = {
+ [nir_address_format_32bit_global] = {{0}},
+ [nir_address_format_64bit_global] = {{0}},
+ [nir_address_format_64bit_bounded_global] = {{0}},
+ [nir_address_format_32bit_index_offset] = {{.u32 = ~0}, {.u32 = ~0}},
+ [nir_address_format_32bit_offset] = {{.u32 = ~0}},
+ [nir_address_format_logical] = {{.u32 = ~0}},
+ };
+
+ assert(addr_format < ARRAY_SIZE(null_values));
+ return null_values[addr_format];
+}