v3d: Drop the old class bits splitting up the accumulators.
[mesa.git] / src / broadcom / compiler / vir_lower_uniforms.c
index b2741994a2d6fc6d113c1b8ef896519fc2661d52..27d58fd33a1cd613e7f81effeb23c2eab7cf98b4 100644 (file)
@@ -66,7 +66,7 @@ remove_uniform(struct hash_table *ht, struct qreg reg)
 
         entry = _mesa_hash_table_search(ht, key);
         assert(entry);
-        entry->data--;
+        entry->data = (void *)(((uintptr_t) entry->data) - 1);
         if (entry->data == NULL)
                 _mesa_hash_table_remove(ht, entry);
 }
@@ -76,8 +76,6 @@ is_lowerable_uniform(struct qinst *inst, int i)
 {
         if (inst->src[i].file != QFILE_UNIF)
                 return false;
-        if (vir_has_implicit_uniform(inst))
-                return i != vir_get_implicit_uniform_src(inst);
         return true;
 }
 
@@ -87,7 +85,7 @@ is_lowerable_uniform(struct qinst *inst, int i)
 static uint32_t
 vir_get_instruction_uniform_count(struct qinst *inst)
 {
-        uint32_t count = 0;
+        uint32_t count = vir_has_uniform(inst);
 
         for (int i = 0; i < vir_get_nsrc(inst); i++) {
                 if (inst->src[i].file != QFILE_UNIF)
@@ -125,8 +123,7 @@ vir_lower_uniforms(struct v3d_compile *c)
                         continue;
 
                 for (int i = 0; i < nsrc; i++) {
-                        if (is_lowerable_uniform(inst, i))
-                                add_uniform(ht, inst->src[i]);
+                        add_uniform(ht, inst->src[i]);
                 }
         }
 
@@ -136,7 +133,6 @@ vir_lower_uniforms(struct v3d_compile *c)
                  */
                 uint32_t max_count = 0;
                 uint32_t max_index = 0;
-                struct hash_entry *entry;
                 hash_table_foreach(ht, entry) {
                         uint32_t count = (uintptr_t)entry->data;
                         uint32_t index = (uintptr_t)entry->key - 1;
@@ -152,7 +148,7 @@ vir_lower_uniforms(struct v3d_compile *c)
                  * reference a temp instead.
                  */
                 vir_for_each_block(block, c) {
-                        struct qinst *mov = NULL;
+                        struct qreg temp = c->undef;
 
                         vir_for_each_inst(inst, block) {
                                 uint32_t nsrc = vir_get_nsrc(inst);
@@ -162,29 +158,27 @@ vir_lower_uniforms(struct v3d_compile *c)
                                 if (count <= 1)
                                         continue;
 
-                                /* If the block doesn't have a load of the
-                                 * uniform yet, add it.  We could potentially
-                                 * do better and CSE MOVs from multiple blocks
-                                 * into dominating blocks, except that may
-                                 * cause troubles for register allocation.
-                                 */
-                                if (!mov) {
-                                        mov = vir_mul_inst(V3D_QPU_M_MOV,
-                                                           vir_get_temp(c),
-                                                           unif, c->undef);
-                                        list_add(&mov->link,
-                                                 &block->instructions);
-                                        c->defs[mov->dst.index] = mov;
-                                }
-
                                 bool removed = false;
                                 for (int i = 0; i < nsrc; i++) {
                                         if (is_lowerable_uniform(inst, i) &&
                                             inst->src[i].index == max_index) {
-                                                inst->src[i].file =
-                                                        mov->dst.file;
-                                                inst->src[i].index =
-                                                        mov->dst.index;
+                                                /* If the block doesn't have a
+                                                 * load of the uniform yet,
+                                                 * add it now.  We could
+                                                 * potentially do better and
+                                                 * CSE MOVs from multiple
+                                                 * blocks into dominating
+                                                 * blocks, except that may
+                                                 * cause troubles for register
+                                                 * allocation.
+                                                 */
+                                                if (temp.file == QFILE_NULL) {
+                                                        c->cursor =
+                                                                vir_before_inst(inst);
+                                                        temp = vir_MOV(c, unif);
+                                                }
+
+                                                inst->src[i] = temp;
                                                 remove_uniform(ht, unif);
                                                 removed = true;
                                         }