1 //===- Intrinsics.td - Defines all LLVM intrinsics ---------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
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 {
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 {
72 // Returned - The specified argument is always the return value of the
74 class Returned<int argNo> : IntrinsicProperty {
78 // ImmArg - The specified argument must be an immediate.
79 class ImmArg<int argNo> : IntrinsicProperty {
83 // ReadOnly - The specified argument pointer is not written to through the
84 // pointer by the intrinsic.
85 class ReadOnly<int argNo> : IntrinsicProperty {
89 // WriteOnly - The intrinsic does not read memory through the specified
91 class WriteOnly<int argNo> : IntrinsicProperty {
95 // ReadNone - The specified argument pointer is not dereferenced by the
97 class ReadNone<int argNo> : IntrinsicProperty {
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> {
139 class LLVMQualPointerType<LLVMType elty, int addrspace>
141 LLVMType ElTy = elty;
142 int AddrSpace = addrspace;
145 class LLVMPointerType<LLVMType elty>
146 : LLVMQualPointerType<elty, 0>;
148 class LLVMAnyPointerType<LLVMType elty>
150 LLVMType ElTy = elty;
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>
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 // Match the element count and bit width of another intrinsic parameter, but
197 // change the element type to an integer.
198 class LLVMVectorOfBitcastsToInt<int num> : LLVMMatchType<num>;
200 def llvm_void_ty : LLVMType<isVoid>;
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>;
207 def llvm_i1_ty : LLVMType<i1>;
208 def llvm_i8_ty : LLVMType<i8>;
209 def llvm_i16_ty : LLVMType<i16>;
210 def llvm_i32_ty : LLVMType<i32>;
211 def llvm_i64_ty : LLVMType<i64>;
212 def llvm_half_ty : LLVMType<f16>;
213 def llvm_float_ty : LLVMType<f32>;
214 def llvm_double_ty : LLVMType<f64>;
215 def llvm_f80_ty : LLVMType<f80>;
216 def llvm_f128_ty : LLVMType<f128>;
217 def llvm_ppcf128_ty : LLVMType<ppcf128>;
218 def llvm_ptr_ty : LLVMPointerType<llvm_i8_ty>; // i8*
219 def llvm_ptrptr_ty : LLVMPointerType<llvm_ptr_ty>; // i8**
220 def llvm_anyptr_ty : LLVMAnyPointerType<llvm_i8_ty>; // (space)i8*
221 def llvm_empty_ty : LLVMType<OtherVT>; // { }
222 def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>; // { }*
223 def llvm_metadata_ty : LLVMType<MetadataVT>; // !{...}
224 def llvm_token_ty : LLVMType<token>; // token
226 def llvm_x86mmx_ty : LLVMType<x86mmx>;
227 def llvm_ptrx86mmx_ty : LLVMPointerType<llvm_x86mmx_ty>; // <1 x i64>*
229 def llvm_v2i1_ty : LLVMType<v2i1>; // 2 x i1
230 def llvm_v4i1_ty : LLVMType<v4i1>; // 4 x i1
231 def llvm_v8i1_ty : LLVMType<v8i1>; // 8 x i1
232 def llvm_v16i1_ty : LLVMType<v16i1>; // 16 x i1
233 def llvm_v32i1_ty : LLVMType<v32i1>; // 32 x i1
234 def llvm_v64i1_ty : LLVMType<v64i1>; // 64 x i1
235 def llvm_v512i1_ty : LLVMType<v512i1>; // 512 x i1
236 def llvm_v1024i1_ty : LLVMType<v1024i1>; //1024 x i1
238 def llvm_v1i8_ty : LLVMType<v1i8>; // 1 x i8
239 def llvm_v2i8_ty : LLVMType<v2i8>; // 2 x i8
240 def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8
241 def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8
242 def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8
243 def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8
244 def llvm_v64i8_ty : LLVMType<v64i8>; // 64 x i8
245 def llvm_v128i8_ty : LLVMType<v128i8>; //128 x i8
246 def llvm_v256i8_ty : LLVMType<v256i8>; //256 x i8
248 def llvm_v1i16_ty : LLVMType<v1i16>; // 1 x i16
249 def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16
250 def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16
251 def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16
252 def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16
253 def llvm_v32i16_ty : LLVMType<v32i16>; // 32 x i16
254 def llvm_v64i16_ty : LLVMType<v64i16>; // 64 x i16
255 def llvm_v128i16_ty : LLVMType<v128i16>; //128 x i16
257 def llvm_v1i32_ty : LLVMType<v1i32>; // 1 x i32
258 def llvm_v2i32_ty : LLVMType<v2i32>; // 2 x i32
259 def llvm_v4i32_ty : LLVMType<v4i32>; // 4 x i32
260 def llvm_v8i32_ty : LLVMType<v8i32>; // 8 x i32
261 def llvm_v16i32_ty : LLVMType<v16i32>; // 16 x i32
262 def llvm_v32i32_ty : LLVMType<v32i32>; // 32 x i32
263 def llvm_v64i32_ty : LLVMType<v64i32>; // 64 x i32
265 def llvm_v1i64_ty : LLVMType<v1i64>; // 1 x i64
266 def llvm_v2i64_ty : LLVMType<v2i64>; // 2 x i64
267 def llvm_v4i64_ty : LLVMType<v4i64>; // 4 x i64
268 def llvm_v8i64_ty : LLVMType<v8i64>; // 8 x i64
269 def llvm_v16i64_ty : LLVMType<v16i64>; // 16 x i64
270 def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64
272 def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128
274 def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16)
275 def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16)
276 def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16)
277 def llvm_v1f32_ty : LLVMType<v1f32>; // 1 x float
278 def llvm_v2f32_ty : LLVMType<v2f32>; // 2 x float
279 def llvm_v4f32_ty : LLVMType<v4f32>; // 4 x float
280 def llvm_v8f32_ty : LLVMType<v8f32>; // 8 x float
281 def llvm_v16f32_ty : LLVMType<v16f32>; // 16 x float
282 def llvm_v32f32_ty : LLVMType<v32f32>; // 32 x float
283 def llvm_v1f64_ty : LLVMType<v1f64>; // 1 x double
284 def llvm_v2f64_ty : LLVMType<v2f64>; // 2 x double
285 def llvm_v4f64_ty : LLVMType<v4f64>; // 4 x double
286 def llvm_v8f64_ty : LLVMType<v8f64>; // 8 x double
288 def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here
290 //===----------------------------------------------------------------------===//
291 // Intrinsic Definitions.
292 //===----------------------------------------------------------------------===//
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.
299 // * RetTypes is a list containing the return types expected for the
301 // * ParamTypes is a list containing the parameter types expected for the
303 // * Properties can be set to describe the behavior of the intrinsic.
305 class Intrinsic<list<LLVMType> ret_types,
306 list<LLVMType> param_types = [],
307 list<IntrinsicProperty> intr_properties = [],
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;
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
323 class GCCBuiltin<string name> {
324 string GCCBuiltinName = name;
327 class MSBuiltin<string name> {
328 string MSBuiltinName = name;
332 //===--------------- Variable Argument Handling Intrinsics ----------------===//
335 def int_vastart : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
336 def int_vacopy : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
338 def int_vaend : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
340 //===------------------- Garbage Collection Intrinsics --------------------===//
342 def int_gcroot : Intrinsic<[],
343 [llvm_ptrptr_ty, llvm_ptr_ty]>;
344 def int_gcread : Intrinsic<[llvm_ptr_ty],
345 [llvm_ptr_ty, llvm_ptrptr_ty],
346 [IntrReadMem, IntrArgMemOnly]>;
347 def int_gcwrite : Intrinsic<[],
348 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
349 [IntrArgMemOnly, NoCapture<1>, NoCapture<2>]>;
351 //===------------------- ObjC ARC runtime Intrinsics --------------------===//
353 // Note these are to support the Objective-C ARC optimizer which wants to
354 // eliminate retain and releases where possible.
356 def int_objc_autorelease : Intrinsic<[llvm_ptr_ty],
358 def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>;
359 def int_objc_autoreleasePoolPush : Intrinsic<[llvm_ptr_ty], []>;
360 def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
362 def int_objc_copyWeak : Intrinsic<[],
365 def int_objc_destroyWeak : Intrinsic<[], [llvm_ptrptr_ty]>;
366 def int_objc_initWeak : Intrinsic<[llvm_ptr_ty],
369 def int_objc_loadWeak : Intrinsic<[llvm_ptr_ty],
371 def int_objc_loadWeakRetained : Intrinsic<[llvm_ptr_ty],
373 def int_objc_moveWeak : Intrinsic<[],
376 def int_objc_release : Intrinsic<[], [llvm_ptr_ty]>;
377 def int_objc_retain : Intrinsic<[llvm_ptr_ty],
379 def int_objc_retainAutorelease : Intrinsic<[llvm_ptr_ty],
381 def int_objc_retainAutoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
383 def int_objc_retainAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
385 def int_objc_retainBlock : Intrinsic<[llvm_ptr_ty],
387 def int_objc_storeStrong : Intrinsic<[],
390 def int_objc_storeWeak : Intrinsic<[llvm_ptr_ty],
393 def int_objc_clang_arc_use : Intrinsic<[],
395 def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
397 def int_objc_retainedObject : Intrinsic<[llvm_ptr_ty],
399 def int_objc_unretainedObject : Intrinsic<[llvm_ptr_ty],
401 def int_objc_unretainedPointer : Intrinsic<[llvm_ptr_ty],
403 def int_objc_retain_autorelease : Intrinsic<[llvm_ptr_ty],
405 def int_objc_sync_enter : Intrinsic<[llvm_i32_ty],
407 def int_objc_sync_exit : Intrinsic<[llvm_i32_ty],
409 def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
412 def int_objc_arc_annotation_topdown_bbend : Intrinsic<[],
415 def int_objc_arc_annotation_bottomup_bbstart : Intrinsic<[],
418 def int_objc_arc_annotation_bottomup_bbend : Intrinsic<[],
423 //===--------------------- Code Generator Intrinsics ----------------------===//
425 def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
426 def int_addressofreturnaddress : Intrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
427 def int_frameaddress : Intrinsic<[llvm_anyptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
428 def int_sponentry : Intrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
429 def int_read_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
430 [IntrReadMem], "llvm.read_register">;
431 def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
432 [], "llvm.write_register">;
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.
436 def int_localaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
438 // Escapes local variables to allow access from other functions.
439 def int_localescape : Intrinsic<[], [llvm_vararg_ty]>;
441 // Given a function and the localaddress of a parent frame, returns a pointer
442 // to an escaped allocation indicated by the index.
443 def int_localrecover : Intrinsic<[llvm_ptr_ty],
444 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
445 [IntrNoMem, ImmArg<2>]>;
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.
449 def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty],
450 [llvm_ptr_ty, llvm_ptr_ty],
453 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
454 // model their dependencies on allocas.
455 def int_stacksave : Intrinsic<[llvm_ptr_ty]>,
456 GCCBuiltin<"__builtin_stack_save">;
457 def int_stackrestore : Intrinsic<[], [llvm_ptr_ty]>,
458 GCCBuiltin<"__builtin_stack_restore">;
460 def int_get_dynamic_area_offset : Intrinsic<[llvm_anyint_ty]>;
462 def int_thread_pointer : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
463 GCCBuiltin<"__builtin_thread_pointer">;
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.
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>]>;
473 def int_pcmarker : Intrinsic<[], [llvm_i32_ty]>;
475 def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
477 // The assume intrinsic is marked as arbitrarily writing so that proper
478 // control dependencies will be maintained.
479 def int_assume : Intrinsic<[], [llvm_i1_ty], [IntrWillReturn]>;
481 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
482 // guard to the correct place on the stack frame.
483 def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
484 def int_stackguard : Intrinsic<[llvm_ptr_ty], [], []>;
486 // A counter increment for instrumentation based profiling.
487 def int_instrprof_increment : Intrinsic<[],
488 [llvm_ptr_ty, llvm_i64_ty,
489 llvm_i32_ty, llvm_i32_ty],
492 // A counter increment with step for instrumentation based profiling.
493 def int_instrprof_increment_step : Intrinsic<[],
494 [llvm_ptr_ty, llvm_i64_ty,
495 llvm_i32_ty, llvm_i32_ty, llvm_i64_ty],
498 // A call to profile runtime for value profiling of target expressions
499 // through instrumentation based profiling.
500 def int_instrprof_value_profile : Intrinsic<[],
501 [llvm_ptr_ty, llvm_i64_ty,
502 llvm_i64_ty, llvm_i32_ty,
506 //===------------------- Standard C Library Intrinsics --------------------===//
509 def int_memcpy : Intrinsic<[],
510 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
512 [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>,
513 NoAlias<0>, NoAlias<1>, WriteOnly<0>, ReadOnly<1>, ImmArg<3>]>;
514 def int_memmove : Intrinsic<[],
515 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
517 [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>,
518 ReadOnly<1>, ImmArg<3>]>;
519 def int_memset : Intrinsic<[],
520 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
522 [IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>,
525 // FIXME: Add version of these floating point intrinsics which allow non-default
526 // rounding modes and FP exception handling.
528 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
529 def int_fma : Intrinsic<[llvm_anyfloat_ty],
530 [LLVMMatchType<0>, LLVMMatchType<0>,
532 def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
533 [LLVMMatchType<0>, LLVMMatchType<0>,
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>],
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]>;
568 def int_minnum : Intrinsic<[llvm_anyfloat_ty],
569 [LLVMMatchType<0>, LLVMMatchType<0>],
570 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
572 def int_maxnum : Intrinsic<[llvm_anyfloat_ty],
573 [LLVMMatchType<0>, LLVMMatchType<0>],
574 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
576 def int_minimum : Intrinsic<[llvm_anyfloat_ty],
577 [LLVMMatchType<0>, LLVMMatchType<0>],
578 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
580 def int_maximum : Intrinsic<[llvm_anyfloat_ty],
581 [LLVMMatchType<0>, LLVMMatchType<0>],
582 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
585 // NOTE: these are internal interfaces.
586 def int_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
587 def int_longjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
588 def int_sigsetjmp : Intrinsic<[llvm_i32_ty] , [llvm_ptr_ty, llvm_i32_ty]>;
589 def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
591 // Internal interface for object size checking
592 def int_objectsize : Intrinsic<[llvm_anyint_ty],
593 [llvm_anyptr_ty, llvm_i1_ty,
594 llvm_i1_ty, llvm_i1_ty],
595 [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>, ImmArg<2>, ImmArg<3>]>,
596 GCCBuiltin<"__builtin_object_size">;
598 //===--------------- Constrained Floating Point Intrinsics ----------------===//
601 let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
602 def int_experimental_constrained_fadd : Intrinsic<[ llvm_anyfloat_ty ],
607 def int_experimental_constrained_fsub : Intrinsic<[ llvm_anyfloat_ty ],
612 def int_experimental_constrained_fmul : Intrinsic<[ llvm_anyfloat_ty ],
617 def int_experimental_constrained_fdiv : Intrinsic<[ llvm_anyfloat_ty ],
622 def int_experimental_constrained_frem : Intrinsic<[ llvm_anyfloat_ty ],
628 def int_experimental_constrained_fma : Intrinsic<[ llvm_anyfloat_ty ],
635 def int_experimental_constrained_fptosi : Intrinsic<[ llvm_anyint_ty ],
639 def int_experimental_constrained_fptoui : Intrinsic<[ llvm_anyint_ty ],
643 def int_experimental_constrained_fptrunc : Intrinsic<[ llvm_anyfloat_ty ],
648 def int_experimental_constrained_fpext : Intrinsic<[ llvm_anyfloat_ty ],
652 // These intrinsics are sensitive to the rounding mode so we need constrained
653 // versions of each of them. When strict rounding and exception control are
654 // not required the non-constrained versions of these intrinsics should be
656 def int_experimental_constrained_sqrt : Intrinsic<[ llvm_anyfloat_ty ],
660 def int_experimental_constrained_powi : Intrinsic<[ llvm_anyfloat_ty ],
665 def int_experimental_constrained_sin : Intrinsic<[ llvm_anyfloat_ty ],
669 def int_experimental_constrained_cos : Intrinsic<[ llvm_anyfloat_ty ],
673 def int_experimental_constrained_pow : Intrinsic<[ llvm_anyfloat_ty ],
678 def int_experimental_constrained_log : Intrinsic<[ llvm_anyfloat_ty ],
682 def int_experimental_constrained_log10: Intrinsic<[ llvm_anyfloat_ty ],
686 def int_experimental_constrained_log2 : Intrinsic<[ llvm_anyfloat_ty ],
690 def int_experimental_constrained_exp : Intrinsic<[ llvm_anyfloat_ty ],
694 def int_experimental_constrained_exp2 : Intrinsic<[ llvm_anyfloat_ty ],
698 def int_experimental_constrained_rint : Intrinsic<[ llvm_anyfloat_ty ],
702 def int_experimental_constrained_nearbyint : Intrinsic<[ llvm_anyfloat_ty ],
706 def int_experimental_constrained_lrint : Intrinsic<[ llvm_anyint_ty ],
710 def int_experimental_constrained_llrint : Intrinsic<[ llvm_anyint_ty ],
714 def int_experimental_constrained_maxnum : Intrinsic<[ llvm_anyfloat_ty ],
719 def int_experimental_constrained_minnum : Intrinsic<[ llvm_anyfloat_ty ],
724 def int_experimental_constrained_ceil : Intrinsic<[ llvm_anyfloat_ty ],
728 def int_experimental_constrained_floor : Intrinsic<[ llvm_anyfloat_ty ],
732 def int_experimental_constrained_lround : Intrinsic<[ llvm_anyint_ty ],
735 def int_experimental_constrained_llround : Intrinsic<[ llvm_anyint_ty ],
738 def int_experimental_constrained_round : Intrinsic<[ llvm_anyfloat_ty ],
742 def int_experimental_constrained_trunc : Intrinsic<[ llvm_anyfloat_ty ],
747 // FIXME: Add intrinsic for fcmp.
748 // FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
750 //===------------------------- Expect Intrinsics --------------------------===//
752 def int_expect : Intrinsic<[llvm_anyint_ty],
753 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
755 //===-------------------- Bit Manipulation Intrinsics ---------------------===//
758 // None of these intrinsics accesses memory at all.
759 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
760 def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
761 def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
762 def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
763 def int_fshl : Intrinsic<[llvm_anyint_ty],
764 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
765 def int_fshr : Intrinsic<[llvm_anyint_ty],
766 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
769 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>] in {
770 def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
771 def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
774 //===------------------------ Debugger Intrinsics -------------------------===//
777 // None of these intrinsics accesses memory at all...but that doesn't
778 // mean the optimizers can change them aggressively. Special handling
779 // needed in a few places. These synthetic intrinsics have no
780 // side-effects and just mark information about their operands.
781 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
782 def int_dbg_declare : Intrinsic<[],
786 def int_dbg_value : Intrinsic<[],
790 def int_dbg_addr : Intrinsic<[],
794 def int_dbg_label : Intrinsic<[],
798 //===------------------ Exception Handling Intrinsics----------------------===//
801 // The result of eh.typeid.for depends on the enclosing function, but inside a
802 // given function it is 'const' and may be CSE'd etc.
803 def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
805 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
806 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
808 // eh.exceptionpointer returns the pointer to the exception caught by
809 // the given `catchpad`.
810 def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
813 // Gets the exception code from a catchpad token. Only used on some platforms.
814 def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
816 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
817 // callee-saved registers to be saved and restored (regardless of whether they
818 // are used) in the calling function. It is used by libgcc_eh.
819 def int_eh_unwind_init: Intrinsic<[]>,
820 GCCBuiltin<"__builtin_unwind_init">;
822 def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
824 let IntrProperties = [IntrNoMem] in {
825 def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty]>;
826 def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty]>;
828 def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
829 def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
830 def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
831 def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>;
833 //===---------------- Generic Variable Attribute Intrinsics----------------===//
835 def int_var_annotation : Intrinsic<[],
836 [llvm_ptr_ty, llvm_ptr_ty,
837 llvm_ptr_ty, llvm_i32_ty],
838 [IntrWillReturn], "llvm.var.annotation">;
839 def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>],
840 [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty,
842 [IntrWillReturn], "llvm.ptr.annotation">;
843 def int_annotation : Intrinsic<[llvm_anyint_ty],
844 [LLVMMatchType<0>, llvm_ptr_ty,
845 llvm_ptr_ty, llvm_i32_ty],
846 [IntrWillReturn], "llvm.annotation">;
848 // Annotates the current program point with metadata strings which are emitted
849 // as CodeView debug info records. This is expensive, as it disables inlining
850 // and is modelled as having side effects.
851 def int_codeview_annotation : Intrinsic<[], [llvm_metadata_ty],
852 [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
853 "llvm.codeview.annotation">;
855 //===------------------------ Trampoline Intrinsics -----------------------===//
857 def int_init_trampoline : Intrinsic<[],
858 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
859 [IntrArgMemOnly, NoCapture<0>]>,
860 GCCBuiltin<"__builtin_init_trampoline">;
862 def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
863 [IntrReadMem, IntrArgMemOnly]>,
864 GCCBuiltin<"__builtin_adjust_trampoline">;
866 //===------------------------ Overflow Intrinsics -------------------------===//
869 // Expose the carry flag from add operations on two integrals.
870 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
871 def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty,
872 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
873 [LLVMMatchType<0>, LLVMMatchType<0>]>;
874 def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty,
875 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
876 [LLVMMatchType<0>, LLVMMatchType<0>]>;
878 def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty,
879 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
880 [LLVMMatchType<0>, LLVMMatchType<0>]>;
881 def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty,
882 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
883 [LLVMMatchType<0>, LLVMMatchType<0>]>;
885 def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty,
886 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
887 [LLVMMatchType<0>, LLVMMatchType<0>]>;
888 def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty,
889 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
890 [LLVMMatchType<0>, LLVMMatchType<0>]>;
892 //===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
894 def int_sadd_sat : Intrinsic<[llvm_anyint_ty],
895 [LLVMMatchType<0>, LLVMMatchType<0>],
896 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
897 def int_uadd_sat : Intrinsic<[llvm_anyint_ty],
898 [LLVMMatchType<0>, LLVMMatchType<0>],
899 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
900 def int_ssub_sat : Intrinsic<[llvm_anyint_ty],
901 [LLVMMatchType<0>, LLVMMatchType<0>],
902 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
903 def int_usub_sat : Intrinsic<[llvm_anyint_ty],
904 [LLVMMatchType<0>, LLVMMatchType<0>],
905 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
907 //===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
909 def int_smul_fix : Intrinsic<[llvm_anyint_ty],
910 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
911 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
913 def int_umul_fix : Intrinsic<[llvm_anyint_ty],
914 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
915 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
917 //===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
919 def int_smul_fix_sat : Intrinsic<[llvm_anyint_ty],
920 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
921 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
922 def int_umul_fix_sat : Intrinsic<[llvm_anyint_ty],
923 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
924 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
926 //===------------------------- Memory Use Markers -------------------------===//
928 def int_lifetime_start : Intrinsic<[],
929 [llvm_i64_ty, llvm_anyptr_ty],
930 [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
931 def int_lifetime_end : Intrinsic<[],
932 [llvm_i64_ty, llvm_anyptr_ty],
933 [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
934 def int_invariant_start : Intrinsic<[llvm_descriptor_ty],
935 [llvm_i64_ty, llvm_anyptr_ty],
936 [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
937 def int_invariant_end : Intrinsic<[],
938 [llvm_descriptor_ty, llvm_i64_ty,
940 [IntrArgMemOnly, IntrWillReturn, NoCapture<2>, ImmArg<1>]>;
942 // launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
943 // because it would cause CSE of two barriers with the same argument.
944 // Inaccessiblememonly says that the barrier doesn't read the argument,
945 // but it changes state not accessible to this module. This way
946 // we can DSE through the barrier because it doesn't read the value
947 // after store. Although the barrier doesn't modify any memory it
948 // can't be marked as readonly, because it would be possible to
949 // CSE 2 barriers with store in between.
950 // The argument also can't be marked with 'returned' attribute, because
951 // it would remove barrier.
952 // Note that it is still experimental, which means that its semantics
953 // might change in the future.
954 def int_launder_invariant_group : Intrinsic<[llvm_anyptr_ty],
956 [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
959 def int_strip_invariant_group : Intrinsic<[llvm_anyptr_ty],
961 [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
963 //===------------------------ Stackmap Intrinsics -------------------------===//
965 def int_experimental_stackmap : Intrinsic<[],
966 [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
968 def int_experimental_patchpoint_void : Intrinsic<[],
969 [llvm_i64_ty, llvm_i32_ty,
970 llvm_ptr_ty, llvm_i32_ty,
973 def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
974 [llvm_i64_ty, llvm_i32_ty,
975 llvm_ptr_ty, llvm_i32_ty,
980 //===------------------------ Garbage Collection Intrinsics ---------------===//
981 // These are documented in docs/Statepoint.rst
983 def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
984 [llvm_i64_ty, llvm_i32_ty,
985 llvm_anyptr_ty, llvm_i32_ty,
986 llvm_i32_ty, llvm_vararg_ty],
987 [Throws, ImmArg<0>, ImmArg<1>, ImmArg<3>, ImmArg<4>]>;
989 def int_experimental_gc_result : Intrinsic<[llvm_any_ty], [llvm_token_ty],
991 def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
992 [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
993 [IntrReadMem, ImmArg<1>, ImmArg<2>]>;
995 //===------------------------ Coroutine Intrinsics ---------------===//
996 // These are documented in docs/Coroutines.rst
998 // Coroutine Structure Intrinsics.
1000 def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty,
1001 llvm_ptr_ty, llvm_ptr_ty],
1002 [IntrArgMemOnly, IntrReadMem,
1003 ReadNone<1>, ReadOnly<2>, NoCapture<2>]>;
1004 def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
1005 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1006 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1008 def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
1009 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1010 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1012 def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
1013 def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1016 def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1017 [IntrReadMem, IntrArgMemOnly, ReadOnly<1>,
1019 def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
1021 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1022 def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1023 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1025 def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
1026 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1027 def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1028 def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1030 def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1031 [llvm_anyint_ty, llvm_i32_ty], []>;
1032 def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1033 def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1035 def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty],
1036 [IntrNoMem, ReadNone<0>, ReadNone<1>]>;
1038 // Coroutine Manipulation Intrinsics.
1040 def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1041 def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1042 def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1043 [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>;
1044 def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1045 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1046 [IntrNoMem, NoCapture<0>]>;
1048 // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1050 def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1051 [IntrReadMem, IntrArgMemOnly, ReadOnly<0>,
1054 ///===-------------------------- Other Intrinsics --------------------------===//
1056 def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
1057 GCCBuiltin<"__builtin_flt_rounds">;
1058 def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
1059 GCCBuiltin<"__builtin_trap">;
1060 def int_debugtrap : Intrinsic<[]>,
1061 GCCBuiltin<"__builtin_debugtrap">;
1063 // Support for dynamic deoptimization (or de-specialization)
1064 def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1067 // Support for speculative runtime guards
1068 def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1071 // Supports widenable conditions for guards represented as explicit branches.
1072 def int_experimental_widenable_condition : Intrinsic<[llvm_i1_ty], [],
1073 [IntrInaccessibleMemOnly, IntrWillReturn]>;
1075 // NOP: calls/invokes to this intrinsic are removed by codegen
1076 def int_donothing : Intrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1078 // This instruction has no actual effect, though it is treated by the optimizer
1079 // has having opaque side effects. This may be inserted into loops to ensure
1080 // that they are not removed even if they turn out to be empty, for languages
1081 // which specify that infinite loops must be preserved.
1082 def int_sideeffect : Intrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1084 // Intrinsics to support half precision floating point format
1085 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1086 def int_convert_to_fp16 : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1087 def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1090 // Clear cache intrinsic, default to ignore (ie. emit nothing)
1091 // maps to void __clear_cache() on supporting platforms
1092 def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1093 [], "llvm.clear_cache">;
1095 // Intrinsic to detect whether its argument is a constant.
1096 def int_is_constant : Intrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem, IntrWillReturn], "llvm.is.constant">;
1098 // Intrinsic to mask out bits of a pointer.
1099 def int_ptrmask: Intrinsic<[llvm_anyptr_ty], [llvm_anyptr_ty, llvm_anyint_ty],
1100 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1102 //===-------------------------- Masked Intrinsics -------------------------===//
1104 def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
1105 LLVMAnyPointerType<LLVMMatchType<0>>,
1107 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1108 [IntrArgMemOnly, IntrWillReturn, ImmArg<2>]>;
1110 def int_masked_load : Intrinsic<[llvm_anyvector_ty],
1111 [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
1112 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1113 [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<1>]>;
1115 def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
1116 [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1117 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1119 [IntrReadMem, IntrWillReturn, ImmArg<1>]>;
1121 def int_masked_scatter: Intrinsic<[],
1123 LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1124 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1125 [IntrWillReturn, ImmArg<2>]>;
1127 def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
1128 [LLVMPointerToElt<0>,
1129 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1131 [IntrReadMem, IntrWillReturn]>;
1133 def int_masked_compressstore: Intrinsic<[],
1135 LLVMPointerToElt<0>,
1136 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1137 [IntrArgMemOnly, IntrWillReturn]>;
1139 // Test whether a pointer is associated with a type metadata identifier.
1140 def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1141 [IntrNoMem, IntrWillReturn]>;
1143 // Safely loads a function pointer from a virtual table pointer using type metadata.
1144 def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty],
1145 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
1146 [IntrNoMem, IntrWillReturn]>;
1148 // Create a branch funnel that implements an indirect call to a limited set of
1149 // callees. This needs to be a musttail call.
1150 def int_icall_branch_funnel : Intrinsic<[], [llvm_vararg_ty], []>;
1152 def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
1153 [IntrReadMem, IntrArgMemOnly]>;
1155 def int_hwasan_check_memaccess :
1156 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1157 def int_hwasan_check_memaccess_shortgranules :
1158 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1161 //===----------------------------------------------------------------------===//
1162 // Custom event logging for x-ray.
1163 // Takes a pointer to a string and the length of the string.
1164 def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
1165 [NoCapture<0>, ReadOnly<0>, IntrWriteMem]>;
1166 // Typed event logging for x-ray.
1167 // Takes a numeric type tag, a pointer to a string and the length of the string.
1168 def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
1169 [NoCapture<1>, ReadOnly<1>, IntrWriteMem]>;
1170 //===----------------------------------------------------------------------===//
1172 //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
1175 // @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
1176 def int_memcpy_element_unordered_atomic
1179 llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1182 IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1183 ReadOnly<1>, ImmArg<3>
1186 // @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
1187 def int_memmove_element_unordered_atomic
1190 llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1193 IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1194 ReadOnly<1>, ImmArg<3>
1197 // @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
1198 def int_memset_element_unordered_atomic
1199 : Intrinsic<[], [ llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty ],
1200 [ IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>, ImmArg<3> ]>;
1202 //===------------------------ Reduction Intrinsics ------------------------===//
1204 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1205 def int_experimental_vector_reduce_v2_fadd : Intrinsic<[llvm_anyfloat_ty],
1207 llvm_anyvector_ty]>;
1208 def int_experimental_vector_reduce_v2_fmul : Intrinsic<[llvm_anyfloat_ty],
1210 llvm_anyvector_ty]>;
1211 def int_experimental_vector_reduce_add : Intrinsic<[LLVMVectorElementType<0>],
1212 [llvm_anyvector_ty]>;
1213 def int_experimental_vector_reduce_mul : Intrinsic<[LLVMVectorElementType<0>],
1214 [llvm_anyvector_ty]>;
1215 def int_experimental_vector_reduce_and : Intrinsic<[LLVMVectorElementType<0>],
1216 [llvm_anyvector_ty]>;
1217 def int_experimental_vector_reduce_or : Intrinsic<[LLVMVectorElementType<0>],
1218 [llvm_anyvector_ty]>;
1219 def int_experimental_vector_reduce_xor : Intrinsic<[LLVMVectorElementType<0>],
1220 [llvm_anyvector_ty]>;
1221 def int_experimental_vector_reduce_smax : Intrinsic<[LLVMVectorElementType<0>],
1222 [llvm_anyvector_ty]>;
1223 def int_experimental_vector_reduce_smin : Intrinsic<[LLVMVectorElementType<0>],
1224 [llvm_anyvector_ty]>;
1225 def int_experimental_vector_reduce_umax : Intrinsic<[LLVMVectorElementType<0>],
1226 [llvm_anyvector_ty]>;
1227 def int_experimental_vector_reduce_umin : Intrinsic<[LLVMVectorElementType<0>],
1228 [llvm_anyvector_ty]>;
1229 def int_experimental_vector_reduce_fmax : Intrinsic<[LLVMVectorElementType<0>],
1230 [llvm_anyvector_ty]>;
1231 def int_experimental_vector_reduce_fmin : Intrinsic<[LLVMVectorElementType<0>],
1232 [llvm_anyvector_ty]>;
1235 //===---------- Intrinsics to control hardware supported loops ----------===//
1237 // Specify that the value given is the number of iterations that the next loop
1239 def int_set_loop_iterations :
1240 Intrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
1242 // Specify that the value given is the number of iterations that the next loop
1243 // will execute. Also test that the given count is not zero, allowing it to
1244 // control entry to a 'while' loop.
1245 def int_test_set_loop_iterations :
1246 Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1248 // Decrement loop counter by the given argument. Return false if the loop
1250 def int_loop_decrement :
1251 Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1253 // Decrement the first operand (the loop counter) by the second operand (the
1254 // maximum number of elements processed in an iteration). Return the remaining
1255 // number of iterations still to be executed. This is effectively a sub which
1256 // can be used with a phi, icmp and br to control the number of iterations
1257 // executed, as usual.
1258 def int_loop_decrement_reg :
1259 Intrinsic<[llvm_anyint_ty],
1260 [llvm_anyint_ty, llvm_anyint_ty], [IntrNoDuplicate]>;
1262 //===----- Intrinsics that are used to provide predicate information -----===//
1264 def int_ssa_copy : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
1265 [IntrNoMem, Returned<0>]>;
1267 //===------- Intrinsics that are used to preserve debug information -------===//
1269 def int_preserve_array_access_index : Intrinsic<[llvm_anyptr_ty],
1270 [llvm_anyptr_ty, llvm_i32_ty,
1272 [IntrNoMem, ImmArg<1>, ImmArg<2>]>;
1273 def int_preserve_union_access_index : Intrinsic<[llvm_anyptr_ty],
1274 [llvm_anyptr_ty, llvm_i32_ty],
1275 [IntrNoMem, ImmArg<1>]>;
1276 def int_preserve_struct_access_index : Intrinsic<[llvm_anyptr_ty],
1277 [llvm_anyptr_ty, llvm_i32_ty,
1279 [IntrNoMem, ImmArg<1>,
1282 //===----------------------------------------------------------------------===//
1283 // Target-specific intrinsics
1284 //===----------------------------------------------------------------------===//
1286 include "llvm/IR/IntrinsicsPowerPC.td"
1287 include "llvm/IR/IntrinsicsX86.td"
1288 include "llvm/IR/IntrinsicsARM.td"
1289 include "llvm/IR/IntrinsicsAArch64.td"
1290 include "llvm/IR/IntrinsicsXCore.td"
1291 include "llvm/IR/IntrinsicsHexagon.td"
1292 include "llvm/IR/IntrinsicsNVVM.td"
1293 include "llvm/IR/IntrinsicsMips.td"
1294 include "llvm/IR/IntrinsicsAMDGPU.td"
1295 include "llvm/IR/IntrinsicsBPF.td"
1296 include "llvm/IR/IntrinsicsSystemZ.td"
1297 include "llvm/IR/IntrinsicsWebAssembly.td"
1298 include "llvm/IR/IntrinsicsRISCV.td"