bifrost: Add support for nir_op_iabs
Signed-off-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6098>
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index b7ae113..5fb8213 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -1434,6 +1434,9 @@
} else if (ins->op.special == BI_SPECIAL_EXP2_LOW) {
assert(!fp16);
op = BIFROST_ADD_OP_FEXP2_FAST;
+ } else if (ins->op.special == BI_SPECIAL_IABS) {
+ assert(ins->src_types[0] == nir_type_int32);
+ op = BIFROST_ADD_OP_IABS_32;
} else {
unreachable("Unknown special op");
}
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index a41076b..085b329 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -164,6 +164,7 @@
#define BIFROST_ADD_OP_FRSQ_FAST_F16_Y (0x0ce70)
#define BIFROST_ADD_OP_LOG2_HELP (0x0cc68)
#define BIFROST_ADD_OP_FEXP2_FAST (0x0cd58)
+#define BIFROST_ADD_OP_IABS_32 (0x07bd4)
struct bifrost_add_inst {
unsigned src0 : 3;
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 2419a4f..ed8741d 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -600,6 +600,7 @@
case nir_op_frcp:
case nir_op_frsq:
+ case nir_op_iabs:
return BI_SPECIAL;
default:
@@ -808,6 +809,9 @@
case nir_op_isub:
alu.op.imath = BI_IMATH_SUB;
break;
+ case nir_op_iabs:
+ alu.op.special = BI_SPECIAL_IABS;
+ break;
case nir_op_inot:
/* no dedicated bitwise not, but we can invert sources. convert to ~a | 0 */
alu.op.bitwise = BI_BITWISE_OR;
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 4c77ac5..32361cc 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -204,6 +204,7 @@
* exp2() in GL. In the first argument, it takes f2i_rte(x * 2^24). In
* the second, it takes x itself. */
BI_SPECIAL_EXP2_LOW,
+ BI_SPECIAL_IABS,
};
enum bi_tex_op {
diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c
index 92fbf20..93afbee 100644
--- a/src/panfrost/bifrost/disassemble.c
+++ b/src/panfrost/bifrost/disassemble.c
@@ -1013,6 +1013,7 @@
{ 0x07ba5, "FSQRT_FREXPE", ADD_ONE_SRC },
{ 0x07bad, "FRSQ_FREXPE", ADD_ONE_SRC },
{ 0x07bc5, "FLOG_FREXPE", ADD_ONE_SRC },
+ { 0x07bd4, "IABS.i32", ADD_ONE_SRC },
{ 0x07d42, "CEIL.v2f16", ADD_ONE_SRC },
{ 0x07d45, "CEIL.f32", ADD_ONE_SRC },
{ 0x07d82, "FLOOR.v2f16", ADD_ONE_SRC },