Mesa (main): ir3: Prepare dest helpers for multi-dst instructions

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


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Fri Jun 25 11:06:35 2021 +0200

ir3: Prepare dest helpers for multi-dst instructions

Assert in dest_regs() that dst_count == 1, since most users of it will
blow up if they encounter multiple destinations, and split out the core
of writes_gpr() so that we can easily make code using it multi-dst
aware.

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

---

 src/freedreno/ir3/ir3.h | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h
index daa2d815d8a..41452856e87 100644
--- a/src/freedreno/ir3/ir3.h
+++ b/src/freedreno/ir3/ir3.h
@@ -966,25 +966,32 @@ static inline unsigned dest_regs(struct ir3_instruction *instr)
 	if (instr->dsts_count == 0)
 		return 0;
 
+	debug_assert(instr->dsts_count == 1);
 	return util_last_bit(instr->dsts[0]->wrmask);
 }
 
+/* is dst a normal temp register: */
+static inline bool is_dest_gpr(struct ir3_register *dst)
+{
+	if (dst->wrmask == 0)
+		return false;
+	if ((reg_num(dst) == REG_A0) ||
+			(dst->num == regid(REG_P0, 0)))
+		return false;
+	return true;
+}
+
 static inline bool
 writes_gpr(struct ir3_instruction *instr)
 {
 	if (dest_regs(instr) == 0)
 		return false;
-	/* is dest a normal temp register: */
-	struct ir3_register *reg = instr->dsts[0];
-	debug_assert(!(reg->flags & (IR3_REG_CONST | IR3_REG_IMMED)));
-	if ((reg_num(reg) == REG_A0) ||
-			(reg->num == regid(REG_P0, 0)))
-		return false;
-	return true;
+	return is_dest_gpr(instr->dsts[0]);
 }
 
 static inline bool writes_addr0(struct ir3_instruction *instr)
 {
+	/* Note: only the first dest can write to a0.x */
 	if (instr->dsts_count > 0) {
 		struct ir3_register *dst = instr->dsts[0];
 		return dst->num == regid(REG_A0, 0);
@@ -994,6 +1001,7 @@ static inline bool writes_addr0(struct ir3_instruction *instr)
 
 static inline bool writes_addr1(struct ir3_instruction *instr)
 {
+	/* Note: only the first dest can write to a1.x */
 	if (instr->dsts_count > 0) {
 		struct ir3_register *dst = instr->dsts[0];
 		return dst->num == regid(REG_A0, 1);
@@ -1003,6 +1011,7 @@ static inline bool writes_addr1(struct ir3_instruction *instr)
 
 static inline bool writes_pred(struct ir3_instruction *instr)
 {
+	/* Note: only the first dest can write to p0.x */
 	if (instr->dsts_count > 0) {
 		struct ir3_register *dst = instr->dsts[0];
 		return reg_num(dst) == REG_P0;



More information about the mesa-commit mailing list