RISCVInstrInfoXTHead.td 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //===-- RISCVInstrInfoXTHead.td ----------------------------*- 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 vendor extensions defined by T-Head of Alibaba.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. //===----------------------------------------------------------------------===//
  13. // Instruction class templates
  14. //===----------------------------------------------------------------------===//
  15. class THInstVdotVV<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
  16. string opcodestr, string argstr>
  17. : RVInstVV<funct6, opv, outs, ins, opcodestr, argstr> {
  18. let Inst{26} = 0;
  19. let Opcode = OPC_CUSTOM_0.Value;
  20. let DecoderNamespace = "THeadV";
  21. }
  22. class THInstVdotVX<bits<6> funct6, RISCVVFormat opv, dag outs, dag ins,
  23. string opcodestr, string argstr>
  24. : RVInstVX<funct6, opv, outs, ins, opcodestr, argstr> {
  25. let Inst{26} = 1;
  26. let Opcode = OPC_CUSTOM_0.Value;
  27. let DecoderNamespace = "THeadV";
  28. }
  29. let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
  30. // op vd, vs1, vs2, vm (reverse the order of vs1 and vs2)
  31. class THVdotALUrVV<bits<6> funct6, RISCVVFormat opv, string opcodestr>
  32. : THInstVdotVV<funct6, opv, (outs VR:$vd),
  33. (ins VR:$vs1, VR:$vs2, VMaskOp:$vm),
  34. opcodestr, "$vd, $vs1, $vs2$vm">;
  35. // op vd, rs1, vs2, vm (reverse the order of rs1 and vs2)
  36. class THVdotALUrVX<bits<6> funct6, RISCVVFormat opv, string opcodestr>
  37. : THInstVdotVX<funct6, opv, (outs VR:$vd),
  38. (ins GPR:$rs1, VR:$vs2, VMaskOp:$vm),
  39. opcodestr, "$vd, $rs1, $vs2$vm">;
  40. } // hasSideEffects = 0, mayLoad = 0, mayStore = 0
  41. //===----------------------------------------------------------------------===//
  42. // Combination of instruction classes.
  43. // Use these multiclasses to define instructions more easily.
  44. //===----------------------------------------------------------------------===//
  45. multiclass THVdotVMAQA_VX<string opcodestr, bits<6> funct6> {
  46. def _VX : THVdotALUrVX<funct6, OPMVX, opcodestr # ".vx">;
  47. }
  48. multiclass THVdotVMAQA<string opcodestr, bits<6> funct6> {
  49. def _VV : THVdotALUrVV<funct6, OPMVX, opcodestr # ".vv">;
  50. defm "" : THVdotVMAQA_VX<opcodestr, funct6>;
  51. }
  52. //===----------------------------------------------------------------------===//
  53. // Instructions
  54. //===----------------------------------------------------------------------===//
  55. let Predicates = [HasVendorXTHeadVdot],
  56. Constraints = "@earlyclobber $vd",
  57. RVVConstraint = WidenV in {
  58. defm THVdotVMAQA : THVdotVMAQA<"th.vmaqa", 0b100000>;
  59. defm THVdotVMAQAU : THVdotVMAQA<"th.vmaqau", 0b100010>;
  60. defm THVdotVMAQASU : THVdotVMAQA<"th.vmaqasu", 0b100100>;
  61. defm THVdotVMAQAUS : THVdotVMAQA_VX<"th.vmaqaus",0b100110>;
  62. }
  63. // Associate LMUL with tablegen records of register classes.
  64. def THVdotV_M1 : LMULInfo<0b000, 8, VR, VR, VR, VR, VR, "M1">;
  65. def THVdotV_M2 : LMULInfo<0b001, 16, VRM2, VRM2, VR, VR, VR, "M2">;
  66. def THVdotV_M4 : LMULInfo<0b010, 32, VRM4, VRM4, VRM2, VR, VR, "M4">;
  67. def THVdotV_M8 : LMULInfo<0b011, 64, VRM8, VRM8, VRM4, VRM2, VR, "M8">;
  68. defvar MxListTHVdot = [V_MF2, THVdotV_M1, THVdotV_M2, THVdotV_M4, THVdotV_M8];
  69. defset list<VTypeInfoToWide> AllQuadWidenableInt8NoVLMulVectors = {
  70. def : VTypeInfoToWide<VI8MF2, VI32MF2>;
  71. def : VTypeInfoToWide<VI8M1, VI32M1>;
  72. def : VTypeInfoToWide<VI8M2, VI32M2>;
  73. def : VTypeInfoToWide<VI8M4, VI32M4>;
  74. def : VTypeInfoToWide<VI8M8, VI32M8>;
  75. }
  76. //===----------------------------------------------------------------------===//
  77. // Combination of instruction classes.
  78. // Use these multiclasses to define instructions more easily.
  79. //===----------------------------------------------------------------------===//
  80. multiclass VPseudoVMAQA_VV_VX {
  81. foreach m = MxListTHVdot in {
  82. defm "" : VPseudoTernaryW_VV<m>;
  83. defm "" : VPseudoTernaryW_VX<m>;
  84. }
  85. }
  86. multiclass VPseudoVMAQA_VX {
  87. foreach m = MxListTHVdot in {
  88. defm "" : VPseudoTernaryW_VX<m>;
  89. }
  90. }
  91. multiclass VPatTernaryVMAQA_VV<string intrinsic, string instruction,
  92. list<VTypeInfoToWide> vtilist> {
  93. foreach vtiToWti = vtilist in {
  94. defvar vti = vtiToWti.Vti;
  95. defvar wti = vtiToWti.Wti;
  96. defm : VPatTernaryWithPolicy<intrinsic, instruction, "VV",
  97. wti.Vector, vti.Vector, vti.Vector,
  98. vti.Mask, wti.Log2SEW, vti.LMul,
  99. wti.RegClass, vti.RegClass, vti.RegClass>;
  100. }
  101. }
  102. multiclass VPatTernaryVMAQA_VX<string intrinsic, string instruction,
  103. list<VTypeInfoToWide> vtilist> {
  104. foreach vtiToWti = vtilist in {
  105. defvar vti = vtiToWti.Vti;
  106. defvar wti = vtiToWti.Wti;
  107. defm : VPatTernaryWithPolicy<intrinsic, instruction,
  108. "V"#vti.ScalarSuffix,
  109. wti.Vector, vti.Scalar, vti.Vector,
  110. vti.Mask, wti.Log2SEW, vti.LMul,
  111. wti.RegClass, vti.ScalarRegClass, vti.RegClass>;
  112. }
  113. }
  114. multiclass VPatTernaryVMAQA_VV_VX<string intrinsic, string instruction,
  115. list<VTypeInfoToWide> vtilist>
  116. : VPatTernaryVMAQA_VV<intrinsic, instruction, vtilist>,
  117. VPatTernaryVMAQA_VX<intrinsic, instruction, vtilist>;
  118. //===----------------------------------------------------------------------===//
  119. // Pseudo-instructions and codegen patterns
  120. //===----------------------------------------------------------------------===//
  121. defm PseudoTHVdotVMAQA : VPseudoVMAQA_VV_VX;
  122. defm PseudoTHVdotVMAQAU : VPseudoVMAQA_VV_VX;
  123. defm PseudoTHVdotVMAQASU : VPseudoVMAQA_VV_VX;
  124. defm PseudoTHVdotVMAQAUS : VPseudoVMAQA_VX;
  125. let Predicates = [HasVendorXTHeadVdot] in {
  126. defm : VPatTernaryVMAQA_VV_VX<"int_riscv_th_vmaqa", "PseudoTHVdotVMAQA", AllQuadWidenableInt8NoVLMulVectors>;
  127. defm : VPatTernaryVMAQA_VV_VX<"int_riscv_th_vmaqau", "PseudoTHVdotVMAQAU", AllQuadWidenableInt8NoVLMulVectors>;
  128. defm : VPatTernaryVMAQA_VV_VX<"int_riscv_th_vmaqasu","PseudoTHVdotVMAQASU",AllQuadWidenableInt8NoVLMulVectors>;
  129. defm : VPatTernaryVMAQA_VX<"int_riscv_th_vmaqaus", "PseudoTHVdotVMAQAUS",AllQuadWidenableInt8NoVLMulVectors>;
  130. }