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 // Internal interface for object size checking
586 def int_objectsize : Intrinsic<[llvm_anyint_ty],
587 [llvm_anyptr_ty, llvm_i1_ty,
588 llvm_i1_ty, llvm_i1_ty],
589 [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>, ImmArg<2>, ImmArg<3>]>,
590 GCCBuiltin<"__builtin_object_size">;
592 //===--------------- Constrained Floating Point Intrinsics ----------------===//
595 let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
596 def int_experimental_constrained_fadd : Intrinsic<[ llvm_anyfloat_ty ],
601 def int_experimental_constrained_fsub : Intrinsic<[ llvm_anyfloat_ty ],
606 def int_experimental_constrained_fmul : Intrinsic<[ llvm_anyfloat_ty ],
611 def int_experimental_constrained_fdiv : Intrinsic<[ llvm_anyfloat_ty ],
616 def int_experimental_constrained_frem : Intrinsic<[ llvm_anyfloat_ty ],
622 def int_experimental_constrained_fma : Intrinsic<[ llvm_anyfloat_ty ],
629 def int_experimental_constrained_fptosi : Intrinsic<[ llvm_anyint_ty ],
633 def int_experimental_constrained_fptoui : Intrinsic<[ llvm_anyint_ty ],
637 def int_experimental_constrained_sitofp : Intrinsic<[ llvm_anyfloat_ty ],
642 def int_experimental_constrained_uitofp : Intrinsic<[ llvm_anyfloat_ty ],
647 def int_experimental_constrained_fptrunc : Intrinsic<[ llvm_anyfloat_ty ],
652 def int_experimental_constrained_fpext : Intrinsic<[ llvm_anyfloat_ty ],
656 // These intrinsics are sensitive to the rounding mode so we need constrained
657 // versions of each of them. When strict rounding and exception control are
658 // not required the non-constrained versions of these intrinsics should be
660 def int_experimental_constrained_sqrt : Intrinsic<[ llvm_anyfloat_ty ],
664 def int_experimental_constrained_powi : Intrinsic<[ llvm_anyfloat_ty ],
669 def int_experimental_constrained_sin : Intrinsic<[ llvm_anyfloat_ty ],
673 def int_experimental_constrained_cos : Intrinsic<[ llvm_anyfloat_ty ],
677 def int_experimental_constrained_pow : Intrinsic<[ llvm_anyfloat_ty ],
682 def int_experimental_constrained_log : Intrinsic<[ llvm_anyfloat_ty ],
686 def int_experimental_constrained_log10: Intrinsic<[ llvm_anyfloat_ty ],
690 def int_experimental_constrained_log2 : Intrinsic<[ llvm_anyfloat_ty ],
694 def int_experimental_constrained_exp : Intrinsic<[ llvm_anyfloat_ty ],
698 def int_experimental_constrained_exp2 : Intrinsic<[ llvm_anyfloat_ty ],
702 def int_experimental_constrained_rint : Intrinsic<[ llvm_anyfloat_ty ],
706 def int_experimental_constrained_nearbyint : Intrinsic<[ llvm_anyfloat_ty ],
710 def int_experimental_constrained_lrint : Intrinsic<[ llvm_anyint_ty ],
714 def int_experimental_constrained_llrint : Intrinsic<[ llvm_anyint_ty ],
718 def int_experimental_constrained_maxnum : Intrinsic<[ llvm_anyfloat_ty ],
722 def int_experimental_constrained_minnum : Intrinsic<[ llvm_anyfloat_ty ],
726 def int_experimental_constrained_maximum : Intrinsic<[ llvm_anyfloat_ty ],
730 def int_experimental_constrained_minimum : Intrinsic<[ llvm_anyfloat_ty ],
734 def int_experimental_constrained_ceil : Intrinsic<[ llvm_anyfloat_ty ],
737 def int_experimental_constrained_floor : Intrinsic<[ llvm_anyfloat_ty ],
740 def int_experimental_constrained_lround : Intrinsic<[ llvm_anyint_ty ],
743 def int_experimental_constrained_llround : Intrinsic<[ llvm_anyint_ty ],
746 def int_experimental_constrained_round : Intrinsic<[ llvm_anyfloat_ty ],
749 def int_experimental_constrained_trunc : Intrinsic<[ llvm_anyfloat_ty ],
753 // Constrained floating-point comparison (quiet and signaling variants).
754 // Third operand is the predicate represented as a metadata string.
755 def int_experimental_constrained_fcmp
756 : Intrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
757 [ llvm_anyfloat_ty, LLVMMatchType<0>,
758 llvm_metadata_ty, llvm_metadata_ty ]>;
759 def int_experimental_constrained_fcmps
760 : Intrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
761 [ llvm_anyfloat_ty, LLVMMatchType<0>,
762 llvm_metadata_ty, llvm_metadata_ty ]>;
764 // FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
766 //===------------------------- Expect Intrinsics --------------------------===//
768 def int_expect : Intrinsic<[llvm_anyint_ty],
769 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
771 //===-------------------- Bit Manipulation Intrinsics ---------------------===//
774 // None of these intrinsics accesses memory at all.
775 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
776 def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
777 def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
778 def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
779 def int_fshl : Intrinsic<[llvm_anyint_ty],
780 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
781 def int_fshr : Intrinsic<[llvm_anyint_ty],
782 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
785 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>] in {
786 def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
787 def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
790 //===------------------------ Debugger Intrinsics -------------------------===//
793 // None of these intrinsics accesses memory at all...but that doesn't
794 // mean the optimizers can change them aggressively. Special handling
795 // needed in a few places. These synthetic intrinsics have no
796 // side-effects and just mark information about their operands.
797 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
798 def int_dbg_declare : Intrinsic<[],
802 def int_dbg_value : Intrinsic<[],
806 def int_dbg_addr : Intrinsic<[],
810 def int_dbg_label : Intrinsic<[],
814 //===------------------ Exception Handling Intrinsics----------------------===//
817 // The result of eh.typeid.for depends on the enclosing function, but inside a
818 // given function it is 'const' and may be CSE'd etc.
819 def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
821 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
822 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
824 // eh.exceptionpointer returns the pointer to the exception caught by
825 // the given `catchpad`.
826 def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
829 // Gets the exception code from a catchpad token. Only used on some platforms.
830 def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
832 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
833 // callee-saved registers to be saved and restored (regardless of whether they
834 // are used) in the calling function. It is used by libgcc_eh.
835 def int_eh_unwind_init: Intrinsic<[]>,
836 GCCBuiltin<"__builtin_unwind_init">;
838 def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
840 let IntrProperties = [IntrNoMem] in {
841 def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty]>;
842 def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty]>;
844 def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
845 def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
846 def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
847 def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>;
849 //===---------------- Generic Variable Attribute Intrinsics----------------===//
851 def int_var_annotation : Intrinsic<[],
852 [llvm_ptr_ty, llvm_ptr_ty,
853 llvm_ptr_ty, llvm_i32_ty],
854 [IntrWillReturn], "llvm.var.annotation">;
855 def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>],
856 [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty,
858 [IntrWillReturn], "llvm.ptr.annotation">;
859 def int_annotation : Intrinsic<[llvm_anyint_ty],
860 [LLVMMatchType<0>, llvm_ptr_ty,
861 llvm_ptr_ty, llvm_i32_ty],
862 [IntrWillReturn], "llvm.annotation">;
864 // Annotates the current program point with metadata strings which are emitted
865 // as CodeView debug info records. This is expensive, as it disables inlining
866 // and is modelled as having side effects.
867 def int_codeview_annotation : Intrinsic<[], [llvm_metadata_ty],
868 [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
869 "llvm.codeview.annotation">;
871 //===------------------------ Trampoline Intrinsics -----------------------===//
873 def int_init_trampoline : Intrinsic<[],
874 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
875 [IntrArgMemOnly, NoCapture<0>]>,
876 GCCBuiltin<"__builtin_init_trampoline">;
878 def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
879 [IntrReadMem, IntrArgMemOnly]>,
880 GCCBuiltin<"__builtin_adjust_trampoline">;
882 //===------------------------ Overflow Intrinsics -------------------------===//
885 // Expose the carry flag from add operations on two integrals.
886 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
887 def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty,
888 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
889 [LLVMMatchType<0>, LLVMMatchType<0>]>;
890 def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty,
891 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
892 [LLVMMatchType<0>, LLVMMatchType<0>]>;
894 def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty,
895 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
896 [LLVMMatchType<0>, LLVMMatchType<0>]>;
897 def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty,
898 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
899 [LLVMMatchType<0>, LLVMMatchType<0>]>;
901 def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty,
902 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
903 [LLVMMatchType<0>, LLVMMatchType<0>]>;
904 def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty,
905 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
906 [LLVMMatchType<0>, LLVMMatchType<0>]>;
908 //===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
910 def int_sadd_sat : Intrinsic<[llvm_anyint_ty],
911 [LLVMMatchType<0>, LLVMMatchType<0>],
912 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
913 def int_uadd_sat : Intrinsic<[llvm_anyint_ty],
914 [LLVMMatchType<0>, LLVMMatchType<0>],
915 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
916 def int_ssub_sat : Intrinsic<[llvm_anyint_ty],
917 [LLVMMatchType<0>, LLVMMatchType<0>],
918 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
919 def int_usub_sat : Intrinsic<[llvm_anyint_ty],
920 [LLVMMatchType<0>, LLVMMatchType<0>],
921 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
923 //===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
925 def int_smul_fix : Intrinsic<[llvm_anyint_ty],
926 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
927 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
929 def int_umul_fix : Intrinsic<[llvm_anyint_ty],
930 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
931 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
933 def int_sdiv_fix : Intrinsic<[llvm_anyint_ty],
934 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
935 [IntrNoMem, ImmArg<2>]>;
937 def int_udiv_fix : Intrinsic<[llvm_anyint_ty],
938 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
939 [IntrNoMem, ImmArg<2>]>;
941 //===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
943 def int_smul_fix_sat : Intrinsic<[llvm_anyint_ty],
944 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
945 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
946 def int_umul_fix_sat : Intrinsic<[llvm_anyint_ty],
947 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
948 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative, ImmArg<2>]>;
950 //===------------------------- Memory Use Markers -------------------------===//
952 def int_lifetime_start : Intrinsic<[],
953 [llvm_i64_ty, llvm_anyptr_ty],
954 [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
955 def int_lifetime_end : Intrinsic<[],
956 [llvm_i64_ty, llvm_anyptr_ty],
957 [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
958 def int_invariant_start : Intrinsic<[llvm_descriptor_ty],
959 [llvm_i64_ty, llvm_anyptr_ty],
960 [IntrArgMemOnly, IntrWillReturn, NoCapture<1>, ImmArg<0>]>;
961 def int_invariant_end : Intrinsic<[],
962 [llvm_descriptor_ty, llvm_i64_ty,
964 [IntrArgMemOnly, IntrWillReturn, NoCapture<2>, ImmArg<1>]>;
966 // launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
967 // because it would cause CSE of two barriers with the same argument.
968 // Inaccessiblememonly says that the barrier doesn't read the argument,
969 // but it changes state not accessible to this module. This way
970 // we can DSE through the barrier because it doesn't read the value
971 // after store. Although the barrier doesn't modify any memory it
972 // can't be marked as readonly, because it would be possible to
973 // CSE 2 barriers with store in between.
974 // The argument also can't be marked with 'returned' attribute, because
975 // it would remove barrier.
976 // Note that it is still experimental, which means that its semantics
977 // might change in the future.
978 def int_launder_invariant_group : Intrinsic<[llvm_anyptr_ty],
980 [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
983 def int_strip_invariant_group : Intrinsic<[llvm_anyptr_ty],
985 [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
987 //===------------------------ Stackmap Intrinsics -------------------------===//
989 def int_experimental_stackmap : Intrinsic<[],
990 [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
992 def int_experimental_patchpoint_void : Intrinsic<[],
993 [llvm_i64_ty, llvm_i32_ty,
994 llvm_ptr_ty, llvm_i32_ty,
997 def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
998 [llvm_i64_ty, llvm_i32_ty,
999 llvm_ptr_ty, llvm_i32_ty,
1004 //===------------------------ Garbage Collection Intrinsics ---------------===//
1005 // These are documented in docs/Statepoint.rst
1007 def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
1008 [llvm_i64_ty, llvm_i32_ty,
1009 llvm_anyptr_ty, llvm_i32_ty,
1010 llvm_i32_ty, llvm_vararg_ty],
1011 [Throws, ImmArg<0>, ImmArg<1>, ImmArg<3>, ImmArg<4>]>;
1013 def int_experimental_gc_result : Intrinsic<[llvm_any_ty], [llvm_token_ty],
1015 def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
1016 [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
1017 [IntrReadMem, ImmArg<1>, ImmArg<2>]>;
1019 //===------------------------ Coroutine Intrinsics ---------------===//
1020 // These are documented in docs/Coroutines.rst
1022 // Coroutine Structure Intrinsics.
1024 def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty,
1025 llvm_ptr_ty, llvm_ptr_ty],
1026 [IntrArgMemOnly, IntrReadMem,
1027 ReadNone<1>, ReadOnly<2>, NoCapture<2>]>;
1028 def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
1029 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1030 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1032 def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
1033 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1034 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1036 def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
1037 def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1040 def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1041 [IntrReadMem, IntrArgMemOnly, ReadOnly<1>,
1043 def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
1045 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1046 def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1047 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1049 def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
1050 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1051 def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1052 def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1054 def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1055 [llvm_anyint_ty, llvm_i32_ty], []>;
1056 def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1057 def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1059 def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty],
1060 [IntrNoMem, ReadNone<0>, ReadNone<1>]>;
1062 // Coroutine Manipulation Intrinsics.
1064 def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1065 def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1066 def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1067 [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>;
1068 def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1069 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1070 [IntrNoMem, NoCapture<0>]>;
1072 // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1074 def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1075 [IntrReadMem, IntrArgMemOnly, ReadOnly<0>,
1078 ///===-------------------------- Other Intrinsics --------------------------===//
1080 def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
1081 GCCBuiltin<"__builtin_flt_rounds">;
1082 def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
1083 GCCBuiltin<"__builtin_trap">;
1084 def int_debugtrap : Intrinsic<[]>,
1085 GCCBuiltin<"__builtin_debugtrap">;
1087 // Support for dynamic deoptimization (or de-specialization)
1088 def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1091 // Support for speculative runtime guards
1092 def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1095 // Supports widenable conditions for guards represented as explicit branches.
1096 def int_experimental_widenable_condition : Intrinsic<[llvm_i1_ty], [],
1097 [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable]>;
1099 // NOP: calls/invokes to this intrinsic are removed by codegen
1100 def int_donothing : Intrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1102 // This instruction has no actual effect, though it is treated by the optimizer
1103 // has having opaque side effects. This may be inserted into loops to ensure
1104 // that they are not removed even if they turn out to be empty, for languages
1105 // which specify that infinite loops must be preserved.
1106 def int_sideeffect : Intrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1108 // Intrinsics to support half precision floating point format
1109 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1110 def int_convert_to_fp16 : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1111 def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1114 // Clear cache intrinsic, default to ignore (ie. emit nothing)
1115 // maps to void __clear_cache() on supporting platforms
1116 def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1117 [], "llvm.clear_cache">;
1119 // Intrinsic to detect whether its argument is a constant.
1120 def int_is_constant : Intrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem, IntrWillReturn], "llvm.is.constant">;
1122 // Intrinsic to mask out bits of a pointer.
1123 def int_ptrmask: Intrinsic<[llvm_anyptr_ty], [llvm_anyptr_ty, llvm_anyint_ty],
1124 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1126 //===-------------------------- Masked Intrinsics -------------------------===//
1128 def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
1129 LLVMAnyPointerType<LLVMMatchType<0>>,
1131 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1132 [IntrArgMemOnly, IntrWillReturn, ImmArg<2>]>;
1134 def int_masked_load : Intrinsic<[llvm_anyvector_ty],
1135 [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
1136 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1137 [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<1>]>;
1139 def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
1140 [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1141 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1143 [IntrReadMem, IntrWillReturn, ImmArg<1>]>;
1145 def int_masked_scatter: Intrinsic<[],
1147 LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1148 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1149 [IntrWillReturn, ImmArg<2>]>;
1151 def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
1152 [LLVMPointerToElt<0>,
1153 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1155 [IntrReadMem, IntrWillReturn]>;
1157 def int_masked_compressstore: Intrinsic<[],
1159 LLVMPointerToElt<0>,
1160 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1161 [IntrArgMemOnly, IntrWillReturn]>;
1163 // Test whether a pointer is associated with a type metadata identifier.
1164 def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1165 [IntrNoMem, IntrWillReturn]>;
1167 // Safely loads a function pointer from a virtual table pointer using type metadata.
1168 def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty],
1169 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
1170 [IntrNoMem, IntrWillReturn]>;
1172 // Create a branch funnel that implements an indirect call to a limited set of
1173 // callees. This needs to be a musttail call.
1174 def int_icall_branch_funnel : Intrinsic<[], [llvm_vararg_ty], []>;
1176 def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
1177 [IntrReadMem, IntrArgMemOnly]>;
1179 def int_hwasan_check_memaccess :
1180 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1181 def int_hwasan_check_memaccess_shortgranules :
1182 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1185 //===----------------------------------------------------------------------===//
1186 // Custom event logging for x-ray.
1187 // Takes a pointer to a string and the length of the string.
1188 def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
1189 [NoCapture<0>, ReadOnly<0>, IntrWriteMem]>;
1190 // Typed event logging for x-ray.
1191 // Takes a numeric type tag, a pointer to a string and the length of the string.
1192 def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
1193 [NoCapture<1>, ReadOnly<1>, IntrWriteMem]>;
1194 //===----------------------------------------------------------------------===//
1196 //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
1199 // @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
1200 def int_memcpy_element_unordered_atomic
1203 llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1206 IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1207 ReadOnly<1>, ImmArg<3>
1210 // @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
1211 def int_memmove_element_unordered_atomic
1214 llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1217 IntrArgMemOnly, IntrWillReturn, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1218 ReadOnly<1>, ImmArg<3>
1221 // @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
1222 def int_memset_element_unordered_atomic
1223 : Intrinsic<[], [ llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty ],
1224 [ IntrArgMemOnly, IntrWillReturn, NoCapture<0>, WriteOnly<0>, ImmArg<3> ]>;
1226 //===------------------------ Reduction Intrinsics ------------------------===//
1228 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1229 def int_experimental_vector_reduce_v2_fadd : Intrinsic<[llvm_anyfloat_ty],
1231 llvm_anyvector_ty]>;
1232 def int_experimental_vector_reduce_v2_fmul : Intrinsic<[llvm_anyfloat_ty],
1234 llvm_anyvector_ty]>;
1235 def int_experimental_vector_reduce_add : Intrinsic<[LLVMVectorElementType<0>],
1236 [llvm_anyvector_ty]>;
1237 def int_experimental_vector_reduce_mul : Intrinsic<[LLVMVectorElementType<0>],
1238 [llvm_anyvector_ty]>;
1239 def int_experimental_vector_reduce_and : Intrinsic<[LLVMVectorElementType<0>],
1240 [llvm_anyvector_ty]>;
1241 def int_experimental_vector_reduce_or : Intrinsic<[LLVMVectorElementType<0>],
1242 [llvm_anyvector_ty]>;
1243 def int_experimental_vector_reduce_xor : Intrinsic<[LLVMVectorElementType<0>],
1244 [llvm_anyvector_ty]>;
1245 def int_experimental_vector_reduce_smax : Intrinsic<[LLVMVectorElementType<0>],
1246 [llvm_anyvector_ty]>;
1247 def int_experimental_vector_reduce_smin : Intrinsic<[LLVMVectorElementType<0>],
1248 [llvm_anyvector_ty]>;
1249 def int_experimental_vector_reduce_umax : Intrinsic<[LLVMVectorElementType<0>],
1250 [llvm_anyvector_ty]>;
1251 def int_experimental_vector_reduce_umin : Intrinsic<[LLVMVectorElementType<0>],
1252 [llvm_anyvector_ty]>;
1253 def int_experimental_vector_reduce_fmax : Intrinsic<[LLVMVectorElementType<0>],
1254 [llvm_anyvector_ty]>;
1255 def int_experimental_vector_reduce_fmin : Intrinsic<[LLVMVectorElementType<0>],
1256 [llvm_anyvector_ty]>;
1259 //===----- Matrix intrinsics ---------------------------------------------===//
1261 def int_matrix_transpose : Intrinsic<[llvm_anyvector_ty],
1265 [IntrNoMem, IntrSpeculatable,
1266 IntrWillReturn, ImmArg<1>, ImmArg<2>]>;
1268 def int_matrix_multiply : Intrinsic<[llvm_anyvector_ty],
1274 [IntrNoMem, IntrSpeculatable,
1275 IntrWillReturn, ImmArg<2>, ImmArg<3>,
1278 def int_matrix_columnwise_load : Intrinsic<[llvm_anyvector_ty],
1279 [LLVMAnyPointerType<LLVMMatchType<0>>,
1283 [IntrReadMem, IntrWillReturn,
1284 ImmArg<2>, ImmArg<3>]>;
1286 def int_matrix_columnwise_store : Intrinsic<[],
1288 LLVMAnyPointerType<LLVMMatchType<0>>,
1292 [WriteOnly<1>, IntrWillReturn,
1293 ImmArg<3>, ImmArg<4>]>;
1295 //===---------- Intrinsics to control hardware supported loops ----------===//
1297 // Specify that the value given is the number of iterations that the next loop
1299 def int_set_loop_iterations :
1300 Intrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
1302 // Specify that the value given is the number of iterations that the next loop
1303 // will execute. Also test that the given count is not zero, allowing it to
1304 // control entry to a 'while' loop.
1305 def int_test_set_loop_iterations :
1306 Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1308 // Decrement loop counter by the given argument. Return false if the loop
1310 def int_loop_decrement :
1311 Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1313 // Decrement the first operand (the loop counter) by the second operand (the
1314 // maximum number of elements processed in an iteration). Return the remaining
1315 // number of iterations still to be executed. This is effectively a sub which
1316 // can be used with a phi, icmp and br to control the number of iterations
1317 // executed, as usual. Any optimisations are allowed to treat it is a sub, and
1318 // it's scevable, so it's the backends responsibility to handle cases where it
1319 // may be optimised.
1320 def int_loop_decrement_reg :
1321 Intrinsic<[llvm_anyint_ty],
1322 [llvm_anyint_ty, llvm_anyint_ty], [IntrNoDuplicate]>;
1324 //===----- Intrinsics that are used to provide predicate information -----===//
1326 def int_ssa_copy : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
1327 [IntrNoMem, Returned<0>]>;
1329 //===------- Intrinsics that are used to preserve debug information -------===//
1331 def int_preserve_array_access_index : Intrinsic<[llvm_anyptr_ty],
1332 [llvm_anyptr_ty, llvm_i32_ty,
1334 [IntrNoMem, ImmArg<1>, ImmArg<2>]>;
1335 def int_preserve_union_access_index : Intrinsic<[llvm_anyptr_ty],
1336 [llvm_anyptr_ty, llvm_i32_ty],
1337 [IntrNoMem, ImmArg<1>]>;
1338 def int_preserve_struct_access_index : Intrinsic<[llvm_anyptr_ty],
1339 [llvm_anyptr_ty, llvm_i32_ty,
1341 [IntrNoMem, ImmArg<1>,
1344 //===----------------------------------------------------------------------===//
1345 // Target-specific intrinsics
1346 //===----------------------------------------------------------------------===//
1348 include "llvm/IR/IntrinsicsPowerPC.td"
1349 include "llvm/IR/IntrinsicsX86.td"
1350 include "llvm/IR/IntrinsicsARM.td"
1351 include "llvm/IR/IntrinsicsAArch64.td"
1352 include "llvm/IR/IntrinsicsXCore.td"
1353 include "llvm/IR/IntrinsicsHexagon.td"
1354 include "llvm/IR/IntrinsicsNVVM.td"
1355 include "llvm/IR/IntrinsicsMips.td"
1356 include "llvm/IR/IntrinsicsAMDGPU.td"
1357 include "llvm/IR/IntrinsicsBPF.td"
1358 include "llvm/IR/IntrinsicsSystemZ.td"
1359 include "llvm/IR/IntrinsicsWebAssembly.td"
1360 include "llvm/IR/IntrinsicsRISCV.td"