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