]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm,cmd/internal/obj/x86: add RDPID instruction to x86 assembler
authorJoel Sing <joel@sing.id.au>
Thu, 6 Apr 2023 20:15:59 +0000 (06:15 +1000)
committerJoel Sing <joel@sing.id.au>
Tue, 11 Apr 2023 18:32:50 +0000 (18:32 +0000)
Add support for the Read Processor ID (RDPID) instruction to the x86
assembler. This returns the current logical processor's ID in the
specified register, as a faster alternative to RDTSCP.

Fixes #56525

Change-Id: I43482e42431dfc385ce2e7f6d44b9746b0cc4548
Reviewed-on: https://go-review.googlesource.com/c/go/+/482955
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/asm/internal/asm/testdata/386enc.s
src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
src/cmd/asm/internal/asm/testdata/amd64error.s
src/cmd/internal/obj/x86/aenum.go
src/cmd/internal/obj/x86/anames.go
src/cmd/internal/obj/x86/asm6.go
src/cmd/internal/obj/x86/obj6.go

index 4af6de36d17b5339f0fff507185c1d626b109a8f..aacb40793e7d89e87dd16b9cb806a970fc3f2d27 100644 (file)
@@ -33,5 +33,8 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
        PUSHL FS // 0fa0
        POPL FS  // 0fa1
        POPL SS  // 17
+
+       RDPID AX                                // f30fc7f8
+
        // End of tests.
        RET
index 48bdf1bcda193674203eb7336ebae673443ddb3c..08cb20c70718033424e12e53fbbe657d03b1f158 100644 (file)
@@ -1055,5 +1055,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
        TPAUSE BX // 660faef3
        UMONITOR BX // f30faef3
        UMWAIT BX // f20faef3
+
+       RDPID DX                                // f30fc7fa
+       RDPID R11                               // f3410fc7fb
+
        // End of tests.
        RET
index 5bd335e303185fa37991568b64ad990bf2a27af7..1ca2d3147cd69cec326327e4b9b2b86374eb4352 100644 (file)
@@ -144,4 +144,7 @@ TEXT errors(SB),$0
        VMOVDQA32.Z Z0, Z1               // ERROR "mask register must be specified for .Z instructions"
        VMOVDQA32.Z Z0, K0, Z1           // ERROR "invalid instruction"
        VMOVDQA32.Z Z0, K1, Z1           // ok
+
+       RDPID (BX)                       // ERROR "invalid instruction"
+
        RET
index f0913d7c55194d823aa5e130ec546417f9564adf..79cdd241a236a3986fb831e5ea433a3b66a459bb 100644 (file)
@@ -747,6 +747,7 @@ const (
        ARDGSBASEL
        ARDGSBASEQ
        ARDMSR
+       ARDPID
        ARDPKRU
        ARDPMC
        ARDRANDL
index 7869e366f9be0f07cb7ebb8732ac74979d5f5a2f..3966381e50d221942a350bb0eb215826e2d8133b 100644 (file)
@@ -745,6 +745,7 @@ var Anames = []string{
        "RDGSBASEL",
        "RDGSBASEQ",
        "RDMSR",
+       "RDPID",
        "RDPKRU",
        "RDPMC",
        "RDRANDL",
index 0e8670c8e5d6f972beb48c9c693ea5bffc1bf42c..718da6a8a2caf61ec4da653585f0f22fdbdcc46a 100644 (file)
@@ -775,7 +775,7 @@ var ymshufb = []ytab{
 }
 
 // It should never have more than 1 entry,
-// because some optab entries you opcode secuences that
+// because some optab entries have opcode sequences that
 // are longer than 2 bytes (zoffset=2 here),
 // ROUNDPD and ROUNDPS and recently added BLENDPD,
 // to name a few.
@@ -1774,6 +1774,7 @@ var optab =
        {ALSSW, ym_rl, Pe, opBytes{0x0f, 0xb2}},
        {ALSSL, ym_rl, Px, opBytes{0x0f, 0xb2}},
        {ALSSQ, ym_rl, Pw, opBytes{0x0f, 0xb2}},
+       {ARDPID, yrdrand, Pf3, opBytes{0xc7, 07}},
 
        {ABLENDPD, yxshuf, Pq, opBytes{0x3a, 0x0d, 0}},
        {ABLENDPS, yxshuf, Pq, opBytes{0x3a, 0x0c, 0}},
index c85b5018eb4c5d595891720cab95eea4c581415d..8c9ea4f2a912c84b1519c3f27ca95a8e32bba246 100644 (file)
@@ -1476,6 +1476,7 @@ var unaryDst = map[obj.As]bool{
        ARDFSBASEQ:  true,
        ARDGSBASEL:  true,
        ARDGSBASEQ:  true,
+       ARDPID:      true,
        ARDRANDL:    true,
        ARDRANDQ:    true,
        ARDRANDW:    true,