This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Enable Intel RDPID instruction.


On Tue, May 3, 2016 at 3:26 AM, Alexander Fomin
<afomin.mailbox@gmail.com> wrote:
> Hi,
> This patch enables Intel RDPID instruction.
>
> Please refer to Intel SDM Vol. 2 (r58) for details about the instruction
> and corresponding CPUID.
>
> I've eliminated i386-init.h and i386-tbl.h from the patch as they were
> just regenerated.
>
> Any objectionis?
>
> Alexander
> ---
> gas/
>
>         * doc/c-i386.texi: Document RDPID.
>
> gas/testsuite/
>
>         * gas/i386/i386.exp: Add RDPID tests.
>         * gas/i386/prefix.d: Adjust.
>         * gas/i386/rdpid.s: New test.
>         * gas/i386/rdpid.d: Ditto.
>         * gas/i386/rdpid-intel.d: Ditto.
>         * gas/i386/x86-64-rdpid.s: Ditto.
>         * gas/i386/x86-64-rdpid.d: Ditto.
>         * gas/i386/x86-64-rdpid-intel.d: Ditto.
>
> opcodes/
>
>         * i386-dis.c (prefix_table): Add RDPID instruction.
>         * i386-gen.c (cpu_flag_init): Add RDPID flag.
>         (cpu_flags): Add RDPID bitfield.
>         * i386-opc.h (enum): Add RDPID element.
>         (i386_cpu_flags): Add RDPID field.
>         * i386-opc.tbl: Add RDPID instruction.
>         * i386-init.h: Regenerate.
>         * i386-tbl.h: Regenerate.
> ---
>  gas/doc/c-i386.texi                         |     3 +-
>  gas/testsuite/gas/i386/i386.exp             |     4 +
>  gas/testsuite/gas/i386/prefix.d             |     3 +-
>  gas/testsuite/gas/i386/rdpid-intel.d        |    11 +
>  gas/testsuite/gas/i386/rdpid.d              |    11 +
>  gas/testsuite/gas/i386/rdpid.s              |     5 +
>  gas/testsuite/gas/i386/x86-64-rdpid-intel.d |    11 +
>  gas/testsuite/gas/i386/x86-64-rdpid.d       |    11 +
>  gas/testsuite/gas/i386/x86-64-rdpid.s       |     5 +
>  opcodes/i386-dis.c                          |     2 +-
>  opcodes/i386-gen.c                          |     3 +
>  opcodes/i386-init.h                         |   223 +-
>  opcodes/i386-opc.h                          |     3 +
>  opcodes/i386-opc.tbl                        |     7 +
>  opcodes/i386-tbl.h                          | 10791 +++++++++++++-------------
>  15 files changed, 5656 insertions(+), 5437 deletions(-)
>  create mode 100644 gas/testsuite/gas/i386/rdpid-intel.d
>  create mode 100644 gas/testsuite/gas/i386/rdpid.d
>  create mode 100644 gas/testsuite/gas/i386/rdpid.s
>  create mode 100644 gas/testsuite/gas/i386/x86-64-rdpid-intel.d
>  create mode 100644 gas/testsuite/gas/i386/x86-64-rdpid.d
>  create mode 100644 gas/testsuite/gas/i386/x86-64-rdpid.s
>
> diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
> index adbcb99..edd187b 100644
> --- a/gas/doc/c-i386.texi
> +++ b/gas/doc/c-i386.texi
> @@ -153,6 +153,7 @@ accept various extension mnemonics.  For example,
>  @code{smap},
>  @code{mpx},
>  @code{sha},
> +@code{rdpid},
>  @code{prefetchwt1},
>  @code{clflushopt},
>  @code{se1},
> @@ -1173,7 +1174,7 @@ supported on the CPU specified.  The choices for @var{cpu_type} are:
>  @item @samp{.3dnow} @tab @samp{.3dnowa} @tab @samp{.sse4a} @tab @samp{.sse5}
>  @item @samp{.syscall} @tab @samp{.rdtscp} @tab @samp{.svme} @tab @samp{.abm}
>  @item @samp{.lwp} @tab @samp{.fma4} @tab @samp{.xop} @tab @samp{.cx16}
> -@item @samp{.padlock} @tab @samp{.clzero} @tab @samp{.mwaitx}
> +@item @samp{.padlock} @tab @samp{.clzero} @tab @samp{.mwaitx} @tab @samp{.rdpid}
>  @end multitable
>
>  Apart from the warning, there are only two other effects on
> diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
> index 9c4fdea..df1518b 100644
> --- a/gas/testsuite/gas/i386/i386.exp
> +++ b/gas/testsuite/gas/i386/i386.exp
> @@ -346,6 +346,8 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
>      run_dump_test "mwaitx-bdver4"
>      run_list_test "mwaitx-reg"
>      run_dump_test "ospke"
> +    run_dump_test "rdpid"
> +    run_dump_test "rdpid-intel"
>
>      # These tests require support for 8 and 16 bit relocs,
>      # so we only run them for ELF and COFF targets.
> @@ -737,6 +739,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
>      run_dump_test "x86-64-mwaitx-bdver4"
>      run_list_test "x86-64-mwaitx-reg"
>      run_dump_test "x86-64-ospke"
> +    run_dump_test "x86-64-rdpid"
> +    run_dump_test "x86-64-rdpid-intel"
>      run_dump_test "x86-64-fence-as-lock-add-yes"
>      run_dump_test "x86-64-fence-as-lock-add-no"
>
> diff --git a/gas/testsuite/gas/i386/prefix.d b/gas/testsuite/gas/i386/prefix.d
> index 7afb0c1..8dd200b 100644
> --- a/gas/testsuite/gas/i386/prefix.d
> +++ b/gas/testsuite/gas/i386/prefix.d
> @@ -63,8 +63,7 @@ Disassembly of section .text:
>  [      ]*[a-f0-9]+:    f3 f0 66 3e 36 90       lock data16 ds ss pause
>  [      ]*[a-f0-9]+:    f3 f2 67 3e 36 90       repz repnz addr16 ds ss nop
>  [      ]*[a-f0-9]+:    f3 67 f2 66 3e 36 90    repz addr16 repnz ds ss xchg %ax,%ax
> -[      ]*[a-f0-9]+:    f3 0f c7                \(bad\)
> -[      ]*[a-f0-9]+:    f8                      clc
> +[      ]*[a-f0-9]+:    f3 0f c7 f8             rdpid  %eax
>  [      ]*[a-f0-9]+:    90                      nop
>  [      ]*[a-f0-9]+:    f3 0f c7                \(bad\)
>  [      ]*[a-f0-9]+:    f0 90                   lock nop
> diff --git a/gas/testsuite/gas/i386/rdpid-intel.d b/gas/testsuite/gas/i386/rdpid-intel.d
> new file mode 100644
> index 0000000..f733b17
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/rdpid-intel.d
> @@ -0,0 +1,11 @@
> +#objdump: -dwMintel
> +#name: i386 RDPID (Intel disassembly)
> +#source: rdpid.s
> +
> +.*: +file format .*
> +
> +Disassembly of section .text:
> +
> +0+ <_start>:
> +[      ]*[a-f0-9]+:[   ]*f3 0f c7 f8[  ]*rdpid  eax
> +#pass
> diff --git a/gas/testsuite/gas/i386/rdpid.d b/gas/testsuite/gas/i386/rdpid.d
> new file mode 100644
> index 0000000..ef67c84
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/rdpid.d
> @@ -0,0 +1,11 @@
> +#objdump: -dw
> +#name: i386 RDPID insns
> +
> +.*: +file format .*
> +
> +
> +Disassembly of section .text:
> +
> +0+ <_start>:
> +[      ]*[a-f0-9]+:[   ]*f3 0f c7 f8[  ]*rdpid  %eax
> +#pass
> diff --git a/gas/testsuite/gas/i386/rdpid.s b/gas/testsuite/gas/i386/rdpid.s
> new file mode 100644
> index 0000000..fe6e401
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/rdpid.s
> @@ -0,0 +1,5 @@
> +# Check 32bit RDPID instructions.
> +
> +       .text
> +_start:
> +       rdpid %eax
> diff --git a/gas/testsuite/gas/i386/x86-64-rdpid-intel.d b/gas/testsuite/gas/i386/x86-64-rdpid-intel.d
> new file mode 100644
> index 0000000..df695ca
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/x86-64-rdpid-intel.d
> @@ -0,0 +1,11 @@
> +#objdump: -dwMintel
> +#name: x86_64 RDPID (Intel disassembly)
> +#source: x86-64-rdpid.s
> +
> +.*: +file format .*
> +
> +Disassembly of section .text:
> +
> +0+ <_start>:
> +[      ]*[a-f0-9]+:[   ]*f3 48 0f c7 f8[       ]*rdpid  rax
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

