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