]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: print absolute PC for all patterns "off(PC)" in testEndToEnd
authorRuinan <ruinan.sun@arm.com>
Thu, 30 Nov 2023 07:54:06 +0000 (15:54 +0800)
committerCherry Mui <cherryyz@google.com>
Thu, 7 Dec 2023 18:42:59 +0000 (18:42 +0000)
Before this CL, testEndToEnd only turns the relative PC to absolute PC
when pattern "off(PC)" is the suffix of an instruction. But there are
some instructions like:

  ADR 10(PC), R10

it's also acceptable for the assembler while the pattern "off(PC)" is
not a suffix, which makes the test fail.

This CL fixes this issue by searching the pattern in the whole string
instead of only in the suffix.

Change-Id: I0cffedeb7b3c63abca7697671088cf993aff71ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/547235
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ruinan Sun <Ruinan.Sun@arm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
src/cmd/asm/internal/asm/endtoend_test.go
src/cmd/asm/internal/asm/testdata/arm64.s

index 592d7b4b76a9287d4b8a4852e45a9ffd23490116..6e1aa1cd95f42cd311b50e826e311bb5fc0bc0b8 100644 (file)
@@ -141,11 +141,17 @@ Diff:
                // Turn relative (PC) into absolute (PC) automatically,
                // so that most branch instructions don't need comments
                // giving the absolute form.
-               if len(f) > 0 && strings.HasSuffix(printed, "(PC)") {
-                       last := f[len(f)-1]
-                       n, err := strconv.Atoi(last[:len(last)-len("(PC)")])
+               if len(f) > 0 && strings.Contains(printed, "(PC)") {
+                       index := len(f) - 1
+                       suf := "(PC)"
+                       for !strings.HasSuffix(f[index], suf) {
+                               index--
+                               suf = "(PC),"
+                       }
+                       str := f[index]
+                       n, err := strconv.Atoi(str[:len(str)-len(suf)])
                        if err == nil {
-                               f[len(f)-1] = fmt.Sprintf("%d(PC)", seq+n)
+                               f[index] = fmt.Sprintf("%d%s", seq+n, suf)
                        }
                }
 
index 46ea6645afbafe33bf57823aa3d7242cdf93100c..12b4e3255e55c2cda9b449b74c6ab8aef3188841 100644 (file)
@@ -981,6 +981,14 @@ again:
        ADR     next, R11     // ADR R11 // 2b000010
 next:
        NOP
+       ADR -2(PC), R10    // 0a000010
+       ADR 2(PC), R16     // 10000010
+       ADR -26(PC), R1    // 01000010
+       ADR 12(PC), R2     // 02000010
+       ADRP -2(PC), R10   // 0a000090
+       ADRP 2(PC), R16    // 10000090
+       ADRP -26(PC), R1   // 01000090
+       ADRP 12(PC), R2    // 02000090
 
 // LDP/STP
        LDP     (R0), (R0, R1)      // 000440a9