Skip to content

Commit 7f620a5

Browse files
committed
cmd/asm: add x86 POPCNTW, POPCNTL
Fixes #4816. Change-Id: Ibeaa69f57b7519d56df4ea357edf8d9dc2102ffe Reviewed-on: https://go-review.googlesource.com/18851 Reviewed-by: Rob Pike <[email protected]> Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 659c632 commit 7f620a5

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

src/cmd/asm/internal/asm/testdata/amd64enc.s

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4145,22 +4145,22 @@ TEXT asmtest(SB),7,$0
41454145
POPQ DX // 8fc2 or 5a
41464146
PUSHQ AX
41474147
POPQ R11 // 418fc3 or 415b
4148-
//TODO: POPCNTW (BX), DX // 66f30fb813
4149-
//TODO: POPCNTW (R11), DX // 66f3410fb813
4150-
//TODO: POPCNTW DX, DX // 66f30fb8d2
4151-
//TODO: POPCNTW R11, DX // 66f3410fb8d3
4152-
//TODO: POPCNTW (BX), R11 // 66f3440fb81b
4153-
//TODO: POPCNTW (R11), R11 // 66f3450fb81b
4154-
//TODO: POPCNTW DX, R11 // 66f3440fb8da
4155-
//TODO: POPCNTW R11, R11 // 66f3450fb8db
4156-
//TODO: POPCNTL (BX), DX // f30fb813
4157-
//TODO: POPCNTL (R11), DX // f3410fb813
4158-
//TODO: POPCNTL DX, DX // f30fb8d2
4159-
//TODO: POPCNTL R11, DX // f3410fb8d3
4160-
//TODO: POPCNTL (BX), R11 // f3440fb81b
4161-
//TODO: POPCNTL (R11), R11 // f3450fb81b
4162-
//TODO: POPCNTL DX, R11 // f3440fb8da
4163-
//TODO: POPCNTL R11, R11 // f3450fb8db
4148+
POPCNTW (BX), DX // 66f30fb813
4149+
POPCNTW (R11), DX // 66f3410fb813
4150+
POPCNTW DX, DX // 66f30fb8d2
4151+
POPCNTW R11, DX // 66f3410fb8d3
4152+
POPCNTW (BX), R11 // 66f3440fb81b
4153+
POPCNTW (R11), R11 // 66f3450fb81b
4154+
POPCNTW DX, R11 // 66f3440fb8da
4155+
POPCNTW R11, R11 // 66f3450fb8db
4156+
POPCNTL (BX), DX // f30fb813
4157+
POPCNTL (R11), DX // f3410fb813
4158+
POPCNTL DX, DX // f30fb8d2
4159+
POPCNTL R11, DX // f3410fb8d3
4160+
POPCNTL (BX), R11 // f3440fb81b
4161+
POPCNTL (R11), R11 // f3450fb81b
4162+
POPCNTL DX, R11 // f3440fb8da
4163+
POPCNTL R11, R11 // f3450fb8db
41644164
POPCNTQ (BX), DX // f3480fb813
41654165
POPCNTQ (R11), DX // f3490fb813
41664166
POPCNTQ DX, DX // f3480fb8d2

src/cmd/internal/obj/x86/asm6.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ const (
219219
Pb = 0xfe /* byte operands */
220220
Pf2 = 0xf2 /* xmm escape 1: f2 0f */
221221
Pf3 = 0xf3 /* xmm escape 2: f3 0f */
222+
Pef3 = 0xf5 /* xmm escape 2 with 16-bit prefix: 66 f3 0f */
222223
Pq3 = 0x67 /* xmm escape 3: 66 48 0f */
223224
Pfw = 0xf4 /* Pf3 with Rex.w: f3 48 0f */
224225
Pvex1 = 0xc5 /* 66.0f escape, vex encoding */
@@ -1208,6 +1209,8 @@ var optab =
12081209
{APMULULQ, ymm, Py1, [23]uint8{0xf4, Pe, 0xf4}},
12091210
{APOPAL, ynone, P32, [23]uint8{0x61}},
12101211
{APOPAW, ynone, Pe, [23]uint8{0x61}},
1212+
{APOPCNTW, yml_rl, Pef3, [23]uint8{0xb8}},
1213+
{APOPCNTL, yml_rl, Pf3, [23]uint8{0xb8}},
12111214
{APOPCNTQ, yml_rl, Pfw, [23]uint8{0xb8}},
12121215
{APOPFL, ynone, P32, [23]uint8{0x9d}},
12131216
{APOPFQ, ynone, Py, [23]uint8{0x9d}},
@@ -3204,6 +3207,14 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
32043207
ctxt.Andptr[0] = Pm
32053208
ctxt.Andptr = ctxt.Andptr[1:]
32063209

3210+
case Pef3:
3211+
ctxt.Andptr[0] = Pe
3212+
ctxt.Andptr = ctxt.Andptr[1:]
3213+
ctxt.Andptr[0] = Pf3
3214+
ctxt.Andptr = ctxt.Andptr[1:]
3215+
ctxt.Andptr[0] = Pm
3216+
ctxt.Andptr = ctxt.Andptr[1:]
3217+
32073218
case Pfw: /* xmm opcode escape + REX.W */
32083219
ctxt.Rexflag |= Pw
32093220
ctxt.Andptr[0] = Pf3

0 commit comments

Comments
 (0)