Commit ce23729a authored by Russ Cox's avatar Russ Cox

cmd/asm: fix and test CALL, JMP aliases on arm, arm64, ppc64

Fixes #11900.

Change-Id: Idfc54e1fac833c8d646266128efe46214a82dfed
Reviewed-on: https://go-review.googlesource.com/12741Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
Reviewed-by: default avatarRob Pike <r@golang.org>
parent 0229317d
...@@ -79,6 +79,7 @@ var armJump = map[string]bool{ ...@@ -79,6 +79,7 @@ var armJump = map[string]bool{
"BGT": true, "BGT": true,
"BLE": true, "BLE": true,
"CALL": true, "CALL": true,
"JMP": true,
} }
func jumpArm(word string) bool { func jumpArm(word string) bool {
......
...@@ -42,6 +42,7 @@ var arm64Jump = map[string]bool{ ...@@ -42,6 +42,7 @@ var arm64Jump = map[string]bool{
"CBZW": true, "CBZW": true,
"CBNZ": true, "CBNZ": true,
"CBNZW": true, "CBNZW": true,
"JMP": true,
} }
func jumpArm64(word string) bool { func jumpArm64(word string) bool {
......
...@@ -12,7 +12,7 @@ import "cmd/internal/obj/ppc64" ...@@ -12,7 +12,7 @@ import "cmd/internal/obj/ppc64"
func jumpPPC64(word string) bool { func jumpPPC64(word string) bool {
switch word { switch word {
case "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLT", "BNE", "BR", "BVC", "BVS", "CALL": case "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLT", "BNE", "BR", "BVC", "BVS", "CALL", "JMP":
return true return true
} }
return false return false
......
...@@ -52,4 +52,8 @@ ...@@ -52,4 +52,8 @@
266 00052 (testdata/arm.s:266) PLD (R1) 266 00052 (testdata/arm.s:266) PLD (R1)
267 00053 (testdata/arm.s:267) PLD 4(R1) 267 00053 (testdata/arm.s:267) PLD 4(R1)
276 00054 (testdata/arm.s:276) RET 276 00054 (testdata/arm.s:276) RET
285 00055 (testdata/arm.s:285) END 280 00055 (testdata/arm.s:280) JMP foo(SB)
281 00056 (testdata/arm.s:281) CALL foo(SB)
282 00057 (testdata/arm.s:282) JMP foo(SB)
283 00058 (testdata/arm.s:283) CALL foo(SB)
292 00059 (testdata/arm.s:292) END
...@@ -275,6 +275,13 @@ TEXT foo(SB), 0, $0 ...@@ -275,6 +275,13 @@ TEXT foo(SB), 0, $0
// } // }
RET RET
// More B/BL cases, and canonical names JMP, CALL.
B foo(SB)
BL foo(SB)
JMP foo(SB)
CALL foo(SB)
// //
// END // END
// //
......
...@@ -48,4 +48,8 @@ ...@@ -48,4 +48,8 @@
242 00048 (testdata/arm64.s:242) LDAXRW (R0), R2 242 00048 (testdata/arm64.s:242) LDAXRW (R0), R2
243 00049 (testdata/arm64.s:243) STLXRW R1, (R0), R3 243 00049 (testdata/arm64.s:243) STLXRW R1, (R0), R3
251 00050 (testdata/arm64.s:251) RET 251 00050 (testdata/arm64.s:251) RET
259 00051 (testdata/arm64.s:259) END 255 00051 (testdata/arm64.s:255) JMP foo(SB)
256 00052 (testdata/arm64.s:256) CALL foo(SB)
257 00053 (testdata/arm64.s:257) JMP foo(SB)
258 00054 (testdata/arm64.s:258) CALL foo(SB)
266 00055 (testdata/arm64.s:266) END
...@@ -250,6 +250,13 @@ again: ...@@ -250,6 +250,13 @@ again:
// } // }
RET RET
// More B/BL cases, and canonical names JMP, CALL.
B foo(SB)
BL foo(SB)
JMP foo(SB)
CALL foo(SB)
// END // END
// //
// LTYPEE comma // LTYPEE comma
......
...@@ -107,4 +107,8 @@ ...@@ -107,4 +107,8 @@
691 00107 (testdata/ppc64.s:691) NOP F2 691 00107 (testdata/ppc64.s:691) NOP F2
697 00108 (testdata/ppc64.s:697) NOP $4 697 00108 (testdata/ppc64.s:697) NOP $4
705 00109 (testdata/ppc64.s:705) RET 705 00109 (testdata/ppc64.s:705) RET
713 00110 (testdata/ppc64.s:713) END 709 00110 (testdata/ppc64.s:709) JMP foo(SB)
710 00111 (testdata/ppc64.s:710) CALL foo(SB)
711 00112 (testdata/ppc64.s:711) JMP foo(SB)
712 00113 (testdata/ppc64.s:712) CALL foo(SB)
720 00114 (testdata/ppc64.s:720) END
...@@ -704,6 +704,13 @@ label1: ...@@ -704,6 +704,13 @@ label1:
// } // }
RET RET
// More BR/BL cases, and canonical names JMP, CALL.
BR foo(SB)
BL foo(SB)
JMP foo(SB)
CALL foo(SB)
// END // END
// //
// LEND comma // asm doesn't support the trailing comma. // LEND comma // asm doesn't support the trailing comma.
......
...@@ -249,7 +249,9 @@ var lexinit = []asm.Lextab{ ...@@ -249,7 +249,9 @@ var lexinit = []asm.Lextab{
{"DIVF", LTYPEK, arm.ADIVF}, {"DIVF", LTYPEK, arm.ADIVF},
{"DIVD", LTYPEK, arm.ADIVD}, {"DIVD", LTYPEK, arm.ADIVD},
{"B", LTYPE4, arm.AB}, {"B", LTYPE4, arm.AB},
{"JMP", LTYPE4, arm.AB},
{"BL", LTYPE4, arm.ABL}, {"BL", LTYPE4, arm.ABL},
{"CALL", LTYPE4, arm.ABL},
{"BX", LTYPEBX, arm.ABX}, {"BX", LTYPEBX, arm.ABX},
{"BEQ", LTYPE5, arm.ABEQ}, {"BEQ", LTYPE5, arm.ABEQ},
{"BNE", LTYPE5, arm.ABNE}, {"BNE", LTYPE5, arm.ABNE},
......
...@@ -256,9 +256,11 @@ var lexinit = []asm.Lextab{ ...@@ -256,9 +256,11 @@ var lexinit = []asm.Lextab{
{"SRAW", LSHW, ppc64.ASRAW}, {"SRAW", LSHW, ppc64.ASRAW},
{"SRAWCC", LSHW, ppc64.ASRAWCC}, {"SRAWCC", LSHW, ppc64.ASRAWCC},
{"BR", LBRA, ppc64.ABR}, {"BR", LBRA, ppc64.ABR},
{"JMP", LBRA, ppc64.ABR},
{"BC", LBRA, ppc64.ABC}, {"BC", LBRA, ppc64.ABC},
{"BCL", LBRA, ppc64.ABC}, {"BCL", LBRA, ppc64.ABC},
{"BL", LBRA, ppc64.ABL}, {"BL", LBRA, ppc64.ABL},
{"CALL", LBRA, ppc64.ABL},
{"BEQ", LBRA, ppc64.ABEQ}, {"BEQ", LBRA, ppc64.ABEQ},
{"BNE", LBRA, ppc64.ABNE}, {"BNE", LBRA, ppc64.ABNE},
{"BGT", LBRA, ppc64.ABGT}, {"BGT", LBRA, ppc64.ABGT},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment