Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
X86: Add ptwrite instruction
Browse files Browse the repository at this point in the history
Implement ptwrite instruction defined in Intel64 and IA-32 Architectures
Software Developer’s Manual, June 2016.

gas/

	* config/tc-i386.c (cpu_arch): Add .ptwrite.
	* doc/c-i386.texi: Document ptwrite and .ptwrite.
	* testsuite/gas/i386/i386.exp: Run ptwrite, ptwrite-intel,
	x86-64-ptwrite and x86-64-ptwrite-intel.
	* testsuite/gas/i386/ptwrite-intel.d: New file.
	* testsuite/gas/i386/ptwrite.d: Likewise.
	* testsuite/gas/i386/ptwrite.s: Likewise.
	* testsuite/gas/i386/x86-64-ptwrite-intel.d: Likewise.
	* testsuite/gas/i386/x86-64-ptwrite.d: Likewise.
	* testsuite/gas/i386/x86-64-ptwrite.s: Likewise.

opcodes/

	* i386-dis.c (PREFIX_MOD_0_0FAE_REG_4): New.
	(PREFIX_MOD_3_0FAE_REG_4): Likewise.
	(prefix_table): Add PREFIX_MOD_0_0FAE_REG_4 and
	PREFIX_MOD_3_0FAE_REG_4.
	(mod_table): Use PREFIX_MOD_0_0FAE_REG_4 and
	PREFIX_MOD_3_0FAE_REG_4.
	* i386-gen.c (cpu_flag_init): Add CPU_PTWRITE_FLAGS.
	(cpu_flags): Add CpuPTWRITE.
	* i386-opc.h (CpuPTWRITE): New.
	(i386_cpu_flags): Add cpuptwrite.
	* i386-opc.tbl: Add ptwrite instruction.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
  • Loading branch information
hjl-tools committed Aug 24, 2016
1 parent bb1fe4a commit 6b40c46
Show file tree
Hide file tree
Showing 17 changed files with 5,524 additions and 5,329 deletions.
13 changes: 13 additions & 0 deletions gas/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2016-08-24 H.J. Lu <[email protected]>

* config/tc-i386.c (cpu_arch): Add .ptwrite.
* doc/c-i386.texi: Document ptwrite and .ptwrite.
* testsuite/gas/i386/i386.exp: Run ptwrite, ptwrite-intel,
x86-64-ptwrite and x86-64-ptwrite-intel.
* testsuite/gas/i386/ptwrite-intel.d: New file.
* testsuite/gas/i386/ptwrite.d: Likewise.
* testsuite/gas/i386/ptwrite.s: Likewise.
* testsuite/gas/i386/x86-64-ptwrite-intel.d: Likewise.
* testsuite/gas/i386/x86-64-ptwrite.d: Likewise.
* testsuite/gas/i386/x86-64-ptwrite.s: Likewise.

2016-08-19 Tamar Christina <[email protected]>

* config/tc-arm.c (do_co_reg2c): Added constraint.
Expand Down
2 changes: 2 additions & 0 deletions gas/config/tc-i386.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ static const arch_entry cpu_arch[] =
CPU_OSPKE_FLAGS, 0 },
{ STRING_COMMA_LEN (".rdpid"), PROCESSOR_UNKNOWN,
CPU_RDPID_FLAGS, 0 },
{ STRING_COMMA_LEN (".ptwrite"), PROCESSOR_UNKNOWN,
CPU_PTWRITE_FLAGS, 0 },
};

static const noarch_entry cpu_noarch[] =
Expand Down
2 changes: 2 additions & 0 deletions gas/doc/c-i386.texi
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ accept various extension mnemonics. For example,
@code{mpx},
@code{sha},
@code{rdpid},
@code{ptwrite},
@code{prefetchwt1},
@code{clflushopt},
@code{se1},
Expand Down Expand Up @@ -1195,6 +1196,7 @@ supported on the CPU specified. The choices for @var{cpu_type} are:
@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} @tab @samp{.rdpid}
@item @samp{.ptwrite}
@end multitable

Apart from the warning, there are only two other effects on
Expand Down
4 changes: 4 additions & 0 deletions gas/testsuite/gas/i386/i386.exp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "ospke"
run_dump_test "rdpid"
run_dump_test "rdpid-intel"
run_dump_test "ptwrite"
run_dump_test "ptwrite-intel"
run_list_test "avx512vl-1" "-al"
run_list_test "avx512vl-2" "-al"

