From: Alyssa Rosenzweig Date: Tue, 10 Mar 2020 12:21:35 +0000 (-0400) Subject: pan/bi: Implement comparison opcodes via BI_CMP X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0541350e3a3cca58484880df04c0db160180b726;p=mesa.git 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 Tested-by: Marge Bot Part-of: --- 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; }