Intrinsics.td revision 360784
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;
21
22// Intr*Mem - Memory properties.  If no property is set, the worst case
23// is assumed (it may read and write any memory it can get access to and it may
24// have other side effects).
25
26// IntrNoMem - The intrinsic does not access memory or have any other side
27// effects.  It may be CSE'd deleted if dead, etc.
28def IntrNoMem : IntrinsicProperty;
29
30// IntrReadMem - This intrinsic only reads from memory. It does not write to
31// memory and has no other side effects. Therefore, it cannot be moved across
32// potentially aliasing stores. However, it can be reordered otherwise and can
33// be deleted if dead.
34def IntrReadMem : IntrinsicProperty;
35
36// IntrWriteMem - This intrinsic only writes to memory, but does not read from
37// memory, and has no other side effects. This means dead stores before calls
38// to this intrinsics may be removed.
39def IntrWriteMem : IntrinsicProperty;
40
41// IntrArgMemOnly - This intrinsic only accesses memory that its pointer-typed
42// argument(s) points to, but may access an unspecified amount. Other than
43// reads from and (possibly volatile) writes to memory, it has no side effects.
44def IntrArgMemOnly : IntrinsicProperty;
45
46// IntrInaccessibleMemOnly -- This intrinsic only accesses memory that is not
47// accessible by the module being compiled. This is a weaker form of IntrNoMem.
48def IntrInaccessibleMemOnly : IntrinsicProperty;
49
50// IntrInaccessibleMemOrArgMemOnly -- This intrinsic only accesses memory that
51// its pointer-typed arguments point to or memory that is not accessible
52// by the module being compiled. This is a weaker form of IntrArgMemOnly.
53def IntrInaccessibleMemOrArgMemOnly : IntrinsicProperty;
54
55// Commutative - This intrinsic is commutative: X op Y == Y op X.
56def Commutative : IntrinsicProperty;
57
58// Throws - This intrinsic can throw.
59def Throws : IntrinsicProperty;
60
61// NoCapture - The specified argument pointer is not captured by the intrinsic.
62class NoCapture<int argNo> : IntrinsicProperty {
63  int ArgNo = argNo;
64}
65
66// NoAlias - The specified argument pointer is not aliasing other "noalias" pointer
67// arguments of the intrinsic wrt. the intrinsic scope.
68class NoAlias<int argNo> : IntrinsicProperty {
69  int ArgNo = argNo;
70}
71
72// Returned - The specified argument is always the return value of the
73// intrinsic.
74class Returned<int argNo> : IntrinsicProperty {
75  int ArgNo = argNo;
76}
77
78// ImmArg - The specified argument must be an immediate.
79class ImmArg<int argNo> : IntrinsicProperty {
80  int ArgNo = argNo;
81}
82
83// ReadOnly - The specified argument pointer is not written to through the
84// pointer by the intrinsic.
85class ReadOnly<int argNo> : IntrinsicProperty {
86  int ArgNo = argNo;
87}
88
89// WriteOnly - The intrinsic does not read memory through the specified
90// argument pointer.
91class WriteOnly<int argNo> : IntrinsicProperty {
92  int ArgNo = argNo;
93}
94
95// ReadNone - The specified argument pointer is not dereferenced by the
96// intrinsic.
97class ReadNone<int argNo> : IntrinsicProperty {
98  int ArgNo = argNo;
99}
100
101def IntrNoReturn : IntrinsicProperty;
102
103def IntrWillReturn : IntrinsicProperty;
104
105// IntrCold - Calls to this intrinsic are cold.
106// Parallels the cold attribute on LLVM IR functions.
107def IntrCold : IntrinsicProperty;
108
109// IntrNoduplicate - Calls to this intrinsic cannot be duplicated.
110// Parallels the noduplicate attribute on LLVM IR functions.
111def IntrNoDuplicate : IntrinsicProperty;
112
113// IntrConvergent - Calls to this intrinsic are convergent and may not be made
114// control-dependent on any additional values.
115// Parallels the convergent attribute on LLVM IR functions.
116def IntrConvergent : IntrinsicProperty;
117
118// This property indicates that the intrinsic is safe to speculate.
119def IntrSpeculatable : IntrinsicProperty;
120
121// This property can be used to override the 'has no other side effects'
122// language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly
123// intrinsic properties.  By default, intrinsics are assumed to have side
124// effects, so this property is only necessary if you have defined one of
125// the memory properties listed above.
126// For this property, 'side effects' has the same meaning as 'side effects'
127// defined by the hasSideEffects property of the TableGen Instruction class.
128def IntrHasSideEffects : IntrinsicProperty;
129
130//===----------------------------------------------------------------------===//
131// Types used by intrinsics.
132//===----------------------------------------------------------------------===//
133
134class LLVMType<ValueType vt> {
135  ValueType VT = vt;
136  int isAny = 0;
137}
138
139class LLVMQualPointerType<LLVMType elty, int addrspace>
140  : LLVMType<iPTR>{
141  LLVMType ElTy = elty;
142  int AddrSpace = addrspace;
143}
144
145class LLVMPointerType<LLVMType elty>
146  : LLVMQualPointerType<elty, 0>;
147
148class LLVMAnyPointerType<LLVMType elty>
149  : LLVMType<iPTRAny>{
150  LLVMType ElTy = elty;
151
152  let isAny = 1;
153}
154
155// Match the type of another intrinsic parameter.  Number is an index into the
156// list of overloaded types for the intrinsic, excluding all the fixed types.
157// The Number value must refer to a previously listed type.  For example:
158//   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
159// has two overloaded types, the 2nd and 3rd arguments.  LLVMMatchType<0>
160// refers to the first overloaded type, which is the 2nd argument.
161class LLVMMatchType<int num>
162  : LLVMType<OtherVT>{
163  int Number = num;
164}
165
166// Match the type of another intrinsic parameter that is expected to be based on
167// an integral type (i.e. either iN or <N x iM>), but change the scalar size to
168// be twice as wide or half as wide as the other type.  This is only useful when
169// the intrinsic is overloaded, so the matched type should be declared as iAny.
170class LLVMExtendedType<int num> : LLVMMatchType<num>;
171class LLVMTruncatedType<int num> : LLVMMatchType<num>;
172
173// Match the scalar/vector of another intrinsic parameter but with a different
174// element type. Either both are scalars or both are vectors with the same
175// number of elements.
176class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
177  : LLVMMatchType<idx> {
178  ValueType ElTy = elty.VT;
179}
180
181class LLVMPointerTo<int num> : LLVMMatchType<num>;
182class LLVMPointerToElt<int num> : LLVMMatchType<num>;
183class LLVMVectorOfAnyPointersToElt<int num> : LLVMMatchType<num>;
184class LLVMVectorElementType<int num> : LLVMMatchType<num>;
185
186// Match the type of another intrinsic parameter that is expected to be a
187// vector type, but change the element count to be half as many
188class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
189
190// Match the type of another intrinsic parameter that is expected to be a
191// vector type (i.e. <N x iM>) but with each element subdivided to
192// form a vector with more elements that are smaller than the original.
193class LLVMSubdivide2VectorType<int num> : LLVMMatchType<num>;
194class LLVMSubdivide4VectorType<int num> : LLVMMatchType<num>;
195
196// Match the element count and bit width of another intrinsic parameter, but
197// change the element type to an integer.
198class LLVMVectorOfBitcastsToInt<int num> : LLVMMatchType<num>;
199
200def llvm_void_ty       : LLVMType<isVoid>;
201let isAny = 1 in {
202  def llvm_any_ty        : LLVMType<Any>;
203  def llvm_anyint_ty     : LLVMType<iAny>;
204  def llvm_anyfloat_ty   : LLVMType<fAny>;
205  def llvm_anyvector_ty  : LLVMType<vAny>;
206}
207def llvm_i1_ty         : LLVMType<i1>;
208def llvm_i8_ty         : LLVMType<i8>;
209def llvm_i16_ty        : LLVMType<i16>;
210def llvm_i32_ty        : LLVMType<i32>;
211def llvm_i64_ty        : LLVMType<i64>;
212def llvm_half_ty       : LLVMType<f16>;
213def llvm_float_ty      : LLVMType<f32>;
214def llvm_double_ty     : LLVMType<f64>;
215def llvm_f80_ty        : LLVMType<f80>;
216def llvm_f128_ty       : LLVMType<f128>;
217def llvm_ppcf128_ty    : LLVMType<ppcf128>;
218def llvm_ptr_ty        : LLVMPointerType<llvm_i8_ty>;             // i8*
219def llvm_ptrptr_ty     : LLVMPointerType<llvm_ptr_ty>;            // i8**
220def llvm_anyptr_ty     : LLVMAnyPointerType<llvm_i8_ty>;          // (space)i8*
221def llvm_empty_ty      : LLVMType<OtherVT>;                       // { }
222def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>;          // { }*
223def llvm_metadata_ty   : LLVMType<MetadataVT>;                    // !{...}
224def llvm_token_ty      : LLVMType<token>;                         // token
225
226def llvm_x86mmx_ty     : LLVMType<x86mmx>;
227def llvm_ptrx86mmx_ty  : LLVMPointerType<llvm_x86mmx_ty>;         // <1 x i64>*
228
229def llvm_v2i1_ty       : LLVMType<v2i1>;     //   2 x i1
230def llvm_v4i1_ty       : LLVMType<v4i1>;     //   4 x i1
231def llvm_v8i1_ty       : LLVMType<v8i1>;     //   8 x i1
232def llvm_v16i1_ty      : LLVMType<v16i1>;    //  16 x i1
233def llvm_v32i1_ty      : LLVMType<v32i1>;    //  32 x i1
234def llvm_v64i1_ty      : LLVMType<v64i1>;    //  64 x i1
235def llvm_v512i1_ty     : LLVMType<v512i1>;   // 512 x i1
236def llvm_v1024i1_ty    : LLVMType<v1024i1>;  //1024 x i1
237
238def llvm_v1i8_ty       : LLVMType<v1i8>;     //  1 x i8
239def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8
240def llvm_v4i8_ty       : LLVMType<v4i8>;     //  4 x i8
241def llvm_v8i8_ty       : LLVMType<v8i8>;     //  8 x i8
242def llvm_v16i8_ty      : LLVMType<v16i8>;    // 16 x i8
243def llvm_v32i8_ty      : LLVMType<v32i8>;    // 32 x i8
244def llvm_v64i8_ty      : LLVMType<v64i8>;    // 64 x i8
245def llvm_v128i8_ty     : LLVMType<v128i8>;   //128 x i8
246def llvm_v256i8_ty     : LLVMType<v256i8>;   //256 x i8
247
248def llvm_v1i16_ty      : LLVMType<v1i16>;    //  1 x i16
249def llvm_v2i16_ty      : LLVMType<v2i16>;    //  2 x i16
250def llvm_v4i16_ty      : LLVMType<v4i16>;    //  4 x i16
251def llvm_v8i16_ty      : LLVMType<v8i16>;    //  8 x i16
252def llvm_v16i16_ty     : LLVMType<v16i16>;   // 16 x i16
253def llvm_v32i16_ty     : LLVMType<v32i16>;   // 32 x i16
254def llvm_v64i16_ty     : LLVMType<v64i16>;   // 64 x i16
255def llvm_v128i16_ty    : LLVMType<v128i16>;  //128 x i16
256
257def llvm_v1i32_ty      : LLVMType<v1i32>;    //  1 x i32
258def llvm_v2i32_ty      : LLVMType<v2i32>;    //  2 x i32
259def llvm_v4i32_ty      : LLVMType<v4i32>;    //  4 x i32
260def llvm_v8i32_ty      : LLVMType<v8i32>;    //  8 x i32
261def llvm_v16i32_ty     : LLVMType<v16i32>;   // 16 x i32
262def llvm_v32i32_ty     : LLVMType<v32i32>;   // 32 x i32
263def llvm_v64i32_ty     : LLVMType<v64i32>;   // 64 x i32
264
265def llvm_v1i64_ty      : LLVMType<v1i64>;    //  1 x i64
266def llvm_v2i64_ty      : LLVMType<v2i64>;    //  2 x i64
267def llvm_v4i64_ty      : LLVMType<v4i64>;    //  4 x i64
268def llvm_v8i64_ty      : LLVMType<v8i64>;    //  8 x i64
269def llvm_v16i64_ty     : LLVMType<v16i64>;   // 16 x i64
270def llvm_v32i64_ty     : LLVMType<v32i64>;   // 32 x i64
271
272def llvm_v1i128_ty     : LLVMType<v1i128>;   //  1 x i128
273
274def llvm_v2f16_ty      : LLVMType<v2f16>;    //  2 x half (__fp16)
275def llvm_v4f16_ty      : LLVMType<v4f16>;    //  4 x half (__fp16)
276def llvm_v8f16_ty      : LLVMType<v8f16>;    //  8 x half (__fp16)
277def llvm_v1f32_ty      : LLVMType<v1f32>;    //  1 x float
278def llvm_v2f32_ty      : LLVMType<v2f32>;    //  2 x float
279def llvm_v4f32_ty      : LLVMType<v4f32>;    //  4 x float
280def llvm_v8f32_ty      : LLVMType<v8f32>;    //  8 x float
281def llvm_v16f32_ty     : LLVMType<v16f32>;   // 16 x float
282def llvm_v32f32_ty     : LLVMType<v32f32>;   // 32 x float
283def llvm_v1f64_ty      : LLVMType<v1f64>;    //  1 x double
284def llvm_v2f64_ty      : LLVMType<v2f64>;    //  2 x double
285def llvm_v4f64_ty      : LLVMType<v4f64>;    //  4 x double
286def llvm_v8f64_ty      : LLVMType<v8f64>;    //  8 x double
287
288def llvm_vararg_ty     : LLVMType<isVoid>;   // this means vararg here
289
290//===----------------------------------------------------------------------===//
291// Intrinsic Definitions.
292//===----------------------------------------------------------------------===//
293
294// Intrinsic class - This is used to define one LLVM intrinsic.  The name of the
295// intrinsic definition should start with "int_", then match the LLVM intrinsic
296// name with the "llvm." prefix removed, and all "."s turned into "_"s.  For
297// example, llvm.bswap.i16 -> int_bswap_i16.
298//
299//  * RetTypes is a list containing the return types expected for the
300//    intrinsic.
301//  * ParamTypes is a list containing the parameter types expected for the
302//    intrinsic.
303//  * Properties can be set to describe the behavior of the intrinsic.
304//
305class Intrinsic<list<LLVMType> ret_types,
306                list<LLVMType> param_types = [],
307                list<IntrinsicProperty> intr_properties = [],
308                string name = "",
309                list<SDNodeProperty> sd_properties = []> : SDPatternOperator {
310  string LLVMName = name;
311  string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
312  list<LLVMType> RetTypes = ret_types;
313  list<LLVMType> ParamTypes = param_types;
314  list<IntrinsicProperty> IntrProperties = intr_properties;
315  let Properties = sd_properties;
316
317  bit isTarget = 0;
318}
319
320/// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this
321/// specifies the name of the builtin.  This provides automatic CBE and CFE
322/// support.
323class GCCBuiltin<string name> {
324  string GCCBuiltinName = name;
325}
326
327class MSBuiltin<string name> {
328  string MSBuiltinName = name;
329}
330
331
332//===--------------- Variable Argument Handling Intrinsics ----------------===//
333//
334
335def int_vastart : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
336def int_vacopy  : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
337                            "llvm.va_copy">;
338def int_vaend   : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
339
340//===------------------- Garbage Collection Intrinsics --------------------===//
341//
342def int_gcroot  : Intrinsic<[],
343                            [llvm_ptrptr_ty, llvm_ptr_ty]>;
344def int_gcread  : Intrinsic<[llvm_ptr_ty],
345                            [llvm_ptr_ty, llvm_ptrptr_ty],
346                            [IntrReadMem, IntrArgMemOnly]>;
347def int_gcwrite : Intrinsic<[],
348                            [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
349                            [IntrArgMemOnly, NoCapture<1>, NoCapture<2>]>;
350
351//===------------------- ObjC ARC runtime Intrinsics --------------------===//
352//
353// Note these are to support the Objective-C ARC optimizer which wants to
354// eliminate retain and releases where possible.
355
356def int_objc_autorelease                    : Intrinsic<[llvm_ptr_ty],
357                                                        [llvm_ptr_ty]>;
358def int_objc_autoreleasePoolPop             : Intrinsic<[], [llvm_ptr_ty]>;
359def int_objc_autoreleasePoolPush            : Intrinsic<[llvm_ptr_ty], []>;
360def int_objc_autoreleaseReturnValue         : Intrinsic<[llvm_ptr_ty],
361                                                        [llvm_ptr_ty]>;
362def int_objc_copyWeak                       : Intrinsic<[],
363                                                        [llvm_ptrptr_ty,
364                                                         llvm_ptrptr_ty]>;
365def int_objc_destroyWeak                    : Intrinsic<[], [llvm_ptrptr_ty]>;
366def int_objc_initWeak                       : Intrinsic<[llvm_ptr_ty],
367                                                        [llvm_ptrptr_ty,
368                                                         llvm_ptr_ty]>;
369def int_objc_loadWeak                       : Intrinsic<[llvm_ptr_ty],
370                                                        [llvm_ptrptr_ty]>;
371def int_objc_loadWeakRetained               : Intrinsic<[llvm_ptr_ty],
372                                                        [llvm_ptrptr_ty]>;
373def int_objc_moveWeak                       : Intrinsic<[],
374                                                        [llvm_ptrptr_ty,
375                                                         llvm_ptrptr_ty]>;
376def int_objc_release                        : Intrinsic<[], [llvm_ptr_ty]>;
377def int_objc_retain                         : Intrinsic<[llvm_ptr_ty],
378                                                        [llvm_ptr_ty]>;
379def int_objc_retainAutorelease              : Intrinsic<[llvm_ptr_ty],
380                                                        [llvm_ptr_ty]>;
381def int_objc_retainAutoreleaseReturnValue   : Intrinsic<[llvm_ptr_ty],
382                                                        [llvm_ptr_ty]>;
383def int_objc_retainAutoreleasedReturnValue  : Intrinsic<[llvm_ptr_ty],
384                                                        [llvm_ptr_ty]>;
385def int_objc_retainBlock                    : Intrinsic<[llvm_ptr_ty],
386                                                        [llvm_ptr_ty]>;
387def int_objc_storeStrong                    : Intrinsic<[],
388                                                        [llvm_ptrptr_ty,
389                                                         llvm_ptr_ty]>;
390def int_objc_storeWeak                      : Intrinsic<[llvm_ptr_ty],
391                                                        [llvm_ptrptr_ty,
392                                                         llvm_ptr_ty]>;
393def int_objc_clang_arc_use                  : Intrinsic<[],
394                                                        [llvm_vararg_ty]>;
395def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
396                                                            [llvm_ptr_ty]>;
397def int_objc_retainedObject                 : Intrinsic<[llvm_ptr_ty],
398                                                        [llvm_ptr_ty]>;
399def int_objc_unretainedObject               : Intrinsic<[llvm_ptr_ty],
400                                                        [llvm_ptr_ty]>;
401def int_objc_unretainedPointer              : Intrinsic<[llvm_ptr_ty],
402                                                        [llvm_ptr_ty]>;
403def int_objc_retain_autorelease             : Intrinsic<[llvm_ptr_ty],
404                                                        [llvm_ptr_ty]>;
405def int_objc_sync_enter                     : Intrinsic<[llvm_i32_ty],
406                                                        [llvm_ptr_ty]>;
407def int_objc_sync_exit                      : Intrinsic<[llvm_i32_ty],
408                                                        [llvm_ptr_ty]>;
409def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
410                                                        [llvm_ptrptr_ty,
411                                                         llvm_ptrptr_ty]>;
412def int_objc_arc_annotation_topdown_bbend   : Intrinsic<[],
413                                                        [llvm_ptrptr_ty,
414                                                         llvm_ptrptr_ty]>;
415def int_objc_arc_annotation_bottomup_bbstart  : Intrinsic<[],
416                                                          [llvm_ptrptr_ty,
417                                                           llvm_ptrptr_ty]>;
418def int_objc_arc_annotation_bottomup_bbend  : Intrinsic<[],
419                                                        [llvm_ptrptr_ty,
420                                                         llvm_ptrptr_ty]>;
421
422
423//===--------------------- Code Generator Intrinsics ----------------------===//
424//
425def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
426def int_addressofreturnaddress : Intrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
427def int_frameaddress : Intrinsic<[llvm_anyptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
428def int_sponentry  : Intrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
429def int_read_register  : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
430                                   [IntrReadMem], "llvm.read_register">;
431def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
432                                   [], "llvm.write_register">;
433
434// Gets the address of the local variable area. This is typically a copy of the
435// stack, frame, or base pointer depending on the type of prologue.
436def int_localaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
437
438// Escapes local variables to allow access from other functions.
439def int_localescape : Intrinsic<[], [llvm_vararg_ty]>;
440
441// Given a function and the localaddress of a parent frame, returns a pointer
442// to an escaped allocation indicated by the index.
443def int_localrecover : Intrinsic<[llvm_ptr_ty],
444                                 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
445                                 [IntrNoMem, ImmArg<2>]>;
446
447// Given the frame pointer passed into an SEH filter function, returns a
448// pointer to the local variable area suitable for use with llvm.localrecover.
449def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty],
450                                 [llvm_ptr_ty, llvm_ptr_ty],
451                                 [IntrNoMem]>;
452
453// Note: we treat stacksave/stackrestore as writemem because we don't otherwise
454// model their dependencies on allocas.
455def int_stacksave     : Intrinsic<[llvm_ptr_ty]>,
456                        GCCBuiltin<"__builtin_stack_save">;
457def int_stackrestore  : Intrinsic<[], [llvm_ptr_ty]>,
458                        GCCBuiltin<"__builtin_stack_restore">;
459
460def int_get_dynamic_area_offset : Intrinsic<[llvm_anyint_ty]>;
461
462def int_thread_pointer : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
463                         GCCBuiltin<"__builtin_thread_pointer">;
464
465// IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
466// necessary for prefetch, however it does conveniently prevent the prefetch
467// from being reordered overly much with respect to nearby access to the same
468// memory while not impeding optimization.
469def int_prefetch
470    : Intrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
471                [ IntrInaccessibleMemOrArgMemOnly, IntrWillReturn, ReadOnly<0>, NoCapture<0>,
472                  ImmArg<1>, ImmArg<2>]>;
473def int_pcmarker      : Intrinsic<[], [llvm_i32_ty]>;
474
475def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
476
477// The assume intrinsic is marked as arbitrarily writing so that proper
478// control dependencies will be maintained.
479def int_assume        : Intrinsic<[], [llvm_i1_ty], [IntrWillReturn]>;
480
481// Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
482// guard to the correct place on the stack frame.
483def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
484def int_stackguard : Intrinsic<[llvm_ptr_ty], [], []>;
485
486// A counter increment for instrumentation based profiling.
487def int_instrprof_increment : Intrinsic<[],
488                                        [llvm_ptr_ty, llvm_i64_ty,
489                                         llvm_i32_ty, llvm_i32_ty],
490                                        []>;
491
492// A counter increment with step for instrumentation based profiling.
493def int_instrprof_increment_step : Intrinsic<[],
494                                        [llvm_ptr_ty, llvm_i64_ty,
495                                         llvm_i32_ty, llvm_i32_ty, llvm_i64_ty],
496                                        []>;
497
498// A call to profile runtime for value profiling of target expressions
499// through instrumentation based profiling.
500def int_instrprof_value_profile : Intrinsic<[],
501                                            [llvm_ptr_ty, llvm_i64_ty,
502                                             llvm_i64_ty, llvm_i32_ty,
503                                             llvm_i32_ty],
504                                            []>;
505
506//===------------------- Standard C Library Intrinsics --------------------===//
507//
508
509def int_memcpy  : Intrinsic<[],
510                             [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
511                              llvm_i1_ty],
512                            [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>,
513                             NoAlias<0>, NoAlias<1>, WriteOnly<0>, ReadOnly<1>, ImmArg<3>]>;
514def int_memmove : Intrinsic<[],
515                            [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
516                             llvm_i1_ty],
517                            [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>,
518                             ReadOnly<1>, ImmArg<3>]>;
519def int_memset  : Intrinsic<[],
520                            [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
521                             llvm_i1_ty],
522                            [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>,
523                            ImmArg<3>]>;
524
525// FIXME: Add version of these floating point intrinsics which allow non-default
526// rounding modes and FP exception handling.
527
528let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
529  def int_fma  : Intrinsic<[llvm_anyfloat_ty],
530                           [LLVMMatchType<0>, LLVMMatchType<0>,
531                            LLVMMatchType<0>]>;
532  def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
533                              [LLVMMatchType<0>, LLVMMatchType<0>,
534                               LLVMMatchType<0>]>;
535
536  // These functions do not read memory, but are sensitive to the
537  // rounding mode. LLVM purposely does not model changes to the FP
538  // environment so they can be treated as readnone.
539  def int_sqrt : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
540  def int_powi : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_i32_ty]>;
541  def int_sin  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
542  def int_cos  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
543  def int_pow  : Intrinsic<[llvm_anyfloat_ty],
544                           [LLVMMatchType<0>, LLVMMatchType<0>]>;
545  def int_log  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
546  def int_log10: Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
547  def int_log2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
548  def int_exp  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
549  def int_exp2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
550  def int_fabs : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
551  def int_copysign : Intrinsic<[llvm_anyfloat_ty],
552                               [LLVMMatchType<0>, LLVMMatchType<0>]>;
553  def int_floor : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
554  def int_ceil  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
555  def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
556  def int_rint  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
557  def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
558  def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
559  def int_canonicalize : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
560                                   [IntrNoMem]>;
561
562  def int_lround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
563  def int_llround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
564  def int_lrint : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
565  def int_llrint : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
566}
567
568def int_minnum : Intrinsic<[llvm_anyfloat_ty],
569  [LLVMMatchType<0>, LLVMMatchType<0>],
570  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
571>;
572def int_maxnum : Intrinsic<[llvm_anyfloat_ty],
573  [LLVMMatchType<0>, LLVMMatchType<0>],
574  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
575>;
576def int_minimum : Intrinsic<[llvm_anyfloat_ty],
577  [LLVMMatchType<0>, LLVMMatchType<0>],
578  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
579>;
580def int_maximum : Intrinsic<[llvm_anyfloat_ty],
581  [LLVMMatchType<0>, LLVMMatchType<0>],
582  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
583>;
584
585// Internal interface for object size checking
586def int_objectsize : Intrinsic<[llvm_anyint_ty],
587                               [llvm_anyptr_ty, llvm_i1_ty,
588                                llvm_i1_ty, llvm_i1_ty],
589                               [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>, ImmArg<2>, ImmArg<3>]>,
590                               GCCBuiltin<"__builtin_object_size">;
591
592//===--------------- Constrained Floating Point Intrinsics ----------------===//
593//
594
595let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
596  def int_experimental_constrained_fadd : Intrinsic<[ llvm_anyfloat_ty ],
597                                                    [ LLVMMatchType<0>,
598                                                      LLVMMatchType<0>,
599                                                      llvm_metadata_ty,
600                                                      llvm_metadata_ty ]>;
601  def int_experimental_constrained_fsub : Intrinsic<[ llvm_anyfloat_ty ],
602                                                    [ LLVMMatchType<0>,
603                                                      LLVMMatchType<0>,
604                                                      llvm_metadata_ty,
605                                                      llvm_metadata_ty ]>;
606  def int_experimental_constrained_fmul : Intrinsic<[ llvm_anyfloat_ty ],
607                                                    [ LLVMMatchType<0>,
608                                                      LLVMMatchType<0>,
609                                                      llvm_metadata_ty,
610                                                      llvm_metadata_ty ]>;
611  def int_experimental_constrained_fdiv : Intrinsic<[ llvm_anyfloat_ty ],
612                                                    [ LLVMMatchType<0>,
613                                                      LLVMMatchType<0>,
614                                                      llvm_metadata_ty,
615                                                      llvm_metadata_ty ]>;
616  def int_experimental_constrained_frem : Intrinsic<[ llvm_anyfloat_ty ],
617                                                    [ LLVMMatchType<0>,
618                                                      LLVMMatchType<0>,
619                                                      llvm_metadata_ty,
620                                                      llvm_metadata_ty ]>;
621
622  def int_experimental_constrained_fma : Intrinsic<[ llvm_anyfloat_ty ],
623                                                    [ LLVMMatchType<0>,
624                                                      LLVMMatchType<0>,
625                                                      LLVMMatchType<0>,
626                                                      llvm_metadata_ty,
627                                                      llvm_metadata_ty ]>;
628
629  def int_experimental_constrained_fptosi : Intrinsic<[ llvm_anyint_ty ],
630                                                    [ llvm_anyfloat_ty,
631                                                      llvm_metadata_ty ]>;
632
633  def int_experimental_constrained_fptoui : Intrinsic<[ llvm_anyint_ty ],
634                                                    [ llvm_anyfloat_ty,
635                                                      llvm_metadata_ty ]>;
636
637  def int_experimental_constrained_sitofp : Intrinsic<[ llvm_anyfloat_ty ],
638                                                       [ llvm_anyint_ty,
639                                                         llvm_metadata_ty,
640                                                         llvm_metadata_ty ]>;
641
642  def int_experimental_constrained_uitofp : Intrinsic<[ llvm_anyfloat_ty ],
643                                                       [ llvm_anyint_ty,
644                                                         llvm_metadata_ty,
645                                                         llvm_metadata_ty ]>;
646
647  def int_experimental_constrained_fptrunc : Intrinsic<[ llvm_anyfloat_ty ],
648                                                       [ llvm_anyfloat_ty,
649                                                         llvm_metadata_ty,
650                                                         llvm_metadata_ty ]>;
651
652  def int_experimental_constrained_fpext : Intrinsic<[ llvm_anyfloat_ty ],
653                                                     [ llvm_anyfloat_ty,
654                                                       llvm_metadata_ty ]>;
655
656  // These intrinsics are sensitive to the rounding mode so we need constrained
657  // versions of each of them.  When strict rounding and exception control are
658  // not required the non-constrained versions of these intrinsics should be
659  // used.
660  def int_experimental_constrained_sqrt : Intrinsic<[ llvm_anyfloat_ty ],
661                                                    [ LLVMMatchType<0>,
662                                                      llvm_metadata_ty,
663                                                      llvm_metadata_ty ]>;
664  def int_experimental_constrained_powi : Intrinsic<[ llvm_anyfloat_ty ],
665                                                    [ LLVMMatchType<0>,
666                                                      llvm_i32_ty,
667                                                      llvm_metadata_ty,
668                                                      llvm_metadata_ty ]>;
669  def int_experimental_constrained_sin  : Intrinsic<[ llvm_anyfloat_ty ],
670                                                    [ LLVMMatchType<0>,
671                                                      llvm_metadata_ty,
672                                                      llvm_metadata_ty ]>;
673  def int_experimental_constrained_cos  : Intrinsic<[ llvm_anyfloat_ty ],
674                                                    [ LLVMMatchType<0>,
675                                                      llvm_metadata_ty,
676                                                      llvm_metadata_ty ]>;
677  def int_experimental_constrained_pow  : Intrinsic<[ llvm_anyfloat_ty ],
678                                                    [ LLVMMatchType<0>,
679                                                      LLVMMatchType<0>,
680                                                      llvm_metadata_ty,
681                                                      llvm_metadata_ty ]>;
682  def int_experimental_constrained_log  : Intrinsic<[ llvm_anyfloat_ty ],
683                                                    [ LLVMMatchType<0>,
684                                                      llvm_metadata_ty,
685                                                      llvm_metadata_ty ]>;
686  def int_experimental_constrained_log10: Intrinsic<[ llvm_anyfloat_ty ],
687                                                    [ LLVMMatchType<0>,
688                                                      llvm_metadata_ty,
689                                                      llvm_metadata_ty ]>;
690  def int_experimental_constrained_log2 : Intrinsic<[ llvm_anyfloat_ty ],
691                                                    [ LLVMMatchType<0>,
692                                                      llvm_metadata_ty,
693                                                      llvm_metadata_ty ]>;
694  def int_experimental_constrained_exp  : Intrinsic<[ llvm_anyfloat_ty ],
695                                                    [ LLVMMatchType<0>,
696                                                      llvm_metadata_ty,
697                                                      llvm_metadata_ty ]>;
698  def int_experimental_constrained_exp2 : Intrinsic<[ llvm_anyfloat_ty ],
699                                                    [ LLVMMatchType<0>,
700                                                      llvm_metadata_ty,
701                                                      llvm_metadata_ty ]>;
702  def int_experimental_constrained_rint  : Intrinsic<[ llvm_anyfloat_ty ],
703                                                     [ LLVMMatchType<0>,
704                                                       llvm_metadata_ty,
705                                                       llvm_metadata_ty ]>;
706  def int_experimental_constrained_nearbyint : Intrinsic<[ llvm_anyfloat_ty ],
707                                                         [ LLVMMatchType<0>,
708                                                           llvm_metadata_ty,
709                                                           llvm_metadata_ty ]>;
710  def int_experimental_constrained_lrint : Intrinsic<[ llvm_anyint_ty ],
711                                                     [ llvm_anyfloat_ty,
712                                                       llvm_metadata_ty,
713                                                       llvm_metadata_ty ]>;
714  def int_experimental_constrained_llrint : Intrinsic<[ llvm_anyint_ty ],
715                                                      [ llvm_anyfloat_ty,
716                                                        llvm_metadata_ty,
717                                                        llvm_metadata_ty ]>;
718  def int_experimental_constrained_maxnum : Intrinsic<[ llvm_anyfloat_ty ],
719                                                      [ LLVMMatchType<0>,
720                                                        LLVMMatchType<0>,
721                                                        llvm_metadata_ty ]>;
722  def int_experimental_constrained_minnum : Intrinsic<[ llvm_anyfloat_ty ],
723                                                      [ LLVMMatchType<0>,
724                                                        LLVMMatchType<0>,
725                                                        llvm_metadata_ty ]>;
726  def int_experimental_constrained_maximum : Intrinsic<[ llvm_anyfloat_ty ],
727                                                       [ LLVMMatchType<0>,
728                                                         LLVMMatchType<0>,
729                                                         llvm_metadata_ty ]>;
730  def int_experimental_constrained_minimum : Intrinsic<[ llvm_anyfloat_ty ],
731                                                       [ LLVMMatchType<0>,
732                                                         LLVMMatchType<0>,
733                                                         llvm_metadata_ty ]>;
734  def int_experimental_constrained_ceil : Intrinsic<[ llvm_anyfloat_ty ],
735                                                    [ LLVMMatchType<0>,
736                                                      llvm_metadata_ty ]>;
737  def int_experimental_constrained_floor : Intrinsic<[ llvm_anyfloat_ty ],
738                                                     [ LLVMMatchType<0>,
739                                                       llvm_metadata_ty ]>;
740  def int_experimental_constrained_lround : Intrinsic<[ llvm_anyint_ty ],
741                                                      [ llvm_anyfloat_ty,
742                                                        llvm_metadata_ty ]>;
743  def int_experimental_constrained_llround : Intrinsic<[ llvm_anyint_ty ],
744                                                       [ llvm_anyfloat_ty,
745                                                         llvm_metadata_ty ]>;
746  def int_experimental_constrained_round : Intrinsic<[ llvm_anyfloat_ty ],
747                                                     [ LLVMMatchType<0>,
748                                                      llvm_metadata_ty ]>;
749  def int_experimental_constrained_trunc : Intrinsic<[ llvm_anyfloat_ty ],
750                                                     [ LLVMMatchType<0>,
751                                                       llvm_metadata_ty ]>;
752
753  // Constrained floating-point comparison (quiet and signaling variants).
754  // Third operand is the predicate represented as a metadata string.
755  def int_experimental_constrained_fcmp
756      : Intrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
757                  [ llvm_anyfloat_ty, LLVMMatchType<0>,
758                    llvm_metadata_ty, llvm_metadata_ty ]>;
759  def int_experimental_constrained_fcmps
760      : Intrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
761                  [ llvm_anyfloat_ty, LLVMMatchType<0>,
762                    llvm_metadata_ty, llvm_metadata_ty ]>;
763}
764// FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
765
766//===------------------------- Expect Intrinsics --------------------------===//
767//
768def int_expect : Intrinsic<[llvm_anyint_ty],
769  [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
770
771//===-------------------- Bit Manipulation Intrinsics ---------------------===//
772//
773
774// None of these intrinsics accesses memory at all.
775let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
776  def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
777  def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
778  def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
779  def int_fshl : Intrinsic<[llvm_anyint_ty],
780      [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
781  def int_fshr : Intrinsic<[llvm_anyint_ty],
782      [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
783}
784
785let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>] in {
786  def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
787  def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
788}
789
790//===------------------------ Debugger Intrinsics -------------------------===//
791//
792
793// None of these intrinsics accesses memory at all...but that doesn't
794// mean the optimizers can change them aggressively.  Special handling
795// needed in a few places. These synthetic intrinsics have no
796// side-effects and just mark information about their operands.
797let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
798  def int_dbg_declare      : Intrinsic<[],
799                                       [llvm_metadata_ty,
800                                        llvm_metadata_ty,
801                                        llvm_metadata_ty]>;
802  def int_dbg_value        : Intrinsic<[],
803                                       [llvm_metadata_ty,
804                                        llvm_metadata_ty,
805                                        llvm_metadata_ty]>;
806  def int_dbg_addr         : Intrinsic<[],
807                                       [llvm_metadata_ty,
808                                        llvm_metadata_ty,
809                                        llvm_metadata_ty]>;
810  def int_dbg_label        : Intrinsic<[],
811                                       [llvm_metadata_ty]>;
812}
813
814//===------------------ Exception Handling Intrinsics----------------------===//
815//
816
817// The result of eh.typeid.for depends on the enclosing function, but inside a
818// given function it is 'const' and may be CSE'd etc.
819def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
820
821def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
822def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
823
824// eh.exceptionpointer returns the pointer to the exception caught by
825// the given `catchpad`.
826def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
827                                        [IntrNoMem]>;
828
829// Gets the exception code from a catchpad token. Only used on some platforms.
830def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
831
832// __builtin_unwind_init is an undocumented GCC intrinsic that causes all
833// callee-saved registers to be saved and restored (regardless of whether they
834// are used) in the calling function. It is used by libgcc_eh.
835def int_eh_unwind_init: Intrinsic<[]>,
836                        GCCBuiltin<"__builtin_unwind_init">;
837
838def int_eh_dwarf_cfa  : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
839
840let IntrProperties = [IntrNoMem] in {
841  def int_eh_sjlj_lsda             : Intrinsic<[llvm_ptr_ty]>;
842  def int_eh_sjlj_callsite         : Intrinsic<[], [llvm_i32_ty]>;
843}
844def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
845def int_eh_sjlj_setjmp          : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
846def int_eh_sjlj_longjmp         : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
847def int_eh_sjlj_setup_dispatch  : Intrinsic<[], []>;
848
849//===---------------- Generic Variable Attribute Intrinsics----------------===//
850//
851def int_var_annotation : Intrinsic<[],
852                                   [llvm_ptr_ty, llvm_ptr_ty,
853                                    llvm_ptr_ty, llvm_i32_ty],
854                                   [IntrWillReturn], "llvm.var.annotation">;
855def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>],
856                                   [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty,
857                                    llvm_i32_ty],
858                                   [IntrWillReturn], "llvm.ptr.annotation">;
859def int_annotation : Intrinsic<[llvm_anyint_ty],
860                               [LLVMMatchType<0>, llvm_ptr_ty,
861                                llvm_ptr_ty, llvm_i32_ty],
862                               [IntrWillReturn], "llvm.annotation">;
863
864// Annotates the current program point with metadata strings which are emitted
865// as CodeView debug info records. This is expensive, as it disables inlining
866// and is modelled as having side effects.
867def int_codeview_annotation : Intrinsic<[], [llvm_metadata_ty],
868                                        [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
869                                        "llvm.codeview.annotation">;
870
871//===------------------------ Trampoline Intrinsics -----------------------===//
872//
873def int_init_trampoline : Intrinsic<[],
874                                    [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
875                                    [IntrArgMemOnly, NoCapture<0>]>,
876                                   GCCBuiltin<"__builtin_init_trampoline">;
877
878def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
879                                      [IntrReadMem, IntrArgMemOnly]>,
880                                     GCCBuiltin<"__builtin_adjust_trampoline">;
881
882//===------------------------ Overflow Intrinsics -------------------------===//
883//
884
885// Expose the carry flag from add operations on two integrals.
886let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
887  def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty,
888                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
889                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
890  def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty,
891                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
892                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
893
894  def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty,
895                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
896                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
897  def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty,
898                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
899                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
900
901  def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty,
902                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
903                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
904  def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty,
905                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
906                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
907}
908//===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
909//
910def int_sadd_sat : Intrinsic<[llvm_anyint_ty],
911                             [LLVMMatchType<0>, LLVMMatchType<0>],
912                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
913def int_uadd_sat : Intrinsic<[llvm_anyint_ty],
914                             [LLVMMatchType<0>, LLVMMatchType<0>],
915                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
916def int_ssub_sat : Intrinsic<[llvm_anyint_ty],
917                             [LLVMMatchType<0>, LLVMMatchType<0>],
918                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
919def int_usub_sat : Intrinsic<[llvm_anyint_ty],
920                             [LLVMMatchType<0>, LLVMMatchType<0>],
921                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
922
923//===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
924//
925def int_smul_fix : Intrinsic<[llvm_anyint_ty],
926                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
927                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
928
929def int_umul_fix : Intrinsic<[llvm_anyint_ty],
930                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
931                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
932
933def int_sdiv_fix : Intrinsic<[llvm_anyint_ty],
934                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
935                             [IntrNoMem, ImmArg<2>]>;
936
937def int_udiv_fix : Intrinsic<[llvm_anyint_ty],
938                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
939                             [IntrNoMem, ImmArg<2>]>;
940
941//===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
942//
943def int_smul_fix_sat : Intrinsic<[llvm_anyint_ty],
944                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
945                                 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
946def int_umul_fix_sat : Intrinsic<[llvm_anyint_ty],
947                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
948                                 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
949
950//===------------------------- Memory Use Markers -------------------------===//
951//
952def int_lifetime_start  : Intrinsic<[],
953                                    [llvm_i64_ty, llvm_anyptr_ty],
954                                    [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
955def int_lifetime_end    : Intrinsic<[],
956                                    [llvm_i64_ty, llvm_anyptr_ty],
957                                    [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
958def int_invariant_start : Intrinsic<[llvm_descriptor_ty],
959                                    [llvm_i64_ty, llvm_anyptr_ty],
960                                    [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
961def int_invariant_end   : Intrinsic<[],
962                                    [llvm_descriptor_ty, llvm_i64_ty,
963                                     llvm_anyptr_ty],
964                                    [IntrArgMemOnly, IntrWillReturn, NoCapture<2>, ImmArg<1>]>;
965
966// launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
967// because it would cause CSE of two barriers with the same argument.
968// Inaccessiblememonly says that the barrier doesn't read the argument,
969// but it changes state not accessible to this module. This way
970// we can DSE through the barrier because it doesn't read the value
971// after store. Although the barrier doesn't modify any memory it
972// can't be marked as readonly, because it would be possible to
973// CSE 2 barriers with store in between.
974// The argument also can't be marked with 'returned' attribute, because
975// it would remove barrier.
976// Note that it is still experimental, which means that its semantics
977// might change in the future.
978def int_launder_invariant_group : Intrinsic<[llvm_anyptr_ty],
979                                            [LLVMMatchType<0>],
980                                            [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
981
982
983def int_strip_invariant_group : Intrinsic<[llvm_anyptr_ty],
984                                          [LLVMMatchType<0>],
985                                          [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
986
987//===------------------------ Stackmap Intrinsics -------------------------===//
988//
989def int_experimental_stackmap : Intrinsic<[],
990                                  [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
991                                  [Throws]>;
992def int_experimental_patchpoint_void : Intrinsic<[],
993                                                 [llvm_i64_ty, llvm_i32_ty,
994                                                  llvm_ptr_ty, llvm_i32_ty,
995                                                  llvm_vararg_ty],
996                                                  [Throws]>;
997def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
998                                                [llvm_i64_ty, llvm_i32_ty,
999                                                 llvm_ptr_ty, llvm_i32_ty,
1000                                                 llvm_vararg_ty],
1001                                                 [Throws]>;
1002
1003
1004//===------------------------ Garbage Collection Intrinsics ---------------===//
1005// These are documented in docs/Statepoint.rst
1006
1007def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
1008                               [llvm_i64_ty, llvm_i32_ty,
1009                                llvm_anyptr_ty, llvm_i32_ty,
1010                                llvm_i32_ty, llvm_vararg_ty],
1011                                [Throws, ImmArg<0>, ImmArg<1>, ImmArg<3>, ImmArg<4>]>;
1012
1013def int_experimental_gc_result   : Intrinsic<[llvm_any_ty], [llvm_token_ty],
1014                                             [IntrReadMem]>;
1015def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
1016                                [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
1017                                [IntrReadMem, ImmArg<1>, ImmArg<2>]>;
1018
1019//===------------------------ Coroutine Intrinsics ---------------===//
1020// These are documented in docs/Coroutines.rst
1021
1022// Coroutine Structure Intrinsics.
1023
1024def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty,
1025                             llvm_ptr_ty, llvm_ptr_ty],
1026                            [IntrArgMemOnly, IntrReadMem,
1027                             ReadNone<1>, ReadOnly<2>, NoCapture<2>]>;
1028def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
1029    [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1030     llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1031    []>;
1032def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
1033    [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1034     llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1035    []>;
1036def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
1037def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1038                               [WriteOnly<1>]>;
1039
1040def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1041                              [IntrReadMem, IntrArgMemOnly, ReadOnly<1>,
1042                               NoCapture<1>]>;
1043def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
1044
1045def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1046def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1047def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1048
1049def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
1050def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1051def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1052def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1053                                        [IntrNoMem]>;
1054def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1055                                      [llvm_anyint_ty, llvm_i32_ty], []>;
1056def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1057def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1058
1059def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty],
1060                               [IntrNoMem, ReadNone<0>, ReadNone<1>]>;
1061
1062// Coroutine Manipulation Intrinsics.
1063
1064def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1065def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1066def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1067                              [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>;
1068def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1069                                 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1070                                 [IntrNoMem, NoCapture<0>]>;
1071
1072// Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1073
1074def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1075                                    [IntrReadMem, IntrArgMemOnly, ReadOnly<0>,
1076                                     NoCapture<0>]>;
1077
1078///===-------------------------- Other Intrinsics --------------------------===//
1079//
1080def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
1081                     GCCBuiltin<"__builtin_flt_rounds">;
1082def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
1083               GCCBuiltin<"__builtin_trap">;
1084def int_debugtrap : Intrinsic<[]>,
1085                    GCCBuiltin<"__builtin_debugtrap">;
1086
1087// Support for dynamic deoptimization (or de-specialization)
1088def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1089                                            [Throws]>;
1090
1091// Support for speculative runtime guards
1092def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1093                                       [Throws]>;
1094
1095// Supports widenable conditions for guards represented as explicit branches.
1096def int_experimental_widenable_condition : Intrinsic<[llvm_i1_ty], [],
1097        [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable]>;
1098
1099// NOP: calls/invokes to this intrinsic are removed by codegen
1100def int_donothing : Intrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1101
1102// This instruction has no actual effect, though it is treated by the optimizer
1103// has having opaque side effects. This may be inserted into loops to ensure
1104// that they are not removed even if they turn out to be empty, for languages
1105// which specify that infinite loops must be preserved.
1106def int_sideeffect : Intrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1107
1108// Intrinsics to support half precision floating point format
1109let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1110def int_convert_to_fp16   : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1111def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1112}
1113
1114// Clear cache intrinsic, default to ignore (ie. emit nothing)
1115// maps to void __clear_cache() on supporting platforms
1116def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1117                                [], "llvm.clear_cache">;
1118
1119// Intrinsic to detect whether its argument is a constant.
1120def int_is_constant : Intrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem, IntrWillReturn], "llvm.is.constant">;
1121
1122// Intrinsic to mask out bits of a pointer.
1123def int_ptrmask: Intrinsic<[llvm_anyptr_ty], [llvm_anyptr_ty, llvm_anyint_ty],
1124                           [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1125
1126//===-------------------------- Masked Intrinsics -------------------------===//
1127//
1128def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
1129                                      LLVMAnyPointerType<LLVMMatchType<0>>,
1130                                      llvm_i32_ty,
1131                                      LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1132                                 [IntrArgMemOnly, IntrWillReturn, ImmArg<2>]>;
1133
1134def int_masked_load  : Intrinsic<[llvm_anyvector_ty],
1135                                 [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
1136                                  LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1137                                 [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<1>]>;
1138
1139def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
1140                                 [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1141                                  LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1142                                  LLVMMatchType<0>],
1143                                 [IntrReadMem, IntrWillReturn, ImmArg<1>]>;
1144
1145def int_masked_scatter: Intrinsic<[],
1146                                  [llvm_anyvector_ty,
1147                                   LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1148                                   LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1149                                   [IntrWillReturn, ImmArg<2>]>;
1150
1151def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
1152                                     [LLVMPointerToElt<0>,
1153                                      LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1154                                      LLVMMatchType<0>],
1155                                     [IntrReadMem, IntrWillReturn]>;
1156
1157def int_masked_compressstore: Intrinsic<[],
1158                                     [llvm_anyvector_ty,
1159                                      LLVMPointerToElt<0>,
1160                                      LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1161                                     [IntrArgMemOnly, IntrWillReturn]>;
1162
1163// Test whether a pointer is associated with a type metadata identifier.
1164def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1165                              [IntrNoMem, IntrWillReturn]>;
1166
1167// Safely loads a function pointer from a virtual table pointer using type metadata.
1168def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty],
1169                                      [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
1170                                      [IntrNoMem, IntrWillReturn]>;
1171
1172// Create a branch funnel that implements an indirect call to a limited set of
1173// callees. This needs to be a musttail call.
1174def int_icall_branch_funnel : Intrinsic<[], [llvm_vararg_ty], []>;
1175
1176def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
1177                                 [IntrReadMem, IntrArgMemOnly]>;
1178
1179def int_hwasan_check_memaccess :
1180  Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1181def int_hwasan_check_memaccess_shortgranules :
1182  Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1183
1184// Xray intrinsics
1185//===----------------------------------------------------------------------===//
1186// Custom event logging for x-ray.
1187// Takes a pointer to a string and the length of the string.
1188def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
1189                                     [NoCapture<0>, ReadOnly<0>, IntrWriteMem]>;
1190// Typed event logging for x-ray.
1191// Takes a numeric type tag, a pointer to a string and the length of the string.
1192def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
1193                                        [NoCapture<1>, ReadOnly<1>, IntrWriteMem]>;
1194//===----------------------------------------------------------------------===//
1195
1196//===------ Memory intrinsics with element-wise atomicity guarantees ------===//
1197//
1198
1199// @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
1200def int_memcpy_element_unordered_atomic
1201    : Intrinsic<[],
1202                [
1203                  llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1204                ],
1205                [
1206                  IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1207                  ReadOnly<1>, ImmArg<3>
1208                ]>;
1209
1210// @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
1211def int_memmove_element_unordered_atomic
1212    : Intrinsic<[],
1213                [
1214                  llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1215                ],
1216                [
1217                  IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1218                  ReadOnly<1>, ImmArg<3>
1219                ]>;
1220
1221// @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
1222def int_memset_element_unordered_atomic
1223    : Intrinsic<[], [ llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty ],
1224                [ IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>, ImmArg<3> ]>;
1225
1226//===------------------------ Reduction Intrinsics ------------------------===//
1227//
1228let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1229  def int_experimental_vector_reduce_v2_fadd : Intrinsic<[llvm_anyfloat_ty],
1230                                                         [LLVMMatchType<0>,
1231                                                          llvm_anyvector_ty]>;
1232  def int_experimental_vector_reduce_v2_fmul : Intrinsic<[llvm_anyfloat_ty],
1233                                                         [LLVMMatchType<0>,
1234                                                          llvm_anyvector_ty]>;
1235  def int_experimental_vector_reduce_add : Intrinsic<[LLVMVectorElementType<0>],
1236                                                     [llvm_anyvector_ty]>;
1237  def int_experimental_vector_reduce_mul : Intrinsic<[LLVMVectorElementType<0>],
1238                                                     [llvm_anyvector_ty]>;
1239  def int_experimental_vector_reduce_and : Intrinsic<[LLVMVectorElementType<0>],
1240                                                     [llvm_anyvector_ty]>;
1241  def int_experimental_vector_reduce_or : Intrinsic<[LLVMVectorElementType<0>],
1242                                                    [llvm_anyvector_ty]>;
1243  def int_experimental_vector_reduce_xor : Intrinsic<[LLVMVectorElementType<0>],
1244                                                     [llvm_anyvector_ty]>;
1245  def int_experimental_vector_reduce_smax : Intrinsic<[LLVMVectorElementType<0>],
1246                                                      [llvm_anyvector_ty]>;
1247  def int_experimental_vector_reduce_smin : Intrinsic<[LLVMVectorElementType<0>],
1248                                                      [llvm_anyvector_ty]>;
1249  def int_experimental_vector_reduce_umax : Intrinsic<[LLVMVectorElementType<0>],
1250                                                      [llvm_anyvector_ty]>;
1251  def int_experimental_vector_reduce_umin : Intrinsic<[LLVMVectorElementType<0>],
1252                                                      [llvm_anyvector_ty]>;
1253  def int_experimental_vector_reduce_fmax : Intrinsic<[LLVMVectorElementType<0>],
1254                                                      [llvm_anyvector_ty]>;
1255  def int_experimental_vector_reduce_fmin : Intrinsic<[LLVMVectorElementType<0>],
1256                                                      [llvm_anyvector_ty]>;
1257}
1258
1259//===----- Matrix intrinsics ---------------------------------------------===//
1260
1261def int_matrix_transpose : Intrinsic<[llvm_anyvector_ty],
1262                                     [LLVMMatchType<0>,
1263                                     llvm_i32_ty,
1264                                     llvm_i32_ty],
1265                                     [IntrNoMem, IntrSpeculatable,
1266                                      IntrWillReturn, ImmArg<1>, ImmArg<2>]>;
1267
1268def int_matrix_multiply : Intrinsic<[llvm_anyvector_ty],
1269                                    [llvm_anyvector_ty,
1270                                     llvm_anyvector_ty,
1271                                     llvm_i32_ty,
1272                                     llvm_i32_ty,
1273                                     llvm_i32_ty],
1274                                    [IntrNoMem, IntrSpeculatable,
1275                                     IntrWillReturn, ImmArg<2>, ImmArg<3>,
1276                                     ImmArg<4>]>;
1277
1278def int_matrix_columnwise_load : Intrinsic<[llvm_anyvector_ty],
1279                                           [LLVMAnyPointerType<LLVMMatchType<0>>,
1280                                            llvm_i32_ty,
1281                                            llvm_i32_ty,
1282                                            llvm_i32_ty],
1283                                           [IntrReadMem, IntrWillReturn,
1284                                            ImmArg<2>, ImmArg<3>]>;
1285
1286def int_matrix_columnwise_store : Intrinsic<[],
1287                                            [llvm_anyvector_ty,
1288                                             LLVMAnyPointerType<LLVMMatchType<0>>,
1289                                             llvm_i32_ty,
1290                                             llvm_i32_ty,
1291                                             llvm_i32_ty],
1292                                            [WriteOnly<1>, IntrWillReturn,
1293                                             ImmArg<3>, ImmArg<4>]>;
1294
1295//===---------- Intrinsics to control hardware supported loops ----------===//
1296
1297// Specify that the value given is the number of iterations that the next loop
1298// will execute.
1299def int_set_loop_iterations :
1300  Intrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
1301
1302// Specify that the value given is the number of iterations that the next loop
1303// will execute. Also test that the given count is not zero, allowing it to
1304// control entry to a 'while' loop.
1305def int_test_set_loop_iterations :
1306  Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1307
1308// Decrement loop counter by the given argument. Return false if the loop
1309// should exit.
1310def int_loop_decrement :
1311  Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1312
1313// Decrement the first operand (the loop counter) by the second operand (the
1314// maximum number of elements processed in an iteration). Return the remaining
1315// number of iterations still to be executed. This is effectively a sub which
1316// can be used with a phi, icmp and br to control the number of iterations
1317// executed, as usual. Any optimisations are allowed to treat it is a sub, and
1318// it's scevable, so it's the backends responsibility to handle cases where it
1319// may be optimised.
1320def int_loop_decrement_reg :
1321  Intrinsic<[llvm_anyint_ty],
1322            [llvm_anyint_ty, llvm_anyint_ty], [IntrNoDuplicate]>;
1323
1324//===----- Intrinsics that are used to provide predicate information -----===//
1325
1326def int_ssa_copy : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
1327                             [IntrNoMem, Returned<0>]>;
1328
1329//===------- Intrinsics that are used to preserve debug information -------===//
1330
1331def int_preserve_array_access_index : Intrinsic<[llvm_anyptr_ty],
1332                                                [llvm_anyptr_ty, llvm_i32_ty,
1333                                                 llvm_i32_ty],
1334                                                [IntrNoMem, ImmArg<1>, ImmArg<2>]>;
1335def int_preserve_union_access_index : Intrinsic<[llvm_anyptr_ty],
1336                                                [llvm_anyptr_ty, llvm_i32_ty],
1337                                                [IntrNoMem, ImmArg<1>]>;
1338def int_preserve_struct_access_index : Intrinsic<[llvm_anyptr_ty],
1339                                                 [llvm_anyptr_ty, llvm_i32_ty,
1340                                                  llvm_i32_ty],
1341                                                 [IntrNoMem, ImmArg<1>,
1342                                                  ImmArg<2>]>;
1343
1344//===----------------------------------------------------------------------===//
1345// Target-specific intrinsics
1346//===----------------------------------------------------------------------===//
1347
1348include "llvm/IR/IntrinsicsPowerPC.td"
1349include "llvm/IR/IntrinsicsX86.td"
1350include "llvm/IR/IntrinsicsARM.td"
1351include "llvm/IR/IntrinsicsAArch64.td"
1352include "llvm/IR/IntrinsicsXCore.td"
1353include "llvm/IR/IntrinsicsHexagon.td"
1354include "llvm/IR/IntrinsicsNVVM.td"
1355include "llvm/IR/IntrinsicsMips.td"
1356include "llvm/IR/IntrinsicsAMDGPU.td"
1357include "llvm/IR/IntrinsicsBPF.td"
1358include "llvm/IR/IntrinsicsSystemZ.td"
1359include "llvm/IR/IntrinsicsWebAssembly.td"
1360include "llvm/IR/IntrinsicsRISCV.td"
1361