Intrinsics.td 88 KB

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