Commit 2bd98fffa9 for qemu.org
commit 2bd98fffa9f2ce43dd573b82e88da6ea473a5757
Author: Brian Cain <brian.cain@oss.qualcomm.com>
Date: Wed Nov 18 07:57:45 2026 -0800
target/hexagon: Fix disassembly of extended GP-relative accesses
A GP-relative load or store with a constant extender is an absolute
access: the semantics read GP as 0 when insn->extension_valid is set,
and the extended immediate is the full address. The printed form kept
the "gp+" base, so for example
R0 = memw(gp+##0x48c30)
was shown for an instruction that accesses 0x48c30 and does not use GP.
Only print the "gp+" base when there is no extender.
Link: https://lore.kernel.org/qemu-devel/20261118144441.27680-1-anjo@rev.ng/
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
diff --git a/target/hexagon/gen_printinsn.py b/target/hexagon/gen_printinsn.py
index cf1a12adbc..1eb98a1a43 100755
--- a/target/hexagon/gen_printinsn.py
+++ b/target/hexagon/gen_printinsn.py
@@ -125,6 +125,10 @@ def main():
beh = hex_common.absimmre.sub(r"#%s0x%x", beh)
beh = hex_common.relimmre.sub(r"PC+%s%d", beh)
beh = spacify(beh)
+
+ gp_relative = "(gp+" in beh
+ if gp_relative:
+ beh = beh.replace("(gp+", "(%s")
# Print out a literal "%s" at the end, used to match empty string
# so C won't complain at us
if "A_VECX" in hex_common.attribdict[tag]:
@@ -158,6 +162,9 @@ def main():
ri += 1
else:
# immediate
+ if gp_relative:
+ f.write(', insn->extension_valid ? "" : "gp+"')
+ gp_relative = False
if immlett.isupper():
if extendable_upper_imm:
if immlett in "rR":