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