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