X86InstrSystem.td 35 KB

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