Intrinsics.td 86 KB

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