X86Instr3DNow.td 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //===-- X86Instr3DNow.td - The 3DNow! 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 3DNow! instruction set, which extends MMX to support
  10. // floating point and also adds a few more random instructions for good measure.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. class I3DNow<bits<8> o, Format F, dag outs, dag ins, string asm, list<dag> pat>
  14. : I<o, F, outs, ins, asm, pat>, Requires<[Has3DNow]> {
  15. }
  16. class I3DNow_binop<bits<8> o, Format F, dag ins, string Mnemonic, list<dag> pat>
  17. : I3DNow<o, F, (outs VR64:$dst), ins,
  18. !strconcat(Mnemonic, "\t{$src2, $dst|$dst, $src2}"), pat>, ThreeDNow {
  19. let Constraints = "$src1 = $dst";
  20. }
  21. class I3DNow_conv<bits<8> o, Format F, dag ins, string Mnemonic, list<dag> pat>
  22. : I3DNow<o, F, (outs VR64:$dst), ins,
  23. !strconcat(Mnemonic, "\t{$src, $dst|$dst, $src}"), pat>, ThreeDNow;
  24. multiclass I3DNow_binop_rm_int<bits<8> opc, string Mn,
  25. X86FoldableSchedWrite sched, bit Commutable = 0,
  26. string Ver = ""> {
  27. let isCommutable = Commutable in
  28. def rr : I3DNow_binop<opc, MRMSrcReg, (ins VR64:$src1, VR64:$src2), Mn,
  29. [(set VR64:$dst, (!cast<Intrinsic>(
  30. !strconcat("int_x86_3dnow", Ver, "_", Mn)) VR64:$src1, VR64:$src2))]>,
  31. Sched<[sched]>;
  32. def rm : I3DNow_binop<opc, MRMSrcMem, (ins VR64:$src1, i64mem:$src2), Mn,
  33. [(set VR64:$dst, (!cast<Intrinsic>(
  34. !strconcat("int_x86_3dnow", Ver, "_", Mn)) VR64:$src1,
  35. (bitconvert (load_mmx addr:$src2))))]>,
  36. Sched<[sched.Folded, sched.ReadAfterFold]>;
  37. }
  38. multiclass I3DNow_conv_rm_int<bits<8> opc, string Mn,
  39. X86FoldableSchedWrite sched, string Ver = ""> {
  40. def rr : I3DNow_conv<opc, MRMSrcReg, (ins VR64:$src), Mn,
  41. [(set VR64:$dst, (!cast<Intrinsic>(
  42. !strconcat("int_x86_3dnow", Ver, "_", Mn)) VR64:$src))]>,
  43. Sched<[sched]>;
  44. def rm : I3DNow_conv<opc, MRMSrcMem, (ins i64mem:$src), Mn,
  45. [(set VR64:$dst, (!cast<Intrinsic>(
  46. !strconcat("int_x86_3dnow", Ver, "_", Mn))
  47. (bitconvert (load_mmx addr:$src))))]>,
  48. Sched<[sched.Folded, sched.ReadAfterFold]>;
  49. }
  50. defm PAVGUSB : I3DNow_binop_rm_int<0xBF, "pavgusb", SchedWriteVecALU.MMX, 1>;
  51. defm PF2ID : I3DNow_conv_rm_int<0x1D, "pf2id", WriteCvtPS2I>;
  52. defm PFACC : I3DNow_binop_rm_int<0xAE, "pfacc", WriteFAdd>;
  53. defm PFADD : I3DNow_binop_rm_int<0x9E, "pfadd", WriteFAdd, 1>;
  54. defm PFCMPEQ : I3DNow_binop_rm_int<0xB0, "pfcmpeq", WriteFAdd, 1>;
  55. defm PFCMPGE : I3DNow_binop_rm_int<0x90, "pfcmpge", WriteFAdd>;
  56. defm PFCMPGT : I3DNow_binop_rm_int<0xA0, "pfcmpgt", WriteFAdd>;
  57. defm PFMAX : I3DNow_binop_rm_int<0xA4, "pfmax", WriteFAdd>;
  58. defm PFMIN : I3DNow_binop_rm_int<0x94, "pfmin", WriteFAdd>;
  59. defm PFMUL : I3DNow_binop_rm_int<0xB4, "pfmul", WriteFAdd, 1>;
  60. defm PFRCP : I3DNow_conv_rm_int<0x96, "pfrcp", WriteFAdd>;
  61. defm PFRCPIT1 : I3DNow_binop_rm_int<0xA6, "pfrcpit1", WriteFAdd>;
  62. defm PFRCPIT2 : I3DNow_binop_rm_int<0xB6, "pfrcpit2", WriteFAdd>;
  63. defm PFRSQIT1 : I3DNow_binop_rm_int<0xA7, "pfrsqit1", WriteFAdd>;
  64. defm PFRSQRT : I3DNow_conv_rm_int<0x97, "pfrsqrt", WriteFAdd>;
  65. defm PFSUB : I3DNow_binop_rm_int<0x9A, "pfsub", WriteFAdd, 1>;
  66. defm PFSUBR : I3DNow_binop_rm_int<0xAA, "pfsubr", WriteFAdd, 1>;
  67. defm PI2FD : I3DNow_conv_rm_int<0x0D, "pi2fd", WriteCvtI2PS>;
  68. defm PMULHRW : I3DNow_binop_rm_int<0xB7, "pmulhrw", SchedWriteVecIMul.MMX, 1>;
  69. let SchedRW = [WriteEMMS],
  70. Defs = [MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
  71. ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7] in
  72. def FEMMS : I3DNow<0x0E, RawFrm, (outs), (ins), "femms",
  73. [(int_x86_mmx_femms)]>, TB;
  74. // PREFETCHWT1 is supported we want to use it for everything but T0.
  75. def PrefetchWLevel : PatFrag<(ops), (i32 imm), [{
  76. return N->getSExtValue() == 3 || !Subtarget->hasPREFETCHWT1();
  77. }]>;
  78. // Use PREFETCHWT1 for NTA, T2, T1.
  79. def PrefetchWT1Level : ImmLeaf<i32, [{
  80. return Imm < 3;
  81. }]>;
  82. let SchedRW = [WriteLoad] in {
  83. let Predicates = [Has3DNow, NoSSEPrefetch] in
  84. def PREFETCH : I3DNow<0x0D, MRM0m, (outs), (ins i8mem:$addr),
  85. "prefetch\t$addr",
  86. [(prefetch addr:$addr, imm, imm, (i32 1))]>, TB;
  87. def PREFETCHW : I<0x0D, MRM1m, (outs), (ins i8mem:$addr), "prefetchw\t$addr",
  88. [(prefetch addr:$addr, (i32 1), (i32 PrefetchWLevel), (i32 1))]>,
  89. TB, Requires<[HasPrefetchW]>;
  90. def PREFETCHWT1 : I<0x0D, MRM2m, (outs), (ins i8mem:$addr), "prefetchwt1\t$addr",
  91. [(prefetch addr:$addr, (i32 1), (i32 PrefetchWT1Level), (i32 1))]>,
  92. TB, Requires<[HasPREFETCHWT1]>;
  93. }
  94. // "3DNowA" instructions
  95. defm PF2IW : I3DNow_conv_rm_int<0x1C, "pf2iw", WriteCvtPS2I, "a">;
  96. defm PI2FW : I3DNow_conv_rm_int<0x0C, "pi2fw", WriteCvtI2PS, "a">;
  97. defm PFNACC : I3DNow_binop_rm_int<0x8A, "pfnacc", WriteFAdd, 0, "a">;
  98. defm PFPNACC : I3DNow_binop_rm_int<0x8E, "pfpnacc", WriteFAdd, 0, "a">;
  99. defm PSWAPD : I3DNow_conv_rm_int<0xBB, "pswapd", SchedWriteShuffle.MMX, "a">;