Debian Codegraph @

suite/synctools/tablegen/X86/back/X86InstrSystem.td

raw
1 //===-- X86InstrSystem.td - System Instructions ------------*- tablegen -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
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
16 let SchedRW = [WriteSystem] in {
17 let Defs = [RAX, RDX] in
18 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>, TB;
19
20 let Defs = [RAX, RCX, RDX] in
21 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", [(X86rdtscp)]>, TB;
22
23 // CPU flow control instructions
24
25 let mayLoad = 1, mayStore = 0, hasSideEffects = 1, isTrap = 1 in {
26 def UD2 : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
27 def UD1 : I<0xB9, RawFrm, (outs), (ins), "ud1", []>, TB;
28 def UD0 : I<0xFF, RawFrm, (outs), (ins), "ud0", []>, TB;
29 }
30
31 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
32 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
33
34 // Interrupt and SysCall Instructions.
35 let Uses = [EFLAGS] in
36 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>, Requires<[Not64BitMode]>;
37
38 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", [(int_x86_int (i8 3))]>;
39 } // SchedRW
40
41 // The long form of "int $3" turns into int3 as a size optimization.
42 // FIXME: This doesn't work because InstAlias can't match immediate constants.
43 //def : InstAlias<"int\t$3", (INT3)>;
44
45 let SchedRW = [WriteSystem] in {
46
47 def INT : Ii8<0xcd, RawFrm, (outs), (ins u8imm:$trap), "int\t$trap",
48 [(int_x86_int imm:$trap)]>;
49
50
51 def SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", []>, TB;
52 def SYSRET : I<0x07, RawFrm, (outs), (ins), "sysret{l}", []>, TB;
53 def SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysretq", []>, TB,
54 Requires<[In64BitMode]>;
55
56 def SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", []>, TB;
57
58 def SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", []>, TB;
59 def SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexitq", []>, TB,
60 Requires<[In64BitMode]>;
61 } // SchedRW
62
63 def : Pat<(debugtrap),
64 (INT3)>, Requires<[NotPS4]>;
65 def : Pat<(debugtrap),
66 (INT (i8 0x41))>, Requires<[IsPS4]>;
67
68 //===----------------------------------------------------------------------===//
69 // Input/Output Instructions.
70 //
71 let SchedRW = [WriteSystem] in {
72 let Defs = [AL], Uses = [DX] in
73 def IN8rr : I<0xEC, RawFrm, (outs), (ins), "in{b}\t{%dx, %al|al, dx}", []>;
74 let Defs = [AX], Uses = [DX] in
75 def IN16rr : I<0xED, RawFrm, (outs), (ins), "in{w}\t{%dx, %ax|ax, dx}", []>,
76 OpSize16;
77 let Defs = [EAX], Uses = [DX] in
78 def IN32rr : I<0xED, RawFrm, (outs), (ins), "in{l}\t{%dx, %eax|eax, dx}", []>,
79 OpSize32;
80
81 let Defs = [AL] in
82 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins u8imm:$port),
83 "in{b}\t{$port, %al|al, $port}", []>;
84 let Defs = [AX] in
85 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
86 "in{w}\t{$port, %ax|ax, $port}", []>, OpSize16;
87 let Defs = [EAX] in
88 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
89 "in{l}\t{$port, %eax|eax, $port}", []>, OpSize32;
90
91 let Uses = [DX, AL] in
92 def OUT8rr : I<0xEE, RawFrm, (outs), (ins), "out{b}\t{%al, %dx|dx, al}", []>;
93 let Uses = [DX, AX] in
94 def OUT16rr : I<0xEF, RawFrm, (outs), (ins), "out{w}\t{%ax, %dx|dx, ax}", []>,
95 OpSize16;
96 let Uses = [DX, EAX] in
97 def OUT32rr : I<0xEF, RawFrm, (outs), (ins), "out{l}\t{%eax, %dx|dx, eax}", []>,
98 OpSize32;
99
100 let Uses = [AL] in
101 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins u8imm:$port),
102 "out{b}\t{%al, $port|$port, al}", []>;
103 let Uses = [AX] in
104 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
105 "out{w}\t{%ax, $port|$port, ax}", []>, OpSize16;
106 let Uses = [EAX] in
107 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
108 "out{l}\t{%eax, $port|$port, eax}", []>, OpSize32;
109
110 } // SchedRW
111
112 //===----------------------------------------------------------------------===//
113 // Moves to and from debug registers
114
115 let SchedRW = [WriteSystem] in {
116 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
117 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
118 Requires<[Not64BitMode]>;
119 def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src),
120 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
121 Requires<[In64BitMode]>;
122
123 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
124 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
125 Requires<[Not64BitMode]>;
126 def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src),
127 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
128 Requires<[In64BitMode]>;
129 } // SchedRW
130
131 //===----------------------------------------------------------------------===//
132 // Moves to and from control registers
133
134 let SchedRW = [WriteSystem] in {
135 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
136 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
137 Requires<[Not64BitMode]>;
138 def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src),
139 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
140 Requires<[In64BitMode]>;
141
142 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
143 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
144 Requires<[Not64BitMode]>;
145 def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src),
146 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
147 Requires<[In64BitMode]>;
148 } // SchedRW
149
150 //===----------------------------------------------------------------------===//
151 // Segment override instruction prefixes
152
153 //let SchedRW = [WriteNop] in {
154 //def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
155 //def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
156 //def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
157 //def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
158 //def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
159 //def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
160 //} // SchedRW
161
162 //===----------------------------------------------------------------------===//
163 // Moves to and from segment registers.
164 //
165
166 let SchedRW = [WriteMove] in {
167 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
168 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
169 def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
170 "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
171 def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src),
172 "mov{q}\t{$src, $dst|$dst, $src}", []>;
173 let mayStore = 1 in {
174 def MOV16ms : I<0x8C, MRMDestMem, (outs), (ins i16mem:$dst, SEGMENT_REG:$src),
175 "mov{w}\t{$src, $dst|$dst, $src}", []>;
176 }
177 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
178 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
179 def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
180 "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
181 def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src),
182 "mov{q}\t{$src, $dst|$dst, $src}", []>;
183 let mayLoad = 1 in {
184 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
185 "mov{w}\t{$src, $dst|$dst, $src}", []>;
186 }
187 } // SchedRW
188
189 //===----------------------------------------------------------------------===//
190 // Segmentation support instructions.
191
192 let SchedRW = [WriteSystem] in {
193 def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB;
194
195 let mayLoad = 1 in
196 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
197 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
198 OpSize16, NotMemoryFoldable;
199 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
200 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
201 OpSize16, NotMemoryFoldable;
202
203 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
204 let mayLoad = 1 in
205 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
206 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
207 OpSize32, NotMemoryFoldable;
208 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
209 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
210 OpSize32, NotMemoryFoldable;
211 // i16mem operand in LAR64rm and GR32 operand in LAR64rr is not a typo.
212 let mayLoad = 1 in
213 def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
214 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
215 def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
216 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
217
218 // i16mem operand in LSL32rm and GR32 operand in LSL32rr is not a typo.
219 let mayLoad = 1 in
220 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
221 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
222 OpSize16, NotMemoryFoldable;
223 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
224 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
225 OpSize16, NotMemoryFoldable;
226 // i16mem operand in LSL64rm and GR32 operand in LSL64rr is not a typo.
227 let mayLoad = 1 in
228 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
229 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
230 OpSize32, NotMemoryFoldable;
231 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
232 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
233 OpSize32, NotMemoryFoldable;
234 let mayLoad = 1 in
235 def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
236 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
237 def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
238 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable;
239
240 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
241
242 def STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins),
243 "str{w}\t$dst", []>, TB, OpSize16;
244 def STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins),
245 "str{l}\t$dst", []>, TB, OpSize32;
246 def STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins),
247 "str{q}\t$dst", []>, TB;
248 let mayStore = 1 in
249 def STRm : I<0x00, MRM1m, (outs), (ins i16mem:$dst), "str{w}\t$dst", []>, TB;
250
251 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable;
252 let mayLoad = 1 in
253 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable;
254
255 def PUSHCS16 : I<0x0E, RawFrm, (outs), (ins), "push{w}\t{%cs|cs}", []>,
256 OpSize16, Requires<[Not64BitMode]>;
257 def PUSHCS32 : I<0x0E, RawFrm, (outs), (ins), "push{l}\t{%cs|cs}", []>,
258 OpSize32, Requires<[Not64BitMode]>;
259 def PUSHSS16 : I<0x16, RawFrm, (outs), (ins), "push{w}\t{%ss|ss}", []>,
260 OpSize16, Requires<[Not64BitMode]>;
261 def PUSHSS32 : I<0x16, RawFrm, (outs), (ins), "push{l}\t{%ss|ss}", []>,
262 OpSize32, Requires<[Not64BitMode]>;
263 def PUSHDS16 : I<0x1E, RawFrm, (outs), (ins), "push{w}\t{%ds|ds}", []>,
264 OpSize16, Requires<[Not64BitMode]>;
265 def PUSHDS32 : I<0x1E, RawFrm, (outs), (ins), "push{l}\t{%ds|ds}", []>,
266 OpSize32, Requires<[Not64BitMode]>;
267 def PUSHES16 : I<0x06, RawFrm, (outs), (ins), "push{w}\t{%es|es}", []>,
268 OpSize16, Requires<[Not64BitMode]>;
269 def PUSHES32 : I<0x06, RawFrm, (outs), (ins), "push{l}\t{%es|es}", []>,
270 OpSize32, Requires<[Not64BitMode]>;
271 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins), "push{w}\t{%fs|fs}", []>,
272 OpSize16, TB;
273 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins), "push{l}\t{%fs|fs}", []>, TB,
274 OpSize32, Requires<[Not64BitMode]>;
275 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins), "push{w}\t{%gs|gs}", []>,
276 OpSize16, TB;
277 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins), "push{l}\t{%gs|gs}", []>, TB,
278 OpSize32, Requires<[Not64BitMode]>;
279 def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), "push{q}\t{%fs|fs}", []>, TB,
280 OpSize32, Requires<[In64BitMode]>;
281 def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), "push{q}\t{%gs|gs}", []>, TB,
282 OpSize32, Requires<[In64BitMode]>;
283
284 // No "pop cs" instruction.
285 def POPSS16 : I<0x17, RawFrm, (outs), (ins), "pop{w}\t{%ss|ss}", []>,
286 OpSize16, Requires<[Not64BitMode]>;
287 def POPSS32 : I<0x17, RawFrm, (outs), (ins), "pop{l}\t{%ss|ss}", []>,
288 OpSize32, Requires<[Not64BitMode]>;
289
290 def POPDS16 : I<0x1F, RawFrm, (outs), (ins), "pop{w}\t{%ds|ds}", []>,
291 OpSize16, Requires<[Not64BitMode]>;
292 def POPDS32 : I<0x1F, RawFrm, (outs), (ins), "pop{l}\t{%ds|ds}", []>,
293 OpSize32, Requires<[Not64BitMode]>;
294
295 def POPES16 : I<0x07, RawFrm, (outs), (ins), "pop{w}\t{%es|es}", []>,
296 OpSize16, Requires<[Not64BitMode]>;
297 def POPES32 : I<0x07, RawFrm, (outs), (ins), "pop{l}\t{%es|es}", []>,
298 OpSize32, Requires<[Not64BitMode]>;
299
300 def POPFS16 : I<0xa1, RawFrm, (outs), (ins), "pop{w}\t{%fs|fs}", []>,
301 OpSize16, TB;
302 def POPFS32 : I<0xa1, RawFrm, (outs), (ins), "pop{l}\t{%fs|fs}", []>, TB,
303 OpSize32, Requires<[Not64BitMode]>;
304 def POPFS64 : I<0xa1, RawFrm, (outs), (ins), "pop{q}\t{%fs|fs}", []>, TB,
305 OpSize32, Requires<[In64BitMode]>;
306
307 def POPGS16 : I<0xa9, RawFrm, (outs), (ins), "pop{w}\t{%gs|gs}", []>,
308 OpSize16, TB;
309 def POPGS32 : I<0xa9, RawFrm, (outs), (ins), "pop{l}\t{%gs|gs}", []>, TB,
310 OpSize32, Requires<[Not64BitMode]>;
311 def POPGS64 : I<0xa9, RawFrm, (outs), (ins), "pop{q}\t{%gs|gs}", []>, TB,
312 OpSize32, Requires<[In64BitMode]>;
313
314 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
315 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
316 Requires<[Not64BitMode]>;
317 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
318 "lds{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
319 Requires<[Not64BitMode]>;
320
321 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
322 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
323 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
324 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
325 def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
326 "lss{q}\t{$src, $dst|$dst, $src}", []>, TB;
327
328 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
329 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
330 Requires<[Not64BitMode]>;
331 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
332 "les{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
333 Requires<[Not64BitMode]>;
334
335 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
336 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
337 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
338 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
339 def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
340 "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB;
341
342 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
343 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
344 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
345 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
346
347 def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
348 "lgs\t{$src, $dst|$dst, $src}", []>, TB;
349
350 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable;
351 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable;
352 let mayLoad = 1 in {
353 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable;
354 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable;
355 }
356 } // SchedRW
357
358 //===----------------------------------------------------------------------===//
359 // Descriptor-table support instructions
360
361 let SchedRW = [WriteSystem] in {
362 def SGDT16m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
363 "sgdt{w}\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
364 def SGDT32m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
365 "sgdt{l}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
366 def SGDT64m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
367 "sgdt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
368 def SIDT16m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
369 "sidt{w}\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
370 def SIDT32m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
371 "sidt{l}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
372 def SIDT64m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
373 "sidt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
374 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
375 "sldt{w}\t$dst", []>, TB, OpSize16;
376 let mayStore = 1 in
377 def SLDT16m : I<0x00, MRM0m, (outs), (ins i16mem:$dst),
378 "sldt{w}\t$dst", []>, TB;
379 def SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins),
380 "sldt{l}\t$dst", []>, OpSize32, TB;
381
382 // LLDT is not interpreted specially in 64-bit mode because there is no sign
383 // extension.
384 def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins),
385 "sldt{q}\t$dst", []>, TB, Requires<[In64BitMode]>;
386
387 def LGDT16m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
388 "lgdt{w}\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
389 def LGDT32m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
390 "lgdt{l}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
391 def LGDT64m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
392 "lgdt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
393 def LIDT16m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
394 "lidt{w}\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
395 def LIDT32m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
396 "lidt{l}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
397 def LIDT64m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
398 "lidt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
399 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
400 "lldt{w}\t$src", []>, TB, NotMemoryFoldable;
401 let mayLoad = 1 in
402 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
403 "lldt{w}\t$src", []>, TB, NotMemoryFoldable;
404 } // SchedRW
405
406 //===----------------------------------------------------------------------===//
407 // Specialized register support
408 let SchedRW = [WriteSystem] in {
409 let Uses = [EAX, ECX, EDX] in
410 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
411 let Defs = [EAX, EDX], Uses = [ECX] in
412 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
413
414 let Defs = [RAX, RDX], Uses = [ECX] in
415 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", [(X86rdpmc)]>, TB;
416
417 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
418 "smsw{w}\t$dst", []>, OpSize16, TB;
419 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
420 "smsw{l}\t$dst", []>, OpSize32, TB;
421 // no m form encodable; use SMSW16m
422 def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
423 "smsw{q}\t$dst", []>, TB;
424
425 // For memory operands, there is only a 16-bit form
426 def SMSW16m : I<0x01, MRM4m, (outs), (ins i16mem:$dst),
427 "smsw{w}\t$dst", []>, TB;
428
429 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
430 "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
431 let mayLoad = 1 in
432 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
433 "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
434
435 let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
436 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
437 } // SchedRW
438
439 //===----------------------------------------------------------------------===//
440 // Cache instructions
441 let SchedRW = [WriteSystem] in {
442 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
443 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB;
444
445 // wbnoinvd is like wbinvd, except without invalidation
446 // encoding: like wbinvd + an 0xF3 prefix
447 def WBNOINVD : I<0x09, RawFrm, (outs), (ins), "wbnoinvd",
448 [(int_x86_wbnoinvd)]>, XS,
449 Requires<[HasWBNOINVD]>;
450 } // SchedRW
451
452 //===----------------------------------------------------------------------===//
453 // CET instructions
454 // Use with caution, availability is not predicated on features.
455 let SchedRW = [WriteSystem] in {
456 let Uses = [SSP] in {
457 let Defs = [SSP] in {
458 def INCSSPD : I<0xAE, MRM5r, (outs), (ins GR32:$src), "incsspd\t$src",
459 [(int_x86_incsspd GR32:$src)]>, XS;
460 def INCSSPQ : RI<0xAE, MRM5r, (outs), (ins GR64:$src), "incsspq\t$src",
461 [(int_x86_incsspq GR64:$src)]>, XS;
462 } // Defs SSP
463
464 let Constraints = "$src = $dst" in {
465 def RDSSPD : I<0x1E, MRM1r, (outs GR32:$dst), (ins GR32:$src),
466 "rdsspd\t$dst",
467 [(set GR32:$dst, (int_x86_rdsspd GR32:$src))]>, XS;
468 def RDSSPQ : RI<0x1E, MRM1r, (outs GR64:$dst), (ins GR64:$src),
469 "rdsspq\t$dst",
470 [(set GR64:$dst, (int_x86_rdsspq GR64:$src))]>, XS;
471 }
472
473 let Defs = [SSP] in {
474 def SAVEPREVSSP : I<0x01, MRM_EA, (outs), (ins), "saveprevssp",
475 [(int_x86_saveprevssp)]>, XS;
476 def RSTORSSP : I<0x01, MRM5m, (outs), (ins i32mem:$src),
477 "rstorssp\t$src",
478 [(int_x86_rstorssp addr:$src)]>, XS;
479 } // Defs SSP
480 } // Uses SSP
481
482 def WRSSD : I<0xF6, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
483 "wrssd\t{$src, $dst|$dst, $src}",
484 [(int_x86_wrssd GR32:$src, addr:$dst)]>, T8PS;
485 def WRSSQ : RI<0xF6, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
486 "wrssq\t{$src, $dst|$dst, $src}",
487 [(int_x86_wrssq GR64:$src, addr:$dst)]>, T8PS;
488 def WRUSSD : I<0xF5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
489 "wrussd\t{$src, $dst|$dst, $src}",
490 [(int_x86_wrussd GR32:$src, addr:$dst)]>, T8PD;
491 def WRUSSQ : RI<0xF5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
492 "wrussq\t{$src, $dst|$dst, $src}",
493 [(int_x86_wrussq GR64:$src, addr:$dst)]>, T8PD;
494
495 let Defs = [SSP] in {
496 let Uses = [SSP] in {
497 def SETSSBSY : I<0x01, MRM_E8, (outs), (ins), "setssbsy",
498 [(int_x86_setssbsy)]>, XS;
499 } // Uses SSP
500
501 def CLRSSBSY : I<0xAE, MRM6m, (outs), (ins i32mem:$src),
502 "clrssbsy\t$src",
503 [(int_x86_clrssbsy addr:$src)]>, XS;
504 } // Defs SSP
505 } // SchedRW
506
507 let SchedRW = [WriteSystem] in {
508 def ENDBR64 : I<0x1E, MRM_FA, (outs), (ins), "endbr64", []>, XS;
509 def ENDBR32 : I<0x1E, MRM_FB, (outs), (ins), "endbr32", []>, XS;
510 } // SchedRW
511
512 //===----------------------------------------------------------------------===//
513 // XSAVE instructions
514 let SchedRW = [WriteSystem] in {
515 let Predicates = [HasXSAVE] in {
516 let Defs = [EDX, EAX], Uses = [ECX] in
517 def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB;
518
519 let Uses = [EDX, EAX, ECX] in
520 def XSETBV : I<0x01, MRM_D1, (outs), (ins),
521 "xsetbv",
522 [(int_x86_xsetbv ECX, EDX, EAX)]>, TB;
523
524 } // HasXSAVE
525
526 let Uses = [EDX, EAX] in {
527 def XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
528 "xsave\t$dst",
529 [(int_x86_xsave addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
530 def XSAVE64 : RI<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
531 "xsave64\t$dst",
532 [(int_x86_xsave64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
533 def XRSTOR : I<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
534 "xrstor\t$dst",
535 [(int_x86_xrstor addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
536 def XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
537 "xrstor64\t$dst",
538 [(int_x86_xrstor64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
539 def XSAVEOPT : I<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
540 "xsaveopt\t$dst",
541 [(int_x86_xsaveopt addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT]>;
542 def XSAVEOPT64 : RI<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
543 "xsaveopt64\t$dst",
544 [(int_x86_xsaveopt64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT, In64BitMode]>;
545 def XSAVEC : I<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
546 "xsavec\t$dst",
547 [(int_x86_xsavec addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC]>;
548 def XSAVEC64 : RI<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
549 "xsavec64\t$dst",
550 [(int_x86_xsavec64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC, In64BitMode]>;
551 def XSAVES : I<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
552 "xsaves\t$dst",
553 [(int_x86_xsaves addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
554 def XSAVES64 : RI<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
555 "xsaves64\t$dst",
556 [(int_x86_xsaves64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>;
557 def XRSTORS : I<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
558 "xrstors\t$dst",
559 [(int_x86_xrstors addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
560 def XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
561 "xrstors64\t$dst",
562 [(int_x86_xrstors64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES, In64BitMode]>;
563 } // Uses
564 } // SchedRW
565
566 //===----------------------------------------------------------------------===//
567 // VIA PadLock crypto instructions
568 let Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in
569 def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
570
571 def : InstAlias<"xstorerng", (XSTORE)>;
572
573 let SchedRW = [WriteSystem] in {
574 let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
575 def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB;
576 def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB;
577 def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB;
578 def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB;
579 def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB;
580 }
581
582 let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
583 def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB;
584 def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB;
585 }
586 let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
587 def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB;
588 } // SchedRW
589
590 /*
591 //==-----------------------------------------------------------------------===//
592 // PKU - enable protection key
593 let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
594 def WRPKRU : PseudoI<(outs), (ins GR32:$src),
595 [(int_x86_wrpkru GR32:$src)]>;
596 def RDPKRU : PseudoI<(outs GR32:$dst), (ins),
597 [(set GR32:$dst, (int_x86_rdpkru))]>;
598 }
599 */
600
601 let SchedRW = [WriteSystem] in {
602 let Defs = [EAX, EDX], Uses = [ECX] in
603 def RDPKRUr : I<0x01, MRM_EE, (outs), (ins), "rdpkru", []>, TB;
604 let Uses = [EAX, ECX, EDX] in
605 def WRPKRUr : I<0x01, MRM_EF, (outs), (ins), "wrpkru", []>, TB;
606 } // SchedRW
607
608 //===----------------------------------------------------------------------===//
609 // FS/GS Base Instructions
610 let Predicates = [HasFSGSBase, In64BitMode], SchedRW = [WriteSystem] in {
611 def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
612 "rdfsbase{l}\t$dst",
613 [(set GR32:$dst, (int_x86_rdfsbase_32))]>, XS;
614 def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
615 "rdfsbase{q}\t$dst",
616 [(set GR64:$dst, (int_x86_rdfsbase_64))]>, XS;
617 def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
618 "rdgsbase{l}\t$dst",
619 [(set GR32:$dst, (int_x86_rdgsbase_32))]>, XS;
620 def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
621 "rdgsbase{q}\t$dst",
622 [(set GR64:$dst, (int_x86_rdgsbase_64))]>, XS;
623 def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
624 "wrfsbase{l}\t$src",
625 [(int_x86_wrfsbase_32 GR32:$src)]>, XS;
626 def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
627 "wrfsbase{q}\t$src",
628 [(int_x86_wrfsbase_64 GR64:$src)]>, XS;
629 def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
630 "wrgsbase{l}\t$src",
631 [(int_x86_wrgsbase_32 GR32:$src)]>, XS;
632 def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
633 "wrgsbase{q}\t$src",
634 [(int_x86_wrgsbase_64 GR64:$src)]>, XS;
635 }
636
637 //===----------------------------------------------------------------------===//
638 // INVPCID Instruction
639 let SchedRW = [WriteSystem] in {
640 def INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
641 "invpcid\t{$src2, $src1|$src1, $src2}",
642 [(int_x86_invpcid GR32:$src1, addr:$src2)]>, T8PD,
643 Requires<[Not64BitMode, HasINVPCID]>;
644 def INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
645 "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD,
646 Requires<[In64BitMode, HasINVPCID]>;
647 } // SchedRW
648
649 let Predicates = [In64BitMode, HasINVPCID] in {
650 // The instruction can only use a 64 bit register as the register argument
651 // in 64 bit mode, while the intrinsic only accepts a 32 bit argument
652 // corresponding to it.
653 // The accepted values for now are 0,1,2,3 anyways (see Intel SDM -- INVCPID
654 // type),/ so it doesn't hurt us that one can't supply a 64 bit value here.
655 def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2),
656 (INVPCID64
657 (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit),
658 addr:$src2)>;
659 }
660
661
662 //===----------------------------------------------------------------------===//
663 // SMAP Instruction
664 let Defs = [EFLAGS], SchedRW = [WriteSystem] in {
665 def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, TB;
666 def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, TB;
667 }
668
669 //===----------------------------------------------------------------------===//
670 // SMX Instruction
671 let SchedRW = [WriteSystem] in {
672 let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in {
673 def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, TB;
674 } // Uses, Defs
675 } // SchedRW
676
677 //===----------------------------------------------------------------------===//
678 // TS flag control instruction.
679 let SchedRW = [WriteSystem] in {
680 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
681 }
682
683 //===----------------------------------------------------------------------===//
684 // IF (inside EFLAGS) management instructions.
685 let SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in {
686 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
687 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
688 }
689
690 //===----------------------------------------------------------------------===//
691 // RDPID Instruction
692 let SchedRW = [WriteSystem] in {
693 def RDPID32 : I<0xC7, MRM7r, (outs GR32:$dst), (ins),
694 "rdpid\t$dst", [(set GR32:$dst, (int_x86_rdpid))]>, XS,
695 Requires<[Not64BitMode, HasRDPID]>;
696 def RDPID64 : I<0xC7, MRM7r, (outs GR64:$dst), (ins), "rdpid\t$dst", []>, XS,
697 Requires<[In64BitMode, HasRDPID]>;
698 } // SchedRW
699
700 let Predicates = [In64BitMode, HasRDPID] in {
701 // Due to silly instruction definition, we have to compensate for the
702 // instruction outputing a 64-bit register.
703 def : Pat<(int_x86_rdpid),
704 (EXTRACT_SUBREG (RDPID64), sub_32bit)>;
705 }
706
707
708 //===----------------------------------------------------------------------===//
709 // PTWRITE Instruction - Write Data to a Processor Trace Packet
710 let SchedRW = [WriteSystem] in {
711 def PTWRITEm: I<0xAE, MRM4m, (outs), (ins i32mem:$dst),
712 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 (loadi32 addr:$dst))]>, XS,
713 Requires<[HasPTWRITE]>;
714 def PTWRITE64m : RI<0xAE, MRM4m, (outs), (ins i64mem:$dst),
715 "ptwrite{q}\t$dst", [(int_x86_ptwrite64 (loadi64 addr:$dst))]>, XS,
716 Requires<[In64BitMode, HasPTWRITE]>;
717
718 def PTWRITEr : I<0xAE, MRM4r, (outs), (ins GR32:$dst),
719 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 GR32:$dst)]>, XS,
720 Requires<[HasPTWRITE]>;
721 def PTWRITE64r : RI<0xAE, MRM4r, (outs), (ins GR64:$dst),
722 "ptwrite{q}\t$dst", [(int_x86_ptwrite64 GR64:$dst)]>, XS,
723 Requires<[In64BitMode, HasPTWRITE]>;
724 } // SchedRW
725
726 //===----------------------------------------------------------------------===//
727 // Platform Configuration instruction
728
729 // From ISA docs:
730 // "This instruction is used to execute functions for configuring platform
731 // features.
732 // EAX: Leaf function to be invoked.
733 // RBX/RCX/RDX: Leaf-specific purpose."
734 // "Successful execution of the leaf clears RAX (set to zero) and ZF, CF, PF,
735 // AF, OF, and SF are cleared. In case of failure, the failure reason is
736 // indicated in RAX with ZF set to 1 and CF, PF, AF, OF, and SF are cleared."
737 // Thus all these mentioned registers are considered clobbered.
738
739 let SchedRW = [WriteSystem] in {
740 let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX, RDX, EFLAGS] in
741 def PCONFIG : I<0x01, MRM_C5, (outs), (ins), "pconfig", []>, TB,
742 Requires<[HasPCONFIG]>;
743 } // SchedRW