Expand Down Expand Up @@ -767,6 +769,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_dump_test "x86-64-ospke"
run_dump_test "x86-64-rdpid"
run_dump_test "x86-64-rdpid-intel"
run_dump_test "x86-64-ptwrite"
run_dump_test "x86-64-ptwrite-intel"
run_dump_test "x86-64-fence-as-lock-add-yes"
run_dump_test "x86-64-fence-as-lock-add-no"
run_dump_test "x86-64-pr20141"
Expand Down
18 changes: 18 additions & 0 deletions gas/testsuite/gas/i386/ptwrite-intel.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#as:
#objdump: -dw -Mintel
#name: i386 PTWRITE insns (Intel disassembly)
#source: ptwrite.s

.*: +file format .*


Disassembly of section \.text:

0+ <_start>:
+[a-f0-9]+: f3 0f ae e1 ptwrite ecx
+[a-f0-9]+: f3 0f ae e1 ptwrite ecx
+[a-f0-9]+: f3 0f ae 21 ptwrite DWORD PTR \[ecx\]
+[a-f0-9]+: f3 0f ae 21 ptwrite DWORD PTR \[ecx\]
+[a-f0-9]+: f3 0f ae e1 ptwrite ecx
+[a-f0-9]+: f3 0f ae 21 ptwrite DWORD PTR \[ecx\]
#pass
18 changes: 18 additions & 0 deletions gas/testsuite/gas/i386/ptwrite.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#as:
#objdump: -dw
#name: i386 PTWRITE insns
#source: ptwrite.s

.*: +file format .*


Disassembly of section \.text:

0+ <_start>:
+[a-f0-9]+: f3 0f ae e1 ptwrite %ecx
+[a-f0-9]+: f3 0f ae e1 ptwrite %ecx
+[a-f0-9]+: f3 0f ae 21 ptwritel \(%ecx\)
+[a-f0-9]+: f3 0f ae 21 ptwritel \(%ecx\)
+[a-f0-9]+: f3 0f ae e1 ptwrite %ecx
+[a-f0-9]+: f3 0f ae 21 ptwritel \(%ecx\)
#pass
12 changes: 12 additions & 0 deletions gas/testsuite/gas/i386/ptwrite.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Check 32bit PTWRITE instructions

.text
_start:
ptwrite %ecx
ptwritel %ecx
ptwrite (%ecx)
ptwritel (%ecx)

.intel_syntax noprefix
ptwrite ecx
ptwrite DWORD PTR [ecx]
23 changes: 23 additions & 0 deletions gas/testsuite/gas/i386/x86-64-ptwrite-intel.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#as:
#objdump: -dw -Mintel
#name: x86_64 PTWRITE insns (Intel disassembly)
#source: x86-64-ptwrite.s

.*: +file format .*


Disassembly of section \.text:

0+ <_start>:
+[a-f0-9]+: f3 0f ae e1 ptwrite ecx
+[a-f0-9]+: f3 0f ae e1 ptwrite ecx
+[a-f0-9]+: f3 48 0f ae e1 ptwrite rcx
+[a-f0-9]+: f3 48 0f ae e1 ptwrite rcx
+[a-f0-9]+: f3 0f ae 21 ptwrite DWORD PTR \[rcx\]
+[a-f0-9]+: f3 0f ae 21 ptwrite DWORD PTR \[rcx\]
+[a-f0-9]+: f3 48 0f ae 21 ptwrite QWORD PTR \[rcx\]
+[a-f0-9]+: f3 0f ae e1 ptwrite ecx
+[a-f0-9]+: f3 48 0f ae e1 ptwrite rcx
+[a-f0-9]+: f3 0f ae 21 ptwrite DWORD PTR \[rcx\]
+[a-f0-9]+: f3 48 0f ae 21 ptwrite QWORD PTR \[rcx\]
#pass
23 changes: 23 additions & 0 deletions gas/testsuite/gas/i386/x86-64-ptwrite.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#as:
#objdump: -dw
#name: x86_64 PTWRITE insns
#source: x86-64-ptwrite.s

.*: +file format .*


Disassembly of section \.text:

