From 2b4da476f449aac5fc3867afdabc4ec545e5f1ec Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 7 Dec 2019 15:54:36 -0500 Subject: [PATCH] pan/midgard: Fix shift for TLS access 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 --- src/panfrost/midgard/midgard_emit.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c index 63dcb41ad41..fca181334bb 100644 --- a/src/panfrost/midgard/midgard_emit.c +++ b/src/panfrost/midgard/midgard_emit.c @@ -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); } } -- 2.30.2