From 12cf9f43f02ac00b9604e12f1fb26e363941d90b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 31 Mar 2020 22:16:55 -0400 Subject: [PATCH] pan/bi: Handle fmov class ops We need to lower them to something reasonable (ideally, the modifier would be attached but we need to do something for the case it's not). We specifically have to lower pre-sched as well, but we can do the lower literally at schedule time for now (if this proves annoying, we can move it earlier, but I want to leave room for modifier-aware copyprop should that prove interesting). Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 2 -- src/panfrost/bifrost/bi_print.c | 1 + src/panfrost/bifrost/bi_schedule.c | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 293a109..9ec3104 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -780,7 +780,6 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) return BIFROST_FMA_NOP; case BI_MOV: return bi_pack_fma_1src(bundle.fma, regs, BIFROST_FMA_OP_MOV); - case BI_FMOV: case BI_SHIFT: case BI_SWIZZLE: case BI_ROUND: @@ -989,7 +988,6 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) return bi_pack_add_ld_var_addr(clause, bundle.add, regs); case BI_MINMAX: case BI_MOV: - case BI_FMOV: case BI_SHIFT: case BI_STORE: return BIFROST_ADD_NOP; diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index 73c3a7f..7a4b73a 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -137,6 +137,7 @@ bi_class_name(enum bi_class cl) case BI_CSEL: return "csel"; case BI_DISCARD: return "discard"; case BI_FMA: return "fma"; + case BI_FMOV: return "fmov"; case BI_FREXP: return "frexp"; case BI_ISUB: return "isub"; case BI_LOAD: return "load"; diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index b3f7ca6..2885aee 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -89,6 +89,22 @@ bi_ambiguous_abs(bi_instruction *ins) return classy && typey && absy; } +/* Lowers FMOV to ADD #0, since FMOV doesn't exist on the h/w and this is the + * latest time it's sane to lower (it's useful to distinguish before, but we'll + * need this handle during scheduling to ensure the ports get modeled + * correctly with respect to the new zero source) */ + +static void +bi_lower_fmov(bi_instruction *ins) +{ + if (ins->type != BI_FMOV) + return; + + ins->type = BI_ADD; + ins->src[1] = BIR_INDEX_ZERO; + ins->src_types[1] = ins->src_types[0]; +} + /* Eventually, we'll need a proper scheduling, grouping instructions * into clauses and ordering/assigning grouped instructions to the * appropriate FMA/ADD slots. Right now we do the dumbest possible @@ -108,6 +124,9 @@ bi_schedule(bi_context *ctx) list_inithead(&bblock->clauses); bi_foreach_instr_in_block(bblock, ins) { + /* Convenient time to lower */ + bi_lower_fmov(ins); + unsigned props = bi_class_props[ins->type]; bi_clause *u = rzalloc(ctx, bi_clause); -- 2.7.4