From 63c2ee2c4c15940f443dd330a4c6ff9281ee7de1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 20 Jan 2021 19:01:03 -0500 Subject: [PATCH] pan/bi: Refactor PC-relative printing Let's get the offset in a named variable for validation. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/disassemble.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c index 9656bf322d3..9858001c06e 100644 --- a/src/panfrost/bifrost/disassemble.c +++ b/src/panfrost/bifrost/disassemble.c @@ -242,6 +242,11 @@ static void dump_const_imm(FILE *fp, uint32_t imm) static void dump_pc_imm(FILE *fp, uint64_t imm, enum bi_constmod mod, bool high32) { + if (mod == BI_CONSTMOD_PC_HI && !high32) { + dump_const_imm(fp, imm); + return; + } + /* 60-bit sign-extend */ uint64_t zx64 = (imm << 4); int64_t sx64 = zx64; @@ -254,24 +259,26 @@ dump_pc_imm(FILE *fp, uint64_t imm, enum bi_constmod mod, bool high32) sx32[0] >>= 4; sx32[1] >>= 4; + int64_t offs = 0; + switch (mod) { case BI_CONSTMOD_PC_LO: - fprintf(fp, "(pc + %" PRId64 ")%s", - sx64, - high32 ? " >> 32" : ""); + offs = sx64; break; case BI_CONSTMOD_PC_HI: - if (high32) - fprintf(fp, "(pc + %d)", sx32[1]); - else - dump_const_imm(fp, imm); + offs = sx32[1]; break; case BI_CONSTMOD_PC_LO_HI: - fprintf(fp, "(pc + %d)", sx32[high32]); + offs = sx32[high32]; break; default: unreachable("Invalid PC modifier"); } + + fprintf(fp, "(pc + %" PRId64 ")", offs); + + if (mod == BI_CONSTMOD_PC_LO && high32) + fprintf(fp, " >> 32"); } /* Convert an index to an embedded constant in FAU-RAM to the index of the