]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: add x86 POPCNTW, POPCNTL
authorRuss Cox <rsc@golang.org>
Fri, 22 Jan 2016 21:25:06 +0000 (16:25 -0500)
committerRuss Cox <rsc@golang.org>
Sun, 24 Jan 2016 05:51:04 +0000 (05:51 +0000)
Fixes #4816.

Change-Id: Ibeaa69f57b7519d56df4ea357edf8d9dc2102ffe
Reviewed-on: https://go-review.googlesource.com/18851
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/asm/internal/asm/testdata/amd64enc.s
src/cmd/internal/obj/x86/asm6.go

index a24e8d3050d772a72f7eff47db9263f4b0ef30cb..ae743afe448d7e272e23d54e8856300b93018bcb 100644 (file)
@@ -4145,22 +4145,22 @@ TEXT asmtest(SB),7,$0
        POPQ DX                                 // 8fc2 or 5a
        PUSHQ AX
        POPQ R11                                // 418fc3 or 415b
-       //TODO: POPCNTW (BX), DX                // 66f30fb813
-       //TODO: POPCNTW (R11), DX               // 66f3410fb813
-       //TODO: POPCNTW DX, DX                  // 66f30fb8d2
-       //TODO: POPCNTW R11, DX                 // 66f3410fb8d3
-       //TODO: POPCNTW (BX), R11               // 66f3440fb81b
-       //TODO: POPCNTW (R11), R11              // 66f3450fb81b
-       //TODO: POPCNTW DX, R11                 // 66f3440fb8da
-       //TODO: POPCNTW R11, R11                // 66f3450fb8db
-       //TODO: POPCNTL (BX), DX                // f30fb813
-       //TODO: POPCNTL (R11), DX               // f3410fb813
-       //TODO: POPCNTL DX, DX                  // f30fb8d2
-       //TODO: POPCNTL R11, DX                 // f3410fb8d3
-       //TODO: POPCNTL (BX), R11               // f3440fb81b
-       //TODO: POPCNTL (R11), R11              // f3450fb81b
-       //TODO: POPCNTL DX, R11                 // f3440fb8da
-       //TODO: POPCNTL R11, R11                // f3450fb8db
+       POPCNTW (BX), DX                        // 66f30fb813
+       POPCNTW (R11), DX                       // 66f3410fb813
+       POPCNTW DX, DX                          // 66f30fb8d2
+       POPCNTW R11, DX                         // 66f3410fb8d3
+       POPCNTW (BX), R11                       // 66f3440fb81b
+       POPCNTW (R11), R11                      // 66f3450fb81b
+       POPCNTW DX, R11                         // 66f3440fb8da
+       POPCNTW R11, R11                        // 66f3450fb8db
+       POPCNTL (BX), DX                        // f30fb813
+       POPCNTL (R11), DX                       // f3410fb813
+       POPCNTL DX, DX                          // f30fb8d2
+       POPCNTL R11, DX                         // f3410fb8d3
+       POPCNTL (BX), R11                       // f3440fb81b
+       POPCNTL (R11), R11                      // f3450fb81b
+       POPCNTL DX, R11                         // f3440fb8da
+       POPCNTL R11, R11                        // f3450fb8db
        POPCNTQ (BX), DX                        // f3480fb813
        POPCNTQ (R11), DX                       // f3490fb813
        POPCNTQ DX, DX                          // f3480fb8d2
index f67dfa94495c40a6cdc4f4ee53576cb05e6b8136..2ffceceba94d8df2b5bcbac81e3c92e07bbc9f1a 100644 (file)
@@ -219,6 +219,7 @@ const (
        Pb    = 0xfe /* byte operands */
        Pf2   = 0xf2 /* xmm escape 1: f2 0f */
        Pf3   = 0xf3 /* xmm escape 2: f3 0f */
+       Pef3  = 0xf5 /* xmm escape 2 with 16-bit prefix: 66 f3 0f */
        Pq3   = 0x67 /* xmm escape 3: 66 48 0f */
        Pfw   = 0xf4 /* Pf3 with Rex.w: f3 48 0f */
        Pvex1 = 0xc5 /* 66.0f escape, vex encoding */
@@ -1208,6 +1209,8 @@ var optab =
        {APMULULQ, ymm, Py1, [23]uint8{0xf4, Pe, 0xf4}},
        {APOPAL, ynone, P32, [23]uint8{0x61}},
        {APOPAW, ynone, Pe, [23]uint8{0x61}},
+       {APOPCNTW, yml_rl, Pef3, [23]uint8{0xb8}},
+       {APOPCNTL, yml_rl, Pf3, [23]uint8{0xb8}},
        {APOPCNTQ, yml_rl, Pfw, [23]uint8{0xb8}},
        {APOPFL, ynone, P32, [23]uint8{0x9d}},
        {APOPFQ, ynone, Py, [23]uint8{0x9d}},
@@ -3204,6 +3207,14 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
                                ctxt.Andptr[0] = Pm
                                ctxt.Andptr = ctxt.Andptr[1:]
 
+                       case Pef3:
+                               ctxt.Andptr[0] = Pe
+                               ctxt.Andptr = ctxt.Andptr[1:]
+                               ctxt.Andptr[0] = Pf3
+                               ctxt.Andptr = ctxt.Andptr[1:]
+                               ctxt.Andptr[0] = Pm
+                               ctxt.Andptr = ctxt.Andptr[1:]
+
                        case Pfw: /* xmm opcode escape + REX.W */
                                ctxt.Rexflag |= Pw
                                ctxt.Andptr[0] = Pf3