VPIntrinsics.def 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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
  33. // implicitly registered as the canonical SDNode for this VP intrinsic. There
  34. // is one VP intrinsic that maps directly to one SDNode that goes by the
  35. // same name. Since the operands are also the same, we open the property
  36. // scopes for both the VPIntrinsic and the SDNode at once.
  37. // \p VPSD The SelectionDAG Node id (eg VP_ADD).
  38. // \p LEGALPOS The operand position of the SDNode that is used for legalizing.
  39. // If LEGALPOS < 0, then the return type given by
  40. // TheNode->getValueType(-1-LEGALPOS) is used.
  41. // \p TDNAME The name of the TableGen definition of this SDNode.
  42. // \p MASKPOS The mask operand position.
  43. // \p EVLPOS The explicit vector length operand position.
  44. #ifndef BEGIN_REGISTER_VP_SDNODE
  45. #define BEGIN_REGISTER_VP_SDNODE(VPSD, LEGALPOS, TDNAME, MASKPOS, EVLPOS)
  46. #endif
  47. // End the property scope of a new VP SDNode.
  48. #ifndef END_REGISTER_VP_SDNODE
  49. #define END_REGISTER_VP_SDNODE(VPSD)
  50. #endif
  51. // Helper macro to set up the mapping from VP intrinsic to ISD opcode.
  52. // Note: More than one VP intrinsic may map to one ISD opcode.
  53. #ifndef HELPER_MAP_VPID_TO_VPSD
  54. #define HELPER_MAP_VPID_TO_VPSD(VPID, VPSD)
  55. #endif
  56. // Helper macros for the common "1:1 - Intrinsic : SDNode" case.
  57. //
  58. // There is one VP intrinsic that maps directly to one SDNode that goes by the
  59. // same name. Since the operands are also the same, we open the property
  60. // scopes for both the VPIntrinsic and the SDNode at once.
  61. //
  62. // \p VPID The canonical name (eg `vp_add`, which at the same time is the
  63. // name of the intrinsic and the TableGen def of the SDNode).
  64. // \p MASKPOS The mask operand position.
  65. // \p EVLPOS The explicit vector length operand position.
  66. // \p VPSD The SelectionDAG Node id (eg VP_ADD).
  67. // \p LEGALPOS The operand position of the SDNode that is used for legalizing
  68. // this SDNode. This can be `-1`, in which case the return type of
  69. // the SDNode is used.
  70. #define BEGIN_REGISTER_VP(VPID, MASKPOS, EVLPOS, VPSD, LEGALPOS) \
  71. BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, EVLPOS) \
  72. BEGIN_REGISTER_VP_SDNODE(VPSD, LEGALPOS, VPID, MASKPOS, EVLPOS) \
  73. HELPER_MAP_VPID_TO_VPSD(VPID, VPSD)
  74. #define END_REGISTER_VP(VPID, VPSD) \
  75. END_REGISTER_VP_INTRINSIC(VPID) \
  76. END_REGISTER_VP_SDNODE(VPSD)
  77. // The following macros attach properties to the scope they are placed in. This
  78. // assigns the property to the VP Intrinsic and/or SDNode that belongs to the
  79. // scope.
  80. //
  81. // Property Macros {
  82. // The intrinsic and/or SDNode has the same function as this LLVM IR Opcode.
  83. // \p OPC The opcode of the instruction with the same function.
  84. #ifndef VP_PROPERTY_FUNCTIONAL_OPC
  85. #define VP_PROPERTY_FUNCTIONAL_OPC(OPC)
  86. #endif
  87. // Whether the intrinsic may have a rounding mode or exception behavior operand
  88. // bundle.
  89. // \p HASROUND '1' if the intrinsic can have a rounding mode operand bundle,
  90. // '0' otherwise.
  91. // \p HASEXCEPT '1' if the intrinsic can have an exception behavior operand
  92. // bundle, '0' otherwise.
  93. // \p INTRINID The constrained fp intrinsic this VP intrinsic corresponds to.
  94. #ifndef VP_PROPERTY_CONSTRAINEDFP
  95. #define VP_PROPERTY_CONSTRAINEDFP(HASROUND, HASEXCEPT, INTRINID)
  96. #endif
  97. // Map this VP intrinsic to its canonical functional intrinsic.
  98. // \p INTRIN The non-VP intrinsics with the same function.
  99. #ifndef VP_PROPERTY_FUNCTIONAL_INTRINSIC
  100. #define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN)
  101. #endif
  102. // This VP Intrinsic is a memory operation
  103. // The pointer arg is at POINTERPOS and the data arg is at DATAPOS.
  104. #ifndef VP_PROPERTY_MEMOP
  105. #define VP_PROPERTY_MEMOP(POINTERPOS, DATAPOS)
  106. #endif
  107. // Map this VP reduction intrinsic to its reduction operand positions.
  108. #ifndef VP_PROPERTY_REDUCTION
  109. #define VP_PROPERTY_REDUCTION(STARTPOS, VECTORPOS)
  110. #endif
  111. // A property to infer VP binary-op SDNode opcodes automatically.
  112. #ifndef VP_PROPERTY_BINARYOP
  113. #define VP_PROPERTY_BINARYOP
  114. #endif
  115. // A property to infer VP type casts automatically.
  116. #ifndef VP_PROPERTY_CASTOP
  117. #define VP_PROPERTY_CASTOP
  118. #endif
  119. // This VP Intrinsic is a comparison operation
  120. // The condition code arg is at CCPOS and accepts floating-point condition
  121. // codes if ISFP is set, else it accepts integer condition codes.
  122. #ifndef VP_PROPERTY_CMP
  123. #define VP_PROPERTY_CMP(CCPOS, ISFP)
  124. #endif
  125. /// } Property Macros
  126. ///// Integer Arithmetic {
  127. // Specialized helper macro for integer binary operators (%x, %y, %mask, %evl).
  128. #ifdef HELPER_REGISTER_BINARY_INT_VP
  129. #error \
  130. "The internal helper macro HELPER_REGISTER_BINARY_INT_VP is already defined!"
  131. #endif
  132. #define HELPER_REGISTER_BINARY_INT_VP(VPID, VPSD, IROPC) \
  133. BEGIN_REGISTER_VP(VPID, 2, 3, VPSD, -1) \
  134. VP_PROPERTY_FUNCTIONAL_OPC(IROPC) \
  135. VP_PROPERTY_BINARYOP \
  136. END_REGISTER_VP(VPID, VPSD)
  137. // llvm.vp.add(x,y,mask,vlen)
  138. HELPER_REGISTER_BINARY_INT_VP(vp_add, VP_ADD, Add)
  139. // llvm.vp.and(x,y,mask,vlen)
  140. HELPER_REGISTER_BINARY_INT_VP(vp_and, VP_AND, And)
  141. // llvm.vp.ashr(x,y,mask,vlen)
  142. HELPER_REGISTER_BINARY_INT_VP(vp_ashr, VP_ASHR, AShr)
  143. // llvm.vp.lshr(x,y,mask,vlen)
  144. HELPER_REGISTER_BINARY_INT_VP(vp_lshr, VP_LSHR, LShr)
  145. // llvm.vp.mul(x,y,mask,vlen)
  146. HELPER_REGISTER_BINARY_INT_VP(vp_mul, VP_MUL, Mul)
  147. // llvm.vp.or(x,y,mask,vlen)
  148. HELPER_REGISTER_BINARY_INT_VP(vp_or, VP_OR, Or)
  149. // llvm.vp.sdiv(x,y,mask,vlen)
  150. HELPER_REGISTER_BINARY_INT_VP(vp_sdiv, VP_SDIV, SDiv)
  151. // llvm.vp.shl(x,y,mask,vlen)
  152. HELPER_REGISTER_BINARY_INT_VP(vp_shl, VP_SHL, Shl)
  153. // llvm.vp.srem(x,y,mask,vlen)
  154. HELPER_REGISTER_BINARY_INT_VP(vp_srem, VP_SREM, SRem)
  155. // llvm.vp.sub(x,y,mask,vlen)
  156. HELPER_REGISTER_BINARY_INT_VP(vp_sub, VP_SUB, Sub)
  157. // llvm.vp.udiv(x,y,mask,vlen)
  158. HELPER_REGISTER_BINARY_INT_VP(vp_udiv, VP_UDIV, UDiv)
  159. // llvm.vp.urem(x,y,mask,vlen)
  160. HELPER_REGISTER_BINARY_INT_VP(vp_urem, VP_UREM, URem)
  161. // llvm.vp.xor(x,y,mask,vlen)
  162. HELPER_REGISTER_BINARY_INT_VP(vp_xor, VP_XOR, Xor)
  163. #undef HELPER_REGISTER_BINARY_INT_VP
  164. // llvm.vp.smin(x,y,mask,vlen)
  165. BEGIN_REGISTER_VP(vp_smin, 2, 3, VP_SMIN, -1)
  166. VP_PROPERTY_BINARYOP
  167. END_REGISTER_VP(vp_smin, VP_SMIN)
  168. // llvm.vp.smax(x,y,mask,vlen)
  169. BEGIN_REGISTER_VP(vp_smax, 2, 3, VP_SMAX, -1)
  170. VP_PROPERTY_BINARYOP
  171. END_REGISTER_VP(vp_smax, VP_SMAX)
  172. // llvm.vp.umin(x,y,mask,vlen)
  173. BEGIN_REGISTER_VP(vp_umin, 2, 3, VP_UMIN, -1)
  174. VP_PROPERTY_BINARYOP
  175. END_REGISTER_VP(vp_umin, VP_UMIN)
  176. // llvm.vp.umax(x,y,mask,vlen)
  177. BEGIN_REGISTER_VP(vp_umax, 2, 3, VP_UMAX, -1)
  178. VP_PROPERTY_BINARYOP
  179. END_REGISTER_VP(vp_umax, VP_UMAX)
  180. // llvm.vp.abs(x,mask,vlen,is_int_min_poison)
  181. BEGIN_REGISTER_VP(vp_abs, 1, 2, VP_ABS, -1)
  182. END_REGISTER_VP(vp_abs, VP_ABS)
  183. // llvm.vp.bswap(x,mask,vlen)
  184. BEGIN_REGISTER_VP(vp_bswap, 1, 2, VP_BSWAP, -1)
  185. END_REGISTER_VP(vp_bswap, VP_BSWAP)
  186. // llvm.vp.bitreverse(x,mask,vlen)
  187. BEGIN_REGISTER_VP(vp_bitreverse, 1, 2, VP_BITREVERSE, -1)
  188. END_REGISTER_VP(vp_bitreverse, VP_BITREVERSE)
  189. // llvm.vp.ctpop(x,mask,vlen)
  190. BEGIN_REGISTER_VP(vp_ctpop, 1, 2, VP_CTPOP, -1)
  191. END_REGISTER_VP(vp_ctpop, VP_CTPOP)
  192. // llvm.vp.ctlz(x,mask,vlen, is_zero_poison)
  193. BEGIN_REGISTER_VP_INTRINSIC(vp_ctlz, 1, 2)
  194. BEGIN_REGISTER_VP_SDNODE(VP_CTLZ, -1, vp_ctlz, 1, 2)
  195. END_REGISTER_VP_SDNODE(VP_CTLZ)
  196. BEGIN_REGISTER_VP_SDNODE(VP_CTLZ_ZERO_UNDEF, -1, vp_ctlz_zero_undef, 1, 2)
  197. END_REGISTER_VP_SDNODE(VP_CTLZ_ZERO_UNDEF)
  198. END_REGISTER_VP_INTRINSIC(vp_ctlz)
  199. // llvm.vp.cttz(x,mask,vlen, is_zero_poison)
  200. BEGIN_REGISTER_VP_INTRINSIC(vp_cttz, 1, 2)
  201. BEGIN_REGISTER_VP_SDNODE(VP_CTTZ, -1, vp_cttz, 1, 2)
  202. END_REGISTER_VP_SDNODE(VP_CTTZ)
  203. BEGIN_REGISTER_VP_SDNODE(VP_CTTZ_ZERO_UNDEF, -1, vp_cttz_zero_undef, 1, 2)
  204. END_REGISTER_VP_SDNODE(VP_CTTZ_ZERO_UNDEF)
  205. END_REGISTER_VP_INTRINSIC(vp_cttz)
  206. // llvm.vp.fshl(x,y,z,mask,vlen)
  207. BEGIN_REGISTER_VP(vp_fshl, 3, 4, VP_FSHL, -1)
  208. END_REGISTER_VP(vp_fshl, VP_FSHL)
  209. // llvm.vp.fshr(x,y,z,mask,vlen)
  210. BEGIN_REGISTER_VP(vp_fshr, 3, 4, VP_FSHR, -1)
  211. END_REGISTER_VP(vp_fshr, VP_FSHR)
  212. ///// } Integer Arithmetic
  213. ///// Floating-Point Arithmetic {
  214. // Specialized helper macro for floating-point binary operators
  215. // <operation>(%x, %y, %mask, %evl).
  216. #ifdef HELPER_REGISTER_BINARY_FP_VP
  217. #error \
  218. "The internal helper macro HELPER_REGISTER_BINARY_FP_VP is already defined!"
  219. #endif
  220. #define HELPER_REGISTER_BINARY_FP_VP(OPSUFFIX, VPSD, IROPC) \
  221. BEGIN_REGISTER_VP(vp_##OPSUFFIX, 2, 3, VPSD, -1) \
  222. VP_PROPERTY_FUNCTIONAL_OPC(IROPC) \
  223. VP_PROPERTY_CONSTRAINEDFP(1, 1, experimental_constrained_##OPSUFFIX) \
  224. VP_PROPERTY_BINARYOP \
  225. END_REGISTER_VP(vp_##OPSUFFIX, VPSD)
  226. // llvm.vp.fadd(x,y,mask,vlen)
  227. HELPER_REGISTER_BINARY_FP_VP(fadd, VP_FADD, FAdd)
  228. // llvm.vp.fsub(x,y,mask,vlen)
  229. HELPER_REGISTER_BINARY_FP_VP(fsub, VP_FSUB, FSub)
  230. // llvm.vp.fmul(x,y,mask,vlen)
  231. HELPER_REGISTER_BINARY_FP_VP(fmul, VP_FMUL, FMul)
  232. // llvm.vp.fdiv(x,y,mask,vlen)
  233. HELPER_REGISTER_BINARY_FP_VP(fdiv, VP_FDIV, FDiv)
  234. // llvm.vp.frem(x,y,mask,vlen)
  235. HELPER_REGISTER_BINARY_FP_VP(frem, VP_FREM, FRem)
  236. #undef HELPER_REGISTER_BINARY_FP_VP
  237. // llvm.vp.fneg(x,mask,vlen)
  238. BEGIN_REGISTER_VP(vp_fneg, 1, 2, VP_FNEG, -1)
  239. VP_PROPERTY_FUNCTIONAL_OPC(FNeg)
  240. END_REGISTER_VP(vp_fneg, VP_FNEG)
  241. // llvm.vp.fabs(x,mask,vlen)
  242. BEGIN_REGISTER_VP(vp_fabs, 1, 2, VP_FABS, -1)
  243. END_REGISTER_VP(vp_fabs, VP_FABS)
  244. // llvm.vp.sqrt(x,mask,vlen)
  245. BEGIN_REGISTER_VP(vp_sqrt, 1, 2, VP_SQRT, -1)
  246. END_REGISTER_VP(vp_sqrt, VP_SQRT)
  247. // llvm.vp.fma(x,y,z,mask,vlen)
  248. BEGIN_REGISTER_VP(vp_fma, 3, 4, VP_FMA, -1)
  249. VP_PROPERTY_CONSTRAINEDFP(1, 1, experimental_constrained_fma)
  250. END_REGISTER_VP(vp_fma, VP_FMA)
  251. // llvm.vp.fmuladd(x,y,z,mask,vlen)
  252. BEGIN_REGISTER_VP(vp_fmuladd, 3, 4, VP_FMULADD, -1)
  253. VP_PROPERTY_CONSTRAINEDFP(1, 1, experimental_constrained_fmuladd)
  254. END_REGISTER_VP(vp_fmuladd, VP_FMULADD)
  255. // llvm.vp.copysign(x,y,mask,vlen)
  256. BEGIN_REGISTER_VP(vp_copysign, 2, 3, VP_FCOPYSIGN, -1)
  257. END_REGISTER_VP(vp_copysign, VP_FCOPYSIGN)
  258. // llvm.vp.minnum(x, y, mask,vlen)
  259. BEGIN_REGISTER_VP(vp_minnum, 2, 3, VP_FMINNUM, -1)
  260. VP_PROPERTY_BINARYOP
  261. END_REGISTER_VP(vp_minnum, VP_FMINNUM)
  262. // llvm.vp.maxnum(x, y, mask,vlen)
  263. BEGIN_REGISTER_VP(vp_maxnum, 2, 3, VP_FMAXNUM, -1)
  264. VP_PROPERTY_BINARYOP
  265. END_REGISTER_VP(vp_maxnum, VP_FMAXNUM)
  266. // llvm.vp.ceil(x,mask,vlen)
  267. BEGIN_REGISTER_VP(vp_ceil, 1, 2, VP_FCEIL, -1)
  268. END_REGISTER_VP(vp_ceil, VP_FCEIL)
  269. // llvm.vp.floor(x,mask,vlen)
  270. BEGIN_REGISTER_VP(vp_floor, 1, 2, VP_FFLOOR, -1)
  271. END_REGISTER_VP(vp_floor, VP_FFLOOR)
  272. // llvm.vp.round(x,mask,vlen)
  273. BEGIN_REGISTER_VP(vp_round, 1, 2, VP_FROUND, -1)
  274. END_REGISTER_VP(vp_round, VP_FROUND)
  275. // llvm.vp.roundeven(x,mask,vlen)
  276. BEGIN_REGISTER_VP(vp_roundeven, 1, 2, VP_FROUNDEVEN, -1)
  277. END_REGISTER_VP(vp_roundeven, VP_FROUNDEVEN)
  278. // llvm.vp.roundtozero(x,mask,vlen)
  279. BEGIN_REGISTER_VP(vp_roundtozero, 1, 2, VP_FROUNDTOZERO, -1)
  280. END_REGISTER_VP(vp_roundtozero, VP_FROUNDTOZERO)
  281. // llvm.vp.rint(x,mask,vlen)
  282. BEGIN_REGISTER_VP(vp_rint, 1, 2, VP_FRINT, -1)
  283. END_REGISTER_VP(vp_rint, VP_FRINT)
  284. // llvm.vp.nearbyint(x,mask,vlen)
  285. BEGIN_REGISTER_VP(vp_nearbyint, 1, 2, VP_FNEARBYINT, -1)
  286. END_REGISTER_VP(vp_nearbyint, VP_FNEARBYINT)
  287. ///// } Floating-Point Arithmetic
  288. ///// Type Casts {
  289. // Specialized helper macro for type conversions.
  290. // <operation>(%x, %mask, %evl).
  291. #ifdef HELPER_REGISTER_FP_CAST_VP
  292. #error \
  293. "The internal helper macro HELPER_REGISTER_FP_CAST_VP is already defined!"
  294. #endif
  295. #define HELPER_REGISTER_FP_CAST_VP(OPSUFFIX, VPSD, IROPC, HASROUND) \
  296. BEGIN_REGISTER_VP(vp_##OPSUFFIX, 1, 2, VPSD, -1) \
  297. VP_PROPERTY_FUNCTIONAL_OPC(IROPC) \
  298. VP_PROPERTY_CONSTRAINEDFP(HASROUND, 1, experimental_constrained_##OPSUFFIX) \
  299. VP_PROPERTY_CASTOP \
  300. END_REGISTER_VP(vp_##OPSUFFIX, VPSD)
  301. // llvm.vp.fptoui(x,mask,vlen)
  302. HELPER_REGISTER_FP_CAST_VP(fptoui, VP_FP_TO_UINT, FPToUI, 0)
  303. // llvm.vp.fptosi(x,mask,vlen)
  304. HELPER_REGISTER_FP_CAST_VP(fptosi, VP_FP_TO_SINT, FPToSI, 0)
  305. // llvm.vp.uitofp(x,mask,vlen)
  306. HELPER_REGISTER_FP_CAST_VP(uitofp, VP_UINT_TO_FP, UIToFP, 1)
  307. // llvm.vp.sitofp(x,mask,vlen)
  308. HELPER_REGISTER_FP_CAST_VP(sitofp, VP_SINT_TO_FP, SIToFP, 1)
  309. // llvm.vp.fptrunc(x,mask,vlen)
  310. HELPER_REGISTER_FP_CAST_VP(fptrunc, VP_FP_ROUND, FPTrunc, 1)
  311. // llvm.vp.fpext(x,mask,vlen)
  312. HELPER_REGISTER_FP_CAST_VP(fpext, VP_FP_EXTEND, FPExt, 0)
  313. #undef HELPER_REGISTER_FP_CAST_VP
  314. // Specialized helper macro for integer type conversions.
  315. // <operation>(%x, %mask, %evl).
  316. #ifdef HELPER_REGISTER_INT_CAST_VP
  317. #error \
  318. "The internal helper macro HELPER_REGISTER_INT_CAST_VP is already defined!"
  319. #endif
  320. #define HELPER_REGISTER_INT_CAST_VP(OPSUFFIX, VPSD, IROPC) \
  321. BEGIN_REGISTER_VP(vp_##OPSUFFIX, 1, 2, VPSD, -1) \
  322. VP_PROPERTY_FUNCTIONAL_OPC(IROPC) \
  323. VP_PROPERTY_CASTOP \
  324. END_REGISTER_VP(vp_##OPSUFFIX, VPSD)
  325. // llvm.vp.trunc(x,mask,vlen)
  326. HELPER_REGISTER_INT_CAST_VP(trunc, VP_TRUNCATE, Trunc)
  327. // llvm.vp.zext(x,mask,vlen)
  328. HELPER_REGISTER_INT_CAST_VP(zext, VP_ZERO_EXTEND, ZExt)
  329. // llvm.vp.sext(x,mask,vlen)
  330. HELPER_REGISTER_INT_CAST_VP(sext, VP_SIGN_EXTEND, SExt)
  331. // llvm.vp.ptrtoint(x,mask,vlen)
  332. HELPER_REGISTER_INT_CAST_VP(ptrtoint, VP_PTRTOINT, PtrToInt)
  333. // llvm.vp.inttoptr(x,mask,vlen)
  334. HELPER_REGISTER_INT_CAST_VP(inttoptr, VP_INTTOPTR, IntToPtr)
  335. #undef HELPER_REGISTER_INT_CAST_VP
  336. ///// } Type Casts
  337. ///// Comparisons {
  338. // VP_SETCC (ISel only)
  339. BEGIN_REGISTER_VP_SDNODE(VP_SETCC, 0, vp_setcc, 3, 4)
  340. END_REGISTER_VP_SDNODE(VP_SETCC)
  341. // llvm.vp.fcmp(x,y,cc,mask,vlen)
  342. BEGIN_REGISTER_VP_INTRINSIC(vp_fcmp, 3, 4)
  343. HELPER_MAP_VPID_TO_VPSD(vp_fcmp, VP_SETCC)
  344. VP_PROPERTY_FUNCTIONAL_OPC(FCmp)
  345. VP_PROPERTY_CMP(2, true)
  346. VP_PROPERTY_CONSTRAINEDFP(0, 1, experimental_constrained_fcmp)
  347. END_REGISTER_VP_INTRINSIC(vp_fcmp)
  348. // llvm.vp.icmp(x,y,cc,mask,vlen)
  349. BEGIN_REGISTER_VP_INTRINSIC(vp_icmp, 3, 4)
  350. HELPER_MAP_VPID_TO_VPSD(vp_icmp, VP_SETCC)
  351. VP_PROPERTY_FUNCTIONAL_OPC(ICmp)
  352. VP_PROPERTY_CMP(2, false)
  353. END_REGISTER_VP_INTRINSIC(vp_icmp)
  354. ///// } Comparisons
  355. ///// Memory Operations {
  356. // llvm.vp.store(val,ptr,mask,vlen)
  357. BEGIN_REGISTER_VP_INTRINSIC(vp_store, 2, 3)
  358. // chain = VP_STORE chain,val,base,offset,mask,evl
  359. BEGIN_REGISTER_VP_SDNODE(VP_STORE, 1, vp_store, 4, 5)
  360. HELPER_MAP_VPID_TO_VPSD(vp_store, VP_STORE)
  361. VP_PROPERTY_FUNCTIONAL_OPC(Store)
  362. VP_PROPERTY_FUNCTIONAL_INTRINSIC(masked_store)
  363. VP_PROPERTY_MEMOP(1, 0)
  364. END_REGISTER_VP(vp_store, VP_STORE)
  365. // llvm.experimental.vp.strided.store(val,ptr,stride,mask,vlen)
  366. BEGIN_REGISTER_VP_INTRINSIC(experimental_vp_strided_store, 3, 4)
  367. // chain = EXPERIMENTAL_VP_STRIDED_STORE chain,val,base,offset,stride,mask,evl
  368. BEGIN_REGISTER_VP_SDNODE(EXPERIMENTAL_VP_STRIDED_STORE, 1, experimental_vp_strided_store, 5, 6)
  369. HELPER_MAP_VPID_TO_VPSD(experimental_vp_strided_store, EXPERIMENTAL_VP_STRIDED_STORE)
  370. VP_PROPERTY_MEMOP(1, 0)
  371. END_REGISTER_VP(experimental_vp_strided_store, EXPERIMENTAL_VP_STRIDED_STORE)
  372. // llvm.vp.scatter(ptr,val,mask,vlen)
  373. BEGIN_REGISTER_VP_INTRINSIC(vp_scatter, 2, 3)
  374. // chain = VP_SCATTER chain,val,base,indices,scale,mask,evl
  375. BEGIN_REGISTER_VP_SDNODE(VP_SCATTER, 1, vp_scatter, 5, 6)
  376. HELPER_MAP_VPID_TO_VPSD(vp_scatter, VP_SCATTER)
  377. VP_PROPERTY_FUNCTIONAL_INTRINSIC(masked_scatter)
  378. VP_PROPERTY_MEMOP(1, 0)
  379. END_REGISTER_VP(vp_scatter, VP_SCATTER)
  380. // llvm.vp.load(ptr,mask,vlen)
  381. BEGIN_REGISTER_VP_INTRINSIC(vp_load, 1, 2)
  382. // val,chain = VP_LOAD chain,base,offset,mask,evl
  383. BEGIN_REGISTER_VP_SDNODE(VP_LOAD, -1, vp_load, 3, 4)
  384. HELPER_MAP_VPID_TO_VPSD(vp_load, VP_LOAD)
  385. VP_PROPERTY_FUNCTIONAL_OPC(Load)
  386. VP_PROPERTY_FUNCTIONAL_INTRINSIC(masked_load)
  387. VP_PROPERTY_MEMOP(0, std::nullopt)
  388. END_REGISTER_VP(vp_load, VP_LOAD)
  389. // llvm.experimental.vp.strided.load(ptr,stride,mask,vlen)
  390. BEGIN_REGISTER_VP_INTRINSIC(experimental_vp_strided_load, 2, 3)
  391. // chain = EXPERIMENTAL_VP_STRIDED_LOAD chain,base,offset,stride,mask,evl
  392. BEGIN_REGISTER_VP_SDNODE(EXPERIMENTAL_VP_STRIDED_LOAD, -1, experimental_vp_strided_load, 4, 5)
  393. HELPER_MAP_VPID_TO_VPSD(experimental_vp_strided_load, EXPERIMENTAL_VP_STRIDED_LOAD)
  394. VP_PROPERTY_MEMOP(0, std::nullopt)
  395. END_REGISTER_VP(experimental_vp_strided_load, EXPERIMENTAL_VP_STRIDED_LOAD)
  396. // llvm.vp.gather(ptr,mask,vlen)
  397. BEGIN_REGISTER_VP_INTRINSIC(vp_gather, 1, 2)
  398. // val,chain = VP_GATHER chain,base,indices,scale,mask,evl
  399. BEGIN_REGISTER_VP_SDNODE(VP_GATHER, -1, vp_gather, 4, 5)
  400. HELPER_MAP_VPID_TO_VPSD(vp_gather, VP_GATHER)
  401. VP_PROPERTY_FUNCTIONAL_INTRINSIC(masked_gather)
  402. VP_PROPERTY_MEMOP(0, std::nullopt)
  403. END_REGISTER_VP(vp_gather, VP_GATHER)
  404. ///// } Memory Operations
  405. ///// Reductions {
  406. // Specialized helper macro for VP reductions (%start, %x, %mask, %evl).
  407. #ifdef HELPER_REGISTER_REDUCTION_VP
  408. #error \
  409. "The internal helper macro HELPER_REGISTER_REDUCTION_VP is already defined!"
  410. #endif
  411. #define HELPER_REGISTER_REDUCTION_VP(VPID, VPSD, INTRIN) \
  412. BEGIN_REGISTER_VP(VPID, 2, 3, VPSD, 1) \
  413. VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) \
  414. VP_PROPERTY_REDUCTION(0, 1) \
  415. END_REGISTER_VP(VPID, VPSD)
  416. // llvm.vp.reduce.add(start,x,mask,vlen)
  417. HELPER_REGISTER_REDUCTION_VP(vp_reduce_add, VP_REDUCE_ADD,
  418. experimental_vector_reduce_add)
  419. // llvm.vp.reduce.mul(start,x,mask,vlen)
  420. HELPER_REGISTER_REDUCTION_VP(vp_reduce_mul, VP_REDUCE_MUL,
  421. experimental_vector_reduce_mul)
  422. // llvm.vp.reduce.and(start,x,mask,vlen)
  423. HELPER_REGISTER_REDUCTION_VP(vp_reduce_and, VP_REDUCE_AND,
  424. experimental_vector_reduce_and)
  425. // llvm.vp.reduce.or(start,x,mask,vlen)
  426. HELPER_REGISTER_REDUCTION_VP(vp_reduce_or, VP_REDUCE_OR,
  427. experimental_vector_reduce_or)
  428. // llvm.vp.reduce.xor(start,x,mask,vlen)
  429. HELPER_REGISTER_REDUCTION_VP(vp_reduce_xor, VP_REDUCE_XOR,
  430. experimental_vector_reduce_xor)
  431. // llvm.vp.reduce.smax(start,x,mask,vlen)
  432. HELPER_REGISTER_REDUCTION_VP(vp_reduce_smax, VP_REDUCE_SMAX,
  433. experimental_vector_reduce_smax)
  434. // llvm.vp.reduce.smin(start,x,mask,vlen)
  435. HELPER_REGISTER_REDUCTION_VP(vp_reduce_smin, VP_REDUCE_SMIN,
  436. experimental_vector_reduce_smin)
  437. // llvm.vp.reduce.umax(start,x,mask,vlen)
  438. HELPER_REGISTER_REDUCTION_VP(vp_reduce_umax, VP_REDUCE_UMAX,
  439. experimental_vector_reduce_umax)
  440. // llvm.vp.reduce.umin(start,x,mask,vlen)
  441. HELPER_REGISTER_REDUCTION_VP(vp_reduce_umin, VP_REDUCE_UMIN,
  442. experimental_vector_reduce_umin)
  443. // llvm.vp.reduce.fmax(start,x,mask,vlen)
  444. HELPER_REGISTER_REDUCTION_VP(vp_reduce_fmax, VP_REDUCE_FMAX,
  445. experimental_vector_reduce_fmax)
  446. // llvm.vp.reduce.fmin(start,x,mask,vlen)
  447. HELPER_REGISTER_REDUCTION_VP(vp_reduce_fmin, VP_REDUCE_FMIN,
  448. experimental_vector_reduce_fmin)
  449. #undef HELPER_REGISTER_REDUCTION_VP
  450. // Specialized helper macro for VP reductions as above but with two forms:
  451. // sequential and reassociative. These manifest as the presence of 'reassoc'
  452. // fast-math flags in the IR and as two distinct ISD opcodes in the
  453. // SelectionDAG.
  454. // Note we by default map from the VP intrinsic to the SEQ ISD opcode, which
  455. // can then be relaxed to the non-SEQ ISD opcode if the 'reassoc' flag is set.
  456. #ifdef HELPER_REGISTER_REDUCTION_SEQ_VP
  457. #error \
  458. "The internal helper macro HELPER_REGISTER_REDUCTION_SEQ_VP is already defined!"
  459. #endif
  460. #define HELPER_REGISTER_REDUCTION_SEQ_VP(VPID, VPSD, SEQ_VPSD, INTRIN) \
  461. BEGIN_REGISTER_VP_INTRINSIC(VPID, 2, 3) \
  462. BEGIN_REGISTER_VP_SDNODE(VPSD, 1, VPID, 2, 3) \
  463. VP_PROPERTY_REDUCTION(0, 1) \
  464. END_REGISTER_VP_SDNODE(VPSD) \
  465. BEGIN_REGISTER_VP_SDNODE(SEQ_VPSD, 1, VPID, 2, 3) \
  466. HELPER_MAP_VPID_TO_VPSD(VPID, SEQ_VPSD) \
  467. VP_PROPERTY_REDUCTION(0, 1) \
  468. END_REGISTER_VP_SDNODE(SEQ_VPSD) \
  469. VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) \
  470. END_REGISTER_VP_INTRINSIC(VPID)
  471. // llvm.vp.reduce.fadd(start,x,mask,vlen)
  472. HELPER_REGISTER_REDUCTION_SEQ_VP(vp_reduce_fadd, VP_REDUCE_FADD,
  473. VP_REDUCE_SEQ_FADD,
  474. experimental_vector_reduce_fadd)
  475. // llvm.vp.reduce.fmul(start,x,mask,vlen)
  476. HELPER_REGISTER_REDUCTION_SEQ_VP(vp_reduce_fmul, VP_REDUCE_FMUL,
  477. VP_REDUCE_SEQ_FMUL,
  478. experimental_vector_reduce_fmul)
  479. #undef HELPER_REGISTER_REDUCTION_SEQ_VP
  480. ///// } Reduction
  481. ///// Shuffles {
  482. // The mask 'cond' operand of llvm.vp.select and llvm.vp.merge are not reported
  483. // as masks with the BEGIN_REGISTER_VP_* macros. This is because, unlike other
  484. // VP intrinsics, these two have a defined result on lanes where the mask is
  485. // false.
  486. //
  487. // llvm.vp.select(cond,on_true,on_false,vlen)
  488. BEGIN_REGISTER_VP(vp_select, std::nullopt, 3, VP_SELECT, -1)
  489. VP_PROPERTY_FUNCTIONAL_OPC(Select)
  490. END_REGISTER_VP(vp_select, VP_SELECT)
  491. // llvm.vp.merge(cond,on_true,on_false,pivot)
  492. BEGIN_REGISTER_VP(vp_merge, std::nullopt, 3, VP_MERGE, -1)
  493. END_REGISTER_VP(vp_merge, VP_MERGE)
  494. BEGIN_REGISTER_VP(experimental_vp_splice, 3, 5, EXPERIMENTAL_VP_SPLICE, -1)
  495. END_REGISTER_VP(experimental_vp_splice, EXPERIMENTAL_VP_SPLICE)
  496. ///// } Shuffles
  497. #undef BEGIN_REGISTER_VP
  498. #undef BEGIN_REGISTER_VP_INTRINSIC
  499. #undef BEGIN_REGISTER_VP_SDNODE
  500. #undef END_REGISTER_VP
  501. #undef END_REGISTER_VP_INTRINSIC
  502. #undef END_REGISTER_VP_SDNODE
  503. #undef HELPER_MAP_VPID_TO_VPSD
  504. #undef VP_PROPERTY_BINARYOP
  505. #undef VP_PROPERTY_CASTOP
  506. #undef VP_PROPERTY_CMP
  507. #undef VP_PROPERTY_CONSTRAINEDFP
  508. #undef VP_PROPERTY_FUNCTIONAL_INTRINSIC
  509. #undef VP_PROPERTY_FUNCTIONAL_OPC
  510. #undef VP_PROPERTY_MEMOP
  511. #undef VP_PROPERTY_REDUCTION