VPIntrinsics.def 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //===-- IR/VPIntrinsics.def - Describes llvm.vp.* Intrinsics -*- C++ -*-===//
  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 contains descriptions of the various Vector Predication intrinsics.
  10. // This is used as a central place for enumerating the different instructions
  11. // and should eventually be the place to put comments about the instructions.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. // NOTE: NO INCLUDE GUARD DESIRED!
  15. // Provide definitions of macros so that users of this file do not have to
  16. // define everything to use it...
  17. //
  18. // Register a VP intrinsic and begin its property scope.
  19. // All VP intrinsic scopes are top level, ie it is illegal to place a
  20. // BEGIN_REGISTER_VP_INTRINSIC within a VP intrinsic scope.
  21. // \p VPID The VP intrinsic id.
  22. // \p MASKPOS The mask operand position.
  23. // \p EVLPOS The explicit vector length operand position.
  24. #ifndef BEGIN_REGISTER_VP_INTRINSIC
  25. #define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, EVLPOS)
  26. #endif
  27. // End the property scope of a VP intrinsic.
  28. #ifndef END_REGISTER_VP_INTRINSIC
  29. #define END_REGISTER_VP_INTRINSIC(VPID)
  30. #endif
  31. // Register a new VP SDNode and begin its property scope.
  32. // When the SDNode scope is nested within a VP intrinsic scope, it is implicitly registered as the canonical SDNode for this VP intrinsic.
  33. // There is one VP intrinsic that maps directly to one SDNode that goes by the
  34. // same name. Since the operands are also the same, we open the property
  35. // scopes for both the VPIntrinsic and the SDNode at once.
  36. // \p SDOPC The SelectionDAG Node id (eg VP_ADD).
  37. // \p LEGALPOS The operand position of the SDNode that is used for legalizing
  38. // this SDNode. This can be `-1`, in which case the return type of
  39. // the SDNode is used.
  40. // \p TDNAME The name of the TableGen definition of this SDNode.
  41. // \p MASKPOS The mask operand position.
  42. // \p EVLPOS The explicit vector length operand position.
  43. #ifndef BEGIN_REGISTER_VP_SDNODE
  44. #define BEGIN_REGISTER_VP_SDNODE(SDOPC, LEGALPOS, TDNAME, MASKPOS, EVLPOS)
  45. #endif
  46. // End the property scope of a new VP SDNode.
  47. #ifndef END_REGISTER_VP_SDNODE
  48. #define END_REGISTER_VP_SDNODE(SDOPC)
  49. #endif
  50. // Helper macros for the common "1:1 - Intrinsic : SDNode" case.
  51. //
  52. // There is one VP intrinsic that maps directly to one SDNode that goes by the
  53. // same name. Since the operands are also the same, we open the property
  54. // scopes for both the VPIntrinsic and the SDNode at once.
  55. //
  56. // \p INTRIN The canonical name (eg `vp_add`, which at the same time is the
  57. // name of the intrinsic and the TableGen def of the SDNode).
  58. // \p MASKPOS The mask operand position.
  59. // \p EVLPOS The explicit vector length operand position.
  60. // \p SDOPC The SelectionDAG Node id (eg VP_ADD).
  61. // \p LEGALPOS The operand position of the SDNode that is used for legalizing
  62. // this SDNode. This can be `-1`, in which case the return type of
  63. // the SDNode is used.
  64. #define BEGIN_REGISTER_VP(INTRIN, MASKPOS, EVLPOS, SDOPC, LEGALPOS) \
  65. BEGIN_REGISTER_VP_INTRINSIC(INTRIN, MASKPOS, EVLPOS) \
  66. BEGIN_REGISTER_VP_SDNODE(SDOPC, LEGALPOS, INTRIN, MASKPOS, EVLPOS)
  67. #define END_REGISTER_VP(INTRIN, SDOPC) \
  68. END_REGISTER_VP_INTRINSIC(INTRIN) \
  69. END_REGISTER_VP_SDNODE(SDOPC)
  70. // The following macros attach properties to the scope they are placed in. This
  71. // assigns the property to the VP Intrinsic and/or SDNode that belongs to the
  72. // scope.
  73. //
  74. // Property Macros {
  75. // The intrinsic and/or SDNode has the same function as this LLVM IR Opcode.
  76. // \p OPC The standard IR opcode.
  77. #ifndef HANDLE_VP_TO_OPC
  78. #define HANDLE_VP_TO_OPC(OPC)
  79. #endif
  80. /// } Property Macros
  81. ///// Integer Arithmetic {
  82. // Specialized helper macro for integer binary operators (%x, %y, %mask, %evl).
  83. #ifdef HELPER_REGISTER_BINARY_INT_VP
  84. #error "The internal helper macro HELPER_REGISTER_BINARY_INT_VP is already defined!"
  85. #endif
  86. #define HELPER_REGISTER_BINARY_INT_VP(INTRIN, SDOPC, OPC) \
  87. BEGIN_REGISTER_VP(INTRIN, 2, 3, SDOPC, -1) \
  88. HANDLE_VP_TO_OPC(OPC) \
  89. END_REGISTER_VP(INTRIN, SDOPC)
  90. // llvm.vp.add(x,y,mask,vlen)
  91. HELPER_REGISTER_BINARY_INT_VP(vp_add, VP_ADD, Add)
  92. // llvm.vp.and(x,y,mask,vlen)
  93. HELPER_REGISTER_BINARY_INT_VP(vp_and, VP_AND, And)
  94. // llvm.vp.ashr(x,y,mask,vlen)
  95. HELPER_REGISTER_BINARY_INT_VP(vp_ashr, VP_ASHR, AShr)
  96. // llvm.vp.lshr(x,y,mask,vlen)
  97. HELPER_REGISTER_BINARY_INT_VP(vp_lshr, VP_LSHR, LShr)
  98. // llvm.vp.mul(x,y,mask,vlen)
  99. HELPER_REGISTER_BINARY_INT_VP(vp_mul, VP_MUL, Mul)
  100. // llvm.vp.or(x,y,mask,vlen)
  101. HELPER_REGISTER_BINARY_INT_VP(vp_or, VP_OR, Or)
  102. // llvm.vp.sdiv(x,y,mask,vlen)
  103. HELPER_REGISTER_BINARY_INT_VP(vp_sdiv, VP_SDIV, SDiv)
  104. // llvm.vp.shl(x,y,mask,vlen)
  105. HELPER_REGISTER_BINARY_INT_VP(vp_shl, VP_SHL, Shl)
  106. // llvm.vp.srem(x,y,mask,vlen)
  107. HELPER_REGISTER_BINARY_INT_VP(vp_srem, VP_SREM, SRem)
  108. // llvm.vp.sub(x,y,mask,vlen)
  109. HELPER_REGISTER_BINARY_INT_VP(vp_sub, VP_SUB, Sub)
  110. // llvm.vp.udiv(x,y,mask,vlen)
  111. HELPER_REGISTER_BINARY_INT_VP(vp_udiv, VP_UDIV, UDiv)
  112. // llvm.vp.urem(x,y,mask,vlen)
  113. HELPER_REGISTER_BINARY_INT_VP(vp_urem, VP_UREM, URem)
  114. // llvm.vp.xor(x,y,mask,vlen)
  115. HELPER_REGISTER_BINARY_INT_VP(vp_xor, VP_XOR, Xor)
  116. #undef HELPER_REGISTER_BINARY_INT_VP
  117. ///// } Integer Arithmetic
  118. #undef BEGIN_REGISTER_VP
  119. #undef BEGIN_REGISTER_VP_INTRINSIC
  120. #undef BEGIN_REGISTER_VP_SDNODE
  121. #undef END_REGISTER_VP
  122. #undef END_REGISTER_VP_INTRINSIC
  123. #undef END_REGISTER_VP_SDNODE
  124. #undef HANDLE_VP_TO_OPC