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