Skip to content

Commit

Permalink
cmd/asm,cmd/internal/obj/x86: add RDPID instruction to x86 assembler
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
4a6f656c committed Apr 11, 2023
1 parent 0d82f58 commit 05cd6cb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/cmd/asm/internal/asm/testdata/386enc.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/cmd/asm/internal/asm/testdata/amd64enc_extra.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/cmd/asm/internal/asm/testdata/amd64error.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/cmd/internal/obj/x86/aenum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/cmd/internal/obj/x86/anames.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/cmd/internal/obj/x86/asm6.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}},
Expand Down
1 change: 1 addition & 0 deletions src/cmd/internal/obj/x86/obj6.go
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ var unaryDst = map[obj.As]bool{
ARDFSBASEQ: true,
ARDGSBASEL: true,
ARDGSBASEQ: true,
ARDPID: true,
ARDRANDL: true,
ARDRANDQ: true,
ARDRANDW: true,
Expand Down

0 comments on commit 05cd6cb

Please sign in to comment.