[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / include / llvm / IR / Intrinsics.td
blob1a67f830435ff5c530cab30fc65f225786c35021
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.
11 //===----------------------------------------------------------------------===//
13 include "llvm/CodeGen/ValueTypes.td"
14 include "llvm/CodeGen/SDNodeProperties.td"
16 //===----------------------------------------------------------------------===//
17 //  Properties we keep track of for intrinsics.
18 //===----------------------------------------------------------------------===//
20 class IntrinsicProperty;
22 // Intr*Mem - Memory properties.  If no property is set, the worst case
23 // is assumed (it may read and write any memory it can get access to and it may
24 // have other side effects).
26 // IntrNoMem - The intrinsic does not access memory or have any other side
27 // effects.  It may be CSE'd deleted if dead, etc.
28 def IntrNoMem : IntrinsicProperty;
30 // IntrReadMem - This intrinsic only reads from memory. It does not write to
31 // memory and has no other side effects. Therefore, it cannot be moved across
32 // potentially aliasing stores. However, it can be reordered otherwise and can
33 // be deleted if dead.
34 def IntrReadMem : IntrinsicProperty;
36 // IntrWriteMem - This intrinsic only writes to memory, but does not read from
37 // memory, and has no other side effects. This means dead stores before calls
38 // to this intrinsics may be removed.
39 def IntrWriteMem : IntrinsicProperty;
41 // IntrArgMemOnly - This intrinsic only accesses memory that its pointer-typed
42 // argument(s) points to, but may access an unspecified amount. Other than
43 // reads from and (possibly volatile) writes to memory, it has no side effects.
44 def IntrArgMemOnly : IntrinsicProperty;
46 // IntrInaccessibleMemOnly -- This intrinsic only accesses memory that is not
47 // accessible by the module being compiled. This is a weaker form of IntrNoMem.
48 def IntrInaccessibleMemOnly : IntrinsicProperty;
50 // IntrInaccessibleMemOrArgMemOnly -- This intrinsic only accesses memory that
51 // its pointer-typed arguments point to or memory that is not accessible
52 // by the module being compiled. This is a weaker form of IntrArgMemOnly.
53 def IntrInaccessibleMemOrArgMemOnly : IntrinsicProperty;
55 // Commutative - This intrinsic is commutative: X op Y == Y op X.
56 def Commutative : IntrinsicProperty;
58 // Throws - This intrinsic can throw.
59 def Throws : IntrinsicProperty;
61 // NoCapture - The specified argument pointer is not captured by the intrinsic.
62 class NoCapture<int argNo> : IntrinsicProperty {
63   int ArgNo = argNo;
66 // NoAlias - The specified argument pointer is not aliasing other "noalias" pointer
67 // arguments of the intrinsic wrt. the intrinsic scope.
68 class NoAlias<int argNo> : IntrinsicProperty {
69   int ArgNo = argNo;
72 // Returned - The specified argument is always the return value of the
73 // intrinsic.
74 class Returned<int argNo> : IntrinsicProperty {
75   int ArgNo = argNo;
78 // ImmArg - The specified argument must be an immediate.
79 class ImmArg<int argNo> : IntrinsicProperty {
80   int ArgNo = argNo;
83 // ReadOnly - The specified argument pointer is not written to through the
84 // pointer by the intrinsic.
85 class ReadOnly<int argNo> : IntrinsicProperty {
86   int ArgNo = argNo;
89 // WriteOnly - The intrinsic does not read memory through the specified
90 // argument pointer.
91 class WriteOnly<int argNo> : IntrinsicProperty {
92   int ArgNo = argNo;
95 // ReadNone - The specified argument pointer is not dereferenced by the
96 // intrinsic.
97 class ReadNone<int argNo> : IntrinsicProperty {
98   int ArgNo = argNo;
101 def IntrNoReturn : IntrinsicProperty;
103 def IntrWillReturn : IntrinsicProperty;
105 // IntrCold - Calls to this intrinsic are cold.
106 // Parallels the cold attribute on LLVM IR functions.
107 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;
113 // IntrConvergent - Calls to this intrinsic are convergent and may not be made
114 // control-dependent on any additional values.
115 // Parallels the convergent attribute on LLVM IR functions.
116 def IntrConvergent : IntrinsicProperty;
118 // This property indicates that the intrinsic is safe to speculate.
119 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;
130 //===----------------------------------------------------------------------===//
131 // Types used by intrinsics.
132 //===----------------------------------------------------------------------===//
134 class LLVMType<ValueType vt> {
135   ValueType VT = vt;
136   int isAny = 0;
139 class LLVMQualPointerType<LLVMType elty, int addrspace>
140   : LLVMType<iPTR>{
141   LLVMType ElTy = elty;
142   int AddrSpace = addrspace;
145 class LLVMPointerType<LLVMType elty>
146   : LLVMQualPointerType<elty, 0>;
148 class LLVMAnyPointerType<LLVMType elty>
149   : LLVMType<iPTRAny>{
150   LLVMType ElTy = elty;
152   let isAny = 1;
155 // Match the type of another intrinsic parameter.  Number is an index into the
156 // list of overloaded types for the intrinsic, excluding all the fixed types.
157 // The Number value must refer to a previously listed type.  For example:
158 //   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
159 // has two overloaded types, the 2nd and 3rd arguments.  LLVMMatchType<0>
160 // refers to the first overloaded type, which is the 2nd argument.
161 class LLVMMatchType<int num>
162   : LLVMType<OtherVT>{
163   int Number = num;
166 // Match the type of another intrinsic parameter that is expected to be based on
167 // an integral type (i.e. either iN or <N x iM>), but change the scalar size to
168 // be twice as wide or half as wide as the other type.  This is only useful when
169 // the intrinsic is overloaded, so the matched type should be declared as iAny.
170 class LLVMExtendedType<int num> : LLVMMatchType<num>;
171 class LLVMTruncatedType<int num> : LLVMMatchType<num>;
173 // Match the scalar/vector of another intrinsic parameter but with a different
174 // element type. Either both are scalars or both are vectors with the same
175 // number of elements.
176 class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
177   : LLVMMatchType<idx> {
178   ValueType ElTy = elty.VT;
181 class LLVMPointerTo<int num> : LLVMMatchType<num>;
182 class LLVMPointerToElt<int num> : LLVMMatchType<num>;
183 class LLVMVectorOfAnyPointersToElt<int num> : LLVMMatchType<num>;
184 class LLVMVectorElementType<int num> : LLVMMatchType<num>;
186 // Match the type of another intrinsic parameter that is expected to be a
187 // vector type, but change the element count to be half as many
188 class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
190 def llvm_void_ty       : LLVMType<isVoid>;
191 let isAny = 1 in {
192   def llvm_any_ty        : LLVMType<Any>;
193   def llvm_anyint_ty     : LLVMType<iAny>;
194   def llvm_anyfloat_ty   : LLVMType<fAny>;
195   def llvm_anyvector_ty  : LLVMType<vAny>;
197 def llvm_i1_ty         : LLVMType<i1>;
198 def llvm_i8_ty         : LLVMType<i8>;
199 def llvm_i16_ty        : LLVMType<i16>;
200 def llvm_i32_ty        : LLVMType<i32>;
201 def llvm_i64_ty        : LLVMType<i64>;
202 def llvm_half_ty       : LLVMType<f16>;
203 def llvm_float_ty      : LLVMType<f32>;
204 def llvm_double_ty     : LLVMType<f64>;
205 def llvm_f80_ty        : LLVMType<f80>;
206 def llvm_f128_ty       : LLVMType<f128>;
207 def llvm_ppcf128_ty    : LLVMType<ppcf128>;
208 def llvm_ptr_ty        : LLVMPointerType<llvm_i8_ty>;             // i8*
209 def llvm_ptrptr_ty     : LLVMPointerType<llvm_ptr_ty>;            // i8**
210 def llvm_anyptr_ty     : LLVMAnyPointerType<llvm_i8_ty>;          // (space)i8*
211 def llvm_empty_ty      : LLVMType<OtherVT>;                       // { }
212 def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>;          // { }*
213 def llvm_metadata_ty   : LLVMType<MetadataVT>;                    // !{...}
214 def llvm_token_ty      : LLVMType<token>;                         // token
216 def llvm_x86mmx_ty     : LLVMType<x86mmx>;
217 def llvm_ptrx86mmx_ty  : LLVMPointerType<llvm_x86mmx_ty>;         // <1 x i64>*
219 def llvm_v2i1_ty       : LLVMType<v2i1>;     //   2 x i1
220 def llvm_v4i1_ty       : LLVMType<v4i1>;     //   4 x i1
221 def llvm_v8i1_ty       : LLVMType<v8i1>;     //   8 x i1
222 def llvm_v16i1_ty      : LLVMType<v16i1>;    //  16 x i1
223 def llvm_v32i1_ty      : LLVMType<v32i1>;    //  32 x i1
224 def llvm_v64i1_ty      : LLVMType<v64i1>;    //  64 x i1
225 def llvm_v512i1_ty     : LLVMType<v512i1>;   // 512 x i1
226 def llvm_v1024i1_ty    : LLVMType<v1024i1>;  //1024 x i1
228 def llvm_v1i8_ty       : LLVMType<v1i8>;     //  1 x i8
229 def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8
230 def llvm_v4i8_ty       : LLVMType<v4i8>;     //  4 x i8
231 def llvm_v8i8_ty       : LLVMType<v8i8>;     //  8 x i8
232 def llvm_v16i8_ty      : LLVMType<v16i8>;    // 16 x i8
233 def llvm_v32i8_ty      : LLVMType<v32i8>;    // 32 x i8
234 def llvm_v64i8_ty      : LLVMType<v64i8>;    // 64 x i8
235 def llvm_v128i8_ty     : LLVMType<v128i8>;   //128 x i8
236 def llvm_v256i8_ty     : LLVMType<v256i8>;   //256 x i8
238 def llvm_v1i16_ty      : LLVMType<v1i16>;    //  1 x i16
239 def llvm_v2i16_ty      : LLVMType<v2i16>;    //  2 x i16
240 def llvm_v4i16_ty      : LLVMType<v4i16>;    //  4 x i16
241 def llvm_v8i16_ty      : LLVMType<v8i16>;    //  8 x i16
242 def llvm_v16i16_ty     : LLVMType<v16i16>;   // 16 x i16
243 def llvm_v32i16_ty     : LLVMType<v32i16>;   // 32 x i16
244 def llvm_v64i16_ty     : LLVMType<v64i16>;   // 64 x i16
245 def llvm_v128i16_ty    : LLVMType<v128i16>;  //128 x i16
247 def llvm_v1i32_ty      : LLVMType<v1i32>;    //  1 x i32
248 def llvm_v2i32_ty      : LLVMType<v2i32>;    //  2 x i32
249 def llvm_v4i32_ty      : LLVMType<v4i32>;    //  4 x i32
250 def llvm_v8i32_ty      : LLVMType<v8i32>;    //  8 x i32
251 def llvm_v16i32_ty     : LLVMType<v16i32>;   // 16 x i32
252 def llvm_v32i32_ty     : LLVMType<v32i32>;   // 32 x i32
253 def llvm_v64i32_ty     : LLVMType<v64i32>;   // 64 x i32
255 def llvm_v1i64_ty      : LLVMType<v1i64>;    //  1 x i64
256 def llvm_v2i64_ty      : LLVMType<v2i64>;    //  2 x i64
257 def llvm_v4i64_ty      : LLVMType<v4i64>;    //  4 x i64
258 def llvm_v8i64_ty      : LLVMType<v8i64>;    //  8 x i64
259 def llvm_v16i64_ty     : LLVMType<v16i64>;   // 16 x i64
260 def llvm_v32i64_ty     : LLVMType<v32i64>;   // 32 x i64
262 def llvm_v1i128_ty     : LLVMType<v1i128>;   //  1 x i128
264 def llvm_v2f16_ty      : LLVMType<v2f16>;    //  2 x half (__fp16)
265 def llvm_v4f16_ty      : LLVMType<v4f16>;    //  4 x half (__fp16)
266 def llvm_v8f16_ty      : LLVMType<v8f16>;    //  8 x half (__fp16)
267 def llvm_v1f32_ty      : LLVMType<v1f32>;    //  1 x float
268 def llvm_v2f32_ty      : LLVMType<v2f32>;    //  2 x float
269 def llvm_v4f32_ty      : LLVMType<v4f32>;    //  4 x float
270 def llvm_v8f32_ty      : LLVMType<v8f32>;    //  8 x float
271 def llvm_v16f32_ty     : LLVMType<v16f32>;   // 16 x float
272 def llvm_v32f32_ty     : LLVMType<v32f32>;   // 32 x float
273 def llvm_v1f64_ty      : LLVMType<v1f64>;    //  1 x double
274 def llvm_v2f64_ty      : LLVMType<v2f64>;    //  2 x double
275 def llvm_v4f64_ty      : LLVMType<v4f64>;    //  4 x double
276 def llvm_v8f64_ty      : LLVMType<v8f64>;    //  8 x double
278 def llvm_vararg_ty     : LLVMType<isVoid>;   // this means vararg here
280 //===----------------------------------------------------------------------===//
281 // Intrinsic Definitions.
282 //===----------------------------------------------------------------------===//
284 // Intrinsic class - This is used to define one LLVM intrinsic.  The name of the
285 // intrinsic definition should start with "int_", then match the LLVM intrinsic
286 // name with the "llvm." prefix removed, and all "."s turned into "_"s.  For
287 // example, llvm.bswap.i16 -> int_bswap_i16.
289 //  * RetTypes is a list containing the return types expected for the
290 //    intrinsic.
291 //  * ParamTypes is a list containing the parameter types expected for the
292 //    intrinsic.
293 //  * Properties can be set to describe the behavior of the intrinsic.
295 class Intrinsic<list<LLVMType> ret_types,
296                 list<LLVMType> param_types = [],
297                 list<IntrinsicProperty> intr_properties = [],
298                 string name = "",
299                 list<SDNodeProperty> sd_properties = []> : SDPatternOperator {
300   string LLVMName = name;
301   string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
302   list<LLVMType> RetTypes = ret_types;
303   list<LLVMType> ParamTypes = param_types;
304   list<IntrinsicProperty> IntrProperties = intr_properties;
305   let Properties = sd_properties;
307   bit isTarget = 0;
310 /// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this
311 /// specifies the name of the builtin.  This provides automatic CBE and CFE
312 /// support.
313 class GCCBuiltin<string name> {
314   string GCCBuiltinName = name;
317 class MSBuiltin<string name> {
318   string MSBuiltinName = name;
322 //===--------------- Variable Argument Handling Intrinsics ----------------===//
325 def int_vastart : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
326 def int_vacopy  : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
327                             "llvm.va_copy">;
328 def int_vaend   : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
330 //===------------------- Garbage Collection Intrinsics --------------------===//
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<1>, NoCapture<2>]>;
341 //===------------------- ObjC ARC runtime Intrinsics --------------------===//
343 // Note these are to support the Objective-C ARC optimizer which wants to
344 // eliminate retain and releases where possible.
346 def int_objc_autorelease                    : Intrinsic<[llvm_ptr_ty],
347                                                         [llvm_ptr_ty]>;
348 def int_objc_autoreleasePoolPop             : Intrinsic<[], [llvm_ptr_ty]>;
349 def int_objc_autoreleasePoolPush            : Intrinsic<[llvm_ptr_ty], []>;
350 def int_objc_autoreleaseReturnValue         : Intrinsic<[llvm_ptr_ty],
351                                                         [llvm_ptr_ty]>;
352 def int_objc_copyWeak                       : Intrinsic<[],
353                                                         [llvm_ptrptr_ty,
354                                                          llvm_ptrptr_ty]>;
355 def int_objc_destroyWeak                    : Intrinsic<[], [llvm_ptrptr_ty]>;
356 def int_objc_initWeak                       : Intrinsic<[llvm_ptr_ty],
357                                                         [llvm_ptrptr_ty,
358                                                          llvm_ptr_ty]>;
359 def int_objc_loadWeak                       : Intrinsic<[llvm_ptr_ty],
360                                                         [llvm_ptrptr_ty]>;
361 def int_objc_loadWeakRetained               : Intrinsic<[llvm_ptr_ty],
362                                                         [llvm_ptrptr_ty]>;
363 def int_objc_moveWeak                       : Intrinsic<[],
364                                                         [llvm_ptrptr_ty,
365                                                          llvm_ptrptr_ty]>;
366 def int_objc_release                        : Intrinsic<[], [llvm_ptr_ty]>;
367 def int_objc_retain                         : Intrinsic<[llvm_ptr_ty],
368                                                         [llvm_ptr_ty]>;
369 def int_objc_retainAutorelease              : Intrinsic<[llvm_ptr_ty],
370                                                         [llvm_ptr_ty]>;
371 def int_objc_retainAutoreleaseReturnValue   : Intrinsic<[llvm_ptr_ty],
372                                                         [llvm_ptr_ty]>;
373 def int_objc_retainAutoreleasedReturnValue  : Intrinsic<[llvm_ptr_ty],
374                                                         [llvm_ptr_ty]>;
375 def int_objc_retainBlock                    : Intrinsic<[llvm_ptr_ty],
376                                                         [llvm_ptr_ty]>;
377 def int_objc_storeStrong                    : Intrinsic<[],
378                                                         [llvm_ptrptr_ty,
379                                                          llvm_ptr_ty]>;
380 def int_objc_storeWeak                      : Intrinsic<[llvm_ptr_ty],
381                                                         [llvm_ptrptr_ty,
382                                                          llvm_ptr_ty]>;
383 def int_objc_clang_arc_use                  : Intrinsic<[],
384                                                         [llvm_vararg_ty]>;
385 def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
386                                                             [llvm_ptr_ty]>;
387 def int_objc_retainedObject                 : Intrinsic<[llvm_ptr_ty],
388                                                         [llvm_ptr_ty]>;
389 def int_objc_unretainedObject               : Intrinsic<[llvm_ptr_ty],
390                                                         [llvm_ptr_ty]>;
391 def int_objc_unretainedPointer              : Intrinsic<[llvm_ptr_ty],
392                                                         [llvm_ptr_ty]>;
393 def int_objc_retain_autorelease             : Intrinsic<[llvm_ptr_ty],
394                                                         [llvm_ptr_ty]>;
395 def int_objc_sync_enter                     : Intrinsic<[llvm_i32_ty],
396                                                         [llvm_ptr_ty]>;
397 def int_objc_sync_exit                      : Intrinsic<[llvm_i32_ty],
398                                                         [llvm_ptr_ty]>;
399 def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
400                                                         [llvm_ptrptr_ty,
401                                                          llvm_ptrptr_ty]>;
402 def int_objc_arc_annotation_topdown_bbend   : Intrinsic<[],
403                                                         [llvm_ptrptr_ty,
404                                                          llvm_ptrptr_ty]>;
405 def int_objc_arc_annotation_bottomup_bbstart  : Intrinsic<[],
406                                                           [llvm_ptrptr_ty,
407                                                            llvm_ptrptr_ty]>;
408 def int_objc_arc_annotation_bottomup_bbend  : Intrinsic<[],
409                                                         [llvm_ptrptr_ty,
410                                                          llvm_ptrptr_ty]>;
413 //===--------------------- Code Generator Intrinsics ----------------------===//
415 def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
416 def int_addressofreturnaddress : Intrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
417 def int_frameaddress : Intrinsic<[llvm_anyptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
418 def int_sponentry  : Intrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
419 def int_read_register  : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
420                                    [IntrReadMem], "llvm.read_register">;
421 def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
422                                    [], "llvm.write_register">;
424 // Gets the address of the local variable area. This is typically a copy of the
425 // stack, frame, or base pointer depending on the type of prologue.
426 def int_localaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
428 // Escapes local variables to allow access from other functions.
429 def int_localescape : Intrinsic<[], [llvm_vararg_ty]>;
431 // Given a function and the localaddress of a parent frame, returns a pointer
432 // to an escaped allocation indicated by the index.
433 def int_localrecover : Intrinsic<[llvm_ptr_ty],
434                                  [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
435                                  [IntrNoMem, ImmArg<2>]>;
437 // Given the frame pointer passed into an SEH filter function, returns a
438 // pointer to the local variable area suitable for use with llvm.localrecover.
439 def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty],
440                                  [llvm_ptr_ty, llvm_ptr_ty],
441                                  [IntrNoMem]>;
443 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
444 // model their dependencies on allocas.
445 def int_stacksave     : Intrinsic<[llvm_ptr_ty]>,
446                         GCCBuiltin<"__builtin_stack_save">;
447 def int_stackrestore  : Intrinsic<[], [llvm_ptr_ty]>,
448                         GCCBuiltin<"__builtin_stack_restore">;
450 def int_get_dynamic_area_offset : Intrinsic<[llvm_anyint_ty]>;
452 def int_thread_pointer : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
453                          GCCBuiltin<"__builtin_thread_pointer">;
455 // IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
456 // necessary for prefetch, however it does conveniently prevent the prefetch
457 // from being reordered overly much with respect to nearby access to the same
458 // memory while not impeding optimization.
459 def int_prefetch
460     : Intrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
461                 [ IntrInaccessibleMemOrArgMemOnly, IntrWillReturn, ReadOnly<0>, NoCapture<0>,
462                   ImmArg<1>, ImmArg<2>]>;
463 def int_pcmarker      : Intrinsic<[], [llvm_i32_ty]>;
465 def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
467 // The assume intrinsic is marked as arbitrarily writing so that proper
468 // control dependencies will be maintained.
469 def int_assume        : Intrinsic<[], [llvm_i1_ty], [IntrWillReturn]>;
471 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
472 // guard to the correct place on the stack frame.
473 def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
474 def int_stackguard : Intrinsic<[llvm_ptr_ty], [], []>;
476 // A counter increment for instrumentation based profiling.
477 def int_instrprof_increment : Intrinsic<[],
478                                         [llvm_ptr_ty, llvm_i64_ty,
479                                          llvm_i32_ty, llvm_i32_ty],
480                                         []>;
482 // A counter increment with step for instrumentation based profiling.
483 def int_instrprof_increment_step : Intrinsic<[],
484                                         [llvm_ptr_ty, llvm_i64_ty,
485                                          llvm_i32_ty, llvm_i32_ty, llvm_i64_ty],
486                                         []>;
488 // A call to profile runtime for value profiling of target expressions
489 // through instrumentation based profiling.
490 def int_instrprof_value_profile : Intrinsic<[],
491                                             [llvm_ptr_ty, llvm_i64_ty,
492                                              llvm_i64_ty, llvm_i32_ty,
493                                              llvm_i32_ty],
494                                             []>;
496 //===------------------- Standard C Library Intrinsics --------------------===//
499 def int_memcpy  : Intrinsic<[],
500                              [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
501                               llvm_i1_ty],
502                             [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>,
503                              NoAlias<0>, NoAlias<1>, WriteOnly<0>, ReadOnly<1>, ImmArg<3>]>;
504 def int_memmove : Intrinsic<[],
505                             [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
506                              llvm_i1_ty],
507                             [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>,
508                              ReadOnly<1>, ImmArg<3>]>;
509 def int_memset  : Intrinsic<[],
510                             [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
511                              llvm_i1_ty],
512                             [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>,
513                             ImmArg<3>]>;
515 // FIXME: Add version of these floating point intrinsics which allow non-default
516 // rounding modes and FP exception handling.
518 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
519   def int_fma  : Intrinsic<[llvm_anyfloat_ty],
520                            [LLVMMatchType<0>, LLVMMatchType<0>,
521                             LLVMMatchType<0>]>;
522   def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
523                               [LLVMMatchType<0>, LLVMMatchType<0>,
524                                LLVMMatchType<0>]>;
526   // These functions do not read memory, but are sensitive to the
527   // rounding mode. LLVM purposely does not model changes to the FP
528   // environment so they can be treated as readnone.
529   def int_sqrt : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
530   def int_powi : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_i32_ty]>;
531   def int_sin  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
532   def int_cos  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
533   def int_pow  : Intrinsic<[llvm_anyfloat_ty],
534                            [LLVMMatchType<0>, LLVMMatchType<0>]>;
535   def int_log  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
536   def int_log10: Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
537   def int_log2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
538   def int_exp  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
539   def int_exp2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
540   def int_fabs : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
541   def int_copysign : Intrinsic<[llvm_anyfloat_ty],
542                                [LLVMMatchType<0>, LLVMMatchType<0>]>;
543   def int_floor : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
544   def int_ceil  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
545   def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
546   def int_rint  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
547   def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
548   def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
549   def int_canonicalize : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
550                                    [IntrNoMem]>;
552   def int_lround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
553   def int_llround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
554   def int_lrint : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
555   def int_llrint : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
558 def int_minnum : Intrinsic<[llvm_anyfloat_ty],
559   [LLVMMatchType<0>, LLVMMatchType<0>],
560   [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
562 def int_maxnum : Intrinsic<[llvm_anyfloat_ty],
563   [LLVMMatchType<0>, LLVMMatchType<0>],
564   [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
566 def int_minimum : Intrinsic<[llvm_anyfloat_ty],
567   [LLVMMatchType<0>, LLVMMatchType<0>],
568   [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
570 def int_maximum : Intrinsic<[llvm_anyfloat_ty],
571   [LLVMMatchType<0>, LLVMMatchType<0>],
572   [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
575 // NOTE: these are internal interfaces.
576 def int_setjmp     : Intrinsic<[llvm_i32_ty],  [llvm_ptr_ty]>;
577 def int_longjmp    : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
578 def int_sigsetjmp  : Intrinsic<[llvm_i32_ty] , [llvm_ptr_ty, llvm_i32_ty]>;
579 def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
581 // Internal interface for object size checking
582 def int_objectsize : Intrinsic<[llvm_anyint_ty],
583                                [llvm_anyptr_ty, llvm_i1_ty,
584                                 llvm_i1_ty, llvm_i1_ty],
585                                [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>, ImmArg<2>, ImmArg<3>]>,
586                                GCCBuiltin<"__builtin_object_size">;
588 //===--------------- Constrained Floating Point Intrinsics ----------------===//
591 let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
592   def int_experimental_constrained_fadd : Intrinsic<[ llvm_anyfloat_ty ],
593                                                     [ LLVMMatchType<0>,
594                                                       LLVMMatchType<0>,
595                                                       llvm_metadata_ty,
596                                                       llvm_metadata_ty ]>;
597   def int_experimental_constrained_fsub : Intrinsic<[ llvm_anyfloat_ty ],
598                                                     [ LLVMMatchType<0>,
599                                                       LLVMMatchType<0>,
600                                                       llvm_metadata_ty,
601                                                       llvm_metadata_ty ]>;
602   def int_experimental_constrained_fmul : Intrinsic<[ llvm_anyfloat_ty ],
603                                                     [ LLVMMatchType<0>,
604                                                       LLVMMatchType<0>,
605                                                       llvm_metadata_ty,
606                                                       llvm_metadata_ty ]>;
607   def int_experimental_constrained_fdiv : Intrinsic<[ llvm_anyfloat_ty ],
608                                                     [ LLVMMatchType<0>,
609                                                       LLVMMatchType<0>,
610                                                       llvm_metadata_ty,
611                                                       llvm_metadata_ty ]>;
612   def int_experimental_constrained_frem : Intrinsic<[ llvm_anyfloat_ty ],
613                                                     [ LLVMMatchType<0>,
614                                                       LLVMMatchType<0>,
615                                                       llvm_metadata_ty,
616                                                       llvm_metadata_ty ]>;
618   def int_experimental_constrained_fma : Intrinsic<[ llvm_anyfloat_ty ],
619                                                     [ LLVMMatchType<0>,
620                                                       LLVMMatchType<0>,
621                                                       LLVMMatchType<0>,
622                                                       llvm_metadata_ty,
623                                                       llvm_metadata_ty ]>;
625   def int_experimental_constrained_fptosi : Intrinsic<[ llvm_anyint_ty ],
626                                                     [ llvm_anyfloat_ty,
627                                                       llvm_metadata_ty ]>;
629   def int_experimental_constrained_fptoui : Intrinsic<[ llvm_anyint_ty ],
630                                                     [ llvm_anyfloat_ty,
631                                                       llvm_metadata_ty ]>;
633   def int_experimental_constrained_fptrunc : Intrinsic<[ llvm_anyfloat_ty ],
634                                                        [ llvm_anyfloat_ty,
635                                                          llvm_metadata_ty,
636                                                          llvm_metadata_ty ]>;
638   def int_experimental_constrained_fpext : Intrinsic<[ llvm_anyfloat_ty ],
639                                                      [ llvm_anyfloat_ty,
640                                                        llvm_metadata_ty ]>;
642   // These intrinsics are sensitive to the rounding mode so we need constrained
643   // versions of each of them.  When strict rounding and exception control are
644   // not required the non-constrained versions of these intrinsics should be
645   // used.
646   def int_experimental_constrained_sqrt : Intrinsic<[ llvm_anyfloat_ty ],
647                                                     [ LLVMMatchType<0>,
648                                                       llvm_metadata_ty,
649                                                       llvm_metadata_ty ]>;
650   def int_experimental_constrained_powi : Intrinsic<[ llvm_anyfloat_ty ],
651                                                     [ LLVMMatchType<0>,
652                                                       llvm_i32_ty,
653                                                       llvm_metadata_ty,
654                                                       llvm_metadata_ty ]>;
655   def int_experimental_constrained_sin  : Intrinsic<[ llvm_anyfloat_ty ],
656                                                     [ LLVMMatchType<0>,
657                                                       llvm_metadata_ty,
658                                                       llvm_metadata_ty ]>;
659   def int_experimental_constrained_cos  : Intrinsic<[ llvm_anyfloat_ty ],
660                                                     [ LLVMMatchType<0>,
661                                                       llvm_metadata_ty,
662                                                       llvm_metadata_ty ]>;
663   def int_experimental_constrained_pow  : Intrinsic<[ llvm_anyfloat_ty ],
664                                                     [ LLVMMatchType<0>,
665                                                       LLVMMatchType<0>,
666                                                       llvm_metadata_ty,
667                                                       llvm_metadata_ty ]>;
668   def int_experimental_constrained_log  : Intrinsic<[ llvm_anyfloat_ty ],
669                                                     [ LLVMMatchType<0>,
670                                                       llvm_metadata_ty,
671                                                       llvm_metadata_ty ]>;
672   def int_experimental_constrained_log10: Intrinsic<[ llvm_anyfloat_ty ],
673                                                     [ LLVMMatchType<0>,
674                                                       llvm_metadata_ty,
675                                                       llvm_metadata_ty ]>;
676   def int_experimental_constrained_log2 : Intrinsic<[ llvm_anyfloat_ty ],
677                                                     [ LLVMMatchType<0>,
678                                                       llvm_metadata_ty,
679                                                       llvm_metadata_ty ]>;
680   def int_experimental_constrained_exp  : Intrinsic<[ llvm_anyfloat_ty ],
681                                                     [ LLVMMatchType<0>,
682                                                       llvm_metadata_ty,
683                                                       llvm_metadata_ty ]>;
684   def int_experimental_constrained_exp2 : Intrinsic<[ llvm_anyfloat_ty ],
685                                                     [ LLVMMatchType<0>,
686                                                       llvm_metadata_ty,
687                                                       llvm_metadata_ty ]>;
688   def int_experimental_constrained_rint  : Intrinsic<[ llvm_anyfloat_ty ],
689                                                      [ LLVMMatchType<0>,
690                                                        llvm_metadata_ty,
691                                                        llvm_metadata_ty ]>;
692   def int_experimental_constrained_nearbyint : Intrinsic<[ llvm_anyfloat_ty ],
693                                                          [ LLVMMatchType<0>,
694                                                            llvm_metadata_ty,
695                                                            llvm_metadata_ty ]>;
696   def int_experimental_constrained_maxnum : Intrinsic<[ llvm_anyfloat_ty ],
697                                                       [ LLVMMatchType<0>,
698                                                         LLVMMatchType<0>,
699                                                         llvm_metadata_ty,
700                                                         llvm_metadata_ty ]>;
701   def int_experimental_constrained_minnum : Intrinsic<[ llvm_anyfloat_ty ],
702                                                       [ LLVMMatchType<0>,
703                                                         LLVMMatchType<0>,
704                                                         llvm_metadata_ty,
705                                                         llvm_metadata_ty ]>;
706   def int_experimental_constrained_ceil : Intrinsic<[ llvm_anyfloat_ty ],
707                                                     [ LLVMMatchType<0>,
708                                                       llvm_metadata_ty,
709                                                       llvm_metadata_ty ]>;
710   def int_experimental_constrained_floor : Intrinsic<[ llvm_anyfloat_ty ],
711                                                      [ LLVMMatchType<0>,
712                                                        llvm_metadata_ty,
713                                                        llvm_metadata_ty ]>;
714   def int_experimental_constrained_round : Intrinsic<[ llvm_anyfloat_ty ],
715                                                      [ LLVMMatchType<0>,
716                                                       llvm_metadata_ty,
717                                                       llvm_metadata_ty ]>;
718   def int_experimental_constrained_trunc : Intrinsic<[ llvm_anyfloat_ty ],
719                                                      [ LLVMMatchType<0>,
720                                                        llvm_metadata_ty,
721                                                        llvm_metadata_ty ]>;
723 // FIXME: Add intrinsic for fcmp.
724 // FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
726 //===------------------------- Expect Intrinsics --------------------------===//
728 def int_expect : Intrinsic<[llvm_anyint_ty],
729   [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
731 //===-------------------- Bit Manipulation Intrinsics ---------------------===//
734 // None of these intrinsics accesses memory at all.
735 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
736   def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
737   def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
738   def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
739   def int_fshl : Intrinsic<[llvm_anyint_ty],
740       [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
741   def int_fshr : Intrinsic<[llvm_anyint_ty],
742       [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
745 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>] in {
746   def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
747   def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
750 //===------------------------ Debugger Intrinsics -------------------------===//
753 // None of these intrinsics accesses memory at all...but that doesn't
754 // mean the optimizers can change them aggressively.  Special handling
755 // needed in a few places. These synthetic intrinsics have no
756 // side-effects and just mark information about their operands.
757 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
758   def int_dbg_declare      : Intrinsic<[],
759                                        [llvm_metadata_ty,
760                                         llvm_metadata_ty,
761                                         llvm_metadata_ty]>;
762   def int_dbg_value        : Intrinsic<[],
763                                        [llvm_metadata_ty,
764                                         llvm_metadata_ty,
765                                         llvm_metadata_ty]>;
766   def int_dbg_addr         : Intrinsic<[],
767                                        [llvm_metadata_ty,
768                                         llvm_metadata_ty,
769                                         llvm_metadata_ty]>;
770   def int_dbg_label        : Intrinsic<[],
771                                        [llvm_metadata_ty]>;
774 //===------------------ Exception Handling Intrinsics----------------------===//
777 // The result of eh.typeid.for depends on the enclosing function, but inside a
778 // given function it is 'const' and may be CSE'd etc.
779 def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
781 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
782 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
784 // eh.exceptionpointer returns the pointer to the exception caught by
785 // the given `catchpad`.
786 def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
787                                         [IntrNoMem]>;
789 // Gets the exception code from a catchpad token. Only used on some platforms.
790 def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
792 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
793 // callee-saved registers to be saved and restored (regardless of whether they
794 // are used) in the calling function. It is used by libgcc_eh.
795 def int_eh_unwind_init: Intrinsic<[]>,
796                         GCCBuiltin<"__builtin_unwind_init">;
798 def int_eh_dwarf_cfa  : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
800 let IntrProperties = [IntrNoMem] in {
801   def int_eh_sjlj_lsda             : Intrinsic<[llvm_ptr_ty]>;
802   def int_eh_sjlj_callsite         : Intrinsic<[], [llvm_i32_ty]>;
804 def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
805 def int_eh_sjlj_setjmp          : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
806 def int_eh_sjlj_longjmp         : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
807 def int_eh_sjlj_setup_dispatch  : Intrinsic<[], []>;
809 //===---------------- Generic Variable Attribute Intrinsics----------------===//
811 def int_var_annotation : Intrinsic<[],
812                                    [llvm_ptr_ty, llvm_ptr_ty,
813                                     llvm_ptr_ty, llvm_i32_ty],
814                                    [IntrWillReturn], "llvm.var.annotation">;
815 def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>],
816                                    [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty,
817                                     llvm_i32_ty],
818                                    [IntrWillReturn], "llvm.ptr.annotation">;
819 def int_annotation : Intrinsic<[llvm_anyint_ty],
820                                [LLVMMatchType<0>, llvm_ptr_ty,
821                                 llvm_ptr_ty, llvm_i32_ty],
822                                [IntrWillReturn], "llvm.annotation">;
824 // Annotates the current program point with metadata strings which are emitted
825 // as CodeView debug info records. This is expensive, as it disables inlining
826 // and is modelled as having side effects.
827 def int_codeview_annotation : Intrinsic<[], [llvm_metadata_ty],
828                                         [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
829                                         "llvm.codeview.annotation">;
831 //===------------------------ Trampoline Intrinsics -----------------------===//
833 def int_init_trampoline : Intrinsic<[],
834                                     [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
835                                     [IntrArgMemOnly, NoCapture<0>]>,
836                                    GCCBuiltin<"__builtin_init_trampoline">;
838 def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
839                                       [IntrReadMem, IntrArgMemOnly]>,
840                                      GCCBuiltin<"__builtin_adjust_trampoline">;
842 //===------------------------ Overflow Intrinsics -------------------------===//
845 // Expose the carry flag from add operations on two integrals.
846 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
847   def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty,
848                                           LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
849                                          [LLVMMatchType<0>, LLVMMatchType<0>]>;
850   def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty,
851                                           LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
852                                          [LLVMMatchType<0>, LLVMMatchType<0>]>;
854   def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty,
855                                           LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
856                                          [LLVMMatchType<0>, LLVMMatchType<0>]>;
857   def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty,
858                                           LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
859                                          [LLVMMatchType<0>, LLVMMatchType<0>]>;
861   def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty,
862                                           LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
863                                          [LLVMMatchType<0>, LLVMMatchType<0>]>;
864   def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty,
865                                           LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
866                                          [LLVMMatchType<0>, LLVMMatchType<0>]>;
868 //===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
870 def int_sadd_sat : Intrinsic<[llvm_anyint_ty],
871                              [LLVMMatchType<0>, LLVMMatchType<0>],
872                              [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
873 def int_uadd_sat : Intrinsic<[llvm_anyint_ty],
874                              [LLVMMatchType<0>, LLVMMatchType<0>],
875                              [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
876 def int_ssub_sat : Intrinsic<[llvm_anyint_ty],
877                              [LLVMMatchType<0>, LLVMMatchType<0>],
878                              [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
879 def int_usub_sat : Intrinsic<[llvm_anyint_ty],
880                              [LLVMMatchType<0>, LLVMMatchType<0>],
881                              [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
883 //===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
885 def int_smul_fix : Intrinsic<[llvm_anyint_ty],
886                              [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
887                              [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
889 def int_umul_fix : Intrinsic<[llvm_anyint_ty],
890                              [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
891                              [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
893 //===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
895 def int_smul_fix_sat : Intrinsic<[llvm_anyint_ty],
896                                  [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
897                                  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
899 //===------------------------- Memory Use Markers -------------------------===//
901 def int_lifetime_start  : Intrinsic<[],
902                                     [llvm_i64_ty, llvm_anyptr_ty],
903                                     [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
904 def int_lifetime_end    : Intrinsic<[],
905                                     [llvm_i64_ty, llvm_anyptr_ty],
906                                     [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
907 def int_invariant_start : Intrinsic<[llvm_descriptor_ty],
908                                     [llvm_i64_ty, llvm_anyptr_ty],
909                                     [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
910 def int_invariant_end   : Intrinsic<[],
911                                     [llvm_descriptor_ty, llvm_i64_ty,
912                                      llvm_anyptr_ty],
913                                     [IntrArgMemOnly, IntrWillReturn, NoCapture<2>, ImmArg<1>]>;
915 // launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
916 // because it would cause CSE of two barriers with the same argument.
917 // Inaccessiblememonly says that the barrier doesn't read the argument,
918 // but it changes state not accessible to this module. This way
919 // we can DSE through the barrier because it doesn't read the value
920 // after store. Although the barrier doesn't modify any memory it
921 // can't be marked as readonly, because it would be possible to
922 // CSE 2 barriers with store in between.
923 // The argument also can't be marked with 'returned' attribute, because
924 // it would remove barrier.
925 // Note that it is still experimental, which means that its semantics
926 // might change in the future.
927 def int_launder_invariant_group : Intrinsic<[llvm_anyptr_ty],
928                                             [LLVMMatchType<0>],
929                                             [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
932 def int_strip_invariant_group : Intrinsic<[llvm_anyptr_ty],
933                                           [LLVMMatchType<0>],
934                                           [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
936 //===------------------------ Stackmap Intrinsics -------------------------===//
938 def int_experimental_stackmap : Intrinsic<[],
939                                   [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
940                                   [Throws]>;
941 def int_experimental_patchpoint_void : Intrinsic<[],
942                                                  [llvm_i64_ty, llvm_i32_ty,
943                                                   llvm_ptr_ty, llvm_i32_ty,
944                                                   llvm_vararg_ty],
945                                                   [Throws]>;
946 def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
947                                                 [llvm_i64_ty, llvm_i32_ty,
948                                                  llvm_ptr_ty, llvm_i32_ty,
949                                                  llvm_vararg_ty],
950                                                  [Throws]>;
953 //===------------------------ Garbage Collection Intrinsics ---------------===//
954 // These are documented in docs/Statepoint.rst
956 def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
957                                [llvm_i64_ty, llvm_i32_ty,
958                                 llvm_anyptr_ty, llvm_i32_ty,
959                                 llvm_i32_ty, llvm_vararg_ty],
960                                 [Throws, ImmArg<0>, ImmArg<1>, ImmArg<3>, ImmArg<4>]>;
962 def int_experimental_gc_result   : Intrinsic<[llvm_any_ty], [llvm_token_ty],
963                                              [IntrReadMem]>;
964 def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
965                                 [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
966                                 [IntrReadMem, ImmArg<1>, ImmArg<2>]>;
968 //===------------------------ Coroutine Intrinsics ---------------===//
969 // These are documented in docs/Coroutines.rst
971 // Coroutine Structure Intrinsics.
973 def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty,
974                              llvm_ptr_ty, llvm_ptr_ty],
975                             [IntrArgMemOnly, IntrReadMem,
976                              ReadNone<1>, ReadOnly<2>, NoCapture<2>]>;
977 def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
978     [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
979      llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
980     []>;
981 def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
982     [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
983      llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
984     []>;
985 def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
986 def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
987                                [WriteOnly<1>]>;
989 def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
990                               [IntrReadMem, IntrArgMemOnly, ReadOnly<1>,
991                                NoCapture<1>]>;
992 def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
994 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
995 def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
996 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
998 def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
999 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1000 def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1001 def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1002                                         [IntrNoMem]>;
1003 def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1004                                       [llvm_anyint_ty, llvm_i32_ty], []>;
1005 def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1006 def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1008 def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty],
1009                                [IntrNoMem, ReadNone<0>, ReadNone<1>]>;
1011 // Coroutine Manipulation Intrinsics.
1013 def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1014 def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1015 def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1016                               [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>;
1017 def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1018                                  [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1019                                  [IntrNoMem, NoCapture<0>]>;
1021 // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1023 def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1024                                     [IntrReadMem, IntrArgMemOnly, ReadOnly<0>,
1025                                      NoCapture<0>]>;
1027 ///===-------------------------- Other Intrinsics --------------------------===//
1029 def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
1030                      GCCBuiltin<"__builtin_flt_rounds">;
1031 def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
1032                GCCBuiltin<"__builtin_trap">;
1033 def int_debugtrap : Intrinsic<[]>,
1034                     GCCBuiltin<"__builtin_debugtrap">;
1036 // Support for dynamic deoptimization (or de-specialization)
1037 def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1038                                             [Throws]>;
1040 // Support for speculative runtime guards
1041 def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1042                                        [Throws]>;
1044 // Supports widenable conditions for guards represented as explicit branches.
1045 def int_experimental_widenable_condition : Intrinsic<[llvm_i1_ty], [],
1046                                            [IntrInaccessibleMemOnly, IntrWillReturn]>;
1048 // NOP: calls/invokes to this intrinsic are removed by codegen
1049 def int_donothing : Intrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1051 // This instruction has no actual effect, though it is treated by the optimizer
1052 // has having opaque side effects. This may be inserted into loops to ensure
1053 // that they are not removed even if they turn out to be empty, for languages
1054 // which specify that infinite loops must be preserved.
1055 def int_sideeffect : Intrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1057 // Intrisics to support half precision floating point format
1058 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1059 def int_convert_to_fp16   : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1060 def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1063 // Clear cache intrinsic, default to ignore (ie. emit nothing)
1064 // maps to void __clear_cache() on supporting platforms
1065 def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1066                                 [], "llvm.clear_cache">;
1068 // Intrinsic to detect whether its argument is a constant.
1069 def int_is_constant : Intrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem, IntrWillReturn], "llvm.is.constant">;
1071 // Intrinsic to mask out bits of a pointer.
1072 def int_ptrmask: Intrinsic<[llvm_anyptr_ty], [llvm_anyptr_ty, llvm_anyint_ty],
1073                            [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1075 //===-------------------------- Masked Intrinsics -------------------------===//
1077 def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
1078                                       LLVMAnyPointerType<LLVMMatchType<0>>,
1079                                       llvm_i32_ty,
1080                                       LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1081                                  [IntrArgMemOnly, IntrWillReturn, ImmArg<2>]>;
1083 def int_masked_load  : Intrinsic<[llvm_anyvector_ty],
1084                                  [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
1085                                   LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1086                                  [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<1>]>;
1088 def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
1089                                  [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1090                                   LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1091                                   LLVMMatchType<0>],
1092                                  [IntrReadMem, IntrWillReturn, ImmArg<1>]>;
1094 def int_masked_scatter: Intrinsic<[],
1095                                   [llvm_anyvector_ty,
1096                                    LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1097                                    LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1098                                    [IntrWillReturn, ImmArg<2>]>;
1100 def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
1101                                      [LLVMPointerToElt<0>,
1102                                       LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1103                                       LLVMMatchType<0>],
1104                                      [IntrReadMem, IntrWillReturn]>;
1106 def int_masked_compressstore: Intrinsic<[],
1107                                      [llvm_anyvector_ty,
1108                                       LLVMPointerToElt<0>,
1109                                       LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1110                                      [IntrArgMemOnly, IntrWillReturn]>;
1112 // Test whether a pointer is associated with a type metadata identifier.
1113 def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1114                               [IntrNoMem, IntrWillReturn]>;
1116 // Safely loads a function pointer from a virtual table pointer using type metadata.
1117 def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty],
1118                                       [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
1119                                       [IntrNoMem, IntrWillReturn]>;
1121 // Create a branch funnel that implements an indirect call to a limited set of
1122 // callees. This needs to be a musttail call.
1123 def int_icall_branch_funnel : Intrinsic<[], [llvm_vararg_ty], []>;
1125 def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
1126                                  [IntrReadMem, IntrArgMemOnly]>;
1128 def int_hwasan_check_memaccess :
1129   Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1131 // Xray intrinsics
1132 //===----------------------------------------------------------------------===//
1133 // Custom event logging for x-ray.
1134 // Takes a pointer to a string and the length of the string.
1135 def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
1136                                      [NoCapture<0>, ReadOnly<0>, IntrWriteMem]>;
1137 // Typed event logging for x-ray.
1138 // Takes a numeric type tag, a pointer to a string and the length of the string.
1139 def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
1140                                         [NoCapture<1>, ReadOnly<1>, IntrWriteMem]>;
1141 //===----------------------------------------------------------------------===//
1143 //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
1146 // @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
1147 def int_memcpy_element_unordered_atomic
1148     : Intrinsic<[],
1149                 [
1150                   llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1151                 ],
1152                 [
1153                   IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1154                   ReadOnly<1>, ImmArg<3>
1155                 ]>;
1157 // @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
1158 def int_memmove_element_unordered_atomic
1159     : Intrinsic<[],
1160                 [
1161                   llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1162                 ],
1163                 [
1164                   IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1165                   ReadOnly<1>, ImmArg<3>
1166                 ]>;
1168 // @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
1169 def int_memset_element_unordered_atomic
1170     : Intrinsic<[], [ llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty ],
1171                 [ IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>, ImmArg<3> ]>;
1173 //===------------------------ Reduction Intrinsics ------------------------===//
1175 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1176   def int_experimental_vector_reduce_v2_fadd : Intrinsic<[llvm_anyfloat_ty],
1177                                                          [LLVMMatchType<0>,
1178                                                           llvm_anyvector_ty]>;
1179   def int_experimental_vector_reduce_v2_fmul : Intrinsic<[llvm_anyfloat_ty],
1180                                                          [LLVMMatchType<0>,
1181                                                           llvm_anyvector_ty]>;
1182   def int_experimental_vector_reduce_add : Intrinsic<[LLVMVectorElementType<0>],
1183                                                      [llvm_anyvector_ty]>;
1184   def int_experimental_vector_reduce_mul : Intrinsic<[LLVMVectorElementType<0>],
1185                                                      [llvm_anyvector_ty]>;
1186   def int_experimental_vector_reduce_and : Intrinsic<[LLVMVectorElementType<0>],
1187                                                      [llvm_anyvector_ty]>;
1188   def int_experimental_vector_reduce_or : Intrinsic<[LLVMVectorElementType<0>],
1189                                                     [llvm_anyvector_ty]>;
1190   def int_experimental_vector_reduce_xor : Intrinsic<[LLVMVectorElementType<0>],
1191                                                      [llvm_anyvector_ty]>;
1192   def int_experimental_vector_reduce_smax : Intrinsic<[LLVMVectorElementType<0>],
1193                                                       [llvm_anyvector_ty]>;
1194   def int_experimental_vector_reduce_smin : Intrinsic<[LLVMVectorElementType<0>],
1195                                                       [llvm_anyvector_ty]>;
1196   def int_experimental_vector_reduce_umax : Intrinsic<[LLVMVectorElementType<0>],
1197                                                       [llvm_anyvector_ty]>;
1198   def int_experimental_vector_reduce_umin : Intrinsic<[LLVMVectorElementType<0>],
1199                                                       [llvm_anyvector_ty]>;
1200   def int_experimental_vector_reduce_fmax : Intrinsic<[LLVMVectorElementType<0>],
1201                                                       [llvm_anyvector_ty]>;
1202   def int_experimental_vector_reduce_fmin : Intrinsic<[LLVMVectorElementType<0>],
1203                                                       [llvm_anyvector_ty]>;
1206 //===---------- Intrinsics to control hardware supported loops ----------===//
1208 // Specify that the value given is the number of iterations that the next loop
1209 // will execute.
1210 def int_set_loop_iterations :
1211   Intrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
1213 // Specify that the value given is the number of iterations that the next loop
1214 // will execute. Also test that the given count is not zero, allowing it to
1215 // control entry to a 'while' loop.
1216 def int_test_set_loop_iterations :
1217   Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1219 // Decrement loop counter by the given argument. Return false if the loop
1220 // should exit.
1221 def int_loop_decrement :
1222   Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1224 // Decrement the first operand (the loop counter) by the second operand (the
1225 // maximum number of elements processed in an iteration). Return the remaining
1226 // number of iterations still to be executed. This is effectively a sub which
1227 // can be used with a phi, icmp and br to control the number of iterations
1228 // executed, as usual.
1229 def int_loop_decrement_reg :
1230   Intrinsic<[llvm_anyint_ty],
1231             [llvm_anyint_ty, llvm_anyint_ty], [IntrNoDuplicate]>;
1233 //===----- Intrinsics that are used to provide predicate information -----===//
1235 def int_ssa_copy : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
1236                              [IntrNoMem, Returned<0>]>;
1238 //===------- Intrinsics that are used to preserve debug information -------===//
1240 def int_preserve_array_access_index : Intrinsic<[llvm_anyptr_ty],
1241                                                 [llvm_anyptr_ty, llvm_i32_ty,
1242                                                  llvm_i32_ty],
1243                                                 [IntrNoMem, ImmArg<1>, ImmArg<2>]>;
1244 def int_preserve_union_access_index : Intrinsic<[llvm_anyptr_ty],
1245                                                 [llvm_anyptr_ty, llvm_i32_ty],
1246                                                 [IntrNoMem, ImmArg<1>]>;
1247 def int_preserve_struct_access_index : Intrinsic<[llvm_anyptr_ty],
1248                                                  [llvm_anyptr_ty, llvm_i32_ty,
1249                                                   llvm_i32_ty],
1250                                                  [IntrNoMem, ImmArg<1>,
1251                                                   ImmArg<2>]>;
1253 //===----------------------------------------------------------------------===//
1254 // Target-specific intrinsics
1255 //===----------------------------------------------------------------------===//
1257 include "llvm/IR/IntrinsicsPowerPC.td"
1258 include "llvm/IR/IntrinsicsX86.td"
1259 include "llvm/IR/IntrinsicsARM.td"
1260 include "llvm/IR/IntrinsicsAArch64.td"
1261 include "llvm/IR/IntrinsicsXCore.td"
1262 include "llvm/IR/IntrinsicsHexagon.td"
1263 include "llvm/IR/IntrinsicsNVVM.td"
1264 include "llvm/IR/IntrinsicsMips.td"
1265 include "llvm/IR/IntrinsicsAMDGPU.td"
1266 include "llvm/IR/IntrinsicsBPF.td"
1267 include "llvm/IR/IntrinsicsSystemZ.td"
1268 include "llvm/IR/IntrinsicsWebAssembly.td"
1269 include "llvm/IR/IntrinsicsRISCV.td"