Commit 720af3c8 authored by Iskander Sharipov's avatar Iskander Sharipov Committed by Brad Fitzpatrick

cmd/asm: reject BSWAPW on amd64

Since BSWAP operation on 16-bit registers is undefined,
forbid the usage of BSWAPW. Users should rely on XCHGB instead.

This behavior is consistent with what GAS does.

Fixes #29167

Change-Id: I3b31e3dd2acfd039f7564a1c17e6068617bcde8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/174312
Run-TryBot: Iskander Sharipov <quasilyte@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 08318f59
......@@ -28,6 +28,10 @@ func TestAMD64BadInstParser(t *testing.T) {
{"VADDPD.BCST.Z.SAE X0, X1, X2", `Z suffix should be the last; can't combine rounding/SAE and broadcast`},
{"VADDPD.SAE.SAE X0, X1, X2", `duplicate suffix "SAE"`},
{"VADDPD.RZ_SAE.SAE X0, X1, X2", `bad suffix combination`},
// BSWAP on 16-bit registers is undefined. See #29167,
{"BSWAPW DX", `unrecognized instruction`},
{"BSWAPW R11", `unrecognized instruction`},
})
}
......
......@@ -588,8 +588,6 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
BSRQ (R11), R11 // 4d0fbd1b
BSRQ DX, R11 // 4c0fbdda
BSRQ R11, R11 // 4d0fbddb
BSWAPW DX // 660fca
BSWAPW R11 // 66410fcb
BSWAPL DX // 0fca
BSWAPL R11 // 410fcb
BSWAPQ DX // 480fca
......
......@@ -69,7 +69,6 @@ const (
ABSRW
ABSWAPL
ABSWAPQ
ABSWAPW
ABTCL
ABTCQ
ABTCW
......
......@@ -67,7 +67,6 @@ var Anames = []string{
"BSRW",
"BSWAPL",
"BSWAPQ",
"BSWAPW",
"BTCL",
"BTCQ",
"BTCW",
......
......@@ -961,7 +961,6 @@ var optab =
{ABSRL, yml_rl, Pm, opBytes{0xbd}},
{ABSRQ, yml_rl, Pw, opBytes{0x0f, 0xbd}},
{ABSRW, yml_rl, Pq, opBytes{0xbd}},
{ABSWAPW, ybswap, Pe, opBytes{0x0f, 0xc8}},
{ABSWAPL, ybswap, Px, opBytes{0x0f, 0xc8}},
{ABSWAPQ, ybswap, Pw, opBytes{0x0f, 0xc8}},
{ABTCL, ybtl, Pm, opBytes{0xba, 07, 0xbb}},
......
......@@ -1206,7 +1206,6 @@ func stacksplit(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog, newprog obj.ProgA
var unaryDst = map[obj.As]bool{
ABSWAPL: true,
ABSWAPQ: true,
ABSWAPW: true,
ACLFLUSH: true,
ACLFLUSHOPT: true,
ACMPXCHG16B: true,
......
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