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 // Returned - The specified argument is always the return value of the
68 class Returned<int argNo> : IntrinsicProperty {
72 // ImmArg - The specified argument must be an immediate.
73 class ImmArg<int argNo> : IntrinsicProperty {
77 // ReadOnly - The specified argument pointer is not written to through the
78 // pointer by the intrinsic.
79 class ReadOnly<int argNo> : IntrinsicProperty {
83 // WriteOnly - The intrinsic does not read memory through the specified
85 class WriteOnly<int argNo> : IntrinsicProperty {
89 // ReadNone - The specified argument pointer is not dereferenced by the
91 class ReadNone<int argNo> : IntrinsicProperty {
95 def IntrNoReturn : IntrinsicProperty;
97 // IntrCold - Calls to this intrinsic are cold.
98 // Parallels the cold attribute on LLVM IR functions.
99 def IntrCold : IntrinsicProperty;
101 // IntrNoduplicate - Calls to this intrinsic cannot be duplicated.
102 // Parallels the noduplicate attribute on LLVM IR functions.
103 def IntrNoDuplicate : IntrinsicProperty;
105 // IntrConvergent - Calls to this intrinsic are convergent and may not be made
106 // control-dependent on any additional values.
107 // Parallels the convergent attribute on LLVM IR functions.
108 def IntrConvergent : IntrinsicProperty;
110 // This property indicates that the intrinsic is safe to speculate.
111 def IntrSpeculatable : IntrinsicProperty;
113 // This property can be used to override the 'has no other side effects'
114 // language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly
115 // intrinsic properties. By default, intrinsics are assumed to have side
116 // effects, so this property is only necessary if you have defined one of
117 // the memory properties listed above.
118 // For this property, 'side effects' has the same meaning as 'side effects'
119 // defined by the hasSideEffects property of the TableGen Instruction class.
120 def IntrHasSideEffects : IntrinsicProperty;
122 //===----------------------------------------------------------------------===//
123 // Types used by intrinsics.
124 //===----------------------------------------------------------------------===//
126 class LLVMType<ValueType vt> {
131 class LLVMQualPointerType<LLVMType elty, int addrspace>
133 LLVMType ElTy = elty;
134 int AddrSpace = addrspace;
137 class LLVMPointerType<LLVMType elty>
138 : LLVMQualPointerType<elty, 0>;
140 class LLVMAnyPointerType<LLVMType elty>
142 LLVMType ElTy = elty;
147 // Match the type of another intrinsic parameter. Number is an index into the
148 // list of overloaded types for the intrinsic, excluding all the fixed types.
149 // The Number value must refer to a previously listed type. For example:
150 // Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
151 // has two overloaded types, the 2nd and 3rd arguments. LLVMMatchType<0>
152 // refers to the first overloaded type, which is the 2nd argument.
153 class LLVMMatchType<int num>
158 // Match the type of another intrinsic parameter that is expected to be based on
159 // an integral type (i.e. either iN or <N x iM>), but change the scalar size to
160 // be twice as wide or half as wide as the other type. This is only useful when
161 // the intrinsic is overloaded, so the matched type should be declared as iAny.
162 class LLVMExtendedType<int num> : LLVMMatchType<num>;
163 class LLVMTruncatedType<int num> : LLVMMatchType<num>;
165 // Match the scalar/vector of another intrinsic parameter but with a different
166 // element type. Either both are scalars or both are vectors with the same
167 // number of elements.
168 class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
169 : LLVMMatchType<idx> {
170 ValueType ElTy = elty.VT;
173 class LLVMPointerTo<int num> : LLVMMatchType<num>;
174 class LLVMPointerToElt<int num> : LLVMMatchType<num>;
175 class LLVMVectorOfAnyPointersToElt<int num> : LLVMMatchType<num>;
176 class LLVMVectorElementType<int num> : LLVMMatchType<num>;
178 // Match the type of another intrinsic parameter that is expected to be a
179 // vector type, but change the element count to be half as many
180 class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
182 def llvm_void_ty : LLVMType<isVoid>;
184 def llvm_any_ty : LLVMType<Any>;
185 def llvm_anyint_ty : LLVMType<iAny>;
186 def llvm_anyfloat_ty : LLVMType<fAny>;
187 def llvm_anyvector_ty : LLVMType<vAny>;
189 def llvm_i1_ty : LLVMType<i1>;
190 def llvm_i8_ty : LLVMType<i8>;
191 def llvm_i16_ty : LLVMType<i16>;
192 def llvm_i32_ty : LLVMType<i32>;
193 def llvm_i64_ty : LLVMType<i64>;
194 def llvm_half_ty : LLVMType<f16>;
195 def llvm_float_ty : LLVMType<f32>;
196 def llvm_double_ty : LLVMType<f64>;
197 def llvm_f80_ty : LLVMType<f80>;
198 def llvm_f128_ty : LLVMType<f128>;
199 def llvm_ppcf128_ty : LLVMType<ppcf128>;
200 def llvm_ptr_ty : LLVMPointerType<llvm_i8_ty>; // i8*
201 def llvm_ptrptr_ty : LLVMPointerType<llvm_ptr_ty>; // i8**
202 def llvm_anyptr_ty : LLVMAnyPointerType<llvm_i8_ty>; // (space)i8*
203 def llvm_empty_ty : LLVMType<OtherVT>; // { }
204 def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>; // { }*
205 def llvm_metadata_ty : LLVMType<MetadataVT>; // !{...}
206 def llvm_token_ty : LLVMType<token>; // token
208 def llvm_x86mmx_ty : LLVMType<x86mmx>;
209 def llvm_ptrx86mmx_ty : LLVMPointerType<llvm_x86mmx_ty>; // <1 x i64>*
211 def llvm_v2i1_ty : LLVMType<v2i1>; // 2 x i1
212 def llvm_v4i1_ty : LLVMType<v4i1>; // 4 x i1
213 def llvm_v8i1_ty : LLVMType<v8i1>; // 8 x i1
214 def llvm_v16i1_ty : LLVMType<v16i1>; // 16 x i1
215 def llvm_v32i1_ty : LLVMType<v32i1>; // 32 x i1
216 def llvm_v64i1_ty : LLVMType<v64i1>; // 64 x i1
217 def llvm_v512i1_ty : LLVMType<v512i1>; // 512 x i1
218 def llvm_v1024i1_ty : LLVMType<v1024i1>; //1024 x i1
220 def llvm_v1i8_ty : LLVMType<v1i8>; // 1 x i8
221 def llvm_v2i8_ty : LLVMType<v2i8>; // 2 x i8
222 def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8
223 def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8
224 def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8
225 def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8
226 def llvm_v64i8_ty : LLVMType<v64i8>; // 64 x i8
227 def llvm_v128i8_ty : LLVMType<v128i8>; //128 x i8
228 def llvm_v256i8_ty : LLVMType<v256i8>; //256 x i8
230 def llvm_v1i16_ty : LLVMType<v1i16>; // 1 x i16
231 def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16
232 def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16
233 def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16
234 def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16
235 def llvm_v32i16_ty : LLVMType<v32i16>; // 32 x i16
236 def llvm_v64i16_ty : LLVMType<v64i16>; // 64 x i16
237 def llvm_v128i16_ty : LLVMType<v128i16>; //128 x i16
239 def llvm_v1i32_ty : LLVMType<v1i32>; // 1 x i32
240 def llvm_v2i32_ty : LLVMType<v2i32>; // 2 x i32
241 def llvm_v4i32_ty : LLVMType<v4i32>; // 4 x i32
242 def llvm_v8i32_ty : LLVMType<v8i32>; // 8 x i32
243 def llvm_v16i32_ty : LLVMType<v16i32>; // 16 x i32
244 def llvm_v32i32_ty : LLVMType<v32i32>; // 32 x i32
245 def llvm_v64i32_ty : LLVMType<v64i32>; // 64 x i32
247 def llvm_v1i64_ty : LLVMType<v1i64>; // 1 x i64
248 def llvm_v2i64_ty : LLVMType<v2i64>; // 2 x i64
249 def llvm_v4i64_ty : LLVMType<v4i64>; // 4 x i64
250 def llvm_v8i64_ty : LLVMType<v8i64>; // 8 x i64
251 def llvm_v16i64_ty : LLVMType<v16i64>; // 16 x i64
252 def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64
254 def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128
256 def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16)
257 def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16)
258 def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16)
259 def llvm_v1f32_ty : LLVMType<v1f32>; // 1 x float
260 def llvm_v2f32_ty : LLVMType<v2f32>; // 2 x float
261 def llvm_v4f32_ty : LLVMType<v4f32>; // 4 x float
262 def llvm_v8f32_ty : LLVMType<v8f32>; // 8 x float
263 def llvm_v16f32_ty : LLVMType<v16f32>; // 16 x float
264 def llvm_v32f32_ty : LLVMType<v32f32>; // 32 x float
265 def llvm_v1f64_ty : LLVMType<v1f64>; // 1 x double
266 def llvm_v2f64_ty : LLVMType<v2f64>; // 2 x double
267 def llvm_v4f64_ty : LLVMType<v4f64>; // 4 x double
268 def llvm_v8f64_ty : LLVMType<v8f64>; // 8 x double
270 def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here
272 //===----------------------------------------------------------------------===//
273 // Intrinsic Definitions.
274 //===----------------------------------------------------------------------===//
276 // Intrinsic class - This is used to define one LLVM intrinsic. The name of the
277 // intrinsic definition should start with "int_", then match the LLVM intrinsic
278 // name with the "llvm." prefix removed, and all "."s turned into "_"s. For
279 // example, llvm.bswap.i16 -> int_bswap_i16.
281 // * RetTypes is a list containing the return types expected for the
283 // * ParamTypes is a list containing the parameter types expected for the
285 // * Properties can be set to describe the behavior of the intrinsic.
287 class Intrinsic<list<LLVMType> ret_types,
288 list<LLVMType> param_types = [],
289 list<IntrinsicProperty> intr_properties = [],
291 list<SDNodeProperty> sd_properties = []> : SDPatternOperator {
292 string LLVMName = name;
293 string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics.
294 list<LLVMType> RetTypes = ret_types;
295 list<LLVMType> ParamTypes = param_types;
296 list<IntrinsicProperty> IntrProperties = intr_properties;
297 let Properties = sd_properties;
302 /// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this
303 /// specifies the name of the builtin. This provides automatic CBE and CFE
305 class GCCBuiltin<string name> {
306 string GCCBuiltinName = name;
309 class MSBuiltin<string name> {
310 string MSBuiltinName = name;
314 //===--------------- Variable Argument Handling Intrinsics ----------------===//
317 def int_vastart : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
318 def int_vacopy : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
320 def int_vaend : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
322 //===------------------- Garbage Collection Intrinsics --------------------===//
324 def int_gcroot : Intrinsic<[],
325 [llvm_ptrptr_ty, llvm_ptr_ty]>;
326 def int_gcread : Intrinsic<[llvm_ptr_ty],
327 [llvm_ptr_ty, llvm_ptrptr_ty],
328 [IntrReadMem, IntrArgMemOnly]>;
329 def int_gcwrite : Intrinsic<[],
330 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
331 [IntrArgMemOnly, NoCapture<1>, NoCapture<2>]>;
333 //===------------------- ObjC ARC runtime Intrinsics --------------------===//
335 // Note these are to support the Objective-C ARC optimizer which wants to
336 // eliminate retain and releases where possible.
338 def int_objc_autorelease : Intrinsic<[llvm_ptr_ty],
340 def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>;
341 def int_objc_autoreleasePoolPush : Intrinsic<[llvm_ptr_ty], []>;
342 def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
344 def int_objc_copyWeak : Intrinsic<[],
347 def int_objc_destroyWeak : Intrinsic<[], [llvm_ptrptr_ty]>;
348 def int_objc_initWeak : Intrinsic<[llvm_ptr_ty],
351 def int_objc_loadWeak : Intrinsic<[llvm_ptr_ty],
353 def int_objc_loadWeakRetained : Intrinsic<[llvm_ptr_ty],
355 def int_objc_moveWeak : Intrinsic<[],
358 def int_objc_release : Intrinsic<[], [llvm_ptr_ty]>;
359 def int_objc_retain : Intrinsic<[llvm_ptr_ty],
361 def int_objc_retainAutorelease : Intrinsic<[llvm_ptr_ty],
363 def int_objc_retainAutoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
365 def int_objc_retainAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
367 def int_objc_retainBlock : Intrinsic<[llvm_ptr_ty],
369 def int_objc_storeStrong : Intrinsic<[],
372 def int_objc_storeWeak : Intrinsic<[llvm_ptr_ty],
375 def int_objc_clang_arc_use : Intrinsic<[],
377 def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
379 def int_objc_retainedObject : Intrinsic<[llvm_ptr_ty],
381 def int_objc_unretainedObject : Intrinsic<[llvm_ptr_ty],
383 def int_objc_unretainedPointer : Intrinsic<[llvm_ptr_ty],
385 def int_objc_retain_autorelease : Intrinsic<[llvm_ptr_ty],
387 def int_objc_sync_enter : Intrinsic<[llvm_i32_ty],
389 def int_objc_sync_exit : Intrinsic<[llvm_i32_ty],
391 def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
394 def int_objc_arc_annotation_topdown_bbend : Intrinsic<[],
397 def int_objc_arc_annotation_bottomup_bbstart : Intrinsic<[],
400 def int_objc_arc_annotation_bottomup_bbend : Intrinsic<[],
405 //===--------------------- Code Generator Intrinsics ----------------------===//
407 def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
408 def int_addressofreturnaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
409 def int_frameaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem, ImmArg<0>]>;
410 def int_sponentry : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
411 def int_read_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
412 [IntrReadMem], "llvm.read_register">;
413 def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
414 [], "llvm.write_register">;
416 // Gets the address of the local variable area. This is typically a copy of the
417 // stack, frame, or base pointer depending on the type of prologue.
418 def int_localaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
420 // Escapes local variables to allow access from other functions.
421 def int_localescape : Intrinsic<[], [llvm_vararg_ty]>;
423 // Given a function and the localaddress of a parent frame, returns a pointer
424 // to an escaped allocation indicated by the index.
425 def int_localrecover : Intrinsic<[llvm_ptr_ty],
426 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
427 [IntrNoMem, ImmArg<2>]>;
429 // Given the frame pointer passed into an SEH filter function, returns a
430 // pointer to the local variable area suitable for use with llvm.localrecover.
431 def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty],
432 [llvm_ptr_ty, llvm_ptr_ty],
435 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
436 // model their dependencies on allocas.
437 def int_stacksave : Intrinsic<[llvm_ptr_ty]>,
438 GCCBuiltin<"__builtin_stack_save">;
439 def int_stackrestore : Intrinsic<[], [llvm_ptr_ty]>,
440 GCCBuiltin<"__builtin_stack_restore">;
442 def int_get_dynamic_area_offset : Intrinsic<[llvm_anyint_ty]>;
444 def int_thread_pointer : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
445 GCCBuiltin<"__builtin_thread_pointer">;
447 // IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
448 // necessary for prefetch, however it does conveniently prevent the prefetch
449 // from being reordered overly much with respect to nearby access to the same
450 // memory while not impeding optimization.
452 : Intrinsic<[], [ llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
453 [ IntrInaccessibleMemOrArgMemOnly, ReadOnly<0>, NoCapture<0>,
454 ImmArg<1>, ImmArg<2>]>;
455 def int_pcmarker : Intrinsic<[], [llvm_i32_ty]>;
457 def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
459 // The assume intrinsic is marked as arbitrarily writing so that proper
460 // control dependencies will be maintained.
461 def int_assume : Intrinsic<[], [llvm_i1_ty], []>;
463 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
464 // guard to the correct place on the stack frame.
465 def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
466 def int_stackguard : Intrinsic<[llvm_ptr_ty], [], []>;
468 // A counter increment for instrumentation based profiling.
469 def int_instrprof_increment : Intrinsic<[],
470 [llvm_ptr_ty, llvm_i64_ty,
471 llvm_i32_ty, llvm_i32_ty],
474 // A counter increment with step for instrumentation based profiling.
475 def int_instrprof_increment_step : Intrinsic<[],
476 [llvm_ptr_ty, llvm_i64_ty,
477 llvm_i32_ty, llvm_i32_ty, llvm_i64_ty],
480 // A call to profile runtime for value profiling of target expressions
481 // through instrumentation based profiling.
482 def int_instrprof_value_profile : Intrinsic<[],
483 [llvm_ptr_ty, llvm_i64_ty,
484 llvm_i64_ty, llvm_i32_ty,
488 //===------------------- Standard C Library Intrinsics --------------------===//
491 def int_memcpy : Intrinsic<[],
492 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
494 [IntrArgMemOnly, NoCapture<0>, NoCapture<1>,
495 WriteOnly<0>, ReadOnly<1>, ImmArg<3>]>;
496 def int_memmove : Intrinsic<[],
497 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
499 [IntrArgMemOnly, NoCapture<0>, NoCapture<1>,
500 ReadOnly<1>, ImmArg<3>]>;
501 def int_memset : Intrinsic<[],
502 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
504 [IntrArgMemOnly, NoCapture<0>, WriteOnly<0>,
507 // FIXME: Add version of these floating point intrinsics which allow non-default
508 // rounding modes and FP exception handling.
510 let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
511 def int_fma : Intrinsic<[llvm_anyfloat_ty],
512 [LLVMMatchType<0>, LLVMMatchType<0>,
514 def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
515 [LLVMMatchType<0>, LLVMMatchType<0>,
518 // These functions do not read memory, but are sensitive to the
519 // rounding mode. LLVM purposely does not model changes to the FP
520 // environment so they can be treated as readnone.
521 def int_sqrt : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
522 def int_powi : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_i32_ty]>;
523 def int_sin : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
524 def int_cos : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
525 def int_pow : Intrinsic<[llvm_anyfloat_ty],
526 [LLVMMatchType<0>, LLVMMatchType<0>]>;
527 def int_log : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
528 def int_log10: Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
529 def int_log2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
530 def int_exp : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
531 def int_exp2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
532 def int_fabs : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
533 def int_copysign : Intrinsic<[llvm_anyfloat_ty],
534 [LLVMMatchType<0>, LLVMMatchType<0>]>;
535 def int_floor : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
536 def int_ceil : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
537 def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
538 def int_rint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
539 def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
540 def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
541 def int_canonicalize : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
544 def int_lround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
545 def int_llround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
546 def int_lrint : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
547 def int_llrint : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
550 def int_minnum : Intrinsic<[llvm_anyfloat_ty],
551 [LLVMMatchType<0>, LLVMMatchType<0>],
552 [IntrNoMem, IntrSpeculatable, Commutative]
554 def int_maxnum : Intrinsic<[llvm_anyfloat_ty],
555 [LLVMMatchType<0>, LLVMMatchType<0>],
556 [IntrNoMem, IntrSpeculatable, Commutative]
558 def int_minimum : Intrinsic<[llvm_anyfloat_ty],
559 [LLVMMatchType<0>, LLVMMatchType<0>],
560 [IntrNoMem, IntrSpeculatable, Commutative]
562 def int_maximum : Intrinsic<[llvm_anyfloat_ty],
563 [LLVMMatchType<0>, LLVMMatchType<0>],
564 [IntrNoMem, IntrSpeculatable, Commutative]
567 // NOTE: these are internal interfaces.
568 def int_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
569 def int_longjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
570 def int_sigsetjmp : Intrinsic<[llvm_i32_ty] , [llvm_ptr_ty, llvm_i32_ty]>;
571 def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
573 // Internal interface for object size checking
574 def int_objectsize : Intrinsic<[llvm_anyint_ty],
575 [llvm_anyptr_ty, llvm_i1_ty,
576 llvm_i1_ty, llvm_i1_ty],
577 [IntrNoMem, IntrSpeculatable, ImmArg<1>, ImmArg<2>, ImmArg<3>]>,
578 GCCBuiltin<"__builtin_object_size">;
580 //===--------------- Constrained Floating Point Intrinsics ----------------===//
583 let IntrProperties = [IntrInaccessibleMemOnly] in {
584 def int_experimental_constrained_fadd : Intrinsic<[ llvm_anyfloat_ty ],
589 def int_experimental_constrained_fsub : Intrinsic<[ llvm_anyfloat_ty ],
594 def int_experimental_constrained_fmul : Intrinsic<[ llvm_anyfloat_ty ],
599 def int_experimental_constrained_fdiv : Intrinsic<[ llvm_anyfloat_ty ],
604 def int_experimental_constrained_frem : Intrinsic<[ llvm_anyfloat_ty ],
610 def int_experimental_constrained_fma : Intrinsic<[ llvm_anyfloat_ty ],
617 def int_experimental_constrained_fptrunc : Intrinsic<[ llvm_anyfloat_ty ],
622 def int_experimental_constrained_fpext : Intrinsic<[ llvm_anyfloat_ty ],
626 // These intrinsics are sensitive to the rounding mode so we need constrained
627 // versions of each of them. When strict rounding and exception control are
628 // not required the non-constrained versions of these intrinsics should be
630 def int_experimental_constrained_sqrt : Intrinsic<[ llvm_anyfloat_ty ],
634 def int_experimental_constrained_powi : Intrinsic<[ llvm_anyfloat_ty ],
639 def int_experimental_constrained_sin : Intrinsic<[ llvm_anyfloat_ty ],
643 def int_experimental_constrained_cos : Intrinsic<[ llvm_anyfloat_ty ],
647 def int_experimental_constrained_pow : Intrinsic<[ llvm_anyfloat_ty ],
652 def int_experimental_constrained_log : Intrinsic<[ llvm_anyfloat_ty ],
656 def int_experimental_constrained_log10: Intrinsic<[ llvm_anyfloat_ty ],
660 def int_experimental_constrained_log2 : Intrinsic<[ llvm_anyfloat_ty ],
664 def int_experimental_constrained_exp : Intrinsic<[ llvm_anyfloat_ty ],
668 def int_experimental_constrained_exp2 : Intrinsic<[ llvm_anyfloat_ty ],
672 def int_experimental_constrained_rint : Intrinsic<[ llvm_anyfloat_ty ],
676 def int_experimental_constrained_nearbyint : Intrinsic<[ llvm_anyfloat_ty ],
680 def int_experimental_constrained_maxnum : Intrinsic<[ llvm_anyfloat_ty ],
685 def int_experimental_constrained_minnum : Intrinsic<[ llvm_anyfloat_ty ],
690 def int_experimental_constrained_ceil : Intrinsic<[ llvm_anyfloat_ty ],
694 def int_experimental_constrained_floor : Intrinsic<[ llvm_anyfloat_ty ],
698 def int_experimental_constrained_round : Intrinsic<[ llvm_anyfloat_ty ],
702 def int_experimental_constrained_trunc : Intrinsic<[ llvm_anyfloat_ty ],
707 // FIXME: Add intrinsics for fcmp, fptoui and fptosi.
709 //===------------------------- Expect Intrinsics --------------------------===//
711 def int_expect : Intrinsic<[llvm_anyint_ty],
712 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
714 //===-------------------- Bit Manipulation Intrinsics ---------------------===//
717 // None of these intrinsics accesses memory at all.
718 let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
719 def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
720 def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
721 def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
722 def int_fshl : Intrinsic<[llvm_anyint_ty],
723 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
724 def int_fshr : Intrinsic<[llvm_anyint_ty],
725 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
728 let IntrProperties = [IntrNoMem, IntrSpeculatable, ImmArg<1>] in {
729 def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
730 def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
733 //===------------------------ Debugger Intrinsics -------------------------===//
736 // None of these intrinsics accesses memory at all...but that doesn't
737 // mean the optimizers can change them aggressively. Special handling
738 // needed in a few places. These synthetic intrinsics have no
739 // side-effects and just mark information about their operands.
740 let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
741 def int_dbg_declare : Intrinsic<[],
745 def int_dbg_value : Intrinsic<[],
749 def int_dbg_addr : Intrinsic<[],
753 def int_dbg_label : Intrinsic<[],
757 //===------------------ Exception Handling Intrinsics----------------------===//
760 // The result of eh.typeid.for depends on the enclosing function, but inside a
761 // given function it is 'const' and may be CSE'd etc.
762 def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
764 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
765 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
767 // eh.exceptionpointer returns the pointer to the exception caught by
768 // the given `catchpad`.
769 def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
772 // Gets the exception code from a catchpad token. Only used on some platforms.
773 def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
775 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
776 // callee-saved registers to be saved and restored (regardless of whether they
777 // are used) in the calling function. It is used by libgcc_eh.
778 def int_eh_unwind_init: Intrinsic<[]>,
779 GCCBuiltin<"__builtin_unwind_init">;
781 def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
783 let IntrProperties = [IntrNoMem] in {
784 def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty]>;
785 def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty]>;
787 def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
788 def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
789 def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
790 def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>;
792 //===---------------- Generic Variable Attribute Intrinsics----------------===//
794 def int_var_annotation : Intrinsic<[],
795 [llvm_ptr_ty, llvm_ptr_ty,
796 llvm_ptr_ty, llvm_i32_ty],
797 [], "llvm.var.annotation">;
798 def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>],
799 [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty,
801 [], "llvm.ptr.annotation">;
802 def int_annotation : Intrinsic<[llvm_anyint_ty],
803 [LLVMMatchType<0>, llvm_ptr_ty,
804 llvm_ptr_ty, llvm_i32_ty],
805 [], "llvm.annotation">;
807 // Annotates the current program point with metadata strings which are emitted
808 // as CodeView debug info records. This is expensive, as it disables inlining
809 // and is modelled as having side effects.
810 def int_codeview_annotation : Intrinsic<[], [llvm_metadata_ty],
811 [IntrInaccessibleMemOnly, IntrNoDuplicate],
812 "llvm.codeview.annotation">;
814 //===------------------------ Trampoline Intrinsics -----------------------===//
816 def int_init_trampoline : Intrinsic<[],
817 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
818 [IntrArgMemOnly, NoCapture<0>]>,
819 GCCBuiltin<"__builtin_init_trampoline">;
821 def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
822 [IntrReadMem, IntrArgMemOnly]>,
823 GCCBuiltin<"__builtin_adjust_trampoline">;
825 //===------------------------ Overflow Intrinsics -------------------------===//
828 // Expose the carry flag from add operations on two integrals.
829 def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty,
830 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
831 [LLVMMatchType<0>, LLVMMatchType<0>],
832 [IntrNoMem, IntrSpeculatable]>;
833 def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty,
834 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
835 [LLVMMatchType<0>, LLVMMatchType<0>],
836 [IntrNoMem, IntrSpeculatable]>;
838 def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty,
839 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
840 [LLVMMatchType<0>, LLVMMatchType<0>],
841 [IntrNoMem, IntrSpeculatable]>;
842 def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty,
843 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
844 [LLVMMatchType<0>, LLVMMatchType<0>],
845 [IntrNoMem, IntrSpeculatable]>;
847 def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty,
848 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
849 [LLVMMatchType<0>, LLVMMatchType<0>],
850 [IntrNoMem, IntrSpeculatable]>;
851 def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty,
852 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
853 [LLVMMatchType<0>, LLVMMatchType<0>],
854 [IntrNoMem, IntrSpeculatable]>;
856 //===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
858 def int_sadd_sat : Intrinsic<[llvm_anyint_ty],
859 [LLVMMatchType<0>, LLVMMatchType<0>],
860 [IntrNoMem, IntrSpeculatable, Commutative]>;
861 def int_uadd_sat : Intrinsic<[llvm_anyint_ty],
862 [LLVMMatchType<0>, LLVMMatchType<0>],
863 [IntrNoMem, IntrSpeculatable, Commutative]>;
864 def int_ssub_sat : Intrinsic<[llvm_anyint_ty],
865 [LLVMMatchType<0>, LLVMMatchType<0>],
866 [IntrNoMem, IntrSpeculatable]>;
867 def int_usub_sat : Intrinsic<[llvm_anyint_ty],
868 [LLVMMatchType<0>, LLVMMatchType<0>],
869 [IntrNoMem, IntrSpeculatable]>;
871 //===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
873 def int_smul_fix : Intrinsic<[llvm_anyint_ty],
874 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
875 [IntrNoMem, IntrSpeculatable, Commutative, ImmArg<2>]>;
877 def int_umul_fix : Intrinsic<[llvm_anyint_ty],
878 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
879 [IntrNoMem, IntrSpeculatable, Commutative, ImmArg<2>]>;
881 //===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
883 def int_smul_fix_sat : Intrinsic<[llvm_anyint_ty],
884 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
885 [IntrNoMem, IntrSpeculatable, Commutative, ImmArg<2>]>;
887 //===------------------------- Memory Use Markers -------------------------===//
889 def int_lifetime_start : Intrinsic<[],
890 [llvm_i64_ty, llvm_anyptr_ty],
891 [IntrArgMemOnly, NoCapture<1>, ImmArg<0>]>;
892 def int_lifetime_end : Intrinsic<[],
893 [llvm_i64_ty, llvm_anyptr_ty],
894 [IntrArgMemOnly, NoCapture<1>, ImmArg<0>]>;
895 def int_invariant_start : Intrinsic<[llvm_descriptor_ty],
896 [llvm_i64_ty, llvm_anyptr_ty],
897 [IntrArgMemOnly, NoCapture<1>, ImmArg<0>]>;
898 def int_invariant_end : Intrinsic<[],
899 [llvm_descriptor_ty, llvm_i64_ty,
901 [IntrArgMemOnly, NoCapture<2>, ImmArg<1>]>;
903 // launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
904 // because it would cause CSE of two barriers with the same argument.
905 // Inaccessiblememonly says that the barrier doesn't read the argument,
906 // but it changes state not accessible to this module. This way
907 // we can DSE through the barrier because it doesn't read the value
908 // after store. Although the barrier doesn't modify any memory it
909 // can't be marked as readonly, because it would be possible to
910 // CSE 2 barriers with store in between.
911 // The argument also can't be marked with 'returned' attribute, because
912 // it would remove barrier.
913 // Note that it is still experimental, which means that its semantics
914 // might change in the future.
915 def int_launder_invariant_group : Intrinsic<[llvm_anyptr_ty],
917 [IntrInaccessibleMemOnly, IntrSpeculatable]>;
920 def int_strip_invariant_group : Intrinsic<[llvm_anyptr_ty],
922 [IntrSpeculatable, IntrNoMem]>;
924 //===------------------------ Stackmap Intrinsics -------------------------===//
926 def int_experimental_stackmap : Intrinsic<[],
927 [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
929 def int_experimental_patchpoint_void : Intrinsic<[],
930 [llvm_i64_ty, llvm_i32_ty,
931 llvm_ptr_ty, llvm_i32_ty,
934 def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
935 [llvm_i64_ty, llvm_i32_ty,
936 llvm_ptr_ty, llvm_i32_ty,
941 //===------------------------ Garbage Collection Intrinsics ---------------===//
942 // These are documented in docs/Statepoint.rst
944 def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
945 [llvm_i64_ty, llvm_i32_ty,
946 llvm_anyptr_ty, llvm_i32_ty,
947 llvm_i32_ty, llvm_vararg_ty],
948 [Throws, ImmArg<0>, ImmArg<1>, ImmArg<3>, ImmArg<4>]>;
950 def int_experimental_gc_result : Intrinsic<[llvm_any_ty], [llvm_token_ty],
952 def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
953 [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
954 [IntrReadMem, ImmArg<1>, ImmArg<2>]>;
956 //===------------------------ Coroutine Intrinsics ---------------===//
957 // These are documented in docs/Coroutines.rst
959 // Coroutine Structure Intrinsics.
961 def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty,
962 llvm_ptr_ty, llvm_ptr_ty],
963 [IntrArgMemOnly, IntrReadMem,
964 ReadNone<1>, ReadOnly<2>, NoCapture<2>]>;
965 def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
966 def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
969 def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
970 [IntrReadMem, IntrArgMemOnly, ReadOnly<1>,
972 def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
974 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
975 def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
976 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
978 def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
979 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
981 def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty],
982 [IntrNoMem, ReadNone<0>, ReadNone<1>]>;
984 // Coroutine Manipulation Intrinsics.
986 def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
987 def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
988 def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
989 [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>;
990 def int_coro_promise : Intrinsic<[llvm_ptr_ty],
991 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
992 [IntrNoMem, NoCapture<0>]>;
994 // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
996 def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
997 [IntrReadMem, IntrArgMemOnly, ReadOnly<0>,
1000 ///===-------------------------- Other Intrinsics --------------------------===//
1002 def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
1003 GCCBuiltin<"__builtin_flt_rounds">;
1004 def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
1005 GCCBuiltin<"__builtin_trap">;
1006 def int_debugtrap : Intrinsic<[]>,
1007 GCCBuiltin<"__builtin_debugtrap">;
1009 // Support for dynamic deoptimization (or de-specialization)
1010 def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1013 // Support for speculative runtime guards
1014 def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1017 // Supports widenable conditions for guards represented as explicit branches.
1018 def int_experimental_widenable_condition : Intrinsic<[llvm_i1_ty], [],
1019 [IntrInaccessibleMemOnly]>;
1021 // NOP: calls/invokes to this intrinsic are removed by codegen
1022 def int_donothing : Intrinsic<[], [], [IntrNoMem]>;
1024 // This instruction has no actual effect, though it is treated by the optimizer
1025 // has having opaque side effects. This may be inserted into loops to ensure
1026 // that they are not removed even if they turn out to be empty, for languages
1027 // which specify that infinite loops must be preserved.
1028 def int_sideeffect : Intrinsic<[], [], [IntrInaccessibleMemOnly]>;
1030 // Intrisics to support half precision floating point format
1031 let IntrProperties = [IntrNoMem] in {
1032 def int_convert_to_fp16 : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1033 def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1036 // Clear cache intrinsic, default to ignore (ie. emit nothing)
1037 // maps to void __clear_cache() on supporting platforms
1038 def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1039 [], "llvm.clear_cache">;
1041 // Intrinsic to detect whether its argument is a constant.
1042 def int_is_constant : Intrinsic<[llvm_i1_ty], [llvm_any_ty], [IntrNoMem], "llvm.is.constant">;
1044 //===-------------------------- Masked Intrinsics -------------------------===//
1046 def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
1047 LLVMAnyPointerType<LLVMMatchType<0>>,
1049 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1050 [IntrArgMemOnly, ImmArg<2>]>;
1052 def int_masked_load : Intrinsic<[llvm_anyvector_ty],
1053 [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
1054 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1055 [IntrReadMem, IntrArgMemOnly, ImmArg<1>]>;
1057 def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
1058 [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1059 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1061 [IntrReadMem, ImmArg<1>]>;
1063 def int_masked_scatter: Intrinsic<[],
1065 LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1066 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1069 def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
1070 [LLVMPointerToElt<0>,
1071 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1075 def int_masked_compressstore: Intrinsic<[],
1077 LLVMPointerToElt<0>,
1078 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1081 // Test whether a pointer is associated with a type metadata identifier.
1082 def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1085 // Safely loads a function pointer from a virtual table pointer using type metadata.
1086 def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty],
1087 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
1090 // Create a branch funnel that implements an indirect call to a limited set of
1091 // callees. This needs to be a musttail call.
1092 def int_icall_branch_funnel : Intrinsic<[], [llvm_vararg_ty], []>;
1094 def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
1095 [IntrReadMem, IntrArgMemOnly]>;
1097 def int_hwasan_check_memaccess :
1098 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrInaccessibleMemOnly, ImmArg<2>]>;
1101 //===----------------------------------------------------------------------===//
1102 // Custom event logging for x-ray.
1103 // Takes a pointer to a string and the length of the string.
1104 def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
1105 [NoCapture<0>, ReadOnly<0>, IntrWriteMem]>;
1106 // Typed event logging for x-ray.
1107 // Takes a numeric type tag, a pointer to a string and the length of the string.
1108 def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
1109 [NoCapture<1>, ReadOnly<1>, IntrWriteMem]>;
1110 //===----------------------------------------------------------------------===//
1112 //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
1115 // @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
1116 def int_memcpy_element_unordered_atomic
1119 llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1122 IntrArgMemOnly, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1123 ReadOnly<1>, ImmArg<3>
1126 // @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
1127 def int_memmove_element_unordered_atomic
1130 llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty
1133 IntrArgMemOnly, NoCapture<0>, NoCapture<1>, WriteOnly<0>,
1134 ReadOnly<1>, ImmArg<3>
1137 // @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
1138 def int_memset_element_unordered_atomic
1139 : Intrinsic<[], [ llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty ],
1140 [ IntrArgMemOnly, NoCapture<0>, WriteOnly<0>, ImmArg<3> ]>;
1142 //===------------------------ Reduction Intrinsics ------------------------===//
1144 def int_experimental_vector_reduce_v2_fadd : Intrinsic<[llvm_anyfloat_ty],
1148 def int_experimental_vector_reduce_v2_fmul : Intrinsic<[llvm_anyfloat_ty],
1152 def int_experimental_vector_reduce_add : Intrinsic<[LLVMVectorElementType<0>],
1153 [llvm_anyvector_ty],
1155 def int_experimental_vector_reduce_mul : Intrinsic<[LLVMVectorElementType<0>],
1156 [llvm_anyvector_ty],
1158 def int_experimental_vector_reduce_and : Intrinsic<[LLVMVectorElementType<0>],
1159 [llvm_anyvector_ty],
1161 def int_experimental_vector_reduce_or : Intrinsic<[LLVMVectorElementType<0>],
1162 [llvm_anyvector_ty],
1164 def int_experimental_vector_reduce_xor : Intrinsic<[LLVMVectorElementType<0>],
1165 [llvm_anyvector_ty],
1167 def int_experimental_vector_reduce_smax : Intrinsic<[LLVMVectorElementType<0>],
1168 [llvm_anyvector_ty],
1170 def int_experimental_vector_reduce_smin : Intrinsic<[LLVMVectorElementType<0>],
1171 [llvm_anyvector_ty],
1173 def int_experimental_vector_reduce_umax : Intrinsic<[LLVMVectorElementType<0>],
1174 [llvm_anyvector_ty],
1176 def int_experimental_vector_reduce_umin : Intrinsic<[LLVMVectorElementType<0>],
1177 [llvm_anyvector_ty],
1179 def int_experimental_vector_reduce_fmax : Intrinsic<[LLVMVectorElementType<0>],
1180 [llvm_anyvector_ty],
1182 def int_experimental_vector_reduce_fmin : Intrinsic<[LLVMVectorElementType<0>],
1183 [llvm_anyvector_ty],
1186 //===---------- Intrinsics to control hardware supported loops ----------===//
1188 // Specify that the value given is the number of iterations that the next loop
1190 def int_set_loop_iterations :
1191 Intrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
1193 // Specify that the value given is the number of iterations that the next loop
1194 // will execute. Also test that the given count is not zero, allowing it to
1195 // control entry to a 'while' loop.
1196 def int_test_set_loop_iterations :
1197 Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1199 // Decrement loop counter by the given argument. Return false if the loop
1201 def int_loop_decrement :
1202 Intrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
1204 // Decrement the first operand (the loop counter) by the second operand (the
1205 // maximum number of elements processed in an iteration). Return the remaining
1206 // number of iterations still to be executed. This is effectively a sub which
1207 // can be used with a phi, icmp and br to control the number of iterations
1208 // executed, as usual.
1209 def int_loop_decrement_reg :
1210 Intrinsic<[llvm_anyint_ty],
1211 [llvm_anyint_ty, llvm_anyint_ty], [IntrNoDuplicate]>;
1213 //===----- Intrinsics that are used to provide predicate information -----===//
1215 def int_ssa_copy : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
1216 [IntrNoMem, Returned<0>]>;
1218 //===------- Intrinsics that are used to preserve debug information -------===//
1220 def int_preserve_array_access_index : Intrinsic<[llvm_anyptr_ty],
1221 [llvm_anyptr_ty, llvm_i32_ty,
1223 [IntrNoMem, ImmArg<1>, ImmArg<2>]>;
1224 def int_preserve_union_access_index : Intrinsic<[llvm_anyptr_ty],
1225 [llvm_anyptr_ty, llvm_i32_ty],
1226 [IntrNoMem, ImmArg<1>]>;
1227 def int_preserve_struct_access_index : Intrinsic<[llvm_anyptr_ty],
1228 [llvm_anyptr_ty, llvm_i32_ty,
1230 [IntrNoMem, ImmArg<1>,
1233 //===----------------------------------------------------------------------===//
1234 // Target-specific intrinsics
1235 //===----------------------------------------------------------------------===//
1237 include "llvm/IR/IntrinsicsPowerPC.td"
1238 include "llvm/IR/IntrinsicsX86.td"
1239 include "llvm/IR/IntrinsicsARM.td"
1240 include "llvm/IR/IntrinsicsAArch64.td"
1241 include "llvm/IR/IntrinsicsXCore.td"
1242 include "llvm/IR/IntrinsicsHexagon.td"
1243 include "llvm/IR/IntrinsicsNVVM.td"
1244 include "llvm/IR/IntrinsicsMips.td"
1245 include "llvm/IR/IntrinsicsAMDGPU.td"
1246 include "llvm/IR/IntrinsicsBPF.td"
1247 include "llvm/IR/IntrinsicsSystemZ.td"
1248 include "llvm/IR/IntrinsicsWebAssembly.td"
1249 include "llvm/IR/IntrinsicsRISCV.td"