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