xref: /llvm-project/llvm/include/llvm/IR/Intrinsics.td (revision a1ee1a9126678aabd3b02ef1367df8879d2536fa)
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 RetIndex : AttrIndex<0>;
68class ArgIndex<int argNo> : AttrIndex<!add(argNo, 1)>;
69
70// Note: Properties that are applicable either to arguments or return values
71// use AttrIndex. Properties applicable only to arguments use ArgIndex. Please
72// refer to Attributes.td.
73
74// NoCapture - The specified argument pointer is not captured by the intrinsic.
75class NoCapture<ArgIndex idx> : IntrinsicProperty {
76  int ArgNo = idx.Value;
77}
78
79// NoAlias - The return value or the specified argument pointer is not aliasing
80// other "noalias" pointer arguments of the intrinsic wrt. the intrinsic scope.
81class NoAlias<AttrIndex idx> : IntrinsicProperty {
82  int ArgNo = idx.Value;
83}
84
85// NoUndef - The return value or specified argument is neither undef nor poison.
86class NoUndef<AttrIndex idx> : IntrinsicProperty {
87  int ArgNo = idx.Value;
88}
89
90// NonNull - The return value or specified argument is not null.
91class NonNull<AttrIndex idx> : IntrinsicProperty {
92  int ArgNo = idx.Value;
93}
94
95// Align - Alignment for return value or the specified argument.
96class Align<AttrIndex idx, int align> : IntrinsicProperty {
97  int ArgNo = idx.Value;
98  int Align = align;
99}
100
101// Dereferenceable -- Return value or the specified argument is dereferenceable
102// upto `bytes` bytes in size.
103class Dereferenceable<AttrIndex idx, int bytes> : IntrinsicProperty {
104  int ArgNo = idx.Value;
105  int Bytes = bytes;
106}
107
108// Returned - The specified argument is always the return value of the
109// intrinsic.
110class Returned<ArgIndex idx> : IntrinsicProperty {
111  int ArgNo = idx.Value;
112}
113
114// ImmArg - The specified argument must be an immediate.
115class ImmArg<ArgIndex idx> : IntrinsicProperty {
116  int ArgNo = idx.Value;
117}
118
119// ReadOnly - The specified argument pointer is not written to through the
120// pointer by the intrinsic.
121class ReadOnly<ArgIndex idx> : IntrinsicProperty {
122  int ArgNo = idx.Value;
123}
124
125// WriteOnly - The intrinsic does not read memory through the specified
126// argument pointer.
127class WriteOnly<ArgIndex idx> : IntrinsicProperty {
128  int ArgNo = idx.Value;
129}
130
131// ReadNone - The specified argument pointer is not dereferenced by the
132// intrinsic.
133class ReadNone<ArgIndex idx> : IntrinsicProperty {
134  int ArgNo = idx.Value;
135}
136
137def IntrNoReturn : IntrinsicProperty;
138
139// Applied by default.
140def IntrNoCallback : IntrinsicProperty<1>;
141
142// IntrNoSync - Threads executing the intrinsic will not synchronize using
143// memory or other means. Applied by default.
144def IntrNoSync : IntrinsicProperty<1>;
145
146// Applied by default.
147def IntrNoFree : IntrinsicProperty<1>;
148
149// Applied by default.
150def IntrWillReturn : IntrinsicProperty<1>;
151
152// IntrCold - Calls to this intrinsic are cold.
153// Parallels the cold attribute on LLVM IR functions.
154def IntrCold : IntrinsicProperty;
155
156// IntrNoDuplicate - Calls to this intrinsic cannot be duplicated.
157// Parallels the noduplicate attribute on LLVM IR functions.
158def IntrNoDuplicate : IntrinsicProperty;
159
160// IntrNoMerge - Calls to this intrinsic cannot be merged
161// Parallels the nomerge attribute on LLVM IR functions.
162def IntrNoMerge : IntrinsicProperty;
163
164// IntrConvergent - Calls to this intrinsic are convergent and may not be made
165// control-dependent on any additional values.
166// Parallels the convergent attribute on LLVM IR functions.
167def IntrConvergent : IntrinsicProperty;
168
169// This property indicates that the intrinsic is safe to speculate.
170def IntrSpeculatable : IntrinsicProperty;
171
172// This property can be used to override the 'has no other side effects'
173// language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly
174// intrinsic properties.  By default, intrinsics are assumed to have side
175// effects, so this property is only necessary if you have defined one of
176// the memory properties listed above.
177// For this property, 'side effects' has the same meaning as 'side effects'
178// defined by the hasSideEffects property of the TableGen Instruction class.
179def IntrHasSideEffects : IntrinsicProperty;
180
181//===----------------------------------------------------------------------===//
182// IIT constants and utils
183//===----------------------------------------------------------------------===//
184
185// llvm::Intrinsic::IITDescriptor::ArgKind::AK_%
186def ArgKind {
187  int Any        = 0;
188  int AnyInteger = 1;
189  int AnyFloat   = 2;
190  int AnyVector  = 3;
191  int AnyPointer = 4;
192
193  int MatchType  = 7;
194}
195
196// Encode placeholder.
197// [15:8] is the ID used how to resolve ArgCode.
198
199// (ACIdx << 3) | ArgCode
200class EncAnyType<int ArgCode=0> {
201  int ID = 0x100;
202  int ret = !or(ID, ArgCode);
203}
204
205// (Mapping[Num] << 3) | AK.MatchType
206class EncMatchType<int Num=0> {
207  int ID = 0x200;
208  int ret = !or(ID, Num);
209}
210
211// (Mapping[Num] << 3) | ArgCodes[Mapping[Num]]
212class EncSameWidth<int Num=0> {
213  int ID = 0x300;
214  int ret = !or(ID, Num);
215}
216
217// ACIdx
218class EncNextArgA<int dummy=0> {
219  int ID = 0x400;
220  int ret = !or(ID, dummy);
221}
222
223// Mapping[Num]
224class EncNextArgN<int Num=0> {
225  int ID = 0x500;
226  int ret = !or(ID, Num);
227}
228
229class ResolveArgCode<
230    list<int> Mapping,
231    list<int> ArgCodes,
232    int ACIdx,
233    int ax> {
234  int ah = !and(ax, 0xFF00);
235  int al = !and(ax, 0x00FF);
236  int num = Mapping[al];
237  int ret = !cond(
238    !eq(ah, EncAnyType<>.ID)   : !or(!shl(ACIdx, 3), al),
239    !eq(ah, EncMatchType<>.ID) : !or(!shl(num, 3), ArgKind.MatchType),
240    !eq(ah, EncSameWidth<>.ID) : !or(!shl(num, 3), ArgCodes[num]),
241    !eq(ah, EncNextArgA<>.ID)  : ACIdx,
242    !eq(ah, EncNextArgN<>.ID)  : num,
243    true : al);
244}
245
246//===----------------------------------------------------------------------===//
247// IIT_Info
248//===----------------------------------------------------------------------===//
249
250class IIT_Base<int num> {
251  int Number = num;
252  list<ValueType> VTs = ?;
253}
254
255class IIT_VT<ValueType vt, int num> : IIT_Base<num> {
256  let VTs = [vt];
257}
258
259class IIT_Int<int size, int num> : IIT_Base<num> {
260  let VTs = !filter(vti, ValueTypes,
261    !and(vti.isInteger, !eq(vti.Size, size)));
262}
263
264class IIT_Vec<int nelem, int num> : IIT_Base<num> {
265  let VTs = !filter(vti, ValueTypes,
266    !and(vti.isVector, !eq(vti.nElem, nelem)));
267}
268
269defset list<IIT_Base> IIT_all = {
270def IIT_Done : IIT_Base<    0>;
271def IIT_I1   : IIT_Int<1,   1>;
272def IIT_I8   : IIT_Int<8,   2>;
273def IIT_I16  : IIT_Int<16,  3>;
274def IIT_I32  : IIT_Int<32,  4>;
275def IIT_I64  : IIT_Int<64,  5>;
276def IIT_F16  : IIT_VT<f16,  6>;
277def IIT_F32  : IIT_VT<f32,  7>;
278def IIT_F64  : IIT_VT<f64,  8>;
279def IIT_V2   : IIT_Vec<2,   9>;
280def IIT_V4   : IIT_Vec<4,  10>;
281def IIT_V8   : IIT_Vec<8,  11>;
282def IIT_V16  : IIT_Vec<16, 12>;
283def IIT_V32  : IIT_Vec<32, 13>;
284def IIT_PTR  : IIT_Base<   14>;
285def IIT_ARG  : IIT_Base<   15>;
286
287def IIT_V64 : IIT_Vec<64, 16>;
288def IIT_MMX : IIT_VT<x86mmx, 17>;
289def IIT_TOKEN : IIT_VT<token, 18>;
290def IIT_METADATA : IIT_VT<MetadataVT, 19>;
291def IIT_EMPTYSTRUCT : IIT_VT<OtherVT, 20>;
292def IIT_STRUCT2 : IIT_Base<21>;
293def IIT_STRUCT3 : IIT_Base<22>;
294def IIT_STRUCT4 : IIT_Base<23>;
295def IIT_STRUCT5 : IIT_Base<24>;
296def IIT_EXTEND_ARG : IIT_Base<25>;
297def IIT_TRUNC_ARG : IIT_Base<26>;
298def IIT_ANYPTR : IIT_Base<27>;
299def IIT_V1 : IIT_Vec<1, 28>;
300def IIT_VARARG : IIT_VT<isVoid, 29>;
301def IIT_HALF_VEC_ARG : IIT_Base<30>;
302def IIT_SAME_VEC_WIDTH_ARG : IIT_Base<31>;
303def IIT_VEC_OF_ANYPTRS_TO_ELT : IIT_Base<34>;
304def IIT_I128 : IIT_Int<128, 35>;
305def IIT_V512 : IIT_Vec<512, 36>;
306def IIT_V1024 : IIT_Vec<1024, 37>;
307def IIT_STRUCT6 : IIT_Base<38>;
308def IIT_STRUCT7 : IIT_Base<39>;
309def IIT_STRUCT8 : IIT_Base<40>;
310def IIT_F128 : IIT_VT<f128, 41>;
311def IIT_VEC_ELEMENT : IIT_Base<42>;
312def IIT_SCALABLE_VEC : IIT_Base<43>;
313def IIT_SUBDIVIDE2_ARG : IIT_Base<44>;
314def IIT_SUBDIVIDE4_ARG : IIT_Base<45>;
315def IIT_VEC_OF_BITCASTS_TO_INT : IIT_Base<46>;
316def IIT_V128 : IIT_Vec<128, 47>;
317def IIT_BF16 : IIT_VT<bf16, 48>;
318def IIT_STRUCT9 : IIT_Base<49>;
319def IIT_V256 : IIT_Vec<256, 50>;
320def IIT_AMX : IIT_VT<x86amx, 51>;
321def IIT_PPCF128 : IIT_VT<ppcf128, 52>;
322def IIT_V3 : IIT_Vec<3, 53>;
323def IIT_EXTERNREF : IIT_VT<externref, 54>;
324def IIT_FUNCREF : IIT_VT<funcref, 55>;
325def IIT_I2 : IIT_Int<2, 57>;
326def IIT_I4 : IIT_Int<4, 58>;
327def IIT_AARCH64_SVCOUNT : IIT_VT<aarch64svcount, 59>;
328def IIT_V6 : IIT_Vec<6, 60>;
329def IIT_V10 : IIT_Vec<10, 61>;
330}
331
332defvar IIT_all_FixedTypes = !filter(iit, IIT_all,
333  !or(!isa<IIT_VT>(iit), !isa<IIT_Int>(iit)));
334
335defvar IIT_all_VectorTypes = !filter(iit, IIT_all,
336  !isa<IIT_Vec>(iit));
337
338defvar IIT_RetNumbers = [
339  [IIT_Done.Number],
340  []<int>,
341  [IIT_STRUCT2.Number],
342  [IIT_STRUCT3.Number],
343  [IIT_STRUCT4.Number],
344  [IIT_STRUCT5.Number],
345  [IIT_STRUCT6.Number],
346  [IIT_STRUCT7.Number],
347  [IIT_STRUCT8.Number],
348  [IIT_STRUCT9.Number],
349];
350
351//===----------------------------------------------------------------------===//
352// Types used by intrinsics.
353//===----------------------------------------------------------------------===//
354
355class LLVMType<ValueType vt> {
356  ValueType VT = vt;
357  int isAny = vt.isOverloaded;
358
359  int ArgCode = ?;
360  int Number = ?;
361
362  list<IIT_Base> IITs = !filter(iit, IIT_all_FixedTypes,
363    !not(!empty(!filter(iit_vt, iit.VTs,
364      !eq(iit_vt, !if(vt.isVector, vt.ElementType, vt))))));
365  assert !le(!size(IITs), 1), "Duplicate type";
366
367  list<IIT_Base> IIT_Vecs = !if(vt.isVector,
368    !filter(iit, IIT_all_VectorTypes,
369      !not(!empty(!filter(iit_vt, iit.VTs, !and(
370        !eq(iit_vt.ElementType, vt.ElementType),
371        !eq(iit_vt.nElem, vt.nElem)))))),
372    []);
373  assert !le(!size(IIT_Vecs), 1), "Duplicate type";
374
375  // For vector types, assert that the IIT_Vecs list is not empty.
376  assert !or(!not(vt.isVector), !not(!empty(IIT_Vecs))),
377         "Invalid IIT encoding for vector type v" # vt.nElem # vt.ElementType;
378
379  list<int> Sig = !listconcat(
380    !if(vt.isScalable, [IIT_SCALABLE_VEC.Number], []),
381    !foreach(iit, IIT_Vecs, iit.Number),
382    !foreach(iit, IITs,     iit.Number));
383}
384
385class LLVMAnyType<ValueType vt> : LLVMType<vt> {
386  let ArgCode = !cond(
387    !eq(vt, Any)     : ArgKind.Any,
388    !eq(vt, iAny)    : ArgKind.AnyInteger,
389    !eq(vt, fAny)    : ArgKind.AnyFloat,
390    !eq(vt, vAny)    : ArgKind.AnyVector,
391    !eq(vt, pAny)    : ArgKind.AnyPointer,
392  );
393  let Sig = [
394    IIT_ARG.Number,
395    EncAnyType<ArgCode>.ret,
396  ];
397
398  assert isAny, "LLVMAnyType.VT should have isOverloaded";
399}
400
401class LLVMQualPointerType<int addrspace>
402  : LLVMType<iPTR> {
403  assert !and(!le(0, addrspace), !le(addrspace, 255)),
404    "Address space exceeds 255";
405
406  let Sig =
407    !if(addrspace, [
408      IIT_ANYPTR.Number,
409      addrspace,
410    ], [
411      IIT_PTR.Number,
412    ]);
413}
414
415class LLVMAnyPointerType : LLVMAnyType<pAny> {
416  assert isAny, "pAny should have isOverloaded";
417}
418
419// Match the type of another intrinsic parameter.  Number is an index into the
420// list of overloaded types for the intrinsic, excluding all the fixed types.
421// The Number value must refer to a previously listed type.  For example:
422//   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
423// has two overloaded types, the 2nd and 3rd arguments.  LLVMMatchType<0>
424// refers to the first overloaded type, which is the 2nd argument.
425class LLVMMatchType<int num, IIT_Base IIT_Info = IIT_ARG>
426  : LLVMType<OtherVT>{
427  let Number = num;
428  let Sig = [
429    IIT_Info.Number,
430    EncMatchType<num>.ret,
431  ];
432}
433
434class LLVMMatchTypeNextArg<int num, IIT_Base IIT_Info>
435  : LLVMMatchType<num, IIT_Info> {
436  let Sig = [
437    IIT_Info.Number,
438    EncNextArgA<>.ret,
439    EncNextArgN<num>.ret,
440  ];
441}
442
443// Match the type of another intrinsic parameter that is expected to be based on
444// an integral type (i.e. either iN or <N x iM>), but change the scalar size to
445// be twice as wide or half as wide as the other type.  This is only useful when
446// the intrinsic is overloaded, so the matched type should be declared as iAny.
447class LLVMExtendedType<int num> : LLVMMatchType<num, IIT_EXTEND_ARG>;
448class LLVMTruncatedType<int num> : LLVMMatchType<num, IIT_TRUNC_ARG>;
449
450// Match the scalar/vector of another intrinsic parameter but with a different
451// element type. Either both are scalars or both are vectors with the same
452// number of elements.
453class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
454  : LLVMMatchType<idx, IIT_SAME_VEC_WIDTH_ARG> {
455  let Sig = !listconcat([
456    IIT_SAME_VEC_WIDTH_ARG.Number,
457    EncSameWidth<idx>.ret,
458  ], elty.Sig);
459}
460
461class LLVMVectorOfAnyPointersToElt<int num>
462  : LLVMMatchTypeNextArg<num, IIT_VEC_OF_ANYPTRS_TO_ELT>;
463class LLVMVectorElementType<int num> : LLVMMatchType<num, IIT_VEC_ELEMENT>;
464
465// Match the type of another intrinsic parameter that is expected to be a
466// vector type, but change the element count to be half as many.
467class LLVMHalfElementsVectorType<int num>
468  : LLVMMatchType<num, IIT_HALF_VEC_ARG>;
469
470// Match the type of another intrinsic parameter that is expected to be a
471// vector type (i.e. <N x iM>) but with each element subdivided to
472// form a vector with more elements that are smaller than the original.
473class LLVMSubdivide2VectorType<int num>
474  : LLVMMatchType<num, IIT_SUBDIVIDE2_ARG>;
475class LLVMSubdivide4VectorType<int num>
476  : LLVMMatchType<num, IIT_SUBDIVIDE4_ARG>;
477
478// Match the element count and bit width of another intrinsic parameter, but
479// change the element type to an integer.
480class LLVMVectorOfBitcastsToInt<int num>
481  : LLVMMatchType<num, IIT_VEC_OF_BITCASTS_TO_INT>;
482
483def llvm_void_ty       : LLVMType<isVoid>;
484
485def llvm_any_ty        : LLVMAnyType<Any>;
486def llvm_anyint_ty     : LLVMAnyType<iAny>;
487def llvm_anyfloat_ty   : LLVMAnyType<fAny>;
488def llvm_anyvector_ty  : LLVMAnyType<vAny>;
489
490def llvm_i1_ty         : LLVMType<i1>;
491def llvm_i8_ty         : LLVMType<i8>;
492def llvm_i16_ty        : LLVMType<i16>;
493def llvm_i32_ty        : LLVMType<i32>;
494def llvm_i64_ty        : LLVMType<i64>;
495def llvm_i128_ty       : LLVMType<i128>;
496def llvm_half_ty       : LLVMType<f16>;
497def llvm_bfloat_ty     : LLVMType<bf16>;
498def llvm_float_ty      : LLVMType<f32>;
499def llvm_double_ty     : LLVMType<f64>;
500def llvm_f80_ty        : LLVMType<f80>;
501def llvm_f128_ty       : LLVMType<f128>;
502def llvm_ppcf128_ty    : LLVMType<ppcf128>;
503def llvm_ptr_ty        : LLVMQualPointerType<0>; // ptr
504def llvm_anyptr_ty     : LLVMAnyPointerType;     // ptr addrspace(N)
505def llvm_empty_ty      : LLVMType<OtherVT>;      // { }
506def llvm_metadata_ty   : LLVMType<MetadataVT>;   // !{...}
507def llvm_token_ty      : LLVMType<token>;        // token
508
509def llvm_x86mmx_ty     : LLVMType<x86mmx>;
510
511def llvm_aarch64_svcount_ty : LLVMType<aarch64svcount>;
512
513def llvm_x86amx_ty     : LLVMType<x86amx>;
514
515def llvm_v2i1_ty       : LLVMType<v2i1>;     //   2 x i1
516def llvm_v4i1_ty       : LLVMType<v4i1>;     //   4 x i1
517def llvm_v8i1_ty       : LLVMType<v8i1>;     //   8 x i1
518def llvm_v16i1_ty      : LLVMType<v16i1>;    //  16 x i1
519def llvm_v32i1_ty      : LLVMType<v32i1>;    //  32 x i1
520def llvm_v64i1_ty      : LLVMType<v64i1>;    //  64 x i1
521def llvm_v128i1_ty     : LLVMType<v128i1>;   // 128 x i1
522def llvm_v256i1_ty     : LLVMType<v256i1>;   // 256 x i1
523def llvm_v512i1_ty     : LLVMType<v512i1>;   // 512 x i1
524def llvm_v1024i1_ty    : LLVMType<v1024i1>;  //1024 x i1
525
526def llvm_v1i8_ty       : LLVMType<v1i8>;     //  1 x i8
527def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8
528def llvm_v3i8_ty       : LLVMType<v3i8>;     //  3 x i8
529def llvm_v4i8_ty       : LLVMType<v4i8>;     //  4 x i8
530def llvm_v8i8_ty       : LLVMType<v8i8>;     //  8 x i8
531def llvm_v16i8_ty      : LLVMType<v16i8>;    // 16 x i8
532def llvm_v32i8_ty      : LLVMType<v32i8>;    // 32 x i8
533def llvm_v64i8_ty      : LLVMType<v64i8>;    // 64 x i8
534def llvm_v128i8_ty     : LLVMType<v128i8>;   //128 x i8
535def llvm_v256i8_ty     : LLVMType<v256i8>;   //256 x i8
536
537def llvm_v1i16_ty      : LLVMType<v1i16>;    //  1 x i16
538def llvm_v2i16_ty      : LLVMType<v2i16>;    //  2 x i16
539def llvm_v4i16_ty      : LLVMType<v4i16>;    //  4 x i16
540def llvm_v8i16_ty      : LLVMType<v8i16>;    //  8 x i16
541def llvm_v16i16_ty     : LLVMType<v16i16>;   // 16 x i16
542def llvm_v32i16_ty     : LLVMType<v32i16>;   // 32 x i16
543def llvm_v64i16_ty     : LLVMType<v64i16>;   // 64 x i16
544def llvm_v128i16_ty    : LLVMType<v128i16>;  //128 x i16
545
546def llvm_v1i32_ty      : LLVMType<v1i32>;    //  1 x i32
547def llvm_v2i32_ty      : LLVMType<v2i32>;    //  2 x i32
548def llvm_v3i32_ty      : LLVMType<v3i32>;    //  3 x i32
549def llvm_v4i32_ty      : LLVMType<v4i32>;    //  4 x i32
550def llvm_v6i32_ty      : LLVMType<v6i32>;    //  6 x i32
551def llvm_v8i32_ty      : LLVMType<v8i32>;    //  8 x i32
552def llvm_v16i32_ty     : LLVMType<v16i32>;   // 16 x i32
553def llvm_v32i32_ty     : LLVMType<v32i32>;   // 32 x i32
554def llvm_v64i32_ty     : LLVMType<v64i32>;   // 64 x i32
555def llvm_v256i32_ty    : LLVMType<v256i32>;  //256 x i32
556
557def llvm_v1i64_ty      : LLVMType<v1i64>;    //  1 x i64
558def llvm_v2i64_ty      : LLVMType<v2i64>;    //  2 x i64
559def llvm_v4i64_ty      : LLVMType<v4i64>;    //  4 x i64
560def llvm_v8i64_ty      : LLVMType<v8i64>;    //  8 x i64
561def llvm_v16i64_ty     : LLVMType<v16i64>;   // 16 x i64
562def llvm_v32i64_ty     : LLVMType<v32i64>;   // 32 x i64
563
564def llvm_v1i128_ty     : LLVMType<v1i128>;   //  1 x i128
565
566def llvm_v2f16_ty      : LLVMType<v2f16>;    //  2 x half (__fp16)
567def llvm_v4f16_ty      : LLVMType<v4f16>;    //  4 x half (__fp16)
568def llvm_v8f16_ty      : LLVMType<v8f16>;    //  8 x half (__fp16)
569def llvm_v16f16_ty     : LLVMType<v16f16>;   // 16 x half (__fp16)
570def llvm_v32f16_ty     : LLVMType<v32f16>;   // 32 x half (__fp16)
571def llvm_v2bf16_ty     : LLVMType<v2bf16>;   //  2 x bfloat (__bf16)
572def llvm_v4bf16_ty     : LLVMType<v4bf16>;   //  4 x bfloat (__bf16)
573def llvm_v8bf16_ty     : LLVMType<v8bf16>;   //  8 x bfloat (__bf16)
574def llvm_v16bf16_ty    : LLVMType<v16bf16>;  // 16 x bfloat (__bf16)
575def llvm_v32bf16_ty    : LLVMType<v32bf16>;  // 32 x bfloat (__bf16)
576def llvm_v1f32_ty      : LLVMType<v1f32>;    //  1 x float
577def llvm_v2f32_ty      : LLVMType<v2f32>;    //  2 x float
578def llvm_v3f32_ty      : LLVMType<v3f32>;    //  3 x float
579def llvm_v4f32_ty      : LLVMType<v4f32>;    //  4 x float
580def llvm_v8f32_ty      : LLVMType<v8f32>;    //  8 x float
581def llvm_v16f32_ty     : LLVMType<v16f32>;   // 16 x float
582def llvm_v32f32_ty     : LLVMType<v32f32>;   // 32 x float
583def llvm_v1f64_ty      : LLVMType<v1f64>;    //  1 x double
584def llvm_v2f64_ty      : LLVMType<v2f64>;    //  2 x double
585def llvm_v4f64_ty      : LLVMType<v4f64>;    //  4 x double
586def llvm_v8f64_ty      : LLVMType<v8f64>;    //  8 x double
587def llvm_v16f64_ty     : LLVMType<v16f64>;   // 16 x double
588
589def llvm_vararg_ty     : LLVMType<isVoid>;   // this means vararg here
590
591def llvm_externref_ty  : LLVMType<externref>;
592def llvm_funcref_ty    : LLVMType<funcref>;
593def llvm_exnref_ty     : LLVMType<exnref>;
594
595//===----------------------------------------------------------------------===//
596
597class MakeIdx<list<int> Set> {
598  list<int> IdxsR = !foreach(i, !range(Set),
599    !if(Set[i],
600      !foldl(0, !range(0, i), m, j, !add(m, Set[j])),
601      -1));
602
603  list<int> RIdxsR = !foreach(i, !range(Set),
604    !foldl(-1, !range(Set), m, j,
605      !if(!and(Set[j], !eq(IdxsR[j], i)), j, m)));
606
607  list<int> Idxs  = !foreach(a, IdxsR,  !if(!ge(a, 0), a, ?));
608  list<int> RIdxs = !foreach(a, RIdxsR, !if(!ge(a, 0), a, ?));
609}
610
611class TypeInfoGen<
612    list<LLVMType> RetTypes,
613    list<LLVMType> ParamTypes> {
614  list<LLVMType> AllTypes = !listconcat(RetTypes, ParamTypes);
615
616  // ArgCodes for NextArg -- isAny or MatchTypeNextArg
617  list<int> ACIdxs = MakeIdx<
618    !foreach(ty, AllTypes,
619      !or(ty.isAny, !isa<LLVMMatchTypeNextArg>(ty)))>.Idxs;
620
621  // ArgCodes (only for isAny or MatchTypeNextArg)
622  list<LLVMType> ACTys = !filter(ty, AllTypes,
623    !or(ty.isAny, !isa<LLVMMatchTypeNextArg>(ty)));
624
625  list<int> ArgCodes = !foreach(ty, ACTys, ty.ArgCode);
626
627  // Mappings MatchTypeIdx to ACTys
628  list<int> MappingRIdxs = MakeIdx<
629    !foreach(ty, ACTys, ty.isAny)>.RIdxs;
630
631  // D63507: Exclude LLVMPointerType<llvm_any_ty>
632  bit isOverloaded = !not(!empty(!filter(ty, AllTypes,
633    !isa<LLVMAnyType>(ty))));
634
635  list<LLVMType> Types = !foreach(ty, AllTypes,
636    !if(!isa<LLVMMatchType>(ty), ACTys[MappingRIdxs[ty.Number]], ty));
637
638  list<int> TypeSig = !listflatten(!listconcat(
639    [IIT_RetNumbers[!size(RetTypes)]],
640    !foreach(i, !range(AllTypes),
641      !foreach(a, AllTypes[i].Sig,
642        ResolveArgCode<
643          MappingRIdxs,
644          ArgCodes,
645          ACIdxs[i],
646          a>.ret))));
647}
648
649//===----------------------------------------------------------------------===//
650// Intrinsic Definitions.
651//===----------------------------------------------------------------------===//
652
653// Intrinsic class - This is used to define one LLVM intrinsic.  The name of the
654// intrinsic definition should start with "int_", then match the LLVM intrinsic
655// name with the "llvm." prefix removed, and all "."s turned into "_"s.  For
656// example, llvm.bswap.i16 -> int_bswap_i16.
657//
658//  * RetTypes is a list containing the return types expected for the
659//    intrinsic.
660//  * ParamTypes is a list containing the parameter types expected for the
661//    intrinsic.
662//  * Properties can be set to describe the behavior of the intrinsic.
663//
664class Intrinsic<list<LLVMType> ret_types,
665                list<LLVMType> param_types = [],
666                list<IntrinsicProperty> intr_properties = [],
667                string name = "",
668                list<SDNodeProperty> sd_properties = [],
669                bit disable_default_attributes = true> : SDPatternOperator {
670  string LLVMName = name;
671  string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
672  list<LLVMType> RetTypes = ret_types;
673  list<LLVMType> ParamTypes = param_types;
674  list<IntrinsicProperty> IntrProperties = intr_properties;
675  let Properties = sd_properties;
676
677  // Disable applying IntrinsicProperties that are marked default with
678  // IntrinsicProperty<1>
679  bit DisableDefaultAttributes = disable_default_attributes;
680
681  TypeInfoGen TypeInfo = TypeInfoGen<RetTypes, ParamTypes>;
682}
683
684// Intrinsic with default attributes (disable_default_attributes = false).
685class DefaultAttrsIntrinsic<list<LLVMType> ret_types,
686                list<LLVMType> param_types = [],
687                list<IntrinsicProperty> intr_properties = [],
688                string name = "",
689                list<SDNodeProperty> sd_properties = []>
690                : Intrinsic<ret_types, param_types,
691                            intr_properties, name,
692                            sd_properties, /*disable_default_attributes*/ 0> {}
693
694/// ClangBuiltin - If this intrinsic exactly corresponds to a Clang builtin, this
695/// specifies the name of the builtin.  This provides automatic CBE and CFE
696/// support.
697class ClangBuiltin<string name> {
698  string ClangBuiltinName = name;
699}
700
701class MSBuiltin<string name> {
702  string MSBuiltinName = name;
703}
704
705#ifndef TEST_INTRINSICS_SUPPRESS_DEFS
706
707//===--------------- Variable Argument Handling Intrinsics ----------------===//
708//
709
710def int_vastart : DefaultAttrsIntrinsic<[],
711                                        [llvm_anyptr_ty], [], "llvm.va_start">;
712def int_vacopy  : DefaultAttrsIntrinsic<[],
713                                        [llvm_anyptr_ty, LLVMMatchType<0>], [],
714                                        "llvm.va_copy">;
715def int_vaend   : DefaultAttrsIntrinsic<[],
716                                        [llvm_anyptr_ty], [], "llvm.va_end">;
717
718//===------------------- Garbage Collection Intrinsics --------------------===//
719//
720def int_gcroot  : Intrinsic<[],
721                            [llvm_ptr_ty, llvm_ptr_ty]>;
722def int_gcread  : Intrinsic<[llvm_ptr_ty],
723                            [llvm_ptr_ty, llvm_ptr_ty],
724                            [IntrReadMem, IntrArgMemOnly]>;
725def int_gcwrite : Intrinsic<[],
726                            [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
727                            [IntrArgMemOnly, NoCapture<ArgIndex<1>>,
728                             NoCapture<ArgIndex<2>>]>;
729
730//===------------------- ObjC ARC runtime Intrinsics --------------------===//
731//
732// Note these are to support the Objective-C ARC optimizer which wants to
733// eliminate retain and releases where possible.
734
735def int_objc_autorelease                    : Intrinsic<[llvm_ptr_ty],
736                                                        [llvm_ptr_ty],
737                                                        [Returned<ArgIndex<0>>]>;
738def int_objc_autoreleasePoolPop             : Intrinsic<[], [llvm_ptr_ty]>;
739def int_objc_autoreleasePoolPush            : Intrinsic<[llvm_ptr_ty], []>;
740def int_objc_autoreleaseReturnValue         : Intrinsic<[llvm_ptr_ty],
741                                                        [llvm_ptr_ty],
742                                                        [Returned<ArgIndex<0>>]>;
743def int_objc_copyWeak                       : Intrinsic<[],
744                                                        [llvm_ptr_ty,
745                                                         llvm_ptr_ty]>;
746def int_objc_destroyWeak                    : Intrinsic<[], [llvm_ptr_ty]>;
747def int_objc_initWeak                       : Intrinsic<[llvm_ptr_ty],
748                                                        [llvm_ptr_ty,
749                                                         llvm_ptr_ty]>;
750def int_objc_loadWeak                       : Intrinsic<[llvm_ptr_ty],
751                                                        [llvm_ptr_ty]>;
752def int_objc_loadWeakRetained               : Intrinsic<[llvm_ptr_ty],
753                                                        [llvm_ptr_ty]>;
754def int_objc_moveWeak                       : Intrinsic<[],
755                                                        [llvm_ptr_ty,
756                                                         llvm_ptr_ty]>;
757def int_objc_release                        : Intrinsic<[], [llvm_ptr_ty]>;
758def int_objc_retain                         : Intrinsic<[llvm_ptr_ty],
759                                                        [llvm_ptr_ty],
760                                                        [Returned<ArgIndex<0>>]>;
761def int_objc_retainAutorelease              : Intrinsic<[llvm_ptr_ty],
762                                                        [llvm_ptr_ty],
763                                                        [Returned<ArgIndex<0>>]>;
764def int_objc_retainAutoreleaseReturnValue   : Intrinsic<[llvm_ptr_ty],
765                                                        [llvm_ptr_ty],
766                                                        [Returned<ArgIndex<0>>]>;
767def int_objc_retainAutoreleasedReturnValue  : Intrinsic<[llvm_ptr_ty],
768                                                        [llvm_ptr_ty]>;
769def int_objc_retainBlock                    : Intrinsic<[llvm_ptr_ty],
770                                                        [llvm_ptr_ty]>;
771def int_objc_storeStrong                    : Intrinsic<[],
772                                                        [llvm_ptr_ty,
773                                                         llvm_ptr_ty]>;
774def int_objc_storeWeak                      : Intrinsic<[llvm_ptr_ty],
775                                                        [llvm_ptr_ty,
776                                                         llvm_ptr_ty]>;
777def int_objc_clang_arc_use                  : Intrinsic<[],
778                                                        [llvm_vararg_ty]>;
779def int_objc_clang_arc_noop_use : DefaultAttrsIntrinsic<[],
780                                                        [llvm_vararg_ty],
781                                                        [IntrInaccessibleMemOnly]>;
782def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
783                                                            [llvm_ptr_ty]>;
784def int_objc_retainedObject                 : Intrinsic<[llvm_ptr_ty],
785                                                        [llvm_ptr_ty]>;
786def int_objc_unretainedObject               : Intrinsic<[llvm_ptr_ty],
787                                                        [llvm_ptr_ty]>;
788def int_objc_unretainedPointer              : Intrinsic<[llvm_ptr_ty],
789                                                        [llvm_ptr_ty]>;
790def int_objc_retain_autorelease             : Intrinsic<[llvm_ptr_ty],
791                                                        [llvm_ptr_ty],
792                                                        [Returned<ArgIndex<0>>]>;
793def int_objc_sync_enter                     : Intrinsic<[llvm_i32_ty],
794                                                        [llvm_ptr_ty]>;
795def int_objc_sync_exit                      : Intrinsic<[llvm_i32_ty],
796                                                        [llvm_ptr_ty]>;
797def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
798                                                        [llvm_ptr_ty,
799                                                         llvm_ptr_ty]>;
800def int_objc_arc_annotation_topdown_bbend   : Intrinsic<[],
801                                                        [llvm_ptr_ty,
802                                                         llvm_ptr_ty]>;
803def int_objc_arc_annotation_bottomup_bbstart  : Intrinsic<[],
804                                                          [llvm_ptr_ty,
805                                                           llvm_ptr_ty]>;
806def int_objc_arc_annotation_bottomup_bbend  : Intrinsic<[],
807                                                        [llvm_ptr_ty,
808                                                         llvm_ptr_ty]>;
809//===--------------- Swift asynchronous context intrinsics ----------------===//
810
811// Returns the location of the Swift asynchronous context (usually stored just
812// before the frame pointer), and triggers the creation of a null context if it
813// would otherwise be unneeded.
814def int_swift_async_context_addr : Intrinsic<[llvm_ptr_ty], [], []>;
815
816//===--------------------- Code Generator Intrinsics ----------------------===//
817//
818def int_returnaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_i32_ty],
819                                  [IntrNoMem, ImmArg<ArgIndex<0>>]>;
820def int_addressofreturnaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
821def int_frameaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_i32_ty],
822                                 [IntrNoMem, ImmArg<ArgIndex<0>>]>;
823def int_sponentry  : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
824def int_read_register  : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
825                                   [IntrReadMem], "llvm.read_register">;
826def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
827                                   [IntrNoCallback], "llvm.write_register">;
828def int_read_volatile_register  : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
829                                            [IntrHasSideEffects],
830                                             "llvm.read_volatile_register">;
831
832// Gets the address of the local variable area. This is typically a copy of the
833// stack, frame, or base pointer depending on the type of prologue.
834def int_localaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
835
836// Escapes local variables to allow access from other functions.
837def int_localescape : DefaultAttrsIntrinsic<[], [llvm_vararg_ty]>;
838
839// Given a function and the localaddress of a parent frame, returns a pointer
840// to an escaped allocation indicated by the index.
841def int_localrecover : DefaultAttrsIntrinsic<[llvm_ptr_ty],
842                                 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
843                                 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
844
845// Given the frame pointer passed into an SEH filter function, returns a
846// pointer to the local variable area suitable for use with llvm.localrecover.
847def int_eh_recoverfp : DefaultAttrsIntrinsic<[llvm_ptr_ty],
848                                 [llvm_ptr_ty, llvm_ptr_ty],
849                                 [IntrNoMem]>;
850
851// To mark the beginning/end of a try-scope for Windows SEH -EHa
852//  calls/invokes to these intrinsics are placed to model control flows
853//    caused by HW exceptions under option -EHa.
854//  calls/invokes to these intrinsics will be discarded during a codegen pass
855//   after EH tables are generated
856def int_seh_try_begin : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
857def int_seh_try_end : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
858def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
859def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>;
860
861// Note: we treat stacksave/stackrestore as writemem because we don't otherwise
862// model their dependencies on allocas.
863def int_stacksave     : DefaultAttrsIntrinsic<[llvm_anyptr_ty]>,
864                        ClangBuiltin<"__builtin_stack_save">;
865def int_stackrestore  : DefaultAttrsIntrinsic<[], [llvm_anyptr_ty]>,
866                        ClangBuiltin<"__builtin_stack_restore">;
867
868def int_get_dynamic_area_offset : DefaultAttrsIntrinsic<[llvm_anyint_ty]>;
869
870def int_thread_pointer : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
871                         ClangBuiltin<"__builtin_thread_pointer">;
872
873// IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
874// necessary for prefetch, however it does conveniently prevent the prefetch
875// from being reordered overly much with respect to nearby access to the same
876// memory while not impeding optimization.
877def int_prefetch
878    : DefaultAttrsIntrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
879                [IntrInaccessibleMemOrArgMemOnly, IntrWillReturn,
880                 ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>,
881                 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
882def int_pcmarker      : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
883
884def int_readcyclecounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>;
885
886def int_readsteadycounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>;
887
888// The assume intrinsic is marked InaccessibleMemOnly so that proper control
889// dependencies will be maintained.
890def int_assume : DefaultAttrsIntrinsic<
891    [], [llvm_i1_ty], [IntrWriteMem, IntrInaccessibleMemOnly, NoUndef<ArgIndex<0>>]>;
892
893// 'llvm.experimental.noalias.scope.decl' intrinsic: Inserted at the location of
894// noalias scope declaration. Makes it possible to identify that a noalias scope
895// is only valid inside the body of a loop.
896//
897// Purpose of the different arguments:
898// - arg0: id.scope: metadata representing the scope declaration.
899def int_experimental_noalias_scope_decl
900    : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
901        [IntrInaccessibleMemOnly]>; // blocks LICM and some more
902
903// Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
904// guard to the correct place on the stack frame.
905def int_stackprotector : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>;
906def int_stackguard : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], []>;
907
908// A cover for instrumentation based profiling.
909def int_instrprof_cover : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty,
910                                         llvm_i32_ty, llvm_i32_ty]>;
911
912// A counter increment for instrumentation based profiling.
913def int_instrprof_increment : Intrinsic<[],
914                                        [llvm_ptr_ty, llvm_i64_ty,
915                                         llvm_i32_ty, llvm_i32_ty]>;
916
917// A counter increment with step for instrumentation based profiling.
918def int_instrprof_increment_step : Intrinsic<[],
919                                        [llvm_ptr_ty, llvm_i64_ty,
920                                         llvm_i32_ty, llvm_i32_ty, llvm_i64_ty]>;
921
922// Callsite instrumentation for contextual profiling
923def int_instrprof_callsite : Intrinsic<[],
924                                        [llvm_ptr_ty, llvm_i64_ty,
925                                         llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty]>;
926
927// A timestamp for instrumentation based profiling.
928def int_instrprof_timestamp : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty,
929                                             llvm_i32_ty, llvm_i32_ty]>;
930
931// A call to profile runtime for value profiling of target expressions
932// through instrumentation based profiling.
933def int_instrprof_value_profile : Intrinsic<[],
934                                            [llvm_ptr_ty, llvm_i64_ty,
935                                             llvm_i64_ty, llvm_i32_ty,
936                                             llvm_i32_ty]>;
937
938// A parameter configuration for instrumentation based MCDC profiling.
939def int_instrprof_mcdc_parameters : Intrinsic<[],
940                                              [llvm_ptr_ty, llvm_i64_ty,
941                                               llvm_i32_ty]>;
942
943// A test vector bitmap update for instrumentation based MCDC profiling.
944def int_instrprof_mcdc_tvbitmap_update : Intrinsic<[],
945                                        [llvm_ptr_ty, llvm_i64_ty,
946                                         llvm_i32_ty, llvm_ptr_ty]>;
947
948def int_call_preallocated_setup : DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty]>;
949def int_call_preallocated_arg : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty]>;
950def int_call_preallocated_teardown : DefaultAttrsIntrinsic<[], [llvm_token_ty]>;
951
952// This intrinsic is intentionally undocumented and users shouldn't call it;
953// it's produced then quickly consumed during codegen.
954def int_callbr_landingpad : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
955                                      [IntrNoMerge]>;
956
957//===------------------- Standard C Library Intrinsics --------------------===//
958//
959
960def int_memcpy  : Intrinsic<[],
961                            [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
962                             llvm_i1_ty],
963                            [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
964                             IntrNoCallback,
965                             NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
966                             NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
967                             WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
968                             ImmArg<ArgIndex<3>>]>;
969
970// Memcpy semantic that is guaranteed to be inlined.
971// In particular this means that the generated code is not allowed to call any
972// external function.
973def int_memcpy_inline
974    : Intrinsic<[],
975      [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i1_ty],
976      [IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
977       NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
978       NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
979       WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
980       ImmArg<ArgIndex<3>>]>;
981
982def int_memmove : Intrinsic<[],
983                            [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
984                             llvm_i1_ty],
985                            [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
986                             IntrNoCallback,
987                             NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
988                             WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
989                             ImmArg<ArgIndex<3>>]>;
990def int_memset  : Intrinsic<[],
991                            [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
992                             llvm_i1_ty],
993                            [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
994                             IntrNoFree, IntrNoCallback,
995                             NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
996                             ImmArg<ArgIndex<3>>]>;
997
998// Memset version that is guaranteed to be inlined.
999// In particular this means that the generated code is not allowed to call any
1000// external function.
1001// The third argument (specifying the size) must be a constant.
1002def int_memset_inline
1003    : Intrinsic<[],
1004      [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i1_ty],
1005      [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
1006       NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1007       ImmArg<ArgIndex<3>>]>;
1008
1009// Memset variant that writes a given pattern.
1010def int_experimental_memset_pattern
1011    : Intrinsic<[],
1012      [llvm_anyptr_ty, // Destination.
1013       llvm_anyint_ty, // Pattern value.
1014       llvm_anyint_ty, // Count (number of times to fill value).
1015       llvm_i1_ty],    // IsVolatile.
1016      [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
1017       NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1018       ImmArg<ArgIndex<3>>]>;
1019
1020// FIXME: Add version of these floating point intrinsics which allow non-default
1021// rounding modes and FP exception handling.
1022
1023let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1024  def int_fma  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1025                           [LLVMMatchType<0>, LLVMMatchType<0>,
1026                            LLVMMatchType<0>]>;
1027  def int_fmuladd : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1028                              [LLVMMatchType<0>, LLVMMatchType<0>,
1029                               LLVMMatchType<0>]>;
1030
1031  // These functions do not read memory, but are sensitive to the
1032  // rounding mode. LLVM purposely does not model changes to the FP
1033  // environment so they can be treated as readnone.
1034  def int_sqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1035  def int_powi : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_anyint_ty]>;
1036  def int_asin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1037  def int_acos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1038  def int_atan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1039  def int_atan2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
1040  def int_sin  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1041  def int_cos  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1042  def int_tan  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1043  def int_sinh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1044  def int_cosh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1045  def int_tanh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1046  def int_pow  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1047                           [LLVMMatchType<0>, LLVMMatchType<0>]>;
1048  def int_log  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1049  def int_log10: DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1050  def int_log2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1051  def int_exp  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1052  def int_exp2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1053  def int_exp10 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1054  def int_fabs : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1055  def int_copysign : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1056                               [LLVMMatchType<0>, LLVMMatchType<0>]>;
1057  def int_floor : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1058  def int_ceil  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1059  def int_trunc : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1060  def int_rint  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1061  def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1062  def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1063  def int_roundeven    : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1064  def int_sincos : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1065                             [llvm_anyfloat_ty]>;
1066
1067  // Truncate a floating point number with a specific rounding mode
1068  def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1069                                                [ llvm_anyfloat_ty, llvm_metadata_ty ]>;
1070
1071  def int_canonicalize : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
1072                                   [IntrNoMem]>;
1073  // Arithmetic fence intrinsic.
1074  def int_arithmetic_fence : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
1075                                                   [IntrNoMem]>;
1076
1077  def int_lround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1078  def int_llround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1079  def int_lrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1080  def int_llrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1081
1082  // TODO: int operand should be constrained to same number of elements as the result.
1083  def int_ldexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>,
1084                                                             llvm_anyint_ty]>;
1085
1086  // TODO: Should constrain all element counts to match
1087  def int_frexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty, llvm_anyint_ty], [LLVMMatchType<0>]>;
1088}
1089
1090def int_minnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1091  [LLVMMatchType<0>, LLVMMatchType<0>],
1092  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1093>;
1094def int_maxnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1095  [LLVMMatchType<0>, LLVMMatchType<0>],
1096  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1097>;
1098def int_minimum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1099  [LLVMMatchType<0>, LLVMMatchType<0>],
1100  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1101>;
1102def int_maximum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1103  [LLVMMatchType<0>, LLVMMatchType<0>],
1104  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1105>;
1106def int_minimumnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1107  [LLVMMatchType<0>, LLVMMatchType<0>],
1108  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1109>;
1110def int_maximumnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1111  [LLVMMatchType<0>, LLVMMatchType<0>],
1112  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1113>;
1114
1115// Internal interface for object size checking
1116def int_objectsize : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1117                               [llvm_anyptr_ty, llvm_i1_ty,
1118                                llvm_i1_ty, llvm_i1_ty],
1119                               [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1120                                ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>,
1121                                ImmArg<ArgIndex<3>>]>,
1122                               ClangBuiltin<"__builtin_object_size">;
1123
1124//===--------------- Access to Floating Point Environment -----------------===//
1125//
1126
1127let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
1128  def int_get_rounding  : DefaultAttrsIntrinsic<[llvm_i32_ty], []>;
1129  def int_set_rounding  : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
1130  def int_get_fpenv     : DefaultAttrsIntrinsic<[llvm_anyint_ty], []>;
1131  def int_set_fpenv     : DefaultAttrsIntrinsic<[], [llvm_anyint_ty]>;
1132  def int_reset_fpenv   : DefaultAttrsIntrinsic<[], []>;
1133  def int_get_fpmode    : DefaultAttrsIntrinsic<[llvm_anyint_ty], []>;
1134  def int_set_fpmode    : DefaultAttrsIntrinsic<[], [llvm_anyint_ty]>;
1135  def int_reset_fpmode  : DefaultAttrsIntrinsic<[], []>;
1136}
1137
1138//===--------------- Floating Point Properties ----------------------------===//
1139//
1140
1141def int_is_fpclass
1142    : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1143                            [llvm_anyfloat_ty, llvm_i32_ty],
1144                            [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
1145
1146//===--------------- Constrained Floating Point Intrinsics ----------------===//
1147//
1148
1149/// IntrStrictFP - The intrinsic is allowed to be used in an alternate
1150/// floating point environment.
1151def IntrStrictFP : IntrinsicProperty;
1152
1153let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn, IntrStrictFP] in {
1154  def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1155                                                    [ LLVMMatchType<0>,
1156                                                      LLVMMatchType<0>,
1157                                                      llvm_metadata_ty,
1158                                                      llvm_metadata_ty ]>;
1159  def int_experimental_constrained_fsub : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1160                                                    [ LLVMMatchType<0>,
1161                                                      LLVMMatchType<0>,
1162                                                      llvm_metadata_ty,
1163                                                      llvm_metadata_ty ]>;
1164  def int_experimental_constrained_fmul : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1165                                                    [ LLVMMatchType<0>,
1166                                                      LLVMMatchType<0>,
1167                                                      llvm_metadata_ty,
1168                                                      llvm_metadata_ty ]>;
1169  def int_experimental_constrained_fdiv : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1170                                                    [ LLVMMatchType<0>,
1171                                                      LLVMMatchType<0>,
1172                                                      llvm_metadata_ty,
1173                                                      llvm_metadata_ty ]>;
1174  def int_experimental_constrained_frem : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1175                                                    [ LLVMMatchType<0>,
1176                                                      LLVMMatchType<0>,
1177                                                      llvm_metadata_ty,
1178                                                      llvm_metadata_ty ]>;
1179
1180  def int_experimental_constrained_fma : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1181                                                    [ LLVMMatchType<0>,
1182                                                      LLVMMatchType<0>,
1183                                                      LLVMMatchType<0>,
1184                                                      llvm_metadata_ty,
1185                                                      llvm_metadata_ty ]>;
1186
1187  def int_experimental_constrained_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1188                                                       [ LLVMMatchType<0>,
1189                                                         LLVMMatchType<0>,
1190                                                         LLVMMatchType<0>,
1191                                                         llvm_metadata_ty,
1192                                                         llvm_metadata_ty ]>;
1193
1194  def int_experimental_constrained_fptosi : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1195                                                    [ llvm_anyfloat_ty,
1196                                                      llvm_metadata_ty ]>;
1197
1198  def int_experimental_constrained_fptoui : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1199                                                    [ llvm_anyfloat_ty,
1200                                                      llvm_metadata_ty ]>;
1201
1202  def int_experimental_constrained_sitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1203                                                       [ llvm_anyint_ty,
1204                                                         llvm_metadata_ty,
1205                                                         llvm_metadata_ty ]>;
1206
1207  def int_experimental_constrained_uitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1208                                                       [ llvm_anyint_ty,
1209                                                         llvm_metadata_ty,
1210                                                         llvm_metadata_ty ]>;
1211
1212  def int_experimental_constrained_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1213                                                       [ llvm_anyfloat_ty,
1214                                                         llvm_metadata_ty,
1215                                                         llvm_metadata_ty ]>;
1216
1217  def int_experimental_constrained_fpext : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1218                                                     [ llvm_anyfloat_ty,
1219                                                       llvm_metadata_ty ]>;
1220
1221  // These intrinsics are sensitive to the rounding mode so we need constrained
1222  // versions of each of them.  When strict rounding and exception control are
1223  // not required the non-constrained versions of these intrinsics should be
1224  // used.
1225  def int_experimental_constrained_sqrt : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1226                                                    [ LLVMMatchType<0>,
1227                                                      llvm_metadata_ty,
1228                                                      llvm_metadata_ty ]>;
1229  def int_experimental_constrained_powi : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1230                                                    [ LLVMMatchType<0>,
1231                                                      llvm_i32_ty,
1232                                                      llvm_metadata_ty,
1233                                                      llvm_metadata_ty ]>;
1234  def int_experimental_constrained_ldexp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1235                                                    [ LLVMMatchType<0>,
1236                                                      llvm_anyint_ty,
1237                                                      llvm_metadata_ty,
1238                                                      llvm_metadata_ty ]>;
1239  def int_experimental_constrained_asin  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1240                                                    [ LLVMMatchType<0>,
1241                                                      llvm_metadata_ty,
1242                                                      llvm_metadata_ty ]>;
1243  def int_experimental_constrained_acos  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1244                                                    [ LLVMMatchType<0>,
1245                                                      llvm_metadata_ty,
1246                                                      llvm_metadata_ty ]>;
1247  def int_experimental_constrained_atan  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1248                                                    [ LLVMMatchType<0>,
1249                                                      llvm_metadata_ty,
1250                                                      llvm_metadata_ty ]>;
1251  def int_experimental_constrained_atan2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1252                                                    [ LLVMMatchType<0>,
1253                                                      LLVMMatchType<0>,
1254                                                      llvm_metadata_ty,
1255                                                      llvm_metadata_ty ]>;
1256  def int_experimental_constrained_sin  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1257                                                    [ LLVMMatchType<0>,
1258                                                      llvm_metadata_ty,
1259                                                      llvm_metadata_ty ]>;
1260  def int_experimental_constrained_cos  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1261                                                    [ LLVMMatchType<0>,
1262                                                      llvm_metadata_ty,
1263                                                      llvm_metadata_ty ]>;
1264  def int_experimental_constrained_tan  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1265                                                    [ LLVMMatchType<0>,
1266                                                      llvm_metadata_ty,
1267                                                      llvm_metadata_ty ]>;
1268  def int_experimental_constrained_sinh  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1269                                                    [ LLVMMatchType<0>,
1270                                                      llvm_metadata_ty,
1271                                                      llvm_metadata_ty ]>;
1272  def int_experimental_constrained_cosh  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1273                                                    [ LLVMMatchType<0>,
1274                                                      llvm_metadata_ty,
1275                                                      llvm_metadata_ty ]>;
1276  def int_experimental_constrained_tanh  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1277                                                    [ LLVMMatchType<0>,
1278                                                      llvm_metadata_ty,
1279                                                      llvm_metadata_ty ]>;
1280  def int_experimental_constrained_pow  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1281                                                    [ LLVMMatchType<0>,
1282                                                      LLVMMatchType<0>,
1283                                                      llvm_metadata_ty,
1284                                                      llvm_metadata_ty ]>;
1285  def int_experimental_constrained_log  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1286                                                    [ LLVMMatchType<0>,
1287                                                      llvm_metadata_ty,
1288                                                      llvm_metadata_ty ]>;
1289  def int_experimental_constrained_log10: DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1290                                                    [ LLVMMatchType<0>,
1291                                                      llvm_metadata_ty,
1292                                                      llvm_metadata_ty ]>;
1293  def int_experimental_constrained_log2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1294                                                    [ LLVMMatchType<0>,
1295                                                      llvm_metadata_ty,
1296                                                      llvm_metadata_ty ]>;
1297  def int_experimental_constrained_exp  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1298                                                    [ LLVMMatchType<0>,
1299                                                      llvm_metadata_ty,
1300                                                      llvm_metadata_ty ]>;
1301  def int_experimental_constrained_exp2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1302                                                    [ LLVMMatchType<0>,
1303                                                      llvm_metadata_ty,
1304                                                      llvm_metadata_ty ]>;
1305  def int_experimental_constrained_rint  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1306                                                     [ LLVMMatchType<0>,
1307                                                       llvm_metadata_ty,
1308                                                       llvm_metadata_ty ]>;
1309  def int_experimental_constrained_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1310                                                         [ LLVMMatchType<0>,
1311                                                           llvm_metadata_ty,
1312                                                           llvm_metadata_ty ]>;
1313  def int_experimental_constrained_lrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1314                                                     [ llvm_anyfloat_ty,
1315                                                       llvm_metadata_ty,
1316                                                       llvm_metadata_ty ]>;
1317  def int_experimental_constrained_llrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1318                                                      [ llvm_anyfloat_ty,
1319                                                        llvm_metadata_ty,
1320                                                        llvm_metadata_ty ]>;
1321  def int_experimental_constrained_maxnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1322                                                      [ LLVMMatchType<0>,
1323                                                        LLVMMatchType<0>,
1324                                                        llvm_metadata_ty ]>;
1325  def int_experimental_constrained_minnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1326                                                      [ LLVMMatchType<0>,
1327                                                        LLVMMatchType<0>,
1328                                                        llvm_metadata_ty ]>;
1329  def int_experimental_constrained_maximum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1330                                                       [ LLVMMatchType<0>,
1331                                                         LLVMMatchType<0>,
1332                                                         llvm_metadata_ty ]>;
1333  def int_experimental_constrained_minimum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1334                                                       [ LLVMMatchType<0>,
1335                                                         LLVMMatchType<0>,
1336                                                         llvm_metadata_ty ]>;
1337  def int_experimental_constrained_ceil : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1338                                                    [ LLVMMatchType<0>,
1339                                                      llvm_metadata_ty ]>;
1340  def int_experimental_constrained_floor : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1341                                                     [ LLVMMatchType<0>,
1342                                                       llvm_metadata_ty ]>;
1343  def int_experimental_constrained_lround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1344                                                      [ llvm_anyfloat_ty,
1345                                                        llvm_metadata_ty ]>;
1346  def int_experimental_constrained_llround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1347                                                       [ llvm_anyfloat_ty,
1348                                                         llvm_metadata_ty ]>;
1349  def int_experimental_constrained_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1350                                                     [ LLVMMatchType<0>,
1351                                                      llvm_metadata_ty ]>;
1352  def int_experimental_constrained_roundeven : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1353                                                         [ LLVMMatchType<0>,
1354                                                           llvm_metadata_ty ]>;
1355  def int_experimental_constrained_trunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1356                                                     [ LLVMMatchType<0>,
1357                                                       llvm_metadata_ty ]>;
1358
1359  // Constrained floating-point comparison (quiet and signaling variants).
1360  // Third operand is the predicate represented as a metadata string.
1361  def int_experimental_constrained_fcmp
1362      : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1363                  [ llvm_anyfloat_ty, LLVMMatchType<0>,
1364                    llvm_metadata_ty, llvm_metadata_ty ]>;
1365  def int_experimental_constrained_fcmps
1366      : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1367                  [ llvm_anyfloat_ty, LLVMMatchType<0>,
1368                    llvm_metadata_ty, llvm_metadata_ty ]>;
1369}
1370// FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
1371
1372
1373//===------------------------- Expect Intrinsics --------------------------===//
1374//
1375def int_expect : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1376  [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
1377
1378def int_expect_with_probability : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1379  [LLVMMatchType<0>, LLVMMatchType<0>, llvm_double_ty],
1380  [IntrNoMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
1381
1382//===-------------------- Bit Manipulation Intrinsics ---------------------===//
1383//
1384
1385// None of these intrinsics accesses memory at all.
1386let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1387  def int_bswap: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
1388  def int_ctpop: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
1389  def int_bitreverse : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
1390  def int_fshl : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1391      [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
1392  def int_fshr : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1393      [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
1394}
1395
1396let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1397                      ImmArg<ArgIndex<1>>] in {
1398  def int_ctlz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
1399  def int_cttz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
1400}
1401
1402//===------------------------ Debugger Intrinsics -------------------------===//
1403//
1404
1405// None of these intrinsics accesses memory at all...but that doesn't
1406// mean the optimizers can change them aggressively.  Special handling
1407// needed in a few places. These synthetic intrinsics have no
1408// side-effects and just mark information about their operands.
1409let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1410  def int_dbg_declare      : DefaultAttrsIntrinsic<[],
1411                                       [llvm_metadata_ty,
1412                                        llvm_metadata_ty,
1413                                        llvm_metadata_ty]>;
1414  def int_dbg_value        : DefaultAttrsIntrinsic<[],
1415                                       [llvm_metadata_ty,
1416                                        llvm_metadata_ty,
1417                                        llvm_metadata_ty]>;
1418  def int_dbg_assign        : DefaultAttrsIntrinsic<[],
1419                                       [llvm_metadata_ty,
1420                                        llvm_metadata_ty,
1421                                        llvm_metadata_ty,
1422                                        llvm_metadata_ty,
1423                                        llvm_metadata_ty,
1424                                        llvm_metadata_ty]>;
1425  def int_dbg_label        : DefaultAttrsIntrinsic<[],
1426                                       [llvm_metadata_ty]>;
1427}
1428
1429//===------------------ Exception Handling Intrinsics----------------------===//
1430//
1431
1432// The result of eh.typeid.for depends on the enclosing function, but inside a
1433// given function it is 'const' and may be CSE'd etc.
1434def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty], [IntrNoMem]>;
1435
1436def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
1437def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
1438
1439// eh.exceptionpointer returns the pointer to the exception caught by
1440// the given `catchpad`.
1441def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
1442                                        [IntrNoMem]>;
1443
1444// Gets the exception code from a catchpad token. Only used on some platforms.
1445def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
1446
1447// __builtin_unwind_init is an undocumented GCC intrinsic that causes all
1448// callee-saved registers to be saved and restored (regardless of whether they
1449// are used) in the calling function. It is used by libgcc_eh.
1450def int_eh_unwind_init: Intrinsic<[]>,
1451                        ClangBuiltin<"__builtin_unwind_init">;
1452
1453def int_eh_dwarf_cfa  : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
1454
1455def int_eh_sjlj_lsda             : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1456def int_eh_sjlj_callsite         : Intrinsic<[], [llvm_i32_ty], [IntrNoMem, ImmArg<ArgIndex<0>>]>;
1457
1458def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
1459def int_eh_sjlj_setjmp          : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
1460def int_eh_sjlj_longjmp         : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
1461def int_eh_sjlj_setup_dispatch  : Intrinsic<[], []>;
1462
1463//===---------------- Generic Variable Attribute Intrinsics----------------===//
1464//
1465def int_var_annotation : DefaultAttrsIntrinsic<
1466    [], [llvm_anyptr_ty, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
1467    [IntrInaccessibleMemOnly], "llvm.var.annotation">;
1468
1469def int_ptr_annotation : DefaultAttrsIntrinsic<
1470    [llvm_anyptr_ty],
1471    [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
1472    [IntrInaccessibleMemOnly], "llvm.ptr.annotation">;
1473
1474def int_annotation : DefaultAttrsIntrinsic<
1475    [llvm_anyint_ty],
1476    [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty],
1477    [IntrInaccessibleMemOnly], "llvm.annotation">;
1478
1479// Annotates the current program point with metadata strings which are emitted
1480// as CodeView debug info records. This is expensive, as it disables inlining
1481// and is modelled as having side effects.
1482def int_codeview_annotation : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
1483                                        [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
1484                                        "llvm.codeview.annotation">;
1485
1486//===------------------------ Trampoline Intrinsics -----------------------===//
1487//
1488def int_init_trampoline : DefaultAttrsIntrinsic<
1489    [], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1490    [IntrArgMemOnly, NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1491     ReadNone<ArgIndex<1>>, ReadNone<ArgIndex<2>>]>,
1492    ClangBuiltin<"__builtin_init_trampoline">;
1493
1494def int_adjust_trampoline : DefaultAttrsIntrinsic<
1495    [llvm_ptr_ty], [llvm_ptr_ty], [IntrReadMem, IntrArgMemOnly]>,
1496    ClangBuiltin<"__builtin_adjust_trampoline">;
1497
1498//===------------------------ Overflow Intrinsics -------------------------===//
1499//
1500
1501// Expose the carry flag from add operations on two integrals.
1502let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1503  def int_sadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1504                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1505                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1506  def int_uadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1507                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1508                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1509
1510  def int_ssub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1511                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1512                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1513  def int_usub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1514                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1515                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1516
1517  def int_smul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1518                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1519                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1520  def int_umul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1521                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1522                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1523}
1524//===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
1525//
1526def int_sadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1527                             [LLVMMatchType<0>, LLVMMatchType<0>],
1528                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
1529def int_uadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1530                             [LLVMMatchType<0>, LLVMMatchType<0>],
1531                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
1532def int_ssub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1533                             [LLVMMatchType<0>, LLVMMatchType<0>],
1534                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1535def int_usub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1536                             [LLVMMatchType<0>, LLVMMatchType<0>],
1537                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1538def int_sshl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1539                             [LLVMMatchType<0>, LLVMMatchType<0>],
1540                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1541def int_ushl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1542                             [LLVMMatchType<0>, LLVMMatchType<0>],
1543                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1544
1545//===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
1546//
1547def int_smul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1548                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1549                             [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1550                              Commutative, ImmArg<ArgIndex<2>>]>;
1551
1552def int_umul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1553                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1554                             [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1555                              Commutative, ImmArg<ArgIndex<2>>]>;
1556
1557def int_sdiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1558                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1559                             [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1560
1561def int_udiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1562                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1563                             [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1564
1565//===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
1566//
1567def int_smul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1568                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1569                                 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1570                                  Commutative, ImmArg<ArgIndex<2>>]>;
1571def int_umul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1572                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1573                                 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1574                                  Commutative, ImmArg<ArgIndex<2>>]>;
1575
1576def int_sdiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1577                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1578                                 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1579
1580def int_udiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1581                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1582                                 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1583
1584//===------------------ Integer Min/Max/Abs Intrinsics --------------------===//
1585//
1586def int_abs : DefaultAttrsIntrinsic<
1587    [llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty],
1588    [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
1589
1590def int_smax : DefaultAttrsIntrinsic<
1591    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1592    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1593def int_smin : DefaultAttrsIntrinsic<
1594    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1595    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1596def int_umax : DefaultAttrsIntrinsic<
1597    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1598    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1599def int_umin : DefaultAttrsIntrinsic<
1600    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1601    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1602def int_scmp : DefaultAttrsIntrinsic<
1603    [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>],
1604    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1605def int_ucmp : DefaultAttrsIntrinsic<
1606    [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>],
1607    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1608
1609//===------------------------- Memory Use Markers -------------------------===//
1610//
1611def int_lifetime_start  : DefaultAttrsIntrinsic<[],
1612                                    [llvm_i64_ty, llvm_anyptr_ty],
1613                                    [IntrArgMemOnly, IntrWillReturn,
1614                                     NoCapture<ArgIndex<1>>,
1615                                     ImmArg<ArgIndex<0>>]>;
1616def int_lifetime_end    : DefaultAttrsIntrinsic<[],
1617                                    [llvm_i64_ty, llvm_anyptr_ty],
1618                                    [IntrArgMemOnly, IntrWillReturn,
1619                                     NoCapture<ArgIndex<1>>,
1620                                     ImmArg<ArgIndex<0>>]>;
1621def int_invariant_start : DefaultAttrsIntrinsic<[llvm_ptr_ty],
1622                                    [llvm_i64_ty, llvm_anyptr_ty],
1623                                    [IntrArgMemOnly, IntrWillReturn,
1624                                     NoCapture<ArgIndex<1>>,
1625                                     ImmArg<ArgIndex<0>>]>;
1626def int_invariant_end   : DefaultAttrsIntrinsic<[],
1627                                    [llvm_ptr_ty, llvm_i64_ty,
1628                                     llvm_anyptr_ty],
1629                                    [IntrArgMemOnly, IntrWillReturn,
1630                                     NoCapture<ArgIndex<2>>,
1631                                     ImmArg<ArgIndex<1>>]>;
1632
1633// launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
1634// because it would cause CSE of two barriers with the same argument.
1635// Inaccessiblememonly says that the barrier doesn't read the argument,
1636// but it changes state not accessible to this module. This way
1637// we can DSE through the barrier because it doesn't read the value
1638// after store. Although the barrier doesn't modify any memory it
1639// can't be marked as readonly, because it would be possible to
1640// CSE 2 barriers with store in between.
1641// The argument also can't be marked with 'returned' attribute, because
1642// it would remove barrier.
1643// Note that it is still experimental, which means that its semantics
1644// might change in the future.
1645def int_launder_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
1646                                            [LLVMMatchType<0>],
1647                                            [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
1648
1649
1650def int_strip_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
1651                                          [LLVMMatchType<0>],
1652                                          [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
1653
1654//===------------------------ Stackmap Intrinsics -------------------------===//
1655//
1656def int_experimental_stackmap : DefaultAttrsIntrinsic<[],
1657                                  [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
1658                                  [Throws, ImmArg<ArgIndex<0>>, ImmArg<ArgIndex<1>>]>;
1659def int_experimental_patchpoint_void : Intrinsic<[],
1660                                                 [llvm_i64_ty, llvm_i32_ty,
1661                                                  llvm_ptr_ty, llvm_i32_ty,
1662                                                  llvm_vararg_ty],
1663                                                  [Throws, ImmArg<ArgIndex<0>>,
1664                                                   ImmArg<ArgIndex<1>>,
1665                                                   ImmArg<ArgIndex<3>>]>;
1666def int_experimental_patchpoint : Intrinsic<[llvm_any_ty],
1667                                            [llvm_i64_ty, llvm_i32_ty,
1668                                             llvm_ptr_ty, llvm_i32_ty,
1669                                             llvm_vararg_ty],
1670                                            [Throws, ImmArg<ArgIndex<0>>,
1671                                             ImmArg<ArgIndex<1>>,
1672                                             ImmArg<ArgIndex<3>>]>;
1673
1674
1675//===------------------------ Garbage Collection Intrinsics ---------------===//
1676// These are documented in docs/Statepoint.rst
1677
1678def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
1679                               [llvm_i64_ty, llvm_i32_ty,
1680                                llvm_anyptr_ty, llvm_i32_ty,
1681                                llvm_i32_ty, llvm_vararg_ty],
1682                               [Throws, ImmArg<ArgIndex<0>>,
1683                                ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<3>>,
1684                                ImmArg<ArgIndex<4>>]>;
1685
1686def int_experimental_gc_result : DefaultAttrsIntrinsic<
1687    [llvm_any_ty], [llvm_token_ty], [IntrNoMem]>;
1688
1689def int_experimental_gc_relocate : DefaultAttrsIntrinsic<
1690    [llvm_any_ty], [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
1691    [IntrNoMem, ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
1692
1693def int_experimental_gc_get_pointer_base : DefaultAttrsIntrinsic<
1694    [llvm_anyptr_ty], [llvm_anyptr_ty],
1695    [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
1696
1697def int_experimental_gc_get_pointer_offset : DefaultAttrsIntrinsic<
1698    [llvm_i64_ty], [llvm_anyptr_ty],
1699    [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
1700
1701//===------------------------ Coroutine Intrinsics ---------------===//
1702// These are documented in docs/Coroutines.rst
1703
1704// Coroutine Structure Intrinsics.
1705
1706def int_coro_id : DefaultAttrsIntrinsic<[llvm_token_ty],
1707    [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1708    [IntrArgMemOnly, IntrReadMem, ReadNone<ArgIndex<1>>, ReadOnly<ArgIndex<2>>,
1709     NoCapture<ArgIndex<2>>]>;
1710def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
1711    [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1712     llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1713    []>;
1714def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
1715    [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1716     llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1717    []>;
1718def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
1719def int_coro_id_async : Intrinsic<[llvm_token_ty],
1720  [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty],
1721  []>;
1722def int_coro_async_context_alloc : Intrinsic<[llvm_ptr_ty],
1723    [llvm_ptr_ty, llvm_ptr_ty],
1724    []>;
1725def int_coro_async_context_dealloc : Intrinsic<[],
1726    [llvm_ptr_ty],
1727    []>;
1728def int_coro_async_resume : Intrinsic<[llvm_ptr_ty],
1729    [],
1730    [IntrNoMerge]>;
1731def int_coro_async_size_replace : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>;
1732def int_coro_suspend_async
1733    : Intrinsic<[llvm_any_ty],
1734                [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty],
1735                [IntrNoMerge]>;
1736def int_coro_prepare_async : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1737                                       [IntrNoMem]>;
1738def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1739                               [WriteOnly<ArgIndex<1>>]>;
1740def int_coro_begin_custom_abi : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty, llvm_i32_ty],
1741                               [WriteOnly<ArgIndex<1>>]>;
1742def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1743                              [IntrReadMem, IntrArgMemOnly,
1744                               ReadOnly<ArgIndex<1>>,
1745                               NoCapture<ArgIndex<1>>]>;
1746def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_token_ty], []>;
1747def int_coro_end_results : Intrinsic<[llvm_token_ty], [llvm_vararg_ty]>;
1748def int_coro_end_async
1749    : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_vararg_ty], []>;
1750
1751def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1752def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1753def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1754def int_coro_align : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1755
1756def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], [IntrNoMerge]>;
1757def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1758def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1759def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1760                                        [IntrNoMem]>;
1761def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1762                                      [llvm_anyint_ty, llvm_i32_ty], []>;
1763def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1764def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1765
1766// Coroutine Manipulation Intrinsics.
1767
1768def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1769def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1770def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1771                              [IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
1772                               NoCapture<ArgIndex<0>>]>;
1773def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1774                                 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1775                                 [IntrNoMem, NoCapture<ArgIndex<0>>]>;
1776
1777def int_coro_await_suspend_void : Intrinsic<[],
1778                                       [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1779                                       [Throws]>;
1780
1781def int_coro_await_suspend_bool : Intrinsic<[llvm_i1_ty],
1782                                            [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1783                                            [Throws]>;
1784
1785def int_coro_await_suspend_handle : Intrinsic<[],
1786                                              [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1787                                              [Throws]>;
1788
1789// Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1790
1791def int_coro_subfn_addr : DefaultAttrsIntrinsic<
1792    [llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1793    [IntrReadMem, IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
1794     NoCapture<ArgIndex<0>>]>;
1795
1796///===-------------------------- Other Intrinsics --------------------------===//
1797//
1798// TODO: We should introduce a new memory kind fo traps (and other side effects
1799//       we only model to keep things alive).
1800def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold, IntrInaccessibleMemOnly,
1801               IntrWriteMem]>, ClangBuiltin<"__builtin_trap">;
1802def int_debugtrap : Intrinsic<[]>,
1803                    ClangBuiltin<"__builtin_debugtrap">;
1804def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],
1805                              [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>;
1806
1807// Return true if ubsan check is allowed.
1808def int_allow_ubsan_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i8_ty],
1809    [IntrInaccessibleMemOnly, IntrWriteMem, ImmArg<ArgIndex<0>>, NoUndef<RetIndex>]>;
1810
1811// Return true if runtime check is allowed.
1812def int_allow_runtime_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_metadata_ty],
1813    [IntrInaccessibleMemOnly, IntrWriteMem, NoUndef<RetIndex>]>,
1814    ClangBuiltin<"__builtin_allow_runtime_check">;
1815
1816// Support for dynamic deoptimization (or de-specialization)
1817def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1818                                            [Throws]>;
1819
1820// Support for speculative runtime guards
1821def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1822                                       [Throws]>;
1823
1824// Supports widenable conditions for guards represented as explicit branches.
1825def int_experimental_widenable_condition : DefaultAttrsIntrinsic<[llvm_i1_ty], [],
1826        [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable, NoUndef<RetIndex>]>;
1827
1828// NOP: calls/invokes to this intrinsic are removed by codegen
1829def int_donothing : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1830
1831// This instruction has no actual effect, though it is treated by the optimizer
1832// has having opaque side effects. This may be inserted into loops to ensure
1833// that they are not removed even if they turn out to be empty, for languages
1834// which specify that infinite loops must be preserved.
1835def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1836
1837// The pseudoprobe intrinsic works as a place holder to the block it probes.
1838// Like the sideeffect intrinsic defined above, this intrinsic is treated by the
1839// optimizer as having opaque side effects so that it won't be get rid of or moved
1840// out of the block it probes.
1841def int_pseudoprobe : DefaultAttrsIntrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
1842                                    [IntrInaccessibleMemOnly, IntrWillReturn]>;
1843
1844// Intrinsics to support half precision floating point format
1845let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1846def int_convert_to_fp16   : DefaultAttrsIntrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1847def int_convert_from_fp16 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1848}
1849
1850// Saturating floating point to integer intrinsics
1851let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1852def int_fptoui_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1853def int_fptosi_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1854}
1855
1856// Clear cache intrinsic, default to ignore (ie. emit nothing)
1857// maps to void __clear_cache() on supporting platforms
1858def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1859                                [], "llvm.clear_cache">;
1860
1861// Intrinsic to detect whether its argument is a constant.
1862def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty],
1863                                [IntrNoMem, IntrWillReturn, IntrConvergent],
1864                                "llvm.is.constant">;
1865
1866// Introduce a use of the argument without generating any code.
1867def int_fake_use : Intrinsic<[], [llvm_vararg_ty]>;
1868
1869// Intrinsic to mask out bits of a pointer.
1870// First argument must be pointer or vector of pointer. This is checked by the
1871// verifier.
1872def int_ptrmask: DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, llvm_anyint_ty],
1873                           [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1874
1875// Intrinsic to wrap a thread local variable.
1876def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>],
1877                                                    [NonNull<RetIndex>, NonNull<ArgIndex<0>>,
1878                                                     IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1879
1880def int_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1881                                            [], [IntrNoMem]>;
1882
1883//===---------------- Vector Predication Intrinsics --------------===//
1884// Memory Intrinsics
1885def int_vp_store : DefaultAttrsIntrinsic<[],
1886                             [ llvm_anyvector_ty,
1887                               llvm_anyptr_ty,
1888                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1889                               llvm_i32_ty],
1890                             [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
1891
1892def int_vp_load  : DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
1893                             [ llvm_anyptr_ty,
1894                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1895                               llvm_i32_ty],
1896                             [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
1897
1898def int_vp_gather: DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
1899                             [ LLVMVectorOfAnyPointersToElt<0>,
1900                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1901                               llvm_i32_ty],
1902                             [ IntrReadMem, IntrNoSync, IntrWillReturn]>;
1903
1904def int_vp_scatter: DefaultAttrsIntrinsic<[],
1905                             [ llvm_anyvector_ty,
1906                               LLVMVectorOfAnyPointersToElt<0>,
1907                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1908                               llvm_i32_ty],
1909                             [ IntrNoSync, IntrWillReturn ]>; // TODO allow IntrNoCapture for vectors of pointers
1910
1911// Experimental strided memory accesses
1912def int_experimental_vp_strided_store : DefaultAttrsIntrinsic<[],
1913                             [ llvm_anyvector_ty,
1914                               llvm_anyptr_ty,
1915                               llvm_anyint_ty, // Stride in bytes
1916                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1917                               llvm_i32_ty],
1918                             [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
1919
1920def int_experimental_vp_strided_load  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1921                             [ llvm_anyptr_ty,
1922                               llvm_anyint_ty, // Stride in bytes
1923                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1924                               llvm_i32_ty],
1925                             [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
1926
1927// Experimental histogram
1928def int_experimental_vector_histogram_add : DefaultAttrsIntrinsic<[],
1929                             [ llvm_anyvector_ty, // Vector of pointers
1930                               llvm_anyint_ty,    // Increment
1931                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], // Mask
1932                             [ IntrArgMemOnly ]>;
1933
1934// Experimental match
1935def int_experimental_vector_match : DefaultAttrsIntrinsic<
1936                             [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1937                             [ llvm_anyvector_ty,
1938                               llvm_anyvector_ty,
1939                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],  // Mask
1940                             [ IntrNoMem, IntrNoSync, IntrWillReturn ]>;
1941
1942// Extract based on mask bits
1943def int_experimental_vector_extract_last_active:
1944    DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1945              [llvm_anyvector_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1946               LLVMVectorElementType<0>], [IntrNoMem]>;
1947
1948// Operators
1949let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn] in {
1950  // Integer arithmetic
1951  def int_vp_add : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1952                             [ LLVMMatchType<0>,
1953                               LLVMMatchType<0>,
1954                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1955                               llvm_i32_ty]>;
1956  def int_vp_sub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1957                             [ LLVMMatchType<0>,
1958                               LLVMMatchType<0>,
1959                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1960                               llvm_i32_ty]>;
1961  def int_vp_mul  : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1962                             [ LLVMMatchType<0>,
1963                               LLVMMatchType<0>,
1964                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1965                               llvm_i32_ty]>;
1966  def int_vp_ashr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1967                             [ LLVMMatchType<0>,
1968                               LLVMMatchType<0>,
1969                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1970                               llvm_i32_ty]>;
1971  def int_vp_lshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1972                             [ LLVMMatchType<0>,
1973                               LLVMMatchType<0>,
1974                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1975                               llvm_i32_ty]>;
1976  def int_vp_shl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1977                             [ LLVMMatchType<0>,
1978                               LLVMMatchType<0>,
1979                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1980                               llvm_i32_ty]>;
1981  def int_vp_or : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1982                             [ LLVMMatchType<0>,
1983                               LLVMMatchType<0>,
1984                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1985                               llvm_i32_ty]>;
1986  def int_vp_and : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1987                             [ LLVMMatchType<0>,
1988                               LLVMMatchType<0>,
1989                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1990                               llvm_i32_ty]>;
1991  def int_vp_xor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1992                             [ LLVMMatchType<0>,
1993                               LLVMMatchType<0>,
1994                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1995                               llvm_i32_ty]>;
1996  def int_vp_sdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1997                             [ LLVMMatchType<0>,
1998                               LLVMMatchType<0>,
1999                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2000                               llvm_i32_ty]>;
2001  def int_vp_udiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2002                             [ LLVMMatchType<0>,
2003                               LLVMMatchType<0>,
2004                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2005                               llvm_i32_ty]>;
2006  def int_vp_srem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2007                             [ LLVMMatchType<0>,
2008                               LLVMMatchType<0>,
2009                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2010                               llvm_i32_ty]>;
2011  def int_vp_urem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2012                             [ LLVMMatchType<0>,
2013                               LLVMMatchType<0>,
2014                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2015                               llvm_i32_ty]>;
2016  def int_vp_abs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2017                             [ LLVMMatchType<0>,
2018                               llvm_i1_ty,
2019                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2020                               llvm_i32_ty]>;
2021  def int_vp_smin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2022                             [ LLVMMatchType<0>,
2023                               LLVMMatchType<0>,
2024                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2025                               llvm_i32_ty]>;
2026  def int_vp_smax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2027                             [ LLVMMatchType<0>,
2028                               LLVMMatchType<0>,
2029                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2030                               llvm_i32_ty]>;
2031  def int_vp_umin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2032                             [ LLVMMatchType<0>,
2033                               LLVMMatchType<0>,
2034                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2035                               llvm_i32_ty]>;
2036  def int_vp_umax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2037                             [ LLVMMatchType<0>,
2038                               LLVMMatchType<0>,
2039                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2040                               llvm_i32_ty]>;
2041  def int_vp_bswap : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2042                             [ LLVMMatchType<0>,
2043                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2044                               llvm_i32_ty]>;
2045  def int_vp_bitreverse : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2046                             [ LLVMMatchType<0>,
2047                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2048                               llvm_i32_ty]>;
2049  def int_vp_ctpop : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2050                             [ LLVMMatchType<0>,
2051                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2052                               llvm_i32_ty]>;
2053  def int_vp_fshl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2054                             [ LLVMMatchType<0>,
2055                               LLVMMatchType<0>,
2056                               LLVMMatchType<0>,
2057                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2058                               llvm_i32_ty]>;
2059  def int_vp_fshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2060                             [ LLVMMatchType<0>,
2061                               LLVMMatchType<0>,
2062                               LLVMMatchType<0>,
2063                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2064                               llvm_i32_ty]>;
2065  def int_vp_sadd_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2066                             [ LLVMMatchType<0>,
2067                               LLVMMatchType<0>,
2068                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2069                               llvm_i32_ty]>;
2070  def int_vp_uadd_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2071                             [ LLVMMatchType<0>,
2072                               LLVMMatchType<0>,
2073                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2074                               llvm_i32_ty]>;
2075  def int_vp_ssub_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2076                             [ LLVMMatchType<0>,
2077                               LLVMMatchType<0>,
2078                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2079                               llvm_i32_ty]>;
2080  def int_vp_usub_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2081                             [ LLVMMatchType<0>,
2082                               LLVMMatchType<0>,
2083                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2084                               llvm_i32_ty]>;
2085
2086  // Floating-point arithmetic
2087  def int_vp_fadd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2088                             [ LLVMMatchType<0>,
2089                               LLVMMatchType<0>,
2090                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2091                               llvm_i32_ty]>;
2092  def int_vp_fsub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2093                             [ LLVMMatchType<0>,
2094                               LLVMMatchType<0>,
2095                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2096                               llvm_i32_ty]>;
2097  def int_vp_fmul  : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2098                             [ LLVMMatchType<0>,
2099                               LLVMMatchType<0>,
2100                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2101                               llvm_i32_ty]>;
2102  def int_vp_fdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2103                             [ LLVMMatchType<0>,
2104                               LLVMMatchType<0>,
2105                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2106                               llvm_i32_ty]>;
2107  def int_vp_frem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2108                             [ LLVMMatchType<0>,
2109                               LLVMMatchType<0>,
2110                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2111                               llvm_i32_ty]>;
2112  def int_vp_fneg : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2113                             [ LLVMMatchType<0>,
2114                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2115                               llvm_i32_ty]>;
2116  def int_vp_fabs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2117                             [ LLVMMatchType<0>,
2118                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2119                               llvm_i32_ty]>;
2120  def int_vp_sqrt : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2121                             [ LLVMMatchType<0>,
2122                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2123                               llvm_i32_ty]>;
2124  def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2125                             [ LLVMMatchType<0>,
2126                               LLVMMatchType<0>,
2127                               LLVMMatchType<0>,
2128                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2129                               llvm_i32_ty]>;
2130  def int_vp_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2131                             [ LLVMMatchType<0>,
2132                               LLVMMatchType<0>,
2133                               LLVMMatchType<0>,
2134                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2135                               llvm_i32_ty]>;
2136  def int_vp_minnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2137                             [ LLVMMatchType<0>,
2138                               LLVMMatchType<0>,
2139                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2140                               llvm_i32_ty]>;
2141  def int_vp_maxnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2142                             [ LLVMMatchType<0>,
2143                               LLVMMatchType<0>,
2144                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2145                               llvm_i32_ty]>;
2146  def int_vp_minimum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2147                             [ LLVMMatchType<0>,
2148                               LLVMMatchType<0>,
2149                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2150                               llvm_i32_ty]>;
2151  def int_vp_maximum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2152                             [ LLVMMatchType<0>,
2153                               LLVMMatchType<0>,
2154                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2155                               llvm_i32_ty]>;
2156  def int_vp_copysign : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2157                             [ LLVMMatchType<0>,
2158                               LLVMMatchType<0>,
2159                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2160                               llvm_i32_ty]>;
2161  def int_vp_ceil : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2162                             [ LLVMMatchType<0>,
2163                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2164                               llvm_i32_ty]>;
2165  def int_vp_floor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2166                             [ LLVMMatchType<0>,
2167                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2168                               llvm_i32_ty]>;
2169  def int_vp_round : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2170                             [ LLVMMatchType<0>,
2171                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2172                               llvm_i32_ty]>;
2173  def int_vp_roundeven : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2174                             [ LLVMMatchType<0>,
2175                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2176                               llvm_i32_ty]>;
2177  def int_vp_roundtozero : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2178                             [ LLVMMatchType<0>,
2179                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2180                               llvm_i32_ty]>;
2181  def int_vp_rint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2182                             [ LLVMMatchType<0>,
2183                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2184                               llvm_i32_ty]>;
2185  def int_vp_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2186                             [ LLVMMatchType<0>,
2187                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2188                               llvm_i32_ty]>;
2189  def int_vp_lrint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2190                             [ llvm_anyvector_ty,
2191                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2192                               llvm_i32_ty]>;
2193  def int_vp_llrint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2194                             [ llvm_anyvector_ty,
2195                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2196                               llvm_i32_ty]>;
2197
2198  // Casts
2199  def int_vp_trunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2200                             [ llvm_anyvector_ty,
2201                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2202                               llvm_i32_ty]>;
2203  def int_vp_zext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2204                             [ llvm_anyvector_ty,
2205                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2206                               llvm_i32_ty]>;
2207  def int_vp_sext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2208                             [ llvm_anyvector_ty,
2209                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2210                               llvm_i32_ty]>;
2211  def int_vp_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2212                             [ llvm_anyvector_ty,
2213                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2214                               llvm_i32_ty]>;
2215  def int_vp_fpext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2216                             [ llvm_anyvector_ty,
2217                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2218                               llvm_i32_ty]>;
2219  def int_vp_fptoui : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2220                             [ llvm_anyvector_ty,
2221                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2222                               llvm_i32_ty]>;
2223  def int_vp_fptosi : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2224                             [ llvm_anyvector_ty,
2225                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2226                               llvm_i32_ty]>;
2227  def int_vp_uitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2228                             [ llvm_anyvector_ty,
2229                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2230                               llvm_i32_ty]>;
2231  def int_vp_sitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2232                             [ llvm_anyvector_ty,
2233                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2234                               llvm_i32_ty]>;
2235  def int_vp_ptrtoint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2236                             [ llvm_anyvector_ty,
2237                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2238                               llvm_i32_ty]>;
2239  def int_vp_inttoptr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2240                             [ llvm_anyvector_ty,
2241                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2242                               llvm_i32_ty]>;
2243  // Shuffles
2244  def int_vp_select : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2245                             [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2246                               LLVMMatchType<0>,
2247                               LLVMMatchType<0>,
2248                               llvm_i32_ty]>;
2249  def int_vp_merge : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2250                             [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2251                               LLVMMatchType<0>,
2252                               LLVMMatchType<0>,
2253                               llvm_i32_ty]>;
2254
2255  // Comparisons
2256  def int_vp_fcmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
2257                             [ llvm_anyvector_ty,
2258                               LLVMMatchType<0>,
2259                               llvm_metadata_ty,
2260                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2261                               llvm_i32_ty]>;
2262  def int_vp_icmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
2263                             [ llvm_anyvector_ty,
2264                               LLVMMatchType<0>,
2265                               llvm_metadata_ty,
2266                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2267                               llvm_i32_ty]>;
2268
2269  // Reductions
2270  def int_vp_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2271                             [ LLVMVectorElementType<0>,
2272                               llvm_anyvector_ty,
2273                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2274                               llvm_i32_ty]>;
2275  def int_vp_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2276                             [ LLVMVectorElementType<0>,
2277                               llvm_anyvector_ty,
2278                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2279                               llvm_i32_ty]>;
2280  def int_vp_reduce_add  : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2281                             [ LLVMVectorElementType<0>,
2282                               llvm_anyvector_ty,
2283                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2284                               llvm_i32_ty]>;
2285  def int_vp_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2286                             [ LLVMVectorElementType<0>,
2287                               llvm_anyvector_ty,
2288                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2289                               llvm_i32_ty]>;
2290  def int_vp_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2291                             [ LLVMVectorElementType<0>,
2292                               llvm_anyvector_ty,
2293                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2294                               llvm_i32_ty]>;
2295  def int_vp_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2296                             [ LLVMVectorElementType<0>,
2297                               llvm_anyvector_ty,
2298                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2299                               llvm_i32_ty]>;
2300  def int_vp_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2301                             [ LLVMVectorElementType<0>,
2302                               llvm_anyvector_ty,
2303                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2304                               llvm_i32_ty]>;
2305  def int_vp_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2306                             [ LLVMVectorElementType<0>,
2307                               llvm_anyvector_ty,
2308                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2309                               llvm_i32_ty]>;
2310  def int_vp_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2311                             [ LLVMVectorElementType<0>,
2312                               llvm_anyvector_ty,
2313                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2314                               llvm_i32_ty]>;
2315  def int_vp_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2316                             [ LLVMVectorElementType<0>,
2317                               llvm_anyvector_ty,
2318                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2319                               llvm_i32_ty]>;
2320  def int_vp_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2321                             [ LLVMVectorElementType<0>,
2322                               llvm_anyvector_ty,
2323                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2324                               llvm_i32_ty]>;
2325  def int_vp_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2326                             [ LLVMVectorElementType<0>,
2327                               llvm_anyvector_ty,
2328                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2329                               llvm_i32_ty]>;
2330  def int_vp_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2331                             [ LLVMVectorElementType<0>,
2332                               llvm_anyvector_ty,
2333                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2334                               llvm_i32_ty]>;
2335  def int_vp_reduce_fmaximum : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2336                                 [ LLVMVectorElementType<0>,
2337                                   llvm_anyvector_ty,
2338                                   LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2339                                   llvm_i32_ty]>;
2340  def int_vp_reduce_fminimum : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2341                                 [ LLVMVectorElementType<0>,
2342                                   llvm_anyvector_ty,
2343                                   LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2344                                   llvm_i32_ty]>;
2345}
2346
2347let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<1>>] in {
2348  def int_vp_ctlz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2349                             [ LLVMMatchType<0>,
2350                               llvm_i1_ty,
2351                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2352                               llvm_i32_ty]>;
2353  def int_vp_cttz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2354                             [ LLVMMatchType<0>,
2355                               llvm_i1_ty,
2356                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2357                               llvm_i32_ty]>;
2358
2359  def int_vp_cttz_elts : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
2360                                  [ llvm_anyvector_ty,
2361                                    llvm_i1_ty,
2362                                    LLVMScalarOrSameVectorWidth<1, llvm_i1_ty>,
2363                                    llvm_i32_ty]>;
2364}
2365
2366def int_get_active_lane_mask:
2367  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2368            [llvm_anyint_ty, LLVMMatchType<1>],
2369            [IntrNoMem, IntrNoSync, IntrWillReturn]>;
2370
2371def int_experimental_get_vector_length:
2372  DefaultAttrsIntrinsic<[llvm_i32_ty],
2373                        [llvm_anyint_ty, llvm_i32_ty, llvm_i1_ty],
2374                        [IntrNoMem, IntrNoSync, IntrWillReturn,
2375                         ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
2376
2377def int_experimental_cttz_elts:
2378  DefaultAttrsIntrinsic<[llvm_anyint_ty],
2379            [llvm_anyvector_ty, llvm_i1_ty],
2380            [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
2381
2382def int_experimental_vp_splice:
2383  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2384            [LLVMMatchType<0>,
2385             LLVMMatchType<0>,
2386             llvm_i32_ty,
2387             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2388             llvm_i32_ty, llvm_i32_ty],
2389            [IntrNoMem, ImmArg<ArgIndex<2>>]>;
2390
2391def int_experimental_vp_reverse:
2392  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2393                        [LLVMMatchType<0>,
2394                         LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2395                         llvm_i32_ty],
2396                        [IntrNoMem]>;
2397
2398def int_experimental_vp_splat:
2399  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2400                        [LLVMVectorElementType<0>,
2401                         LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2402                         llvm_i32_ty],
2403                        [IntrNoMem]>;
2404
2405def int_vp_is_fpclass:
2406      DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2407                              [ llvm_anyvector_ty,
2408                                llvm_i32_ty,
2409                                LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2410                                llvm_i32_ty],
2411                              [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
2412
2413//===-------------------------- Masked Intrinsics -------------------------===//
2414//
2415def int_masked_load:
2416  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2417            [llvm_anyptr_ty, llvm_i32_ty,
2418             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
2419            [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<ArgIndex<1>>,
2420             NoCapture<ArgIndex<0>>]>;
2421
2422def int_masked_store:
2423  DefaultAttrsIntrinsic<[],
2424            [llvm_anyvector_ty, llvm_anyptr_ty,
2425             llvm_i32_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2426            [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
2427             ImmArg<ArgIndex<2>>, NoCapture<ArgIndex<1>>]>;
2428
2429def int_masked_gather:
2430  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2431            [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
2432             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
2433            [IntrReadMem, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
2434
2435def int_masked_scatter:
2436  DefaultAttrsIntrinsic<[],
2437            [llvm_anyvector_ty, LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
2438             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2439            [IntrWriteMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
2440
2441def int_masked_expandload:
2442  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2443            [llvm_ptr_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2444             LLVMMatchType<0>],
2445            [IntrReadMem, IntrWillReturn, NoCapture<ArgIndex<0>>]>;
2446
2447def int_masked_compressstore:
2448  DefaultAttrsIntrinsic<[],
2449            [llvm_anyvector_ty, llvm_ptr_ty,
2450             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2451            [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
2452             NoCapture<ArgIndex<1>>]>;
2453
2454def int_experimental_vector_compress:
2455    DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2456              [LLVMMatchType<0>, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
2457              [IntrNoMem, IntrWillReturn]>;
2458
2459// Test whether a pointer is associated with a type metadata identifier.
2460def int_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
2461                              [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
2462
2463// Safely loads a function pointer from a virtual table pointer using type metadata.
2464def int_type_checked_load : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty],
2465                                      [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
2466                                      [IntrNoMem, IntrWillReturn]>;
2467
2468// Safely loads a relative function pointer from a virtual table pointer using type metadata.
2469def int_type_checked_load_relative : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty],
2470                                      [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
2471                                      [IntrNoMem, IntrWillReturn]>;
2472
2473// Test whether a pointer is associated with a type metadata identifier. Used
2474// for public visibility classes that may later be refined to private
2475// visibility.
2476def int_public_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
2477                              [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
2478
2479// Create a branch funnel that implements an indirect call to a limited set of
2480// callees. This needs to be a musttail call.
2481def int_icall_branch_funnel : DefaultAttrsIntrinsic<[], [llvm_vararg_ty], []>;
2482
2483def int_load_relative: DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
2484                                 [IntrReadMem, IntrArgMemOnly]>;
2485
2486def int_asan_check_memaccess :
2487  Intrinsic<[],[llvm_ptr_ty, llvm_i32_ty], [ImmArg<ArgIndex<1>>]>;
2488
2489// HWASan intrinsics to test whether a pointer is addressable.
2490//===----------------------------------------------------------------------===//
2491//
2492// Variant 1) is the OG memaccess intrinsic
2493// Parameters: Shadow base (passed in a register), pointer to be checked for
2494// validity, AccessInfo (AccessInfo is defined in HWAddressSanitizer.h)
2495def int_hwasan_check_memaccess :
2496  Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
2497            [ImmArg<ArgIndex<2>>]>;
2498
2499// Variant 2) supports short granule checks
2500// Parameters: same as Variant 1
2501def int_hwasan_check_memaccess_shortgranules :
2502  Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
2503            [ImmArg<ArgIndex<2>>]>;
2504
2505// Variant 3) assumes a fixed shadow offset
2506// Parameters: Pointer to be checked for validity, AccessInfo, Shadow base
2507def int_hwasan_check_memaccess_fixedshadow :
2508  Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i64_ty],
2509            [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
2510
2511// Variant 4) supports short granule checks and assumes a fixed shadow offset
2512// Parameters: same as Variant 3
2513def int_hwasan_check_memaccess_shortgranules_fixedshadow :
2514  Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i64_ty],
2515            [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
2516
2517// Xray intrinsics
2518//===----------------------------------------------------------------------===//
2519// Custom event logging for x-ray.
2520// Takes a pointer to a string and the length of the string.
2521def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty],
2522                                     [IntrWriteMem, NoCapture<ArgIndex<0>>,
2523                                      ReadOnly<ArgIndex<0>>]>;
2524// Typed event logging for x-ray.
2525// Takes a numeric type tag, a pointer to a string and the length of the string.
2526def int_xray_typedevent : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty, llvm_i64_ty],
2527                                        [IntrWriteMem, NoCapture<ArgIndex<1>>,
2528                                         ReadOnly<ArgIndex<1>>]>;
2529//===----------------------------------------------------------------------===//
2530
2531//===------ Memory intrinsics with element-wise atomicity guarantees ------===//
2532//
2533
2534// @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
2535def int_memcpy_element_unordered_atomic
2536    : Intrinsic<[],
2537                [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
2538                [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
2539                 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
2540                 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
2541                 ImmArg<ArgIndex<3>>]>;
2542
2543// @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
2544def int_memmove_element_unordered_atomic
2545    : Intrinsic<[],
2546                [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
2547                [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
2548                 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
2549                 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
2550                 ImmArg<ArgIndex<3>>]>;
2551
2552// @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
2553def int_memset_element_unordered_atomic
2554    : Intrinsic<[], [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty],
2555                [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoSync,
2556                 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
2557                 ImmArg<ArgIndex<3>>]>;
2558
2559//===------------------------ Reduction Intrinsics ------------------------===//
2560//
2561let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
2562
2563  def int_vector_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2564                                         [LLVMVectorElementType<0>,
2565                                          llvm_anyvector_ty]>;
2566  def int_vector_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2567                                         [LLVMVectorElementType<0>,
2568                                          llvm_anyvector_ty]>;
2569  def int_vector_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2570                                        [llvm_anyvector_ty]>;
2571  def int_vector_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2572                                        [llvm_anyvector_ty]>;
2573  def int_vector_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2574                                        [llvm_anyvector_ty]>;
2575  def int_vector_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2576                                       [llvm_anyvector_ty]>;
2577  def int_vector_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2578                                        [llvm_anyvector_ty]>;
2579  def int_vector_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2580                                         [llvm_anyvector_ty]>;
2581  def int_vector_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2582                                         [llvm_anyvector_ty]>;
2583  def int_vector_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2584                                         [llvm_anyvector_ty]>;
2585  def int_vector_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2586                                         [llvm_anyvector_ty]>;
2587  def int_vector_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2588                                         [llvm_anyvector_ty]>;
2589  def int_vector_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2590                                         [llvm_anyvector_ty]>;
2591  def int_vector_reduce_fminimum: DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2592                                         [llvm_anyvector_ty]>;
2593  def int_vector_reduce_fmaximum: DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2594                                         [llvm_anyvector_ty]>;
2595}
2596
2597//===----- Matrix intrinsics ---------------------------------------------===//
2598
2599def int_matrix_transpose
2600  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2601              [LLVMMatchType<0>, llvm_i32_ty, llvm_i32_ty],
2602              [ IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>,
2603               ImmArg<ArgIndex<2>>]>;
2604
2605def int_matrix_multiply
2606  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2607              [llvm_anyvector_ty, llvm_anyvector_ty, llvm_i32_ty, llvm_i32_ty,
2608               llvm_i32_ty],
2609              [IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>,
2610               ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>]>;
2611
2612def int_matrix_column_major_load
2613  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2614              [llvm_ptr_ty, llvm_anyint_ty, llvm_i1_ty,
2615               llvm_i32_ty, llvm_i32_ty],
2616              [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrReadMem,
2617               NoCapture<ArgIndex<0>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>,
2618               ImmArg<ArgIndex<4>>]>;
2619
2620def int_matrix_column_major_store
2621  : DefaultAttrsIntrinsic<[],
2622              [llvm_anyvector_ty, llvm_ptr_ty,
2623               llvm_anyint_ty, llvm_i1_ty, llvm_i32_ty, llvm_i32_ty],
2624              [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrWriteMem,
2625               WriteOnly<ArgIndex<1>>, NoCapture<ArgIndex<1>>,
2626               ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>, ImmArg<ArgIndex<5>>]>;
2627
2628//===---------- Intrinsics to control hardware supported loops ----------===//
2629
2630// Specify that the value given is the number of iterations that the next loop
2631// will execute.
2632def int_set_loop_iterations :
2633  DefaultAttrsIntrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
2634
2635// Same as the above, but produces a value (the same as the input operand) to
2636// be fed into the loop.
2637def int_start_loop_iterations :
2638  DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], [IntrNoDuplicate]>;
2639
2640// Specify that the value given is the number of iterations that the next loop
2641// will execute. Also test that the given count is not zero, allowing it to
2642// control entry to a 'while' loop.
2643def int_test_set_loop_iterations :
2644  DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
2645
2646// Same as the above, but produces an extra value (the same as the input
2647// operand) to be fed into the loop.
2648def int_test_start_loop_iterations :
2649  DefaultAttrsIntrinsic<[llvm_anyint_ty, llvm_i1_ty], [LLVMMatchType<0>],
2650                        [IntrNoDuplicate]>;
2651
2652// Decrement loop counter by the given argument. Return false if the loop
2653// should exit.
2654def int_loop_decrement :
2655  DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
2656
2657// Decrement the first operand (the loop counter) by the second operand (the
2658// maximum number of elements processed in an iteration). Return the remaining
2659// number of iterations still to be executed. This is effectively a sub which
2660// can be used with a phi, icmp and br to control the number of iterations
2661// executed, as usual. Any optimisations are allowed to treat it is a sub, and
2662// it's scevable, so it's the backends responsibility to handle cases where it
2663// may be optimised.
2664def int_loop_decrement_reg :
2665  DefaultAttrsIntrinsic<[llvm_anyint_ty],
2666            [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoDuplicate]>;
2667
2668//===----- Intrinsics that are used to provide predicate information -----===//
2669
2670def int_ssa_copy : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>],
2671                             [IntrNoMem, Returned<ArgIndex<0>>]>;
2672
2673//===------- Intrinsics that are used to preserve debug information -------===//
2674
2675def int_preserve_array_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2676                                                [llvm_anyptr_ty, llvm_i32_ty,
2677                                                 llvm_i32_ty],
2678                                                [IntrNoMem,
2679                                                 ImmArg<ArgIndex<1>>,
2680                                                 ImmArg<ArgIndex<2>>]>;
2681def int_preserve_union_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2682                                                [llvm_anyptr_ty, llvm_i32_ty],
2683                                                [IntrNoMem,
2684                                                 ImmArg<ArgIndex<1>>]>;
2685def int_preserve_struct_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2686                                                 [llvm_anyptr_ty, llvm_i32_ty,
2687                                                  llvm_i32_ty],
2688                                                 [IntrNoMem,
2689                                                  ImmArg<ArgIndex<1>>,
2690                                                  ImmArg<ArgIndex<2>>]>;
2691def int_preserve_static_offset : DefaultAttrsIntrinsic<[llvm_ptr_ty],
2692                                                       [llvm_ptr_ty],
2693                                                       [IntrNoMem, IntrSpeculatable,
2694                                                        ReadNone <ArgIndex<0>>]>;
2695
2696//===------------ Intrinsics to perform common vector shuffles ------------===//
2697
2698def int_vector_reverse : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2699                                               [LLVMMatchType<0>],
2700                                               [IntrNoMem]>;
2701
2702def int_vector_splice : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2703                                              [LLVMMatchType<0>,
2704                                               LLVMMatchType<0>,
2705                                               llvm_i32_ty],
2706                                              [IntrNoMem, ImmArg<ArgIndex<2>>]>;
2707
2708//===---------- Intrinsics to query properties of scalable vectors --------===//
2709def int_vscale : DefaultAttrsIntrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
2710
2711//===---------- Intrinsics to perform subvector insertion/extraction ------===//
2712def int_vector_insert : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2713                                              [LLVMMatchType<0>, llvm_anyvector_ty, llvm_i64_ty],
2714                                              [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>]>;
2715
2716def int_vector_extract : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2717                                               [llvm_anyvector_ty, llvm_i64_ty],
2718                                               [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
2719
2720
2721def int_vector_interleave2   : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2722                                                     [LLVMHalfElementsVectorType<0>,
2723                                                      LLVMHalfElementsVectorType<0>],
2724                                                     [IntrNoMem]>;
2725
2726def int_vector_deinterleave2 : DefaultAttrsIntrinsic<[LLVMHalfElementsVectorType<0>,
2727                                                      LLVMHalfElementsVectorType<0>],
2728                                                     [llvm_anyvector_ty],
2729                                                     [IntrNoMem]>;
2730
2731//===-------------- Intrinsics to perform partial reduction ---------------===//
2732
2733def int_experimental_vector_partial_reduce_add : DefaultAttrsIntrinsic<[LLVMMatchType<0>],
2734                                                                       [llvm_anyvector_ty, llvm_anyvector_ty],
2735                                                                       [IntrNoMem]>;
2736
2737//===----------------- Pointer Authentication Intrinsics ------------------===//
2738//
2739
2740// Sign an unauthenticated pointer using the specified key and discriminator,
2741// passed in that order.
2742// Returns the first argument, with some known bits replaced with a signature.
2743def int_ptrauth_sign :
2744  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
2745                        [IntrNoMem, ImmArg<ArgIndex<1>>]>;
2746
2747// Authenticate a signed pointer, using the specified key and discriminator.
2748// Returns the first argument, with the signature bits removed.
2749// The signature must be valid.
2750def int_ptrauth_auth : Intrinsic<[llvm_i64_ty],
2751                                 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
2752                                 [IntrNoMem,ImmArg<ArgIndex<1>>]>;
2753
2754// Authenticate a signed pointer and resign it.
2755// The second (key) and third (discriminator) arguments specify the signing
2756// schema used for authenticating.
2757// The fourth and fifth arguments specify the schema used for signing.
2758// The signature must be valid.
2759// This is a combined form of @llvm.ptrauth.sign and @llvm.ptrauth.auth, with
2760// an additional integrity guarantee on the intermediate value.
2761def int_ptrauth_resign : Intrinsic<[llvm_i64_ty],
2762                                   [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty,
2763                                    llvm_i32_ty, llvm_i64_ty],
2764                                   [IntrNoMem, ImmArg<ArgIndex<1>>,
2765                                    ImmArg<ArgIndex<3>>]>;
2766
2767// Strip the embedded signature out of a signed pointer.
2768// The second argument specifies the key.
2769// This behaves like @llvm.ptrauth.auth, but doesn't require the signature to
2770// be valid.
2771def int_ptrauth_strip :
2772  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty],
2773                        [IntrNoMem, ImmArg<ArgIndex<1>>]>;
2774
2775// Blend a small integer discriminator with an address discriminator, producing
2776// a new discriminator value.
2777def int_ptrauth_blend :
2778  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2779
2780// Compute the signature of a value, using a given discriminator.
2781// This differs from @llvm.ptrauth.sign in that it doesn't embed the computed
2782// signature in the pointer, but instead returns the signature as a value.
2783// That allows it to be used to sign non-pointer data: in that sense, it is
2784// generic.  There is no generic @llvm.ptrauth.auth: instead, the signature
2785// can be computed using @llvm.ptrauth.sign_generic, and compared with icmp.
2786def int_ptrauth_sign_generic :
2787  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2788
2789//===----------------------------------------------------------------------===//
2790//===------- Convergence Intrinsics ---------------------------------------===//
2791
2792def int_experimental_convergence_entry
2793  : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
2794def int_experimental_convergence_anchor
2795  : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
2796def int_experimental_convergence_loop
2797  : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
2798
2799//===----------------------------------------------------------------------===//
2800// Target-specific intrinsics
2801//===----------------------------------------------------------------------===//
2802
2803include "llvm/IR/IntrinsicsPowerPC.td"
2804include "llvm/IR/IntrinsicsX86.td"
2805include "llvm/IR/IntrinsicsARM.td"
2806include "llvm/IR/IntrinsicsAArch64.td"
2807include "llvm/IR/IntrinsicsXCore.td"
2808include "llvm/IR/IntrinsicsHexagon.td"
2809include "llvm/IR/IntrinsicsNVVM.td"
2810include "llvm/IR/IntrinsicsMips.td"
2811include "llvm/IR/IntrinsicsAMDGPU.td"
2812include "llvm/IR/IntrinsicsBPF.td"
2813include "llvm/IR/IntrinsicsSystemZ.td"
2814include "llvm/IR/IntrinsicsWebAssembly.td"
2815include "llvm/IR/IntrinsicsRISCV.td"
2816include "llvm/IR/IntrinsicsSPIRV.td"
2817include "llvm/IR/IntrinsicsVE.td"
2818include "llvm/IR/IntrinsicsDirectX.td"
2819include "llvm/IR/IntrinsicsLoongArch.td"
2820
2821#endif // TEST_INTRINSICS_SUPPRESS_DEFS
2822