blob: 013a2c01d2c660445cd0ee61aaa8ac80d0e92c2d [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86InstrSystem.td - System Instructions ------------*- tablegen -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Jia Liub22310f2012-02-18 12:03:15 +00006//
Chris Lattnerdec85b82010-10-05 05:32:15 +00007//===----------------------------------------------------------------------===//
8//
9// This file describes the X86 instructions that are generally used in
10// privileged modes. These are not typically used by the compiler, but are
11// supported for the assembler and disassembler.
12//
13//===----------------------------------------------------------------------===//
14
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000015let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000016let Defs = [RAX, RDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000017 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000018
19let Defs = [RAX, RCX, RDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000020 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", [(X86rdtscp)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000021
22// CPU flow control instructions
23
Joel Galenson06e7e572018-07-13 15:19:33 +000024let mayLoad = 1, mayStore = 0, hasSideEffects = 1, isTrap = 1 in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +000025 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Kevin Enderby5e7cb5f2010-10-27 20:46:49 +000026 def UD2B : I<0xB9, RawFrm, (outs), (ins), "ud2b", []>, TB;
27}
Chris Lattnerdec85b82010-10-05 05:32:15 +000028
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000029def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
30def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000031
32// Interrupt and SysCall Instructions.
33let Uses = [EFLAGS] in
Andrew V. Tischenko92980ce2017-09-20 08:17:17 +000034 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000035
36def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", [(int_x86_int (i8 3))]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000037} // SchedRW
Chris Lattnerfc4fe002011-04-09 19:41:05 +000038
39// The long form of "int $3" turns into int3 as a size optimization.
40// FIXME: This doesn't work because InstAlias can't match immediate constants.
41//def : InstAlias<"int\t$3", (INT3)>;
42
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000043let SchedRW = [WriteSystem] in {
Chris Lattnerfc4fe002011-04-09 19:41:05 +000044
Craig Topper87990ee2015-10-11 18:27:24 +000045def INT : Ii8<0xcd, RawFrm, (outs), (ins u8imm:$trap), "int\t$trap",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000046 [(int_x86_int imm:$trap)]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000047
Chris Lattnerfc4fe002011-04-09 19:41:05 +000048
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000049def SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", []>, TB;
50def SYSRET : I<0x07, RawFrm, (outs), (ins), "sysret{l}", []>, TB;
Craig Topper57315582018-04-29 22:55:54 +000051def SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysretq", []>, TB,
Chris Lattnerae33f5d2010-10-05 06:04:14 +000052 Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000053
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000054def SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", []>, TB;
Preston Gurdd6c440c2012-05-04 19:26:37 +000055
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000056def SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", []>, TB;
Craig Topper57315582018-04-29 22:55:54 +000057def SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexitq", []>, TB,
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000058 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000059} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +000060
Alex Rosenbergb9fefdd2015-01-26 19:09:27 +000061def : Pat<(debugtrap),
62 (INT3)>, Requires<[NotPS4]>;
63def : Pat<(debugtrap),
64 (INT (i8 0x41))>, Requires<[IsPS4]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000065
66//===----------------------------------------------------------------------===//
67// Input/Output Instructions.
68//
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000069let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000070let Defs = [AL], Uses = [DX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000071def IN8rr : I<0xEC, RawFrm, (outs), (ins), "in{b}\t{%dx, %al|al, dx}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000072let Defs = [AX], Uses = [DX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000073def IN16rr : I<0xED, RawFrm, (outs), (ins), "in{w}\t{%dx, %ax|ax, dx}", []>,
74 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000075let Defs = [EAX], Uses = [DX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000076def IN32rr : I<0xED, RawFrm, (outs), (ins), "in{l}\t{%dx, %eax|eax, dx}", []>,
77 OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000078
79let Defs = [AL] in
Craig Topper5be914e2015-10-12 04:17:55 +000080def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000081 "in{b}\t{$port, %al|al, $port}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000082let Defs = [AX] in
Craig Topper5be914e2015-10-12 04:17:55 +000083def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000084 "in{w}\t{$port, %ax|ax, $port}", []>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000085let Defs = [EAX] in
Craig Topper5be914e2015-10-12 04:17:55 +000086def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000087 "in{l}\t{$port, %eax|eax, $port}", []>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000088
89let Uses = [DX, AL] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000090def OUT8rr : I<0xEE, RawFrm, (outs), (ins), "out{b}\t{%al, %dx|dx, al}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000091let Uses = [DX, AX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000092def OUT16rr : I<0xEF, RawFrm, (outs), (ins), "out{w}\t{%ax, %dx|dx, ax}", []>,
93 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000094let Uses = [DX, EAX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000095def OUT32rr : I<0xEF, RawFrm, (outs), (ins), "out{l}\t{%eax, %dx|dx, eax}", []>,
96 OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000097
98let Uses = [AL] in
Craig Topper5be914e2015-10-12 04:17:55 +000099def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000100 "out{b}\t{%al, $port|$port, al}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000101let Uses = [AX] in
Craig Topper5be914e2015-10-12 04:17:55 +0000102def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000103 "out{w}\t{%ax, $port|$port, ax}", []>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000104let Uses = [EAX] in
Craig Topper5be914e2015-10-12 04:17:55 +0000105def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000106 "out{l}\t{%eax, $port|$port, eax}", []>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000107
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000108} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000109
110//===----------------------------------------------------------------------===//
111// Moves to and from debug registers
112
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000113let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000114def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000115 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000116 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000117def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000118 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000119 Requires<[In64BitMode]>;
120
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000121def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000122 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000123 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000124def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000125 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000126 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000127} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000128
129//===----------------------------------------------------------------------===//
130// Moves to and from control registers
131
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000132let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000133def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000134 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000135 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000136def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000137 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000138 Requires<[In64BitMode]>;
139
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000140def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000141 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000142 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000143def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000144 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000145 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000146} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000147
148//===----------------------------------------------------------------------===//
149// Segment override instruction prefixes
150
Simon Pilgrimdf702102017-12-09 16:58:34 +0000151let SchedRW = [WriteNop] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000152def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
153def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
154def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
155def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
156def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
157def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
Simon Pilgrimdf702102017-12-09 16:58:34 +0000158} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000159
160//===----------------------------------------------------------------------===//
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000161// Moves to and from segment registers.
162//
163
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000164let SchedRW = [WriteMove] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000165def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000166 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000167def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000168 "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000169def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000170 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000171let mayStore = 1 in {
Craig Topper955308f2016-03-13 02:56:31 +0000172def MOV16ms : I<0x8C, MRMDestMem, (outs), (ins i16mem:$dst, SEGMENT_REG:$src),
Craig Topper2a283362018-04-22 01:24:58 +0000173 "mov{w}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000174}
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000175def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000176 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000177def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000178 "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000179def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000180 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000181let mayLoad = 1 in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000182def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
Craig Topper2a283362018-04-22 01:24:58 +0000183 "mov{w}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000184}
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000185} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000186
187//===----------------------------------------------------------------------===//
Chris Lattnerdec85b82010-10-05 05:32:15 +0000188// Segmentation support instructions.
189
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000190let SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000191def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000192
Ayman Musa62d1c712017-04-13 10:03:45 +0000193let mayLoad = 1 in
Michael Liao5bf95782014-12-04 05:20:33 +0000194def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000195 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000196 OpSize16, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000197def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000198 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000199 OpSize16, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000200
201// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000202let mayLoad = 1 in
Michael Liao5bf95782014-12-04 05:20:33 +0000203def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000204 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000205 OpSize32, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000206def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000207 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000208 OpSize32, NotMemoryFoldable;
Craig Topper386cfa02018-02-15 01:21:53 +0000209// i16mem operand in LAR64rm and GR32 operand in LAR64rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000210let mayLoad = 1 in
Michael Liao5bf95782014-12-04 05:20:33 +0000211def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000212 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000213def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000214 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000215
Craig Topper386cfa02018-02-15 01:21:53 +0000216// i16mem operand in LSL32rm and GR32 operand in LSL32rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000217let mayLoad = 1 in
Chris Lattnerdec85b82010-10-05 05:32:15 +0000218def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000219 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000220 OpSize16, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000221def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000222 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000223 OpSize16, NotMemoryFoldable;
Craig Topper386cfa02018-02-15 01:21:53 +0000224// i16mem operand in LSL64rm and GR32 operand in LSL64rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000225let mayLoad = 1 in
Craig Topper386cfa02018-02-15 01:21:53 +0000226def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000227 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000228 OpSize32, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000229def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000230 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000231 OpSize32, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000232let mayLoad = 1 in
Craig Topper386cfa02018-02-15 01:21:53 +0000233def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000234 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Craig Topper386cfa02018-02-15 01:21:53 +0000235def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000236 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000237
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000238def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000239
Eli Friedmanf63614a2011-03-04 00:10:17 +0000240def STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000241 "str{w}\t$dst", []>, TB, OpSize16;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000242def STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000243 "str{l}\t$dst", []>, TB, OpSize32;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000244def STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000245 "str{q}\t$dst", []>, TB;
Ayman Musa62d1c712017-04-13 10:03:45 +0000246let mayStore = 1 in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000247def STRm : I<0x00, MRM1m, (outs), (ins i16mem:$dst), "str{w}\t$dst", []>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000248
Craig Topper66572df2018-06-12 04:34:59 +0000249def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000250let mayLoad = 1 in
Craig Topper66572df2018-06-12 04:34:59 +0000251def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable;
Michael Liao5bf95782014-12-04 05:20:33 +0000252
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000253def PUSHCS16 : I<0x0E, RawFrm, (outs), (ins), "push{w}\t{%cs|cs}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000254 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000255def PUSHCS32 : I<0x0E, RawFrm, (outs), (ins), "push{l}\t{%cs|cs}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000256 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000257def PUSHSS16 : I<0x16, RawFrm, (outs), (ins), "push{w}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000258 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000259def PUSHSS32 : I<0x16, RawFrm, (outs), (ins), "push{l}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000260 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000261def PUSHDS16 : I<0x1E, RawFrm, (outs), (ins), "push{w}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000262 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000263def PUSHDS32 : I<0x1E, RawFrm, (outs), (ins), "push{l}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000264 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000265def PUSHES16 : I<0x06, RawFrm, (outs), (ins), "push{w}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000266 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000267def PUSHES32 : I<0x06, RawFrm, (outs), (ins), "push{l}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000268 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000269def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins), "push{w}\t{%fs|fs}", []>,
270 OpSize16, TB;
271def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins), "push{l}\t{%fs|fs}", []>, TB,
272 OpSize32, Requires<[Not64BitMode]>;
273def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins), "push{w}\t{%gs|gs}", []>,
274 OpSize16, TB;
275def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins), "push{l}\t{%gs|gs}", []>, TB,
276 OpSize32, Requires<[Not64BitMode]>;
277def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), "push{q}\t{%fs|fs}", []>, TB,
278 OpSize32, Requires<[In64BitMode]>;
279def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), "push{q}\t{%gs|gs}", []>, TB,
280 OpSize32, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000281
282// No "pop cs" instruction.
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000283def POPSS16 : I<0x17, RawFrm, (outs), (ins), "pop{w}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000284 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000285def POPSS32 : I<0x17, RawFrm, (outs), (ins), "pop{l}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000286 OpSize32, Requires<[Not64BitMode]>;
287
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000288def POPDS16 : I<0x1F, RawFrm, (outs), (ins), "pop{w}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000289 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000290def POPDS32 : I<0x1F, RawFrm, (outs), (ins), "pop{l}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000291 OpSize32, Requires<[Not64BitMode]>;
292
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000293def POPES16 : I<0x07, RawFrm, (outs), (ins), "pop{w}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000294 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000295def POPES32 : I<0x07, RawFrm, (outs), (ins), "pop{l}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000296 OpSize32, Requires<[Not64BitMode]>;
297
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000298def POPFS16 : I<0xa1, RawFrm, (outs), (ins), "pop{w}\t{%fs|fs}", []>,
299 OpSize16, TB;
300def POPFS32 : I<0xa1, RawFrm, (outs), (ins), "pop{l}\t{%fs|fs}", []>, TB,
301 OpSize32, Requires<[Not64BitMode]>;
302def POPFS64 : I<0xa1, RawFrm, (outs), (ins), "pop{q}\t{%fs|fs}", []>, TB,
303 OpSize32, Requires<[In64BitMode]>;
Craig Topper6872fd32014-02-18 08:18:29 +0000304
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000305def POPGS16 : I<0xa9, RawFrm, (outs), (ins), "pop{w}\t{%gs|gs}", []>,
306 OpSize16, TB;
307def POPGS32 : I<0xa9, RawFrm, (outs), (ins), "pop{l}\t{%gs|gs}", []>, TB,
308 OpSize32, Requires<[Not64BitMode]>;
309def POPGS64 : I<0xa9, RawFrm, (outs), (ins), "pop{q}\t{%gs|gs}", []>, TB,
310 OpSize32, Requires<[In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000311
312def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000313 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
Craig Topperb9c932f2016-01-26 06:10:15 +0000314 Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000315def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000316 "lds{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
Craig Topperb9c932f2016-01-26 06:10:15 +0000317 Requires<[Not64BitMode]>;
Michael Liao5bf95782014-12-04 05:20:33 +0000318
Craig Topper33dc01d2018-05-01 04:42:00 +0000319def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000320 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
Craig Topper33dc01d2018-05-01 04:42:00 +0000321def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000322 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
Craig Topper33dc01d2018-05-01 04:42:00 +0000323def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000324 "lss{q}\t{$src, $dst|$dst, $src}", []>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000325
Craig Topper33dc01d2018-05-01 04:42:00 +0000326def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000327 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
Craig Topperb9c932f2016-01-26 06:10:15 +0000328 Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000329def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000330 "les{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
Craig Topperb9c932f2016-01-26 06:10:15 +0000331 Requires<[Not64BitMode]>;
Michael Liao5bf95782014-12-04 05:20:33 +0000332
Craig Topper33dc01d2018-05-01 04:42:00 +0000333def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000334 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
Craig Topper33dc01d2018-05-01 04:42:00 +0000335def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000336 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
Craig Topper33dc01d2018-05-01 04:42:00 +0000337def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000338 "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000339
Craig Topper33dc01d2018-05-01 04:42:00 +0000340def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000341 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
Craig Topper33dc01d2018-05-01 04:42:00 +0000342def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000343 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
Michael Liao5bf95782014-12-04 05:20:33 +0000344
Craig Topper33dc01d2018-05-01 04:42:00 +0000345def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000346 "lgs{q}\t{$src, $dst|$dst, $src}", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000347
Craig Topper66572df2018-06-12 04:34:59 +0000348def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable;
349def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000350let mayLoad = 1 in {
Craig Topper66572df2018-06-12 04:34:59 +0000351def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable;
352def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000353}
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000354} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000355
356//===----------------------------------------------------------------------===//
357// Descriptor-table support instructions
358
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000359let SchedRW = [WriteSystem] in {
Craig Topper33dc01d2018-05-01 04:42:00 +0000360def SGDT16m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000361 "sgdtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000362def SGDT32m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000363 "sgdt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000364def SGDT64m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000365 "sgdt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000366def SIDT16m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000367 "sidtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000368def SIDT32m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000369 "sidt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000370def SIDT64m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000371 "sidt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000372def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000373 "sldt{w}\t$dst", []>, TB, OpSize16;
Ayman Musa62d1c712017-04-13 10:03:45 +0000374let mayStore = 1 in
Craig Topper955308f2016-03-13 02:56:31 +0000375def SLDT16m : I<0x00, MRM0m, (outs), (ins i16mem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000376 "sldt{w}\t$dst", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000377def SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000378 "sldt{l}\t$dst", []>, OpSize32, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000379
Chris Lattnerc184a572010-10-05 06:22:35 +0000380// LLDT is not interpreted specially in 64-bit mode because there is no sign
381// extension.
382def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000383 "sldt{q}\t$dst", []>, TB, Requires<[In64BitMode]>;
Chris Lattnerc184a572010-10-05 06:22:35 +0000384
Craig Topper33dc01d2018-05-01 04:42:00 +0000385def LGDT16m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000386 "lgdtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000387def LGDT32m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000388 "lgdt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000389def LGDT64m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000390 "lgdt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000391def LIDT16m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000392 "lidtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000393def LIDT32m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000394 "lidt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000395def LIDT64m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000396 "lidt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000397def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000398 "lldt{w}\t$src", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000399let mayLoad = 1 in
Chris Lattnerdec85b82010-10-05 05:32:15 +0000400def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000401 "lldt{w}\t$src", []>, TB, NotMemoryFoldable;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000402} // SchedRW
403
Chris Lattnerdec85b82010-10-05 05:32:15 +0000404//===----------------------------------------------------------------------===//
405// Specialized register support
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000406let SchedRW = [WriteSystem] in {
Craig Toppere169c572015-02-07 23:36:51 +0000407let Uses = [EAX, ECX, EDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000408def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
Craig Toppere169c572015-02-07 23:36:51 +0000409let Defs = [EAX, EDX], Uses = [ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000410def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
Andrea Di Biagio53b68302014-06-30 17:14:21 +0000411
412let Defs = [RAX, RDX], Uses = [ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000413 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", [(X86rdpmc)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000414
Michael Liao5bf95782014-12-04 05:20:33 +0000415def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000416 "smsw{w}\t$dst", []>, OpSize16, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000417def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000418 "smsw{l}\t$dst", []>, OpSize32, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000419// no m form encodable; use SMSW16m
Michael Liao5bf95782014-12-04 05:20:33 +0000420def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000421 "smsw{q}\t$dst", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000422
423// For memory operands, there is only a 16-bit form
Craig Topper955308f2016-03-13 02:56:31 +0000424def SMSW16m : I<0x01, MRM4m, (outs), (ins i16mem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000425 "smsw{w}\t$dst", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000426
427def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000428 "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000429let mayLoad = 1 in
Chris Lattnerdec85b82010-10-05 05:32:15 +0000430def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000431 "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
Reid Klecknerb2340d42014-01-28 02:08:22 +0000432
433let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000434 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000435} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000436
437//===----------------------------------------------------------------------===//
438// Cache instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000439let SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000440def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
Gabor Buella297c1382018-04-12 18:38:18 +0000441def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB;
Gabor Buella2ef36f32018-04-11 20:01:57 +0000442
443// wbnoinvd is like wbinvd, except without invalidation
444// encoding: like wbinvd + an 0xF3 prefix
445def WBNOINVD : I<0x09, RawFrm, (outs), (ins), "wbnoinvd",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000446 [(int_x86_wbnoinvd)]>, XS,
Gabor Buella2ef36f32018-04-11 20:01:57 +0000447 Requires<[HasWBNOINVD]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000448} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000449
Craig Topperd9cfddc2011-10-07 07:02:24 +0000450//===----------------------------------------------------------------------===//
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000451// CET instructions
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000452// Use with caution, availability is not predicated on features.
453let SchedRW = [WriteSystem] in {
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000454 let Uses = [SSP] in {
455 let Defs = [SSP] in {
456 def INCSSPD : I<0xAE, MRM5r, (outs), (ins GR32:$src), "incsspd\t$src",
457 [(int_x86_incsspd GR32:$src)]>, XS;
458 def INCSSPQ : RI<0xAE, MRM5r, (outs), (ins GR64:$src), "incsspq\t$src",
Craig Topper365e8aa2017-12-15 19:01:48 +0000459 [(int_x86_incsspq GR64:$src)]>, XS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000460 } // Defs SSP
461
462 let Constraints = "$src = $dst" in {
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000463 def RDSSPD : I<0x1E, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000464 "rdsspd\t$dst",
465 [(set GR32:$dst, (int_x86_rdsspd GR32:$src))]>, XS;
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000466 def RDSSPQ : RI<0x1E, MRM1r, (outs GR64:$dst), (ins GR64:$src),
467 "rdsspq\t$dst",
Craig Topper365e8aa2017-12-15 19:01:48 +0000468 [(set GR64:$dst, (int_x86_rdsspq GR64:$src))]>, XS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000469 }
470
471 let Defs = [SSP] in {
472 def SAVEPREVSSP : I<0x01, MRM_EA, (outs), (ins), "saveprevssp",
473 [(int_x86_saveprevssp)]>, XS;
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000474 def RSTORSSP : I<0x01, MRM5m, (outs), (ins i32mem:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000475 "rstorssp\t$src",
476 [(int_x86_rstorssp addr:$src)]>, XS;
477 } // Defs SSP
478 } // Uses SSP
479
480 def WRSSD : I<0xF6, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
481 "wrssd\t{$src, $dst|$dst, $src}",
Craig Topper365e8aa2017-12-15 19:01:48 +0000482 [(int_x86_wrssd GR32:$src, addr:$dst)]>, T8PS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000483 def WRSSQ : RI<0xF6, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
484 "wrssq\t{$src, $dst|$dst, $src}",
Craig Topper365e8aa2017-12-15 19:01:48 +0000485 [(int_x86_wrssq GR64:$src, addr:$dst)]>, T8PS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000486 def WRUSSD : I<0xF5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
487 "wrussd\t{$src, $dst|$dst, $src}",
488 [(int_x86_wrussd GR32:$src, addr:$dst)]>, T8PD;
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000489 def WRUSSQ : RI<0xF5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000490 "wrussq\t{$src, $dst|$dst, $src}",
Craig Topper365e8aa2017-12-15 19:01:48 +0000491 [(int_x86_wrussq GR64:$src, addr:$dst)]>, T8PD;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000492
493 let Defs = [SSP] in {
494 let Uses = [SSP] in {
495 def SETSSBSY : I<0x01, MRM_E8, (outs), (ins), "setssbsy",
496 [(int_x86_setssbsy)]>, XS;
497 } // Uses SSP
498
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000499 def CLRSSBSY : I<0xAE, MRM6m, (outs), (ins i32mem:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000500 "clrssbsy\t$src",
501 [(int_x86_clrssbsy addr:$src)]>, XS;
502 } // Defs SSP
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000503} // SchedRW
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000504
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000505let SchedRW = [WriteSystem] in {
Oren Ben Simhon1c6308e2018-01-09 08:51:18 +0000506 def ENDBR64 : I<0x1E, MRM_FA, (outs), (ins), "endbr64", []>, XS;
507 def ENDBR32 : I<0x1E, MRM_FB, (outs), (ins), "endbr32", []>, XS;
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000508} // SchedRW
Oren Ben Simhon1c6308e2018-01-09 08:51:18 +0000509
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000510//===----------------------------------------------------------------------===//
Craig Topperd9cfddc2011-10-07 07:02:24 +0000511// XSAVE instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000512let SchedRW = [WriteSystem] in {
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000513let Predicates = [HasXSAVE] in {
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000514let Defs = [EDX, EAX], Uses = [ECX] in
Rafael Espindolae3906212011-02-22 00:35:18 +0000515 def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB;
516
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000517let Uses = [EDX, EAX, ECX] in
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000518 def XSETBV : I<0x01, MRM_D1, (outs), (ins),
519 "xsetbv",
Guy Blank722caeb2016-08-16 06:41:00 +0000520 [(int_x86_xsetbv ECX, EDX, EAX)]>, TB;
521
522} // HasXSAVE
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000523
524let Uses = [EDX, EAX] in {
Craig Topper33dc01d2018-05-01 04:42:00 +0000525def XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000526 "xsave\t$dst",
527 [(int_x86_xsave addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000528def XSAVE64 : RI<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000529 "xsave64\t$dst",
530 [(int_x86_xsave64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000531def XRSTOR : I<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000532 "xrstor\t$dst",
533 [(int_x86_xrstor addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000534def XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000535 "xrstor64\t$dst",
536 [(int_x86_xrstor64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000537def XSAVEOPT : I<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000538 "xsaveopt\t$dst",
539 [(int_x86_xsaveopt addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000540def XSAVEOPT64 : RI<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000541 "xsaveopt64\t$dst",
542 [(int_x86_xsaveopt64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000543def XSAVEC : I<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000544 "xsavec\t$dst",
545 [(int_x86_xsavec addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000546def XSAVEC64 : RI<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000547 "xsavec64\t$dst",
548 [(int_x86_xsavec64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000549def XSAVES : I<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000550 "xsaves\t$dst",
551 [(int_x86_xsaves addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000552def XSAVES64 : RI<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000553 "xsaves64\t$dst",
554 [(int_x86_xsaves64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000555def XRSTORS : I<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000556 "xrstors\t$dst",
557 [(int_x86_xrstors addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000558def XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000559 "xrstors64\t$dst",
560 [(int_x86_xrstors64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES, In64BitMode]>;
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000561} // Uses
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000562} // SchedRW
Craig Topperbf136762011-10-07 05:53:50 +0000563
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000564//===----------------------------------------------------------------------===//
565// VIA PadLock crypto instructions
Simon Pilgrim4ba33142017-12-08 16:06:40 +0000566let Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in
Craig Topper0d1fd552014-02-19 05:34:21 +0000567 def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000568
Joerg Sonnenberger91e56622011-06-30 01:38:03 +0000569def : InstAlias<"xstorerng", (XSTORE)>;
570
Simon Pilgrim4ba33142017-12-08 16:06:40 +0000571let SchedRW = [WriteSystem] in {
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000572let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
Craig Topper0d1fd552014-02-19 05:34:21 +0000573 def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB;
574 def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB;
575 def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB;
576 def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB;
577 def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000578}
579
580let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
Craig Topper0d1fd552014-02-19 05:34:21 +0000581 def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB;
582 def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000583}
584let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
Craig Topper0d1fd552014-02-19 05:34:21 +0000585 def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB;
Simon Pilgrim4ba33142017-12-08 16:06:40 +0000586} // SchedRW
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000587
Asaf Badouh9a5a83a2015-12-24 08:25:00 +0000588//==-----------------------------------------------------------------------===//
589// PKU - enable protection key
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000590let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
Asaf Badouhaf6569a2015-12-31 08:31:13 +0000591 def WRPKRU : PseudoI<(outs), (ins GR32:$src),
592 [(int_x86_wrpkru GR32:$src)]>;
593 def RDPKRU : PseudoI<(outs GR32:$dst), (ins),
594 [(set GR32:$dst, (int_x86_rdpkru))]>;
595}
596
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000597let SchedRW = [WriteSystem] in {
Zvi Rackoverb346eaa2016-06-18 19:13:38 +0000598let Defs = [EAX, EDX], Uses = [ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000599 def RDPKRUr : I<0x01, MRM_EE, (outs), (ins), "rdpkru", []>, TB;
Asaf Badouh9a5a83a2015-12-24 08:25:00 +0000600let Uses = [EAX, ECX, EDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000601 def WRPKRUr : I<0x01, MRM_EF, (outs), (ins), "wrpkru", []>, TB;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000602} // SchedRW
Craig Topperd9cfddc2011-10-07 07:02:24 +0000603
604//===----------------------------------------------------------------------===//
605// FS/GS Base Instructions
Simon Pilgrim7e636cc2017-12-09 20:42:27 +0000606let Predicates = [HasFSGSBase, In64BitMode], SchedRW = [WriteSystem] in {
Craig Topperd9cfddc2011-10-07 07:02:24 +0000607 def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000608 "rdfsbase{l}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000609 [(set GR32:$dst, (int_x86_rdfsbase_32))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000610 def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000611 "rdfsbase{q}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000612 [(set GR64:$dst, (int_x86_rdfsbase_64))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000613 def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000614 "rdgsbase{l}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000615 [(set GR32:$dst, (int_x86_rdgsbase_32))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000616 def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000617 "rdgsbase{q}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000618 [(set GR64:$dst, (int_x86_rdgsbase_64))]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000619 def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
620 "wrfsbase{l}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000621 [(int_x86_wrfsbase_32 GR32:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000622 def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
623 "wrfsbase{q}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000624 [(int_x86_wrfsbase_64 GR64:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000625 def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
626 "wrgsbase{l}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000627 [(int_x86_wrgsbase_32 GR32:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000628 def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
629 "wrgsbase{q}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000630 [(int_x86_wrgsbase_64 GR64:$src)]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000631}
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000632
633//===----------------------------------------------------------------------===//
634// INVPCID Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000635let SchedRW = [WriteSystem] in {
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000636def INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000637 "invpcid\t{$src2, $src1|$src1, $src2}",
638 [(int_x86_invpcid GR32:$src1, addr:$src2)]>, T8PD,
639 Requires<[Not64BitMode, HasINVPCID]>;
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000640def INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000641 "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD,
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000642 Requires<[In64BitMode, HasINVPCID]>;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000643} // SchedRW
Michael Liao95d944032013-04-11 04:52:28 +0000644
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000645let Predicates = [In64BitMode, HasINVPCID] in {
646 // The instruction can only use a 64 bit register as the register argument
647 // in 64 bit mode, while the intrinsic only accepts a 32 bit argument
648 // corresponding to it.
649 // The accepted values for now are 0,1,2,3 anyways (see Intel SDM -- INVCPID
650 // type),/ so it doesn't hurt us that one can't supply a 64 bit value here.
651 def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2),
652 (INVPCID64
653 (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit),
654 addr:$src2)>;
655}
656
657
Michael Liao95d944032013-04-11 04:52:28 +0000658//===----------------------------------------------------------------------===//
659// SMAP Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000660let Defs = [EFLAGS], SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000661 def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, TB;
662 def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, TB;
Michael Liao95d944032013-04-11 04:52:28 +0000663}
Craig Topper1d472db2015-02-07 23:36:36 +0000664
665//===----------------------------------------------------------------------===//
666// SMX Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000667let SchedRW = [WriteSystem] in {
Craig Topper1d472db2015-02-07 23:36:36 +0000668let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000669 def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, TB;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000670} // Uses, Defs
671} // SchedRW
Craig Topper5f0339d2017-10-23 15:53:16 +0000672
673//===----------------------------------------------------------------------===//
Chandler Carruth0ca3bd02018-04-10 06:40:51 +0000674// TS flag control instruction.
675let SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000676def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
Chandler Carruth0ca3bd02018-04-10 06:40:51 +0000677}
678
679//===----------------------------------------------------------------------===//
680// IF (inside EFLAGS) management instructions.
681let SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000682def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
683def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
Chandler Carruth0ca3bd02018-04-10 06:40:51 +0000684}
685
686//===----------------------------------------------------------------------===//
Craig Topper5f0339d2017-10-23 15:53:16 +0000687// RDPID Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000688let SchedRW = [WriteSystem] in {
Craig Topper84b26b92018-01-18 23:52:31 +0000689def RDPID32 : I<0xC7, MRM7r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000690 "rdpid\t$dst", [(set GR32:$dst, (int_x86_rdpid))]>, XS,
691 Requires<[Not64BitMode, HasRDPID]>;
692def RDPID64 : I<0xC7, MRM7r, (outs GR64:$dst), (ins), "rdpid\t$dst", []>, XS,
693 Requires<[In64BitMode, HasRDPID]>;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000694} // SchedRW
Craig Topper8f182fd2017-10-23 15:53:21 +0000695
Craig Topper84b26b92018-01-18 23:52:31 +0000696let Predicates = [In64BitMode, HasRDPID] in {
697 // Due to silly instruction definition, we have to compensate for the
698 // instruction outputing a 64-bit register.
699 def : Pat<(int_x86_rdpid),
700 (EXTRACT_SUBREG (RDPID64), sub_32bit)>;
701}
702
703
Craig Topper8f182fd2017-10-23 15:53:21 +0000704//===----------------------------------------------------------------------===//
Gabor Buellaa832b222018-05-10 07:26:05 +0000705// PTWRITE Instruction - Write Data to a Processor Trace Packet
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000706let SchedRW = [WriteSystem] in {
Craig Topper8f182fd2017-10-23 15:53:21 +0000707def PTWRITEm: I<0xAE, MRM4m, (outs), (ins i32mem:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000708 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 (loadi32 addr:$dst))]>, XS,
709 Requires<[HasPTWRITE]>;
Craig Topper8f182fd2017-10-23 15:53:21 +0000710def PTWRITE64m : RI<0xAE, MRM4m, (outs), (ins i64mem:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000711 "ptwrite{q}\t$dst", [(int_x86_ptwrite64 (loadi64 addr:$dst))]>, XS,
712 Requires<[In64BitMode, HasPTWRITE]>;
Craig Topper8f182fd2017-10-23 15:53:21 +0000713
714def PTWRITEr : I<0xAE, MRM4r, (outs), (ins GR32:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000715 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 GR32:$dst)]>, XS,
716 Requires<[HasPTWRITE]>;
Craig Topper8f182fd2017-10-23 15:53:21 +0000717def PTWRITE64r : RI<0xAE, MRM4r, (outs), (ins GR64:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000718 "ptwrite{q}\t$dst", [(int_x86_ptwrite64 GR64:$dst)]>, XS,
719 Requires<[In64BitMode, HasPTWRITE]>;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000720} // SchedRW
Gabor Buella2b5e9602018-05-08 06:47:36 +0000721
722//===----------------------------------------------------------------------===//
723// Platform Configuration instruction
724
725// From ISA docs:
726// "This instruction is used to execute functions for configuring platform
727// features.
728// EAX: Leaf function to be invoked.
729// RBX/RCX/RDX: Leaf-specific purpose."
730// "Successful execution of the leaf clears RAX (set to zero) and ZF, CF, PF,
731// AF, OF, and SF are cleared. In case of failure, the failure reason is
732// indicated in RAX with ZF set to 1 and CF, PF, AF, OF, and SF are cleared."
733// Thus all these mentioned registers are considered clobbered.
734
Simon Pilgrimf5f28aa2018-05-08 15:55:14 +0000735let SchedRW = [WriteSystem] in {
Gabor Buella2b5e9602018-05-08 06:47:36 +0000736let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX, RDX, EFLAGS] in
737 def PCONFIG : I<0x01, MRM_C5, (outs), (ins), "pconfig", []>, TB,
738 Requires<[HasPCONFIG]>;
Gabor Buellaa832b222018-05-10 07:26:05 +0000739} // SchedRW