nir: Add nir_address_format_null_value()
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 1 May 2019 21:44:15 +0000 (14:44 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 20 May 2019 17:53:38 +0000 (10:53 -0700)
Returns the nir_const_value * with the representation of the NULL
pointer for each address format.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_io.c

index 3d46250eadeae62e54c7abb98e75dadc4ae0fa30..7e51501e9130a050e825ec2d69a8ef7e013ad9e2 100644 (file)
@@ -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,
index 153cd931f26cfb06a87292715204b35a341569bb..6f370173387e267e486dd0c34031eddda4089cab 100644 (file)
@@ -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];
+}