rdpid doesn't need the REX prefix.

> +#pass
> diff --git a/gas/testsuite/gas/i386/x86-64-rdpid.d b/gas/testsuite/gas/i386/x86-64-rdpid.d
> new file mode 100644
> index 0000000..ebe14fd
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/x86-64-rdpid.d
> @@ -0,0 +1,11 @@
> +#objdump: -dw
> +#name: x86_64 RDPID insns
> +
> +.*: +file format .*
> +
> +
> +Disassembly of section .text:
> +
> +0+ <_start>:
> +[      ]*[a-f0-9]+:[   ]*f3 48 0f c7 f8[       ]*rdpid  %rax
> +#pass
> diff --git a/gas/testsuite/gas/i386/x86-64-rdpid.s b/gas/testsuite/gas/i386/x86-64-rdpid.s
> new file mode 100644
> index 0000000..675ee46
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/x86-64-rdpid.s
> @@ -0,0 +1,5 @@
> +# Check 64bit RDPID instructions.
> +
> +       .text
> +_start:
> +       rdpid %rax
> diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> index 560f75c..5b55bda 100644
> --- a/opcodes/i386-dis.c
> +++ b/opcodes/i386-dis.c
> @@ -4132,7 +4132,7 @@ static const struct dis386 prefix_table[][4] = {
>    /* PREFIX_MOD_3_0FC7_REG_7 */
>    {
>      { "rdseed",        { Ev }, 0 },
> -    { Bad_Opcode },
> +    { "rdpid", { Ev }, 0 },
^^^^^^^^^^^^^^^^^^^^^^^^^^ Use Em.

This is wrong.  REX and 0x66 prefix should be ignored.

>      { "rdseed",        { Ev }, 0 },
>    },
>
> diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
> index e82954e..5b997f9 100644
> --- a/opcodes/i386-gen.c
> +++ b/opcodes/i386-gen.c
> @@ -257,6 +257,8 @@ static initializer cpu_flag_init[] =
>      "CpuMWAITX" },
>    { "CPU_OSPKE_FLAGS",
>      "CpuOSPKE" },
> +  { "CPU_RDPID_FLAGS",
> +    "CpuRDPID" }
>  };
>
>  static initializer operand_type_init[] =
> @@ -464,6 +466,7 @@ static bitfield cpu_flags[] =
>    BITFIELD (CpuMWAITX),
>    BITFIELD (CpuCLZERO),
>    BITFIELD (CpuOSPKE),
> +  BITFIELD (CpuRDPID),
>    BITFIELD (CpuAMD64),
>    BITFIELD (CpuIntel64),
>  #ifdef CpuUnused
> diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h
> index c5ca4c3..a93c1f3 100644
> --- a/opcodes/i386-opc.h
> +++ b/opcodes/i386-opc.h
> @@ -200,6 +200,8 @@ enum
>    CpuCLZERO,
>    /* OSPKE instruction required */
>    CpuOSPKE,
> +  /* RDPID instruction required */
> +  CpuRDPID,
>    /* 64bit support required  */
>    Cpu64,
>    /* Not supported in the 64bit mode  */
> @@ -311,6 +313,7 @@ typedef union i386_cpu_flags
>        unsigned int cpumwaitx:1;
>        unsigned int cpuclzero:1;
>        unsigned int cpuospke:1;
> +      unsigned int cpurdpid:1;
>        unsigned int cpu64:1;
>        unsigned int cpuno64:1;
>        unsigned int cpuamd64:1;
> diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
> index d10635c..317e8e4 100644
> --- a/opcodes/i386-opc.tbl
> +++ b/opcodes/i386-opc.tbl
> @@ -5958,3 +5958,10 @@ rdpkru, 0, 0xf01ee, None, 3, CpuOSPKE, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|N
>  wrpkru, 0, 0xf01ef, None, 3, CpuOSPKE, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { 0 }
>
>  // OSPKE instructions end.
> +
> +// RDPID instructions.
> +
> +rdpid, 1, 0xf30fc7, 0x7, 2, CpuRDPID|CpuNo64, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Reg32 }
> +rdpid, 1, 0xf30fc7, 0x7, 2, CpuRDPID|Cpu64, Modrm|IgnoreSize|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Reg64 }

Add NoRex64.

> +
> +// RDPID instructions end.
> --
> 1.8.3.1
>



-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]