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