blob: 35ee00b9e016b0bd95970fbec870d8ae591b8386 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86InstrSystem.td - System Instructions ------------*- tablegen -*-===//
2//
Chris Lattnerdec85b82010-10-05 05:32:15 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jia Liub22310f2012-02-18 12:03:15 +00007//
Chris Lattnerdec85b82010-10-05 05:32:15 +00008//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instructions that are generally used in
11// privileged modes. These are not typically used by the compiler, but are
12// supported for the assembler and disassembler.
13//
14//===----------------------------------------------------------------------===//
15
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000016let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000017let Defs = [RAX, RDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000018 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000019
20let Defs = [RAX, RCX, RDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000021 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", [(X86rdtscp)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000022
23// CPU flow control instructions
24
Joel Galenson06e7e572018-07-13 15:19:33 +000025let mayLoad = 1, mayStore = 0, hasSideEffects = 1, isTrap = 1 in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +000026 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Kevin Enderby5e7cb5f2010-10-27 20:46:49 +000027 def UD2B : I<0xB9, RawFrm, (outs), (ins), "ud2b", []>, TB;
28}
Chris Lattnerdec85b82010-10-05 05:32:15 +000029
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000030def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
31def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000032
33// Interrupt and SysCall Instructions.
34let Uses = [EFLAGS] in
Andrew V. Tischenko92980ce2017-09-20 08:17:17 +000035 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000036
37def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", [(int_x86_int (i8 3))]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000038} // SchedRW
Chris Lattnerfc4fe002011-04-09 19:41:05 +000039
40// The long form of "int $3" turns into int3 as a size optimization.
41// FIXME: This doesn't work because InstAlias can't match immediate constants.
42//def : InstAlias<"int\t$3", (INT3)>;
43
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000044let SchedRW = [WriteSystem] in {
Chris Lattnerfc4fe002011-04-09 19:41:05 +000045
Craig Topper87990ee2015-10-11 18:27:24 +000046def INT : Ii8<0xcd, RawFrm, (outs), (ins u8imm:$trap), "int\t$trap",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000047 [(int_x86_int imm:$trap)]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000048
Chris Lattnerfc4fe002011-04-09 19:41:05 +000049
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000050def SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", []>, TB;
51def SYSRET : I<0x07, RawFrm, (outs), (ins), "sysret{l}", []>, TB;
Craig Topper57315582018-04-29 22:55:54 +000052def SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysretq", []>, TB,
Chris Lattnerae33f5d2010-10-05 06:04:14 +000053 Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000054
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000055def SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", []>, TB;
Preston Gurdd6c440c2012-05-04 19:26:37 +000056
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000057def SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", []>, TB;
Craig Topper57315582018-04-29 22:55:54 +000058def SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexitq", []>, TB,
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000059 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000060} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +000061
Alex Rosenbergb9fefdd2015-01-26 19:09:27 +000062def : Pat<(debugtrap),
63 (INT3)>, Requires<[NotPS4]>;
64def : Pat<(debugtrap),
65 (INT (i8 0x41))>, Requires<[IsPS4]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000066
67//===----------------------------------------------------------------------===//
68// Input/Output Instructions.
69//
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000070let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000071let Defs = [AL], Uses = [DX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000072def IN8rr : I<0xEC, RawFrm, (outs), (ins), "in{b}\t{%dx, %al|al, dx}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000073let Defs = [AX], Uses = [DX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000074def IN16rr : I<0xED, RawFrm, (outs), (ins), "in{w}\t{%dx, %ax|ax, dx}", []>,
75 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000076let Defs = [EAX], Uses = [DX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000077def IN32rr : I<0xED, RawFrm, (outs), (ins), "in{l}\t{%dx, %eax|eax, dx}", []>,
78 OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000079
80let Defs = [AL] in
Craig Topper5be914e2015-10-12 04:17:55 +000081def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000082 "in{b}\t{$port, %al|al, $port}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000083let Defs = [AX] in
Craig Topper5be914e2015-10-12 04:17:55 +000084def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000085 "in{w}\t{$port, %ax|ax, $port}", []>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000086let Defs = [EAX] in
Craig Topper5be914e2015-10-12 04:17:55 +000087def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000088 "in{l}\t{$port, %eax|eax, $port}", []>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000089
90let Uses = [DX, AL] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000091def OUT8rr : I<0xEE, RawFrm, (outs), (ins), "out{b}\t{%al, %dx|dx, al}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000092let Uses = [DX, AX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000093def OUT16rr : I<0xEF, RawFrm, (outs), (ins), "out{w}\t{%ax, %dx|dx, ax}", []>,
94 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000095let Uses = [DX, EAX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +000096def OUT32rr : I<0xEF, RawFrm, (outs), (ins), "out{l}\t{%eax, %dx|dx, eax}", []>,
97 OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000098
99let Uses = [AL] in
Craig Topper5be914e2015-10-12 04:17:55 +0000100def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000101 "out{b}\t{%al, $port|$port, al}", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000102let Uses = [AX] in
Craig Topper5be914e2015-10-12 04:17:55 +0000103def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000104 "out{w}\t{%ax, $port|$port, ax}", []>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000105let Uses = [EAX] in
Craig Topper5be914e2015-10-12 04:17:55 +0000106def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000107 "out{l}\t{%eax, $port|$port, eax}", []>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000108
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000109} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000110
111//===----------------------------------------------------------------------===//
112// Moves to and from debug registers
113
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000114let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000115def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000116 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000117 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000118def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000119 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000120 Requires<[In64BitMode]>;
121
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000122def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000123 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000124 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000125def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000126 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000127 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000128} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000129
130//===----------------------------------------------------------------------===//
131// Moves to and from control registers
132
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000133let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000134def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000135 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000136 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000137def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000138 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000139 Requires<[In64BitMode]>;
140
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000141def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000142 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000143 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000144def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000145 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topperbc281ad82014-01-04 22:29:41 +0000146 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000147} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000148
149//===----------------------------------------------------------------------===//
150// Segment override instruction prefixes
151
Simon Pilgrimdf702102017-12-09 16:58:34 +0000152let SchedRW = [WriteNop] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000153def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
154def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
155def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
156def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
157def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
158def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
Simon Pilgrimdf702102017-12-09 16:58:34 +0000159} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000160
161//===----------------------------------------------------------------------===//
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000162// Moves to and from segment registers.
163//
164
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000165let SchedRW = [WriteMove] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000166def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000167 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000168def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000169 "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000170def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000171 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000172let mayStore = 1 in {
Craig Topper955308f2016-03-13 02:56:31 +0000173def MOV16ms : I<0x8C, MRMDestMem, (outs), (ins i16mem:$dst, SEGMENT_REG:$src),
Craig Topper2a283362018-04-22 01:24:58 +0000174 "mov{w}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000175}
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000176def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000177 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000178def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000179 "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000180def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000181 "mov{q}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000182let mayLoad = 1 in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000183def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
Craig Topper2a283362018-04-22 01:24:58 +0000184 "mov{w}\t{$src, $dst|$dst, $src}", []>;
Ayman Musa62d1c712017-04-13 10:03:45 +0000185}
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000186} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000187
188//===----------------------------------------------------------------------===//
Chris Lattnerdec85b82010-10-05 05:32:15 +0000189// Segmentation support instructions.
190
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000191let SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000192def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000193
Ayman Musa62d1c712017-04-13 10:03:45 +0000194let mayLoad = 1 in
Michael Liao5bf95782014-12-04 05:20:33 +0000195def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000196 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000197 OpSize16, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000198def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000199 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000200 OpSize16, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000201
202// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000203let mayLoad = 1 in
Michael Liao5bf95782014-12-04 05:20:33 +0000204def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000205 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000206 OpSize32, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000207def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000208 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000209 OpSize32, NotMemoryFoldable;
Craig Topper386cfa02018-02-15 01:21:53 +0000210// i16mem operand in LAR64rm and GR32 operand in LAR64rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000211let mayLoad = 1 in
Michael Liao5bf95782014-12-04 05:20:33 +0000212def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000213 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000214def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000215 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000216
Craig Topper386cfa02018-02-15 01:21:53 +0000217// i16mem operand in LSL32rm and GR32 operand in LSL32rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000218let mayLoad = 1 in
Chris Lattnerdec85b82010-10-05 05:32:15 +0000219def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000220 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000221 OpSize16, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000222def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000223 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000224 OpSize16, NotMemoryFoldable;
Craig Topper386cfa02018-02-15 01:21:53 +0000225// i16mem operand in LSL64rm and GR32 operand in LSL64rr is not a typo.
Ayman Musa62d1c712017-04-13 10:03:45 +0000226let mayLoad = 1 in
Craig Topper386cfa02018-02-15 01:21:53 +0000227def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000228 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000229 OpSize32, NotMemoryFoldable;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000230def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000231 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
Craig Topper66572df2018-06-12 04:34:59 +0000232 OpSize32, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000233let mayLoad = 1 in
Craig Topper386cfa02018-02-15 01:21:53 +0000234def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000235 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Craig Topper386cfa02018-02-15 01:21:53 +0000236def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000237 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000238
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000239def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000240
Eli Friedmanf63614a2011-03-04 00:10:17 +0000241def STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000242 "str{w}\t$dst", []>, TB, OpSize16;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000243def STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000244 "str{l}\t$dst", []>, TB, OpSize32;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000245def STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000246 "str{q}\t$dst", []>, TB;
Ayman Musa62d1c712017-04-13 10:03:45 +0000247let mayStore = 1 in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000248def STRm : I<0x00, MRM1m, (outs), (ins i16mem:$dst), "str{w}\t$dst", []>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000249
Craig Topper66572df2018-06-12 04:34:59 +0000250def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000251let mayLoad = 1 in
Craig Topper66572df2018-06-12 04:34:59 +0000252def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable;
Michael Liao5bf95782014-12-04 05:20:33 +0000253
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000254def PUSHCS16 : I<0x0E, RawFrm, (outs), (ins), "push{w}\t{%cs|cs}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000255 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000256def PUSHCS32 : I<0x0E, RawFrm, (outs), (ins), "push{l}\t{%cs|cs}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000257 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000258def PUSHSS16 : I<0x16, RawFrm, (outs), (ins), "push{w}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000259 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000260def PUSHSS32 : I<0x16, RawFrm, (outs), (ins), "push{l}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000261 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000262def PUSHDS16 : I<0x1E, RawFrm, (outs), (ins), "push{w}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000263 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000264def PUSHDS32 : I<0x1E, RawFrm, (outs), (ins), "push{l}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000265 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000266def PUSHES16 : I<0x06, RawFrm, (outs), (ins), "push{w}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000267 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000268def PUSHES32 : I<0x06, RawFrm, (outs), (ins), "push{l}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000269 OpSize32, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000270def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins), "push{w}\t{%fs|fs}", []>,
271 OpSize16, TB;
272def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins), "push{l}\t{%fs|fs}", []>, TB,
273 OpSize32, Requires<[Not64BitMode]>;
274def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins), "push{w}\t{%gs|gs}", []>,
275 OpSize16, TB;
276def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins), "push{l}\t{%gs|gs}", []>, TB,
277 OpSize32, Requires<[Not64BitMode]>;
278def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), "push{q}\t{%fs|fs}", []>, TB,
279 OpSize32, Requires<[In64BitMode]>;
280def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), "push{q}\t{%gs|gs}", []>, TB,
281 OpSize32, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000282
283// No "pop cs" instruction.
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000284def POPSS16 : I<0x17, RawFrm, (outs), (ins), "pop{w}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000285 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000286def POPSS32 : I<0x17, RawFrm, (outs), (ins), "pop{l}\t{%ss|ss}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000287 OpSize32, Requires<[Not64BitMode]>;
288
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000289def POPDS16 : I<0x1F, RawFrm, (outs), (ins), "pop{w}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000290 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000291def POPDS32 : I<0x1F, RawFrm, (outs), (ins), "pop{l}\t{%ds|ds}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000292 OpSize32, Requires<[Not64BitMode]>;
293
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000294def POPES16 : I<0x07, RawFrm, (outs), (ins), "pop{w}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000295 OpSize16, Requires<[Not64BitMode]>;
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000296def POPES32 : I<0x07, RawFrm, (outs), (ins), "pop{l}\t{%es|es}", []>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000297 OpSize32, Requires<[Not64BitMode]>;
298
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000299def POPFS16 : I<0xa1, RawFrm, (outs), (ins), "pop{w}\t{%fs|fs}", []>,
300 OpSize16, TB;
301def POPFS32 : I<0xa1, RawFrm, (outs), (ins), "pop{l}\t{%fs|fs}", []>, TB,
302 OpSize32, Requires<[Not64BitMode]>;
303def POPFS64 : I<0xa1, RawFrm, (outs), (ins), "pop{q}\t{%fs|fs}", []>, TB,
304 OpSize32, Requires<[In64BitMode]>;
Craig Topper6872fd32014-02-18 08:18:29 +0000305
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000306def POPGS16 : I<0xa9, RawFrm, (outs), (ins), "pop{w}\t{%gs|gs}", []>,
307 OpSize16, TB;
308def POPGS32 : I<0xa9, RawFrm, (outs), (ins), "pop{l}\t{%gs|gs}", []>, TB,
309 OpSize32, Requires<[Not64BitMode]>;
310def POPGS64 : I<0xa9, RawFrm, (outs), (ins), "pop{q}\t{%gs|gs}", []>, TB,
311 OpSize32, Requires<[In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000312
313def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000314 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
Craig Topperb9c932f2016-01-26 06:10:15 +0000315 Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000316def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000317 "lds{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
Craig Topperb9c932f2016-01-26 06:10:15 +0000318 Requires<[Not64BitMode]>;
Michael Liao5bf95782014-12-04 05:20:33 +0000319
Craig Topper33dc01d2018-05-01 04:42:00 +0000320def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000321 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
Craig Topper33dc01d2018-05-01 04:42:00 +0000322def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000323 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
Craig Topper33dc01d2018-05-01 04:42:00 +0000324def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000325 "lss{q}\t{$src, $dst|$dst, $src}", []>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000326
Craig Topper33dc01d2018-05-01 04:42:00 +0000327def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000328 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
Craig Topperb9c932f2016-01-26 06:10:15 +0000329 Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000330def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000331 "les{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
Craig Topperb9c932f2016-01-26 06:10:15 +0000332 Requires<[Not64BitMode]>;
Michael Liao5bf95782014-12-04 05:20:33 +0000333
Craig Topper33dc01d2018-05-01 04:42:00 +0000334def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000335 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
Craig Topper33dc01d2018-05-01 04:42:00 +0000336def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000337 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
Craig Topper33dc01d2018-05-01 04:42:00 +0000338def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000339 "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000340
Craig Topper33dc01d2018-05-01 04:42:00 +0000341def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000342 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
Craig Topper33dc01d2018-05-01 04:42:00 +0000343def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000344 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
Michael Liao5bf95782014-12-04 05:20:33 +0000345
Craig Topper33dc01d2018-05-01 04:42:00 +0000346def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000347 "lgs{q}\t{$src, $dst|$dst, $src}", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000348
Craig Topper66572df2018-06-12 04:34:59 +0000349def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable;
350def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000351let mayLoad = 1 in {
Craig Topper66572df2018-06-12 04:34:59 +0000352def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable;
353def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000354}
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000355} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000356
357//===----------------------------------------------------------------------===//
358// Descriptor-table support instructions
359
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000360let SchedRW = [WriteSystem] in {
Craig Topper33dc01d2018-05-01 04:42:00 +0000361def SGDT16m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000362 "sgdtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000363def SGDT32m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000364 "sgdt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000365def SGDT64m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000366 "sgdt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000367def SIDT16m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000368 "sidtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000369def SIDT32m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000370 "sidt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000371def SIDT64m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000372 "sidt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000373def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000374 "sldt{w}\t$dst", []>, TB, OpSize16;
Ayman Musa62d1c712017-04-13 10:03:45 +0000375let mayStore = 1 in
Craig Topper955308f2016-03-13 02:56:31 +0000376def SLDT16m : I<0x00, MRM0m, (outs), (ins i16mem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000377 "sldt{w}\t$dst", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000378def SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000379 "sldt{l}\t$dst", []>, OpSize32, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000380
Chris Lattnerc184a572010-10-05 06:22:35 +0000381// LLDT is not interpreted specially in 64-bit mode because there is no sign
382// extension.
383def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000384 "sldt{q}\t$dst", []>, TB, Requires<[In64BitMode]>;
Chris Lattnerc184a572010-10-05 06:22:35 +0000385
Craig Topper33dc01d2018-05-01 04:42:00 +0000386def LGDT16m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000387 "lgdtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000388def LGDT32m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000389 "lgdt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000390def LGDT64m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000391 "lgdt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000392def LIDT16m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000393 "lidtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000394def LIDT32m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
Craig Topper18c4c8e2018-04-29 06:24:09 +0000395 "lidt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000396def LIDT64m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000397 "lidt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000398def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000399 "lldt{w}\t$src", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000400let mayLoad = 1 in
Chris Lattnerdec85b82010-10-05 05:32:15 +0000401def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000402 "lldt{w}\t$src", []>, TB, NotMemoryFoldable;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000403} // SchedRW
404
Chris Lattnerdec85b82010-10-05 05:32:15 +0000405//===----------------------------------------------------------------------===//
406// Specialized register support
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000407let SchedRW = [WriteSystem] in {
Craig Toppere169c572015-02-07 23:36:51 +0000408let Uses = [EAX, ECX, EDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000409def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
Craig Toppere169c572015-02-07 23:36:51 +0000410let Defs = [EAX, EDX], Uses = [ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000411def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
Andrea Di Biagio53b68302014-06-30 17:14:21 +0000412
413let Defs = [RAX, RDX], Uses = [ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000414 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", [(X86rdpmc)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000415
Michael Liao5bf95782014-12-04 05:20:33 +0000416def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000417 "smsw{w}\t$dst", []>, OpSize16, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000418def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000419 "smsw{l}\t$dst", []>, OpSize32, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000420// no m form encodable; use SMSW16m
Michael Liao5bf95782014-12-04 05:20:33 +0000421def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000422 "smsw{q}\t$dst", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000423
424// For memory operands, there is only a 16-bit form
Craig Topper955308f2016-03-13 02:56:31 +0000425def SMSW16m : I<0x01, MRM4m, (outs), (ins i16mem:$dst),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000426 "smsw{w}\t$dst", []>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000427
428def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000429 "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
Ayman Musa62d1c712017-04-13 10:03:45 +0000430let mayLoad = 1 in
Chris Lattnerdec85b82010-10-05 05:32:15 +0000431def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
Craig Topper66572df2018-06-12 04:34:59 +0000432 "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
Reid Klecknerb2340d42014-01-28 02:08:22 +0000433
434let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000435 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000436} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000437
438//===----------------------------------------------------------------------===//
439// Cache instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000440let SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000441def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
Gabor Buella297c1382018-04-12 18:38:18 +0000442def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB;
Gabor Buella2ef36f32018-04-11 20:01:57 +0000443
444// wbnoinvd is like wbinvd, except without invalidation
445// encoding: like wbinvd + an 0xF3 prefix
446def WBNOINVD : I<0x09, RawFrm, (outs), (ins), "wbnoinvd",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000447 [(int_x86_wbnoinvd)]>, XS,
Gabor Buella2ef36f32018-04-11 20:01:57 +0000448 Requires<[HasWBNOINVD]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000449} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000450
Craig Topperd9cfddc2011-10-07 07:02:24 +0000451//===----------------------------------------------------------------------===//
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000452// CET instructions
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000453// Use with caution, availability is not predicated on features.
454let SchedRW = [WriteSystem] in {
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000455 let Uses = [SSP] in {
456 let Defs = [SSP] in {
457 def INCSSPD : I<0xAE, MRM5r, (outs), (ins GR32:$src), "incsspd\t$src",
458 [(int_x86_incsspd GR32:$src)]>, XS;
459 def INCSSPQ : RI<0xAE, MRM5r, (outs), (ins GR64:$src), "incsspq\t$src",
Craig Topper365e8aa2017-12-15 19:01:48 +0000460 [(int_x86_incsspq GR64:$src)]>, XS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000461 } // Defs SSP
462
463 let Constraints = "$src = $dst" in {
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000464 def RDSSPD : I<0x1E, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000465 "rdsspd\t$dst",
466 [(set GR32:$dst, (int_x86_rdsspd GR32:$src))]>, XS;
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000467 def RDSSPQ : RI<0x1E, MRM1r, (outs GR64:$dst), (ins GR64:$src),
468 "rdsspq\t$dst",
Craig Topper365e8aa2017-12-15 19:01:48 +0000469 [(set GR64:$dst, (int_x86_rdsspq GR64:$src))]>, XS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000470 }
471
472 let Defs = [SSP] in {
473 def SAVEPREVSSP : I<0x01, MRM_EA, (outs), (ins), "saveprevssp",
474 [(int_x86_saveprevssp)]>, XS;
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000475 def RSTORSSP : I<0x01, MRM5m, (outs), (ins i32mem:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000476 "rstorssp\t$src",
477 [(int_x86_rstorssp addr:$src)]>, XS;
478 } // Defs SSP
479 } // Uses SSP
480
481 def WRSSD : I<0xF6, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
482 "wrssd\t{$src, $dst|$dst, $src}",
Craig Topper365e8aa2017-12-15 19:01:48 +0000483 [(int_x86_wrssd GR32:$src, addr:$dst)]>, T8PS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000484 def WRSSQ : RI<0xF6, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
485 "wrssq\t{$src, $dst|$dst, $src}",
Craig Topper365e8aa2017-12-15 19:01:48 +0000486 [(int_x86_wrssq GR64:$src, addr:$dst)]>, T8PS;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000487 def WRUSSD : I<0xF5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
488 "wrussd\t{$src, $dst|$dst, $src}",
489 [(int_x86_wrussd GR32:$src, addr:$dst)]>, T8PD;
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000490 def WRUSSQ : RI<0xF5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000491 "wrussq\t{$src, $dst|$dst, $src}",
Craig Topper365e8aa2017-12-15 19:01:48 +0000492 [(int_x86_wrussq GR64:$src, addr:$dst)]>, T8PD;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000493
494 let Defs = [SSP] in {
495 let Uses = [SSP] in {
496 def SETSSBSY : I<0x01, MRM_E8, (outs), (ins), "setssbsy",
497 [(int_x86_setssbsy)]>, XS;
498 } // Uses SSP
499
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000500 def CLRSSBSY : I<0xAE, MRM6m, (outs), (ins i32mem:$src),
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000501 "clrssbsy\t$src",
502 [(int_x86_clrssbsy addr:$src)]>, XS;
503 } // Defs SSP
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000504} // SchedRW
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000505
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000506let SchedRW = [WriteSystem] in {
Oren Ben Simhon1c6308e2018-01-09 08:51:18 +0000507 def ENDBR64 : I<0x1E, MRM_FA, (outs), (ins), "endbr64", []>, XS;
508 def ENDBR32 : I<0x1E, MRM_FB, (outs), (ins), "endbr32", []>, XS;
Alexander Ivchenko5c547422018-05-18 11:58:25 +0000509} // SchedRW
Oren Ben Simhon1c6308e2018-01-09 08:51:18 +0000510
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000511//===----------------------------------------------------------------------===//
Craig Topperd9cfddc2011-10-07 07:02:24 +0000512// XSAVE instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000513let SchedRW = [WriteSystem] in {
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000514let Predicates = [HasXSAVE] in {
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000515let Defs = [EDX, EAX], Uses = [ECX] in
Rafael Espindolae3906212011-02-22 00:35:18 +0000516 def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB;
517
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000518let Uses = [EDX, EAX, ECX] in
Simon Pilgrimb2b93f62017-12-09 20:44:51 +0000519 def XSETBV : I<0x01, MRM_D1, (outs), (ins),
520 "xsetbv",
Guy Blank722caeb2016-08-16 06:41:00 +0000521 [(int_x86_xsetbv ECX, EDX, EAX)]>, TB;
522
523} // HasXSAVE
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000524
525let Uses = [EDX, EAX] in {
Craig Topper33dc01d2018-05-01 04:42:00 +0000526def XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000527 "xsave\t$dst",
528 [(int_x86_xsave addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000529def XSAVE64 : RI<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000530 "xsave64\t$dst",
531 [(int_x86_xsave64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000532def XRSTOR : I<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000533 "xrstor\t$dst",
534 [(int_x86_xrstor addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000535def XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
Craig Toppera1639502017-12-15 17:22:58 +0000536 "xrstor64\t$dst",
537 [(int_x86_xrstor64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000538def XSAVEOPT : I<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000539 "xsaveopt\t$dst",
540 [(int_x86_xsaveopt addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000541def XSAVEOPT64 : RI<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000542 "xsaveopt64\t$dst",
543 [(int_x86_xsaveopt64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000544def XSAVEC : I<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000545 "xsavec\t$dst",
546 [(int_x86_xsavec addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000547def XSAVEC64 : RI<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000548 "xsavec64\t$dst",
549 [(int_x86_xsavec64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000550def XSAVES : I<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000551 "xsaves\t$dst",
552 [(int_x86_xsaves addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000553def XSAVES64 : RI<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000554 "xsaves64\t$dst",
555 [(int_x86_xsaves64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000556def XRSTORS : I<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000557 "xrstors\t$dst",
558 [(int_x86_xrstors addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
Craig Topper33dc01d2018-05-01 04:42:00 +0000559def XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
Craig Topper23c34882017-12-15 19:01:51 +0000560 "xrstors64\t$dst",
561 [(int_x86_xrstors64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES, In64BitMode]>;
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000562} // Uses
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000563} // SchedRW
Craig Topperbf136762011-10-07 05:53:50 +0000564
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000565//===----------------------------------------------------------------------===//
566// VIA PadLock crypto instructions
Simon Pilgrim4ba33142017-12-08 16:06:40 +0000567let Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in
Craig Topper0d1fd552014-02-19 05:34:21 +0000568 def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000569
Joerg Sonnenberger91e56622011-06-30 01:38:03 +0000570def : InstAlias<"xstorerng", (XSTORE)>;
571
Simon Pilgrim4ba33142017-12-08 16:06:40 +0000572let SchedRW = [WriteSystem] in {
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000573let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
Craig Topper0d1fd552014-02-19 05:34:21 +0000574 def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB;
575 def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB;
576 def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB;
577 def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB;
578 def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000579}
580
581let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
Craig Topper0d1fd552014-02-19 05:34:21 +0000582 def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB;
583 def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000584}
585let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
Craig Topper0d1fd552014-02-19 05:34:21 +0000586 def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB;
Simon Pilgrim4ba33142017-12-08 16:06:40 +0000587} // SchedRW
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000588
Asaf Badouh9a5a83a2015-12-24 08:25:00 +0000589//==-----------------------------------------------------------------------===//
590// PKU - enable protection key
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000591let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
Asaf Badouhaf6569a2015-12-31 08:31:13 +0000592 def WRPKRU : PseudoI<(outs), (ins GR32:$src),
593 [(int_x86_wrpkru GR32:$src)]>;
594 def RDPKRU : PseudoI<(outs GR32:$dst), (ins),
595 [(set GR32:$dst, (int_x86_rdpkru))]>;
596}
597
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000598let SchedRW = [WriteSystem] in {
Zvi Rackoverb346eaa2016-06-18 19:13:38 +0000599let Defs = [EAX, EDX], Uses = [ECX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000600 def RDPKRUr : I<0x01, MRM_EE, (outs), (ins), "rdpkru", []>, TB;
Asaf Badouh9a5a83a2015-12-24 08:25:00 +0000601let Uses = [EAX, ECX, EDX] in
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000602 def WRPKRUr : I<0x01, MRM_EF, (outs), (ins), "wrpkru", []>, TB;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000603} // SchedRW
Craig Topperd9cfddc2011-10-07 07:02:24 +0000604
605//===----------------------------------------------------------------------===//
606// FS/GS Base Instructions
Simon Pilgrim7e636cc2017-12-09 20:42:27 +0000607let Predicates = [HasFSGSBase, In64BitMode], SchedRW = [WriteSystem] in {
Craig Topperd9cfddc2011-10-07 07:02:24 +0000608 def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000609 "rdfsbase{l}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000610 [(set GR32:$dst, (int_x86_rdfsbase_32))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000611 def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000612 "rdfsbase{q}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000613 [(set GR64:$dst, (int_x86_rdfsbase_64))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000614 def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000615 "rdgsbase{l}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000616 [(set GR32:$dst, (int_x86_rdgsbase_32))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000617 def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000618 "rdgsbase{q}\t$dst",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000619 [(set GR64:$dst, (int_x86_rdgsbase_64))]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000620 def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
621 "wrfsbase{l}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000622 [(int_x86_wrfsbase_32 GR32:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000623 def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
624 "wrfsbase{q}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000625 [(int_x86_wrfsbase_64 GR64:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000626 def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
627 "wrgsbase{l}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000628 [(int_x86_wrgsbase_32 GR32:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000629 def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
630 "wrgsbase{q}\t$src",
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000631 [(int_x86_wrgsbase_64 GR64:$src)]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000632}
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000633
634//===----------------------------------------------------------------------===//
635// INVPCID Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000636let SchedRW = [WriteSystem] in {
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000637def INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000638 "invpcid\t{$src2, $src1|$src1, $src2}",
639 [(int_x86_invpcid GR32:$src1, addr:$src2)]>, T8PD,
640 Requires<[Not64BitMode, HasINVPCID]>;
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000641def INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000642 "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD,
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000643 Requires<[In64BitMode, HasINVPCID]>;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000644} // SchedRW
Michael Liao95d944032013-04-11 04:52:28 +0000645
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000646let Predicates = [In64BitMode, HasINVPCID] in {
647 // The instruction can only use a 64 bit register as the register argument
648 // in 64 bit mode, while the intrinsic only accepts a 32 bit argument
649 // corresponding to it.
650 // The accepted values for now are 0,1,2,3 anyways (see Intel SDM -- INVCPID
651 // type),/ so it doesn't hurt us that one can't supply a 64 bit value here.
652 def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2),
653 (INVPCID64
654 (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit),
655 addr:$src2)>;
656}
657
658
Michael Liao95d944032013-04-11 04:52:28 +0000659//===----------------------------------------------------------------------===//
660// SMAP Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000661let Defs = [EFLAGS], SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000662 def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, TB;
663 def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, TB;
Michael Liao95d944032013-04-11 04:52:28 +0000664}
Craig Topper1d472db2015-02-07 23:36:36 +0000665
666//===----------------------------------------------------------------------===//
667// SMX Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000668let SchedRW = [WriteSystem] in {
Craig Topper1d472db2015-02-07 23:36:36 +0000669let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000670 def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, TB;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000671} // Uses, Defs
672} // SchedRW
Craig Topper5f0339d2017-10-23 15:53:16 +0000673
674//===----------------------------------------------------------------------===//
Chandler Carruth0ca3bd02018-04-10 06:40:51 +0000675// TS flag control instruction.
676let SchedRW = [WriteSystem] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000677def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
Chandler Carruth0ca3bd02018-04-10 06:40:51 +0000678}
679
680//===----------------------------------------------------------------------===//
681// IF (inside EFLAGS) management instructions.
682let SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in {
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000683def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
684def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
Chandler Carruth0ca3bd02018-04-10 06:40:51 +0000685}
686
687//===----------------------------------------------------------------------===//
Craig Topper5f0339d2017-10-23 15:53:16 +0000688// RDPID Instruction
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000689let SchedRW = [WriteSystem] in {
Craig Topper84b26b92018-01-18 23:52:31 +0000690def RDPID32 : I<0xC7, MRM7r, (outs GR32:$dst), (ins),
Simon Pilgrim0cd0fbd2018-04-12 12:09:24 +0000691 "rdpid\t$dst", [(set GR32:$dst, (int_x86_rdpid))]>, XS,
692 Requires<[Not64BitMode, HasRDPID]>;
693def RDPID64 : I<0xC7, MRM7r, (outs GR64:$dst), (ins), "rdpid\t$dst", []>, XS,
694 Requires<[In64BitMode, HasRDPID]>;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000695} // SchedRW
Craig Topper8f182fd2017-10-23 15:53:21 +0000696
Craig Topper84b26b92018-01-18 23:52:31 +0000697let Predicates = [In64BitMode, HasRDPID] in {
698 // Due to silly instruction definition, we have to compensate for the
699 // instruction outputing a 64-bit register.
700 def : Pat<(int_x86_rdpid),
701 (EXTRACT_SUBREG (RDPID64), sub_32bit)>;
702}
703
704
Craig Topper8f182fd2017-10-23 15:53:21 +0000705//===----------------------------------------------------------------------===//
Gabor Buellaa832b222018-05-10 07:26:05 +0000706// PTWRITE Instruction - Write Data to a Processor Trace Packet
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000707let SchedRW = [WriteSystem] in {
Craig Topper8f182fd2017-10-23 15:53:21 +0000708def PTWRITEm: I<0xAE, MRM4m, (outs), (ins i32mem:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000709 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 (loadi32 addr:$dst))]>, XS,
710 Requires<[HasPTWRITE]>;
Craig Topper8f182fd2017-10-23 15:53:21 +0000711def PTWRITE64m : RI<0xAE, MRM4m, (outs), (ins i64mem:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000712 "ptwrite{q}\t$dst", [(int_x86_ptwrite64 (loadi64 addr:$dst))]>, XS,
713 Requires<[In64BitMode, HasPTWRITE]>;
Craig Topper8f182fd2017-10-23 15:53:21 +0000714
715def PTWRITEr : I<0xAE, MRM4r, (outs), (ins GR32:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000716 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 GR32:$dst)]>, XS,
717 Requires<[HasPTWRITE]>;
Craig Topper8f182fd2017-10-23 15:53:21 +0000718def PTWRITE64r : RI<0xAE, MRM4r, (outs), (ins GR64:$dst),
Gabor Buellaa832b222018-05-10 07:26:05 +0000719 "ptwrite{q}\t$dst", [(int_x86_ptwrite64 GR64:$dst)]>, XS,
720 Requires<[In64BitMode, HasPTWRITE]>;
Simon Pilgrim1ddcae62017-12-08 15:48:37 +0000721} // SchedRW
Gabor Buella2b5e9602018-05-08 06:47:36 +0000722
723//===----------------------------------------------------------------------===//
724// Platform Configuration instruction
725
726// From ISA docs:
727// "This instruction is used to execute functions for configuring platform
728// features.
729// EAX: Leaf function to be invoked.
730// RBX/RCX/RDX: Leaf-specific purpose."
731// "Successful execution of the leaf clears RAX (set to zero) and ZF, CF, PF,
732// AF, OF, and SF are cleared. In case of failure, the failure reason is
733// indicated in RAX with ZF set to 1 and CF, PF, AF, OF, and SF are cleared."
734// Thus all these mentioned registers are considered clobbered.
735
Simon Pilgrimf5f28aa2018-05-08 15:55:14 +0000736let SchedRW = [WriteSystem] in {
Gabor Buella2b5e9602018-05-08 06:47:36 +0000737let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX, RDX, EFLAGS] in
738 def PCONFIG : I<0x01, MRM_C5, (outs), (ins), "pconfig", []>, TB,
739 Requires<[HasPCONFIG]>;
Gabor Buellaa832b222018-05-10 07:26:05 +0000740} // SchedRW