nir: Add nir_address_format_logical
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Wed, 1 May 2019 20:24:45 +0000 (13:24 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 20 May 2019 17:53:38 +0000 (10:53 -0700)
An address format representing a purely logical addressing model.  In
this model, all deref chains must be complete from the dereference
operation to the variable.  Cast derefs are not allowed.  These
addresses will be 32-bit scalars but the format is immaterial because
you can always chase the chain.  E.g. push constants in anv.

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 3e408e20f07cde0721f6c2b99c3e5117cc03ea44..5897f6cea7c597a0ca80013a12351c1431b25782 100644 (file)
@@ -3112,6 +3112,15 @@ typedef enum {
     * component is a buffer index and the second is an offset.
     */
    nir_address_format_32bit_index_offset,
+
+   /**
+    * An address format representing a purely logical addressing model.  In
+    * this model, all deref chains must be complete from the dereference
+    * operation to the variable.  Cast derefs are not allowed.  These
+    * addresses will be 32-bit scalars but the format is immaterial because
+    * you can always chase the chain.
+    */
+   nir_address_format_logical,
 } nir_address_format;
 
 static inline unsigned
@@ -3122,6 +3131,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_logical:                return 32;
    }
    unreachable("Invalid address format");
 }
@@ -3134,6 +3144,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_logical:                return 1;
    }
    unreachable("Invalid address format");
 }
index d964255625892ef71071f1508bc348d24c79ff12..1a7e00bf96afa657ceb3d843480aa09ae5a4dfc2 100644 (file)
@@ -618,6 +618,8 @@ build_addr_iadd(nir_builder *b, nir_ssa_def *addr,
       assert(addr->num_components == 2);
       return nir_vec2(b, nir_channel(b, addr, 0),
                          nir_iadd(b, nir_channel(b, addr, 1), offset));
+   case nir_address_format_logical:
+      unreachable("Unsupported address format");
    }
    unreachable("Invalid address format");
 }
@@ -673,6 +675,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_logical:
       unreachable("Cannot get a 64-bit address with this address format");
    }