aco/ra: Add some documentation
authorTony Wasserka <tony.wasserka@gmx.de>
Tue, 17 Nov 2020 18:15:48 +0000 (19:15 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 29 Dec 2020 18:57:10 +0000 (18:57 +0000)
This should make these somewhat tricky bits easier to follow.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7461>

src/amd/compiler/aco_register_allocation.cpp

index d5a921e..dd59239 100644 (file)
@@ -192,6 +192,8 @@ public:
    }
 
    bool is_empty_or_blocked(PhysReg start) {
+      /* Empty is 0, blocked is 0xFFFFFFFF, so to check both we compare the
+       * incremented value to 1 */
       if (regs[start] == 0xF0000000) {
          return subdword_regs[start][start.byte()] + 1 <= 1;
       }
@@ -994,7 +996,9 @@ std::pair<PhysReg, bool> get_reg_impl(ra_ctx& ctx,
    unsigned reg_lo = lb;
    unsigned reg_hi = lb + size - 1;
    for (reg_lo = lb, reg_hi = lb + size - 1; reg_hi < ub; reg_lo += stride, reg_hi += stride) {
-      /* first check the edges: this is what we have to fix to allow for num_moves > size */
+      /* first check if the register window starts in the middle of an
+       * allocated variable: this is what we have to fix to allow for
+       * num_moves > size */
       if (reg_lo > lb && !tmp_file.is_empty_or_blocked(PhysReg(reg_lo)) &&
           tmp_file.get_id(PhysReg(reg_lo)) == tmp_file.get_id(PhysReg(reg_lo).advance(-1)))
          continue;