xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86InstrSystem.td (revision 1db9f3b21e39176dd5b67cf8ac378633b172463e)
10b57cec5SDimitry Andric//===-- X86InstrSystem.td - System Instructions ------------*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric//
90b57cec5SDimitry Andric// This file describes the X86 instructions that are generally used in
100b57cec5SDimitry Andric// privileged modes.  These are not typically used by the compiler, but are
110b57cec5SDimitry Andric// supported for the assembler and disassembler.
120b57cec5SDimitry Andric//
130b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
140b57cec5SDimitry Andric
150b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
160b57cec5SDimitry Andriclet Defs = [RAX, RDX] in
170b57cec5SDimitry Andricdef RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", []>, TB;
180b57cec5SDimitry Andric
190b57cec5SDimitry Andriclet Defs = [RAX, RCX, RDX] in
200b57cec5SDimitry Andricdef RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
210b57cec5SDimitry Andric
220b57cec5SDimitry Andric// CPU flow control instructions
230b57cec5SDimitry Andric
240b57cec5SDimitry Andriclet mayLoad = 1, mayStore = 0, hasSideEffects = 1, isTrap = 1 in {
250b57cec5SDimitry Andric  def TRAP    : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
265ffd83dbSDimitry Andric
275ffd83dbSDimitry Andric  def UD1Wm   : I<0xB9, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2881ad6265SDimitry Andric                  "ud1{w}\t{$src2, $src1|$src1, $src2}", []>, TB, OpSize16;
295ffd83dbSDimitry Andric  def UD1Lm   : I<0xB9, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3081ad6265SDimitry Andric                  "ud1{l}\t{$src2, $src1|$src1, $src2}", []>, TB, OpSize32;
315ffd83dbSDimitry Andric  def UD1Qm   : RI<0xB9, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
3281ad6265SDimitry Andric                   "ud1{q}\t{$src2, $src1|$src1, $src2}", []>, TB;
335ffd83dbSDimitry Andric
345ffd83dbSDimitry Andric  def UD1Wr   : I<0xB9, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3581ad6265SDimitry Andric                  "ud1{w}\t{$src2, $src1|$src1, $src2}", []>, TB, OpSize16;
365ffd83dbSDimitry Andric  def UD1Lr   : I<0xB9, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3781ad6265SDimitry Andric                  "ud1{l}\t{$src2, $src1|$src1, $src2}", []>, TB, OpSize32;
385ffd83dbSDimitry Andric  def UD1Qr   : RI<0xB9, MRMSrcReg, (outs), (ins GR64:$src1, GR64:$src2),
3981ad6265SDimitry Andric                   "ud1{q}\t{$src2, $src1|$src1, $src2}", []>, TB;
400b57cec5SDimitry Andric}
410b57cec5SDimitry Andric
42fe6060f1SDimitry Andriclet isTerminator = 1 in
430b57cec5SDimitry Andric  def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
440b57cec5SDimitry Andricdef RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric// Interrupt and SysCall Instructions.
470b57cec5SDimitry Andriclet Uses = [EFLAGS] in
480b57cec5SDimitry Andric  def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>, Requires<[Not64BitMode]>;
490b57cec5SDimitry Andric
500b57cec5SDimitry Andricdef INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", [(int_x86_int (i8 3))]>;
510b57cec5SDimitry Andric
52e8d8bef9SDimitry Andricdef UBSAN_UD1 : PseudoI<(outs), (ins i32imm:$kind), [(ubsantrap (i32 timm:$kind))]>;
530b57cec5SDimitry Andric// The long form of "int $3" turns into int3 as a size optimization.
540b57cec5SDimitry Andric// FIXME: This doesn't work because InstAlias can't match immediate constants.
550b57cec5SDimitry Andric//def : InstAlias<"int\t$3", (INT3)>;
560b57cec5SDimitry Andric
570b57cec5SDimitry Andricdef INT : Ii8<0xcd, RawFrm, (outs), (ins u8imm:$trap), "int\t$trap",
588bcb0991SDimitry Andric              [(int_x86_int timm:$trap)]>;
590b57cec5SDimitry Andric
600b57cec5SDimitry Andric
610b57cec5SDimitry Andricdef SYSCALL  : I<0x05, RawFrm, (outs), (ins), "syscall", []>, TB;
620b57cec5SDimitry Andricdef SYSRET   : I<0x07, RawFrm, (outs), (ins), "sysret{l}", []>, TB;
630b57cec5SDimitry Andricdef SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysretq", []>, TB,
640b57cec5SDimitry Andric               Requires<[In64BitMode]>;
650b57cec5SDimitry Andric
660b57cec5SDimitry Andricdef SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", []>, TB;
670b57cec5SDimitry Andric
680b57cec5SDimitry Andricdef SYSEXIT   : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", []>, TB;
690b57cec5SDimitry Andricdef SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexitq", []>, TB,
700b57cec5SDimitry Andric                  Requires<[In64BitMode]>;
710b57cec5SDimitry Andric} // SchedRW
720b57cec5SDimitry Andric
730b57cec5SDimitry Andricdef : Pat<(debugtrap),
7481ad6265SDimitry Andric          (INT3)>, Requires<[NotPS]>;
750b57cec5SDimitry Andricdef : Pat<(debugtrap),
7681ad6265SDimitry Andric          (INT (i8 0x41))>, Requires<[IsPS]>;
770b57cec5SDimitry Andric
780b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
790b57cec5SDimitry Andric//  Input/Output Instructions.
800b57cec5SDimitry Andric//
810b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
820b57cec5SDimitry Andriclet Defs = [AL], Uses = [DX] in
830b57cec5SDimitry Andricdef IN8rr  : I<0xEC, RawFrm, (outs), (ins), "in{b}\t{%dx, %al|al, dx}", []>;
840b57cec5SDimitry Andriclet Defs = [AX], Uses = [DX] in
850b57cec5SDimitry Andricdef IN16rr : I<0xED, RawFrm, (outs), (ins), "in{w}\t{%dx, %ax|ax, dx}", []>,
860b57cec5SDimitry Andric               OpSize16;
870b57cec5SDimitry Andriclet Defs = [EAX], Uses = [DX] in
880b57cec5SDimitry Andricdef IN32rr : I<0xED, RawFrm, (outs), (ins), "in{l}\t{%dx, %eax|eax, dx}", []>,
890b57cec5SDimitry Andric               OpSize32;
900b57cec5SDimitry Andric
910b57cec5SDimitry Andriclet Defs = [AL] in
920b57cec5SDimitry Andricdef IN8ri  : Ii8<0xE4, RawFrm, (outs), (ins u8imm:$port),
930b57cec5SDimitry Andric                 "in{b}\t{$port, %al|al, $port}", []>;
940b57cec5SDimitry Andriclet Defs = [AX] in
950b57cec5SDimitry Andricdef IN16ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
960b57cec5SDimitry Andric                 "in{w}\t{$port, %ax|ax, $port}", []>, OpSize16;
970b57cec5SDimitry Andriclet Defs = [EAX] in
980b57cec5SDimitry Andricdef IN32ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port),
990b57cec5SDimitry Andric                 "in{l}\t{$port, %eax|eax, $port}", []>, OpSize32;
1000b57cec5SDimitry Andric
1010b57cec5SDimitry Andriclet Uses = [DX, AL] in
1020b57cec5SDimitry Andricdef OUT8rr  : I<0xEE, RawFrm, (outs), (ins), "out{b}\t{%al, %dx|dx, al}", []>;
1030b57cec5SDimitry Andriclet Uses = [DX, AX] in
1040b57cec5SDimitry Andricdef OUT16rr : I<0xEF, RawFrm, (outs), (ins), "out{w}\t{%ax, %dx|dx, ax}", []>,
1050b57cec5SDimitry Andric                OpSize16;
1060b57cec5SDimitry Andriclet Uses = [DX, EAX] in
1070b57cec5SDimitry Andricdef OUT32rr : I<0xEF, RawFrm, (outs), (ins), "out{l}\t{%eax, %dx|dx, eax}", []>,
1080b57cec5SDimitry Andric                OpSize32;
1090b57cec5SDimitry Andric
1100b57cec5SDimitry Andriclet Uses = [AL] in
1110b57cec5SDimitry Andricdef OUT8ir  : Ii8<0xE6, RawFrm, (outs), (ins u8imm:$port),
1120b57cec5SDimitry Andric                   "out{b}\t{%al, $port|$port, al}", []>;
1130b57cec5SDimitry Andriclet Uses = [AX] in
1140b57cec5SDimitry Andricdef OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
1150b57cec5SDimitry Andric                   "out{w}\t{%ax, $port|$port, ax}", []>, OpSize16;
1160b57cec5SDimitry Andriclet Uses = [EAX] in
1170b57cec5SDimitry Andricdef OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port),
1180b57cec5SDimitry Andric                  "out{l}\t{%eax, $port|$port, eax}", []>, OpSize32;
1190b57cec5SDimitry Andric
1200b57cec5SDimitry Andric} // SchedRW
1210b57cec5SDimitry Andric
1220b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1230b57cec5SDimitry Andric// Moves to and from debug registers
1240b57cec5SDimitry Andric
1250b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
1260b57cec5SDimitry Andricdef MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1270b57cec5SDimitry Andric                "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
1280b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
1290b57cec5SDimitry Andricdef MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src),
1300b57cec5SDimitry Andric                "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
1310b57cec5SDimitry Andric                Requires<[In64BitMode]>;
1320b57cec5SDimitry Andric
1330b57cec5SDimitry Andricdef MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1340b57cec5SDimitry Andric                "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
1350b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
1360b57cec5SDimitry Andricdef MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src),
1370b57cec5SDimitry Andric                "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
1380b57cec5SDimitry Andric                Requires<[In64BitMode]>;
1390b57cec5SDimitry Andric} // SchedRW
1400b57cec5SDimitry Andric
1410b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1420b57cec5SDimitry Andric// Moves to and from control registers
1430b57cec5SDimitry Andric
1440b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
1450b57cec5SDimitry Andricdef MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1460b57cec5SDimitry Andric                "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
1470b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
1480b57cec5SDimitry Andricdef MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src),
1490b57cec5SDimitry Andric                "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
1500b57cec5SDimitry Andric                Requires<[In64BitMode]>;
1510b57cec5SDimitry Andric
1520b57cec5SDimitry Andricdef MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1530b57cec5SDimitry Andric                "mov{l}\t{$src, $dst|$dst, $src}", []>, TB,
1540b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
1550b57cec5SDimitry Andricdef MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src),
1560b57cec5SDimitry Andric                "mov{q}\t{$src, $dst|$dst, $src}", []>, TB,
1570b57cec5SDimitry Andric                Requires<[In64BitMode]>;
1580b57cec5SDimitry Andric} // SchedRW
1590b57cec5SDimitry Andric
1600b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1610b57cec5SDimitry Andric// Segment override instruction prefixes
1620b57cec5SDimitry Andric
1630b57cec5SDimitry Andriclet SchedRW = [WriteNop] in {
1645ffd83dbSDimitry Andricdef CS_PREFIX : I<0x2E, PrefixByte, (outs), (ins), "cs", []>;
1655ffd83dbSDimitry Andricdef SS_PREFIX : I<0x36, PrefixByte, (outs), (ins), "ss", []>;
1665ffd83dbSDimitry Andricdef DS_PREFIX : I<0x3E, PrefixByte, (outs), (ins), "ds", []>;
1675ffd83dbSDimitry Andricdef ES_PREFIX : I<0x26, PrefixByte, (outs), (ins), "es", []>;
1685ffd83dbSDimitry Andricdef FS_PREFIX : I<0x64, PrefixByte, (outs), (ins), "fs", []>;
1695ffd83dbSDimitry Andricdef GS_PREFIX : I<0x65, PrefixByte, (outs), (ins), "gs", []>;
1700b57cec5SDimitry Andric} // SchedRW
1710b57cec5SDimitry Andric
1720b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
173e8d8bef9SDimitry Andric// Address-size override prefixes.
174e8d8bef9SDimitry Andric//
175e8d8bef9SDimitry Andric
176e8d8bef9SDimitry Andriclet SchedRW = [WriteNop] in {
177e8d8bef9SDimitry Andricdef ADDR16_PREFIX : I<0x67, PrefixByte, (outs), (ins), "addr16", []>,
178e8d8bef9SDimitry Andric                      Requires<[In32BitMode]>;
179e8d8bef9SDimitry Andricdef ADDR32_PREFIX : I<0x67, PrefixByte, (outs), (ins), "addr32", []>,
180e8d8bef9SDimitry Andric                      Requires<[In64BitMode]>;
181e8d8bef9SDimitry Andric} // SchedRW
182e8d8bef9SDimitry Andric
183e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===//
1840b57cec5SDimitry Andric// Moves to and from segment registers.
1850b57cec5SDimitry Andric//
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andriclet SchedRW = [WriteMove] in {
1880b57cec5SDimitry Andricdef MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1890b57cec5SDimitry Andric                "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
1900b57cec5SDimitry Andricdef MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1910b57cec5SDimitry Andric                "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
1920b57cec5SDimitry Andricdef MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src),
1930b57cec5SDimitry Andric                 "mov{q}\t{$src, $dst|$dst, $src}", []>;
1940b57cec5SDimitry Andriclet mayStore = 1 in {
1950b57cec5SDimitry Andricdef MOV16ms : I<0x8C, MRMDestMem, (outs), (ins i16mem:$dst, SEGMENT_REG:$src),
1960b57cec5SDimitry Andric                "mov{w}\t{$src, $dst|$dst, $src}", []>;
1970b57cec5SDimitry Andric}
1980b57cec5SDimitry Andricdef MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1990b57cec5SDimitry Andric                "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16;
2000b57cec5SDimitry Andricdef MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
2010b57cec5SDimitry Andric                "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32;
2020b57cec5SDimitry Andricdef MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src),
2030b57cec5SDimitry Andric                 "mov{q}\t{$src, $dst|$dst, $src}", []>;
2040b57cec5SDimitry Andriclet mayLoad = 1 in {
2050b57cec5SDimitry Andricdef MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
2060b57cec5SDimitry Andric                "mov{w}\t{$src, $dst|$dst, $src}", []>;
2070b57cec5SDimitry Andric}
2080b57cec5SDimitry Andric} // SchedRW
2090b57cec5SDimitry Andric
2100b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2110b57cec5SDimitry Andric// Segmentation support instructions.
2120b57cec5SDimitry Andric
2130b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
2140b57cec5SDimitry Andricdef SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB;
2150b57cec5SDimitry Andric
2160b57cec5SDimitry Andriclet mayLoad = 1 in
2170b57cec5SDimitry Andricdef LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
2180b57cec5SDimitry Andric                "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
21906c3fb27SDimitry Andric                OpSize16;
220590d96feSDimitry Andricdef LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16orGR32orGR64:$src),
2210b57cec5SDimitry Andric                "lar{w}\t{$src, $dst|$dst, $src}", []>, TB,
22206c3fb27SDimitry Andric                OpSize16;
2230b57cec5SDimitry Andric
2240b57cec5SDimitry Andriclet mayLoad = 1 in
2250b57cec5SDimitry Andricdef LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2260b57cec5SDimitry Andric                "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
22706c3fb27SDimitry Andric                OpSize32;
228590d96feSDimitry Andricdef LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR16orGR32orGR64:$src),
2290b57cec5SDimitry Andric                "lar{l}\t{$src, $dst|$dst, $src}", []>, TB,
23006c3fb27SDimitry Andric                OpSize32;
2310b57cec5SDimitry Andriclet mayLoad = 1 in
2320b57cec5SDimitry Andricdef LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
23306c3fb27SDimitry Andric                 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB;
234590d96feSDimitry Andricdef LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR16orGR32orGR64:$src),
23506c3fb27SDimitry Andric                 "lar{q}\t{$src, $dst|$dst, $src}", []>, TB;
2360b57cec5SDimitry Andric
2370b57cec5SDimitry Andriclet mayLoad = 1 in
2380b57cec5SDimitry Andricdef LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
2390b57cec5SDimitry Andric                "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
24006c3fb27SDimitry Andric                OpSize16;
241590d96feSDimitry Andricdef LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16orGR32orGR64:$src),
2420b57cec5SDimitry Andric                "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB,
24306c3fb27SDimitry Andric                OpSize16;
2440b57cec5SDimitry Andriclet mayLoad = 1 in
2450b57cec5SDimitry Andricdef LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2460b57cec5SDimitry Andric                "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
24706c3fb27SDimitry Andric                OpSize32;
248590d96feSDimitry Andricdef LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR16orGR32orGR64:$src),
2490b57cec5SDimitry Andric                "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB,
25006c3fb27SDimitry Andric                OpSize32;
2510b57cec5SDimitry Andriclet mayLoad = 1 in
2520b57cec5SDimitry Andricdef LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
25306c3fb27SDimitry Andric                 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB;
254590d96feSDimitry Andricdef LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR16orGR32orGR64:$src),
25506c3fb27SDimitry Andric                 "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB;
2560b57cec5SDimitry Andric
2570b57cec5SDimitry Andricdef INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andricdef STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins),
2600b57cec5SDimitry Andric               "str{w}\t$dst", []>, TB, OpSize16;
2610b57cec5SDimitry Andricdef STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins),
2620b57cec5SDimitry Andric               "str{l}\t$dst", []>, TB, OpSize32;
2630b57cec5SDimitry Andricdef STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins),
2640b57cec5SDimitry Andric                "str{q}\t$dst", []>, TB;
2650b57cec5SDimitry Andriclet mayStore = 1 in
2660b57cec5SDimitry Andricdef STRm   : I<0x00, MRM1m, (outs), (ins i16mem:$dst), "str{w}\t$dst", []>, TB;
2670b57cec5SDimitry Andric
26806c3fb27SDimitry Andricdef LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src), "ltr{w}\t$src", []>, TB;
2690b57cec5SDimitry Andriclet mayLoad = 1 in
27006c3fb27SDimitry Andricdef LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src), "ltr{w}\t$src", []>, TB;
2710b57cec5SDimitry Andric
2720b57cec5SDimitry Andricdef PUSHCS16 : I<0x0E, RawFrm, (outs), (ins), "push{w}\t{%cs|cs}", []>,
2730b57cec5SDimitry Andric                 OpSize16, Requires<[Not64BitMode]>;
2740b57cec5SDimitry Andricdef PUSHCS32 : I<0x0E, RawFrm, (outs), (ins), "push{l}\t{%cs|cs}", []>,
2750b57cec5SDimitry Andric                 OpSize32, Requires<[Not64BitMode]>;
2760b57cec5SDimitry Andricdef PUSHSS16 : I<0x16, RawFrm, (outs), (ins), "push{w}\t{%ss|ss}", []>,
2770b57cec5SDimitry Andric                 OpSize16, Requires<[Not64BitMode]>;
2780b57cec5SDimitry Andricdef PUSHSS32 : I<0x16, RawFrm, (outs), (ins), "push{l}\t{%ss|ss}", []>,
2790b57cec5SDimitry Andric                 OpSize32, Requires<[Not64BitMode]>;
2800b57cec5SDimitry Andricdef PUSHDS16 : I<0x1E, RawFrm, (outs), (ins), "push{w}\t{%ds|ds}", []>,
2810b57cec5SDimitry Andric                 OpSize16, Requires<[Not64BitMode]>;
2820b57cec5SDimitry Andricdef PUSHDS32 : I<0x1E, RawFrm, (outs), (ins), "push{l}\t{%ds|ds}", []>,
2830b57cec5SDimitry Andric                 OpSize32, Requires<[Not64BitMode]>;
2840b57cec5SDimitry Andricdef PUSHES16 : I<0x06, RawFrm, (outs), (ins), "push{w}\t{%es|es}", []>,
2850b57cec5SDimitry Andric                 OpSize16, Requires<[Not64BitMode]>;
2860b57cec5SDimitry Andricdef PUSHES32 : I<0x06, RawFrm, (outs), (ins), "push{l}\t{%es|es}", []>,
2870b57cec5SDimitry Andric                 OpSize32, Requires<[Not64BitMode]>;
2880b57cec5SDimitry Andricdef PUSHFS16 : I<0xa0, RawFrm, (outs), (ins), "push{w}\t{%fs|fs}", []>,
2890b57cec5SDimitry Andric                 OpSize16, TB;
2900b57cec5SDimitry Andricdef PUSHFS32 : I<0xa0, RawFrm, (outs), (ins), "push{l}\t{%fs|fs}", []>, TB,
2910b57cec5SDimitry Andric                 OpSize32, Requires<[Not64BitMode]>;
2920b57cec5SDimitry Andricdef PUSHGS16 : I<0xa8, RawFrm, (outs), (ins), "push{w}\t{%gs|gs}", []>,
2930b57cec5SDimitry Andric                 OpSize16, TB;
2940b57cec5SDimitry Andricdef PUSHGS32 : I<0xa8, RawFrm, (outs), (ins), "push{l}\t{%gs|gs}", []>, TB,
2950b57cec5SDimitry Andric                 OpSize32, Requires<[Not64BitMode]>;
2960b57cec5SDimitry Andricdef PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), "push{q}\t{%fs|fs}", []>, TB,
2970b57cec5SDimitry Andric                 OpSize32, Requires<[In64BitMode]>;
2980b57cec5SDimitry Andricdef PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), "push{q}\t{%gs|gs}", []>, TB,
2990b57cec5SDimitry Andric                 OpSize32, Requires<[In64BitMode]>;
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andric// No "pop cs" instruction.
3020b57cec5SDimitry Andricdef POPSS16 : I<0x17, RawFrm, (outs), (ins), "pop{w}\t{%ss|ss}", []>,
3030b57cec5SDimitry Andric              OpSize16, Requires<[Not64BitMode]>;
3040b57cec5SDimitry Andricdef POPSS32 : I<0x17, RawFrm, (outs), (ins), "pop{l}\t{%ss|ss}", []>,
3050b57cec5SDimitry Andric              OpSize32, Requires<[Not64BitMode]>;
3060b57cec5SDimitry Andric
3070b57cec5SDimitry Andricdef POPDS16 : I<0x1F, RawFrm, (outs), (ins), "pop{w}\t{%ds|ds}", []>,
3080b57cec5SDimitry Andric              OpSize16, Requires<[Not64BitMode]>;
3090b57cec5SDimitry Andricdef POPDS32 : I<0x1F, RawFrm, (outs), (ins), "pop{l}\t{%ds|ds}", []>,
3100b57cec5SDimitry Andric              OpSize32, Requires<[Not64BitMode]>;
3110b57cec5SDimitry Andric
3120b57cec5SDimitry Andricdef POPES16 : I<0x07, RawFrm, (outs), (ins), "pop{w}\t{%es|es}", []>,
3130b57cec5SDimitry Andric              OpSize16, Requires<[Not64BitMode]>;
3140b57cec5SDimitry Andricdef POPES32 : I<0x07, RawFrm, (outs), (ins), "pop{l}\t{%es|es}", []>,
3150b57cec5SDimitry Andric              OpSize32, Requires<[Not64BitMode]>;
3160b57cec5SDimitry Andric
3170b57cec5SDimitry Andricdef POPFS16 : I<0xa1, RawFrm, (outs), (ins), "pop{w}\t{%fs|fs}", []>,
3180b57cec5SDimitry Andric                OpSize16, TB;
3190b57cec5SDimitry Andricdef POPFS32 : I<0xa1, RawFrm, (outs), (ins), "pop{l}\t{%fs|fs}", []>, TB,
3200b57cec5SDimitry Andric                OpSize32, Requires<[Not64BitMode]>;
3210b57cec5SDimitry Andricdef POPFS64 : I<0xa1, RawFrm, (outs), (ins), "pop{q}\t{%fs|fs}", []>, TB,
3220b57cec5SDimitry Andric                OpSize32, Requires<[In64BitMode]>;
3230b57cec5SDimitry Andric
3240b57cec5SDimitry Andricdef POPGS16 : I<0xa9, RawFrm, (outs), (ins), "pop{w}\t{%gs|gs}", []>,
3250b57cec5SDimitry Andric                OpSize16, TB;
3260b57cec5SDimitry Andricdef POPGS32 : I<0xa9, RawFrm, (outs), (ins), "pop{l}\t{%gs|gs}", []>, TB,
3270b57cec5SDimitry Andric                OpSize32, Requires<[Not64BitMode]>;
3280b57cec5SDimitry Andricdef POPGS64 : I<0xa9, RawFrm, (outs), (ins), "pop{q}\t{%gs|gs}", []>, TB,
3290b57cec5SDimitry Andric                OpSize32, Requires<[In64BitMode]>;
3300b57cec5SDimitry Andric
3310b57cec5SDimitry Andricdef LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
3320b57cec5SDimitry Andric                "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
3330b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
3340b57cec5SDimitry Andricdef LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
3350b57cec5SDimitry Andric                "lds{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
3360b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
3370b57cec5SDimitry Andric
3380b57cec5SDimitry Andricdef LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
3390b57cec5SDimitry Andric                "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
3400b57cec5SDimitry Andricdef LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
3410b57cec5SDimitry Andric                "lss{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
3420b57cec5SDimitry Andricdef LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
3430b57cec5SDimitry Andric                 "lss{q}\t{$src, $dst|$dst, $src}", []>, TB;
3440b57cec5SDimitry Andric
3450b57cec5SDimitry Andricdef LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
3460b57cec5SDimitry Andric                "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize16,
3470b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
3480b57cec5SDimitry Andricdef LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
3490b57cec5SDimitry Andric                "les{l}\t{$src, $dst|$dst, $src}", []>, OpSize32,
3500b57cec5SDimitry Andric                Requires<[Not64BitMode]>;
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andricdef LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
3530b57cec5SDimitry Andric                "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
3540b57cec5SDimitry Andricdef LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
3550b57cec5SDimitry Andric                "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
3560b57cec5SDimitry Andricdef LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
3570b57cec5SDimitry Andric                 "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB;
3580b57cec5SDimitry Andric
3590b57cec5SDimitry Andricdef LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src),
3600b57cec5SDimitry Andric                "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16;
3610b57cec5SDimitry Andricdef LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src),
3620b57cec5SDimitry Andric                "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32;
3630b57cec5SDimitry Andric
3640b57cec5SDimitry Andricdef LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src),
3650b57cec5SDimitry Andric                 "lgs{q}\t{$src, $dst|$dst, $src}", []>, TB;
3660b57cec5SDimitry Andric
36706c3fb27SDimitry Andricdef VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg), "verr\t$seg", []>, TB;
36806c3fb27SDimitry Andricdef VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg), "verw\t$seg", []>, TB;
3690b57cec5SDimitry Andriclet mayLoad = 1 in {
37006c3fb27SDimitry Andricdef VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg), "verr\t$seg", []>, TB;
37106c3fb27SDimitry Andricdef VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg), "verw\t$seg", []>, TB;
3720b57cec5SDimitry Andric}
3730b57cec5SDimitry Andric} // SchedRW
3740b57cec5SDimitry Andric
3750b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
3760b57cec5SDimitry Andric// Descriptor-table support instructions
3770b57cec5SDimitry Andric
3780b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
3790b57cec5SDimitry Andricdef SGDT16m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
3800b57cec5SDimitry Andric                "sgdtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
3810b57cec5SDimitry Andricdef SGDT32m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
3820b57cec5SDimitry Andric                "sgdt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
3830b57cec5SDimitry Andricdef SGDT64m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst),
3840b57cec5SDimitry Andric                "sgdt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
3850b57cec5SDimitry Andricdef SIDT16m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
3860b57cec5SDimitry Andric                "sidtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>;
3870b57cec5SDimitry Andricdef SIDT32m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
3880b57cec5SDimitry Andric                "sidt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
3890b57cec5SDimitry Andricdef SIDT64m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst),
3900b57cec5SDimitry Andric                "sidt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
3910b57cec5SDimitry Andricdef SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
3920b57cec5SDimitry Andric                "sldt{w}\t$dst", []>, TB, OpSize16;
3930b57cec5SDimitry Andriclet mayStore = 1 in
3940b57cec5SDimitry Andricdef SLDT16m : I<0x00, MRM0m, (outs), (ins i16mem:$dst),
3950b57cec5SDimitry Andric                "sldt{w}\t$dst", []>, TB;
3960b57cec5SDimitry Andricdef SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins),
3970b57cec5SDimitry Andric                "sldt{l}\t$dst", []>, OpSize32, TB;
3980b57cec5SDimitry Andric
3990b57cec5SDimitry Andric// LLDT is not interpreted specially in 64-bit mode because there is no sign
4000b57cec5SDimitry Andric//   extension.
4010b57cec5SDimitry Andricdef SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins),
4020b57cec5SDimitry Andric                 "sldt{q}\t$dst", []>, TB, Requires<[In64BitMode]>;
4030b57cec5SDimitry Andric
4040b57cec5SDimitry Andricdef LGDT16m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
4050b57cec5SDimitry Andric                "lgdtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
4060b57cec5SDimitry Andricdef LGDT32m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
4070b57cec5SDimitry Andric                "lgdt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
4080b57cec5SDimitry Andricdef LGDT64m : I<0x01, MRM2m, (outs), (ins opaquemem:$src),
4090b57cec5SDimitry Andric                "lgdt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
4100b57cec5SDimitry Andricdef LIDT16m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
4110b57cec5SDimitry Andric                "lidtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>;
4120b57cec5SDimitry Andricdef LIDT32m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
4130b57cec5SDimitry Andric                "lidt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>;
4140b57cec5SDimitry Andricdef LIDT64m : I<0x01, MRM3m, (outs), (ins opaquemem:$src),
4150b57cec5SDimitry Andric                "lidt{q}\t$src", []>, TB, Requires<[In64BitMode]>;
4160b57cec5SDimitry Andricdef LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
41706c3fb27SDimitry Andric                "lldt{w}\t$src", []>, TB;
4180b57cec5SDimitry Andriclet mayLoad = 1 in
4190b57cec5SDimitry Andricdef LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
42006c3fb27SDimitry Andric                "lldt{w}\t$src", []>, TB;
4210b57cec5SDimitry Andric} // SchedRW
4220b57cec5SDimitry Andric
4230b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
4240b57cec5SDimitry Andric// Specialized register support
4250b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
4260b57cec5SDimitry Andriclet Uses = [EAX, ECX, EDX] in
4270b57cec5SDimitry Andricdef WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
428bdd1243dSDimitry Andriclet Uses = [EAX, ECX, EDX] in
429cb14a3feSDimitry Andricdef WRMSRNS : I<0x01, MRM_C6, (outs), (ins), "wrmsrns", []>, TB;
4300b57cec5SDimitry Andriclet Defs = [EAX, EDX], Uses = [ECX] in
4310b57cec5SDimitry Andricdef RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
43206c3fb27SDimitry Andriclet Defs = [RAX, EFLAGS], Uses = [RBX, RCX], Predicates = [In64BitMode] in
433cb14a3feSDimitry Andricdef PBNDKB : I<0x01, MRM_C7, (outs), (ins), "pbndkb", []>, TB;
434bdd1243dSDimitry Andriclet Uses = [RSI, RDI, RCX], Predicates = [In64BitMode] in {
435cb14a3feSDimitry Andricdef WRMSRLIST : I<0x01, MRM_C6, (outs), (ins), "wrmsrlist", []>, TB, XS;
436cb14a3feSDimitry Andricdef RDMSRLIST : I<0x01, MRM_C6, (outs), (ins), "rdmsrlist", []>, TB, XD;
437bdd1243dSDimitry Andric}
438bdd1243dSDimitry Andric
4395f757f3fSDimitry Andriclet Predicates = [HasUSERMSR], mayLoad = 1 in {
4405f757f3fSDimitry Andric  def URDMSRrr : I<0xf8, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4415f757f3fSDimitry Andric                "urdmsr\t{$src, $dst|$dst, $src}",
442cb14a3feSDimitry Andric                [(set GR64:$dst, (int_x86_urdmsr GR64:$src))]>, T8, XD;
4435f757f3fSDimitry Andric  def URDMSRri : Ii32<0xf8, MRM0r, (outs GR64:$dst), (ins i64i32imm:$imm),
4445f757f3fSDimitry Andric                "urdmsr\t{$imm, $dst|$dst, $imm}",
445cb14a3feSDimitry Andric                [(set GR64:$dst, (int_x86_urdmsr i64immSExt32_su:$imm))]>, T_MAP7, XD, VEX;
4465f757f3fSDimitry Andric}
4475f757f3fSDimitry Andriclet Predicates = [HasUSERMSR], mayStore = 1 in {
4485f757f3fSDimitry Andric  def UWRMSRrr : I<0xf8, MRMSrcReg, (outs), (ins GR64:$src1, GR64:$src2),
449647cbc5dSDimitry Andric                "uwrmsr\t{$src2, $src1|$src1, $src2}",
450cb14a3feSDimitry Andric                [(int_x86_uwrmsr GR64:$src1, GR64:$src2)]>, T8, XS;
4515f757f3fSDimitry Andric  def UWRMSRir : Ii32<0xf8, MRM0r, (outs), (ins GR64:$src, i64i32imm:$imm),
4525f757f3fSDimitry Andric                "uwrmsr\t{$src, $imm|$imm, $src}",
453647cbc5dSDimitry Andric                [(int_x86_uwrmsr i64immSExt32_su:$imm, GR64:$src)]>, T_MAP7, XS, VEX;
4545f757f3fSDimitry Andric}
4550b57cec5SDimitry Andriclet Defs = [RAX, RDX], Uses = [ECX] in
4560b57cec5SDimitry Andricdef RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4570b57cec5SDimitry Andric
4580b57cec5SDimitry Andricdef SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4590b57cec5SDimitry Andric                "smsw{w}\t$dst", []>, OpSize16, TB;
4600b57cec5SDimitry Andricdef SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4610b57cec5SDimitry Andric                "smsw{l}\t$dst", []>, OpSize32, TB;
4620b57cec5SDimitry Andric// no m form encodable; use SMSW16m
4630b57cec5SDimitry Andricdef SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
4640b57cec5SDimitry Andric                 "smsw{q}\t$dst", []>, TB;
4650b57cec5SDimitry Andric
4660b57cec5SDimitry Andric// For memory operands, there is only a 16-bit form
4670b57cec5SDimitry Andricdef SMSW16m : I<0x01, MRM4m, (outs), (ins i16mem:$dst),
4680b57cec5SDimitry Andric                "smsw{w}\t$dst", []>, TB;
4690b57cec5SDimitry Andric
4700b57cec5SDimitry Andricdef LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
47106c3fb27SDimitry Andric                "lmsw{w}\t$src", []>, TB;
4720b57cec5SDimitry Andriclet mayLoad = 1 in
4730b57cec5SDimitry Andricdef LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
47406c3fb27SDimitry Andric                "lmsw{w}\t$src", []>, TB;
4750b57cec5SDimitry Andric
4760b57cec5SDimitry Andriclet Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
4770b57cec5SDimitry Andric  def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4780b57cec5SDimitry Andric} // SchedRW
4790b57cec5SDimitry Andric
4800b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
4810b57cec5SDimitry Andric// Cache instructions
4820b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
4830b57cec5SDimitry Andricdef INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
484cb14a3feSDimitry Andricdef WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB, PS;
4850b57cec5SDimitry Andric
4860b57cec5SDimitry Andric// wbnoinvd is like wbinvd, except without invalidation
4870b57cec5SDimitry Andric// encoding: like wbinvd + an 0xF3 prefix
4880b57cec5SDimitry Andricdef WBNOINVD : I<0x09, RawFrm, (outs), (ins), "wbnoinvd",
489cb14a3feSDimitry Andric                 [(int_x86_wbnoinvd)]>, TB, XS,
4900b57cec5SDimitry Andric                 Requires<[HasWBNOINVD]>;
4910b57cec5SDimitry Andric} // SchedRW
4920b57cec5SDimitry Andric
4930b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
4940b57cec5SDimitry Andric// CET instructions
4950b57cec5SDimitry Andric// Use with caution, availability is not predicated on features.
4960b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
4970b57cec5SDimitry Andric  let Uses = [SSP] in {
4980b57cec5SDimitry Andric    let Defs = [SSP] in {
4990b57cec5SDimitry Andric      def INCSSPD : I<0xAE, MRM5r, (outs), (ins GR32:$src), "incsspd\t$src",
500cb14a3feSDimitry Andric                       [(int_x86_incsspd GR32:$src)]>, TB, XS;
5010b57cec5SDimitry Andric      def INCSSPQ : RI<0xAE, MRM5r, (outs), (ins GR64:$src), "incsspq\t$src",
502cb14a3feSDimitry Andric                       [(int_x86_incsspq GR64:$src)]>, TB, XS;
5030b57cec5SDimitry Andric    } // Defs SSP
5040b57cec5SDimitry Andric
5050b57cec5SDimitry Andric    let Constraints = "$src = $dst" in {
5060b57cec5SDimitry Andric      def RDSSPD : I<0x1E, MRM1r, (outs GR32:$dst), (ins GR32:$src),
5070b57cec5SDimitry Andric                     "rdsspd\t$dst",
508cb14a3feSDimitry Andric                     [(set GR32:$dst, (int_x86_rdsspd GR32:$src))]>, TB, XS;
5090b57cec5SDimitry Andric      def RDSSPQ : RI<0x1E, MRM1r, (outs GR64:$dst), (ins GR64:$src),
5100b57cec5SDimitry Andric                     "rdsspq\t$dst",
511cb14a3feSDimitry Andric                     [(set GR64:$dst, (int_x86_rdsspq GR64:$src))]>, TB, XS;
5120b57cec5SDimitry Andric    }
5130b57cec5SDimitry Andric
5140b57cec5SDimitry Andric    let Defs = [SSP] in {
5150b57cec5SDimitry Andric      def SAVEPREVSSP : I<0x01, MRM_EA, (outs), (ins), "saveprevssp",
516cb14a3feSDimitry Andric                       [(int_x86_saveprevssp)]>, TB, XS;
5170b57cec5SDimitry Andric      def RSTORSSP : I<0x01, MRM5m, (outs), (ins i32mem:$src),
5180b57cec5SDimitry Andric                       "rstorssp\t$src",
519cb14a3feSDimitry Andric                       [(int_x86_rstorssp addr:$src)]>, TB, XS;
5200b57cec5SDimitry Andric    } // Defs SSP
5210b57cec5SDimitry Andric  } // Uses SSP
5220b57cec5SDimitry Andric
523cb14a3feSDimitry Andriclet Predicates = [NoEGPR] in {
5240b57cec5SDimitry Andric  def WRSSD : I<0xF6, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
5250b57cec5SDimitry Andric                "wrssd\t{$src, $dst|$dst, $src}",
526cb14a3feSDimitry Andric                [(int_x86_wrssd GR32:$src, addr:$dst)]>, T8;
5270b57cec5SDimitry Andric  def WRSSQ : RI<0xF6, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
5280b57cec5SDimitry Andric                 "wrssq\t{$src, $dst|$dst, $src}",
529cb14a3feSDimitry Andric                 [(int_x86_wrssq GR64:$src, addr:$dst)]>, T8;
5300b57cec5SDimitry Andric  def WRUSSD : I<0xF5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
5310b57cec5SDimitry Andric                 "wrussd\t{$src, $dst|$dst, $src}",
532cb14a3feSDimitry Andric                 [(int_x86_wrussd GR32:$src, addr:$dst)]>, T8, PD;
5330b57cec5SDimitry Andric  def WRUSSQ : RI<0xF5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
5340b57cec5SDimitry Andric                  "wrussq\t{$src, $dst|$dst, $src}",
535cb14a3feSDimitry Andric                  [(int_x86_wrussq GR64:$src, addr:$dst)]>, T8, PD;
536cb14a3feSDimitry Andric}
537cb14a3feSDimitry Andric
538cb14a3feSDimitry Andriclet Predicates = [HasEGPR, In64BitMode] in {
539cb14a3feSDimitry Andric  def WRSSD_EVEX : I<0x66, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
540cb14a3feSDimitry Andric                     "wrssd\t{$src, $dst|$dst, $src}",
541cb14a3feSDimitry Andric                     [(int_x86_wrssd GR32:$src, addr:$dst)]>, EVEX, NoCD8, T_MAP4;
542cb14a3feSDimitry Andric  def WRSSQ_EVEX : RI<0x66, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
543cb14a3feSDimitry Andric                      "wrssq\t{$src, $dst|$dst, $src}",
544cb14a3feSDimitry Andric                      [(int_x86_wrssq GR64:$src, addr:$dst)]>, EVEX, NoCD8, T_MAP4;
545cb14a3feSDimitry Andric  def WRUSSD_EVEX : I<0x65, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
546cb14a3feSDimitry Andric                      "wrussd\t{$src, $dst|$dst, $src}",
547cb14a3feSDimitry Andric                      [(int_x86_wrussd GR32:$src, addr:$dst)]>, EVEX, NoCD8, T_MAP4, PD;
548cb14a3feSDimitry Andric  def WRUSSQ_EVEX : RI<0x65, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
549cb14a3feSDimitry Andric                       "wrussq\t{$src, $dst|$dst, $src}",
550cb14a3feSDimitry Andric                       [(int_x86_wrussq GR64:$src, addr:$dst)]>, EVEX, NoCD8, T_MAP4, PD;
551cb14a3feSDimitry Andric}
5520b57cec5SDimitry Andric
5530b57cec5SDimitry Andric  let Defs = [SSP] in {
5540b57cec5SDimitry Andric    let Uses = [SSP] in {
5550b57cec5SDimitry Andric        def SETSSBSY : I<0x01, MRM_E8, (outs), (ins), "setssbsy",
556cb14a3feSDimitry Andric                         [(int_x86_setssbsy)]>, TB, XS;
5570b57cec5SDimitry Andric    } // Uses SSP
5580b57cec5SDimitry Andric
5590b57cec5SDimitry Andric    def CLRSSBSY : I<0xAE, MRM6m, (outs), (ins i32mem:$src),
5600b57cec5SDimitry Andric                     "clrssbsy\t$src",
561cb14a3feSDimitry Andric                     [(int_x86_clrssbsy addr:$src)]>, TB, XS;
5620b57cec5SDimitry Andric  } // Defs SSP
5630b57cec5SDimitry Andric} // SchedRW
5640b57cec5SDimitry Andric
5650b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
566cb14a3feSDimitry Andric    def ENDBR64 : I<0x1E, MRM_FA, (outs), (ins), "endbr64", []>, TB, XS;
567cb14a3feSDimitry Andric    def ENDBR32 : I<0x1E, MRM_FB, (outs), (ins), "endbr32", []>, TB, XS;
5680b57cec5SDimitry Andric} // SchedRW
5690b57cec5SDimitry Andric
5700b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
5710b57cec5SDimitry Andric// XSAVE instructions
5720b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
573349cc55cSDimitry Andric// NOTE: No HasXSAVE predicate so that these can be used with _xgetbv/_xsetbv
574349cc55cSDimitry Andric// on Windows without needing to enable the xsave feature to be compatible with
575349cc55cSDimitry Andric// MSVC.
5760b57cec5SDimitry Andriclet Defs = [EDX, EAX], Uses = [ECX] in
577cb14a3feSDimitry Andricdef XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB;
5780b57cec5SDimitry Andric
5790b57cec5SDimitry Andriclet Uses = [EDX, EAX, ECX] in
5800b57cec5SDimitry Andricdef XSETBV : I<0x01, MRM_D1, (outs), (ins),
5810b57cec5SDimitry Andric              "xsetbv",
582cb14a3feSDimitry Andric              [(int_x86_xsetbv ECX, EDX, EAX)]>, TB;
5830b57cec5SDimitry Andric
5840b57cec5SDimitry Andric
5850b57cec5SDimitry Andriclet Uses = [EDX, EAX] in {
5860b57cec5SDimitry Andricdef XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
5870b57cec5SDimitry Andric              "xsave\t$dst",
588cb14a3feSDimitry Andric              [(int_x86_xsave addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE]>;
5890b57cec5SDimitry Andricdef XSAVE64 : RI<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
5900b57cec5SDimitry Andric                 "xsave64\t$dst",
591cb14a3feSDimitry Andric                 [(int_x86_xsave64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>;
5920b57cec5SDimitry Andricdef XRSTOR : I<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
5930b57cec5SDimitry Andric               "xrstor\t$dst",
594cb14a3feSDimitry Andric               [(int_x86_xrstor addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE]>;
5950b57cec5SDimitry Andricdef XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
5960b57cec5SDimitry Andric                  "xrstor64\t$dst",
597cb14a3feSDimitry Andric                  [(int_x86_xrstor64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>;
5980b57cec5SDimitry Andricdef XSAVEOPT : I<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
5990b57cec5SDimitry Andric                 "xsaveopt\t$dst",
600cb14a3feSDimitry Andric                 [(int_x86_xsaveopt addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEOPT]>;
6010b57cec5SDimitry Andricdef XSAVEOPT64 : RI<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
6020b57cec5SDimitry Andric                    "xsaveopt64\t$dst",
603cb14a3feSDimitry Andric                    [(int_x86_xsaveopt64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEOPT, In64BitMode]>;
6040b57cec5SDimitry Andricdef XSAVEC : I<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
6050b57cec5SDimitry Andric               "xsavec\t$dst",
606cb14a3feSDimitry Andric               [(int_x86_xsavec addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC]>;
6070b57cec5SDimitry Andricdef XSAVEC64 : RI<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
6080b57cec5SDimitry Andric                 "xsavec64\t$dst",
609cb14a3feSDimitry Andric                 [(int_x86_xsavec64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC, In64BitMode]>;
6100b57cec5SDimitry Andricdef XSAVES : I<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
6110b57cec5SDimitry Andric               "xsaves\t$dst",
612cb14a3feSDimitry Andric               [(int_x86_xsaves addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
6130b57cec5SDimitry Andricdef XSAVES64 : RI<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
6140b57cec5SDimitry Andric                  "xsaves64\t$dst",
615cb14a3feSDimitry Andric                  [(int_x86_xsaves64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>;
6160b57cec5SDimitry Andricdef XRSTORS : I<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
6170b57cec5SDimitry Andric                "xrstors\t$dst",
618cb14a3feSDimitry Andric                [(int_x86_xrstors addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>;
6190b57cec5SDimitry Andricdef XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
6200b57cec5SDimitry Andric                   "xrstors64\t$dst",
621cb14a3feSDimitry Andric                   [(int_x86_xrstors64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES, In64BitMode]>;
6220b57cec5SDimitry Andric} // Uses
6230b57cec5SDimitry Andric} // SchedRW
6240b57cec5SDimitry Andric
6250b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6260b57cec5SDimitry Andric// VIA PadLock crypto instructions
6270b57cec5SDimitry Andriclet Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in
6284b972518SDimitry Andric  def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
6290b57cec5SDimitry Andric
6300b57cec5SDimitry Andricdef : InstAlias<"xstorerng", (XSTORE)>;
6310b57cec5SDimitry Andric
6320b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
6330b57cec5SDimitry Andriclet Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
6345ffd83dbSDimitry Andric  def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB, REP;
6355ffd83dbSDimitry Andric  def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB, REP;
6365ffd83dbSDimitry Andric  def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB, REP;
6375ffd83dbSDimitry Andric  def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB, REP;
6385ffd83dbSDimitry Andric  def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB, REP;
6390b57cec5SDimitry Andric}
6400b57cec5SDimitry Andric
6410b57cec5SDimitry Andriclet Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
6425ffd83dbSDimitry Andric  def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB, REP;
6435ffd83dbSDimitry Andric  def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB, REP;
6440b57cec5SDimitry Andric}
6450b57cec5SDimitry Andriclet Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
6465ffd83dbSDimitry Andric  def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB, REP;
6470b57cec5SDimitry Andric} // SchedRW
6480b57cec5SDimitry Andric
6490b57cec5SDimitry Andric//==-----------------------------------------------------------------------===//
6500b57cec5SDimitry Andric// PKU  - enable protection key
6510b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
6520b57cec5SDimitry Andriclet Defs = [EAX, EDX], Uses = [ECX] in
6530b57cec5SDimitry Andric  def RDPKRUr : I<0x01, MRM_EE, (outs), (ins), "rdpkru",
654cb14a3feSDimitry Andric                  [(set EAX, (X86rdpkru ECX)), (implicit EDX)]>, TB;
6550b57cec5SDimitry Andriclet Uses = [EAX, ECX, EDX] in
6560b57cec5SDimitry Andric  def WRPKRUr : I<0x01, MRM_EF, (outs), (ins), "wrpkru",
657cb14a3feSDimitry Andric                  [(X86wrpkru EAX, EDX, ECX)]>, TB;
6580b57cec5SDimitry Andric} // SchedRW
6590b57cec5SDimitry Andric
6600b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6610b57cec5SDimitry Andric// FS/GS Base Instructions
6620b57cec5SDimitry Andriclet Predicates = [HasFSGSBase, In64BitMode], SchedRW = [WriteSystem] in {
6630b57cec5SDimitry Andric  def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
6640b57cec5SDimitry Andric                   "rdfsbase{l}\t$dst",
665cb14a3feSDimitry Andric                   [(set GR32:$dst, (int_x86_rdfsbase_32))]>, TB, XS;
6660b57cec5SDimitry Andric  def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
6670b57cec5SDimitry Andric                     "rdfsbase{q}\t$dst",
668cb14a3feSDimitry Andric                     [(set GR64:$dst, (int_x86_rdfsbase_64))]>, TB, XS;
6690b57cec5SDimitry Andric  def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
6700b57cec5SDimitry Andric                   "rdgsbase{l}\t$dst",
671cb14a3feSDimitry Andric                   [(set GR32:$dst, (int_x86_rdgsbase_32))]>, TB, XS;
6720b57cec5SDimitry Andric  def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
6730b57cec5SDimitry Andric                     "rdgsbase{q}\t$dst",
674cb14a3feSDimitry Andric                     [(set GR64:$dst, (int_x86_rdgsbase_64))]>, TB, XS;
6750b57cec5SDimitry Andric  def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
6760b57cec5SDimitry Andric                   "wrfsbase{l}\t$src",
677cb14a3feSDimitry Andric                   [(int_x86_wrfsbase_32 GR32:$src)]>, TB, XS;
6780b57cec5SDimitry Andric  def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
6790b57cec5SDimitry Andric                      "wrfsbase{q}\t$src",
680cb14a3feSDimitry Andric                      [(int_x86_wrfsbase_64 GR64:$src)]>, TB, XS;
6810b57cec5SDimitry Andric  def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
6820b57cec5SDimitry Andric                   "wrgsbase{l}\t$src",
683cb14a3feSDimitry Andric                   [(int_x86_wrgsbase_32 GR32:$src)]>, TB, XS;
6840b57cec5SDimitry Andric  def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
6850b57cec5SDimitry Andric                      "wrgsbase{q}\t$src",
686cb14a3feSDimitry Andric                      [(int_x86_wrgsbase_64 GR64:$src)]>, TB, XS;
6870b57cec5SDimitry Andric}
6880b57cec5SDimitry Andric
6890b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
6900b57cec5SDimitry Andric// INVPCID Instruction
6910b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
6920b57cec5SDimitry Andricdef INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
6930b57cec5SDimitry Andric                  "invpcid\t{$src2, $src1|$src1, $src2}",
694cb14a3feSDimitry Andric                  [(int_x86_invpcid GR32:$src1, addr:$src2)]>, T8, PD,
6950b57cec5SDimitry Andric                  Requires<[Not64BitMode, HasINVPCID]>;
6960b57cec5SDimitry Andricdef INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
697cb14a3feSDimitry Andric                  "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8, PD,
698*1db9f3b2SDimitry Andric                  Requires<[In64BitMode]>;
6995f757f3fSDimitry Andric
7005f757f3fSDimitry Andricdef INVPCID64_EVEX : I<0xF2, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
7015f757f3fSDimitry Andric                       "invpcid\t{$src2, $src1|$src1, $src2}", []>,
702*1db9f3b2SDimitry Andric                     EVEX, NoCD8, T_MAP4, XS, Requires<[In64BitMode]>;
7030b57cec5SDimitry Andric} // SchedRW
7040b57cec5SDimitry Andric
705*1db9f3b2SDimitry Andriclet Predicates = [HasINVPCID, NoEGPR] in {
7060b57cec5SDimitry Andric  // The instruction can only use a 64 bit register as the register argument
7070b57cec5SDimitry Andric  // in 64 bit mode, while the intrinsic only accepts a 32 bit argument
7080b57cec5SDimitry Andric  // corresponding to it.
7090b57cec5SDimitry Andric  // The accepted values for now are 0,1,2,3 anyways (see Intel SDM -- INVCPID
7100b57cec5SDimitry Andric  // type),/ so it doesn't hurt us that one can't supply a 64 bit value here.
7110b57cec5SDimitry Andric  def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2),
7120b57cec5SDimitry Andric            (INVPCID64
7130b57cec5SDimitry Andric              (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit),
7140b57cec5SDimitry Andric              addr:$src2)>;
7150b57cec5SDimitry Andric}
7160b57cec5SDimitry Andric
717*1db9f3b2SDimitry Andriclet Predicates = [HasINVPCID, HasEGPR] in {
718*1db9f3b2SDimitry Andric  def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2),
719*1db9f3b2SDimitry Andric            (INVPCID64_EVEX
720*1db9f3b2SDimitry Andric              (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit),
721*1db9f3b2SDimitry Andric              addr:$src2)>;
722*1db9f3b2SDimitry Andric}
723*1db9f3b2SDimitry Andric
7240b57cec5SDimitry Andric
7250b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7260b57cec5SDimitry Andric// SMAP Instruction
7270b57cec5SDimitry Andriclet Defs = [EFLAGS], SchedRW = [WriteSystem] in {
728cb14a3feSDimitry Andric  def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, TB;
729cb14a3feSDimitry Andric  def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, TB;
7300b57cec5SDimitry Andric}
7310b57cec5SDimitry Andric
7320b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7330b57cec5SDimitry Andric// SMX Instruction
7340b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
7350b57cec5SDimitry Andriclet Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in {
736cb14a3feSDimitry Andric  def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, TB;
7370b57cec5SDimitry Andric} // Uses, Defs
7380b57cec5SDimitry Andric} // SchedRW
7390b57cec5SDimitry Andric
7400b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7410b57cec5SDimitry Andric// TS flag control instruction.
7420b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
7430b57cec5SDimitry Andricdef CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
7440b57cec5SDimitry Andric}
7450b57cec5SDimitry Andric
7460b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7470b57cec5SDimitry Andric// IF (inside EFLAGS) management instructions.
7480b57cec5SDimitry Andriclet SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in {
7490b57cec5SDimitry Andricdef CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
7500b57cec5SDimitry Andricdef STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
7510b57cec5SDimitry Andric}
7520b57cec5SDimitry Andric
7530b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7540b57cec5SDimitry Andric// RDPID Instruction
7550b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
7560b57cec5SDimitry Andricdef RDPID32 : I<0xC7, MRM7r, (outs GR32:$dst), (ins),
757cb14a3feSDimitry Andric                "rdpid\t$dst", [(set GR32:$dst, (int_x86_rdpid))]>, TB, XS,
7580b57cec5SDimitry Andric                Requires<[Not64BitMode, HasRDPID]>;
759cb14a3feSDimitry Andricdef RDPID64 : I<0xC7, MRM7r, (outs GR64:$dst), (ins), "rdpid\t$dst", []>, TB, XS,
7600b57cec5SDimitry Andric                Requires<[In64BitMode, HasRDPID]>;
7610b57cec5SDimitry Andric} // SchedRW
7620b57cec5SDimitry Andric
7630b57cec5SDimitry Andriclet Predicates = [In64BitMode, HasRDPID] in {
7640b57cec5SDimitry Andric  // Due to silly instruction definition, we have to compensate for the
7650b57cec5SDimitry Andric  // instruction outputing a 64-bit register.
7660b57cec5SDimitry Andric  def : Pat<(int_x86_rdpid),
7670b57cec5SDimitry Andric            (EXTRACT_SUBREG (RDPID64), sub_32bit)>;
7680b57cec5SDimitry Andric}
7690b57cec5SDimitry Andric
7700b57cec5SDimitry Andric
7710b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
7720b57cec5SDimitry Andric// PTWRITE Instruction - Write Data to a Processor Trace Packet
7730b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
7740b57cec5SDimitry Andricdef PTWRITEm: I<0xAE, MRM4m, (outs), (ins i32mem:$dst),
775cb14a3feSDimitry Andric                "ptwrite{l}\t$dst", [(int_x86_ptwrite32 (loadi32 addr:$dst))]>, TB, XS,
7760b57cec5SDimitry Andric                Requires<[HasPTWRITE]>;
7770b57cec5SDimitry Andricdef PTWRITE64m : RI<0xAE, MRM4m, (outs), (ins i64mem:$dst),
778cb14a3feSDimitry Andric                    "ptwrite{q}\t$dst", [(int_x86_ptwrite64 (loadi64 addr:$dst))]>, TB, XS,
7790b57cec5SDimitry Andric                    Requires<[In64BitMode, HasPTWRITE]>;
7800b57cec5SDimitry Andric
7810b57cec5SDimitry Andricdef PTWRITEr : I<0xAE, MRM4r, (outs), (ins GR32:$dst),
782cb14a3feSDimitry Andric                 "ptwrite{l}\t$dst", [(int_x86_ptwrite32 GR32:$dst)]>, TB, XS,
7830b57cec5SDimitry Andric                    Requires<[HasPTWRITE]>;
7840b57cec5SDimitry Andricdef PTWRITE64r : RI<0xAE, MRM4r, (outs), (ins GR64:$dst),
785cb14a3feSDimitry Andric                    "ptwrite{q}\t$dst", [(int_x86_ptwrite64 GR64:$dst)]>, TB, XS,
7860b57cec5SDimitry Andric                    Requires<[In64BitMode, HasPTWRITE]>;
7870b57cec5SDimitry Andric} // SchedRW
7880b57cec5SDimitry Andric
7890b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
790753f127fSDimitry Andric// RDPRU - Read Processor Register instruction.
791753f127fSDimitry Andric
792753f127fSDimitry Andriclet SchedRW = [WriteSystem] in {
793753f127fSDimitry Andriclet Uses = [ECX], Defs = [EAX, EDX] in
794cb14a3feSDimitry Andric   def RDPRU : I<0x01, MRM_FD, (outs), (ins), "rdpru", []>, TB,
795753f127fSDimitry Andric               Requires<[HasRDPRU]>;
796753f127fSDimitry Andric}
797753f127fSDimitry Andric
798753f127fSDimitry Andric//===----------------------------------------------------------------------===//
7990b57cec5SDimitry Andric// Platform Configuration instruction
8000b57cec5SDimitry Andric
8010b57cec5SDimitry Andric// From ISA docs:
8020b57cec5SDimitry Andric//  "This instruction is used to execute functions for configuring platform
8030b57cec5SDimitry Andric//   features.
8040b57cec5SDimitry Andric//   EAX: Leaf function to be invoked.
8050b57cec5SDimitry Andric//   RBX/RCX/RDX: Leaf-specific purpose."
8060b57cec5SDimitry Andric//  "Successful execution of the leaf clears RAX (set to zero) and ZF, CF, PF,
8070b57cec5SDimitry Andric//   AF, OF, and SF are cleared. In case of failure, the failure reason is
8080b57cec5SDimitry Andric//   indicated in RAX with ZF set to 1 and CF, PF, AF, OF, and SF are cleared."
8090b57cec5SDimitry Andric// Thus all these mentioned registers are considered clobbered.
8100b57cec5SDimitry Andric
8110b57cec5SDimitry Andriclet SchedRW = [WriteSystem] in {
8120b57cec5SDimitry Andriclet Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX, RDX, EFLAGS] in
813cb14a3feSDimitry Andric    def PCONFIG : I<0x01, MRM_C5, (outs), (ins), "pconfig", []>, TB,
8140b57cec5SDimitry Andric                  Requires<[HasPCONFIG]>;
8150b57cec5SDimitry Andric} // SchedRW
816