diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-04-01 18:50:27 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-05 23:26:04 +0000 |
commit | 9b262208b620fea21a7c44fbc74e17b846953ad1 (patch) | |
tree | 18a1791fac3eaa4a698976bd36e2f81992f2070e /src/panfrost | |
parent | 069189ff0f2beb3dd9004a1e37b8cc0cdeac4f23 (diff) |
pan/bit: Add CSEL to interpreter
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4458>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/bifrost/test/bi_interpret.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/panfrost/bifrost/test/bi_interpret.c b/src/panfrost/bifrost/test/bi_interpret.c index 2ad1a21df25..9217b9e42ea 100644 --- a/src/panfrost/bifrost/test/bi_interpret.c +++ b/src/panfrost/bifrost/test/bi_interpret.c @@ -214,6 +214,41 @@ bit_srcmod(float raw, bool abs, bool neg) return raw; } +#define BIT_COND(cond, left, right) \ + if (cond == BI_COND_LT) return left < right; \ + else if (cond == BI_COND_LE) return left <= right; \ + else if (cond == BI_COND_GE) return left >= right; \ + else if (cond == BI_COND_GT) return left > right; \ + else if (cond == BI_COND_EQ) return left == right; \ + else if (cond == BI_COND_NE) return left != right; \ + else { return true; } + +static bool +bit_eval_cond(enum bi_cond cond, bit_t l, bit_t r, nir_alu_type T, unsigned c) +{ + if (T == nir_type_float32) { + BIT_COND(cond, l.f32, r.f32); + } else if (T == nir_type_float16) { + float left = bf(l.f16[c]); + float right = bf(r.f16[c]); + BIT_COND(cond, left, right); + } else if (T == nir_type_int32) { + int32_t left = (int32_t) l.u32; + int32_t right = (int32_t) r.u32; + BIT_COND(cond, left, right); + } else if (T == nir_type_int16) { + int16_t left = (int16_t) l.u32; + int16_t right = (int16_t) r.u32; + BIT_COND(cond, left, right); + } else if (T == nir_type_uint32) { + BIT_COND(cond, l.u32, r.u32); + } else if (T == nir_type_uint16) { + BIT_COND(cond, l.u16[c], r.u16[c]); + } else { + unreachable("Unknown type evaluated"); + } +} + void bit_step(struct bit_state *s, bi_instruction *ins, bool FMA) { @@ -251,9 +286,17 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA) case BI_CMP: case BI_BITWISE: case BI_CONVERT: - case BI_CSEL: unreachable("Unsupported op"); + case BI_CSEL: { + bool direct = ins->csel_cond == BI_COND_ALWAYS; + bool cond = direct ? srcs[0].u32 : + bit_eval_cond(ins->csel_cond, srcs[0], srcs[1], ins->src_types[0], 0); + + dest = cond ? srcs[2] : srcs[3]; + break; + } + case BI_FMA: { bfloat(bit_f64fma, bit_f32fma); unreachable("Unknown type"); |