Mesa (master): bifrost: Add support for nir_op_imul
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 28 02:16:47 UTC 2020
Module: Mesa
Branch: master
Commit: a0a70879c5bea8b71e71cf0069c904a05ba0f7c2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0a70879c5bea8b71e71cf0069c904a05ba0f7c2
Author: Chris Forbes <chrisforbes at google.com>
Date: Sun Jul 26 15:54:14 2020 -0700
bifrost: Add support for nir_op_imul
Unfortunately this doesn't map nicely to the existing instruction
classes, so we'll make a new one for now.
Signed-off-by: Chris Forbes <chrisforbes at google.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6091>
---
src/panfrost/bifrost/bi_pack.c | 10 ++++++++++
src/panfrost/bifrost/bi_print.c | 1 +
src/panfrost/bifrost/bi_tables.c | 1 +
src/panfrost/bifrost/bifrost.h | 1 +
src/panfrost/bifrost/bifrost_compile.c | 6 ++++++
src/panfrost/bifrost/compiler.h | 6 ++++++
6 files changed, 25 insertions(+)
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index 99a155fd56a..b7ae1132793 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -1141,6 +1141,14 @@ bi_pack_fma_imath(bi_instruction *ins, bi_registers *regs)
return bi_pack_fma_2src(ins, regs, op);
}
+static unsigned
+bi_pack_fma_imul(bi_instruction *ins, bi_registers *regs)
+{
+ assert(ins->op.imul == BI_IMUL_IMUL);
+ unsigned op = BIFROST_FMA_IMUL_32;
+ return bi_pack_fma_2src(ins, regs, op);
+}
+
static unsigned
bi_pack_fma(bi_clause *clause, bi_bundle bundle, bi_registers *regs)
{
@@ -1174,6 +1182,8 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, bi_registers *regs)
return bi_pack_fma_round(bundle.fma, regs);
case BI_REDUCE_FMA:
return bi_pack_fma_reduce(bundle.fma, regs);
+ case BI_IMUL:
+ return bi_pack_fma_imul(bundle.fma, regs);
default:
unreachable("Cannot encode class as FMA");
}
diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c
index e8fb326271b..6dcfdbd3e78 100644
--- a/src/panfrost/bifrost/bi_print.c
+++ b/src/panfrost/bifrost/bi_print.c
@@ -155,6 +155,7 @@ bi_class_name(enum bi_class cl)
case BI_TABLE: return "table";
case BI_TEX: return "tex";
case BI_ROUND: return "round";
+ case BI_IMUL: return "imul";
default: return "unknown_class";
}
}
diff --git a/src/panfrost/bifrost/bi_tables.c b/src/panfrost/bifrost/bi_tables.c
index 81365937f04..942de5eae5a 100644
--- a/src/panfrost/bifrost/bi_tables.c
+++ b/src/panfrost/bifrost/bi_tables.c
@@ -56,4 +56,5 @@ unsigned bi_class_props[BI_NUM_CLASSES] = {
[BI_SELECT] = BI_SCHED_ALL | BI_SWIZZLABLE,
[BI_TEX] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST,
[BI_ROUND] = BI_ROUNDMODE | BI_SCHED_ALL,
+ [BI_IMUL] = BI_SCHED_FMA,
};
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index 0864b3a497e..a41076bcea3 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -117,6 +117,7 @@ struct bifrost_fma_inst {
#define BIFROST_FMA_IADD_32 (0x4ff98 >> 3)
#define BIFROST_FMA_ISUB_32 (0x4ffd8 >> 3)
+#define BIFROST_FMA_IMUL_32 ((BIFROST_FMA_EXT | 0x7818) >> 3)
struct bifrost_fma_2src {
unsigned src0 : 3;
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 566c0e59881..2419a4fbcf5 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -512,6 +512,9 @@ bi_class_for_nir_alu(nir_op op)
case nir_op_isub:
return BI_IMATH;
+ case nir_op_imul:
+ return BI_IMUL;
+
case nir_op_iand:
case nir_op_ior:
case nir_op_ixor:
@@ -821,6 +824,9 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr)
alu.src_types[2] = alu.src_types[1];
alu.src[1] = BIR_INDEX_ZERO;
break;
+ case nir_op_imul:
+ alu.op.imul = BI_IMUL_IMUL;
+ break;
case nir_op_fmax:
case nir_op_imax:
case nir_op_umax:
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 2038a3299d1..4c77ac5edf9 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -76,6 +76,7 @@ enum bi_class {
BI_TABLE,
BI_TEX,
BI_ROUND,
+ BI_IMUL,
BI_NUM_CLASSES
};
@@ -171,6 +172,10 @@ enum bi_imath_op {
BI_IMATH_SUB,
};
+enum bi_imul_op {
+ BI_IMUL_IMUL,
+};
+
enum bi_table_op {
/* fp32 log2() with low precision, suitable for GL or half_log2() in
* CL. In the first argument, takes x. Letting u be such that x =
@@ -281,6 +286,7 @@ typedef struct {
enum bi_frexp_op frexp;
enum bi_tex_op texture;
enum bi_imath_op imath;
+ enum bi_imul_op imul;
/* For FMA/ADD, should we add a biased exponent? */
bool mscale;
More information about the mesa-commit
mailing list