1dff0c46cSDimitry Andric//===-- X86InstrSystem.td - System Instructions ------------*- tablegen -*-===// 22754fe60SDimitry Andric// 32754fe60SDimitry Andric// The LLVM Compiler Infrastructure 42754fe60SDimitry Andric// 52754fe60SDimitry Andric// This file is distributed under the University of Illinois Open Source 62754fe60SDimitry Andric// License. See LICENSE.TXT for details. 72754fe60SDimitry Andric// 82754fe60SDimitry Andric//===----------------------------------------------------------------------===// 92754fe60SDimitry Andric// 102754fe60SDimitry Andric// This file describes the X86 instructions that are generally used in 112754fe60SDimitry Andric// privileged modes. These are not typically used by the compiler, but are 122754fe60SDimitry Andric// supported for the assembler and disassembler. 132754fe60SDimitry Andric// 142754fe60SDimitry Andric//===----------------------------------------------------------------------===// 152754fe60SDimitry Andric 16139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 172754fe60SDimitry Andriclet Defs = [RAX, RDX] in 18*4ba319b5SDimitry Andric def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>, TB; 192754fe60SDimitry Andric 202754fe60SDimitry Andriclet Defs = [RAX, RCX, RDX] in 21*4ba319b5SDimitry Andric def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", [(X86rdtscp)]>, TB; 222754fe60SDimitry Andric 232754fe60SDimitry Andric// CPU flow control instructions 242754fe60SDimitry Andric 25*4ba319b5SDimitry Andriclet mayLoad = 1, mayStore = 0, hasSideEffects = 1, isTrap = 1 in { 262754fe60SDimitry Andric def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB; 272754fe60SDimitry Andric def UD2B : I<0xB9, RawFrm, (outs), (ins), "ud2b", []>, TB; 282754fe60SDimitry Andric} 292754fe60SDimitry Andric 30*4ba319b5SDimitry Andricdef HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>; 31*4ba319b5SDimitry Andricdef RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB; 322754fe60SDimitry Andric 332754fe60SDimitry Andric// Interrupt and SysCall Instructions. 342754fe60SDimitry Andriclet Uses = [EFLAGS] in 352cab237bSDimitry Andric def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>, Requires<[Not64BitMode]>; 36*4ba319b5SDimitry Andric 37*4ba319b5SDimitry Andricdef INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", [(int_x86_int (i8 3))]>; 38139f7f9bSDimitry Andric} // SchedRW 397ae0e2c9SDimitry Andric 403b0f4066SDimitry Andric// The long form of "int $3" turns into int3 as a size optimization. 413b0f4066SDimitry Andric// FIXME: This doesn't work because InstAlias can't match immediate constants. 423b0f4066SDimitry Andric//def : InstAlias<"int\t$3", (INT3)>; 433b0f4066SDimitry Andric 44139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 453b0f4066SDimitry Andric 467d523365SDimitry Andricdef INT : Ii8<0xcd, RawFrm, (outs), (ins u8imm:$trap), "int\t$trap", 47*4ba319b5SDimitry Andric [(int_x86_int imm:$trap)]>; 482754fe60SDimitry Andric 493b0f4066SDimitry Andric 50*4ba319b5SDimitry Andricdef SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", []>, TB; 51*4ba319b5SDimitry Andricdef SYSRET : I<0x07, RawFrm, (outs), (ins), "sysret{l}", []>, TB; 52*4ba319b5SDimitry Andricdef SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysretq", []>, TB, 532754fe60SDimitry Andric Requires<[In64BitMode]>; 542754fe60SDimitry Andric 55*4ba319b5SDimitry Andricdef SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", []>, TB; 562754fe60SDimitry Andric 57*4ba319b5SDimitry Andricdef SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", []>, TB; 58*4ba319b5SDimitry Andricdef SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexitq", []>, TB, 59*4ba319b5SDimitry Andric Requires<[In64BitMode]>; 60139f7f9bSDimitry Andric} // SchedRW 612754fe60SDimitry Andric 62ff0cc061SDimitry Andricdef : Pat<(debugtrap), 63ff0cc061SDimitry Andric (INT3)>, Requires<[NotPS4]>; 64ff0cc061SDimitry Andricdef : Pat<(debugtrap), 65ff0cc061SDimitry Andric (INT (i8 0x41))>, Requires<[IsPS4]>; 662754fe60SDimitry Andric 672754fe60SDimitry Andric//===----------------------------------------------------------------------===// 682754fe60SDimitry Andric// Input/Output Instructions. 692754fe60SDimitry Andric// 70139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 712754fe60SDimitry Andriclet Defs = [AL], Uses = [DX] in 72*4ba319b5SDimitry Andricdef IN8rr : I<0xEC, RawFrm, (outs), (ins), "in{b}\t{%dx, %al|al, dx}", []>; 732754fe60SDimitry Andriclet Defs = [AX], Uses = [DX] in 74*4ba319b5SDimitry Andricdef IN16rr : I<0xED, RawFrm, (outs), (ins), "in{w}\t{%dx, %ax|ax, dx}", []>, 75*4ba319b5SDimitry Andric OpSize16; 762754fe60SDimitry Andriclet Defs = [EAX], Uses = [DX] in 77*4ba319b5SDimitry Andricdef IN32rr : I<0xED, RawFrm, (outs), (ins), "in{l}\t{%dx, %eax|eax, dx}", []>, 78*4ba319b5SDimitry Andric OpSize32; 792754fe60SDimitry Andric 802754fe60SDimitry Andriclet Defs = [AL] in 817d523365SDimitry Andricdef IN8ri : Ii8<0xE4, RawFrm, (outs), (ins u8imm:$port), 82*4ba319b5SDimitry Andric "in{b}\t{$port, %al|al, $port}", []>; 832754fe60SDimitry Andriclet Defs = [AX] in 847d523365SDimitry Andricdef IN16ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port), 85*4ba319b5SDimitry Andric "in{w}\t{$port, %ax|ax, $port}", []>, OpSize16; 862754fe60SDimitry Andriclet Defs = [EAX] in 877d523365SDimitry Andricdef IN32ri : Ii8<0xE5, RawFrm, (outs), (ins u8imm:$port), 88*4ba319b5SDimitry Andric "in{l}\t{$port, %eax|eax, $port}", []>, OpSize32; 892754fe60SDimitry Andric 902754fe60SDimitry Andriclet Uses = [DX, AL] in 91*4ba319b5SDimitry Andricdef OUT8rr : I<0xEE, RawFrm, (outs), (ins), "out{b}\t{%al, %dx|dx, al}", []>; 922754fe60SDimitry Andriclet Uses = [DX, AX] in 93*4ba319b5SDimitry Andricdef OUT16rr : I<0xEF, RawFrm, (outs), (ins), "out{w}\t{%ax, %dx|dx, ax}", []>, 94*4ba319b5SDimitry Andric OpSize16; 952754fe60SDimitry Andriclet Uses = [DX, EAX] in 96*4ba319b5SDimitry Andricdef OUT32rr : I<0xEF, RawFrm, (outs), (ins), "out{l}\t{%eax, %dx|dx, eax}", []>, 97*4ba319b5SDimitry Andric OpSize32; 982754fe60SDimitry Andric 992754fe60SDimitry Andriclet Uses = [AL] in 1007d523365SDimitry Andricdef OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins u8imm:$port), 101*4ba319b5SDimitry Andric "out{b}\t{%al, $port|$port, al}", []>; 1022754fe60SDimitry Andriclet Uses = [AX] in 1037d523365SDimitry Andricdef OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port), 104*4ba319b5SDimitry Andric "out{w}\t{%ax, $port|$port, ax}", []>, OpSize16; 1052754fe60SDimitry Andriclet Uses = [EAX] in 1067d523365SDimitry Andricdef OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins u8imm:$port), 107*4ba319b5SDimitry Andric "out{l}\t{%eax, $port|$port, eax}", []>, OpSize32; 1082754fe60SDimitry Andric 109139f7f9bSDimitry Andric} // SchedRW 1102754fe60SDimitry Andric 1112754fe60SDimitry Andric//===----------------------------------------------------------------------===// 1122754fe60SDimitry Andric// Moves to and from debug registers 1132754fe60SDimitry Andric 114139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 1152754fe60SDimitry Andricdef MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src), 116*4ba319b5SDimitry Andric "mov{l}\t{$src, $dst|$dst, $src}", []>, TB, 11791bc56edSDimitry Andric Requires<[Not64BitMode]>; 1182754fe60SDimitry Andricdef MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src), 119*4ba319b5SDimitry Andric "mov{q}\t{$src, $dst|$dst, $src}", []>, TB, 12091bc56edSDimitry Andric Requires<[In64BitMode]>; 1212754fe60SDimitry Andric 1222754fe60SDimitry Andricdef MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src), 123*4ba319b5SDimitry Andric "mov{l}\t{$src, $dst|$dst, $src}", []>, TB, 12491bc56edSDimitry Andric Requires<[Not64BitMode]>; 1252754fe60SDimitry Andricdef MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src), 126*4ba319b5SDimitry Andric "mov{q}\t{$src, $dst|$dst, $src}", []>, TB, 12791bc56edSDimitry Andric Requires<[In64BitMode]>; 128139f7f9bSDimitry Andric} // SchedRW 1292754fe60SDimitry Andric 1302754fe60SDimitry Andric//===----------------------------------------------------------------------===// 1312754fe60SDimitry Andric// Moves to and from control registers 1322754fe60SDimitry Andric 133139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 1342754fe60SDimitry Andricdef MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src), 135*4ba319b5SDimitry Andric "mov{l}\t{$src, $dst|$dst, $src}", []>, TB, 13691bc56edSDimitry Andric Requires<[Not64BitMode]>; 1372754fe60SDimitry Andricdef MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src), 138*4ba319b5SDimitry Andric "mov{q}\t{$src, $dst|$dst, $src}", []>, TB, 13991bc56edSDimitry Andric Requires<[In64BitMode]>; 1402754fe60SDimitry Andric 1412754fe60SDimitry Andricdef MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src), 142*4ba319b5SDimitry Andric "mov{l}\t{$src, $dst|$dst, $src}", []>, TB, 14391bc56edSDimitry Andric Requires<[Not64BitMode]>; 1442754fe60SDimitry Andricdef MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src), 145*4ba319b5SDimitry Andric "mov{q}\t{$src, $dst|$dst, $src}", []>, TB, 14691bc56edSDimitry Andric Requires<[In64BitMode]>; 147139f7f9bSDimitry Andric} // SchedRW 1482754fe60SDimitry Andric 1492754fe60SDimitry Andric//===----------------------------------------------------------------------===// 1502754fe60SDimitry Andric// Segment override instruction prefixes 1512754fe60SDimitry Andric 1522cab237bSDimitry Andriclet SchedRW = [WriteNop] in { 153*4ba319b5SDimitry Andricdef CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>; 154*4ba319b5SDimitry Andricdef SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>; 155*4ba319b5SDimitry Andricdef DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>; 156*4ba319b5SDimitry Andricdef ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>; 157*4ba319b5SDimitry Andricdef FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>; 158*4ba319b5SDimitry Andricdef GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>; 1592cab237bSDimitry Andric} // SchedRW 1602754fe60SDimitry Andric 1612754fe60SDimitry Andric//===----------------------------------------------------------------------===// 1622754fe60SDimitry Andric// Moves to and from segment registers. 1632754fe60SDimitry Andric// 1642754fe60SDimitry Andric 165139f7f9bSDimitry Andriclet SchedRW = [WriteMove] in { 1662754fe60SDimitry Andricdef MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src), 167*4ba319b5SDimitry Andric "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16; 1682754fe60SDimitry Andricdef MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src), 169*4ba319b5SDimitry Andric "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32; 1702754fe60SDimitry Andricdef MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src), 171*4ba319b5SDimitry Andric "mov{q}\t{$src, $dst|$dst, $src}", []>; 1727a7e6055SDimitry Andriclet mayStore = 1 in { 1733ca95b02SDimitry Andricdef MOV16ms : I<0x8C, MRMDestMem, (outs), (ins i16mem:$dst, SEGMENT_REG:$src), 174*4ba319b5SDimitry Andric "mov{w}\t{$src, $dst|$dst, $src}", []>; 1757a7e6055SDimitry Andric} 1762754fe60SDimitry Andricdef MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src), 177*4ba319b5SDimitry Andric "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize16; 1782754fe60SDimitry Andricdef MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src), 179*4ba319b5SDimitry Andric "mov{l}\t{$src, $dst|$dst, $src}", []>, OpSize32; 1802754fe60SDimitry Andricdef MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src), 181*4ba319b5SDimitry Andric "mov{q}\t{$src, $dst|$dst, $src}", []>; 1827a7e6055SDimitry Andriclet mayLoad = 1 in { 1832754fe60SDimitry Andricdef MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src), 184*4ba319b5SDimitry Andric "mov{w}\t{$src, $dst|$dst, $src}", []>; 1857a7e6055SDimitry Andric} 186139f7f9bSDimitry Andric} // SchedRW 1872754fe60SDimitry Andric 1882754fe60SDimitry Andric//===----------------------------------------------------------------------===// 1892754fe60SDimitry Andric// Segmentation support instructions. 1902754fe60SDimitry Andric 191139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 192*4ba319b5SDimitry Andricdef SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB; 1932754fe60SDimitry Andric 1947a7e6055SDimitry Andriclet mayLoad = 1 in 1952754fe60SDimitry Andricdef LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src), 196*4ba319b5SDimitry Andric "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, 197*4ba319b5SDimitry Andric OpSize16, NotMemoryFoldable; 1982754fe60SDimitry Andricdef LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src), 199*4ba319b5SDimitry Andric "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, 200*4ba319b5SDimitry Andric OpSize16, NotMemoryFoldable; 2012754fe60SDimitry Andric 2022754fe60SDimitry Andric// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo. 2037a7e6055SDimitry Andriclet mayLoad = 1 in 2042754fe60SDimitry Andricdef LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src), 205*4ba319b5SDimitry Andric "lar{l}\t{$src, $dst|$dst, $src}", []>, TB, 206*4ba319b5SDimitry Andric OpSize32, NotMemoryFoldable; 2072754fe60SDimitry Andricdef LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src), 208*4ba319b5SDimitry Andric "lar{l}\t{$src, $dst|$dst, $src}", []>, TB, 209*4ba319b5SDimitry Andric OpSize32, NotMemoryFoldable; 210*4ba319b5SDimitry Andric// i16mem operand in LAR64rm and GR32 operand in LAR64rr is not a typo. 2117a7e6055SDimitry Andriclet mayLoad = 1 in 2122754fe60SDimitry Andricdef LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), 213*4ba319b5SDimitry Andric "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable; 2142754fe60SDimitry Andricdef LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), 215*4ba319b5SDimitry Andric "lar{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable; 2162754fe60SDimitry Andric 217*4ba319b5SDimitry Andric// i16mem operand in LSL32rm and GR32 operand in LSL32rr is not a typo. 2187a7e6055SDimitry Andriclet mayLoad = 1 in 2192754fe60SDimitry Andricdef LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src), 220*4ba319b5SDimitry Andric "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, 221*4ba319b5SDimitry Andric OpSize16, NotMemoryFoldable; 2222754fe60SDimitry Andricdef LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src), 223*4ba319b5SDimitry Andric "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, 224*4ba319b5SDimitry Andric OpSize16, NotMemoryFoldable; 225*4ba319b5SDimitry Andric// i16mem operand in LSL64rm and GR32 operand in LSL64rr is not a typo. 2267a7e6055SDimitry Andriclet mayLoad = 1 in 227*4ba319b5SDimitry Andricdef LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src), 228*4ba319b5SDimitry Andric "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB, 229*4ba319b5SDimitry Andric OpSize32, NotMemoryFoldable; 2302754fe60SDimitry Andricdef LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src), 231*4ba319b5SDimitry Andric "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB, 232*4ba319b5SDimitry Andric OpSize32, NotMemoryFoldable; 2337a7e6055SDimitry Andriclet mayLoad = 1 in 234*4ba319b5SDimitry Andricdef LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), 235*4ba319b5SDimitry Andric "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable; 236*4ba319b5SDimitry Andricdef LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), 237*4ba319b5SDimitry Andric "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB, NotMemoryFoldable; 2382754fe60SDimitry Andric 239*4ba319b5SDimitry Andricdef INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB; 2402754fe60SDimitry Andric 2413b0f4066SDimitry Andricdef STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins), 242*4ba319b5SDimitry Andric "str{w}\t$dst", []>, TB, OpSize16; 2433b0f4066SDimitry Andricdef STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins), 244*4ba319b5SDimitry Andric "str{l}\t$dst", []>, TB, OpSize32; 2453b0f4066SDimitry Andricdef STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins), 246*4ba319b5SDimitry Andric "str{q}\t$dst", []>, TB; 2477a7e6055SDimitry Andriclet mayStore = 1 in 248*4ba319b5SDimitry Andricdef STRm : I<0x00, MRM1m, (outs), (ins i16mem:$dst), "str{w}\t$dst", []>, TB; 2493b0f4066SDimitry Andric 250*4ba319b5SDimitry Andricdef LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable; 2517a7e6055SDimitry Andriclet mayLoad = 1 in 252*4ba319b5SDimitry Andricdef LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src), "ltr{w}\t$src", []>, TB, NotMemoryFoldable; 2532754fe60SDimitry Andric 254*4ba319b5SDimitry Andricdef PUSHCS16 : I<0x0E, RawFrm, (outs), (ins), "push{w}\t{%cs|cs}", []>, 25591bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 256*4ba319b5SDimitry Andricdef PUSHCS32 : I<0x0E, RawFrm, (outs), (ins), "push{l}\t{%cs|cs}", []>, 25791bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 258*4ba319b5SDimitry Andricdef PUSHSS16 : I<0x16, RawFrm, (outs), (ins), "push{w}\t{%ss|ss}", []>, 25991bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 260*4ba319b5SDimitry Andricdef PUSHSS32 : I<0x16, RawFrm, (outs), (ins), "push{l}\t{%ss|ss}", []>, 26191bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 262*4ba319b5SDimitry Andricdef PUSHDS16 : I<0x1E, RawFrm, (outs), (ins), "push{w}\t{%ds|ds}", []>, 26391bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 264*4ba319b5SDimitry Andricdef PUSHDS32 : I<0x1E, RawFrm, (outs), (ins), "push{l}\t{%ds|ds}", []>, 26591bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 266*4ba319b5SDimitry Andricdef PUSHES16 : I<0x06, RawFrm, (outs), (ins), "push{w}\t{%es|es}", []>, 26791bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 268*4ba319b5SDimitry Andricdef PUSHES32 : I<0x06, RawFrm, (outs), (ins), "push{l}\t{%es|es}", []>, 26991bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 270*4ba319b5SDimitry Andricdef PUSHFS16 : I<0xa0, RawFrm, (outs), (ins), "push{w}\t{%fs|fs}", []>, 271*4ba319b5SDimitry Andric OpSize16, TB; 272*4ba319b5SDimitry Andricdef PUSHFS32 : I<0xa0, RawFrm, (outs), (ins), "push{l}\t{%fs|fs}", []>, TB, 27391bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 274*4ba319b5SDimitry Andricdef PUSHGS16 : I<0xa8, RawFrm, (outs), (ins), "push{w}\t{%gs|gs}", []>, 275*4ba319b5SDimitry Andric OpSize16, TB; 276*4ba319b5SDimitry Andricdef PUSHGS32 : I<0xa8, RawFrm, (outs), (ins), "push{l}\t{%gs|gs}", []>, TB, 27791bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 278*4ba319b5SDimitry Andricdef PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), "push{q}\t{%fs|fs}", []>, TB, 27991bc56edSDimitry Andric OpSize32, Requires<[In64BitMode]>; 280*4ba319b5SDimitry Andricdef PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), "push{q}\t{%gs|gs}", []>, TB, 28191bc56edSDimitry Andric OpSize32, Requires<[In64BitMode]>; 2822754fe60SDimitry Andric 2832754fe60SDimitry Andric// No "pop cs" instruction. 284*4ba319b5SDimitry Andricdef POPSS16 : I<0x17, RawFrm, (outs), (ins), "pop{w}\t{%ss|ss}", []>, 28591bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 286*4ba319b5SDimitry Andricdef POPSS32 : I<0x17, RawFrm, (outs), (ins), "pop{l}\t{%ss|ss}", []>, 28791bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 2882754fe60SDimitry Andric 289*4ba319b5SDimitry Andricdef POPDS16 : I<0x1F, RawFrm, (outs), (ins), "pop{w}\t{%ds|ds}", []>, 29091bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 291*4ba319b5SDimitry Andricdef POPDS32 : I<0x1F, RawFrm, (outs), (ins), "pop{l}\t{%ds|ds}", []>, 29291bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 2932754fe60SDimitry Andric 294*4ba319b5SDimitry Andricdef POPES16 : I<0x07, RawFrm, (outs), (ins), "pop{w}\t{%es|es}", []>, 29591bc56edSDimitry Andric OpSize16, Requires<[Not64BitMode]>; 296*4ba319b5SDimitry Andricdef POPES32 : I<0x07, RawFrm, (outs), (ins), "pop{l}\t{%es|es}", []>, 29791bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 2982754fe60SDimitry Andric 299*4ba319b5SDimitry Andricdef POPFS16 : I<0xa1, RawFrm, (outs), (ins), "pop{w}\t{%fs|fs}", []>, 300*4ba319b5SDimitry Andric OpSize16, TB; 301*4ba319b5SDimitry Andricdef POPFS32 : I<0xa1, RawFrm, (outs), (ins), "pop{l}\t{%fs|fs}", []>, TB, 30291bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 303*4ba319b5SDimitry Andricdef POPFS64 : I<0xa1, RawFrm, (outs), (ins), "pop{q}\t{%fs|fs}", []>, TB, 30491bc56edSDimitry Andric OpSize32, Requires<[In64BitMode]>; 3052754fe60SDimitry Andric 306*4ba319b5SDimitry Andricdef POPGS16 : I<0xa9, RawFrm, (outs), (ins), "pop{w}\t{%gs|gs}", []>, 307*4ba319b5SDimitry Andric OpSize16, TB; 308*4ba319b5SDimitry Andricdef POPGS32 : I<0xa9, RawFrm, (outs), (ins), "pop{l}\t{%gs|gs}", []>, TB, 30991bc56edSDimitry Andric OpSize32, Requires<[Not64BitMode]>; 310*4ba319b5SDimitry Andricdef POPGS64 : I<0xa9, RawFrm, (outs), (ins), "pop{q}\t{%gs|gs}", []>, TB, 31191bc56edSDimitry Andric OpSize32, Requires<[In64BitMode]>; 3122754fe60SDimitry Andric 313*4ba319b5SDimitry Andricdef LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src), 314*4ba319b5SDimitry Andric "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize16, 3153ca95b02SDimitry Andric Requires<[Not64BitMode]>; 316*4ba319b5SDimitry Andricdef LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src), 317*4ba319b5SDimitry Andric "lds{l}\t{$src, $dst|$dst, $src}", []>, OpSize32, 3183ca95b02SDimitry Andric Requires<[Not64BitMode]>; 3192754fe60SDimitry Andric 320*4ba319b5SDimitry Andricdef LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src), 321*4ba319b5SDimitry Andric "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16; 322*4ba319b5SDimitry Andricdef LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src), 323*4ba319b5SDimitry Andric "lss{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32; 324*4ba319b5SDimitry Andricdef LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src), 325*4ba319b5SDimitry Andric "lss{q}\t{$src, $dst|$dst, $src}", []>, TB; 3262754fe60SDimitry Andric 327*4ba319b5SDimitry Andricdef LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src), 328*4ba319b5SDimitry Andric "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize16, 3293ca95b02SDimitry Andric Requires<[Not64BitMode]>; 330*4ba319b5SDimitry Andricdef LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src), 331*4ba319b5SDimitry Andric "les{l}\t{$src, $dst|$dst, $src}", []>, OpSize32, 3323ca95b02SDimitry Andric Requires<[Not64BitMode]>; 3332754fe60SDimitry Andric 334*4ba319b5SDimitry Andricdef LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src), 335*4ba319b5SDimitry Andric "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16; 336*4ba319b5SDimitry Andricdef LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src), 337*4ba319b5SDimitry Andric "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32; 338*4ba319b5SDimitry Andricdef LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src), 339*4ba319b5SDimitry Andric "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB; 3402754fe60SDimitry Andric 341*4ba319b5SDimitry Andricdef LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaquemem:$src), 342*4ba319b5SDimitry Andric "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize16; 343*4ba319b5SDimitry Andricdef LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaquemem:$src), 344*4ba319b5SDimitry Andric "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB, OpSize32; 3452754fe60SDimitry Andric 346*4ba319b5SDimitry Andricdef LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaquemem:$src), 347*4ba319b5SDimitry Andric "lgs{q}\t{$src, $dst|$dst, $src}", []>, TB; 3482754fe60SDimitry Andric 349*4ba319b5SDimitry Andricdef VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable; 350*4ba319b5SDimitry Andricdef VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable; 3517a7e6055SDimitry Andriclet mayLoad = 1 in { 352*4ba319b5SDimitry Andricdef VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg), "verr\t$seg", []>, TB, NotMemoryFoldable; 353*4ba319b5SDimitry Andricdef VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg), "verw\t$seg", []>, TB, NotMemoryFoldable; 3547a7e6055SDimitry Andric} 355139f7f9bSDimitry Andric} // SchedRW 3562754fe60SDimitry Andric 3572754fe60SDimitry Andric//===----------------------------------------------------------------------===// 3582754fe60SDimitry Andric// Descriptor-table support instructions 3592754fe60SDimitry Andric 360139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 361*4ba319b5SDimitry Andricdef SGDT16m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst), 362*4ba319b5SDimitry Andric "sgdtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>; 363*4ba319b5SDimitry Andricdef SGDT32m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst), 364*4ba319b5SDimitry Andric "sgdt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>; 365*4ba319b5SDimitry Andricdef SGDT64m : I<0x01, MRM0m, (outs), (ins opaquemem:$dst), 366*4ba319b5SDimitry Andric "sgdt{q}\t$dst", []>, TB, Requires <[In64BitMode]>; 367*4ba319b5SDimitry Andricdef SIDT16m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst), 368*4ba319b5SDimitry Andric "sidtw\t$dst", []>, TB, OpSize16, Requires<[Not64BitMode]>; 369*4ba319b5SDimitry Andricdef SIDT32m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst), 370*4ba319b5SDimitry Andric "sidt{l|d}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>; 371*4ba319b5SDimitry Andricdef SIDT64m : I<0x01, MRM1m, (outs), (ins opaquemem:$dst), 37291bc56edSDimitry Andric "sidt{q}\t$dst", []>, TB, Requires <[In64BitMode]>; 3732754fe60SDimitry Andricdef SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins), 374*4ba319b5SDimitry Andric "sldt{w}\t$dst", []>, TB, OpSize16; 3757a7e6055SDimitry Andriclet mayStore = 1 in 3763ca95b02SDimitry Andricdef SLDT16m : I<0x00, MRM0m, (outs), (ins i16mem:$dst), 377*4ba319b5SDimitry Andric "sldt{w}\t$dst", []>, TB; 3782754fe60SDimitry Andricdef SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins), 379*4ba319b5SDimitry Andric "sldt{l}\t$dst", []>, OpSize32, TB; 3802754fe60SDimitry Andric 3812754fe60SDimitry Andric// LLDT is not interpreted specially in 64-bit mode because there is no sign 3822754fe60SDimitry Andric// extension. 3832754fe60SDimitry Andricdef SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins), 384*4ba319b5SDimitry Andric "sldt{q}\t$dst", []>, TB, Requires<[In64BitMode]>; 3852754fe60SDimitry Andric 386*4ba319b5SDimitry Andricdef LGDT16m : I<0x01, MRM2m, (outs), (ins opaquemem:$src), 387*4ba319b5SDimitry Andric "lgdtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>; 388*4ba319b5SDimitry Andricdef LGDT32m : I<0x01, MRM2m, (outs), (ins opaquemem:$src), 389*4ba319b5SDimitry Andric "lgdt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>; 390*4ba319b5SDimitry Andricdef LGDT64m : I<0x01, MRM2m, (outs), (ins opaquemem:$src), 391*4ba319b5SDimitry Andric "lgdt{q}\t$src", []>, TB, Requires<[In64BitMode]>; 392*4ba319b5SDimitry Andricdef LIDT16m : I<0x01, MRM3m, (outs), (ins opaquemem:$src), 393*4ba319b5SDimitry Andric "lidtw\t$src", []>, TB, OpSize16, Requires<[Not64BitMode]>; 394*4ba319b5SDimitry Andricdef LIDT32m : I<0x01, MRM3m, (outs), (ins opaquemem:$src), 395*4ba319b5SDimitry Andric "lidt{l|d}\t$src", []>, OpSize32, TB, Requires<[Not64BitMode]>; 396*4ba319b5SDimitry Andricdef LIDT64m : I<0x01, MRM3m, (outs), (ins opaquemem:$src), 397*4ba319b5SDimitry Andric "lidt{q}\t$src", []>, TB, Requires<[In64BitMode]>; 3982754fe60SDimitry Andricdef LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src), 399*4ba319b5SDimitry Andric "lldt{w}\t$src", []>, TB, NotMemoryFoldable; 4007a7e6055SDimitry Andriclet mayLoad = 1 in 4012754fe60SDimitry Andricdef LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src), 402*4ba319b5SDimitry Andric "lldt{w}\t$src", []>, TB, NotMemoryFoldable; 403139f7f9bSDimitry Andric} // SchedRW 4042754fe60SDimitry Andric 4052754fe60SDimitry Andric//===----------------------------------------------------------------------===// 4062754fe60SDimitry Andric// Specialized register support 407139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 408ff0cc061SDimitry Andriclet Uses = [EAX, ECX, EDX] in 409*4ba319b5SDimitry Andricdef WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB; 410ff0cc061SDimitry Andriclet Defs = [EAX, EDX], Uses = [ECX] in 411*4ba319b5SDimitry Andricdef RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB; 41291bc56edSDimitry Andric 41391bc56edSDimitry Andriclet Defs = [RAX, RDX], Uses = [ECX] in 414*4ba319b5SDimitry Andric def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", [(X86rdpmc)]>, TB; 4152754fe60SDimitry Andric 4162754fe60SDimitry Andricdef SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins), 417*4ba319b5SDimitry Andric "smsw{w}\t$dst", []>, OpSize16, TB; 4182754fe60SDimitry Andricdef SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins), 419*4ba319b5SDimitry Andric "smsw{l}\t$dst", []>, OpSize32, TB; 4202754fe60SDimitry Andric// no m form encodable; use SMSW16m 4212754fe60SDimitry Andricdef SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins), 422*4ba319b5SDimitry Andric "smsw{q}\t$dst", []>, TB; 4232754fe60SDimitry Andric 4242754fe60SDimitry Andric// For memory operands, there is only a 16-bit form 4253ca95b02SDimitry Andricdef SMSW16m : I<0x01, MRM4m, (outs), (ins i16mem:$dst), 426*4ba319b5SDimitry Andric "smsw{w}\t$dst", []>, TB; 4272754fe60SDimitry Andric 4282754fe60SDimitry Andricdef LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src), 429*4ba319b5SDimitry Andric "lmsw{w}\t$src", []>, TB, NotMemoryFoldable; 4307a7e6055SDimitry Andriclet mayLoad = 1 in 4312754fe60SDimitry Andricdef LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src), 432*4ba319b5SDimitry Andric "lmsw{w}\t$src", []>, TB, NotMemoryFoldable; 4332754fe60SDimitry Andric 43491bc56edSDimitry Andriclet Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in 435*4ba319b5SDimitry Andric def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB; 436139f7f9bSDimitry Andric} // SchedRW 4372754fe60SDimitry Andric 4382754fe60SDimitry Andric//===----------------------------------------------------------------------===// 4392754fe60SDimitry Andric// Cache instructions 440139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 441*4ba319b5SDimitry Andricdef INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB; 442*4ba319b5SDimitry Andricdef WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB; 443*4ba319b5SDimitry Andric 444*4ba319b5SDimitry Andric// wbnoinvd is like wbinvd, except without invalidation 445*4ba319b5SDimitry Andric// encoding: like wbinvd + an 0xF3 prefix 446*4ba319b5SDimitry Andricdef WBNOINVD : I<0x09, RawFrm, (outs), (ins), "wbnoinvd", 447*4ba319b5SDimitry Andric [(int_x86_wbnoinvd)]>, XS, 448*4ba319b5SDimitry Andric Requires<[HasWBNOINVD]>; 449139f7f9bSDimitry Andric} // SchedRW 4502754fe60SDimitry Andric 4516122f3e6SDimitry Andric//===----------------------------------------------------------------------===// 4522cab237bSDimitry Andric// CET instructions 453*4ba319b5SDimitry Andric// Use with caution, availability is not predicated on features. 454*4ba319b5SDimitry Andriclet SchedRW = [WriteSystem] in { 4552cab237bSDimitry Andric let Uses = [SSP] in { 4562cab237bSDimitry Andric let Defs = [SSP] in { 4572cab237bSDimitry Andric def INCSSPD : I<0xAE, MRM5r, (outs), (ins GR32:$src), "incsspd\t$src", 4582cab237bSDimitry Andric [(int_x86_incsspd GR32:$src)]>, XS; 4592cab237bSDimitry Andric def INCSSPQ : RI<0xAE, MRM5r, (outs), (ins GR64:$src), "incsspq\t$src", 4602cab237bSDimitry Andric [(int_x86_incsspq GR64:$src)]>, XS; 4612cab237bSDimitry Andric } // Defs SSP 4622cab237bSDimitry Andric 4632cab237bSDimitry Andric let Constraints = "$src = $dst" in { 4642cab237bSDimitry Andric def RDSSPD : I<0x1E, MRM1r, (outs GR32:$dst), (ins GR32:$src), 4652cab237bSDimitry Andric "rdsspd\t$dst", 4662cab237bSDimitry Andric [(set GR32:$dst, (int_x86_rdsspd GR32:$src))]>, XS; 4672cab237bSDimitry Andric def RDSSPQ : RI<0x1E, MRM1r, (outs GR64:$dst), (ins GR64:$src), 4682cab237bSDimitry Andric "rdsspq\t$dst", 4692cab237bSDimitry Andric [(set GR64:$dst, (int_x86_rdsspq GR64:$src))]>, XS; 4702cab237bSDimitry Andric } 4712cab237bSDimitry Andric 4722cab237bSDimitry Andric let Defs = [SSP] in { 4732cab237bSDimitry Andric def SAVEPREVSSP : I<0x01, MRM_EA, (outs), (ins), "saveprevssp", 4742cab237bSDimitry Andric [(int_x86_saveprevssp)]>, XS; 4752cab237bSDimitry Andric def RSTORSSP : I<0x01, MRM5m, (outs), (ins i32mem:$src), 4762cab237bSDimitry Andric "rstorssp\t$src", 4772cab237bSDimitry Andric [(int_x86_rstorssp addr:$src)]>, XS; 4782cab237bSDimitry Andric } // Defs SSP 4792cab237bSDimitry Andric } // Uses SSP 4802cab237bSDimitry Andric 4812cab237bSDimitry Andric def WRSSD : I<0xF6, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), 4822cab237bSDimitry Andric "wrssd\t{$src, $dst|$dst, $src}", 4832cab237bSDimitry Andric [(int_x86_wrssd GR32:$src, addr:$dst)]>, T8PS; 4842cab237bSDimitry Andric def WRSSQ : RI<0xF6, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), 4852cab237bSDimitry Andric "wrssq\t{$src, $dst|$dst, $src}", 4862cab237bSDimitry Andric [(int_x86_wrssq GR64:$src, addr:$dst)]>, T8PS; 4872cab237bSDimitry Andric def WRUSSD : I<0xF5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), 4882cab237bSDimitry Andric "wrussd\t{$src, $dst|$dst, $src}", 4892cab237bSDimitry Andric [(int_x86_wrussd GR32:$src, addr:$dst)]>, T8PD; 4902cab237bSDimitry Andric def WRUSSQ : RI<0xF5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), 4912cab237bSDimitry Andric "wrussq\t{$src, $dst|$dst, $src}", 4922cab237bSDimitry Andric [(int_x86_wrussq GR64:$src, addr:$dst)]>, T8PD; 4932cab237bSDimitry Andric 4942cab237bSDimitry Andric let Defs = [SSP] in { 4952cab237bSDimitry Andric let Uses = [SSP] in { 4962cab237bSDimitry Andric def SETSSBSY : I<0x01, MRM_E8, (outs), (ins), "setssbsy", 4972cab237bSDimitry Andric [(int_x86_setssbsy)]>, XS; 4982cab237bSDimitry Andric } // Uses SSP 4992cab237bSDimitry Andric 5002cab237bSDimitry Andric def CLRSSBSY : I<0xAE, MRM6m, (outs), (ins i32mem:$src), 5012cab237bSDimitry Andric "clrssbsy\t$src", 5022cab237bSDimitry Andric [(int_x86_clrssbsy addr:$src)]>, XS; 5032cab237bSDimitry Andric } // Defs SSP 504*4ba319b5SDimitry Andric} // SchedRW 505*4ba319b5SDimitry Andric 506*4ba319b5SDimitry Andriclet SchedRW = [WriteSystem] in { 507*4ba319b5SDimitry Andric def ENDBR64 : I<0x1E, MRM_FA, (outs), (ins), "endbr64", []>, XS; 508*4ba319b5SDimitry Andric def ENDBR32 : I<0x1E, MRM_FB, (outs), (ins), "endbr32", []>, XS; 509*4ba319b5SDimitry Andric} // SchedRW 5102cab237bSDimitry Andric 5112cab237bSDimitry Andric//===----------------------------------------------------------------------===// 5126122f3e6SDimitry Andric// XSAVE instructions 513139f7f9bSDimitry Andriclet SchedRW = [WriteSystem] in { 5147d523365SDimitry Andriclet Predicates = [HasXSAVE] in { 51539d628a0SDimitry Andriclet Defs = [EDX, EAX], Uses = [ECX] in 516dd6029ffSDimitry Andric def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB; 517dd6029ffSDimitry Andric 51839d628a0SDimitry Andriclet Uses = [EDX, EAX, ECX] in 519d88c1a5aSDimitry Andric def XSETBV : I<0x01, MRM_D1, (outs), (ins), 520d88c1a5aSDimitry Andric "xsetbv", 521d88c1a5aSDimitry Andric [(int_x86_xsetbv ECX, EDX, EAX)]>, TB; 522d88c1a5aSDimitry Andric 523d88c1a5aSDimitry Andric} // HasXSAVE 5247d523365SDimitry Andric 5257d523365SDimitry Andriclet Uses = [EDX, EAX] in { 526*4ba319b5SDimitry Andricdef XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst), 5277d523365SDimitry Andric "xsave\t$dst", 5282cab237bSDimitry Andric [(int_x86_xsave addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>; 529*4ba319b5SDimitry Andricdef XSAVE64 : RI<0xAE, MRM4m, (outs), (ins opaquemem:$dst), 5307d523365SDimitry Andric "xsave64\t$dst", 5312cab237bSDimitry Andric [(int_x86_xsave64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>; 532*4ba319b5SDimitry Andricdef XRSTOR : I<0xAE, MRM5m, (outs), (ins opaquemem:$dst), 5337d523365SDimitry Andric "xrstor\t$dst", 5342cab237bSDimitry Andric [(int_x86_xrstor addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>; 535*4ba319b5SDimitry Andricdef XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaquemem:$dst), 5367d523365SDimitry Andric "xrstor64\t$dst", 5372cab237bSDimitry Andric [(int_x86_xrstor64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>; 538*4ba319b5SDimitry Andricdef XSAVEOPT : I<0xAE, MRM6m, (outs), (ins opaquemem:$dst), 5397d523365SDimitry Andric "xsaveopt\t$dst", 5402cab237bSDimitry Andric [(int_x86_xsaveopt addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT]>; 541*4ba319b5SDimitry Andricdef XSAVEOPT64 : RI<0xAE, MRM6m, (outs), (ins opaquemem:$dst), 5427d523365SDimitry Andric "xsaveopt64\t$dst", 5432cab237bSDimitry Andric [(int_x86_xsaveopt64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT, In64BitMode]>; 544*4ba319b5SDimitry Andricdef XSAVEC : I<0xC7, MRM4m, (outs), (ins opaquemem:$dst), 5457d523365SDimitry Andric "xsavec\t$dst", 5462cab237bSDimitry Andric [(int_x86_xsavec addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC]>; 547*4ba319b5SDimitry Andricdef XSAVEC64 : RI<0xC7, MRM4m, (outs), (ins opaquemem:$dst), 5487d523365SDimitry Andric "xsavec64\t$dst", 5492cab237bSDimitry Andric [(int_x86_xsavec64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVEC, In64BitMode]>; 550*4ba319b5SDimitry Andricdef XSAVES : I<0xC7, MRM5m, (outs), (ins opaquemem:$dst), 5517d523365SDimitry Andric "xsaves\t$dst", 5522cab237bSDimitry Andric [(int_x86_xsaves addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>; 553*4ba319b5SDimitry Andricdef XSAVES64 : RI<0xC7, MRM5m, (outs), (ins opaquemem:$dst), 5547d523365SDimitry Andric "xsaves64\t$dst", 5552cab237bSDimitry Andric [(int_x86_xsaves64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVE, In64BitMode]>; 556*4ba319b5SDimitry Andricdef XRSTORS : I<0xC7, MRM3m, (outs), (ins opaquemem:$dst), 5577d523365SDimitry Andric "xrstors\t$dst", 5582cab237bSDimitry Andric [(int_x86_xrstors addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES]>; 559*4ba319b5SDimitry Andricdef XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst), 5607d523365SDimitry Andric "xrstors64\t$dst", 5612cab237bSDimitry Andric [(int_x86_xrstors64 addr:$dst, EDX, EAX)]>, TB, Requires<[HasXSAVES, In64BitMode]>; 5627d523365SDimitry Andric} // Uses 563139f7f9bSDimitry Andric} // SchedRW 5646122f3e6SDimitry Andric 5653b0f4066SDimitry Andric//===----------------------------------------------------------------------===// 5663b0f4066SDimitry Andric// VIA PadLock crypto instructions 5672cab237bSDimitry Andriclet Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in 56891bc56edSDimitry Andric def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB; 5693b0f4066SDimitry Andric 57017a519f9SDimitry Andricdef : InstAlias<"xstorerng", (XSTORE)>; 57117a519f9SDimitry Andric 5722cab237bSDimitry Andriclet SchedRW = [WriteSystem] in { 5733b0f4066SDimitry Andriclet Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in { 57491bc56edSDimitry Andric def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB; 57591bc56edSDimitry Andric def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB; 57691bc56edSDimitry Andric def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB; 57791bc56edSDimitry Andric def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB; 57891bc56edSDimitry Andric def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB; 5793b0f4066SDimitry Andric} 5803b0f4066SDimitry Andric 5813b0f4066SDimitry Andriclet Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in { 58291bc56edSDimitry Andric def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB; 58391bc56edSDimitry Andric def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB; 5843b0f4066SDimitry Andric} 5853b0f4066SDimitry Andriclet Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in 58691bc56edSDimitry Andric def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB; 5872cab237bSDimitry Andric} // SchedRW 5882cab237bSDimitry Andric 5897d523365SDimitry Andric//==-----------------------------------------------------------------------===// 5907d523365SDimitry Andric// PKU - enable protection key 5912cab237bSDimitry Andriclet usesCustomInserter = 1, hasNoSchedulingInfo = 1 in { 5924d0b32cdSDimitry Andric def WRPKRU : PseudoI<(outs), (ins GR32:$src), 5934d0b32cdSDimitry Andric [(int_x86_wrpkru GR32:$src)]>; 5944d0b32cdSDimitry Andric def RDPKRU : PseudoI<(outs GR32:$dst), (ins), 5954d0b32cdSDimitry Andric [(set GR32:$dst, (int_x86_rdpkru))]>; 5964d0b32cdSDimitry Andric} 5974d0b32cdSDimitry Andric 5982cab237bSDimitry Andriclet SchedRW = [WriteSystem] in { 5997d523365SDimitry Andriclet Defs = [EAX, EDX], Uses = [ECX] in 600*4ba319b5SDimitry Andric def RDPKRUr : I<0x01, MRM_EE, (outs), (ins), "rdpkru", []>, TB; 6017d523365SDimitry Andriclet Uses = [EAX, ECX, EDX] in 602*4ba319b5SDimitry Andric def WRPKRUr : I<0x01, MRM_EF, (outs), (ins), "wrpkru", []>, TB; 6032cab237bSDimitry Andric} // SchedRW 6046122f3e6SDimitry Andric 6056122f3e6SDimitry Andric//===----------------------------------------------------------------------===// 6066122f3e6SDimitry Andric// FS/GS Base Instructions 6072cab237bSDimitry Andriclet Predicates = [HasFSGSBase, In64BitMode], SchedRW = [WriteSystem] in { 6086122f3e6SDimitry Andric def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins), 609dff0c46cSDimitry Andric "rdfsbase{l}\t$dst", 610*4ba319b5SDimitry Andric [(set GR32:$dst, (int_x86_rdfsbase_32))]>, XS; 6116122f3e6SDimitry Andric def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins), 612dff0c46cSDimitry Andric "rdfsbase{q}\t$dst", 613*4ba319b5SDimitry Andric [(set GR64:$dst, (int_x86_rdfsbase_64))]>, XS; 6146122f3e6SDimitry Andric def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins), 615dff0c46cSDimitry Andric "rdgsbase{l}\t$dst", 616*4ba319b5SDimitry Andric [(set GR32:$dst, (int_x86_rdgsbase_32))]>, XS; 6176122f3e6SDimitry Andric def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins), 618dff0c46cSDimitry Andric "rdgsbase{q}\t$dst", 619*4ba319b5SDimitry Andric [(set GR64:$dst, (int_x86_rdgsbase_64))]>, XS; 620dff0c46cSDimitry Andric def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src), 621dff0c46cSDimitry Andric "wrfsbase{l}\t$src", 622*4ba319b5SDimitry Andric [(int_x86_wrfsbase_32 GR32:$src)]>, XS; 623dff0c46cSDimitry Andric def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src), 624dff0c46cSDimitry Andric "wrfsbase{q}\t$src", 625*4ba319b5SDimitry Andric [(int_x86_wrfsbase_64 GR64:$src)]>, XS; 626dff0c46cSDimitry Andric def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src), 627dff0c46cSDimitry Andric "wrgsbase{l}\t$src", 628*4ba319b5SDimitry Andric [(int_x86_wrgsbase_32 GR32:$src)]>, XS; 629dff0c46cSDimitry Andric def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src), 630dff0c46cSDimitry Andric "wrgsbase{q}\t$src", 631*4ba319b5SDimitry Andric [(int_x86_wrgsbase_64 GR64:$src)]>, XS; 6326122f3e6SDimitry Andric} 633dff0c46cSDimitry Andric 634dff0c46cSDimitry Andric//===----------------------------------------------------------------------===// 635dff0c46cSDimitry Andric// INVPCID Instruction 6362cab237bSDimitry Andriclet SchedRW = [WriteSystem] in { 637dff0c46cSDimitry Andricdef INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2), 638*4ba319b5SDimitry Andric "invpcid\t{$src2, $src1|$src1, $src2}", 639*4ba319b5SDimitry Andric [(int_x86_invpcid GR32:$src1, addr:$src2)]>, T8PD, 640*4ba319b5SDimitry Andric Requires<[Not64BitMode, HasINVPCID]>; 641dff0c46cSDimitry Andricdef INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2), 642*4ba319b5SDimitry Andric "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD, 643*4ba319b5SDimitry Andric Requires<[In64BitMode, HasINVPCID]>; 6442cab237bSDimitry Andric} // SchedRW 645284c1978SDimitry Andric 646*4ba319b5SDimitry Andriclet Predicates = [In64BitMode, HasINVPCID] in { 647*4ba319b5SDimitry Andric // The instruction can only use a 64 bit register as the register argument 648*4ba319b5SDimitry Andric // in 64 bit mode, while the intrinsic only accepts a 32 bit argument 649*4ba319b5SDimitry Andric // corresponding to it. 650*4ba319b5SDimitry Andric // The accepted values for now are 0,1,2,3 anyways (see Intel SDM -- INVCPID 651*4ba319b5SDimitry Andric // type),/ so it doesn't hurt us that one can't supply a 64 bit value here. 652*4ba319b5SDimitry Andric def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2), 653*4ba319b5SDimitry Andric (INVPCID64 654*4ba319b5SDimitry Andric (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit), 655*4ba319b5SDimitry Andric addr:$src2)>; 656*4ba319b5SDimitry Andric} 657*4ba319b5SDimitry Andric 658*4ba319b5SDimitry Andric 659284c1978SDimitry Andric//===----------------------------------------------------------------------===// 660284c1978SDimitry Andric// SMAP Instruction 6612cab237bSDimitry Andriclet Defs = [EFLAGS], SchedRW = [WriteSystem] in { 662*4ba319b5SDimitry Andric def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, TB; 663*4ba319b5SDimitry Andric def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, TB; 664284c1978SDimitry Andric} 665ff0cc061SDimitry Andric 666ff0cc061SDimitry Andric//===----------------------------------------------------------------------===// 667ff0cc061SDimitry Andric// SMX Instruction 6682cab237bSDimitry Andriclet SchedRW = [WriteSystem] in { 669ff0cc061SDimitry Andriclet Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in { 670*4ba319b5SDimitry Andric def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, TB; 6712cab237bSDimitry Andric} // Uses, Defs 6722cab237bSDimitry Andric} // SchedRW 6732cab237bSDimitry Andric 6742cab237bSDimitry Andric//===----------------------------------------------------------------------===// 6750556cfadSDimitry Andric// TS flag control instruction. 6760556cfadSDimitry Andriclet SchedRW = [WriteSystem] in { 677*4ba319b5SDimitry Andricdef CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB; 6780556cfadSDimitry Andric} 6790556cfadSDimitry Andric 6800556cfadSDimitry Andric//===----------------------------------------------------------------------===// 6810556cfadSDimitry Andric// IF (inside EFLAGS) management instructions. 6820556cfadSDimitry Andriclet SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in { 683*4ba319b5SDimitry Andricdef CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>; 684*4ba319b5SDimitry Andricdef STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>; 6850556cfadSDimitry Andric} 6860556cfadSDimitry Andric 6870556cfadSDimitry Andric//===----------------------------------------------------------------------===// 6882cab237bSDimitry Andric// RDPID Instruction 6892cab237bSDimitry Andriclet SchedRW = [WriteSystem] in { 690*4ba319b5SDimitry Andricdef RDPID32 : I<0xC7, MRM7r, (outs GR32:$dst), (ins), 691*4ba319b5SDimitry Andric "rdpid\t$dst", [(set GR32:$dst, (int_x86_rdpid))]>, XS, 692*4ba319b5SDimitry Andric Requires<[Not64BitMode, HasRDPID]>; 693*4ba319b5SDimitry Andricdef RDPID64 : I<0xC7, MRM7r, (outs GR64:$dst), (ins), "rdpid\t$dst", []>, XS, 694*4ba319b5SDimitry Andric Requires<[In64BitMode, HasRDPID]>; 695*4ba319b5SDimitry Andric} // SchedRW 696*4ba319b5SDimitry Andric 697*4ba319b5SDimitry Andriclet Predicates = [In64BitMode, HasRDPID] in { 698*4ba319b5SDimitry Andric // Due to silly instruction definition, we have to compensate for the 699*4ba319b5SDimitry Andric // instruction outputing a 64-bit register. 700*4ba319b5SDimitry Andric def : Pat<(int_x86_rdpid), 701*4ba319b5SDimitry Andric (EXTRACT_SUBREG (RDPID64), sub_32bit)>; 702*4ba319b5SDimitry Andric} 703*4ba319b5SDimitry Andric 704*4ba319b5SDimitry Andric 705*4ba319b5SDimitry Andric//===----------------------------------------------------------------------===// 706*4ba319b5SDimitry Andric// PTWRITE Instruction - Write Data to a Processor Trace Packet 707*4ba319b5SDimitry Andriclet SchedRW = [WriteSystem] in { 708*4ba319b5SDimitry Andricdef PTWRITEm: I<0xAE, MRM4m, (outs), (ins i32mem:$dst), 709*4ba319b5SDimitry Andric "ptwrite{l}\t$dst", [(int_x86_ptwrite32 (loadi32 addr:$dst))]>, XS, 710*4ba319b5SDimitry Andric Requires<[HasPTWRITE]>; 711*4ba319b5SDimitry Andricdef PTWRITE64m : RI<0xAE, MRM4m, (outs), (ins i64mem:$dst), 712*4ba319b5SDimitry Andric "ptwrite{q}\t$dst", [(int_x86_ptwrite64 (loadi64 addr:$dst))]>, XS, 713*4ba319b5SDimitry Andric Requires<[In64BitMode, HasPTWRITE]>; 714*4ba319b5SDimitry Andric 715*4ba319b5SDimitry Andricdef PTWRITEr : I<0xAE, MRM4r, (outs), (ins GR32:$dst), 716*4ba319b5SDimitry Andric "ptwrite{l}\t$dst", [(int_x86_ptwrite32 GR32:$dst)]>, XS, 717*4ba319b5SDimitry Andric Requires<[HasPTWRITE]>; 718*4ba319b5SDimitry Andricdef PTWRITE64r : RI<0xAE, MRM4r, (outs), (ins GR64:$dst), 719*4ba319b5SDimitry Andric "ptwrite{q}\t$dst", [(int_x86_ptwrite64 GR64:$dst)]>, XS, 720*4ba319b5SDimitry Andric Requires<[In64BitMode, HasPTWRITE]>; 7212cab237bSDimitry Andric} // SchedRW 7222cab237bSDimitry Andric 7232cab237bSDimitry Andric//===----------------------------------------------------------------------===// 724*4ba319b5SDimitry Andric// Platform Configuration instruction 725*4ba319b5SDimitry Andric 726*4ba319b5SDimitry Andric// From ISA docs: 727*4ba319b5SDimitry Andric// "This instruction is used to execute functions for configuring platform 728*4ba319b5SDimitry Andric// features. 729*4ba319b5SDimitry Andric// EAX: Leaf function to be invoked. 730*4ba319b5SDimitry Andric// RBX/RCX/RDX: Leaf-specific purpose." 731*4ba319b5SDimitry Andric// "Successful execution of the leaf clears RAX (set to zero) and ZF, CF, PF, 732*4ba319b5SDimitry Andric// AF, OF, and SF are cleared. In case of failure, the failure reason is 733*4ba319b5SDimitry Andric// indicated in RAX with ZF set to 1 and CF, PF, AF, OF, and SF are cleared." 734*4ba319b5SDimitry Andric// Thus all these mentioned registers are considered clobbered. 735*4ba319b5SDimitry Andric 7362cab237bSDimitry Andriclet SchedRW = [WriteSystem] in { 737*4ba319b5SDimitry Andriclet Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX, RDX, EFLAGS] in 738*4ba319b5SDimitry Andric def PCONFIG : I<0x01, MRM_C5, (outs), (ins), "pconfig", []>, TB, 739*4ba319b5SDimitry Andric Requires<[HasPCONFIG]>; 7402cab237bSDimitry Andric} // SchedRW 741