From: Alyssa Rosenzweig Date: Mon, 4 May 2020 18:37:04 +0000 (-0400) Subject: pan/bi: Pack ADD IADD/ISUB for 8/16/32 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10c18c6f69ed6ea8d82b300dc93c55e3180c1c74;p=mesa.git pan/bi: Pack ADD IADD/ISUB for 8/16/32 Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 90d63be6ff7..741ed133fc8 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -1625,6 +1625,32 @@ bi_pack_add_cmp(bi_instruction *ins, struct bi_registers *regs) } } +static unsigned +bi_pack_add_imath(bi_instruction *ins, struct bi_registers *regs) +{ + /* TODO: 32+16 add */ + assert(ins->src_types[0] == ins->src_types[1]); + unsigned sz = nir_alu_type_get_type_size(ins->src_types[0]); + enum bi_imath_op p = ins->op.imath; + + unsigned op = 0; + + if (sz == 8) { + op = (p == BI_IMATH_ADD) ? BIFROST_ADD_IADD_8 : + BIFROST_ADD_ISUB_8; + } else if (sz == 16) { + op = (p == BI_IMATH_ADD) ? BIFROST_ADD_IADD_16 : + BIFROST_ADD_ISUB_16; + } else if (sz == 32) { + op = (p == BI_IMATH_ADD) ? BIFROST_ADD_IADD_32 : + BIFROST_ADD_ISUB_32; + } else { + unreachable("64-bit todo"); + } + + return bi_pack_add_2src(ins, regs, op); +} + static unsigned bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) { @@ -1649,7 +1675,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) case BI_DISCARD: return bi_pack_add_discard(bundle.add, regs); case BI_FREXP: + unreachable("Packing todo"); case BI_IMATH: + return bi_pack_add_imath(bundle.add, regs); case BI_LOAD: unreachable("Packing todo"); case BI_LOAD_ATTR: diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 15e44251c1a..31ef76a4d5a 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -195,6 +195,13 @@ struct bifrost_add_discard { #define BIFROST_ADD_OP_LD_UBO_4 (0x0c220 >> 3) #define BIFROST_ADD_SEL_16(swiz) ((0xea60 >> 3) | (swiz)) +#define BIFROST_ADD_IADD_8 (0x17880 >> 3) +#define BIFROST_ADD_IADD_16 (0x17900 >> 3) +#define BIFROST_ADD_IADD_32 (0x178c0 >> 3) +#define BIFROST_ADD_ISUB_8 (0x17a80 >> 3) +#define BIFROST_ADD_ISUB_16 (0x17b00 >> 3) +#define BIFROST_ADD_ISUB_32 (0x17ac0 >> 3) + struct bifrost_add_2src { unsigned src0 : 3; unsigned src1 : 3;