pan/midgard: Fix quadword_count handling
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 4 Nov 2019 15:32:49 +0000 (10:32 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 4 Nov 2019 20:36:08 +0000 (15:36 -0500)
Spilling can mess with this considerably.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_schedule.c
src/panfrost/midgard/mir.c

index 2604bbe980a3fbed38f6a33cb70bfc63a82fde11..22c0d44c759511e7d46735228e2d11fa19265e5f 100644 (file)
@@ -2359,10 +2359,10 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx)
         unsigned first_tag = 0;
 
         mir_foreach_block_from(ctx, initial_block, v) {
-                midgard_bundle *initial_bundle =
-                        util_dynarray_element(&v->bundles, midgard_bundle, 0);
+                if (v->quadword_count) {
+                        midgard_bundle *initial_bundle =
+                                util_dynarray_element(&v->bundles, midgard_bundle, 0);
 
-                if (initial_bundle) {
                         first_tag = initial_bundle->tag;
                         break;
                 }
index acfc5754480d5e67b09eaead69a98d6d9a716f31..0c93f3ed32b5374e0ccdd02a7142ee1443bc7c58 100644 (file)
@@ -1072,7 +1072,9 @@ schedule_block(compiler_context *ctx, midgard_block *block)
 
         /* Blend constant was backwards as well. blend_offset if set is
          * strictly positive, as an offset of zero would imply constants before
-         * any instructions which is invalid in Midgard */
+         * any instructions which is invalid in Midgard. TODO: blend constants
+         * are broken if you spill since then quadword_count becomes invalid
+         * XXX */
 
         if (blend_offset)
                 ctx->blend_constant_offset = ((ctx->quadword_count + block->quadword_count) - blend_offset - 1) * 0x10;
index fef2fd8e0f81ed712ef646baaa5f9ed0546a50e8..609cd5c1db424a9a97fa00d85223e2c5af9f004c 100644 (file)
@@ -547,6 +547,7 @@ mir_insert_instruction_before_scheduled(
         memcpy(bundles + before, &new, sizeof(new));
 
         list_addtail(&new.instructions[0]->link, &before_bundle->instructions[0]->link);
+        block->quadword_count += quadword_size(new.tag);
 }
 
 void
@@ -571,6 +572,7 @@ mir_insert_instruction_after_scheduled(
         midgard_bundle new = mir_bundle_for_op(ctx, ins);
         memcpy(bundles + after + 1, &new, sizeof(new));
         list_add(&new.instructions[0]->link, &after_bundle->instructions[after_bundle->instruction_count - 1]->link);
+        block->quadword_count += quadword_size(new.tag);
 }
 
 /* Flip the first-two arguments of a (binary) op. Currently ALU