diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-04-27 16:00:38 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-29 15:18:38 +0000 |
commit | 5860b18665a8d44d164caaf3de080172b91f36e0 (patch) | |
tree | 735c29c34cf215e86a9b01a15aa8fd4f8cdfcc51 | |
parent | e3062edff42a3afe8029c7bc36136124036d3053 (diff) |
panfrost: Move Bifrost IR indexing to common
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4792>
-rw-r--r-- | src/panfrost/util/pan_ir.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index 2d416ffeb21..7eb51fa5df1 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -178,4 +178,36 @@ pan_to_bytemask(unsigned bytes, unsigned mask); void pan_block_add_successor(pan_block *block, pan_block *successor); +/* IR indexing */ +#define PAN_IS_REG (1) + +static inline unsigned +pan_ssa_index(nir_ssa_def *ssa) +{ + /* Off-by-one ensures BIR_NO_ARG is skipped */ + return ((ssa->index + 1) << 1) | 0; +} + +static inline unsigned +pan_src_index(nir_src *src) +{ + if (src->is_ssa) + return pan_ssa_index(src->ssa); + else { + assert(!src->reg.indirect); + return (src->reg.reg->index << 1) | BIR_IS_REG; + } +} + +static inline unsigned +pan_dest_index(nir_dest *dst) +{ + if (dst->is_ssa) + return pan_ssa_index(&dst->ssa); + else { + assert(!dst->reg.indirect); + return (dst->reg.reg->index << 1) | BIR_IS_REG; + } +} + #endif |