diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-19 16:58:48 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-22 03:32:34 +0000 |
commit | 6b7077efda9a8b518c7f55f497504a031c623e54 (patch) | |
tree | eb84077a5f4852917d87015cb7b1199c8b4a59a5 | |
parent | f8bbf44ca4d32889232ced844a1b939b8a86f727 (diff) |
pan/bi: Implement FMA/MOV without modifiers
We split off MOV from FMOV since the canonical move on Bifrost doesn't
accept modifiers. (We can still do fmov, but with something like add-0.)
This will also make copyprop a little nicer, I think. Anyway, the
non-modifier version we can implement as-is for FMA.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4276>
-rw-r--r-- | src/panfrost/bifrost/bi_pack.c | 15 | ||||
-rw-r--r-- | src/panfrost/bifrost/bi_tables.c | 3 | ||||
-rw-r--r-- | src/panfrost/bifrost/bifrost.h | 3 | ||||
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 9 | ||||
-rw-r--r-- | src/panfrost/bifrost/compiler.h | 1 |
5 files changed, 26 insertions, 5 deletions
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 2494cb55cdd..16a1266b5a8 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -363,6 +363,17 @@ bi_pack_fma_add(bi_instruction *ins, struct bi_registers *regs) } static unsigned +bi_pack_fma_1src(bi_instruction *ins, struct bi_registers *regs, unsigned op) +{ + struct bifrost_fma_inst pack = { + .src0 = bi_get_src(ins, regs, 0, true), + .op = op + }; + + RETURN_PACKED(pack); +} + +static unsigned bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) { if (!bundle.fma) @@ -381,7 +392,10 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) case BI_FREXP: case BI_ISUB: case BI_MINMAX: + 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: @@ -499,6 +513,7 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) case BI_LOAD_VAR_ADDRESS: case BI_MINMAX: case BI_MOV: + case BI_FMOV: case BI_SHIFT: case BI_STORE: case BI_STORE_VAR: diff --git a/src/panfrost/bifrost/bi_tables.c b/src/panfrost/bifrost/bi_tables.c index 72d2ccf2155..729c4800393 100644 --- a/src/panfrost/bifrost/bi_tables.c +++ b/src/panfrost/bifrost/bi_tables.c @@ -45,7 +45,8 @@ unsigned bi_class_props[BI_NUM_CLASSES] = { [BI_LOAD_VAR] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, [BI_LOAD_VAR_ADDRESS] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD, [BI_MINMAX] = BI_GENERIC | BI_SCHED_ALL, - [BI_MOV] = BI_MODS | BI_SCHED_ALL, + [BI_MOV] = BI_SCHED_ALL, + [BI_FMOV] = BI_MODS | BI_SCHED_ALL, [BI_SHIFT] = BI_SCHED_ALL, [BI_STORE] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_SRC, [BI_STORE_VAR] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_SRC, diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index dac4ad190dd..5ec8c495465 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -95,6 +95,9 @@ enum bifrost_packed_src { BIFROST_SRC_PASS_ADD = 7, }; +#define BIFROST_FMA_EXT (0xe0000) +#define BIFROST_FMA_OP_MOV BIFROST_FMA_EXT | (0x32d) + struct bifrost_fma_inst { unsigned src0 : 3; unsigned op : 20; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 0755d1313fc..7d050678115 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -375,6 +375,7 @@ bi_class_for_nir_alu(nir_op op) case nir_op_fsat: case nir_op_fneg: case nir_op_fabs: + return BI_FMOV; case nir_op_mov: return BI_MOV; @@ -480,16 +481,16 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) alu.src[2] = BIR_INDEX_ZERO; /* FMA */ break; case nir_op_fsat: - alu.outmod = BIFROST_SAT; /* MOV */ + alu.outmod = BIFROST_SAT; /* FMOV */ break; case nir_op_fneg: - alu.src_neg[0] = true; /* MOV */ + alu.src_neg[0] = true; /* FMOV */ break; case nir_op_fabs: - alu.src_abs[0] = true; /* MOV */ + alu.src_abs[0] = true; /* FMOV */ break; case nir_op_fsub: - alu.src_neg[1] = true; /* ADD */ + alu.src_neg[1] = true; /* FADD */ break; case nir_op_fmax: case nir_op_imax: diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 483a282b57d..d7d80d5c8a9 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -57,6 +57,7 @@ enum bi_class { BI_CSEL, BI_DISCARD, BI_FMA, + BI_FMOV, BI_FREXP, BI_ISUB, BI_LOAD, |