diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-10 08:21:35 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-10 19:26:00 +0000 |
commit | 0541350e3a3cca58484880df04c0db160180b726 (patch) | |
tree | 317455be8c8b209fdf1b84d068b41b93ed07a211 | |
parent | 6409896ca70d6f7cbcc95b370118c7fa95b7220f (diff) |
pan/bi: Implement comparison opcodes via BI_CMP
Pretty straightforward for the moment. Ideally these would be fused into
csel/branches but that will come a bit later.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4139>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4139>
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index f2529e52a09..5e822299094 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -237,6 +237,16 @@ bi_class_for_nir_alu(nir_op op) case nir_op_isub: return BI_ISUB; + case nir_op_flt: + case nir_op_fge: + case nir_op_feq: + case nir_op_fne: + case nir_op_ilt: + case nir_op_ige: + case nir_op_ieq: + case nir_op_ine: + return BI_CMP; + case nir_op_bcsel: return BI_CSEL; @@ -290,6 +300,27 @@ bi_class_for_nir_alu(nir_op op) } } +static enum bi_cond +bi_cond_for_nir(nir_op op) +{ + switch (op) { + case nir_op_flt: + case nir_op_ilt: + return BI_COND_LT; + case nir_op_fge: + case nir_op_ige: + return BI_COND_GE; + case nir_op_feq: + case nir_op_ieq: + return BI_COND_EQ; + case nir_op_fne: + case nir_op_ine: + return BI_COND_NE; + default: + unreachable("Invalid compare"); + } +} + static void emit_alu(bi_context *ctx, nir_alu_instr *instr) { @@ -388,6 +419,16 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) case nir_op_fcos: alu.op.special = BI_SPECIAL_FCOS; break; + case nir_op_flt: + case nir_op_ilt: + case nir_op_fge: + case nir_op_ige: + case nir_op_feq: + case nir_op_ieq: + case nir_op_fne: + case nir_op_ine: + alu.op.compare = bi_cond_for_nir(instr->op); + break; default: break; } |