Skip to contentSkip to conversation

target/hexagon: Fix disassembly of extended GP-relative accesses

PATCH In review Brian Cain 3 participants 3 messages Nov 18

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

PATCH 1/1 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.

---
 target/hexagon/gen_printinsn.py | 7 +++++++
 1 file changed, 7 insertions(+)
target/hexagon/gen_printinsn.py +7 -0
index cf1a12adbc1..1eb98a1a432 100755
@@ -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":
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Brian Cain

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.

Quoted 8 lines

Only print the "gp+" base when there is no extender.

---
 target/hexagon/gen_printinsn.py | 7 +++++++
 1 file changed, 7 insertions(+)
Reviewed-by Anton Johansson on v1 1/1
#2 lore raw
In reply to Brian Cain
Quoted 9 lines · Brian Cain

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.

Quoted 7 lines

Only print the "gp+" base when there is no extender.

---
 target/hexagon/gen_printinsn.py | 7 +++++++
 1 file changed, 7 insertions(+)