Mesa (main): ir3/validate: Support multi-mov instructions

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 29 08:25:32 UTC 2021


Module: Mesa
Branch: main
Commit: b7f114ea13f7d7e26ff85114cda0963707f8ec3f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7f114ea13f7d7e26ff85114cda0963707f8ec3f

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Mon Jun 21 18:46:37 2021 +0200

ir3/validate: Support multi-mov instructions

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11565>

---

 src/freedreno/ir3/ir3_validate.c | 53 ++++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 15 deletions(-)

diff --git a/src/freedreno/ir3/ir3_validate.c b/src/freedreno/ir3/ir3_validate.c
index d091031e46e..a500d9b605a 100644
--- a/src/freedreno/ir3/ir3_validate.c
+++ b/src/freedreno/ir3/ir3_validate.c
@@ -63,14 +63,14 @@ static void
 validate_src(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr,
 			 struct ir3_register *reg)
 {
-	struct ir3_instruction *src = ssa(reg);
-
-	if (!src)
+	if (!(reg->flags & IR3_REG_SSA) || !reg->def)
 		return;
 
-	validate_assert(ctx, _mesa_set_search(ctx->defs, src));
-	validate_assert(ctx, src->dsts[0]->wrmask == reg->wrmask);
-	validate_assert(ctx, reg_class_flags(src->dsts[0]) == reg_class_flags(reg));
+	struct ir3_register *src = reg->def;
+
+	validate_assert(ctx, _mesa_set_search(ctx->defs, src->instr));
+	validate_assert(ctx, src->wrmask == reg->wrmask);
+	validate_assert(ctx, reg_class_flags(src) == reg_class_flags(reg));
 
 	if (reg->tied) {
 		validate_assert(ctx, reg->tied->tied == reg);
@@ -108,7 +108,8 @@ static void
 validate_phi(struct ir3_validate_ctx *ctx, struct ir3_instruction *phi)
 {
 	_mesa_set_add(ctx->defs, phi);
-	validate_assert(ctx, writes_gpr(phi));
+	validate_assert(ctx, phi->dsts_count == 1);
+	validate_assert(ctx, is_dest_gpr(phi->dsts[0]));
 }
 
 static void
@@ -135,6 +136,9 @@ validate_dst(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr,
 
 	if (reg->flags & IR3_REG_SSA)
 		validate_assert(ctx, reg->instr == instr);
+
+	if (reg->flags & IR3_REG_RELATIV)
+		validate_assert(ctx, instr->address);
 }
 
 #define validate_reg_size(ctx, reg, type) \
@@ -145,12 +149,6 @@ validate_instr(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr)
 {
 	struct ir3_register *last_reg = NULL;
 
-	if (writes_gpr(instr)) {
-		if (instr->dsts[0]->flags & IR3_REG_RELATIV) {
-			validate_assert(ctx, instr->address);
-		}
-	}
-
 	foreach_src_n (reg, n, instr) {
 		if (reg->flags & IR3_REG_RELATIV)
 			validate_assert(ctx, instr->address);
@@ -209,9 +207,34 @@ validate_instr(struct ir3_validate_ctx *ctx, struct ir3_instruction *instr)
 			validate_assert(ctx, !(instr->dsts[0]->flags & IR3_REG_HALF));
 			validate_assert(ctx, util_is_power_of_two_or_zero(instr->dsts[0]->wrmask + 1));
 		} else {
-			validate_reg_size(ctx, instr->dsts[0], instr->cat1.dst_type);
-			validate_reg_size(ctx, instr->srcs[0], instr->cat1.src_type);
+			foreach_dst (dst, instr)
+				validate_reg_size(ctx, dst, instr->cat1.dst_type);
+			foreach_src (src, instr) {
+				if (!src->tied && src != instr->address)
+					validate_reg_size(ctx, src, instr->cat1.src_type);
+			}
+
+			switch (instr->opc) {
+				case OPC_SWZ:
+					validate_assert(ctx, instr->srcs_count == 2);
+					validate_assert(ctx, instr->dsts_count == 2);
+					break;
+				case OPC_GAT:
+					validate_assert(ctx, instr->srcs_count == 4);
+					validate_assert(ctx, instr->dsts_count == 1);
+					break;
+				case OPC_SCT:
+					validate_assert(ctx, instr->srcs_count == 1);
+					validate_assert(ctx, instr->dsts_count == 4);
+					break;
+				default:
+					break;
+			}
 		}
+
+		if (instr->opc != OPC_MOV)
+			validate_assert(ctx, !instr->address);
+
 		break;
 	case 3:
 		/* Validate that cat3 opc matches the src type.  We've already checked that all



More information about the mesa-commit mailing list