0+ <_start>:
+[a-f0-9]+: f3 0f ae e1 ptwrite %ecx
+[a-f0-9]+: f3 0f ae e1 ptwrite %ecx
+[a-f0-9]+: f3 48 0f ae e1 ptwrite %rcx
+[a-f0-9]+: f3 48 0f ae e1 ptwrite %rcx
+[a-f0-9]+: f3 0f ae 21 ptwritel \(%rcx\)
+[a-f0-9]+: f3 0f ae 21 ptwritel \(%rcx\)
+[a-f0-9]+: f3 48 0f ae 21 ptwriteq \(%rcx\)
+[a-f0-9]+: f3 0f ae e1 ptwrite %ecx
+[a-f0-9]+: f3 48 0f ae e1 ptwrite %rcx
+[a-f0-9]+: f3 0f ae 21 ptwritel \(%rcx\)
+[a-f0-9]+: f3 48 0f ae 21 ptwriteq \(%rcx\)
#pass
17 changes: 17 additions & 0 deletions gas/testsuite/gas/i386/x86-64-ptwrite.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Check 64bit PTWRITE instructions

.text
_start:
ptwrite %ecx
ptwritel %ecx
ptwrite %rcx
ptwriteq %rcx
ptwrite (%rcx)
ptwritel (%rcx)
ptwriteq (%rcx)

.intel_syntax noprefix
ptwrite ecx
ptwrite rcx
ptwrite DWORD PTR [rcx]
ptwrite QWORD PTR [rcx]
16 changes: 16 additions & 0 deletions opcodes/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2016-08-24 H.J. Lu <[email protected]>

* i386-dis.c (PREFIX_MOD_0_0FAE_REG_4): New.
(PREFIX_MOD_3_0FAE_REG_4): Likewise.
(prefix_table): Add PREFIX_MOD_0_0FAE_REG_4 and
PREFIX_MOD_3_0FAE_REG_4.
(mod_table): Use PREFIX_MOD_0_0FAE_REG_4 and
PREFIX_MOD_3_0FAE_REG_4.
* i386-gen.c (cpu_flag_init): Add CPU_PTWRITE_FLAGS.
(cpu_flags): Add CpuPTWRITE.
* i386-opc.h (CpuPTWRITE): New.
(i386_cpu_flags): Add cpuptwrite.
* i386-opc.tbl: Add ptwrite instruction.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.

2016-08-24 Anton Kolesov <[email protected]>

* arc-dis.h: Wrap around in extern "C".
Expand Down
17 changes: 16 additions & 1 deletion opcodes/i386-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,8 @@ enum
PREFIX_0FAE_REG_1,
PREFIX_0FAE_REG_2,
PREFIX_0FAE_REG_3,
PREFIX_MOD_0_0FAE_REG_4,
PREFIX_MOD_3_0FAE_REG_4,
PREFIX_0FAE_REG_6,
PREFIX_0FAE_REG_7,
PREFIX_RM_0_0FAE_REG_7,
Expand Down Expand Up @@ -4066,6 +4068,18 @@ static const struct dis386 prefix_table[][4] = {
{ "wrgsbase", { Ev }, 0 },
},

/* PREFIX_MOD_0_0FAE_REG_4 */
{
{ "xsave", { FXSAVE }, 0 },
{ "ptwrite%LQ", { Edq }, 0 },
},

/* PREFIX_MOD_3_0FAE_REG_4 */
{
{ Bad_Opcode },
{ "ptwrite%LQ", { Edq }, 0 },
},

/* PREFIX_0FAE_REG_6 */
{
{ "xsaveopt", { FXSAVE }, 0 },
Expand Down Expand Up @@ -11869,7 +11883,8 @@ static const struct dis386 mod_table[][2] = {
},
{
/* MOD_0FAE_REG_4 */
{ "xsave", { FXSAVE }, 0 },
{ PREFIX_TABLE (PREFIX_MOD_0_0FAE_REG_4) },
{ PREFIX_TABLE (PREFIX_MOD_3_0FAE_REG_4) },
},
{
/* MOD_0FAE_REG_5 */
Expand Down
3 changes: 3 additions & 0 deletions opcodes/i386-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ static initializer cpu_flag_init[] =
"CpuOSPKE" },
{ "CPU_RDPID_FLAGS",
"CpuRDPID" },
{ "CPU_PTWRITE_FLAGS",
"CpuPTWRITE" },
{ "CPU_ANY_X87_FLAGS",
"CPU_ANY_287_FLAGS|Cpu8087" },
{ "CPU_ANY_287_FLAGS",
Expand Down Expand Up @@ -511,6 +513,7 @@ static bitfield cpu_flags[] =
BITFIELD (CpuCLZERO),
BITFIELD (CpuOSPKE),
BITFIELD (CpuRDPID),
BITFIELD (CpuPTWRITE),
BITFIELD (CpuRegMMX),
BITFIELD (CpuRegXMM),
BITFIELD (CpuRegYMM),
Expand Down
Loading

0 comments on commit 6b40c46

Please sign in to comment.