nir: Add nir_address_format_32bit_offset
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 3 May 2019 21:34:55 +0000 (14:34 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 20 May 2019 17:53:38 +0000 (10:53 -0700)
This is a simple 32-bit address which is not a global address.  Gives
us a format that don't use 0 as its null pointer value.  We will need
this in anv to represent nir_var_mem_shared addresses.

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 5897f6cea7c597a0ca80013a12351c1431b25782..3d46250eadeae62e54c7abb98e75dadc4ae0fa30 100644 (file)
@@ -3113,6 +3113,11 @@ typedef enum {
     */
    nir_address_format_32bit_index_offset,
 
+   /**
+    * An address format which is a simple 32-bit offset.
+    */
+   nir_address_format_32bit_offset,
+
    /**
     * An address format representing a purely logical addressing model.  In
     * this model, all deref chains must be complete from the dereference
@@ -3131,6 +3136,7 @@ nir_address_format_bit_size(nir_address_format addr_format)
    case nir_address_format_64bit_global:           return 64;
    case nir_address_format_64bit_bounded_global:   return 32;
    case nir_address_format_32bit_index_offset:     return 32;
+   case nir_address_format_32bit_offset:           return 32;
    case nir_address_format_logical:                return 32;
    }
    unreachable("Invalid address format");
@@ -3144,6 +3150,7 @@ nir_address_format_num_components(nir_address_format addr_format)
    case nir_address_format_64bit_global:           return 1;
    case nir_address_format_64bit_bounded_global:   return 4;
    case nir_address_format_32bit_index_offset:     return 2;
+   case nir_address_format_32bit_offset:           return 1;
    case nir_address_format_logical:                return 1;
    }
    unreachable("Invalid address format");
index 1a7e00bf96afa657ceb3d843480aa09ae5a4dfc2..153cd931f26cfb06a87292715204b35a341569bb 100644 (file)
@@ -604,6 +604,7 @@ build_addr_iadd(nir_builder *b, nir_ssa_def *addr,
    switch (addr_format) {
    case nir_address_format_32bit_global:
    case nir_address_format_64bit_global:
+   case nir_address_format_32bit_offset:
       assert(addr->num_components == 1);
       return nir_iadd(b, addr, offset);
 
@@ -675,6 +676,7 @@ addr_to_global(nir_builder *b, nir_ssa_def *addr,
                          nir_u2u64(b, nir_channel(b, addr, 3)));
 
    case nir_address_format_32bit_index_offset:
+   case nir_address_format_32bit_offset:
    case nir_address_format_logical:
       unreachable("Cannot get a 64-bit address with this address format");
    }