From a463b2c2ed452f1ee1497fbc19921c910de93237 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 4 May 2020 14:28:47 -0400 Subject: [PATCH] pan/bi: Pack FMA IADD/ISUB 32 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 17 +++++++++++++++-- src/panfrost/bifrost/bifrost.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index d877602bdb2..90d63be6ff7 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -1149,7 +1149,20 @@ bi_pack_fma_round(bi_instruction *ins, struct bi_registers *regs) return bi_pack_fma_1src(ins, regs, op); } - + +static unsigned +bi_pack_fma_imath(bi_instruction *ins, struct bi_registers *regs) +{ + /* Scheduler: only ADD can have 8/16-bit imath */ + assert(ins->dest_type == nir_type_int32 || ins->dest_type == nir_type_uint32); + + unsigned op = ins->op.imath == BI_IMATH_ADD + ? BIFROST_FMA_IADD_32 + : BIFROST_FMA_ISUB_32; + + return bi_pack_fma_2src(ins, regs, op); +} + static unsigned bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) { @@ -1172,7 +1185,7 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) case BI_FREXP: return bi_pack_fma_frexp(bundle.fma, regs); case BI_IMATH: - unreachable("Packing todo"); + return bi_pack_fma_imath(bundle.fma, regs); case BI_MINMAX: return bi_pack_fma_addmin(bundle.fma, regs); case BI_MOV: diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index cc26e281ea4..15e44251c1a 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -115,6 +115,9 @@ struct bifrost_fma_inst { unsigned op : 20; } __attribute__((packed)); +#define BIFROST_FMA_IADD_32 (0x4ff98 >> 3) +#define BIFROST_FMA_ISUB_32 (0x4ffd8 >> 3) + struct bifrost_fma_2src { unsigned src0 : 3; unsigned src1 : 3; -- 2.30.2