diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-11 14:46:01 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-11 20:28:21 +0000 |
commit | e623007eb786ddc5fb06133f3d7c27f9a2eb18f9 (patch) | |
tree | 5993d4ca402ff1fc0864dea9a567c02746a6deaf /src | |
parent | e94754a7c47bd59526de72115576519e015f4d76 (diff) |
pan/bi: Add bi_bytemask_of_read_components helpers
Same purpose as the Midgard version, but the implementation is
*dramatically* simpler thanks to our more regular IR.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4150>
Diffstat (limited to 'src')
-rw-r--r-- | src/panfrost/bifrost/bir.c | 21 | ||||
-rw-r--r-- | src/panfrost/bifrost/compiler.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/bir.c b/src/panfrost/bifrost/bir.c index 5fe0ae48409..48c06ab776e 100644 --- a/src/panfrost/bifrost/bir.c +++ b/src/panfrost/bifrost/bir.c @@ -74,3 +74,24 @@ bi_has_arg(bi_instruction *ins, unsigned arg) return false; } + +uint16_t +bi_bytemask_of_read_components(bi_instruction *ins, unsigned node) +{ + uint16_t mask = 0x0; + + bi_foreach_src(ins, s) { + if (ins->src[s] != node) continue; + nir_alu_type T = ins->src_types[s]; + unsigned size = nir_alu_type_get_type_size(T); + unsigned bytes = (MAX2(size, 8) / 8); + unsigned cmask = (1 << bytes) - 1; + + for (unsigned i = 0; i < ARRAY_SIZE(ins->swizzle[s]); ++i) { + unsigned c = ins->swizzle[s][i]; + mask |= (cmask << (c * bytes)); + } + } + + return mask; +} diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index cd0d4f56536..467735bcf0a 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -475,6 +475,7 @@ bool bi_has_outmod(bi_instruction *ins); bool bi_has_source_mods(bi_instruction *ins); bool bi_is_src_swizzled(bi_instruction *ins, unsigned s); bool bi_has_arg(bi_instruction *ins, unsigned arg); +uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node); /* BIR passes */ |