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