aboutsummaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-03-02 20:24:03 -0500
committerMarge Bot <[email protected]>2020-03-05 14:35:37 +0000
commit230be61f201d07ac95e32a82e688a05eb4093fcc (patch)
tree11001fcebfcfb3ab9434988e5196441ce0d157a1 /src/panfrost
parente7dc2a7b9beeb3fe9af00033d972f89bf436bb68 (diff)
pan/bi: Add src/dest fields to bifrost_instruction
...along with some helpers to generate indices. The indexing scheme is mostly a copypaste from Midgard, except we specifically reserve 0 as the sentinel (midgard uses ~0 for this which has always been a pain point). Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4061>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/bifrost/compiler.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 6c2f657a73a..9903bb6ee7c 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -68,9 +68,17 @@ enum bi_class {
BI_ROUND,
};
+/* It can't get any worse than csel4... can it? */
+#define BIR_SRC_COUNT 4
+
typedef struct {
struct list_head link; /* Must be first */
enum bi_class type;
+
+ /* Indices, see bir_ssa_index etc. Note zero is special cased
+ * to "no argument" */
+ unsigned dest;
+ unsigned src[BIR_SRC_COUNT];
} bi_instruction;
typedef struct {
@@ -83,4 +91,37 @@ typedef struct {
struct list_head blocks; /* list of bi_block */
} bi_context;
+/* So we can distinguish between SSA/reg/sentinel quickly */
+#define BIR_NO_ARG (0)
+#define BIR_IS_REG (1)
+
+static inline unsigned
+bir_ssa_index(nir_ssa_def *ssa)
+{
+ /* Off-by-one ensures BIR_NO_ARG is skipped */
+ return ((ssa->index + 1) << 1) | 0;
+}
+
+static inline unsigned
+bir_src_index(nir_src *src)
+{
+ if (src->is_ssa)
+ return bir_ssa_index(src->ssa);
+ else {
+ assert(!src->reg.indirect);
+ return (src->reg.reg->index << 1) | BIR_IS_REG;
+ }
+}
+
+static inline unsigned
+bir_dest_index(nir_dest *dst)
+{
+ if (dst->is_ssa)
+ return bir_ssa_index(&dst->ssa);
+ else {
+ assert(!dst->reg.indirect);
+ return (dst->reg.reg->index << 1) | BIR_IS_REG;
+ }
+}
+
#endif