r600/sfn: Make use of four clause local registers
authorGert Wollny <gert.wollny@collabora.com>
Mon, 7 Aug 2023 13:10:26 +0000 (15:10 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 6 Sep 2023 15:14:19 +0000 (15:14 +0000)
The hardware is actually configures like this, but for fma64
we have to sacrifice a "normal" register to allocate z and w
channels, even though the result written there is not used.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24638>

src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/sfn/sfn_alu_defines.h
src/gallium/drivers/r600/sfn/sfn_assembler.cpp
src/gallium/drivers/r600/sfn/sfn_ra.cpp
src/gallium/drivers/r600/sfn/sfn_valuefactory.h

index f51fae6..39b16f1 100644 (file)
@@ -1334,14 +1334,14 @@ int r600_bytecode_add_alu_type(struct r600_bytecode *bc,
        }
        /* number of gpr == the last gpr used in any alu */
        for (i = 0; i < 3; i++) {
-               if (nalu->src[i].sel >= bc->ngpr && nalu->src[i].sel < 124) {
+               if (nalu->src[i].sel >= bc->ngpr && nalu->src[i].sel < 123) {
                        bc->ngpr = nalu->src[i].sel + 1;
                }
                if (nalu->src[i].sel == V_SQ_ALU_SRC_LITERAL)
                        r600_bytecode_special_constants(nalu->src[i].value,
                                &nalu->src[i].sel);
        }
-       if (nalu->dst.write && nalu->dst.sel >= bc->ngpr && nalu->dst.sel < 124) {
+       if (nalu->dst.write && nalu->dst.sel >= bc->ngpr && nalu->dst.sel < 123) {
                bc->ngpr = nalu->dst.sel + 1;
        }
        list_addtail(&nalu->list, &bc->cf_last->alu);
index dd02459..93ee6c6 100644 (file)
 
 namespace r600 {
 
-
+// We sacrifice 123 for dummy dests
+static const int g_registers_end = 123;
 static const int g_clause_local_start = 124;
-static const int g_clause_local_end = 126;
+static const int g_clause_local_end = 128;
 
 /* ALU op2 instructions 17:7 top three bits always zero. */
 enum EAluOp {
index 47cabf9..208ec68 100644 (file)
@@ -1217,7 +1217,7 @@ bool
 AssamblerVisitor::copy_dst(r600_bytecode_alu_dst& dst, const Register& d, bool write)
 {
    if (write && d.sel() > g_clause_local_end) {
-      R600_ERR("shader_from_nir: Don't support more then 124 GPRs + 2 claus "
+      R600_ERR("shader_from_nir: Don't support more then 123 GPRs + 4 clause "
                "local, but try using %d\n",
                d.sel());
       m_result = false;
@@ -1306,7 +1306,7 @@ EncodeSourceVisitor::EncodeSourceVisitor(r600_bytecode_alu_src& s, r600_bytecode
 void
 EncodeSourceVisitor::visit(const Register& value)
 {
-   assert(value.sel() < g_clause_local_end && "Only have 124 reisters + 4 clause local");
+   assert(value.sel() < g_clause_local_end && "Only have 123 reisters + 4 clause local");
 }
 
 void
index 2a36b31..6905827 100644 (file)
@@ -114,7 +114,7 @@ group_allocation(LiveRangeMap& lrm,
       if (group.priority > 0)
          color = 0;
 
-      while (color < 124) {
+      while (color < g_registers_end) {
          /* Find the coloring for the first channel */
          bool color_in_use = false;
          int comp = start_comp;
@@ -181,7 +181,7 @@ group_allocation(LiveRangeMap& lrm,
          break;
       }
 
-      if (color == 124)
+      if (color == g_registers_end)
          return false;
    }
 
@@ -206,7 +206,7 @@ scalar_allocation(LiveRangeMap& lrm, const Interference& interference)
 
          int color = 0;
 
-         while (color < 124) {
+         while (color < g_registers_end) {
             bool color_in_use = false;
             for (auto adj : adjecency) {
                if (live_ranges[adj].m_color == color) {
@@ -223,7 +223,7 @@ scalar_allocation(LiveRangeMap& lrm, const Interference& interference)
             r.m_color = color;
             break;
          }
-         if (color == 124)
+         if (color == g_registers_end)
             return false;
       }
    }
index b5293ab..f29e090 100644 (file)
@@ -329,7 +329,7 @@ private:
    uint32_t m_nowrite_idx;
 
    RegisterVec4 m_dummy_dest_pinned{
-      126, pin_chan, {0, 1, 2, 3}
+      g_registers_end, pin_chan, {0, 1, 2, 3}
    };
    ChannelCounts m_channel_counts;
    uint32_t m_required_array_registers{0};