X86InstrMMX.td 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. //===-- X86InstrMMX.td - Describe the MMX Instruction Set --*- 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 MMX instruction set, defining the instructions,
  10. // and properties of the instructions which are needed for code generation,
  11. // machine code emission, and analysis.
  12. //
  13. // All instructions that use MMX should be in this file, even if they also use
  14. // SSE.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. //===----------------------------------------------------------------------===//
  18. // MMX Multiclasses
  19. //===----------------------------------------------------------------------===//
  20. // Alias instruction that maps zero vector to pxor mmx.
  21. // This is expanded by ExpandPostRAPseudos to an pxor.
  22. // We set canFoldAsLoad because this can be converted to a constant-pool
  23. // load of an all-zeros value if folding it would be beneficial.
  24. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1,
  25. isPseudo = 1, SchedRW = [WriteZero], Predicates = [HasMMX] in {
  26. def MMX_SET0 : I<0, Pseudo, (outs VR64:$dst), (ins), "",
  27. [(set VR64:$dst, (x86mmx (MMX_X86movw2d (i32 0))))]>;
  28. }
  29. let Constraints = "$src1 = $dst" in {
  30. // MMXI_binop_rm_int - Simple MMX binary operator based on intrinsic.
  31. multiclass MMXI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId,
  32. X86FoldableSchedWrite sched, bit Commutable = 0,
  33. X86MemOperand OType = i64mem> {
  34. def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
  35. (ins VR64:$src1, VR64:$src2),
  36. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  37. [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]>,
  38. Sched<[sched]> {
  39. let isCommutable = Commutable;
  40. }
  41. def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
  42. (ins VR64:$src1, OType:$src2),
  43. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  44. [(set VR64:$dst, (IntId VR64:$src1, (load_mmx addr:$src2)))]>,
  45. Sched<[sched.Folded, sched.ReadAfterFold]>;
  46. }
  47. multiclass MMXI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm,
  48. string OpcodeStr, Intrinsic IntId,
  49. Intrinsic IntId2, X86FoldableSchedWrite sched,
  50. X86FoldableSchedWrite schedImm> {
  51. def rr : MMXI<opc, MRMSrcReg, (outs VR64:$dst),
  52. (ins VR64:$src1, VR64:$src2),
  53. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  54. [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2))]>,
  55. Sched<[sched]>;
  56. def rm : MMXI<opc, MRMSrcMem, (outs VR64:$dst),
  57. (ins VR64:$src1, i64mem:$src2),
  58. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  59. [(set VR64:$dst, (IntId VR64:$src1, (load_mmx addr:$src2)))]>,
  60. Sched<[sched.Folded, sched.ReadAfterFold]>;
  61. def ri : MMXIi8<opc2, ImmForm, (outs VR64:$dst),
  62. (ins VR64:$src1, i32u8imm:$src2),
  63. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  64. [(set VR64:$dst, (IntId2 VR64:$src1, timm:$src2))]>,
  65. Sched<[schedImm]>;
  66. }
  67. }
  68. /// Unary MMX instructions requiring SSSE3.
  69. multiclass SS3I_unop_rm_int_mm<bits<8> opc, string OpcodeStr,
  70. Intrinsic IntId64, X86FoldableSchedWrite sched> {
  71. def rr : MMXSS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
  72. !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
  73. [(set VR64:$dst, (IntId64 VR64:$src))]>,
  74. Sched<[sched]>;
  75. def rm : MMXSS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
  76. !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"),
  77. [(set VR64:$dst, (IntId64 (load_mmx addr:$src)))]>,
  78. Sched<[sched.Folded]>;
  79. }
  80. /// Binary MMX instructions requiring SSSE3.
  81. let ImmT = NoImm, Constraints = "$src1 = $dst" in {
  82. multiclass SS3I_binop_rm_int_mm<bits<8> opc, string OpcodeStr,
  83. Intrinsic IntId64, X86FoldableSchedWrite sched,
  84. bit Commutable = 0> {
  85. let isCommutable = Commutable in
  86. def rr : MMXSS38I<opc, MRMSrcReg, (outs VR64:$dst),
  87. (ins VR64:$src1, VR64:$src2),
  88. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  89. [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]>,
  90. Sched<[sched]>;
  91. def rm : MMXSS38I<opc, MRMSrcMem, (outs VR64:$dst),
  92. (ins VR64:$src1, i64mem:$src2),
  93. !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
  94. [(set VR64:$dst,
  95. (IntId64 VR64:$src1, (load_mmx addr:$src2)))]>,
  96. Sched<[sched.Folded, sched.ReadAfterFold]>;
  97. }
  98. }
  99. /// PALIGN MMX instructions (require SSSE3).
  100. multiclass ssse3_palign_mm<string asm, Intrinsic IntId,
  101. X86FoldableSchedWrite sched> {
  102. def rri : MMXSS3AI<0x0F, MRMSrcReg, (outs VR64:$dst),
  103. (ins VR64:$src1, VR64:$src2, u8imm:$src3),
  104. !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
  105. [(set VR64:$dst, (IntId VR64:$src1, VR64:$src2, (i8 timm:$src3)))]>,
  106. Sched<[sched]>;
  107. def rmi : MMXSS3AI<0x0F, MRMSrcMem, (outs VR64:$dst),
  108. (ins VR64:$src1, i64mem:$src2, u8imm:$src3),
  109. !strconcat(asm, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
  110. [(set VR64:$dst, (IntId VR64:$src1, (load_mmx addr:$src2),
  111. (i8 timm:$src3)))]>,
  112. Sched<[sched.Folded, sched.ReadAfterFold]>;
  113. }
  114. multiclass sse12_cvt_pint<bits<8> opc, RegisterClass SrcRC, RegisterClass DstRC,
  115. Intrinsic Int, X86MemOperand x86memop, PatFrag ld_frag,
  116. string asm, X86FoldableSchedWrite sched, Domain d> {
  117. def rr : MMXPI<opc, MRMSrcReg, (outs DstRC:$dst), (ins SrcRC:$src), asm,
  118. [(set DstRC:$dst, (Int SrcRC:$src))], d>,
  119. Sched<[sched]>;
  120. def rm : MMXPI<opc, MRMSrcMem, (outs DstRC:$dst), (ins x86memop:$src), asm,
  121. [(set DstRC:$dst, (Int (ld_frag addr:$src)))], d>,
  122. Sched<[sched.Folded]>;
  123. }
  124. multiclass sse12_cvt_pint_3addr<bits<8> opc, RegisterClass SrcRC,
  125. RegisterClass DstRC, Intrinsic Int, X86MemOperand x86memop,
  126. PatFrag ld_frag, string asm, Domain d> {
  127. def rr : MMXPI<opc, MRMSrcReg, (outs DstRC:$dst),
  128. (ins DstRC:$src1, SrcRC:$src2), asm,
  129. [(set DstRC:$dst, (Int DstRC:$src1, SrcRC:$src2))], d>,
  130. Sched<[WriteCvtI2PS]>;
  131. def rm : MMXPI<opc, MRMSrcMem, (outs DstRC:$dst),
  132. (ins DstRC:$src1, x86memop:$src2), asm,
  133. [(set DstRC:$dst, (Int DstRC:$src1, (ld_frag addr:$src2)))], d>,
  134. Sched<[WriteCvtI2PS.Folded]>;
  135. }
  136. //===----------------------------------------------------------------------===//
  137. // MMX EMMS Instruction
  138. //===----------------------------------------------------------------------===//
  139. let SchedRW = [WriteEMMS],
  140. Defs = [MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
  141. ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7] in
  142. def MMX_EMMS : MMXI<0x77, RawFrm, (outs), (ins), "emms", [(int_x86_mmx_emms)]>;
  143. //===----------------------------------------------------------------------===//
  144. // MMX Scalar Instructions
  145. //===----------------------------------------------------------------------===//
  146. // Data Transfer Instructions
  147. def MMX_MOVD64rr : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR32:$src),
  148. "movd\t{$src, $dst|$dst, $src}",
  149. [(set VR64:$dst,
  150. (x86mmx (MMX_X86movw2d GR32:$src)))]>,
  151. Sched<[WriteVecMoveFromGpr]>;
  152. def MMX_MOVD64rm : MMXI<0x6E, MRMSrcMem, (outs VR64:$dst), (ins i32mem:$src),
  153. "movd\t{$src, $dst|$dst, $src}",
  154. [(set VR64:$dst,
  155. (x86mmx (MMX_X86movw2d (loadi32 addr:$src))))]>,
  156. Sched<[WriteVecLoad]>;
  157. let mayStore = 1 in
  158. def MMX_MOVD64mr : MMXI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR64:$src),
  159. "movd\t{$src, $dst|$dst, $src}", []>,
  160. Sched<[WriteVecStore]>;
  161. def MMX_MOVD64grr : MMXI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR64:$src),
  162. "movd\t{$src, $dst|$dst, $src}",
  163. [(set GR32:$dst,
  164. (MMX_X86movd2w (x86mmx VR64:$src)))]>,
  165. Sched<[WriteVecMoveToGpr]>, FoldGenData<"MMX_MOVD64rr">;
  166. let isBitcast = 1 in
  167. def MMX_MOVD64to64rr : MMXRI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src),
  168. "movq\t{$src, $dst|$dst, $src}",
  169. [(set VR64:$dst, (bitconvert GR64:$src))]>,
  170. Sched<[WriteVecMoveFromGpr]>;
  171. let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0, mayLoad = 1 in
  172. def MMX_MOVD64to64rm : MMXRI<0x6E, MRMSrcMem, (outs VR64:$dst),
  173. (ins i64mem:$src), "movq\t{$src, $dst|$dst, $src}",
  174. []>, Sched<[SchedWriteVecMoveLS.MMX.RM]>;
  175. let isBitcast = 1 in {
  176. def MMX_MOVD64from64rr : MMXRI<0x7E, MRMDestReg,
  177. (outs GR64:$dst), (ins VR64:$src),
  178. "movq\t{$src, $dst|$dst, $src}",
  179. [(set GR64:$dst, (bitconvert VR64:$src))]>,
  180. Sched<[WriteVecMoveToGpr]>;
  181. let SchedRW = [WriteVecMove], hasSideEffects = 0, isMoveReg = 1 in {
  182. def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src),
  183. "movq\t{$src, $dst|$dst, $src}", []>;
  184. let isCodeGenOnly = 1, ForceDisassemble = 1 in
  185. def MMX_MOVQ64rr_REV : MMXI<0x7F, MRMDestReg, (outs VR64:$dst), (ins VR64:$src),
  186. "movq\t{$src, $dst|$dst, $src}", []>,
  187. FoldGenData<"MMX_MOVQ64rr">;
  188. } // SchedRW, hasSideEffects, isMoveReg
  189. } // isBitcast
  190. def : InstAlias<"movq.s\t{$src, $dst|$dst, $src}",
  191. (MMX_MOVQ64rr_REV VR64:$dst, VR64:$src), 0>;
  192. let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0, mayStore = 1 in
  193. def MMX_MOVD64from64rm : MMXRI<0x7E, MRMDestMem,
  194. (outs), (ins i64mem:$dst, VR64:$src),
  195. "movq\t{$src, $dst|$dst, $src}", []>,
  196. Sched<[SchedWriteVecMoveLS.MMX.MR]>;
  197. let SchedRW = [SchedWriteVecMoveLS.MMX.RM] in {
  198. let canFoldAsLoad = 1 in
  199. def MMX_MOVQ64rm : MMXI<0x6F, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src),
  200. "movq\t{$src, $dst|$dst, $src}",
  201. [(set VR64:$dst, (load_mmx addr:$src))]>;
  202. } // SchedRW
  203. let SchedRW = [SchedWriteVecMoveLS.MMX.MR] in
  204. def MMX_MOVQ64mr : MMXI<0x7F, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
  205. "movq\t{$src, $dst|$dst, $src}",
  206. [(store (x86mmx VR64:$src), addr:$dst)]>;
  207. def MMX_X86movdq2q : SDNode<"X86ISD::MOVDQ2Q", SDTypeProfile<1, 1,
  208. [SDTCisVT<0, x86mmx>, SDTCisVT<1, v2i64>]>>;
  209. def MMX_X86movq2dq : SDNode<"X86ISD::MOVQ2DQ", SDTypeProfile<1, 1,
  210. [SDTCisVT<0, v2i64>, SDTCisVT<1, x86mmx>]>>;
  211. let SchedRW = [SchedWriteVecMoveLS.XMM.RR] in {
  212. def MMX_MOVDQ2Qrr : MMXSDIi8<0xD6, MRMSrcReg, (outs VR64:$dst),
  213. (ins VR128:$src), "movdq2q\t{$src, $dst|$dst, $src}",
  214. [(set VR64:$dst,
  215. (x86mmx (MMX_X86movdq2q VR128:$src)))]>;
  216. def MMX_MOVQ2DQrr : MMXS2SIi8<0xD6, MRMSrcReg, (outs VR128:$dst),
  217. (ins VR64:$src), "movq2dq\t{$src, $dst|$dst, $src}",
  218. [(set VR128:$dst,
  219. (v2i64 (MMX_X86movq2dq VR64:$src)))]>;
  220. let isCodeGenOnly = 1, hasSideEffects = 1 in {
  221. def MMX_MOVQ2FR64rr: MMXS2SIi8<0xD6, MRMSrcReg, (outs FR64:$dst),
  222. (ins VR64:$src), "movq2dq\t{$src, $dst|$dst, $src}",
  223. []>;
  224. def MMX_MOVFR642Qrr: MMXSDIi8<0xD6, MRMSrcReg, (outs VR64:$dst),
  225. (ins FR64:$src), "movdq2q\t{$src, $dst|$dst, $src}",
  226. []>;
  227. }
  228. } // SchedRW
  229. let Predicates = [HasMMX, HasSSE1] in
  230. def MMX_MOVNTQmr : MMXI<0xE7, MRMDestMem, (outs), (ins i64mem:$dst, VR64:$src),
  231. "movntq\t{$src, $dst|$dst, $src}",
  232. [(int_x86_mmx_movnt_dq addr:$dst, VR64:$src)]>,
  233. Sched<[SchedWriteVecMoveLSNT.MMX.MR]>;
  234. // Arithmetic Instructions
  235. defm MMX_PABSB : SS3I_unop_rm_int_mm<0x1C, "pabsb", int_x86_ssse3_pabs_b,
  236. SchedWriteVecALU.MMX>;
  237. defm MMX_PABSW : SS3I_unop_rm_int_mm<0x1D, "pabsw", int_x86_ssse3_pabs_w,
  238. SchedWriteVecALU.MMX>;
  239. defm MMX_PABSD : SS3I_unop_rm_int_mm<0x1E, "pabsd", int_x86_ssse3_pabs_d,
  240. SchedWriteVecALU.MMX>;
  241. // -- Addition
  242. defm MMX_PADDB : MMXI_binop_rm_int<0xFC, "paddb", int_x86_mmx_padd_b,
  243. SchedWriteVecALU.MMX, 1>;
  244. defm MMX_PADDW : MMXI_binop_rm_int<0xFD, "paddw", int_x86_mmx_padd_w,
  245. SchedWriteVecALU.MMX, 1>;
  246. defm MMX_PADDD : MMXI_binop_rm_int<0xFE, "paddd", int_x86_mmx_padd_d,
  247. SchedWriteVecALU.MMX, 1>;
  248. let Predicates = [HasMMX, HasSSE2] in
  249. defm MMX_PADDQ : MMXI_binop_rm_int<0xD4, "paddq", int_x86_mmx_padd_q,
  250. SchedWriteVecALU.MMX, 1>;
  251. defm MMX_PADDSB : MMXI_binop_rm_int<0xEC, "paddsb" , int_x86_mmx_padds_b,
  252. SchedWriteVecALU.MMX, 1>;
  253. defm MMX_PADDSW : MMXI_binop_rm_int<0xED, "paddsw" , int_x86_mmx_padds_w,
  254. SchedWriteVecALU.MMX, 1>;
  255. defm MMX_PADDUSB : MMXI_binop_rm_int<0xDC, "paddusb", int_x86_mmx_paddus_b,
  256. SchedWriteVecALU.MMX, 1>;
  257. defm MMX_PADDUSW : MMXI_binop_rm_int<0xDD, "paddusw", int_x86_mmx_paddus_w,
  258. SchedWriteVecALU.MMX, 1>;
  259. defm MMX_PHADDW : SS3I_binop_rm_int_mm<0x01, "phaddw", int_x86_ssse3_phadd_w,
  260. SchedWritePHAdd.MMX>;
  261. defm MMX_PHADDD : SS3I_binop_rm_int_mm<0x02, "phaddd", int_x86_ssse3_phadd_d,
  262. SchedWritePHAdd.MMX>;
  263. defm MMX_PHADDSW : SS3I_binop_rm_int_mm<0x03, "phaddsw",int_x86_ssse3_phadd_sw,
  264. SchedWritePHAdd.MMX>;
  265. // -- Subtraction
  266. defm MMX_PSUBB : MMXI_binop_rm_int<0xF8, "psubb", int_x86_mmx_psub_b,
  267. SchedWriteVecALU.MMX>;
  268. defm MMX_PSUBW : MMXI_binop_rm_int<0xF9, "psubw", int_x86_mmx_psub_w,
  269. SchedWriteVecALU.MMX>;
  270. defm MMX_PSUBD : MMXI_binop_rm_int<0xFA, "psubd", int_x86_mmx_psub_d,
  271. SchedWriteVecALU.MMX>;
  272. let Predicates = [HasMMX, HasSSE2] in
  273. defm MMX_PSUBQ : MMXI_binop_rm_int<0xFB, "psubq", int_x86_mmx_psub_q,
  274. SchedWriteVecALU.MMX>;
  275. defm MMX_PSUBSB : MMXI_binop_rm_int<0xE8, "psubsb" , int_x86_mmx_psubs_b,
  276. SchedWriteVecALU.MMX>;
  277. defm MMX_PSUBSW : MMXI_binop_rm_int<0xE9, "psubsw" , int_x86_mmx_psubs_w,
  278. SchedWriteVecALU.MMX>;
  279. defm MMX_PSUBUSB : MMXI_binop_rm_int<0xD8, "psubusb", int_x86_mmx_psubus_b,
  280. SchedWriteVecALU.MMX>;
  281. defm MMX_PSUBUSW : MMXI_binop_rm_int<0xD9, "psubusw", int_x86_mmx_psubus_w,
  282. SchedWriteVecALU.MMX>;
  283. defm MMX_PHSUBW : SS3I_binop_rm_int_mm<0x05, "phsubw", int_x86_ssse3_phsub_w,
  284. SchedWritePHAdd.MMX>;
  285. defm MMX_PHSUBD : SS3I_binop_rm_int_mm<0x06, "phsubd", int_x86_ssse3_phsub_d,
  286. SchedWritePHAdd.MMX>;
  287. defm MMX_PHSUBSW : SS3I_binop_rm_int_mm<0x07, "phsubsw",int_x86_ssse3_phsub_sw,
  288. SchedWritePHAdd.MMX>;
  289. // -- Multiplication
  290. defm MMX_PMULLW : MMXI_binop_rm_int<0xD5, "pmullw", int_x86_mmx_pmull_w,
  291. SchedWriteVecIMul.MMX, 1>;
  292. defm MMX_PMULHW : MMXI_binop_rm_int<0xE5, "pmulhw", int_x86_mmx_pmulh_w,
  293. SchedWriteVecIMul.MMX, 1>;
  294. let Predicates = [HasMMX, HasSSE1] in
  295. defm MMX_PMULHUW : MMXI_binop_rm_int<0xE4, "pmulhuw", int_x86_mmx_pmulhu_w,
  296. SchedWriteVecIMul.MMX, 1>;
  297. let Predicates = [HasMMX, HasSSE2] in
  298. defm MMX_PMULUDQ : MMXI_binop_rm_int<0xF4, "pmuludq", int_x86_mmx_pmulu_dq,
  299. SchedWriteVecIMul.MMX, 1>;
  300. defm MMX_PMULHRSW : SS3I_binop_rm_int_mm<0x0B, "pmulhrsw",
  301. int_x86_ssse3_pmul_hr_sw,
  302. SchedWriteVecIMul.MMX, 1>;
  303. // -- Miscellanea
  304. defm MMX_PMADDWD : MMXI_binop_rm_int<0xF5, "pmaddwd", int_x86_mmx_pmadd_wd,
  305. SchedWriteVecIMul.MMX, 1>;
  306. defm MMX_PMADDUBSW : SS3I_binop_rm_int_mm<0x04, "pmaddubsw",
  307. int_x86_ssse3_pmadd_ub_sw,
  308. SchedWriteVecIMul.MMX>;
  309. let Predicates = [HasMMX, HasSSE1] in {
  310. defm MMX_PAVGB : MMXI_binop_rm_int<0xE0, "pavgb", int_x86_mmx_pavg_b,
  311. SchedWriteVecALU.MMX, 1>;
  312. defm MMX_PAVGW : MMXI_binop_rm_int<0xE3, "pavgw", int_x86_mmx_pavg_w,
  313. SchedWriteVecALU.MMX, 1>;
  314. defm MMX_PMINUB : MMXI_binop_rm_int<0xDA, "pminub", int_x86_mmx_pminu_b,
  315. SchedWriteVecALU.MMX, 1>;
  316. defm MMX_PMINSW : MMXI_binop_rm_int<0xEA, "pminsw", int_x86_mmx_pmins_w,
  317. SchedWriteVecALU.MMX, 1>;
  318. defm MMX_PMAXUB : MMXI_binop_rm_int<0xDE, "pmaxub", int_x86_mmx_pmaxu_b,
  319. SchedWriteVecALU.MMX, 1>;
  320. defm MMX_PMAXSW : MMXI_binop_rm_int<0xEE, "pmaxsw", int_x86_mmx_pmaxs_w,
  321. SchedWriteVecALU.MMX, 1>;
  322. defm MMX_PSADBW : MMXI_binop_rm_int<0xF6, "psadbw", int_x86_mmx_psad_bw,
  323. SchedWritePSADBW.MMX, 1>;
  324. }
  325. defm MMX_PSIGNB : SS3I_binop_rm_int_mm<0x08, "psignb", int_x86_ssse3_psign_b,
  326. SchedWriteVecALU.MMX>;
  327. defm MMX_PSIGNW : SS3I_binop_rm_int_mm<0x09, "psignw", int_x86_ssse3_psign_w,
  328. SchedWriteVecALU.MMX>;
  329. defm MMX_PSIGND : SS3I_binop_rm_int_mm<0x0A, "psignd", int_x86_ssse3_psign_d,
  330. SchedWriteVecALU.MMX>;
  331. let Constraints = "$src1 = $dst" in
  332. defm MMX_PALIGNR : ssse3_palign_mm<"palignr", int_x86_mmx_palignr_b,
  333. SchedWriteShuffle.MMX>;
  334. // Logical Instructions
  335. defm MMX_PAND : MMXI_binop_rm_int<0xDB, "pand", int_x86_mmx_pand,
  336. SchedWriteVecLogic.MMX, 1>;
  337. defm MMX_POR : MMXI_binop_rm_int<0xEB, "por" , int_x86_mmx_por,
  338. SchedWriteVecLogic.MMX, 1>;
  339. defm MMX_PXOR : MMXI_binop_rm_int<0xEF, "pxor", int_x86_mmx_pxor,
  340. SchedWriteVecLogic.MMX, 1>;
  341. defm MMX_PANDN : MMXI_binop_rm_int<0xDF, "pandn", int_x86_mmx_pandn,
  342. SchedWriteVecLogic.MMX>;
  343. // Shift Instructions
  344. defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw",
  345. int_x86_mmx_psrl_w, int_x86_mmx_psrli_w,
  346. SchedWriteVecShift.MMX,
  347. SchedWriteVecShiftImm.MMX>;
  348. defm MMX_PSRLD : MMXI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld",
  349. int_x86_mmx_psrl_d, int_x86_mmx_psrli_d,
  350. SchedWriteVecShift.MMX,
  351. SchedWriteVecShiftImm.MMX>;
  352. defm MMX_PSRLQ : MMXI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq",
  353. int_x86_mmx_psrl_q, int_x86_mmx_psrli_q,
  354. SchedWriteVecShift.MMX,
  355. SchedWriteVecShiftImm.MMX>;
  356. defm MMX_PSLLW : MMXI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw",
  357. int_x86_mmx_psll_w, int_x86_mmx_pslli_w,
  358. SchedWriteVecShift.MMX,
  359. SchedWriteVecShiftImm.MMX>;
  360. defm MMX_PSLLD : MMXI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld",
  361. int_x86_mmx_psll_d, int_x86_mmx_pslli_d,
  362. SchedWriteVecShift.MMX,
  363. SchedWriteVecShiftImm.MMX>;
  364. defm MMX_PSLLQ : MMXI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq",
  365. int_x86_mmx_psll_q, int_x86_mmx_pslli_q,
  366. SchedWriteVecShift.MMX,
  367. SchedWriteVecShiftImm.MMX>;
  368. defm MMX_PSRAW : MMXI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw",
  369. int_x86_mmx_psra_w, int_x86_mmx_psrai_w,
  370. SchedWriteVecShift.MMX,
  371. SchedWriteVecShiftImm.MMX>;
  372. defm MMX_PSRAD : MMXI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad",
  373. int_x86_mmx_psra_d, int_x86_mmx_psrai_d,
  374. SchedWriteVecShift.MMX,
  375. SchedWriteVecShiftImm.MMX>;
  376. // Comparison Instructions
  377. defm MMX_PCMPEQB : MMXI_binop_rm_int<0x74, "pcmpeqb", int_x86_mmx_pcmpeq_b,
  378. SchedWriteVecALU.MMX>;
  379. defm MMX_PCMPEQW : MMXI_binop_rm_int<0x75, "pcmpeqw", int_x86_mmx_pcmpeq_w,
  380. SchedWriteVecALU.MMX>;
  381. defm MMX_PCMPEQD : MMXI_binop_rm_int<0x76, "pcmpeqd", int_x86_mmx_pcmpeq_d,
  382. SchedWriteVecALU.MMX>;
  383. defm MMX_PCMPGTB : MMXI_binop_rm_int<0x64, "pcmpgtb", int_x86_mmx_pcmpgt_b,
  384. SchedWriteVecALU.MMX>;
  385. defm MMX_PCMPGTW : MMXI_binop_rm_int<0x65, "pcmpgtw", int_x86_mmx_pcmpgt_w,
  386. SchedWriteVecALU.MMX>;
  387. defm MMX_PCMPGTD : MMXI_binop_rm_int<0x66, "pcmpgtd", int_x86_mmx_pcmpgt_d,
  388. SchedWriteVecALU.MMX>;
  389. // -- Unpack Instructions
  390. defm MMX_PUNPCKHBW : MMXI_binop_rm_int<0x68, "punpckhbw",
  391. int_x86_mmx_punpckhbw,
  392. SchedWriteShuffle.MMX>;
  393. defm MMX_PUNPCKHWD : MMXI_binop_rm_int<0x69, "punpckhwd",
  394. int_x86_mmx_punpckhwd,
  395. SchedWriteShuffle.MMX>;
  396. defm MMX_PUNPCKHDQ : MMXI_binop_rm_int<0x6A, "punpckhdq",
  397. int_x86_mmx_punpckhdq,
  398. SchedWriteShuffle.MMX>;
  399. defm MMX_PUNPCKLBW : MMXI_binop_rm_int<0x60, "punpcklbw",
  400. int_x86_mmx_punpcklbw,
  401. SchedWriteShuffle.MMX,
  402. 0, i32mem>;
  403. defm MMX_PUNPCKLWD : MMXI_binop_rm_int<0x61, "punpcklwd",
  404. int_x86_mmx_punpcklwd,
  405. SchedWriteShuffle.MMX,
  406. 0, i32mem>;
  407. defm MMX_PUNPCKLDQ : MMXI_binop_rm_int<0x62, "punpckldq",
  408. int_x86_mmx_punpckldq,
  409. SchedWriteShuffle.MMX,
  410. 0, i32mem>;
  411. // -- Pack Instructions
  412. defm MMX_PACKSSWB : MMXI_binop_rm_int<0x63, "packsswb", int_x86_mmx_packsswb,
  413. SchedWriteShuffle.MMX>;
  414. defm MMX_PACKSSDW : MMXI_binop_rm_int<0x6B, "packssdw", int_x86_mmx_packssdw,
  415. SchedWriteShuffle.MMX>;
  416. defm MMX_PACKUSWB : MMXI_binop_rm_int<0x67, "packuswb", int_x86_mmx_packuswb,
  417. SchedWriteShuffle.MMX>;
  418. // -- Shuffle Instructions
  419. defm MMX_PSHUFB : SS3I_binop_rm_int_mm<0x00, "pshufb", int_x86_ssse3_pshuf_b,
  420. SchedWriteVarShuffle.MMX>;
  421. let Predicates = [HasMMX, HasSSE1] in {
  422. def MMX_PSHUFWri : MMXIi8<0x70, MRMSrcReg,
  423. (outs VR64:$dst), (ins VR64:$src1, u8imm:$src2),
  424. "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
  425. [(set VR64:$dst,
  426. (int_x86_sse_pshuf_w VR64:$src1, timm:$src2))]>,
  427. Sched<[SchedWriteShuffle.MMX]>;
  428. def MMX_PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
  429. (outs VR64:$dst), (ins i64mem:$src1, u8imm:$src2),
  430. "pshufw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
  431. [(set VR64:$dst,
  432. (int_x86_sse_pshuf_w (load_mmx addr:$src1),
  433. timm:$src2))]>,
  434. Sched<[SchedWriteShuffle.MMX.Folded]>;
  435. }
  436. // -- Conversion Instructions
  437. defm MMX_CVTPS2PI : sse12_cvt_pint<0x2D, VR128, VR64, int_x86_sse_cvtps2pi,
  438. f64mem, load, "cvtps2pi\t{$src, $dst|$dst, $src}",
  439. WriteCvtPS2I, SSEPackedSingle>, PS, SIMD_EXC;
  440. defm MMX_CVTPD2PI : sse12_cvt_pint<0x2D, VR128, VR64, int_x86_sse_cvtpd2pi,
  441. f128mem, memop, "cvtpd2pi\t{$src, $dst|$dst, $src}",
  442. WriteCvtPD2I, SSEPackedDouble>, PD, SIMD_EXC;
  443. defm MMX_CVTTPS2PI : sse12_cvt_pint<0x2C, VR128, VR64, int_x86_sse_cvttps2pi,
  444. f64mem, load, "cvttps2pi\t{$src, $dst|$dst, $src}",
  445. WriteCvtPS2I, SSEPackedSingle>, PS, SIMD_EXC;
  446. defm MMX_CVTTPD2PI : sse12_cvt_pint<0x2C, VR128, VR64, int_x86_sse_cvttpd2pi,
  447. f128mem, memop, "cvttpd2pi\t{$src, $dst|$dst, $src}",
  448. WriteCvtPD2I, SSEPackedDouble>, PD, SIMD_EXC;
  449. defm MMX_CVTPI2PD : sse12_cvt_pint<0x2A, VR64, VR128, int_x86_sse_cvtpi2pd,
  450. i64mem, load, "cvtpi2pd\t{$src, $dst|$dst, $src}",
  451. WriteCvtI2PD, SSEPackedDouble>, PD;
  452. let Constraints = "$src1 = $dst" in {
  453. defm MMX_CVTPI2PS : sse12_cvt_pint_3addr<0x2A, VR64, VR128,
  454. int_x86_sse_cvtpi2ps,
  455. i64mem, load, "cvtpi2ps\t{$src2, $dst|$dst, $src2}",
  456. SSEPackedSingle>, PS, SIMD_EXC;
  457. }
  458. // Extract / Insert
  459. let Predicates = [HasMMX, HasSSE1] in
  460. def MMX_PEXTRWrr: MMXIi8<0xC5, MRMSrcReg,
  461. (outs GR32orGR64:$dst), (ins VR64:$src1, i32u8imm:$src2),
  462. "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}",
  463. [(set GR32orGR64:$dst, (int_x86_mmx_pextr_w VR64:$src1,
  464. timm:$src2))]>,
  465. Sched<[WriteVecExtract]>;
  466. let Constraints = "$src1 = $dst" in {
  467. let Predicates = [HasMMX, HasSSE1] in {
  468. def MMX_PINSRWrr : MMXIi8<0xC4, MRMSrcReg,
  469. (outs VR64:$dst),
  470. (ins VR64:$src1, GR32orGR64:$src2, i32u8imm:$src3),
  471. "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
  472. [(set VR64:$dst, (int_x86_mmx_pinsr_w VR64:$src1,
  473. GR32orGR64:$src2, timm:$src3))]>,
  474. Sched<[WriteVecInsert, ReadDefault, ReadInt2Fpu]>;
  475. def MMX_PINSRWrm : MMXIi8<0xC4, MRMSrcMem,
  476. (outs VR64:$dst),
  477. (ins VR64:$src1, i16mem:$src2, i32u8imm:$src3),
  478. "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}",
  479. [(set VR64:$dst, (int_x86_mmx_pinsr_w VR64:$src1,
  480. (i32 (anyext (loadi16 addr:$src2))),
  481. timm:$src3))]>,
  482. Sched<[WriteVecInsert.Folded, WriteVecInsert.ReadAfterFold]>;
  483. }
  484. }
  485. // Mask creation
  486. let Predicates = [HasMMX, HasSSE1] in
  487. def MMX_PMOVMSKBrr : MMXI<0xD7, MRMSrcReg, (outs GR32orGR64:$dst),
  488. (ins VR64:$src),
  489. "pmovmskb\t{$src, $dst|$dst, $src}",
  490. [(set GR32orGR64:$dst,
  491. (int_x86_mmx_pmovmskb VR64:$src))]>,
  492. Sched<[WriteMMXMOVMSK]>;
  493. // Misc.
  494. let SchedRW = [SchedWriteShuffle.MMX] in {
  495. let Uses = [EDI], Predicates = [HasMMX, HasSSE1,Not64BitMode] in
  496. def MMX_MASKMOVQ : MMXI32<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
  497. "maskmovq\t{$mask, $src|$src, $mask}",
  498. [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, EDI)]>;
  499. let Uses = [RDI], Predicates = [HasMMX, HasSSE1,In64BitMode] in
  500. def MMX_MASKMOVQ64: MMXI64<0xF7, MRMSrcReg, (outs), (ins VR64:$src, VR64:$mask),
  501. "maskmovq\t{$mask, $src|$src, $mask}",
  502. [(int_x86_mmx_maskmovq VR64:$src, VR64:$mask, RDI)]>;
  503. }
  504. // 64-bit bit convert.
  505. let Predicates = [HasMMX, HasSSE2] in {
  506. def : Pat<(f64 (bitconvert (x86mmx VR64:$src))),
  507. (MMX_MOVQ2FR64rr VR64:$src)>;
  508. def : Pat<(x86mmx (bitconvert (f64 FR64:$src))),
  509. (MMX_MOVFR642Qrr FR64:$src)>;
  510. def : Pat<(x86mmx (MMX_X86movdq2q
  511. (bc_v2i64 (v4i32 (X86cvtp2Int (v4f32 VR128:$src)))))),
  512. (MMX_CVTPS2PIrr VR128:$src)>;
  513. def : Pat<(x86mmx (MMX_X86movdq2q
  514. (bc_v2i64 (v4i32 (X86cvttp2si (v4f32 VR128:$src)))))),
  515. (MMX_CVTTPS2PIrr VR128:$src)>;
  516. def : Pat<(x86mmx (MMX_X86movdq2q
  517. (bc_v2i64 (v4i32 (X86cvtp2Int (v2f64 VR128:$src)))))),
  518. (MMX_CVTPD2PIrr VR128:$src)>;
  519. def : Pat<(x86mmx (MMX_X86movdq2q
  520. (bc_v2i64 (v4i32 (X86cvttp2si (v2f64 VR128:$src)))))),
  521. (MMX_CVTTPD2PIrr VR128:$src)>;
  522. }