summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-03-03 15:39:04 -0500
committerMarge Bot <[email protected]>2020-03-05 14:35:38 +0000
commit5f7a3ba872c90afc251035f24f7fc7faf6498fe3 (patch)
treebd712957d12ee38b50c86f56e4f329334af74d9f /src
parent8ec671801a8decdd5c733f2fec53726d34666a0b (diff)
pan/bi: Move some print routines out of the disasm
These are generally useful for debug of the compiler IR even prior to code emit; let's share these. Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4061>
Diffstat (limited to 'src')
-rw-r--r--src/panfrost/Makefile.sources2
-rw-r--r--src/panfrost/bifrost/bi_print.c93
-rw-r--r--src/panfrost/bifrost/bi_print.h38
-rw-r--r--src/panfrost/bifrost/bifrost.h28
-rw-r--r--src/panfrost/bifrost/disassemble.c125
-rw-r--r--src/panfrost/bifrost/meson.build1
6 files changed, 167 insertions, 120 deletions
diff --git a/src/panfrost/Makefile.sources b/src/panfrost/Makefile.sources
index 58e72e38841..5893fac91aa 100644
--- a/src/panfrost/Makefile.sources
+++ b/src/panfrost/Makefile.sources
@@ -3,6 +3,8 @@ bifrost_FILES := \
bifrost/bifrost_compile.c \
bifrost/bifrost_compile.h \
bifrost/bifrost_tables.c \
+ bifrost/bi_print.c \
+ bifrost/bi_print.h \
bifrost/bi_quirks.c \
bifrost/compiler.h \
bifrost/cmdline.c \
diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c
new file mode 100644
index 00000000000..020ef70c36b
--- /dev/null
+++ b/src/panfrost/bifrost/bi_print.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2019 Connor Abbott <[email protected]>
+ * Copyright (C) 2019 Lyude Paul <[email protected]>
+ * Copyright (C) 2019 Ryan Houdek <[email protected]>
+ * Copyright (C) 2019-2020 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "bi_print.h"
+
+const char *
+bi_output_mod_name(enum bifrost_outmod mod)
+{
+ switch (mod) {
+ case BIFROST_NONE: return "";
+ case BIFROST_POS: return ".pos";
+ case BIFROST_SAT_SIGNED: return ".sat_signed";
+ case BIFROST_SAT: return ".sat";
+ default: return "invalid";
+ }
+}
+
+const char *
+bi_minmax_mode_name(enum bifrost_minmax_mode mod)
+{
+ switch (mod) {
+ case BIFROST_MINMAX_NONE: return "";
+ case BIFROST_NAN_WINS: return ".nan_wins";
+ case BIFROST_SRC1_WINS: return ".src1_wins";
+ case BIFROST_SRC0_WINS: return ".src0_wins";
+ default: return "invalid";
+ }
+}
+
+const char *
+bi_round_mode_name(enum bifrost_roundmode mod)
+{
+ switch (mod) {
+ case BIFROST_RTE: return "";
+ case BIFROST_RTP: return ".rtp";
+ case BIFROST_RTN: return ".rtn";
+ case BIFROST_RTZ: return ".rtz";
+ default: return "invalid";
+ }
+}
+
+const char *
+bi_csel_cond_name(enum bifrost_csel_cond cond)
+{
+ switch (cond) {
+ case BIFROST_FEQ_F: return "feq.f";
+ case BIFROST_FGT_F: return "fgt.f";
+ case BIFROST_FGE_F: return "fge.f";
+ case BIFROST_IEQ_F: return "ieq.f";
+ case BIFROST_IGT_I: return "igt.i";
+ case BIFROST_IGE_I: return "uge.i";
+ case BIFROST_UGT_I: return "ugt.i";
+ case BIFROST_UGE_I: return "uge.i";
+ default: return "invalid";
+ }
+}
+
+const char *
+bi_ldst_type_name(enum bifrost_ldst_type type)
+{
+ switch (type) {
+ case BIFROST_LDST_F16: return "f16";
+ case BIFROST_LDST_F32: return "f32";
+ case BIFROST_LDST_I32: return "i32";
+ case BIFROST_LDST_U32: return "u32";
+ default: return "invalid";
+ }
+}
+
+
diff --git a/src/panfrost/bifrost/bi_print.h b/src/panfrost/bifrost/bi_print.h
new file mode 100644
index 00000000000..8b90fa1e7da
--- /dev/null
+++ b/src/panfrost/bifrost/bi_print.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2019 Connor Abbott <[email protected]>
+ * Copyright (C) 2019 Lyude Paul <[email protected]>
+ * Copyright (C) 2019 Ryan Houdek <[email protected]>
+ * Copyright (C) 2020 Collabora Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __BI_PRINT_H
+#define __BI_PRINT_H
+
+#include "bifrost.h"
+
+const char * bi_output_mod_name(enum bifrost_outmod mod);
+const char * bi_minmax_mode_name(enum bifrost_minmax_mode mod);
+const char * bi_round_mode_name(enum bifrost_roundmode mod);
+const char * bi_csel_cond_name(enum bifrost_csel_cond cond);
+const char * bi_ldst_type_name(enum bifrost_ldst_type type);
+
+#endif
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index 689eb146cff..d8a1cff089d 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -90,12 +90,32 @@ enum bifrost_outmod {
};
enum bifrost_roundmode {
- BIFROST_RTE = 0x0,
- BIFROST_RTP = 0x1,
- BIFROST_RTN = 0x2,
- BIFROST_RTZ = 0x3
+ BIFROST_RTE = 0x0, /* round to even */
+ BIFROST_RTP = 0x1, /* round to positive */
+ BIFROST_RTN = 0x2, /* round to negative */
+ BIFROST_RTZ = 0x3 /* round to zero */
};
+/* NONE: Same as fmax() and fmin() -- return the other
+ * number if any number is NaN. Also always return +0 if
+ * one argument is +0 and the other is -0.
+ *
+ * NAN_WINS: Instead of never returning a NaN, always return
+ * one. The "greater"/"lesser" NaN is always returned, first
+ * by checking the sign and then the mantissa bits.
+ *
+ * SRC1_WINS: For max, implement src0 > src1 ? src0 : src1.
+ * For min, implement src0 < src1 ? src0 : src1. This
+ * includes handling NaN's and signedness of 0 differently
+ * from above, since +0 and -0 compare equal and comparisons
+ * always return false for NaN's. As a result, this mode is
+ * *not* commutative.
+ *
+ * SRC0_WINS: For max, implement src0 < src1 ? src1 : src0
+ * For min, implement src0 > src1 ? src1 : src0
+ */
+
+
enum bifrost_minmax_mode {
BIFROST_MINMAX_NONE = 0x0,
BIFROST_NAN_WINS = 0x1,
diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c
index 19964d36a5d..6c1bebda1ec 100644
--- a/src/panfrost/bifrost/disassemble.c
+++ b/src/panfrost/bifrost/disassemble.c
@@ -32,6 +32,7 @@
#include "bifrost.h"
#include "disassemble.h"
+#include "bi_print.h"
#include "util/macros.h"
// return bits (high, lo]
@@ -417,102 +418,6 @@ static void dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, uint64_t
}
}
-static void dump_output_mod(FILE *fp, unsigned mod)
-{
- switch (mod) {
- case BIFROST_NONE:
- break;
- case BIFROST_POS:
- fprintf(fp, ".clamp_0_inf");
- break; // max(out, 0)
- case BIFROST_SAT_SIGNED:
- fprintf(fp, ".clamp_m1_1");
- break; // clamp(out, -1, 1)
- case BIFROST_SAT:
- fprintf(fp, ".clamp_0_1");
- break; // clamp(out, 0, 1)
- default:
- break;
- }
-}
-
-static void dump_minmax_mode(FILE *fp, unsigned mod)
-{
- switch (mod) {
- case BIFROST_MINMAX_NONE:
- /* Same as fmax() and fmin() -- return the other number if any
- * number is NaN. Also always return +0 if one argument is +0 and
- * the other is -0.
- */
- break;
- case BIFROST_NAN_WINS:
- /* Instead of never returning a NaN, always return one. The
- * "greater"/"lesser" NaN is always returned, first by checking the
- * sign and then the mantissa bits.
- */
- fprintf(fp, ".nan_wins");
- break;
- case BIFROST_SRC1_WINS:
- /* For max, implement src0 > src1 ? src0 : src1
- * For min, implement src0 < src1 ? src0 : src1
- *
- * This includes handling NaN's and signedness of 0 differently
- * from above, since +0 and -0 compare equal and comparisons always
- * return false for NaN's. As a result, this mode is *not*
- * commutative.
- */
- fprintf(fp, ".src1_wins");
- break;
- case BIFROST_SRC0_WINS:
- /* For max, implement src0 < src1 ? src1 : src0
- * For min, implement src0 > src1 ? src1 : src0
- */
- fprintf(fp, ".src0_wins");
- break;
- default:
- break;
- }
-}
-
-static void dump_round_mode(FILE *fp, unsigned mod)
-{
- switch (mod) {
- case BIFROST_RTE:
- /* roundTiesToEven, the IEEE default. */
- break;
- case BIFROST_RTP:
- /* roundTowardPositive in the IEEE spec. */
- fprintf(fp, ".round_pos");
- break;
- case BIFROST_RTN:
- /* roundTowardNegative in the IEEE spec. */
- fprintf(fp, ".round_neg");
- break;
- case BIFROST_RTZ:
- /* roundTowardZero in the IEEE spec. */
- fprintf(fp, ".round_zero");
- break;
- default:
- break;
- }
-}
-
-static const char *
-csel_cond_name(enum bifrost_csel_cond cond)
-{
- switch (cond) {
- case BIFROST_FEQ_F: return "feq.f";
- case BIFROST_FGT_F: return "fgt.f";
- case BIFROST_FGE_F: return "fge.f";
- case BIFROST_IEQ_F: return "ieq.f";
- case BIFROST_IGT_I: return "igt.i";
- case BIFROST_IGE_I: return "uge.i";
- case BIFROST_UGT_I: return "ugt.i";
- case BIFROST_UGE_I: return "uge.i";
- default: return "invalid";
- }
-}
-
static const struct fma_op_info FMAOpInfos[] = {
{ false, 0x00000, "FMA.f32", FMA_FMA },
{ false, 0x40000, "MAX.f32", FMA_FMINMAX },
@@ -769,18 +674,6 @@ static void dump_fma_expand_src1(FILE *fp, unsigned ctrl)
}
}
-static const char *
-bi_ldst_type_name(enum bifrost_ldst_type type)
-{
- switch (type) {
- case BIFROST_LDST_F16: return "f16";
- case BIFROST_LDST_F32: return "f32";
- case BIFROST_LDST_I32: return "i32";
- case BIFROST_LDST_U32: return "u32";
- default: return "invalid";
- }
-}
-
static void dump_fma(FILE *fp, uint64_t word, struct bifrost_regs regs, struct bifrost_regs next_regs, uint64_t *consts, bool verbose)
{
if (verbose) {
@@ -797,17 +690,17 @@ static void dump_fma(FILE *fp, uint64_t word, struct bifrost_regs regs, struct b
info.src_type == FMA_FADD16 ||
info.src_type == FMA_FMINMAX16 ||
info.src_type == FMA_FMA16) {
- dump_output_mod(fp, bits(FMA.op, 12, 14));
+ fprintf(fp, "%s", bi_output_mod_name(bits(FMA.op, 12, 14)));
switch (info.src_type) {
case FMA_FADD:
case FMA_FMA:
case FMA_FADD16:
case FMA_FMA16:
- dump_round_mode(fp, bits(FMA.op, 10, 12));
+ fprintf(fp, "%s", bi_round_mode_name(bits(FMA.op, 10, 12)));
break;
case FMA_FMINMAX:
case FMA_FMINMAX16:
- dump_minmax_mode(fp, bits(FMA.op, 10, 12));
+ fprintf(fp, "%s", bi_minmax_mode_name(bits(FMA.op, 10, 12)));
break;
default:
assert(0);
@@ -842,7 +735,7 @@ static void dump_fma(FILE *fp, uint64_t word, struct bifrost_regs regs, struct b
fprintf(fp, ".unk%d_mode", (int) (FMA.op >> 9) & 0x3);
}
} else {
- dump_output_mod(fp, bits(FMA.op, 9, 11));
+ fprintf(fp, "%s", bi_output_mod_name(bits(FMA.op, 9, 11)));
}
} else if (info.src_type == FMA_SHIFT) {
struct bifrost_shift_fma shift;
@@ -1021,7 +914,7 @@ static void dump_fma(FILE *fp, uint64_t word, struct bifrost_regs regs, struct b
case FMA_CSEL4: {
struct bifrost_csel4 csel;
memcpy(&csel, &FMA, sizeof(csel));
- fprintf(fp, ".%s ", csel_cond_name(csel.cond));
+ fprintf(fp, ".%s ", bi_csel_cond_name(csel.cond));
dump_src(fp, csel.src0, regs, consts, true);
fprintf(fp, ", ");
@@ -1281,11 +1174,11 @@ static void dump_add(FILE *fp, uint64_t word, struct bifrost_regs regs,
// float16 seems like it doesn't support output modifiers
if (info.src_type == ADD_FADD || info.src_type == ADD_FMINMAX) {
// output modifiers
- dump_output_mod(fp, bits(ADD.op, 8, 10));
+ fprintf(fp, "%s", bi_output_mod_name(bits(ADD.op, 8, 10)));
if (info.src_type == ADD_FADD)
- dump_round_mode(fp, bits(ADD.op, 10, 12));
+ fprintf(fp, "%s", bi_round_mode_name(bits(ADD.op, 10, 12)));
else
- dump_minmax_mode(fp, bits(ADD.op, 10, 12));
+ fprintf(fp, "%s", bi_minmax_mode_name(bits(ADD.op, 10, 12)));
} else if (info.src_type == ADD_FCMP || info.src_type == ADD_FCMP16) {
dump_fcmp(fp, bits(ADD.op, 3, 6));
if (info.src_type == ADD_FCMP)
diff --git a/src/panfrost/bifrost/meson.build b/src/panfrost/bifrost/meson.build
index f7141eb69e1..2812dba2c5b 100644
--- a/src/panfrost/bifrost/meson.build
+++ b/src/panfrost/bifrost/meson.build
@@ -21,6 +21,7 @@
libpanfrost_bifrost_files = files(
'disassemble.c',
+ 'bi_print.c',
'bi_tables.c',
'bifrost_compile.c',
)