X86InstrSystem.td 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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} {$src2, $src1|$src1, $src2}", []>, TB, OpSize16;
  24. def UD1Lm : I<0xB9, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
  25. "ud1{l} {$src2, $src1|$src1, $src2}", []>, TB, OpSize32;
  26. def UD1Qm : RI<0xB9, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2),
  27. "ud1{q} {$src2, $src1|$src1, $src2}", []>, TB;
  28. def UD1Wr : I<0xB9, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
  29. "ud1{w} {$src2, $src1|$src1, $src2}", []>, TB, OpSize16;
  30. def UD1Lr : I<0xB9, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
  31. "ud1{l} {$src2, $src1|$src1, $src2}", []>, TB, OpSize32;
  32. def UD1Qr : RI<0xB9, MRMSrcReg, (outs), (ins GR64:$src1, GR64:$src2),
  33. "ud1{q} {$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<[NotPS4]>;
  59. def : Pat<(debugtrap),
  60. (INT (i8 0x41))>, Requires<[IsPS4]>;
  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 Defs = [EAX, EDX], Uses = [ECX] in
  370. def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
  371. let Defs = [RAX, RDX], Uses = [ECX] in
  372. def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
  373. def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
  374. "smsw{w}\t$dst", []>, OpSize16, TB;
  375. def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
  376. "smsw{l}\t$dst", []>, OpSize32, TB;
  377. // no m form encodable; use SMSW16m
  378. def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
  379. "smsw{q}\t$dst", []>, TB;
  380. // For memory operands, there is only a 16-bit form
  381. def SMSW16m : I<0x01, MRM4m, (outs), (ins i16mem:$dst),
  382. "smsw{w}\t$dst", []>, TB;
  383. def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
  384. "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
  385. let mayLoad = 1 in
  386. def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
  387. "lmsw{w}\t$src", []>, TB, NotMemoryFoldable;
  388. let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
  389. def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
  390. } // SchedRW
  391. //===----------------------------------------------------------------------===//
  392. // Cache instructions
  393. let SchedRW = [WriteSystem] in {
  394. def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
  395. def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, PS;
  396. // wbnoinvd is like wbinvd, except without invalidation
  397. // encoding: like wbinvd + an 0xF3 prefix
  398. def WBNOINVD : I<0x09, RawFrm, (outs), (ins), "wbnoinvd",
  399. [(int_x86_wbnoinvd)]>, XS,
  400. Requires<[HasWBNOINVD]>;
  401. } // SchedRW
  402. //===----------------------------------------------------------------------===//
  403. // CET instructions
  404. // Use with caution, availability is not predicated on features.
  405. let SchedRW = [WriteSystem] in {
  406. let Uses = [SSP] in {
  407. let Defs = [SSP] in {
  408. def INCSSPD : I<0xAE, MRM5r, (outs), (ins GR32:$src), "incsspd\t$src",
  409. [(int_x86_incsspd GR32:$src)]>, XS;
  410. def INCSSPQ : RI<0xAE, MRM5r, (outs), (ins GR64:$src), "incsspq\t$src",
  411. [(int_x86_incsspq GR64:$src)]>, XS;
  412. } // Defs SSP
  413. let Constraints = "$src = $dst" in {
  414. def RDSSPD : I<0x1E, MRM1r, (outs GR32:$dst), (ins GR32:$src),
  415. "rdsspd\t$dst",
  416. [(set GR32:$dst, (int_x86_rdsspd GR32:$src))]>, XS;
  417. def RDSSPQ : RI<0x1E, MRM1r, (outs GR64:$dst), (ins GR64:$src),
  418. "rdsspq\t$dst",
  419. [(set GR64:$dst, (int_x86_rdsspq GR64:$src))]>, XS;
  420. }
  421. let Defs = [SSP] in {
  422. def SAVEPREVSSP : I<0x01, MRM_EA, (outs), (ins), "saveprevssp",
  423. [(int_x86_saveprevssp)]>, XS;
  424. def RSTORSSP : I<0x01, MRM5m, (outs), (ins i32mem:$src),
  425. "rstorssp\t$src",
  426. [(int_x86_rstorssp addr:$src)]>, XS;
  427. } // Defs SSP
  428. } // Uses SSP
  429. def WRSSD : I<0xF6, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
  430. "wrssd\t{$src, $dst|$dst, $src}",
  431. [(int_x86_wrssd GR32:$src, addr:$dst)]>, T8PS;
  432. def WRSSQ : RI<0xF6, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
  433. "wrssq\t{$src, $dst|$dst, $src}",
  434. [(int_x86_wrssq GR64:$src, addr:$dst)]>, T8PS;
  435. def WRUSSD : I<0xF5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
  436. "wrussd\t{$src, $dst|$dst, $src}",
  437. [(int_x86_wrussd GR32:$src, addr:$dst)]>, T8PD;
  438. def WRUSSQ : RI<0xF5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
  439. "wrussq\t{$src, $dst|$dst, $src}",
  440. [(int_x86_wrussq GR64:$src, addr:$dst)]>, T8PD;
  441. let Defs = [SSP] in {
  442. let Uses = [SSP] in {
  443. def SETSSBSY : I<0x01, MRM_E8, (outs), (ins), "setssbsy",
  444. [(int_x86_setssbsy)]>, XS;
  445. } // Uses SSP
  446. def CLRSSBSY : I<0xAE, MRM6m, (outs), (ins i32mem:$src),
  447. "clrssbsy\t$src",
  448. [(int_x86_clrssbsy addr:$src)]>, XS;
  449. } // Defs SSP
  450. } // SchedRW
  451. let SchedRW = [WriteSystem] in {
  452. def ENDBR64 : I<0x1E, MRM_FA, (outs), (ins), "endbr64", []>, XS;
  453. def ENDBR32 : I<0x1E, MRM_FB, (outs), (ins), "endbr32", []>, XS;
  454. } // SchedRW
  455. //===----------------------------------------------------------------------===//
  456. // XSAVE instructions
  457. let SchedRW = [WriteSystem] in {
  458. // NOTE: No HasXSAVE predicate so that these can be used with _xgetbv/_xsetbv
  459. // on Windows without needing to enable the xsave feature to be compatible with
  460. // MSVC.
  461. let Defs = [EDX, EAX], Uses = [ECX] in
  462. def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, PS;
  463. let Uses = [EDX, EAX, ECX] in
  464. def XSETBV : I<0x01, MRM_D1, (outs), (ins),
  465. "xsetbv",
  466. [(int_x86_xsetbv ECX, EDX, EAX)]>, PS;
  467. let Uses = [EDX, EAX] in {
  468. def XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
  469. "xsave\t$dst",
  470. [(int_x86_xsave addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
  471. def XSAVE64 : RI<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
  472. "xsave64\t$dst",
  473. [(int_x86_xsave64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
  474. def XRSTOR : I<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
  475. "xrstor\t$dst",
  476. [(int_x86_xrstor addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE]>;
  477. def XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaquemem:$dst),
  478. "xrstor64\t$dst",
  479. [(int_x86_xrstor64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
  480. def XSAVEOPT : I<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
  481. "xsaveopt\t$dst",
  482. [(int_x86_xsaveopt addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT]>;
  483. def XSAVEOPT64 : RI<0xAE, MRM6m, (outs), (ins opaquemem:$dst),
  484. "xsaveopt64\t$dst",
  485. [(int_x86_xsaveopt64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEOPT, In64BitMode]>;
  486. def XSAVEC : I<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
  487. "xsavec\t$dst",
  488. [(int_x86_xsavec addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEC]>;
  489. def XSAVEC64 : RI<0xC7, MRM4m, (outs), (ins opaquemem:$dst),
  490. "xsavec64\t$dst",
  491. [(int_x86_xsavec64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVEC, In64BitMode]>;
  492. def XSAVES : I<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
  493. "xsaves\t$dst",
  494. [(int_x86_xsaves addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVES]>;
  495. def XSAVES64 : RI<0xC7, MRM5m, (outs), (ins opaquemem:$dst),
  496. "xsaves64\t$dst",
  497. [(int_x86_xsaves64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVE, In64BitMode]>;
  498. def XRSTORS : I<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
  499. "xrstors\t$dst",
  500. [(int_x86_xrstors addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVES]>;
  501. def XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
  502. "xrstors64\t$dst",
  503. [(int_x86_xrstors64 addr:$dst, EDX, EAX)]>, PS, Requires<[HasXSAVES, In64BitMode]>;
  504. } // Uses
  505. } // SchedRW
  506. //===----------------------------------------------------------------------===//
  507. // VIA PadLock crypto instructions
  508. let Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in
  509. def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
  510. def : InstAlias<"xstorerng", (XSTORE)>;
  511. let SchedRW = [WriteSystem] in {
  512. let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
  513. def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB, REP;
  514. def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB, REP;
  515. def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB, REP;
  516. def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB, REP;
  517. def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB, REP;
  518. }
  519. let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
  520. def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB, REP;
  521. def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB, REP;
  522. }
  523. let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
  524. def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB, REP;
  525. } // SchedRW
  526. //==-----------------------------------------------------------------------===//
  527. // PKU - enable protection key
  528. let SchedRW = [WriteSystem] in {
  529. let Defs = [EAX, EDX], Uses = [ECX] in
  530. def RDPKRUr : I<0x01, MRM_EE, (outs), (ins), "rdpkru",
  531. [(set EAX, (X86rdpkru ECX)), (implicit EDX)]>, PS;
  532. let Uses = [EAX, ECX, EDX] in
  533. def WRPKRUr : I<0x01, MRM_EF, (outs), (ins), "wrpkru",
  534. [(X86wrpkru EAX, EDX, ECX)]>, PS;
  535. } // SchedRW
  536. //===----------------------------------------------------------------------===//
  537. // FS/GS Base Instructions
  538. let Predicates = [HasFSGSBase, In64BitMode], SchedRW = [WriteSystem] in {
  539. def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
  540. "rdfsbase{l}\t$dst",
  541. [(set GR32:$dst, (int_x86_rdfsbase_32))]>, XS;
  542. def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
  543. "rdfsbase{q}\t$dst",
  544. [(set GR64:$dst, (int_x86_rdfsbase_64))]>, XS;
  545. def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
  546. "rdgsbase{l}\t$dst",
  547. [(set GR32:$dst, (int_x86_rdgsbase_32))]>, XS;
  548. def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
  549. "rdgsbase{q}\t$dst",
  550. [(set GR64:$dst, (int_x86_rdgsbase_64))]>, XS;
  551. def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
  552. "wrfsbase{l}\t$src",
  553. [(int_x86_wrfsbase_32 GR32:$src)]>, XS;
  554. def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
  555. "wrfsbase{q}\t$src",
  556. [(int_x86_wrfsbase_64 GR64:$src)]>, XS;
  557. def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
  558. "wrgsbase{l}\t$src",
  559. [(int_x86_wrgsbase_32 GR32:$src)]>, XS;
  560. def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
  561. "wrgsbase{q}\t$src",
  562. [(int_x86_wrgsbase_64 GR64:$src)]>, XS;
  563. }
  564. //===----------------------------------------------------------------------===//
  565. // INVPCID Instruction
  566. let SchedRW = [WriteSystem] in {
  567. def INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
  568. "invpcid\t{$src2, $src1|$src1, $src2}",
  569. [(int_x86_invpcid GR32:$src1, addr:$src2)]>, T8PD,
  570. Requires<[Not64BitMode, HasINVPCID]>;
  571. def INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
  572. "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD,
  573. Requires<[In64BitMode, HasINVPCID]>;
  574. } // SchedRW
  575. let Predicates = [In64BitMode, HasINVPCID] in {
  576. // The instruction can only use a 64 bit register as the register argument
  577. // in 64 bit mode, while the intrinsic only accepts a 32 bit argument
  578. // corresponding to it.
  579. // The accepted values for now are 0,1,2,3 anyways (see Intel SDM -- INVCPID
  580. // type),/ so it doesn't hurt us that one can't supply a 64 bit value here.
  581. def : Pat<(int_x86_invpcid GR32:$src1, addr:$src2),
  582. (INVPCID64
  583. (SUBREG_TO_REG (i64 0), (MOV32rr GR32:$src1), sub_32bit),
  584. addr:$src2)>;
  585. }
  586. //===----------------------------------------------------------------------===//
  587. // SMAP Instruction
  588. let Defs = [EFLAGS], SchedRW = [WriteSystem] in {
  589. def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, PS;
  590. def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, PS;
  591. }
  592. //===----------------------------------------------------------------------===//
  593. // SMX Instruction
  594. let SchedRW = [WriteSystem] in {
  595. let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in {
  596. def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, PS;
  597. } // Uses, Defs
  598. } // SchedRW
  599. //===----------------------------------------------------------------------===//
  600. // TS flag control instruction.
  601. let SchedRW = [WriteSystem] in {
  602. def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
  603. }
  604. //===----------------------------------------------------------------------===//
  605. // IF (inside EFLAGS) management instructions.
  606. let SchedRW = [WriteSystem], Uses = [EFLAGS], Defs = [EFLAGS] in {
  607. def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
  608. def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
  609. }
  610. //===----------------------------------------------------------------------===//
  611. // RDPID Instruction
  612. let SchedRW = [WriteSystem] in {
  613. def RDPID32 : I<0xC7, MRM7r, (outs GR32:$dst), (ins),
  614. "rdpid\t$dst", [(set GR32:$dst, (int_x86_rdpid))]>, XS,
  615. Requires<[Not64BitMode, HasRDPID]>;
  616. def RDPID64 : I<0xC7, MRM7r, (outs GR64:$dst), (ins), "rdpid\t$dst", []>, XS,
  617. Requires<[In64BitMode, HasRDPID]>;
  618. } // SchedRW
  619. let Predicates = [In64BitMode, HasRDPID] in {
  620. // Due to silly instruction definition, we have to compensate for the
  621. // instruction outputing a 64-bit register.
  622. def : Pat<(int_x86_rdpid),
  623. (EXTRACT_SUBREG (RDPID64), sub_32bit)>;
  624. }
  625. //===----------------------------------------------------------------------===//
  626. // PTWRITE Instruction - Write Data to a Processor Trace Packet
  627. let SchedRW = [WriteSystem] in {
  628. def PTWRITEm: I<0xAE, MRM4m, (outs), (ins i32mem:$dst),
  629. "ptwrite{l}\t$dst", [(int_x86_ptwrite32 (loadi32 addr:$dst))]>, XS,
  630. Requires<[HasPTWRITE]>;
  631. def PTWRITE64m : RI<0xAE, MRM4m, (outs), (ins i64mem:$dst),
  632. "ptwrite{q}\t$dst", [(int_x86_ptwrite64 (loadi64 addr:$dst))]>, XS,
  633. Requires<[In64BitMode, HasPTWRITE]>;
  634. def PTWRITEr : I<0xAE, MRM4r, (outs), (ins GR32:$dst),
  635. "ptwrite{l}\t$dst", [(int_x86_ptwrite32 GR32:$dst)]>, XS,
  636. Requires<[HasPTWRITE]>;
  637. def PTWRITE64r : RI<0xAE, MRM4r, (outs), (ins GR64:$dst),
  638. "ptwrite{q}\t$dst", [(int_x86_ptwrite64 GR64:$dst)]>, XS,
  639. Requires<[In64BitMode, HasPTWRITE]>;
  640. } // SchedRW
  641. //===----------------------------------------------------------------------===//
  642. // Platform Configuration instruction
  643. // From ISA docs:
  644. // "This instruction is used to execute functions for configuring platform
  645. // features.
  646. // EAX: Leaf function to be invoked.
  647. // RBX/RCX/RDX: Leaf-specific purpose."
  648. // "Successful execution of the leaf clears RAX (set to zero) and ZF, CF, PF,
  649. // AF, OF, and SF are cleared. In case of failure, the failure reason is
  650. // indicated in RAX with ZF set to 1 and CF, PF, AF, OF, and SF are cleared."
  651. // Thus all these mentioned registers are considered clobbered.
  652. let SchedRW = [WriteSystem] in {
  653. let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX, RDX, EFLAGS] in
  654. def PCONFIG : I<0x01, MRM_C5, (outs), (ins), "pconfig", []>, PS,
  655. Requires<[HasPCONFIG]>;
  656. } // SchedRW