Intrinsics.td 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193
  1. //===- Intrinsics.td - Defines all LLVM intrinsics ---------*- 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 defines properties of all LLVM intrinsics.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. include "llvm/CodeGen/ValueTypes.td"
  13. include "llvm/CodeGen/SDNodeProperties.td"
  14. //===----------------------------------------------------------------------===//
  15. // Properties we keep track of for intrinsics.
  16. //===----------------------------------------------------------------------===//
  17. class IntrinsicProperty<bit is_default = false> {
  18. bit IsDefault = is_default;
  19. }
  20. // Intr*Mem - Memory properties. If no property is set, the worst case
  21. // is assumed (it may read and write any memory it can get access to and it may
  22. // have other side effects).
  23. // IntrNoMem - The intrinsic does not access memory or have any other side
  24. // effects. It may be CSE'd deleted if dead, etc.
  25. def IntrNoMem : IntrinsicProperty;
  26. // IntrReadMem - This intrinsic only reads from memory. It does not write to
  27. // memory and has no other side effects. Therefore, it cannot be moved across
  28. // potentially aliasing stores. However, it can be reordered otherwise and can
  29. // be deleted if dead.
  30. def IntrReadMem : IntrinsicProperty;
  31. // IntrWriteMem - This intrinsic only writes to memory, but does not read from
  32. // memory, and has no other side effects. This means dead stores before calls
  33. // to this intrinsics may be removed.
  34. def IntrWriteMem : IntrinsicProperty;
  35. // IntrArgMemOnly - This intrinsic only accesses memory that its pointer-typed
  36. // argument(s) points to, but may access an unspecified amount. Other than
  37. // reads from and (possibly volatile) writes to memory, it has no side effects.
  38. def IntrArgMemOnly : IntrinsicProperty;
  39. // IntrInaccessibleMemOnly -- This intrinsic only accesses memory that is not
  40. // accessible by the module being compiled. This is a weaker form of IntrNoMem.
  41. def IntrInaccessibleMemOnly : IntrinsicProperty;
  42. // IntrInaccessibleMemOrArgMemOnly -- This intrinsic only accesses memory that
  43. // its pointer-typed arguments point to or memory that is not accessible
  44. // by the module being compiled. This is a weaker form of IntrArgMemOnly.
  45. def IntrInaccessibleMemOrArgMemOnly : IntrinsicProperty;
  46. // Commutative - This intrinsic is commutative: X op Y == Y op X.
  47. def Commutative : IntrinsicProperty;
  48. // Throws - This intrinsic can throw.
  49. def Throws : IntrinsicProperty;
  50. // Attribute index needs to match `AttrIndex` defined `Attributes.h`.
  51. class AttrIndex<int idx> {
  52. int Value = idx;
  53. }
  54. def FuncIndex : AttrIndex<-1>;
  55. def RetIndex : AttrIndex<0>;
  56. class ArgIndex<int argNo> : AttrIndex<!add(argNo, 1)>;
  57. // NoCapture - The specified argument pointer is not captured by the intrinsic.
  58. class NoCapture<AttrIndex idx> : IntrinsicProperty {
  59. int ArgNo = idx.Value;
  60. }
  61. // NoAlias - The specified argument pointer is not aliasing other "noalias" pointer
  62. // arguments of the intrinsic wrt. the intrinsic scope.
  63. class NoAlias<AttrIndex idx> : IntrinsicProperty {
  64. int ArgNo = idx.Value;
  65. }
  66. // NoUndef - The specified argument is neither undef nor poison.
  67. class NoUndef<AttrIndex idx> : IntrinsicProperty {
  68. int ArgNo = idx.Value;
  69. }
  70. // NonNull - The specified argument is not null.
  71. class NonNull<AttrIndex idx> : IntrinsicProperty {
  72. int ArgNo = idx.Value;
  73. }
  74. class Align<AttrIndex idx, int align> : IntrinsicProperty {
  75. int ArgNo = idx.Value;
  76. int Align = align;
  77. }
  78. // Returned - The specified argument is always the return value of the
  79. // intrinsic.
  80. class Returned<AttrIndex idx> : IntrinsicProperty {
  81. int ArgNo = idx.Value;
  82. }
  83. // ImmArg - The specified argument must be an immediate.
  84. class ImmArg<AttrIndex idx> : IntrinsicProperty {
  85. int ArgNo = idx.Value;
  86. }
  87. // ReadOnly - The specified argument pointer is not written to through the
  88. // pointer by the intrinsic.
  89. class ReadOnly<AttrIndex idx> : IntrinsicProperty {
  90. int ArgNo = idx.Value;
  91. }
  92. // WriteOnly - The intrinsic does not read memory through the specified
  93. // argument pointer.
  94. class WriteOnly<AttrIndex idx> : IntrinsicProperty {
  95. int ArgNo = idx.Value;
  96. }
  97. // ReadNone - The specified argument pointer is not dereferenced by the
  98. // intrinsic.
  99. class ReadNone<AttrIndex idx> : IntrinsicProperty {
  100. int ArgNo = idx.Value;
  101. }
  102. def IntrNoReturn : IntrinsicProperty;
  103. // Applied by default.
  104. def IntrNoCallback : IntrinsicProperty<1>;
  105. // IntrNoSync - Threads executing the intrinsic will not synchronize using
  106. // memory or other means. Applied by default.
  107. def IntrNoSync : IntrinsicProperty<1>;
  108. // Applied by default.
  109. def IntrNoFree : IntrinsicProperty<1>;
  110. // Applied by default.
  111. def IntrWillReturn : IntrinsicProperty<1>;
  112. // IntrCold - Calls to this intrinsic are cold.
  113. // Parallels the cold attribute on LLVM IR functions.
  114. def IntrCold : IntrinsicProperty;
  115. // IntrNoDuplicate - Calls to this intrinsic cannot be duplicated.
  116. // Parallels the noduplicate attribute on LLVM IR functions.
  117. def IntrNoDuplicate : IntrinsicProperty;
  118. // IntrNoMerge - Calls to this intrinsic cannot be merged
  119. // Parallels the nomerge attribute on LLVM IR functions.
  120. def IntrNoMerge : IntrinsicProperty;
  121. // IntrConvergent - Calls to this intrinsic are convergent and may not be made
  122. // control-dependent on any additional values.
  123. // Parallels the convergent attribute on LLVM IR functions.
  124. def IntrConvergent : IntrinsicProperty;
  125. // This property indicates that the intrinsic is safe to speculate.
  126. def IntrSpeculatable : IntrinsicProperty;
  127. // This property can be used to override the 'has no other side effects'
  128. // language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly
  129. // intrinsic properties. By default, intrinsics are assumed to have side
  130. // effects, so this property is only necessary if you have defined one of
  131. // the memory properties listed above.
  132. // For this property, 'side effects' has the same meaning as 'side effects'
  133. // defined by the hasSideEffects property of the TableGen Instruction class.
  134. def IntrHasSideEffects : IntrinsicProperty;
  135. //===----------------------------------------------------------------------===//
  136. // Types used by intrinsics.
  137. //===----------------------------------------------------------------------===//
  138. class LLVMType<ValueType vt> {
  139. ValueType VT = vt;
  140. int isAny = false;
  141. }
  142. class LLVMQualPointerType<LLVMType elty, int addrspace>
  143. : LLVMType<iPTR>{
  144. LLVMType ElTy = elty;
  145. int AddrSpace = addrspace;
  146. }
  147. class LLVMPointerType<LLVMType elty>
  148. : LLVMQualPointerType<elty, 0>;
  149. class LLVMAnyPointerType<LLVMType elty>
  150. : LLVMType<iPTRAny>{
  151. LLVMType ElTy = elty;
  152. let isAny = true;
  153. }
  154. // Match the type of another intrinsic parameter. Number is an index into the
  155. // list of overloaded types for the intrinsic, excluding all the fixed types.
  156. // The Number value must refer to a previously listed type. For example:
  157. // Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
  158. // has two overloaded types, the 2nd and 3rd arguments. LLVMMatchType<0>
  159. // refers to the first overloaded type, which is the 2nd argument.
  160. class LLVMMatchType<int num>
  161. : LLVMType<OtherVT>{
  162. int Number = num;
  163. }
  164. // Match the type of another intrinsic parameter that is expected to be based on
  165. // an integral type (i.e. either iN or <N x iM>), but change the scalar size to
  166. // be twice as wide or half as wide as the other type. This is only useful when
  167. // the intrinsic is overloaded, so the matched type should be declared as iAny.
  168. class LLVMExtendedType<int num> : LLVMMatchType<num>;
  169. class LLVMTruncatedType<int num> : LLVMMatchType<num>;
  170. // Match the scalar/vector of another intrinsic parameter but with a different
  171. // element type. Either both are scalars or both are vectors with the same
  172. // number of elements.
  173. class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
  174. : LLVMMatchType<idx> {
  175. ValueType ElTy = elty.VT;
  176. }
  177. class LLVMPointerTo<int num> : LLVMMatchType<num>;
  178. class LLVMPointerToElt<int num> : LLVMMatchType<num>;
  179. class LLVMAnyPointerToElt<int num> : LLVMMatchType<num>;
  180. class LLVMVectorOfAnyPointersToElt<int num> : LLVMMatchType<num>;
  181. class LLVMVectorElementType<int num> : LLVMMatchType<num>;
  182. // Match the type of another intrinsic parameter that is expected to be a
  183. // vector type, but change the element count to be half as many.
  184. class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
  185. // Match the type of another intrinsic parameter that is expected to be a
  186. // vector type (i.e. <N x iM>) but with each element subdivided to
  187. // form a vector with more elements that are smaller than the original.
  188. class LLVMSubdivide2VectorType<int num> : LLVMMatchType<num>;
  189. class LLVMSubdivide4VectorType<int num> : LLVMMatchType<num>;
  190. // Match the element count and bit width of another intrinsic parameter, but
  191. // change the element type to an integer.
  192. class LLVMVectorOfBitcastsToInt<int num> : LLVMMatchType<num>;
  193. def llvm_void_ty : LLVMType<isVoid>;
  194. let isAny = true in {
  195. def llvm_any_ty : LLVMType<Any>;
  196. def llvm_anyint_ty : LLVMType<iAny>;
  197. def llvm_anyfloat_ty : LLVMType<fAny>;
  198. def llvm_anyvector_ty : LLVMType<vAny>;
  199. }
  200. def llvm_i1_ty : LLVMType<i1>;
  201. def llvm_i8_ty : LLVMType<i8>;
  202. def llvm_i16_ty : LLVMType<i16>;
  203. def llvm_i32_ty : LLVMType<i32>;
  204. def llvm_i64_ty : LLVMType<i64>;
  205. def llvm_i128_ty : LLVMType<i128>;
  206. def llvm_half_ty : LLVMType<f16>;
  207. def llvm_bfloat_ty : LLVMType<bf16>;
  208. def llvm_float_ty : LLVMType<f32>;
  209. def llvm_double_ty : LLVMType<f64>;
  210. def llvm_f80_ty : LLVMType<f80>;
  211. def llvm_f128_ty : LLVMType<f128>;
  212. def llvm_ppcf128_ty : LLVMType<ppcf128>;
  213. def llvm_ptr_ty : LLVMPointerType<llvm_i8_ty>; // i8*
  214. def llvm_ptrptr_ty : LLVMPointerType<llvm_ptr_ty>; // i8**
  215. def llvm_anyptr_ty : LLVMAnyPointerType<llvm_i8_ty>; // (space)i8*
  216. def llvm_empty_ty : LLVMType<OtherVT>; // { }
  217. def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>; // { }*
  218. def llvm_metadata_ty : LLVMType<MetadataVT>; // !{...}
  219. def llvm_token_ty : LLVMType<token>; // token
  220. def llvm_x86mmx_ty : LLVMType<x86mmx>;
  221. def llvm_ptrx86mmx_ty : LLVMPointerType<llvm_x86mmx_ty>; // <1 x i64>*
  222. def llvm_x86amx_ty : LLVMType<x86amx>;
  223. def llvm_v2i1_ty : LLVMType<v2i1>; // 2 x i1
  224. def llvm_v4i1_ty : LLVMType<v4i1>; // 4 x i1
  225. def llvm_v8i1_ty : LLVMType<v8i1>; // 8 x i1
  226. def llvm_v16i1_ty : LLVMType<v16i1>; // 16 x i1
  227. def llvm_v32i1_ty : LLVMType<v32i1>; // 32 x i1
  228. def llvm_v64i1_ty : LLVMType<v64i1>; // 64 x i1
  229. def llvm_v128i1_ty : LLVMType<v128i1>; // 128 x i1
  230. def llvm_v256i1_ty : LLVMType<v256i1>; // 256 x i1
  231. def llvm_v512i1_ty : LLVMType<v512i1>; // 512 x i1
  232. def llvm_v1024i1_ty : LLVMType<v1024i1>; //1024 x i1
  233. def llvm_v2048i1_ty : LLVMType<v2048i1>; //2048 x i1
  234. def llvm_v1i8_ty : LLVMType<v1i8>; // 1 x i8
  235. def llvm_v2i8_ty : LLVMType<v2i8>; // 2 x i8
  236. def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8
  237. def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8
  238. def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8
  239. def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8
  240. def llvm_v64i8_ty : LLVMType<v64i8>; // 64 x i8
  241. def llvm_v128i8_ty : LLVMType<v128i8>; //128 x i8
  242. def llvm_v256i8_ty : LLVMType<v256i8>; //256 x i8
  243. def llvm_v1i16_ty : LLVMType<v1i16>; // 1 x i16
  244. def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16
  245. def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16
  246. def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16
  247. def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16
  248. def llvm_v32i16_ty : LLVMType<v32i16>; // 32 x i16
  249. def llvm_v64i16_ty : LLVMType<v64i16>; // 64 x i16
  250. def llvm_v128i16_ty : LLVMType<v128i16>; //128 x i16
  251. def llvm_v1i32_ty : LLVMType<v1i32>; // 1 x i32
  252. def llvm_v2i32_ty : LLVMType<v2i32>; // 2 x i32
  253. def llvm_v4i32_ty : LLVMType<v4i32>; // 4 x i32
  254. def llvm_v8i32_ty : LLVMType<v8i32>; // 8 x i32
  255. def llvm_v16i32_ty : LLVMType<v16i32>; // 16 x i32
  256. def llvm_v32i32_ty : LLVMType<v32i32>; // 32 x i32
  257. def llvm_v64i32_ty : LLVMType<v64i32>; // 64 x i32
  258. def llvm_v256i32_ty : LLVMType<v256i32>; //256 x i32
  259. def llvm_v1i64_ty : LLVMType<v1i64>; // 1 x i64
  260. def llvm_v2i64_ty : LLVMType<v2i64>; // 2 x i64
  261. def llvm_v4i64_ty : LLVMType<v4i64>; // 4 x i64
  262. def llvm_v8i64_ty : LLVMType<v8i64>; // 8 x i64
  263. def llvm_v16i64_ty : LLVMType<v16i64>; // 16 x i64
  264. def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64
  265. def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128
  266. def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16)
  267. def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16)
  268. def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16)
  269. def llvm_v16f16_ty : LLVMType<v16f16>; // 16 x half (__fp16)
  270. def llvm_v32f16_ty : LLVMType<v32f16>; // 32 x half (__fp16)
  271. def llvm_v2bf16_ty : LLVMType<v2bf16>; // 2 x bfloat (__bf16)
  272. def llvm_v4bf16_ty : LLVMType<v4bf16>; // 4 x bfloat (__bf16)
  273. def llvm_v8bf16_ty : LLVMType<v8bf16>; // 8 x bfloat (__bf16)
  274. def llvm_v16bf16_ty : LLVMType<v16bf16>; // 16 x bfloat (__bf16)
  275. def llvm_v32bf16_ty : LLVMType<v32bf16>; // 32 x bfloat (__bf16)
  276. def llvm_v1f32_ty : LLVMType<v1f32>; // 1 x float
  277. def llvm_v2f32_ty : LLVMType<v2f32>; // 2 x float
  278. def llvm_v3f32_ty : LLVMType<v3f32>; // 3 x float
  279. def llvm_v4f32_ty : LLVMType<v4f32>; // 4 x float
  280. def llvm_v8f32_ty : LLVMType<v8f32>; // 8 x float
  281. def llvm_v16f32_ty : LLVMType<v16f32>; // 16 x float
  282. def llvm_v32f32_ty : LLVMType<v32f32>; // 32 x float
  283. def llvm_v1f64_ty : LLVMType<v1f64>; // 1 x double
  284. def llvm_v2f64_ty : LLVMType<v2f64>; // 2 x double
  285. def llvm_v4f64_ty : LLVMType<v4f64>; // 4 x double
  286. def llvm_v8f64_ty : LLVMType<v8f64>; // 8 x double
  287. def llvm_v16f64_ty : LLVMType<v16f64>; // 16 x double
  288. def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here
  289. def llvm_externref_ty : LLVMType<externref>;
  290. def llvm_funcref_ty : LLVMType<funcref>;
  291. //===----------------------------------------------------------------------===//
  292. // Intrinsic Definitions.
  293. //===----------------------------------------------------------------------===//
  294. // Intrinsic class - This is used to define one LLVM intrinsic. The name of the
  295. // intrinsic definition should start with "int_", then match the LLVM intrinsic
  296. // name with the "llvm." prefix removed, and all "."s turned into "_"s. For
  297. // example, llvm.bswap.i16 -> int_bswap_i16.
  298. //
  299. // * RetTypes is a list containing the return types expected for the
  300. // intrinsic.
  301. // * ParamTypes is a list containing the parameter types expected for the
  302. // intrinsic.
  303. // * Properties can be set to describe the behavior of the intrinsic.
  304. //
  305. class Intrinsic<list<LLVMType> ret_types,
  306. list<LLVMType> param_types = [],
  307. list<IntrinsicProperty> intr_properties = [],
  308. string name = "",
  309. list<SDNodeProperty> sd_properties = [],
  310. bit disable_default_attributes = true> : SDPatternOperator {
  311. string LLVMName = name;
  312. string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics.
  313. list<LLVMType> RetTypes = ret_types;
  314. list<LLVMType> ParamTypes = param_types;
  315. list<IntrinsicProperty> IntrProperties = intr_properties;
  316. let Properties = sd_properties;
  317. // Disable applying IntrinsicProperties that are marked default with
  318. // IntrinsicProperty<1>
  319. bit DisableDefaultAttributes = disable_default_attributes;
  320. bit isTarget = false;
  321. }
  322. // Intrinsic with default attributes (disable_default_attributes = false).
  323. class DefaultAttrsIntrinsic<list<LLVMType> ret_types,
  324. list<LLVMType> param_types = [],
  325. list<IntrinsicProperty> intr_properties = [],
  326. string name = "",
  327. list<SDNodeProperty> sd_properties = []>
  328. : Intrinsic<ret_types, param_types,
  329. intr_properties, name,
  330. sd_properties, /*disable_default_attributes*/ 0> {}
  331. /// ClangBuiltin - If this intrinsic exactly corresponds to a Clang builtin, this
  332. /// specifies the name of the builtin. This provides automatic CBE and CFE
  333. /// support.
  334. class ClangBuiltin<string name> {
  335. string ClangBuiltinName = name;
  336. }
  337. class MSBuiltin<string name> {
  338. string MSBuiltinName = name;
  339. }
  340. //===--------------- Variable Argument Handling Intrinsics ----------------===//
  341. //
  342. def int_vastart : DefaultAttrsIntrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
  343. def int_vacopy : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
  344. "llvm.va_copy">;
  345. def int_vaend : DefaultAttrsIntrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
  346. //===------------------- Garbage Collection Intrinsics --------------------===//
  347. //
  348. def int_gcroot : Intrinsic<[],
  349. [llvm_ptrptr_ty, llvm_ptr_ty]>;
  350. def int_gcread : Intrinsic<[llvm_ptr_ty],
  351. [llvm_ptr_ty, llvm_ptrptr_ty],
  352. [IntrReadMem, IntrArgMemOnly]>;
  353. def int_gcwrite : Intrinsic<[],
  354. [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
  355. [IntrArgMemOnly, NoCapture<ArgIndex<1>>,
  356. NoCapture<ArgIndex<2>>]>;
  357. //===------------------- ObjC ARC runtime Intrinsics --------------------===//
  358. //
  359. // Note these are to support the Objective-C ARC optimizer which wants to
  360. // eliminate retain and releases where possible.
  361. def int_objc_autorelease : Intrinsic<[llvm_ptr_ty],
  362. [llvm_ptr_ty]>;
  363. def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>;
  364. def int_objc_autoreleasePoolPush : Intrinsic<[llvm_ptr_ty], []>;
  365. def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
  366. [llvm_ptr_ty]>;
  367. def int_objc_copyWeak : Intrinsic<[],
  368. [llvm_ptrptr_ty,
  369. llvm_ptrptr_ty]>;
  370. def int_objc_destroyWeak : Intrinsic<[], [llvm_ptrptr_ty]>;
  371. def int_objc_initWeak : Intrinsic<[llvm_ptr_ty],
  372. [llvm_ptrptr_ty,
  373. llvm_ptr_ty]>;
  374. def int_objc_loadWeak : Intrinsic<[llvm_ptr_ty],
  375. [llvm_ptrptr_ty]>;
  376. def int_objc_loadWeakRetained : Intrinsic<[llvm_ptr_ty],
  377. [llvm_ptrptr_ty]>;
  378. def int_objc_moveWeak : Intrinsic<[],
  379. [llvm_ptrptr_ty,
  380. llvm_ptrptr_ty]>;
  381. def int_objc_release : Intrinsic<[], [llvm_ptr_ty]>;
  382. def int_objc_retain : Intrinsic<[llvm_ptr_ty],
  383. [llvm_ptr_ty]>;
  384. def int_objc_retainAutorelease : Intrinsic<[llvm_ptr_ty],
  385. [llvm_ptr_ty]>;
  386. def int_objc_retainAutoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
  387. [llvm_ptr_ty]>;
  388. def int_objc_retainAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
  389. [llvm_ptr_ty]>;
  390. def int_objc_retainBlock : Intrinsic<[llvm_ptr_ty],
  391. [llvm_ptr_ty]>;
  392. def int_objc_storeStrong : Intrinsic<[],
  393. [llvm_ptrptr_ty,
  394. llvm_ptr_ty]>;
  395. def int_objc_storeWeak : Intrinsic<[llvm_ptr_ty],
  396. [llvm_ptrptr_ty,
  397. llvm_ptr_ty]>;
  398. def int_objc_clang_arc_use : Intrinsic<[],
  399. [llvm_vararg_ty]>;
  400. def int_objc_clang_arc_noop_use : DefaultAttrsIntrinsic<[],
  401. [llvm_vararg_ty],
  402. [IntrInaccessibleMemOnly]>;
  403. def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
  404. [llvm_ptr_ty]>;
  405. def int_objc_retainedObject : Intrinsic<[llvm_ptr_ty],
  406. [llvm_ptr_ty]>;
  407. def int_objc_unretainedObject : Intrinsic<[llvm_ptr_ty],
  408. [llvm_ptr_ty]>;
  409. def int_objc_unretainedPointer : Intrinsic<[llvm_ptr_ty],
  410. [llvm_ptr_ty]>;
  411. def int_objc_retain_autorelease : Intrinsic<[llvm_ptr_ty],
  412. [llvm_ptr_ty]>;
  413. def int_objc_sync_enter : Intrinsic<[llvm_i32_ty],
  414. [llvm_ptr_ty]>;
  415. def int_objc_sync_exit : Intrinsic<[llvm_i32_ty],
  416. [llvm_ptr_ty]>;
  417. def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
  418. [llvm_ptrptr_ty,
  419. llvm_ptrptr_ty]>;
  420. def int_objc_arc_annotation_topdown_bbend : Intrinsic<[],
  421. [llvm_ptrptr_ty,
  422. llvm_ptrptr_ty]>;
  423. def int_objc_arc_annotation_bottomup_bbstart : Intrinsic<[],
  424. [llvm_ptrptr_ty,
  425. llvm_ptrptr_ty]>;
  426. def int_objc_arc_annotation_bottomup_bbend : Intrinsic<[],
  427. [llvm_ptrptr_ty,
  428. llvm_ptrptr_ty]>;
  429. //===--------------- Swift asynchronous context intrinsics ----------------===//
  430. // Returns the location of the Swift asynchronous context (usually stored just
  431. // before the frame pointer), and triggers the creation of a null context if it
  432. // would otherwise be unneeded.
  433. def int_swift_async_context_addr : Intrinsic<[llvm_ptrptr_ty], [], []>;
  434. //===--------------------- Code Generator Intrinsics ----------------------===//
  435. //
  436. def int_returnaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_i32_ty],
  437. [IntrNoMem, ImmArg<ArgIndex<0>>]>;
  438. def int_addressofreturnaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
  439. def int_frameaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_i32_ty],
  440. [IntrNoMem, ImmArg<ArgIndex<0>>]>;
  441. def int_sponentry : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
  442. def int_read_register : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
  443. [IntrReadMem], "llvm.read_register">;
  444. def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
  445. [IntrNoCallback], "llvm.write_register">;
  446. def int_read_volatile_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
  447. [IntrHasSideEffects],
  448. "llvm.read_volatile_register">;
  449. // Gets the address of the local variable area. This is typically a copy of the
  450. // stack, frame, or base pointer depending on the type of prologue.
  451. def int_localaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
  452. // Escapes local variables to allow access from other functions.
  453. def int_localescape : DefaultAttrsIntrinsic<[], [llvm_vararg_ty]>;
  454. // Given a function and the localaddress of a parent frame, returns a pointer
  455. // to an escaped allocation indicated by the index.
  456. def int_localrecover : DefaultAttrsIntrinsic<[llvm_ptr_ty],
  457. [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
  458. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  459. // Given the frame pointer passed into an SEH filter function, returns a
  460. // pointer to the local variable area suitable for use with llvm.localrecover.
  461. def int_eh_recoverfp : DefaultAttrsIntrinsic<[llvm_ptr_ty],
  462. [llvm_ptr_ty, llvm_ptr_ty],
  463. [IntrNoMem]>;
  464. // To mark the beginning/end of a try-scope for Windows SEH -EHa
  465. // calls/invokes to these intrinsics are placed to model control flows
  466. // caused by HW exceptions under option -EHa.
  467. // calls/invokes to these intrinsics will be discarded during a codegen pass
  468. // after EH tables are generated
  469. def int_seh_try_begin : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
  470. def int_seh_try_end : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
  471. def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
  472. def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>;
  473. // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
  474. // model their dependencies on allocas.
  475. def int_stacksave : DefaultAttrsIntrinsic<[llvm_ptr_ty]>,
  476. ClangBuiltin<"__builtin_stack_save">;
  477. def int_stackrestore : DefaultAttrsIntrinsic<[], [llvm_ptr_ty]>,
  478. ClangBuiltin<"__builtin_stack_restore">;
  479. def int_get_dynamic_area_offset : DefaultAttrsIntrinsic<[llvm_anyint_ty]>;
  480. def int_thread_pointer : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
  481. ClangBuiltin<"__builtin_thread_pointer">;
  482. // IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
  483. // necessary for prefetch, however it does conveniently prevent the prefetch
  484. // from being reordered overly much with respect to nearby access to the same
  485. // memory while not impeding optimization.
  486. def int_prefetch
  487. : DefaultAttrsIntrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
  488. [IntrInaccessibleMemOrArgMemOnly, IntrWillReturn,
  489. ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>,
  490. ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
  491. def int_pcmarker : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
  492. def int_readcyclecounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>;
  493. // The assume intrinsic is marked InaccessibleMemOnly so that proper control
  494. // dependencies will be maintained.
  495. def int_assume : DefaultAttrsIntrinsic<
  496. [], [llvm_i1_ty], [IntrInaccessibleMemOnly, NoUndef<ArgIndex<0>>]>;
  497. // 'llvm.experimental.noalias.scope.decl' intrinsic: Inserted at the location of
  498. // noalias scope declaration. Makes it possible to identify that a noalias scope
  499. // is only valid inside the body of a loop.
  500. //
  501. // Purpose of the different arguments:
  502. // - arg0: id.scope: metadata representing the scope declaration.
  503. def int_experimental_noalias_scope_decl
  504. : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
  505. [IntrInaccessibleMemOnly]>; // blocks LICM and some more
  506. // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
  507. // guard to the correct place on the stack frame.
  508. def int_stackprotector : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
  509. def int_stackguard : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], []>;
  510. // A cover for instrumentation based profiling.
  511. def int_instrprof_cover : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty,
  512. llvm_i32_ty, llvm_i32_ty]>;
  513. // A counter increment for instrumentation based profiling.
  514. def int_instrprof_increment : Intrinsic<[],
  515. [llvm_ptr_ty, llvm_i64_ty,
  516. llvm_i32_ty, llvm_i32_ty]>;
  517. // A counter increment with step for instrumentation based profiling.
  518. def int_instrprof_increment_step : Intrinsic<[],
  519. [llvm_ptr_ty, llvm_i64_ty,
  520. llvm_i32_ty, llvm_i32_ty, llvm_i64_ty]>;
  521. // A call to profile runtime for value profiling of target expressions
  522. // through instrumentation based profiling.
  523. def int_instrprof_value_profile : Intrinsic<[],
  524. [llvm_ptr_ty, llvm_i64_ty,
  525. llvm_i64_ty, llvm_i32_ty,
  526. llvm_i32_ty]>;
  527. def int_call_preallocated_setup : DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty]>;
  528. def int_call_preallocated_arg : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty]>;
  529. def int_call_preallocated_teardown : DefaultAttrsIntrinsic<[], [llvm_token_ty]>;
  530. //===------------------- Standard C Library Intrinsics --------------------===//
  531. //
  532. def int_memcpy : Intrinsic<[],
  533. [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
  534. llvm_i1_ty],
  535. [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
  536. IntrNoCallback,
  537. NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
  538. NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
  539. WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
  540. ImmArg<ArgIndex<3>>]>;
  541. // Memcpy semantic that is guaranteed to be inlined.
  542. // In particular this means that the generated code is not allowed to call any
  543. // external function.
  544. // The third argument (specifying the size) must be a constant.
  545. def int_memcpy_inline
  546. : Intrinsic<[],
  547. [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i1_ty],
  548. [IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
  549. NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
  550. NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
  551. WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
  552. ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
  553. def int_memmove : Intrinsic<[],
  554. [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
  555. llvm_i1_ty],
  556. [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
  557. IntrNoCallback,
  558. NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
  559. WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
  560. ImmArg<ArgIndex<3>>]>;
  561. def int_memset : Intrinsic<[],
  562. [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
  563. llvm_i1_ty],
  564. [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
  565. IntrNoFree, IntrNoCallback,
  566. NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
  567. ImmArg<ArgIndex<3>>]>;
  568. // Memset version that is guaranteed to be inlined.
  569. // In particular this means that the generated code is not allowed to call any
  570. // external function.
  571. // The third argument (specifying the size) must be a constant.
  572. def int_memset_inline
  573. : Intrinsic<[],
  574. [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i1_ty],
  575. [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
  576. NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
  577. ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
  578. // FIXME: Add version of these floating point intrinsics which allow non-default
  579. // rounding modes and FP exception handling.
  580. let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
  581. def int_fma : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  582. [LLVMMatchType<0>, LLVMMatchType<0>,
  583. LLVMMatchType<0>]>;
  584. def int_fmuladd : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  585. [LLVMMatchType<0>, LLVMMatchType<0>,
  586. LLVMMatchType<0>]>;
  587. // These functions do not read memory, but are sensitive to the
  588. // rounding mode. LLVM purposely does not model changes to the FP
  589. // environment so they can be treated as readnone.
  590. def int_sqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  591. def int_powi : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_anyint_ty]>;
  592. def int_sin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  593. def int_cos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  594. def int_pow : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  595. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  596. def int_log : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  597. def int_log10: DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  598. def int_log2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  599. def int_exp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  600. def int_exp2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  601. def int_fabs : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  602. def int_copysign : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  603. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  604. def int_floor : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  605. def int_ceil : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  606. def int_trunc : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  607. def int_rint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  608. def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  609. def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  610. def int_roundeven : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
  611. // Truncate a floating point number with a specific rounding mode
  612. def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  613. [ llvm_anyfloat_ty, llvm_metadata_ty ]>;
  614. def int_canonicalize : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
  615. [IntrNoMem]>;
  616. // Arithmetic fence intrinsic.
  617. def int_arithmetic_fence : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
  618. [IntrNoMem]>;
  619. def int_lround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
  620. def int_llround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
  621. def int_lrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
  622. def int_llrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
  623. }
  624. def int_minnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  625. [LLVMMatchType<0>, LLVMMatchType<0>],
  626. [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
  627. >;
  628. def int_maxnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  629. [LLVMMatchType<0>, LLVMMatchType<0>],
  630. [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
  631. >;
  632. def int_minimum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  633. [LLVMMatchType<0>, LLVMMatchType<0>],
  634. [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
  635. >;
  636. def int_maximum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
  637. [LLVMMatchType<0>, LLVMMatchType<0>],
  638. [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
  639. >;
  640. // Internal interface for object size checking
  641. def int_objectsize : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  642. [llvm_anyptr_ty, llvm_i1_ty,
  643. llvm_i1_ty, llvm_i1_ty],
  644. [IntrNoMem, IntrSpeculatable, IntrWillReturn,
  645. ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>,
  646. ImmArg<ArgIndex<3>>]>,
  647. ClangBuiltin<"__builtin_object_size">;
  648. //===--------------- Access to Floating Point Environment -----------------===//
  649. //
  650. let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
  651. def int_get_rounding : DefaultAttrsIntrinsic<[llvm_i32_ty], []>;
  652. def int_set_rounding : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
  653. }
  654. //===--------------- Floating Point Properties ----------------------------===//
  655. //
  656. def int_is_fpclass
  657. : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  658. [llvm_anyfloat_ty, llvm_i32_ty],
  659. [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
  660. //===--------------- Constrained Floating Point Intrinsics ----------------===//
  661. //
  662. let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
  663. def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  664. [ LLVMMatchType<0>,
  665. LLVMMatchType<0>,
  666. llvm_metadata_ty,
  667. llvm_metadata_ty ]>;
  668. def int_experimental_constrained_fsub : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  669. [ LLVMMatchType<0>,
  670. LLVMMatchType<0>,
  671. llvm_metadata_ty,
  672. llvm_metadata_ty ]>;
  673. def int_experimental_constrained_fmul : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  674. [ LLVMMatchType<0>,
  675. LLVMMatchType<0>,
  676. llvm_metadata_ty,
  677. llvm_metadata_ty ]>;
  678. def int_experimental_constrained_fdiv : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  679. [ LLVMMatchType<0>,
  680. LLVMMatchType<0>,
  681. llvm_metadata_ty,
  682. llvm_metadata_ty ]>;
  683. def int_experimental_constrained_frem : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  684. [ LLVMMatchType<0>,
  685. LLVMMatchType<0>,
  686. llvm_metadata_ty,
  687. llvm_metadata_ty ]>;
  688. def int_experimental_constrained_fma : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  689. [ LLVMMatchType<0>,
  690. LLVMMatchType<0>,
  691. LLVMMatchType<0>,
  692. llvm_metadata_ty,
  693. llvm_metadata_ty ]>;
  694. def int_experimental_constrained_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  695. [ LLVMMatchType<0>,
  696. LLVMMatchType<0>,
  697. LLVMMatchType<0>,
  698. llvm_metadata_ty,
  699. llvm_metadata_ty ]>;
  700. def int_experimental_constrained_fptosi : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
  701. [ llvm_anyfloat_ty,
  702. llvm_metadata_ty ]>;
  703. def int_experimental_constrained_fptoui : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
  704. [ llvm_anyfloat_ty,
  705. llvm_metadata_ty ]>;
  706. def int_experimental_constrained_sitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  707. [ llvm_anyint_ty,
  708. llvm_metadata_ty,
  709. llvm_metadata_ty ]>;
  710. def int_experimental_constrained_uitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  711. [ llvm_anyint_ty,
  712. llvm_metadata_ty,
  713. llvm_metadata_ty ]>;
  714. def int_experimental_constrained_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  715. [ llvm_anyfloat_ty,
  716. llvm_metadata_ty,
  717. llvm_metadata_ty ]>;
  718. def int_experimental_constrained_fpext : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  719. [ llvm_anyfloat_ty,
  720. llvm_metadata_ty ]>;
  721. // These intrinsics are sensitive to the rounding mode so we need constrained
  722. // versions of each of them. When strict rounding and exception control are
  723. // not required the non-constrained versions of these intrinsics should be
  724. // used.
  725. def int_experimental_constrained_sqrt : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  726. [ LLVMMatchType<0>,
  727. llvm_metadata_ty,
  728. llvm_metadata_ty ]>;
  729. def int_experimental_constrained_powi : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  730. [ LLVMMatchType<0>,
  731. llvm_i32_ty,
  732. llvm_metadata_ty,
  733. llvm_metadata_ty ]>;
  734. def int_experimental_constrained_sin : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  735. [ LLVMMatchType<0>,
  736. llvm_metadata_ty,
  737. llvm_metadata_ty ]>;
  738. def int_experimental_constrained_cos : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  739. [ LLVMMatchType<0>,
  740. llvm_metadata_ty,
  741. llvm_metadata_ty ]>;
  742. def int_experimental_constrained_pow : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  743. [ LLVMMatchType<0>,
  744. LLVMMatchType<0>,
  745. llvm_metadata_ty,
  746. llvm_metadata_ty ]>;
  747. def int_experimental_constrained_log : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  748. [ LLVMMatchType<0>,
  749. llvm_metadata_ty,
  750. llvm_metadata_ty ]>;
  751. def int_experimental_constrained_log10: DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  752. [ LLVMMatchType<0>,
  753. llvm_metadata_ty,
  754. llvm_metadata_ty ]>;
  755. def int_experimental_constrained_log2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  756. [ LLVMMatchType<0>,
  757. llvm_metadata_ty,
  758. llvm_metadata_ty ]>;
  759. def int_experimental_constrained_exp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  760. [ LLVMMatchType<0>,
  761. llvm_metadata_ty,
  762. llvm_metadata_ty ]>;
  763. def int_experimental_constrained_exp2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  764. [ LLVMMatchType<0>,
  765. llvm_metadata_ty,
  766. llvm_metadata_ty ]>;
  767. def int_experimental_constrained_rint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  768. [ LLVMMatchType<0>,
  769. llvm_metadata_ty,
  770. llvm_metadata_ty ]>;
  771. def int_experimental_constrained_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  772. [ LLVMMatchType<0>,
  773. llvm_metadata_ty,
  774. llvm_metadata_ty ]>;
  775. def int_experimental_constrained_lrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
  776. [ llvm_anyfloat_ty,
  777. llvm_metadata_ty,
  778. llvm_metadata_ty ]>;
  779. def int_experimental_constrained_llrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
  780. [ llvm_anyfloat_ty,
  781. llvm_metadata_ty,
  782. llvm_metadata_ty ]>;
  783. def int_experimental_constrained_maxnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  784. [ LLVMMatchType<0>,
  785. LLVMMatchType<0>,
  786. llvm_metadata_ty ]>;
  787. def int_experimental_constrained_minnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  788. [ LLVMMatchType<0>,
  789. LLVMMatchType<0>,
  790. llvm_metadata_ty ]>;
  791. def int_experimental_constrained_maximum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  792. [ LLVMMatchType<0>,
  793. LLVMMatchType<0>,
  794. llvm_metadata_ty ]>;
  795. def int_experimental_constrained_minimum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  796. [ LLVMMatchType<0>,
  797. LLVMMatchType<0>,
  798. llvm_metadata_ty ]>;
  799. def int_experimental_constrained_ceil : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  800. [ LLVMMatchType<0>,
  801. llvm_metadata_ty ]>;
  802. def int_experimental_constrained_floor : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  803. [ LLVMMatchType<0>,
  804. llvm_metadata_ty ]>;
  805. def int_experimental_constrained_lround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
  806. [ llvm_anyfloat_ty,
  807. llvm_metadata_ty ]>;
  808. def int_experimental_constrained_llround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
  809. [ llvm_anyfloat_ty,
  810. llvm_metadata_ty ]>;
  811. def int_experimental_constrained_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  812. [ LLVMMatchType<0>,
  813. llvm_metadata_ty ]>;
  814. def int_experimental_constrained_roundeven : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  815. [ LLVMMatchType<0>,
  816. llvm_metadata_ty ]>;
  817. def int_experimental_constrained_trunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
  818. [ LLVMMatchType<0>,
  819. llvm_metadata_ty ]>;
  820. // Constrained floating-point comparison (quiet and signaling variants).
  821. // Third operand is the predicate represented as a metadata string.
  822. def int_experimental_constrained_fcmp
  823. : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
  824. [ llvm_anyfloat_ty, LLVMMatchType<0>,
  825. llvm_metadata_ty, llvm_metadata_ty ]>;
  826. def int_experimental_constrained_fcmps
  827. : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
  828. [ llvm_anyfloat_ty, LLVMMatchType<0>,
  829. llvm_metadata_ty, llvm_metadata_ty ]>;
  830. }
  831. // FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
  832. //===------------------------- Expect Intrinsics --------------------------===//
  833. //
  834. def int_expect : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  835. [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
  836. def int_expect_with_probability : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  837. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_double_ty],
  838. [IntrNoMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
  839. //===-------------------- Bit Manipulation Intrinsics ---------------------===//
  840. //
  841. // None of these intrinsics accesses memory at all.
  842. let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
  843. def int_bswap: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
  844. def int_ctpop: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
  845. def int_bitreverse : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
  846. def int_fshl : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  847. [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
  848. def int_fshr : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  849. [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
  850. }
  851. let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn,
  852. ImmArg<ArgIndex<1>>] in {
  853. def int_ctlz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
  854. def int_cttz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
  855. }
  856. //===------------------------ Debugger Intrinsics -------------------------===//
  857. //
  858. // None of these intrinsics accesses memory at all...but that doesn't
  859. // mean the optimizers can change them aggressively. Special handling
  860. // needed in a few places. These synthetic intrinsics have no
  861. // side-effects and just mark information about their operands.
  862. let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
  863. def int_dbg_declare : DefaultAttrsIntrinsic<[],
  864. [llvm_metadata_ty,
  865. llvm_metadata_ty,
  866. llvm_metadata_ty]>;
  867. def int_dbg_value : DefaultAttrsIntrinsic<[],
  868. [llvm_metadata_ty,
  869. llvm_metadata_ty,
  870. llvm_metadata_ty]>;
  871. def int_dbg_addr : DefaultAttrsIntrinsic<[],
  872. [llvm_metadata_ty,
  873. llvm_metadata_ty,
  874. llvm_metadata_ty]>;
  875. def int_dbg_assign : DefaultAttrsIntrinsic<[],
  876. [llvm_metadata_ty,
  877. llvm_metadata_ty,
  878. llvm_metadata_ty,
  879. llvm_metadata_ty,
  880. llvm_metadata_ty,
  881. llvm_metadata_ty]>;
  882. def int_dbg_label : DefaultAttrsIntrinsic<[],
  883. [llvm_metadata_ty]>;
  884. }
  885. //===------------------ Exception Handling Intrinsics----------------------===//
  886. //
  887. // The result of eh.typeid.for depends on the enclosing function, but inside a
  888. // given function it is 'const' and may be CSE'd etc.
  889. def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
  890. def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
  891. def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
  892. // eh.exceptionpointer returns the pointer to the exception caught by
  893. // the given `catchpad`.
  894. def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
  895. [IntrNoMem]>;
  896. // Gets the exception code from a catchpad token. Only used on some platforms.
  897. def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
  898. // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
  899. // callee-saved registers to be saved and restored (regardless of whether they
  900. // are used) in the calling function. It is used by libgcc_eh.
  901. def int_eh_unwind_init: Intrinsic<[]>,
  902. ClangBuiltin<"__builtin_unwind_init">;
  903. def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
  904. def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
  905. def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty], [IntrNoMem, ImmArg<ArgIndex<0>>]>;
  906. def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
  907. def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
  908. def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
  909. def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>;
  910. //===---------------- Generic Variable Attribute Intrinsics----------------===//
  911. //
  912. def int_var_annotation : DefaultAttrsIntrinsic<
  913. [], [llvm_anyptr_ty, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
  914. [IntrInaccessibleMemOnly], "llvm.var.annotation">;
  915. def int_ptr_annotation : DefaultAttrsIntrinsic<
  916. [LLVMAnyPointerType<llvm_anyint_ty>],
  917. [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
  918. [IntrInaccessibleMemOnly], "llvm.ptr.annotation">;
  919. def int_annotation : DefaultAttrsIntrinsic<
  920. [llvm_anyint_ty],
  921. [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty],
  922. [IntrInaccessibleMemOnly], "llvm.annotation">;
  923. // Annotates the current program point with metadata strings which are emitted
  924. // as CodeView debug info records. This is expensive, as it disables inlining
  925. // and is modelled as having side effects.
  926. def int_codeview_annotation : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
  927. [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
  928. "llvm.codeview.annotation">;
  929. //===------------------------ Trampoline Intrinsics -----------------------===//
  930. //
  931. def int_init_trampoline : DefaultAttrsIntrinsic<
  932. [], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
  933. [IntrArgMemOnly, NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
  934. ReadNone<ArgIndex<1>>, ReadNone<ArgIndex<2>>]>,
  935. ClangBuiltin<"__builtin_init_trampoline">;
  936. def int_adjust_trampoline : DefaultAttrsIntrinsic<
  937. [llvm_ptr_ty], [llvm_ptr_ty], [IntrReadMem, IntrArgMemOnly]>,
  938. ClangBuiltin<"__builtin_adjust_trampoline">;
  939. //===------------------------ Overflow Intrinsics -------------------------===//
  940. //
  941. // Expose the carry flag from add operations on two integrals.
  942. let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
  943. def int_sadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
  944. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  945. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  946. def int_uadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
  947. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  948. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  949. def int_ssub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
  950. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  951. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  952. def int_usub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
  953. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  954. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  955. def int_smul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
  956. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  957. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  958. def int_umul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
  959. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  960. [LLVMMatchType<0>, LLVMMatchType<0>]>;
  961. }
  962. //===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
  963. //
  964. def int_sadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  965. [LLVMMatchType<0>, LLVMMatchType<0>],
  966. [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
  967. def int_uadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  968. [LLVMMatchType<0>, LLVMMatchType<0>],
  969. [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
  970. def int_ssub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  971. [LLVMMatchType<0>, LLVMMatchType<0>],
  972. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  973. def int_usub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  974. [LLVMMatchType<0>, LLVMMatchType<0>],
  975. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  976. def int_sshl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  977. [LLVMMatchType<0>, LLVMMatchType<0>],
  978. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  979. def int_ushl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  980. [LLVMMatchType<0>, LLVMMatchType<0>],
  981. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  982. //===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
  983. //
  984. def int_smul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  985. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  986. [IntrNoMem, IntrSpeculatable, IntrWillReturn,
  987. Commutative, ImmArg<ArgIndex<2>>]>;
  988. def int_umul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  989. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  990. [IntrNoMem, IntrSpeculatable, IntrWillReturn,
  991. Commutative, ImmArg<ArgIndex<2>>]>;
  992. def int_sdiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  993. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  994. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  995. def int_udiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  996. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  997. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  998. //===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
  999. //
  1000. def int_smul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  1001. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  1002. [IntrNoMem, IntrSpeculatable, IntrWillReturn,
  1003. Commutative, ImmArg<ArgIndex<2>>]>;
  1004. def int_umul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  1005. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  1006. [IntrNoMem, IntrSpeculatable, IntrWillReturn,
  1007. Commutative, ImmArg<ArgIndex<2>>]>;
  1008. def int_sdiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  1009. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  1010. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  1011. def int_udiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
  1012. [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
  1013. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  1014. //===------------------ Integer Min/Max/Abs Intrinsics --------------------===//
  1015. //
  1016. def int_abs : DefaultAttrsIntrinsic<
  1017. [llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty],
  1018. [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
  1019. def int_smax : DefaultAttrsIntrinsic<
  1020. [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
  1021. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  1022. def int_smin : DefaultAttrsIntrinsic<
  1023. [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
  1024. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  1025. def int_umax : DefaultAttrsIntrinsic<
  1026. [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
  1027. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  1028. def int_umin : DefaultAttrsIntrinsic<
  1029. [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
  1030. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  1031. //===------------------------- Memory Use Markers -------------------------===//
  1032. //
  1033. def int_lifetime_start : DefaultAttrsIntrinsic<[],
  1034. [llvm_i64_ty, llvm_anyptr_ty],
  1035. [IntrArgMemOnly, IntrWillReturn,
  1036. NoCapture<ArgIndex<1>>,
  1037. ImmArg<ArgIndex<0>>]>;
  1038. def int_lifetime_end : DefaultAttrsIntrinsic<[],
  1039. [llvm_i64_ty, llvm_anyptr_ty],
  1040. [IntrArgMemOnly, IntrWillReturn,
  1041. NoCapture<ArgIndex<1>>,
  1042. ImmArg<ArgIndex<0>>]>;
  1043. def int_invariant_start : DefaultAttrsIntrinsic<[llvm_descriptor_ty],
  1044. [llvm_i64_ty, llvm_anyptr_ty],
  1045. [IntrArgMemOnly, IntrWillReturn,
  1046. NoCapture<ArgIndex<1>>,
  1047. ImmArg<ArgIndex<0>>]>;
  1048. def int_invariant_end : DefaultAttrsIntrinsic<[],
  1049. [llvm_descriptor_ty, llvm_i64_ty,
  1050. llvm_anyptr_ty],
  1051. [IntrArgMemOnly, IntrWillReturn,
  1052. NoCapture<ArgIndex<2>>,
  1053. ImmArg<ArgIndex<1>>]>;
  1054. // launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
  1055. // because it would cause CSE of two barriers with the same argument.
  1056. // Inaccessiblememonly says that the barrier doesn't read the argument,
  1057. // but it changes state not accessible to this module. This way
  1058. // we can DSE through the barrier because it doesn't read the value
  1059. // after store. Although the barrier doesn't modify any memory it
  1060. // can't be marked as readonly, because it would be possible to
  1061. // CSE 2 barriers with store in between.
  1062. // The argument also can't be marked with 'returned' attribute, because
  1063. // it would remove barrier.
  1064. // Note that it is still experimental, which means that its semantics
  1065. // might change in the future.
  1066. def int_launder_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
  1067. [LLVMMatchType<0>],
  1068. [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
  1069. def int_strip_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
  1070. [LLVMMatchType<0>],
  1071. [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
  1072. //===------------------------ Stackmap Intrinsics -------------------------===//
  1073. //
  1074. def int_experimental_stackmap : DefaultAttrsIntrinsic<[],
  1075. [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
  1076. [Throws]>;
  1077. def int_experimental_patchpoint_void : Intrinsic<[],
  1078. [llvm_i64_ty, llvm_i32_ty,
  1079. llvm_ptr_ty, llvm_i32_ty,
  1080. llvm_vararg_ty],
  1081. [Throws]>;
  1082. def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
  1083. [llvm_i64_ty, llvm_i32_ty,
  1084. llvm_ptr_ty, llvm_i32_ty,
  1085. llvm_vararg_ty],
  1086. [Throws]>;
  1087. //===------------------------ Garbage Collection Intrinsics ---------------===//
  1088. // These are documented in docs/Statepoint.rst
  1089. def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
  1090. [llvm_i64_ty, llvm_i32_ty,
  1091. llvm_anyptr_ty, llvm_i32_ty,
  1092. llvm_i32_ty, llvm_vararg_ty],
  1093. [Throws, ImmArg<ArgIndex<0>>,
  1094. ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<3>>,
  1095. ImmArg<ArgIndex<4>>]>;
  1096. def int_experimental_gc_result : DefaultAttrsIntrinsic<
  1097. [llvm_any_ty], [llvm_token_ty], [IntrNoMem]>;
  1098. def int_experimental_gc_relocate : DefaultAttrsIntrinsic<
  1099. [llvm_any_ty], [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
  1100. [IntrNoMem, ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
  1101. def int_experimental_gc_get_pointer_base : DefaultAttrsIntrinsic<
  1102. [llvm_anyptr_ty], [llvm_anyptr_ty],
  1103. [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
  1104. def int_experimental_gc_get_pointer_offset : DefaultAttrsIntrinsic<
  1105. [llvm_i64_ty], [llvm_anyptr_ty],
  1106. [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
  1107. //===------------------------ Coroutine Intrinsics ---------------===//
  1108. // These are documented in docs/Coroutines.rst
  1109. // Coroutine Structure Intrinsics.
  1110. def int_coro_id : DefaultAttrsIntrinsic<[llvm_token_ty],
  1111. [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
  1112. [IntrArgMemOnly, IntrReadMem, ReadNone<ArgIndex<1>>, ReadOnly<ArgIndex<2>>,
  1113. NoCapture<ArgIndex<2>>]>;
  1114. def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
  1115. [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
  1116. llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
  1117. []>;
  1118. def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
  1119. [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
  1120. llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
  1121. []>;
  1122. def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
  1123. def int_coro_id_async : Intrinsic<[llvm_token_ty],
  1124. [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty],
  1125. []>;
  1126. def int_coro_async_context_alloc : Intrinsic<[llvm_ptr_ty],
  1127. [llvm_ptr_ty, llvm_ptr_ty],
  1128. []>;
  1129. def int_coro_async_context_dealloc : Intrinsic<[],
  1130. [llvm_ptr_ty],
  1131. []>;
  1132. def int_coro_async_resume : Intrinsic<[llvm_ptr_ty],
  1133. [],
  1134. [IntrNoMerge]>;
  1135. def int_coro_async_size_replace : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>;
  1136. def int_coro_suspend_async
  1137. : Intrinsic<[llvm_any_ty],
  1138. [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty],
  1139. [IntrNoMerge]>;
  1140. def int_coro_prepare_async : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
  1141. [IntrNoMem]>;
  1142. def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
  1143. [WriteOnly<ArgIndex<1>>]>;
  1144. def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
  1145. [IntrReadMem, IntrArgMemOnly,
  1146. ReadOnly<ArgIndex<1>>,
  1147. NoCapture<ArgIndex<1>>]>;
  1148. def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
  1149. def int_coro_end_async
  1150. : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_vararg_ty], []>;
  1151. def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
  1152. def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
  1153. def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
  1154. def int_coro_align : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
  1155. def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], [IntrNoMerge]>;
  1156. def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
  1157. def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
  1158. def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
  1159. [IntrNoMem]>;
  1160. def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
  1161. [llvm_anyint_ty, llvm_i32_ty], []>;
  1162. def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
  1163. def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
  1164. // Coroutine Manipulation Intrinsics.
  1165. def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
  1166. def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
  1167. def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
  1168. [IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
  1169. NoCapture<ArgIndex<0>>]>;
  1170. def int_coro_promise : Intrinsic<[llvm_ptr_ty],
  1171. [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
  1172. [IntrNoMem, NoCapture<ArgIndex<0>>]>;
  1173. // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
  1174. def int_coro_subfn_addr : DefaultAttrsIntrinsic<
  1175. [llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
  1176. [IntrReadMem, IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
  1177. NoCapture<ArgIndex<0>>]>;
  1178. ///===-------------------------- Other Intrinsics --------------------------===//
  1179. //
  1180. def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
  1181. ClangBuiltin<"__builtin_trap">;
  1182. def int_debugtrap : Intrinsic<[]>,
  1183. ClangBuiltin<"__builtin_debugtrap">;
  1184. def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],
  1185. [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>;
  1186. // Support for dynamic deoptimization (or de-specialization)
  1187. def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
  1188. [Throws]>;
  1189. // Support for speculative runtime guards
  1190. def int_experimental_guard : DefaultAttrsIntrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
  1191. [Throws]>;
  1192. // Supports widenable conditions for guards represented as explicit branches.
  1193. def int_experimental_widenable_condition : DefaultAttrsIntrinsic<[llvm_i1_ty], [],
  1194. [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable]>;
  1195. // NOP: calls/invokes to this intrinsic are removed by codegen
  1196. def int_donothing : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
  1197. // This instruction has no actual effect, though it is treated by the optimizer
  1198. // has having opaque side effects. This may be inserted into loops to ensure
  1199. // that they are not removed even if they turn out to be empty, for languages
  1200. // which specify that infinite loops must be preserved.
  1201. def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
  1202. // The pseudoprobe intrinsic works as a place holder to the block it probes.
  1203. // Like the sideeffect intrinsic defined above, this intrinsic is treated by the
  1204. // optimizer as having opaque side effects so that it won't be get rid of or moved
  1205. // out of the block it probes.
  1206. def int_pseudoprobe : DefaultAttrsIntrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
  1207. [IntrInaccessibleMemOnly, IntrWillReturn]>;
  1208. // Intrinsics to support half precision floating point format
  1209. let IntrProperties = [IntrNoMem, IntrWillReturn] in {
  1210. def int_convert_to_fp16 : DefaultAttrsIntrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
  1211. def int_convert_from_fp16 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
  1212. }
  1213. // Saturating floating point to integer intrinsics
  1214. let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
  1215. def int_fptoui_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
  1216. def int_fptosi_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
  1217. }
  1218. // Clear cache intrinsic, default to ignore (ie. emit nothing)
  1219. // maps to void __clear_cache() on supporting platforms
  1220. def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
  1221. [], "llvm.clear_cache">;
  1222. // Intrinsic to detect whether its argument is a constant.
  1223. def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty],
  1224. [IntrNoMem, IntrWillReturn, IntrConvergent],
  1225. "llvm.is.constant">;
  1226. // Intrinsic to mask out bits of a pointer.
  1227. def int_ptrmask: DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>, llvm_anyint_ty],
  1228. [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  1229. // Intrinsic to wrap a thread local variable.
  1230. def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>],
  1231. [NonNull<RetIndex>, NonNull<ArgIndex<0>>,
  1232. IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
  1233. def int_experimental_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1234. [], [IntrNoMem]>;
  1235. //===---------------- Vector Predication Intrinsics --------------===//
  1236. // Memory Intrinsics
  1237. def int_vp_store : DefaultAttrsIntrinsic<[],
  1238. [ llvm_anyvector_ty,
  1239. LLVMAnyPointerType<LLVMMatchType<0>>,
  1240. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1241. llvm_i32_ty],
  1242. [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
  1243. def int_vp_load : DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
  1244. [ LLVMAnyPointerType<LLVMMatchType<0>>,
  1245. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1246. llvm_i32_ty],
  1247. [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
  1248. def int_vp_gather: DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
  1249. [ LLVMVectorOfAnyPointersToElt<0>,
  1250. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1251. llvm_i32_ty],
  1252. [ IntrReadMem, IntrNoSync, IntrWillReturn]>;
  1253. def int_vp_scatter: DefaultAttrsIntrinsic<[],
  1254. [ llvm_anyvector_ty,
  1255. LLVMVectorOfAnyPointersToElt<0>,
  1256. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1257. llvm_i32_ty],
  1258. [ IntrNoSync, IntrWillReturn ]>; // TODO allow IntrNoCapture for vectors of pointers
  1259. // Experimental strided memory accesses
  1260. def int_experimental_vp_strided_store : DefaultAttrsIntrinsic<[],
  1261. [ llvm_anyvector_ty,
  1262. LLVMAnyPointerToElt<0>,
  1263. llvm_anyint_ty, // Stride in bytes
  1264. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1265. llvm_i32_ty],
  1266. [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
  1267. def int_experimental_vp_strided_load : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1268. [ LLVMAnyPointerToElt<0>,
  1269. llvm_anyint_ty, // Stride in bytes
  1270. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1271. llvm_i32_ty],
  1272. [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
  1273. // Operators
  1274. let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn] in {
  1275. // Integer arithmetic
  1276. def int_vp_add : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1277. [ LLVMMatchType<0>,
  1278. LLVMMatchType<0>,
  1279. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1280. llvm_i32_ty]>;
  1281. def int_vp_sub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1282. [ LLVMMatchType<0>,
  1283. LLVMMatchType<0>,
  1284. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1285. llvm_i32_ty]>;
  1286. def int_vp_mul : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1287. [ LLVMMatchType<0>,
  1288. LLVMMatchType<0>,
  1289. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1290. llvm_i32_ty]>;
  1291. def int_vp_ashr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1292. [ LLVMMatchType<0>,
  1293. LLVMMatchType<0>,
  1294. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1295. llvm_i32_ty]>;
  1296. def int_vp_lshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1297. [ LLVMMatchType<0>,
  1298. LLVMMatchType<0>,
  1299. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1300. llvm_i32_ty]>;
  1301. def int_vp_shl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1302. [ LLVMMatchType<0>,
  1303. LLVMMatchType<0>,
  1304. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1305. llvm_i32_ty]>;
  1306. def int_vp_or : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1307. [ LLVMMatchType<0>,
  1308. LLVMMatchType<0>,
  1309. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1310. llvm_i32_ty]>;
  1311. def int_vp_and : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1312. [ LLVMMatchType<0>,
  1313. LLVMMatchType<0>,
  1314. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1315. llvm_i32_ty]>;
  1316. def int_vp_xor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1317. [ LLVMMatchType<0>,
  1318. LLVMMatchType<0>,
  1319. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1320. llvm_i32_ty]>;
  1321. def int_vp_sdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1322. [ LLVMMatchType<0>,
  1323. LLVMMatchType<0>,
  1324. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1325. llvm_i32_ty]>;
  1326. def int_vp_udiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1327. [ LLVMMatchType<0>,
  1328. LLVMMatchType<0>,
  1329. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1330. llvm_i32_ty]>;
  1331. def int_vp_srem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1332. [ LLVMMatchType<0>,
  1333. LLVMMatchType<0>,
  1334. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1335. llvm_i32_ty]>;
  1336. def int_vp_urem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1337. [ LLVMMatchType<0>,
  1338. LLVMMatchType<0>,
  1339. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1340. llvm_i32_ty]>;
  1341. def int_vp_abs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1342. [ LLVMMatchType<0>,
  1343. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1344. llvm_i32_ty,
  1345. llvm_i1_ty]>;
  1346. def int_vp_smin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1347. [ LLVMMatchType<0>,
  1348. LLVMMatchType<0>,
  1349. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1350. llvm_i32_ty]>;
  1351. def int_vp_smax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1352. [ LLVMMatchType<0>,
  1353. LLVMMatchType<0>,
  1354. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1355. llvm_i32_ty]>;
  1356. def int_vp_umin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1357. [ LLVMMatchType<0>,
  1358. LLVMMatchType<0>,
  1359. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1360. llvm_i32_ty]>;
  1361. def int_vp_umax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1362. [ LLVMMatchType<0>,
  1363. LLVMMatchType<0>,
  1364. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1365. llvm_i32_ty]>;
  1366. def int_vp_bswap : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1367. [ LLVMMatchType<0>,
  1368. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1369. llvm_i32_ty]>;
  1370. def int_vp_bitreverse : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1371. [ LLVMMatchType<0>,
  1372. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1373. llvm_i32_ty]>;
  1374. def int_vp_ctpop : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1375. [ LLVMMatchType<0>,
  1376. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1377. llvm_i32_ty]>;
  1378. def int_vp_fshl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1379. [ LLVMMatchType<0>,
  1380. LLVMMatchType<0>,
  1381. LLVMMatchType<0>,
  1382. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1383. llvm_i32_ty]>;
  1384. def int_vp_fshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1385. [ LLVMMatchType<0>,
  1386. LLVMMatchType<0>,
  1387. LLVMMatchType<0>,
  1388. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1389. llvm_i32_ty]>;
  1390. // Floating-point arithmetic
  1391. def int_vp_fadd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1392. [ LLVMMatchType<0>,
  1393. LLVMMatchType<0>,
  1394. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1395. llvm_i32_ty]>;
  1396. def int_vp_fsub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1397. [ LLVMMatchType<0>,
  1398. LLVMMatchType<0>,
  1399. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1400. llvm_i32_ty]>;
  1401. def int_vp_fmul : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1402. [ LLVMMatchType<0>,
  1403. LLVMMatchType<0>,
  1404. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1405. llvm_i32_ty]>;
  1406. def int_vp_fdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1407. [ LLVMMatchType<0>,
  1408. LLVMMatchType<0>,
  1409. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1410. llvm_i32_ty]>;
  1411. def int_vp_frem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1412. [ LLVMMatchType<0>,
  1413. LLVMMatchType<0>,
  1414. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1415. llvm_i32_ty]>;
  1416. def int_vp_fneg : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1417. [ LLVMMatchType<0>,
  1418. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1419. llvm_i32_ty]>;
  1420. def int_vp_fabs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1421. [ LLVMMatchType<0>,
  1422. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1423. llvm_i32_ty]>;
  1424. def int_vp_sqrt : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1425. [ LLVMMatchType<0>,
  1426. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1427. llvm_i32_ty]>;
  1428. def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1429. [ LLVMMatchType<0>,
  1430. LLVMMatchType<0>,
  1431. LLVMMatchType<0>,
  1432. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1433. llvm_i32_ty]>;
  1434. def int_vp_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1435. [ LLVMMatchType<0>,
  1436. LLVMMatchType<0>,
  1437. LLVMMatchType<0>,
  1438. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1439. llvm_i32_ty]>;
  1440. def int_vp_minnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1441. [ LLVMMatchType<0>,
  1442. LLVMMatchType<0>,
  1443. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1444. llvm_i32_ty]>;
  1445. def int_vp_maxnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1446. [ LLVMMatchType<0>,
  1447. LLVMMatchType<0>,
  1448. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1449. llvm_i32_ty]>;
  1450. def int_vp_copysign : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1451. [ LLVMMatchType<0>,
  1452. LLVMMatchType<0>,
  1453. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1454. llvm_i32_ty]>;
  1455. def int_vp_ceil : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1456. [ LLVMMatchType<0>,
  1457. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1458. llvm_i32_ty]>;
  1459. def int_vp_floor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1460. [ LLVMMatchType<0>,
  1461. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1462. llvm_i32_ty]>;
  1463. def int_vp_round : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1464. [ LLVMMatchType<0>,
  1465. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1466. llvm_i32_ty]>;
  1467. def int_vp_roundeven : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1468. [ LLVMMatchType<0>,
  1469. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1470. llvm_i32_ty]>;
  1471. def int_vp_roundtozero : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1472. [ LLVMMatchType<0>,
  1473. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1474. llvm_i32_ty]>;
  1475. def int_vp_rint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1476. [ LLVMMatchType<0>,
  1477. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1478. llvm_i32_ty]>;
  1479. def int_vp_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1480. [ LLVMMatchType<0>,
  1481. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1482. llvm_i32_ty]>;
  1483. // Casts
  1484. def int_vp_trunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1485. [ llvm_anyvector_ty,
  1486. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1487. llvm_i32_ty]>;
  1488. def int_vp_zext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1489. [ llvm_anyvector_ty,
  1490. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1491. llvm_i32_ty]>;
  1492. def int_vp_sext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1493. [ llvm_anyvector_ty,
  1494. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1495. llvm_i32_ty]>;
  1496. def int_vp_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1497. [ llvm_anyvector_ty,
  1498. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1499. llvm_i32_ty]>;
  1500. def int_vp_fpext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1501. [ llvm_anyvector_ty,
  1502. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1503. llvm_i32_ty]>;
  1504. def int_vp_fptoui : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1505. [ llvm_anyvector_ty,
  1506. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1507. llvm_i32_ty]>;
  1508. def int_vp_fptosi : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1509. [ llvm_anyvector_ty,
  1510. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1511. llvm_i32_ty]>;
  1512. def int_vp_uitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1513. [ llvm_anyvector_ty,
  1514. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1515. llvm_i32_ty]>;
  1516. def int_vp_sitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1517. [ llvm_anyvector_ty,
  1518. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1519. llvm_i32_ty]>;
  1520. def int_vp_ptrtoint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1521. [ llvm_anyvector_ty,
  1522. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1523. llvm_i32_ty]>;
  1524. def int_vp_inttoptr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1525. [ llvm_anyvector_ty,
  1526. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1527. llvm_i32_ty]>;
  1528. // Shuffles
  1529. def int_vp_select : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1530. [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1531. LLVMMatchType<0>,
  1532. LLVMMatchType<0>,
  1533. llvm_i32_ty]>;
  1534. def int_vp_merge : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1535. [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1536. LLVMMatchType<0>,
  1537. LLVMMatchType<0>,
  1538. llvm_i32_ty]>;
  1539. // Comparisons
  1540. def int_vp_fcmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
  1541. [ llvm_anyvector_ty,
  1542. LLVMMatchType<0>,
  1543. llvm_metadata_ty,
  1544. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1545. llvm_i32_ty]>;
  1546. def int_vp_icmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
  1547. [ llvm_anyvector_ty,
  1548. LLVMMatchType<0>,
  1549. llvm_metadata_ty,
  1550. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1551. llvm_i32_ty]>;
  1552. // Reductions
  1553. def int_vp_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1554. [ LLVMVectorElementType<0>,
  1555. llvm_anyvector_ty,
  1556. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1557. llvm_i32_ty]>;
  1558. def int_vp_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1559. [ LLVMVectorElementType<0>,
  1560. llvm_anyvector_ty,
  1561. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1562. llvm_i32_ty]>;
  1563. def int_vp_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1564. [ LLVMVectorElementType<0>,
  1565. llvm_anyvector_ty,
  1566. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1567. llvm_i32_ty]>;
  1568. def int_vp_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1569. [ LLVMVectorElementType<0>,
  1570. llvm_anyvector_ty,
  1571. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1572. llvm_i32_ty]>;
  1573. def int_vp_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1574. [ LLVMVectorElementType<0>,
  1575. llvm_anyvector_ty,
  1576. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1577. llvm_i32_ty]>;
  1578. def int_vp_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1579. [ LLVMVectorElementType<0>,
  1580. llvm_anyvector_ty,
  1581. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1582. llvm_i32_ty]>;
  1583. def int_vp_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1584. [ LLVMVectorElementType<0>,
  1585. llvm_anyvector_ty,
  1586. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1587. llvm_i32_ty]>;
  1588. def int_vp_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1589. [ LLVMVectorElementType<0>,
  1590. llvm_anyvector_ty,
  1591. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1592. llvm_i32_ty]>;
  1593. def int_vp_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1594. [ LLVMVectorElementType<0>,
  1595. llvm_anyvector_ty,
  1596. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1597. llvm_i32_ty]>;
  1598. def int_vp_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1599. [ LLVMVectorElementType<0>,
  1600. llvm_anyvector_ty,
  1601. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1602. llvm_i32_ty]>;
  1603. def int_vp_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1604. [ LLVMVectorElementType<0>,
  1605. llvm_anyvector_ty,
  1606. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1607. llvm_i32_ty]>;
  1608. def int_vp_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1609. [ LLVMVectorElementType<0>,
  1610. llvm_anyvector_ty,
  1611. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1612. llvm_i32_ty]>;
  1613. def int_vp_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1614. [ LLVMVectorElementType<0>,
  1615. llvm_anyvector_ty,
  1616. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1617. llvm_i32_ty]>;
  1618. }
  1619. let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<3>>] in {
  1620. def int_vp_ctlz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1621. [ LLVMMatchType<0>,
  1622. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1623. llvm_i32_ty,
  1624. llvm_i1_ty]>;
  1625. def int_vp_cttz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
  1626. [ LLVMMatchType<0>,
  1627. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1628. llvm_i32_ty,
  1629. llvm_i1_ty]>;
  1630. }
  1631. def int_get_active_lane_mask:
  1632. DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1633. [llvm_anyint_ty, LLVMMatchType<1>],
  1634. [IntrNoMem, IntrNoSync, IntrWillReturn]>;
  1635. def int_experimental_vp_splice:
  1636. DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1637. [LLVMMatchType<0>,
  1638. LLVMMatchType<0>,
  1639. llvm_i32_ty,
  1640. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1641. llvm_i32_ty, llvm_i32_ty],
  1642. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  1643. //===-------------------------- Masked Intrinsics -------------------------===//
  1644. //
  1645. def int_masked_load:
  1646. DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1647. [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
  1648. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
  1649. [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<ArgIndex<1>>,
  1650. NoCapture<ArgIndex<0>>]>;
  1651. def int_masked_store:
  1652. DefaultAttrsIntrinsic<[],
  1653. [llvm_anyvector_ty, LLVMAnyPointerType<LLVMMatchType<0>>,
  1654. llvm_i32_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  1655. [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
  1656. ImmArg<ArgIndex<2>>, NoCapture<ArgIndex<1>>]>;
  1657. def int_masked_gather:
  1658. DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1659. [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
  1660. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
  1661. [IntrReadMem, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
  1662. def int_masked_scatter:
  1663. DefaultAttrsIntrinsic<[],
  1664. [llvm_anyvector_ty, LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
  1665. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  1666. [IntrWriteMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
  1667. def int_masked_expandload:
  1668. DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1669. [LLVMPointerToElt<0>, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
  1670. LLVMMatchType<0>],
  1671. [IntrReadMem, IntrWillReturn, NoCapture<ArgIndex<0>>]>;
  1672. def int_masked_compressstore:
  1673. DefaultAttrsIntrinsic<[],
  1674. [llvm_anyvector_ty, LLVMPointerToElt<0>,
  1675. LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
  1676. [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
  1677. NoCapture<ArgIndex<1>>]>;
  1678. // Test whether a pointer is associated with a type metadata identifier.
  1679. def int_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
  1680. [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
  1681. // Safely loads a function pointer from a virtual table pointer using type metadata.
  1682. def int_type_checked_load : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty],
  1683. [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
  1684. [IntrNoMem, IntrWillReturn]>;
  1685. // Test whether a pointer is associated with a type metadata identifier. Used
  1686. // for public visibility classes that may later be refined to private
  1687. // visibility.
  1688. def int_public_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
  1689. [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
  1690. // Create a branch funnel that implements an indirect call to a limited set of
  1691. // callees. This needs to be a musttail call.
  1692. def int_icall_branch_funnel : DefaultAttrsIntrinsic<[], [llvm_vararg_ty], []>;
  1693. def int_load_relative: DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
  1694. [IntrReadMem, IntrArgMemOnly]>;
  1695. def int_asan_check_memaccess :
  1696. Intrinsic<[],[llvm_ptr_ty, llvm_i32_ty], [ImmArg<ArgIndex<1>>]>;
  1697. def int_hwasan_check_memaccess :
  1698. Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
  1699. [ImmArg<ArgIndex<2>>]>;
  1700. def int_hwasan_check_memaccess_shortgranules :
  1701. Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
  1702. [ImmArg<ArgIndex<2>>]>;
  1703. // Xray intrinsics
  1704. //===----------------------------------------------------------------------===//
  1705. // Custom event logging for x-ray.
  1706. // Takes a pointer to a string and the length of the string.
  1707. def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
  1708. [IntrWriteMem, NoCapture<ArgIndex<0>>,
  1709. ReadOnly<ArgIndex<0>>]>;
  1710. // Typed event logging for x-ray.
  1711. // Takes a numeric type tag, a pointer to a string and the length of the string.
  1712. def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
  1713. [IntrWriteMem, NoCapture<ArgIndex<1>>,
  1714. ReadOnly<ArgIndex<1>>]>;
  1715. //===----------------------------------------------------------------------===//
  1716. //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
  1717. //
  1718. // @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
  1719. def int_memcpy_element_unordered_atomic
  1720. : Intrinsic<[],
  1721. [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
  1722. [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
  1723. NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
  1724. WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
  1725. ImmArg<ArgIndex<3>>]>;
  1726. // @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
  1727. def int_memmove_element_unordered_atomic
  1728. : Intrinsic<[],
  1729. [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
  1730. [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
  1731. NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
  1732. WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
  1733. ImmArg<ArgIndex<3>>]>;
  1734. // @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
  1735. def int_memset_element_unordered_atomic
  1736. : Intrinsic<[], [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty],
  1737. [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoSync,
  1738. NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
  1739. ImmArg<ArgIndex<3>>]>;
  1740. //===------------------------ Reduction Intrinsics ------------------------===//
  1741. //
  1742. let IntrProperties = [IntrNoMem] in {
  1743. def int_vector_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1744. [LLVMVectorElementType<0>,
  1745. llvm_anyvector_ty]>;
  1746. def int_vector_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1747. [LLVMVectorElementType<0>,
  1748. llvm_anyvector_ty]>;
  1749. def int_vector_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1750. [llvm_anyvector_ty]>;
  1751. def int_vector_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1752. [llvm_anyvector_ty]>;
  1753. def int_vector_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1754. [llvm_anyvector_ty]>;
  1755. def int_vector_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1756. [llvm_anyvector_ty]>;
  1757. def int_vector_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1758. [llvm_anyvector_ty]>;
  1759. def int_vector_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1760. [llvm_anyvector_ty]>;
  1761. def int_vector_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1762. [llvm_anyvector_ty]>;
  1763. def int_vector_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1764. [llvm_anyvector_ty]>;
  1765. def int_vector_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1766. [llvm_anyvector_ty]>;
  1767. def int_vector_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1768. [llvm_anyvector_ty]>;
  1769. def int_vector_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
  1770. [llvm_anyvector_ty]>;
  1771. }
  1772. //===----- Matrix intrinsics ---------------------------------------------===//
  1773. def int_matrix_transpose
  1774. : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1775. [LLVMMatchType<0>, llvm_i32_ty, llvm_i32_ty],
  1776. [ IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>,
  1777. ImmArg<ArgIndex<2>>]>;
  1778. def int_matrix_multiply
  1779. : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1780. [llvm_anyvector_ty, llvm_anyvector_ty, llvm_i32_ty, llvm_i32_ty,
  1781. llvm_i32_ty],
  1782. [IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>,
  1783. ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>]>;
  1784. def int_matrix_column_major_load
  1785. : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1786. [LLVMPointerToElt<0>, llvm_anyint_ty, llvm_i1_ty,
  1787. llvm_i32_ty, llvm_i32_ty],
  1788. [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrReadMem,
  1789. NoCapture<ArgIndex<0>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>,
  1790. ImmArg<ArgIndex<4>>]>;
  1791. def int_matrix_column_major_store
  1792. : DefaultAttrsIntrinsic<[],
  1793. [llvm_anyvector_ty, LLVMPointerToElt<0>,
  1794. llvm_anyint_ty, llvm_i1_ty, llvm_i32_ty, llvm_i32_ty],
  1795. [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrWriteMem,
  1796. WriteOnly<ArgIndex<1>>, NoCapture<ArgIndex<1>>,
  1797. ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>, ImmArg<ArgIndex<5>>]>;
  1798. //===---------- Intrinsics to control hardware supported loops ----------===//
  1799. // Specify that the value given is the number of iterations that the next loop
  1800. // will execute.
  1801. def int_set_loop_iterations :
  1802. DefaultAttrsIntrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
  1803. // Same as the above, but produces a value (the same as the input operand) to
  1804. // be fed into the loop.
  1805. def int_start_loop_iterations :
  1806. DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], [IntrNoDuplicate]>;
  1807. // Specify that the value given is the number of iterations that the next loop
  1808. // will execute. Also test that the given count is not zero, allowing it to
  1809. // control entry to a 'while' loop.
  1810. def int_test_set_loop_iterations :
  1811. DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
  1812. // Same as the above, but produces an extra value (the same as the input
  1813. // operand) to be fed into the loop.
  1814. def int_test_start_loop_iterations :
  1815. DefaultAttrsIntrinsic<[llvm_anyint_ty, llvm_i1_ty], [LLVMMatchType<0>],
  1816. [IntrNoDuplicate]>;
  1817. // Decrement loop counter by the given argument. Return false if the loop
  1818. // should exit.
  1819. def int_loop_decrement :
  1820. DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
  1821. // Decrement the first operand (the loop counter) by the second operand (the
  1822. // maximum number of elements processed in an iteration). Return the remaining
  1823. // number of iterations still to be executed. This is effectively a sub which
  1824. // can be used with a phi, icmp and br to control the number of iterations
  1825. // executed, as usual. Any optimisations are allowed to treat it is a sub, and
  1826. // it's scevable, so it's the backends responsibility to handle cases where it
  1827. // may be optimised.
  1828. def int_loop_decrement_reg :
  1829. DefaultAttrsIntrinsic<[llvm_anyint_ty],
  1830. [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoDuplicate]>;
  1831. //===----- Intrinsics that are used to provide predicate information -----===//
  1832. def int_ssa_copy : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>],
  1833. [IntrNoMem, Returned<ArgIndex<0>>]>;
  1834. //===------- Intrinsics that are used to preserve debug information -------===//
  1835. def int_preserve_array_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
  1836. [llvm_anyptr_ty, llvm_i32_ty,
  1837. llvm_i32_ty],
  1838. [IntrNoMem,
  1839. ImmArg<ArgIndex<1>>,
  1840. ImmArg<ArgIndex<2>>]>;
  1841. def int_preserve_union_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
  1842. [llvm_anyptr_ty, llvm_i32_ty],
  1843. [IntrNoMem,
  1844. ImmArg<ArgIndex<1>>]>;
  1845. def int_preserve_struct_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
  1846. [llvm_anyptr_ty, llvm_i32_ty,
  1847. llvm_i32_ty],
  1848. [IntrNoMem,
  1849. ImmArg<ArgIndex<1>>,
  1850. ImmArg<ArgIndex<2>>]>;
  1851. //===------------ Intrinsics to perform common vector shuffles ------------===//
  1852. def int_experimental_vector_reverse : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1853. [LLVMMatchType<0>],
  1854. [IntrNoMem]>;
  1855. def int_experimental_vector_splice : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1856. [LLVMMatchType<0>,
  1857. LLVMMatchType<0>,
  1858. llvm_i32_ty],
  1859. [IntrNoMem, ImmArg<ArgIndex<2>>]>;
  1860. //===---------- Intrinsics to query properties of scalable vectors --------===//
  1861. def int_vscale : DefaultAttrsIntrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
  1862. //===---------- Intrinsics to perform subvector insertion/extraction ------===//
  1863. def int_vector_insert : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1864. [LLVMMatchType<0>, llvm_anyvector_ty, llvm_i64_ty],
  1865. [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>]>;
  1866. def int_vector_extract : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
  1867. [llvm_anyvector_ty, llvm_i64_ty],
  1868. [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
  1869. //===----------------- Pointer Authentication Intrinsics ------------------===//
  1870. //
  1871. // Sign an unauthenticated pointer using the specified key and discriminator,
  1872. // passed in that order.
  1873. // Returns the first argument, with some known bits replaced with a signature.
  1874. def int_ptrauth_sign :
  1875. DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
  1876. [IntrNoMem, ImmArg<ArgIndex<1>>]>;
  1877. // Authenticate a signed pointer, using the specified key and discriminator.
  1878. // Returns the first argument, with the signature bits removed.
  1879. // The signature must be valid.
  1880. def int_ptrauth_auth : Intrinsic<[llvm_i64_ty],
  1881. [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
  1882. [IntrNoMem,ImmArg<ArgIndex<1>>]>;
  1883. // Authenticate a signed pointer and resign it.
  1884. // The second (key) and third (discriminator) arguments specify the signing
  1885. // schema used for authenticating.
  1886. // The fourth and fifth arguments specify the schema used for signing.
  1887. // The signature must be valid.
  1888. // This is a combined form of @llvm.ptrauth.sign and @llvm.ptrauth.auth, with
  1889. // an additional integrity guarantee on the intermediate value.
  1890. def int_ptrauth_resign : Intrinsic<[llvm_i64_ty],
  1891. [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty,
  1892. llvm_i32_ty, llvm_i64_ty],
  1893. [IntrNoMem, ImmArg<ArgIndex<1>>,
  1894. ImmArg<ArgIndex<3>>]>;
  1895. // Strip the embedded signature out of a signed pointer.
  1896. // The second argument specifies the key.
  1897. // This behaves like @llvm.ptrauth.auth, but doesn't require the signature to
  1898. // be valid.
  1899. def int_ptrauth_strip :
  1900. DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty],
  1901. [IntrNoMem, ImmArg<ArgIndex<1>>]>;
  1902. // Blend a small integer discriminator with an address discriminator, producing
  1903. // a new discriminator value.
  1904. def int_ptrauth_blend :
  1905. DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
  1906. // Compute the signature of a value, using a given discriminator.
  1907. // This differs from @llvm.ptrauth.sign in that it doesn't embed the computed
  1908. // signature in the pointer, but instead returns the signature as a value.
  1909. // That allows it to be used to sign non-pointer data: in that sense, it is
  1910. // generic. There is no generic @llvm.ptrauth.auth: instead, the signature
  1911. // can be computed using @llvm.ptrauth.sign_generic, and compared with icmp.
  1912. def int_ptrauth_sign_generic :
  1913. DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
  1914. //===----------------------------------------------------------------------===//
  1915. //===----------------------------------------------------------------------===//
  1916. // Target-specific intrinsics
  1917. //===----------------------------------------------------------------------===//
  1918. include "llvm/IR/IntrinsicsPowerPC.td"
  1919. include "llvm/IR/IntrinsicsX86.td"
  1920. include "llvm/IR/IntrinsicsARM.td"
  1921. include "llvm/IR/IntrinsicsAArch64.td"
  1922. include "llvm/IR/IntrinsicsXCore.td"
  1923. include "llvm/IR/IntrinsicsHexagon.td"
  1924. include "llvm/IR/IntrinsicsNVVM.td"
  1925. include "llvm/IR/IntrinsicsMips.td"
  1926. include "llvm/IR/IntrinsicsAMDGPU.td"
  1927. include "llvm/IR/IntrinsicsBPF.td"
  1928. include "llvm/IR/IntrinsicsSystemZ.td"
  1929. include "llvm/IR/IntrinsicsWebAssembly.td"
  1930. include "llvm/IR/IntrinsicsRISCV.td"
  1931. include "llvm/IR/IntrinsicsSPIRV.td"
  1932. include "llvm/IR/IntrinsicsVE.td"
  1933. include "llvm/IR/IntrinsicsDirectX.td"
  1934. include "llvm/IR/IntrinsicsLoongArch.td"