diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-05-16 15:11:07 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-06-03 13:45:09 -0700 |
commit | ca164ab49513101096788d38a4ba09cc64ba0268 (patch) | |
tree | 1c03330e637380bb8c62339625aabd2ab248b72c /src/compiler/nir | |
parent | 09cc3389b9b072a9e35476b1942f208ec672a672 (diff) |
nir: Add functions to subtract and compare addresses
v2: Fix comparing addresses from formats that have more than one
component by using nir_ball_iequal(). (Jason)
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir.h | 6 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_io.c | 48 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index a1bd9b954cf..632cf06c32c 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3198,6 +3198,12 @@ nir_address_format_to_glsl_type(nir_address_format addr_format) const nir_const_value *nir_address_format_null_value(nir_address_format addr_format); +nir_ssa_def *nir_build_addr_ieq(struct nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, + nir_address_format addr_format); + +nir_ssa_def *nir_build_addr_isub(struct nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, + 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 b0197399bdf..c54303b271e 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -1258,3 +1258,51 @@ nir_address_format_null_value(nir_address_format addr_format) assert(addr_format < ARRAY_SIZE(null_values)); return null_values[addr_format]; } + +nir_ssa_def * +nir_build_addr_ieq(nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, + nir_address_format addr_format) +{ + switch (addr_format) { + case nir_address_format_32bit_global: + case nir_address_format_64bit_global: + case nir_address_format_64bit_bounded_global: + case nir_address_format_32bit_index_offset: + case nir_address_format_32bit_offset: + return nir_ball_iequal(b, addr0, addr1); + + case nir_address_format_logical: + unreachable("Unsupported address format"); + } + + unreachable("Invalid address format"); +} + +nir_ssa_def * +nir_build_addr_isub(nir_builder *b, nir_ssa_def *addr0, nir_ssa_def *addr1, + nir_address_format addr_format) +{ + switch (addr_format) { + case nir_address_format_32bit_global: + case nir_address_format_64bit_global: + case nir_address_format_32bit_offset: + assert(addr0->num_components == 1); + assert(addr1->num_components == 1); + return nir_isub(b, addr0, addr1); + + case nir_address_format_64bit_bounded_global: + return nir_isub(b, addr_to_global(b, addr0, addr_format), + addr_to_global(b, addr1, addr_format)); + + case nir_address_format_32bit_index_offset: + assert(addr0->num_components == 2); + assert(addr1->num_components == 2); + /* Assume the same buffer index. */ + return nir_isub(b, nir_channel(b, addr0, 1), nir_channel(b, addr1, 1)); + + case nir_address_format_logical: + unreachable("Unsupported address format"); + } + + unreachable("Invalid address format"); +} |