broadcom/vc5: Use a physical-reg-only register class for LDVPM.
authorEric Anholt <eric@anholt.net>
Fri, 5 Jan 2018 22:34:51 +0000 (14:34 -0800)
committerEric Anholt <eric@anholt.net>
Sat, 13 Jan 2018 05:54:42 +0000 (21:54 -0800)
This is needed for LDVPM on V3D 4.x, but will also be needed for keeping
values out of the accumulators across THRSW.

src/broadcom/compiler/v3d_compiler.h
src/broadcom/compiler/vir_register_allocate.c

index 0a6638b95c5780c786c2acbdbcbb13b29cbe5533..72641bb7be30007540d821702a88da75534071ef 100644 (file)
@@ -383,7 +383,8 @@ struct qblock {
 struct v3d_compiler {
         const struct v3d_device_info *devinfo;
         struct ra_regs *regs;
-        unsigned int reg_class[3];
+        unsigned int reg_class_phys[3];
+        unsigned int reg_class_phys_or_acc[3];
 };
 
 struct v3d_compile {
index 0889937f4248fd2b5389e3a5c2e15eba236fd1e2..ff30101ce41d49069702b1ae74eea7e386412190 100644 (file)
@@ -44,18 +44,22 @@ vir_init_reg_sets(struct v3d_compiler *compiler)
          * can be divided up for fragment shader threading.
          */
         for (int threads = 0; threads < 3; threads++) {
-                compiler->reg_class[threads] =
+                compiler->reg_class_phys_or_acc[threads] =
+                        ra_alloc_reg_class(compiler->regs);
+                compiler->reg_class_phys[threads] =
                         ra_alloc_reg_class(compiler->regs);
 
                 for (int i = PHYS_INDEX;
                      i < PHYS_INDEX + (PHYS_COUNT >> threads); i++) {
                         ra_class_add_reg(compiler->regs,
-                                         compiler->reg_class[threads], i);
+                                         compiler->reg_class_phys_or_acc[threads], i);
+                        ra_class_add_reg(compiler->regs,
+                                         compiler->reg_class_phys[threads], i);
                 }
 
                 for (int i = ACC_INDEX + 0; i < ACC_INDEX + ACC_COUNT; i++) {
                         ra_class_add_reg(compiler->regs,
-                                         compiler->reg_class[threads], i);
+                                         compiler->reg_class_phys_or_acc[threads], i);
                 }
         }
 
@@ -173,8 +177,7 @@ v3d_register_allocate(struct v3d_compile *c)
                                  * decides whether the LDVPM is in or out)
                                  */
                                 assert(inst->dst.file == QFILE_TEMP);
-                                class_bits[temp_to_node[inst->dst.index]] &=
-                                        CLASS_BIT_PHYS;
+                                class_bits[inst->dst.index] &= CLASS_BIT_PHYS;
                                 break;
 
                         default:
@@ -223,8 +226,17 @@ v3d_register_allocate(struct v3d_compile *c)
         }
 
         for (uint32_t i = 0; i < c->num_temps; i++) {
-                ra_set_node_class(g, temp_to_node[i],
-                                  c->compiler->reg_class[c->fs_threaded]);
+                if (class_bits[i] == CLASS_BIT_PHYS) {
+                        ra_set_node_class(g, temp_to_node[i],
+                                          c->compiler->reg_class_phys[c->fs_threaded]);
+                } else {
+                        assert(class_bits[i] == (CLASS_BIT_PHYS |
+                                                 CLASS_BIT_R0_R2 |
+                                                 CLASS_BIT_R3 |
+                                                 CLASS_BIT_R4));
+                        ra_set_node_class(g, temp_to_node[i],
+                                          c->compiler->reg_class_phys_or_acc[c->fs_threaded]);
+                }
         }
 
         for (uint32_t i = 0; i < c->num_temps; i++) {