Intrinsics.td 100 KB

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