]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: LOOP is a branch instruction on x86
authorRob Pike <r@golang.org>
Tue, 3 Mar 2015 17:30:07 +0000 (09:30 -0800)
committerRob Pike <r@golang.org>
Tue, 3 Mar 2015 22:44:24 +0000 (22:44 +0000)
Just a missed case in in the handling of branches.

Fixes #10065

Change-Id: I6be054d30bf1f383c12b4c7626abd5f8ae22b22e
Reviewed-on: https://go-review.googlesource.com/6631
Reviewed-by: Minux Ma <minux@golang.org>
src/cmd/asm/internal/arch/arch.go
src/cmd/asm/internal/asm/testdata/386.out
src/cmd/asm/internal/asm/testdata/386.s
src/cmd/asm/internal/asm/testdata/amd64.out
src/cmd/asm/internal/asm/testdata/amd64.s

index 79e2f722ac1f108226d613d08e5c7dd19ba34c31..4156d3c1042f44299ccfa60b0b9bfe7c84eaee6b 100644 (file)
@@ -11,6 +11,7 @@ import (
        "cmd/internal/obj/ppc64"
        "cmd/internal/obj/x86" // == amd64
        "fmt"
+       "strings"
 )
 
 // Pseudo-registers whose names are the constant name without the leading R.
@@ -77,7 +78,7 @@ func Set(GOARCH string) *Arch {
 }
 
 func jump386(word string) bool {
-       return word[0] == 'J' || word == "CALL"
+       return word[0] == 'J' || word == "CALL" || strings.HasPrefix(word, "LOOP")
 }
 
 func arch386() *Arch {
index 59c7f89e927987a1ea026e4a166ad97faa2754ac..8ac94db82b3cd7556e03348749b802ac104c2905 100644 (file)
@@ -45,4 +45,5 @@
 75 00045 (testdata/386.s:75)   CMPPD   X0,foo+4(SB)
 78 00046 (testdata/386.s:78)   PINSRD  (AX),$1,X0
 79 00047 (testdata/386.s:79)   PINSRD  foo+4(FP),$2,X0
-82 00048 (testdata/386.s:82)   RET     ,
+83 00048 (testdata/386.s:83)   LOOP    ,
+86 00049 (testdata/386.s:86)   RET     ,
index 67c48d0fc30ddaa6f9f0568612e3e96989fe9e15..6bee39f3d4162e4f167ebcae05159ee2f6da5a87 100644 (file)
@@ -78,5 +78,9 @@ label:
        PINSRD  $1, (AX), X0
        PINSRD  $2, foo+4(FP), X0
 
+// Was bug: LOOP is a branch instruction.
+loop:
+       LOOP    loop
+
 // LTYPE0 nonnon       { outcode(int($1), &$2); }
        RET
index a17ae0f4729230d157a51e96c4d5326fc1c1d80d..e647a5c6bda2880ee9ec6f47dfd55771ad1deb3c 100644 (file)
@@ -53,4 +53,5 @@
 86 00053 (testdata/amd64.s:86) PINSRW  R11,$4,AX
 87 00054 (testdata/amd64.s:87) PINSRW  foo+4(SB),$4,AX
 90 00055 (testdata/amd64.s:90) RETFL   $4,
-93 00056 (testdata/amd64.s:93) RET     ,
+94 00056 (testdata/amd64.s:94) LOOP    ,
+97 00057 (testdata/amd64.s:97) RET     ,
index cb925f2475c94190394bb80ef7a27206c5944e55..eb13a1f96e4dd991a60280ef6a90c926215ff169 100644 (file)
@@ -89,5 +89,9 @@ label:
 // LTYPERT spec10      { outcode($1, &$2); }
        RETFL   $4
 
+// Was bug: LOOP is a branch instruction.
+loop:
+       LOOP    loop
+
 // LTYPE0 nonnon       { outcode($1, &$2); }
        RET