Mesa (main): nir,panfrost: Suffix fsat_signed and fclamp_pos with _mali
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 21 14:28:04 UTC 2021
Module: Mesa
Branch: main
Commit: 0afbfee8da30d465f141d214ad6a307ed54b3b03
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0afbfee8da30d465f141d214ad6a307ed54b3b03
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Fri Jun 18 09:21:07 2021 -0500
nir,panfrost: Suffix fsat_signed and fclamp_pos with _mali
Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11463>
---
src/compiler/nir/nir_opcodes.py | 6 ++++--
src/panfrost/bifrost/bifrost_compile.c | 4 ++--
src/panfrost/bifrost/bifrost_nir_algebraic.py | 6 +++---
src/panfrost/midgard/midgard_compile.c | 14 +++++++-------
src/panfrost/midgard/midgard_nir_algebraic.py | 6 +++---
5 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index a692c4ecc9c..efd7ecce212 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -217,8 +217,6 @@ unop("isign", tint, "(src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1)")
unop("iabs", tint, "(src0 < 0) ? -src0 : src0")
unop("fabs", tfloat, "fabs(src0)")
unop("fsat", tfloat, ("fmin(fmax(src0, 0.0), 1.0)"))
-unop("fsat_signed", tfloat, ("fmin(fmax(src0, -1.0), 1.0)"))
-unop("fclamp_pos", tfloat, ("fmax(src0, 0.0)"))
unop("frcp", tfloat, "bit_size == 64 ? 1.0 / src0 : 1.0f / src0")
unop("frsq", tfloat, "bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0)")
unop("fsqrt", tfloat, "bit_size == 64 ? sqrt(src0) : sqrtf(src0)")
@@ -1288,6 +1286,10 @@ binop("umul24_relaxed", tuint32, _2src_commutative + associative, "src0 * src1")
unop_convert("fisnormal", tbool1, tfloat, "isnormal(src0)")
unop_convert("fisfinite", tbool1, tfloat, "isfinite(src0)")
+# Mali-specific opcodes
+unop("fsat_signed_mali", tfloat, ("fmin(fmax(src0, -1.0), 1.0)"))
+unop("fclamp_pos_mali", tfloat, ("fmax(src0, 0.0)"))
+
# DXIL specific double [un]pack
# DXIL doesn't support generic [un]pack instructions, so we want those
# lowered to bit ops. HLSL doesn't support 64bit bitcasts to/from
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 548cb32c383..4a53f9da7c0 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -1785,13 +1785,13 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr)
break;
}
- case nir_op_fsat_signed: {
+ case nir_op_fsat_signed_mali: {
bi_instr *I = bi_fadd_to(b, sz, dst, s0, bi_negzero(), BI_ROUND_NONE);
I->clamp = BI_CLAMP_CLAMP_M1_1;
break;
}
- case nir_op_fclamp_pos: {
+ case nir_op_fclamp_pos_mali: {
bi_instr *I = bi_fadd_to(b, sz, dst, s0, bi_negzero(), BI_ROUND_NONE);
I->clamp = BI_CLAMP_CLAMP_0_INF;
break;
diff --git a/src/panfrost/bifrost/bifrost_nir_algebraic.py b/src/panfrost/bifrost/bifrost_nir_algebraic.py
index fdbc8ec1ec8..bae71807640 100644
--- a/src/panfrost/bifrost/bifrost_nir_algebraic.py
+++ b/src/panfrost/bifrost/bifrost_nir_algebraic.py
@@ -33,9 +33,9 @@ algebraic_late = [
(('fmul', a, 2.0), ('fadd', a, a)),
# Fuse Mali-specific clamps
- (('fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed', a)),
- (('fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed', a)),
- (('fmax', a, 0.0), ('fclamp_pos', a)),
+ (('fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed_mali', a)),
+ (('fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed_mali', a)),
+ (('fmax', a, 0.0), ('fclamp_pos_mali', a)),
]
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 23d624e1ac2..2d4d2697947 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -585,9 +585,9 @@ mir_accept_dest_mod(compiler_context *ctx, nir_dest **dest, nir_op op)
static unsigned
mir_determine_float_outmod(compiler_context *ctx, nir_dest **dest, unsigned prior_outmod)
{
- bool clamp_0_inf = mir_accept_dest_mod(ctx, dest, nir_op_fclamp_pos);
+ bool clamp_0_inf = mir_accept_dest_mod(ctx, dest, nir_op_fclamp_pos_mali);
bool clamp_0_1 = mir_accept_dest_mod(ctx, dest, nir_op_fsat);
- bool clamp_m1_1 = mir_accept_dest_mod(ctx, dest, nir_op_fsat_signed);
+ bool clamp_m1_1 = mir_accept_dest_mod(ctx, dest, nir_op_fsat_signed_mali);
bool prior = (prior_outmod != midgard_outmod_none);
int count = (int) prior + (int) clamp_0_inf + (int) clamp_0_1 + (int) clamp_m1_1;
@@ -659,7 +659,7 @@ mir_is_bcsel_float(nir_alu_instr *instr)
};
nir_op floatdestmods[] = {
- nir_op_fsat, nir_op_fsat_signed, nir_op_fclamp_pos,
+ nir_op_fsat, nir_op_fsat_signed_mali, nir_op_fclamp_pos_mali,
nir_op_f2f16, nir_op_f2f32
};
@@ -847,8 +847,8 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
ALU_CASE(fabs, fmov);
ALU_CASE(fneg, fmov);
ALU_CASE(fsat, fmov);
- ALU_CASE(fsat_signed, fmov);
- ALU_CASE(fclamp_pos, fmov);
+ ALU_CASE(fsat_signed_mali, fmov);
+ ALU_CASE(fclamp_pos_mali, fmov);
/* For size conversion, we use a move. Ideally though we would squash
* these ops together; maybe that has to happen after in NIR as part of
@@ -939,9 +939,9 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
outmod = midgard_outmod_keeplo;
} else if (instr->op == nir_op_fsat) {
outmod = midgard_outmod_clamp_0_1;
- } else if (instr->op == nir_op_fsat_signed) {
+ } else if (instr->op == nir_op_fsat_signed_mali) {
outmod = midgard_outmod_clamp_m1_1;
- } else if (instr->op == nir_op_fclamp_pos) {
+ } else if (instr->op == nir_op_fclamp_pos_mali) {
outmod = midgard_outmod_clamp_0_inf;
}
diff --git a/src/panfrost/midgard/midgard_nir_algebraic.py b/src/panfrost/midgard/midgard_nir_algebraic.py
index c66fd97dd7c..9c8668f9683 100644
--- a/src/panfrost/midgard/midgard_nir_algebraic.py
+++ b/src/panfrost/midgard/midgard_nir_algebraic.py
@@ -53,11 +53,11 @@ algebraic_late = [
(('b32csel', a, 0, 'b at 32'), ('iand', ('inot', a), b)),
# Fuse sat_signed. This should probably be shared with Bifrost
- (('~fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed', a)),
- (('~fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed', a)),
+ (('~fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed_mali', a)),
+ (('~fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed_mali', a)),
# Fuse clamp_positive. This should probably be shared with Utgard/bifrost
- (('fmax', a, 0.0), ('fclamp_pos', a)),
+ (('fmax', a, 0.0), ('fclamp_pos_mali', a)),
(('ishl', 'a at 16', b), ('u2u16', ('ishl', ('u2u32', a), b))),
(('ishr', 'a at 16', b), ('i2i16', ('ishr', ('i2i32', a), b))),
More information about the mesa-commit
mailing list