]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/IR/Intrinsics.td
Merge OpenSSL 1.0.2l.
[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
16 //===----------------------------------------------------------------------===//
17 //  Properties we keep track of for intrinsics.
18 //===----------------------------------------------------------------------===//
19
20 class IntrinsicProperty;
21
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).
25
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;
29
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;
35
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;
40
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;
45
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;
49
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;
54
55 // Commutative - This intrinsic is commutative: X op Y == Y op X.
56 def Commutative : IntrinsicProperty;
57
58 // Throws - This intrinsic can throw.
59 def Throws : IntrinsicProperty;
60
61 // NoCapture - The specified argument pointer is not captured by the intrinsic.
62 class NoCapture<int argNo> : IntrinsicProperty {
63   int ArgNo = argNo;
64 }
65
66 // Returned - The specified argument is always the return value of the
67 // intrinsic.
68 class Returned<int argNo> : IntrinsicProperty {
69   int ArgNo = argNo;
70 }
71
72 // ReadOnly - The specified argument pointer is not written to through the
73 // pointer by the intrinsic.
74 class ReadOnly<int argNo> : IntrinsicProperty {
75   int ArgNo = argNo;
76 }
77
78 // WriteOnly - The intrinsic does not read memory through the specified
79 // argument pointer.
80 class WriteOnly<int argNo> : IntrinsicProperty {
81   int ArgNo = argNo;
82 }
83
84 // ReadNone - The specified argument pointer is not dereferenced by the
85 // intrinsic.
86 class ReadNone<int argNo> : IntrinsicProperty {
87   int ArgNo = argNo;
88 }
89
90 def IntrNoReturn : IntrinsicProperty;
91
92 // IntrNoduplicate - Calls to this intrinsic cannot be duplicated.
93 // Parallels the noduplicate attribute on LLVM IR functions.
94 def IntrNoDuplicate : IntrinsicProperty;
95
96 // IntrConvergent - Calls to this intrinsic are convergent and may not be made
97 // control-dependent on any additional values.
98 // Parallels the convergent attribute on LLVM IR functions.
99 def IntrConvergent : IntrinsicProperty;
100
101 //===----------------------------------------------------------------------===//
102 // Types used by intrinsics.
103 //===----------------------------------------------------------------------===//
104
105 class LLVMType<ValueType vt> {
106   ValueType VT = vt;
107 }
108
109 class LLVMQualPointerType<LLVMType elty, int addrspace>
110   : LLVMType<iPTR>{
111   LLVMType ElTy = elty;
112   int AddrSpace = addrspace;
113 }
114
115 class LLVMPointerType<LLVMType elty>
116   : LLVMQualPointerType<elty, 0>;
117
118 class LLVMAnyPointerType<LLVMType elty>
119   : LLVMType<iPTRAny>{
120   LLVMType ElTy = elty;
121 }
122
123 // Match the type of another intrinsic parameter.  Number is an index into the
124 // list of overloaded types for the intrinsic, excluding all the fixed types.
125 // The Number value must refer to a previously listed type.  For example:
126 //   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
127 // has two overloaded types, the 2nd and 3rd arguments.  LLVMMatchType<0>
128 // refers to the first overloaded type, which is the 2nd argument.
129 class LLVMMatchType<int num>
130   : LLVMType<OtherVT>{
131   int Number = num;
132 }
133
134 // Match the type of another intrinsic parameter that is expected to be based on
135 // an integral type (i.e. either iN or <N x iM>), but change the scalar size to
136 // be twice as wide or half as wide as the other type.  This is only useful when
137 // the intrinsic is overloaded, so the matched type should be declared as iAny.
138 class LLVMExtendedType<int num> : LLVMMatchType<num>;
139 class LLVMTruncatedType<int num> : LLVMMatchType<num>;
140 class LLVMVectorSameWidth<int num, LLVMType elty>
141   : LLVMMatchType<num> {
142   ValueType ElTy = elty.VT;
143 }
144 class LLVMPointerTo<int num> : LLVMMatchType<num>;
145 class LLVMPointerToElt<int num> : LLVMMatchType<num>;
146 class LLVMVectorOfPointersToElt<int num> : LLVMMatchType<num>;
147
148 // Match the type of another intrinsic parameter that is expected to be a
149 // vector type, but change the element count to be half as many
150 class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
151
152 def llvm_void_ty       : LLVMType<isVoid>;
153 def llvm_any_ty        : LLVMType<Any>;
154 def llvm_anyint_ty     : LLVMType<iAny>;
155 def llvm_anyfloat_ty   : LLVMType<fAny>;
156 def llvm_anyvector_ty  : LLVMType<vAny>;
157 def llvm_i1_ty         : LLVMType<i1>;
158 def llvm_i8_ty         : LLVMType<i8>;
159 def llvm_i16_ty        : LLVMType<i16>;
160 def llvm_i32_ty        : LLVMType<i32>;
161 def llvm_i64_ty        : LLVMType<i64>;
162 def llvm_half_ty       : LLVMType<f16>;
163 def llvm_float_ty      : LLVMType<f32>;
164 def llvm_double_ty     : LLVMType<f64>;
165 def llvm_f80_ty        : LLVMType<f80>;
166 def llvm_f128_ty       : LLVMType<f128>;
167 def llvm_ppcf128_ty    : LLVMType<ppcf128>;
168 def llvm_ptr_ty        : LLVMPointerType<llvm_i8_ty>;             // i8*
169 def llvm_ptrptr_ty     : LLVMPointerType<llvm_ptr_ty>;            // i8**
170 def llvm_anyptr_ty     : LLVMAnyPointerType<llvm_i8_ty>;          // (space)i8*
171 def llvm_empty_ty      : LLVMType<OtherVT>;                       // { }
172 def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>;          // { }*
173 def llvm_metadata_ty   : LLVMType<MetadataVT>;                    // !{...}
174 def llvm_token_ty      : LLVMType<token>;                         // token
175
176 def llvm_x86mmx_ty     : LLVMType<x86mmx>;
177 def llvm_ptrx86mmx_ty  : LLVMPointerType<llvm_x86mmx_ty>;         // <1 x i64>*
178
179 def llvm_v2i1_ty       : LLVMType<v2i1>;     //   2 x i1
180 def llvm_v4i1_ty       : LLVMType<v4i1>;     //   4 x i1
181 def llvm_v8i1_ty       : LLVMType<v8i1>;     //   8 x i1
182 def llvm_v16i1_ty      : LLVMType<v16i1>;    //  16 x i1
183 def llvm_v32i1_ty      : LLVMType<v32i1>;    //  32 x i1
184 def llvm_v64i1_ty      : LLVMType<v64i1>;    //  64 x i1
185 def llvm_v512i1_ty     : LLVMType<v512i1>;   // 512 x i1
186 def llvm_v1024i1_ty    : LLVMType<v1024i1>;  //1024 x i1
187
188 def llvm_v1i8_ty       : LLVMType<v1i8>;     //  1 x i8
189 def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8
190 def llvm_v4i8_ty       : LLVMType<v4i8>;     //  4 x i8
191 def llvm_v8i8_ty       : LLVMType<v8i8>;     //  8 x i8
192 def llvm_v16i8_ty      : LLVMType<v16i8>;    // 16 x i8
193 def llvm_v32i8_ty      : LLVMType<v32i8>;    // 32 x i8
194 def llvm_v64i8_ty      : LLVMType<v64i8>;    // 64 x i8
195 def llvm_v128i8_ty     : LLVMType<v128i8>;   //128 x i8
196 def llvm_v256i8_ty     : LLVMType<v256i8>;   //256 x i8
197
198 def llvm_v1i16_ty      : LLVMType<v1i16>;    //  1 x i16
199 def llvm_v2i16_ty      : LLVMType<v2i16>;    //  2 x i16
200 def llvm_v4i16_ty      : LLVMType<v4i16>;    //  4 x i16
201 def llvm_v8i16_ty      : LLVMType<v8i16>;    //  8 x i16
202 def llvm_v16i16_ty     : LLVMType<v16i16>;   // 16 x i16
203 def llvm_v32i16_ty     : LLVMType<v32i16>;   // 32 x i16
204 def llvm_v64i16_ty     : LLVMType<v64i16>;   // 64 x i16
205 def llvm_v128i16_ty    : LLVMType<v128i16>;  //128 x i16
206
207 def llvm_v1i32_ty      : LLVMType<v1i32>;    //  1 x i32
208 def llvm_v2i32_ty      : LLVMType<v2i32>;    //  2 x i32
209 def llvm_v4i32_ty      : LLVMType<v4i32>;    //  4 x i32
210 def llvm_v8i32_ty      : LLVMType<v8i32>;    //  8 x i32
211 def llvm_v16i32_ty     : LLVMType<v16i32>;   // 16 x i32
212 def llvm_v32i32_ty     : LLVMType<v32i32>;   // 32 x i32
213 def llvm_v64i32_ty     : LLVMType<v64i32>;   // 64 x i32
214
215 def llvm_v1i64_ty      : LLVMType<v1i64>;    //  1 x i64
216 def llvm_v2i64_ty      : LLVMType<v2i64>;    //  2 x i64
217 def llvm_v4i64_ty      : LLVMType<v4i64>;    //  4 x i64
218 def llvm_v8i64_ty      : LLVMType<v8i64>;    //  8 x i64
219 def llvm_v16i64_ty     : LLVMType<v16i64>;   // 16 x i64
220 def llvm_v32i64_ty     : LLVMType<v32i64>;   // 32 x i64
221
222 def llvm_v1i128_ty     : LLVMType<v1i128>;   //  1 x i128
223
224 def llvm_v2f16_ty      : LLVMType<v2f16>;    //  2 x half (__fp16)
225 def llvm_v4f16_ty      : LLVMType<v4f16>;    //  4 x half (__fp16)
226 def llvm_v8f16_ty      : LLVMType<v8f16>;    //  8 x half (__fp16)
227 def llvm_v1f32_ty      : LLVMType<v1f32>;    //  1 x float
228 def llvm_v2f32_ty      : LLVMType<v2f32>;    //  2 x float
229 def llvm_v4f32_ty      : LLVMType<v4f32>;    //  4 x float
230 def llvm_v8f32_ty      : LLVMType<v8f32>;    //  8 x float
231 def llvm_v16f32_ty     : LLVMType<v16f32>;   // 16 x float
232 def llvm_v1f64_ty      : LLVMType<v1f64>;    //  1 x double
233 def llvm_v2f64_ty      : LLVMType<v2f64>;    //  2 x double
234 def llvm_v4f64_ty      : LLVMType<v4f64>;    //  4 x double
235 def llvm_v8f64_ty      : LLVMType<v8f64>;    //  8 x double
236
237 def llvm_vararg_ty     : LLVMType<isVoid>;   // this means vararg here
238
239
240 //===----------------------------------------------------------------------===//
241 // Intrinsic Definitions.
242 //===----------------------------------------------------------------------===//
243
244 // Intrinsic class - This is used to define one LLVM intrinsic.  The name of the
245 // intrinsic definition should start with "int_", then match the LLVM intrinsic
246 // name with the "llvm." prefix removed, and all "."s turned into "_"s.  For
247 // example, llvm.bswap.i16 -> int_bswap_i16.
248 //
249 //  * RetTypes is a list containing the return types expected for the
250 //    intrinsic.
251 //  * ParamTypes is a list containing the parameter types expected for the
252 //    intrinsic.
253 //  * Properties can be set to describe the behavior of the intrinsic.
254 //
255 class SDPatternOperator;
256 class Intrinsic<list<LLVMType> ret_types,
257                 list<LLVMType> param_types = [],
258                 list<IntrinsicProperty> properties = [],
259                 string name = ""> : SDPatternOperator {
260   string LLVMName = name;
261   string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
262   list<LLVMType> RetTypes = ret_types;
263   list<LLVMType> ParamTypes = param_types;
264   list<IntrinsicProperty> IntrProperties = properties;
265
266   bit isTarget = 0;
267 }
268
269 /// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this
270 /// specifies the name of the builtin.  This provides automatic CBE and CFE
271 /// support.
272 class GCCBuiltin<string name> {
273   string GCCBuiltinName = name;
274 }
275
276 class MSBuiltin<string name> {
277   string MSBuiltinName = name;
278 }
279
280
281 //===--------------- Variable Argument Handling Intrinsics ----------------===//
282 //
283
284 def int_vastart : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
285 def int_vacopy  : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
286                             "llvm.va_copy">;
287 def int_vaend   : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
288
289 //===------------------- Garbage Collection Intrinsics --------------------===//
290 //
291 def int_gcroot  : Intrinsic<[],
292                             [llvm_ptrptr_ty, llvm_ptr_ty]>;
293 def int_gcread  : Intrinsic<[llvm_ptr_ty],
294                             [llvm_ptr_ty, llvm_ptrptr_ty],
295                             [IntrReadMem, IntrArgMemOnly]>;
296 def int_gcwrite : Intrinsic<[],
297                             [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
298                             [IntrArgMemOnly, NoCapture<1>, NoCapture<2>]>;
299
300 //===--------------------- Code Generator Intrinsics ----------------------===//
301 //
302 def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem]>;
303 def int_addressofreturnaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
304 def int_frameaddress  : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem]>;
305 def int_read_register  : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
306                                    [IntrReadMem], "llvm.read_register">;
307 def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
308                                    [], "llvm.write_register">;
309
310 // Gets the address of the local variable area. This is typically a copy of the
311 // stack, frame, or base pointer depending on the type of prologue.
312 def int_localaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
313
314 // Escapes local variables to allow access from other functions.
315 def int_localescape : Intrinsic<[], [llvm_vararg_ty]>;
316
317 // Given a function and the localaddress of a parent frame, returns a pointer
318 // to an escaped allocation indicated by the index.
319 def int_localrecover : Intrinsic<[llvm_ptr_ty],
320                                  [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
321                                  [IntrNoMem]>;
322 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
323 // model their dependencies on allocas.
324 def int_stacksave     : Intrinsic<[llvm_ptr_ty]>,
325                         GCCBuiltin<"__builtin_stack_save">;
326 def int_stackrestore  : Intrinsic<[], [llvm_ptr_ty]>,
327                         GCCBuiltin<"__builtin_stack_restore">;
328
329 def int_get_dynamic_area_offset : Intrinsic<[llvm_anyint_ty]>;
330
331 def int_thread_pointer : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
332                          GCCBuiltin<"__builtin_thread_pointer">;
333
334 // IntrArgMemOnly is more pessimistic than strictly necessary for prefetch,
335 // however it does conveniently prevent the prefetch from being reordered
336 // with respect to nearby accesses to the same memory.
337 def int_prefetch      : Intrinsic<[],
338                                   [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty,
339                                    llvm_i32_ty],
340                                   [IntrArgMemOnly, NoCapture<0>]>;
341 def int_pcmarker      : Intrinsic<[], [llvm_i32_ty]>;
342
343 def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
344
345 // The assume intrinsic is marked as arbitrarily writing so that proper
346 // control dependencies will be maintained.
347 def int_assume        : Intrinsic<[], [llvm_i1_ty], []>;
348
349 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
350 // guard to the correct place on the stack frame.
351 def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
352 def int_stackguard : Intrinsic<[llvm_ptr_ty], [], []>;
353
354 // A counter increment for instrumentation based profiling.
355 def int_instrprof_increment : Intrinsic<[],
356                                         [llvm_ptr_ty, llvm_i64_ty,
357                                          llvm_i32_ty, llvm_i32_ty],
358                                         []>;
359
360 // A counter increment with step for instrumentation based profiling.
361 def int_instrprof_increment_step : Intrinsic<[],
362                                         [llvm_ptr_ty, llvm_i64_ty,
363                                          llvm_i32_ty, llvm_i32_ty, llvm_i64_ty],
364                                         []>;
365
366 // A call to profile runtime for value profiling of target expressions
367 // through instrumentation based profiling.
368 def int_instrprof_value_profile : Intrinsic<[],
369                                             [llvm_ptr_ty, llvm_i64_ty,
370                                              llvm_i64_ty, llvm_i32_ty,
371                                              llvm_i32_ty],
372                                             []>;
373
374 //===------------------- Standard C Library Intrinsics --------------------===//
375 //
376
377 def int_memcpy  : Intrinsic<[],
378                              [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
379                               llvm_i32_ty, llvm_i1_ty],
380                             [IntrArgMemOnly, NoCapture<0>, NoCapture<1>,
381                              WriteOnly<0>, ReadOnly<1>]>;
382 def int_memmove : Intrinsic<[],
383                             [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
384                              llvm_i32_ty, llvm_i1_ty],
385                             [IntrArgMemOnly, NoCapture<0>, NoCapture<1>,
386                              ReadOnly<1>]>;
387 def int_memset  : Intrinsic<[],
388                             [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
389                              llvm_i32_ty, llvm_i1_ty],
390                             [IntrArgMemOnly, NoCapture<0>, WriteOnly<0>]>;
391
392 let IntrProperties = [IntrNoMem] in {
393   def int_fma  : Intrinsic<[llvm_anyfloat_ty],
394                            [LLVMMatchType<0>, LLVMMatchType<0>,
395                             LLVMMatchType<0>]>;
396   def int_fmuladd : Intrinsic<[llvm_anyfloat_ty],
397                               [LLVMMatchType<0>, LLVMMatchType<0>,
398                                LLVMMatchType<0>]>;
399
400   // These functions do not read memory, but are sensitive to the
401   // rounding mode. LLVM purposely does not model changes to the FP
402   // environment so they can be treated as readnone.
403   def int_sqrt : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
404   def int_powi : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_i32_ty]>;
405   def int_sin  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
406   def int_cos  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
407   def int_pow  : Intrinsic<[llvm_anyfloat_ty],
408                            [LLVMMatchType<0>, LLVMMatchType<0>]>;
409   def int_log  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
410   def int_log10: Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
411   def int_log2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
412   def int_exp  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
413   def int_exp2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
414   def int_fabs : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
415   def int_copysign : Intrinsic<[llvm_anyfloat_ty],
416                                [LLVMMatchType<0>, LLVMMatchType<0>]>;
417   def int_floor : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
418   def int_ceil  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
419   def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
420   def int_rint  : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
421   def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
422   def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
423   def int_canonicalize : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
424                                    [IntrNoMem]>;
425 }
426
427 def int_minnum : Intrinsic<[llvm_anyfloat_ty],
428   [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, Commutative]
429 >;
430 def int_maxnum : Intrinsic<[llvm_anyfloat_ty],
431   [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, Commutative]
432 >;
433
434 // NOTE: these are internal interfaces.
435 def int_setjmp     : Intrinsic<[llvm_i32_ty],  [llvm_ptr_ty]>;
436 def int_longjmp    : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
437 def int_sigsetjmp  : Intrinsic<[llvm_i32_ty] , [llvm_ptr_ty, llvm_i32_ty]>;
438 def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>;
439
440 // Internal interface for object size checking
441 def int_objectsize : Intrinsic<[llvm_anyint_ty], [llvm_anyptr_ty, llvm_i1_ty],
442                                [IntrNoMem]>,
443                                GCCBuiltin<"__builtin_object_size">;
444
445 //===------------------------- Expect Intrinsics --------------------------===//
446 //
447 def int_expect : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>,
448                                               LLVMMatchType<0>], [IntrNoMem]>;
449
450 //===-------------------- Bit Manipulation Intrinsics ---------------------===//
451 //
452
453 // None of these intrinsics accesses memory at all.
454 let IntrProperties = [IntrNoMem] in {
455   def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
456   def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
457   def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
458   def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
459   def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
460 }
461
462 //===------------------------ Debugger Intrinsics -------------------------===//
463 //
464
465 // None of these intrinsics accesses memory at all...but that doesn't mean the
466 // optimizers can change them aggressively.  Special handling needed in a few
467 // places.
468 let IntrProperties = [IntrNoMem] in {
469   def int_dbg_declare      : Intrinsic<[],
470                                        [llvm_metadata_ty,
471                                        llvm_metadata_ty,
472                                        llvm_metadata_ty]>;
473   def int_dbg_value        : Intrinsic<[],
474                                        [llvm_metadata_ty, llvm_i64_ty,
475                                         llvm_metadata_ty,
476                                         llvm_metadata_ty]>;
477 }
478
479 //===------------------ Exception Handling Intrinsics----------------------===//
480 //
481
482 // The result of eh.typeid.for depends on the enclosing function, but inside a
483 // given function it is 'const' and may be CSE'd etc.
484 def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
485
486 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
487 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
488
489 // eh.exceptionpointer returns the pointer to the exception caught by
490 // the given `catchpad`.
491 def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
492                                         [IntrNoMem]>;
493
494 // Gets the exception code from a catchpad token. Only used on some platforms.
495 def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
496
497 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
498 // callee-saved registers to be saved and restored (regardless of whether they
499 // are used) in the calling function. It is used by libgcc_eh.
500 def int_eh_unwind_init: Intrinsic<[]>,
501                         GCCBuiltin<"__builtin_unwind_init">;
502
503 def int_eh_dwarf_cfa  : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
504
505 let IntrProperties = [IntrNoMem] in {
506   def int_eh_sjlj_lsda             : Intrinsic<[llvm_ptr_ty]>;
507   def int_eh_sjlj_callsite         : Intrinsic<[], [llvm_i32_ty]>;
508 }
509 def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
510 def int_eh_sjlj_setjmp          : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
511 def int_eh_sjlj_longjmp         : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
512 def int_eh_sjlj_setup_dispatch  : Intrinsic<[], []>;
513
514 //===---------------- Generic Variable Attribute Intrinsics----------------===//
515 //
516 def int_var_annotation : Intrinsic<[],
517                                    [llvm_ptr_ty, llvm_ptr_ty,
518                                     llvm_ptr_ty, llvm_i32_ty],
519                                    [], "llvm.var.annotation">;
520 def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>],
521                                    [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty,
522                                     llvm_i32_ty],
523                                    [], "llvm.ptr.annotation">;
524 def int_annotation : Intrinsic<[llvm_anyint_ty],
525                                [LLVMMatchType<0>, llvm_ptr_ty,
526                                 llvm_ptr_ty, llvm_i32_ty],
527                                [], "llvm.annotation">;
528
529 //===------------------------ Trampoline Intrinsics -----------------------===//
530 //
531 def int_init_trampoline : Intrinsic<[],
532                                     [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
533                                     [IntrArgMemOnly, NoCapture<0>]>,
534                                    GCCBuiltin<"__builtin_init_trampoline">;
535
536 def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
537                                       [IntrReadMem, IntrArgMemOnly]>,
538                                      GCCBuiltin<"__builtin_adjust_trampoline">;
539
540 //===------------------------ Overflow Intrinsics -------------------------===//
541 //
542
543 // Expose the carry flag from add operations on two integrals.
544 def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty],
545                                        [LLVMMatchType<0>, LLVMMatchType<0>],
546                                        [IntrNoMem]>;
547 def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty],
548                                        [LLVMMatchType<0>, LLVMMatchType<0>],
549                                        [IntrNoMem]>;
550
551 def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty],
552                                        [LLVMMatchType<0>, LLVMMatchType<0>],
553                                        [IntrNoMem]>;
554 def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty],
555                                        [LLVMMatchType<0>, LLVMMatchType<0>],
556                                        [IntrNoMem]>;
557
558 def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty],
559                                        [LLVMMatchType<0>, LLVMMatchType<0>],
560                                        [IntrNoMem]>;
561 def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty],
562                                        [LLVMMatchType<0>, LLVMMatchType<0>],
563                                        [IntrNoMem]>;
564
565 //===------------------------- Memory Use Markers -------------------------===//
566 //
567 def int_lifetime_start  : Intrinsic<[],
568                                     [llvm_i64_ty, llvm_ptr_ty],
569                                     [IntrArgMemOnly, NoCapture<1>]>;
570 def int_lifetime_end    : Intrinsic<[],
571                                     [llvm_i64_ty, llvm_ptr_ty],
572                                     [IntrArgMemOnly, NoCapture<1>]>;
573 def int_invariant_start : Intrinsic<[llvm_descriptor_ty],
574                                     [llvm_i64_ty, llvm_anyptr_ty],
575                                     [IntrArgMemOnly, NoCapture<1>]>;
576 def int_invariant_end   : Intrinsic<[],
577                                     [llvm_descriptor_ty, llvm_i64_ty,
578                                      llvm_anyptr_ty],
579                                     [IntrArgMemOnly, NoCapture<2>]>;
580
581 def int_invariant_group_barrier : Intrinsic<[llvm_ptr_ty],
582                                             [llvm_ptr_ty],
583                                             [IntrNoMem]>;
584
585 //===------------------------ Stackmap Intrinsics -------------------------===//
586 //
587 def int_experimental_stackmap : Intrinsic<[],
588                                   [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
589                                   [Throws]>;
590 def int_experimental_patchpoint_void : Intrinsic<[],
591                                                  [llvm_i64_ty, llvm_i32_ty,
592                                                   llvm_ptr_ty, llvm_i32_ty,
593                                                   llvm_vararg_ty],
594                                                   [Throws]>;
595 def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
596                                                 [llvm_i64_ty, llvm_i32_ty,
597                                                  llvm_ptr_ty, llvm_i32_ty,
598                                                  llvm_vararg_ty],
599                                                  [Throws]>;
600
601
602 //===------------------------ Garbage Collection Intrinsics ---------------===//
603 // These are documented in docs/Statepoint.rst
604
605 def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
606                                [llvm_i64_ty, llvm_i32_ty,
607                                 llvm_anyptr_ty, llvm_i32_ty,
608                                 llvm_i32_ty, llvm_vararg_ty],
609                                 [Throws]>;
610
611 def int_experimental_gc_result   : Intrinsic<[llvm_any_ty], [llvm_token_ty],
612                                              [IntrReadMem]>;
613 def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
614                                 [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
615                                 [IntrReadMem]>;
616
617 //===------------------------ Coroutine Intrinsics ---------------===//
618 // These are documented in docs/Coroutines.rst
619
620 // Coroutine Structure Intrinsics.
621
622 def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty, 
623                              llvm_ptr_ty, llvm_ptr_ty], 
624                             [IntrArgMemOnly, IntrReadMem, 
625                              ReadNone<1>, ReadOnly<2>, NoCapture<2>]>;
626 def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
627 def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
628                                [WriteOnly<1>]>;
629
630 def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty], 
631                               [IntrReadMem, IntrArgMemOnly, ReadOnly<1>, 
632                                NoCapture<1>]>;
633 def int_coro_end : Intrinsic<[], [llvm_ptr_ty, llvm_i1_ty], []>;
634
635 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
636 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
637
638 def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>;
639 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
640
641 def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty],
642                                [IntrNoMem, ReadNone<0>, ReadNone<1>]>;
643
644 // Coroutine Manipulation Intrinsics.
645
646 def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
647 def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
648 def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
649                               [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>;
650 def int_coro_promise : Intrinsic<[llvm_ptr_ty],
651                                  [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
652                                  [IntrNoMem, NoCapture<0>]>;
653
654 // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
655
656 def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
657                                     [IntrReadMem, IntrArgMemOnly, ReadOnly<0>,
658                                      NoCapture<0>]>;
659
660 ///===-------------------------- Other Intrinsics --------------------------===//
661 //
662 def int_flt_rounds : Intrinsic<[llvm_i32_ty]>,
663                      GCCBuiltin<"__builtin_flt_rounds">;
664 def int_trap : Intrinsic<[], [], [IntrNoReturn]>,
665                GCCBuiltin<"__builtin_trap">;
666 def int_debugtrap : Intrinsic<[]>,
667                     GCCBuiltin<"__builtin_debugtrap">;
668
669 // Support for dynamic deoptimization (or de-specialization)
670 def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
671                                             [Throws]>;
672
673 // Support for speculative runtime guards
674 def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
675                                        [Throws]>;
676
677 // NOP: calls/invokes to this intrinsic are removed by codegen
678 def int_donothing : Intrinsic<[], [], [IntrNoMem]>;
679
680 // Intrisics to support half precision floating point format
681 let IntrProperties = [IntrNoMem] in {
682 def int_convert_to_fp16   : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
683 def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
684 }
685
686 // Clear cache intrinsic, default to ignore (ie. emit nothing)
687 // maps to void __clear_cache() on supporting platforms
688 def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
689                                 [], "llvm.clear_cache">;
690
691 //===-------------------------- Masked Intrinsics -------------------------===//
692 //
693 def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
694                                       LLVMAnyPointerType<LLVMMatchType<0>>,
695                                       llvm_i32_ty,
696                                       LLVMVectorSameWidth<0, llvm_i1_ty>],
697                                  [IntrArgMemOnly]>;
698
699 def int_masked_load  : Intrinsic<[llvm_anyvector_ty],
700                                  [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
701                                   LLVMVectorSameWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
702                                  [IntrReadMem, IntrArgMemOnly]>;
703
704 def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
705                                  [LLVMVectorOfPointersToElt<0>, llvm_i32_ty,
706                                   LLVMVectorSameWidth<0, llvm_i1_ty>,
707                                   LLVMMatchType<0>],
708                                  [IntrReadMem]>;
709
710 def int_masked_scatter: Intrinsic<[],
711                                   [llvm_anyvector_ty,
712                                    LLVMVectorOfPointersToElt<0>, llvm_i32_ty,
713                                    LLVMVectorSameWidth<0, llvm_i1_ty>]>;
714
715 def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
716                                      [LLVMPointerToElt<0>,
717                                       LLVMVectorSameWidth<0, llvm_i1_ty>,
718                                       LLVMMatchType<0>],
719                                      [IntrReadMem]>;
720
721 def int_masked_compressstore: Intrinsic<[],
722                                      [llvm_anyvector_ty,
723                                       LLVMPointerToElt<0>,
724                                       LLVMVectorSameWidth<0, llvm_i1_ty>],
725                                      [IntrArgMemOnly]>;
726
727 // Test whether a pointer is associated with a type metadata identifier.
728 def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
729                               [IntrNoMem]>;
730
731 // Safely loads a function pointer from a virtual table pointer using type metadata.
732 def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty],
733                                       [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
734                                       [IntrNoMem]>;
735
736 def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
737                                  [IntrReadMem, IntrArgMemOnly]>;
738
739 //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
740 //
741
742 def int_memcpy_element_atomic  : Intrinsic<[],
743                                            [llvm_anyptr_ty, llvm_anyptr_ty,
744                                             llvm_i64_ty, llvm_i32_ty],
745                                  [IntrArgMemOnly, NoCapture<0>, NoCapture<1>,
746                                   WriteOnly<0>, ReadOnly<1>]>;
747
748 //===----------------------------------------------------------------------===//
749 // Target-specific intrinsics
750 //===----------------------------------------------------------------------===//
751
752 include "llvm/IR/IntrinsicsPowerPC.td"
753 include "llvm/IR/IntrinsicsX86.td"
754 include "llvm/IR/IntrinsicsARM.td"
755 include "llvm/IR/IntrinsicsAArch64.td"
756 include "llvm/IR/IntrinsicsXCore.td"
757 include "llvm/IR/IntrinsicsHexagon.td"
758 include "llvm/IR/IntrinsicsNVVM.td"
759 include "llvm/IR/IntrinsicsMips.td"
760 include "llvm/IR/IntrinsicsAMDGPU.td"
761 include "llvm/IR/IntrinsicsBPF.td"
762 include "llvm/IR/IntrinsicsSystemZ.td"
763 include "llvm/IR/IntrinsicsWebAssembly.td"