Mesa (main): ir3: Add ra_foreach_src_n/ra_foreach_dst_n

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 20 10:57:10 UTC 2021


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Fri Jul 23 13:08:59 2021 +0200

ir3: Add ra_foreach_src_n/ra_foreach_dst_n

I found ra_foreach_src_n useful in one place in the spiller. But this
also aligns RA with the rest of the compiler and stops us from
reinventing the iterators.

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

---

 src/freedreno/ir3/ir3_ra.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/freedreno/ir3/ir3_ra.h b/src/freedreno/ir3/ir3_ra.h
index 98533a38aed..2925370c13c 100644
--- a/src/freedreno/ir3/ir3_ra.h
+++ b/src/freedreno/ir3/ir3_ra.h
@@ -106,14 +106,14 @@ ra_reg_is_dst(const struct ir3_register *reg)
 /* Iterators for sources and destinations which:
  * - Don't include fake sources (irrelevant for RA)
  * - Don't include non-SSA sources (immediates and constants, also irrelevant)
- * - Consider array destinations as both a source and a destination
  */
 
+#define ra_foreach_src_n(__srcreg, __n, __instr)                               \
+   foreach_src_n(__srcreg, __n, __instr)                                       \
+      if (ra_reg_is_src(__srcreg))
+
 #define ra_foreach_src(__srcreg, __instr)                                      \
-   for (struct ir3_register *__srcreg = (void *)~0; __srcreg; __srcreg = NULL) \
-      for (unsigned __cnt = (__instr)->srcs_count, __i = 0; __i < __cnt;       \
-           __i++)                                                              \
-         if (ra_reg_is_src((__srcreg = (__instr)->srcs[__i])))
+   ra_foreach_src_n(__srcreg, __i, __instr)
 
 #define ra_foreach_src_rev(__srcreg, __instr)                                  \
    for (struct ir3_register *__srcreg = (void *)~0; __srcreg; __srcreg = NULL) \
@@ -121,11 +121,12 @@ ra_reg_is_dst(const struct ir3_register *reg)
            __i--)                                                              \
          if (ra_reg_is_src((__srcreg = (__instr)->srcs[__i])))
 
+#define ra_foreach_dst_n(__dstreg, __n, __instr)                               \
+   foreach_dst_n(__dstreg, __n, instr)                                         \
+      if (ra_reg_is_dst(__dstreg))
+
 #define ra_foreach_dst(__dstreg, __instr)                                      \
-   for (struct ir3_register *__dstreg = (void *)~0; __dstreg; __dstreg = NULL) \
-      for (unsigned __cnt = (__instr)->dsts_count, __i = 0; __i < __cnt;       \
-           __i++)                                                              \
-         if (ra_reg_is_dst((__dstreg = (__instr)->dsts[__i])))
+   ra_foreach_dst_n(__dstreg, __i, __instr)
 
 #define RA_HALF_SIZE     (4 * 48)
 #define RA_FULL_SIZE     (4 * 48 * 2)



More information about the mesa-commit mailing list