pan/midgard: Fix shift for TLS access
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 7 Dec 2019 20:54:36 +0000 (15:54 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 12 Dec 2019 16:42:07 +0000 (11:42 -0500)
Due to this issue we were using 4x the memory we should have for TLS,
which was messing up the size calculations. Oops!

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

index 63dcb41ad4141ca94b899dbb2fcf89fbb345e5e2..fca181334bb8d2b0d09538d2a6f0166fd009d368 100644 (file)
@@ -359,6 +359,19 @@ emit_alu_bundle(compiler_context *ctx,
         }
 }
 
+/* Shift applied to the immediate used as an offset. Probably this is papering
+ * over some other semantic distinction else well, but it unifies things in the
+ * compiler so I don't mind. */
+
+static unsigned
+mir_ldst_imm_shift(midgard_load_store_op op)
+{
+        if (OP_IS_UBO_READ(op))
+                return 3;
+        else
+                return 1;
+}
+
 /* After everything is scheduled, emit whole bundles at a time */
 
 void
@@ -393,8 +406,11 @@ emit_binary_bundle(compiler_context *ctx,
                         unsigned offset = bundle->instructions[i]->constants[0];
 
                         if (offset) {
-                                bundle->instructions[i]->load_store.varying_parameters |= (offset & 0x7F) << 3;
-                                bundle->instructions[i]->load_store.address |= (offset >> 7);
+                                unsigned shift = mir_ldst_imm_shift(bundle->instructions[i]->load_store.op);
+                                unsigned upper_shift = 10 - shift;
+
+                                bundle->instructions[i]->load_store.varying_parameters |= (offset & ((1 << upper_shift) - 1)) << shift;
+                                bundle->instructions[i]->load_store.address |= (offset >> upper_shift);
                         }
                 }