Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===- Intrinsics.td - Defines all LLVM intrinsics ---------*- tablegen -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines properties of all LLVM intrinsics.
10
//
11
//===----------------------------------------------------------------------===//
12
 
13
include "llvm/CodeGen/ValueTypes.td"
14
include "llvm/CodeGen/SDNodeProperties.td"
15
 
16
//===----------------------------------------------------------------------===//
17
//  Properties we keep track of for intrinsics.
18
//===----------------------------------------------------------------------===//
19
 
20
class IntrinsicProperty<bit is_default = false> {
21
  bit IsDefault = is_default;
22
}
23
 
24
// Intr*Mem - Memory properties.  If no property is set, the worst case
25
// is assumed (it may read and write any memory it can get access to and it may
26
// have other side effects).
27
 
28
// IntrNoMem - The intrinsic does not access memory or have any other side
29
// effects.  It may be CSE'd deleted if dead, etc.
30
def IntrNoMem : IntrinsicProperty;
31
 
32
// IntrReadMem - This intrinsic only reads from memory. It does not write to
33
// memory and has no other side effects. Therefore, it cannot be moved across
34
// potentially aliasing stores. However, it can be reordered otherwise and can
35
// be deleted if dead.
36
def IntrReadMem : IntrinsicProperty;
37
 
38
// IntrWriteMem - This intrinsic only writes to memory, but does not read from
39
// memory, and has no other side effects. This means dead stores before calls
40
// to this intrinsics may be removed.
41
def IntrWriteMem : IntrinsicProperty;
42
 
43
// IntrArgMemOnly - This intrinsic only accesses memory that its pointer-typed
44
// argument(s) points to, but may access an unspecified amount. Other than
45
// reads from and (possibly volatile) writes to memory, it has no side effects.
46
def IntrArgMemOnly : IntrinsicProperty;
47
 
48
// IntrInaccessibleMemOnly -- This intrinsic only accesses memory that is not
49
// accessible by the module being compiled. This is a weaker form of IntrNoMem.
50
def IntrInaccessibleMemOnly : IntrinsicProperty;
51
 
52
// IntrInaccessibleMemOrArgMemOnly -- This intrinsic only accesses memory that
53
// its pointer-typed arguments point to or memory that is not accessible
54
// by the module being compiled. This is a weaker form of IntrArgMemOnly.
55
def IntrInaccessibleMemOrArgMemOnly : IntrinsicProperty;
56
 
57
// Commutative - This intrinsic is commutative: X op Y == Y op X.
58
def Commutative : IntrinsicProperty;
59
 
60
// Throws - This intrinsic can throw.
61
def Throws : IntrinsicProperty;
62
 
63
// Attribute index needs to match `AttrIndex` defined `Attributes.h`.
64
class AttrIndex<int idx> {
65
  int Value = idx;
66
}
67
def FuncIndex : AttrIndex<-1>;
68
def RetIndex : AttrIndex<0>;
69
class ArgIndex<int argNo> : AttrIndex<!add(argNo, 1)>;
70
 
71
// NoCapture - The specified argument pointer is not captured by the intrinsic.
72
class NoCapture<AttrIndex idx> : IntrinsicProperty {
73
  int ArgNo = idx.Value;
74
}
75
 
76
// NoAlias - The specified argument pointer is not aliasing other "noalias" pointer
77
// arguments of the intrinsic wrt. the intrinsic scope.
78
class NoAlias<AttrIndex idx> : IntrinsicProperty {
79
  int ArgNo = idx.Value;
80
}
81
 
82
// NoUndef - The specified argument is neither undef nor poison.
83
class NoUndef<AttrIndex idx> : IntrinsicProperty {
84
  int ArgNo = idx.Value;
85
}
86
 
87
// NonNull - The specified argument is not null.
88
class NonNull<AttrIndex idx> : IntrinsicProperty {
89
  int ArgNo = idx.Value;
90
}
91
 
92
class Align<AttrIndex idx, int align> : IntrinsicProperty {
93
  int ArgNo = idx.Value;
94
  int Align = align;
95
}
96
 
97
// Returned - The specified argument is always the return value of the
98
// intrinsic.
99
class Returned<AttrIndex idx> : IntrinsicProperty {
100
  int ArgNo = idx.Value;
101
}
102
 
103
// ImmArg - The specified argument must be an immediate.
104
class ImmArg<AttrIndex idx> : IntrinsicProperty {
105
  int ArgNo = idx.Value;
106
}
107
 
108
// ReadOnly - The specified argument pointer is not written to through the
109
// pointer by the intrinsic.
110
class ReadOnly<AttrIndex idx> : IntrinsicProperty {
111
  int ArgNo = idx.Value;
112
}
113
 
114
// WriteOnly - The intrinsic does not read memory through the specified
115
// argument pointer.
116
class WriteOnly<AttrIndex idx> : IntrinsicProperty {
117
  int ArgNo = idx.Value;
118
}
119
 
120
// ReadNone - The specified argument pointer is not dereferenced by the
121
// intrinsic.
122
class ReadNone<AttrIndex idx> : IntrinsicProperty {
123
  int ArgNo = idx.Value;
124
}
125
 
126
def IntrNoReturn : IntrinsicProperty;
127
 
128
// Applied by default.
129
def IntrNoCallback : IntrinsicProperty<1>;
130
 
131
// IntrNoSync - Threads executing the intrinsic will not synchronize using
132
// memory or other means. Applied by default.
133
def IntrNoSync : IntrinsicProperty<1>;
134
 
135
// Applied by default.
136
def IntrNoFree : IntrinsicProperty<1>;
137
 
138
// Applied by default.
139
def IntrWillReturn : IntrinsicProperty<1>;
140
 
141
// IntrCold - Calls to this intrinsic are cold.
142
// Parallels the cold attribute on LLVM IR functions.
143
def IntrCold : IntrinsicProperty;
144
 
145
// IntrNoDuplicate - Calls to this intrinsic cannot be duplicated.
146
// Parallels the noduplicate attribute on LLVM IR functions.
147
def IntrNoDuplicate : IntrinsicProperty;
148
 
149
// IntrNoMerge - Calls to this intrinsic cannot be merged
150
// Parallels the nomerge attribute on LLVM IR functions.
151
def IntrNoMerge : IntrinsicProperty;
152
 
153
// IntrConvergent - Calls to this intrinsic are convergent and may not be made
154
// control-dependent on any additional values.
155
// Parallels the convergent attribute on LLVM IR functions.
156
def IntrConvergent : IntrinsicProperty;
157
 
158
// This property indicates that the intrinsic is safe to speculate.
159
def IntrSpeculatable : IntrinsicProperty;
160
 
161
// This property can be used to override the 'has no other side effects'
162
// language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly
163
// intrinsic properties.  By default, intrinsics are assumed to have side
164
// effects, so this property is only necessary if you have defined one of
165
// the memory properties listed above.
166
// For this property, 'side effects' has the same meaning as 'side effects'
167
// defined by the hasSideEffects property of the TableGen Instruction class.
168
def IntrHasSideEffects : IntrinsicProperty;
169
 
170
//===----------------------------------------------------------------------===//
171
// Types used by intrinsics.
172
//===----------------------------------------------------------------------===//
173
 
174
class LLVMType<ValueType vt> {
175
  ValueType VT = vt;
176
  int isAny = false;
177
}
178
 
179
class LLVMQualPointerType<LLVMType elty, int addrspace>
180
  : LLVMType<iPTR>{
181
  LLVMType ElTy = elty;
182
  int AddrSpace = addrspace;
183
}
184
 
185
class LLVMPointerType<LLVMType elty>
186
  : LLVMQualPointerType<elty, 0>;
187
 
188
class LLVMAnyPointerType<LLVMType elty>
189
  : LLVMType<iPTRAny>{
190
  LLVMType ElTy = elty;
191
 
192
  let isAny = true;
193
}
194
 
195
// Match the type of another intrinsic parameter.  Number is an index into the
196
// list of overloaded types for the intrinsic, excluding all the fixed types.
197
// The Number value must refer to a previously listed type.  For example:
198
//   Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
199
// has two overloaded types, the 2nd and 3rd arguments.  LLVMMatchType<0>
200
// refers to the first overloaded type, which is the 2nd argument.
201
class LLVMMatchType<int num>
202
  : LLVMType<OtherVT>{
203
  int Number = num;
204
}
205
 
206
// Match the type of another intrinsic parameter that is expected to be based on
207
// an integral type (i.e. either iN or <N x iM>), but change the scalar size to
208
// be twice as wide or half as wide as the other type.  This is only useful when
209
// the intrinsic is overloaded, so the matched type should be declared as iAny.
210
class LLVMExtendedType<int num> : LLVMMatchType<num>;
211
class LLVMTruncatedType<int num> : LLVMMatchType<num>;
212
 
213
// Match the scalar/vector of another intrinsic parameter but with a different
214
// element type. Either both are scalars or both are vectors with the same
215
// number of elements.
216
class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
217
  : LLVMMatchType<idx> {
218
  ValueType ElTy = elty.VT;
219
}
220
 
221
class LLVMPointerTo<int num> : LLVMMatchType<num>;
222
class LLVMPointerToElt<int num> : LLVMMatchType<num>;
223
class LLVMAnyPointerToElt<int num> : LLVMMatchType<num>;
224
class LLVMVectorOfAnyPointersToElt<int num> : LLVMMatchType<num>;
225
class LLVMVectorElementType<int num> : LLVMMatchType<num>;
226
 
227
// Match the type of another intrinsic parameter that is expected to be a
228
// vector type, but change the element count to be half as many.
229
class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>;
230
 
231
// Match the type of another intrinsic parameter that is expected to be a
232
// vector type (i.e. <N x iM>) but with each element subdivided to
233
// form a vector with more elements that are smaller than the original.
234
class LLVMSubdivide2VectorType<int num> : LLVMMatchType<num>;
235
class LLVMSubdivide4VectorType<int num> : LLVMMatchType<num>;
236
 
237
// Match the element count and bit width of another intrinsic parameter, but
238
// change the element type to an integer.
239
class LLVMVectorOfBitcastsToInt<int num> : LLVMMatchType<num>;
240
 
241
def llvm_void_ty       : LLVMType<isVoid>;
242
let isAny = true in {
243
  def llvm_any_ty        : LLVMType<Any>;
244
  def llvm_anyint_ty     : LLVMType<iAny>;
245
  def llvm_anyfloat_ty   : LLVMType<fAny>;
246
  def llvm_anyvector_ty  : LLVMType<vAny>;
247
}
248
def llvm_i1_ty         : LLVMType<i1>;
249
def llvm_i8_ty         : LLVMType<i8>;
250
def llvm_i16_ty        : LLVMType<i16>;
251
def llvm_i32_ty        : LLVMType<i32>;
252
def llvm_i64_ty        : LLVMType<i64>;
253
def llvm_i128_ty       : LLVMType<i128>;
254
def llvm_half_ty       : LLVMType<f16>;
255
def llvm_bfloat_ty     : LLVMType<bf16>;
256
def llvm_float_ty      : LLVMType<f32>;
257
def llvm_double_ty     : LLVMType<f64>;
258
def llvm_f80_ty        : LLVMType<f80>;
259
def llvm_f128_ty       : LLVMType<f128>;
260
def llvm_ppcf128_ty    : LLVMType<ppcf128>;
261
def llvm_ptr_ty        : LLVMPointerType<llvm_i8_ty>;             // i8*
262
def llvm_ptrptr_ty     : LLVMPointerType<llvm_ptr_ty>;            // i8**
263
def llvm_anyptr_ty     : LLVMAnyPointerType<llvm_i8_ty>;          // (space)i8*
264
def llvm_empty_ty      : LLVMType<OtherVT>;                       // { }
265
def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>;          // { }*
266
def llvm_metadata_ty   : LLVMType<MetadataVT>;                    // !{...}
267
def llvm_token_ty      : LLVMType<token>;                         // token
268
 
269
def llvm_x86mmx_ty     : LLVMType<x86mmx>;
270
def llvm_ptrx86mmx_ty  : LLVMPointerType<llvm_x86mmx_ty>;         // <1 x i64>*
271
 
272
def llvm_x86amx_ty     : LLVMType<x86amx>;
273
 
274
def llvm_v2i1_ty       : LLVMType<v2i1>;     //   2 x i1
275
def llvm_v4i1_ty       : LLVMType<v4i1>;     //   4 x i1
276
def llvm_v8i1_ty       : LLVMType<v8i1>;     //   8 x i1
277
def llvm_v16i1_ty      : LLVMType<v16i1>;    //  16 x i1
278
def llvm_v32i1_ty      : LLVMType<v32i1>;    //  32 x i1
279
def llvm_v64i1_ty      : LLVMType<v64i1>;    //  64 x i1
280
def llvm_v128i1_ty     : LLVMType<v128i1>;   // 128 x i1
281
def llvm_v256i1_ty     : LLVMType<v256i1>;   // 256 x i1
282
def llvm_v512i1_ty     : LLVMType<v512i1>;   // 512 x i1
283
def llvm_v1024i1_ty    : LLVMType<v1024i1>;  //1024 x i1
284
def llvm_v2048i1_ty    : LLVMType<v2048i1>;  //2048 x i1
285
 
286
def llvm_v1i8_ty       : LLVMType<v1i8>;     //  1 x i8
287
def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8
288
def llvm_v4i8_ty       : LLVMType<v4i8>;     //  4 x i8
289
def llvm_v8i8_ty       : LLVMType<v8i8>;     //  8 x i8
290
def llvm_v16i8_ty      : LLVMType<v16i8>;    // 16 x i8
291
def llvm_v32i8_ty      : LLVMType<v32i8>;    // 32 x i8
292
def llvm_v64i8_ty      : LLVMType<v64i8>;    // 64 x i8
293
def llvm_v128i8_ty     : LLVMType<v128i8>;   //128 x i8
294
def llvm_v256i8_ty     : LLVMType<v256i8>;   //256 x i8
295
 
296
def llvm_v1i16_ty      : LLVMType<v1i16>;    //  1 x i16
297
def llvm_v2i16_ty      : LLVMType<v2i16>;    //  2 x i16
298
def llvm_v4i16_ty      : LLVMType<v4i16>;    //  4 x i16
299
def llvm_v8i16_ty      : LLVMType<v8i16>;    //  8 x i16
300
def llvm_v16i16_ty     : LLVMType<v16i16>;   // 16 x i16
301
def llvm_v32i16_ty     : LLVMType<v32i16>;   // 32 x i16
302
def llvm_v64i16_ty     : LLVMType<v64i16>;   // 64 x i16
303
def llvm_v128i16_ty    : LLVMType<v128i16>;  //128 x i16
304
 
305
def llvm_v1i32_ty      : LLVMType<v1i32>;    //  1 x i32
306
def llvm_v2i32_ty      : LLVMType<v2i32>;    //  2 x i32
307
def llvm_v4i32_ty      : LLVMType<v4i32>;    //  4 x i32
308
def llvm_v8i32_ty      : LLVMType<v8i32>;    //  8 x i32
309
def llvm_v16i32_ty     : LLVMType<v16i32>;   // 16 x i32
310
def llvm_v32i32_ty     : LLVMType<v32i32>;   // 32 x i32
311
def llvm_v64i32_ty     : LLVMType<v64i32>;   // 64 x i32
312
def llvm_v256i32_ty    : LLVMType<v256i32>;  //256 x i32
313
 
314
def llvm_v1i64_ty      : LLVMType<v1i64>;    //  1 x i64
315
def llvm_v2i64_ty      : LLVMType<v2i64>;    //  2 x i64
316
def llvm_v4i64_ty      : LLVMType<v4i64>;    //  4 x i64
317
def llvm_v8i64_ty      : LLVMType<v8i64>;    //  8 x i64
318
def llvm_v16i64_ty     : LLVMType<v16i64>;   // 16 x i64
319
def llvm_v32i64_ty     : LLVMType<v32i64>;   // 32 x i64
320
 
321
def llvm_v1i128_ty     : LLVMType<v1i128>;   //  1 x i128
322
 
323
def llvm_v2f16_ty      : LLVMType<v2f16>;    //  2 x half (__fp16)
324
def llvm_v4f16_ty      : LLVMType<v4f16>;    //  4 x half (__fp16)
325
def llvm_v8f16_ty      : LLVMType<v8f16>;    //  8 x half (__fp16)
326
def llvm_v16f16_ty     : LLVMType<v16f16>;   // 16 x half (__fp16)
327
def llvm_v32f16_ty     : LLVMType<v32f16>;   // 32 x half (__fp16)
328
def llvm_v2bf16_ty     : LLVMType<v2bf16>;   //  2 x bfloat (__bf16)
329
def llvm_v4bf16_ty     : LLVMType<v4bf16>;   //  4 x bfloat (__bf16)
330
def llvm_v8bf16_ty     : LLVMType<v8bf16>;   //  8 x bfloat (__bf16)
331
def llvm_v16bf16_ty    : LLVMType<v16bf16>;  // 16 x bfloat (__bf16)
332
def llvm_v32bf16_ty    : LLVMType<v32bf16>;  // 32 x bfloat (__bf16)
333
def llvm_v1f32_ty      : LLVMType<v1f32>;    //  1 x float
334
def llvm_v2f32_ty      : LLVMType<v2f32>;    //  2 x float
335
def llvm_v3f32_ty      : LLVMType<v3f32>;    //  3 x float
336
def llvm_v4f32_ty      : LLVMType<v4f32>;    //  4 x float
337
def llvm_v8f32_ty      : LLVMType<v8f32>;    //  8 x float
338
def llvm_v16f32_ty     : LLVMType<v16f32>;   // 16 x float
339
def llvm_v32f32_ty     : LLVMType<v32f32>;   // 32 x float
340
def llvm_v1f64_ty      : LLVMType<v1f64>;    //  1 x double
341
def llvm_v2f64_ty      : LLVMType<v2f64>;    //  2 x double
342
def llvm_v4f64_ty      : LLVMType<v4f64>;    //  4 x double
343
def llvm_v8f64_ty      : LLVMType<v8f64>;    //  8 x double
344
def llvm_v16f64_ty     : LLVMType<v16f64>;   // 16 x double
345
 
346
def llvm_vararg_ty     : LLVMType<isVoid>;   // this means vararg here
347
 
348
def llvm_externref_ty  : LLVMType<externref>;
349
def llvm_funcref_ty    : LLVMType<funcref>;
350
 
351
//===----------------------------------------------------------------------===//
352
// Intrinsic Definitions.
353
//===----------------------------------------------------------------------===//
354
 
355
// Intrinsic class - This is used to define one LLVM intrinsic.  The name of the
356
// intrinsic definition should start with "int_", then match the LLVM intrinsic
357
// name with the "llvm." prefix removed, and all "."s turned into "_"s.  For
358
// example, llvm.bswap.i16 -> int_bswap_i16.
359
//
360
//  * RetTypes is a list containing the return types expected for the
361
//    intrinsic.
362
//  * ParamTypes is a list containing the parameter types expected for the
363
//    intrinsic.
364
//  * Properties can be set to describe the behavior of the intrinsic.
365
//
366
class Intrinsic<list<LLVMType> ret_types,
367
                list<LLVMType> param_types = [],
368
                list<IntrinsicProperty> intr_properties = [],
369
                string name = "",
370
                list<SDNodeProperty> sd_properties = [],
371
                bit disable_default_attributes = true> : SDPatternOperator {
372
  string LLVMName = name;
373
  string TargetPrefix = "";   // Set to a prefix for target-specific intrinsics.
374
  list<LLVMType> RetTypes = ret_types;
375
  list<LLVMType> ParamTypes = param_types;
376
  list<IntrinsicProperty> IntrProperties = intr_properties;
377
  let Properties = sd_properties;
378
 
379
  // Disable applying IntrinsicProperties that are marked default with
380
  // IntrinsicProperty<1>
381
  bit DisableDefaultAttributes = disable_default_attributes;
382
 
383
  bit isTarget = false;
384
}
385
 
386
// Intrinsic with default attributes (disable_default_attributes = false).
387
class DefaultAttrsIntrinsic<list<LLVMType> ret_types,
388
                list<LLVMType> param_types = [],
389
                list<IntrinsicProperty> intr_properties = [],
390
                string name = "",
391
                list<SDNodeProperty> sd_properties = []>
392
                : Intrinsic<ret_types, param_types,
393
                            intr_properties, name,
394
                            sd_properties, /*disable_default_attributes*/ 0> {}
395
 
396
/// ClangBuiltin - If this intrinsic exactly corresponds to a Clang builtin, this
397
/// specifies the name of the builtin.  This provides automatic CBE and CFE
398
/// support.
399
class ClangBuiltin<string name> {
400
  string ClangBuiltinName = name;
401
}
402
 
403
class MSBuiltin<string name> {
404
  string MSBuiltinName = name;
405
}
406
 
407
 
408
//===--------------- Variable Argument Handling Intrinsics ----------------===//
409
//
410
 
411
def int_vastart : DefaultAttrsIntrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">;
412
def int_vacopy  : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [],
413
                            "llvm.va_copy">;
414
def int_vaend   : DefaultAttrsIntrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">;
415
 
416
//===------------------- Garbage Collection Intrinsics --------------------===//
417
//
418
def int_gcroot  : Intrinsic<[],
419
                            [llvm_ptrptr_ty, llvm_ptr_ty]>;
420
def int_gcread  : Intrinsic<[llvm_ptr_ty],
421
                            [llvm_ptr_ty, llvm_ptrptr_ty],
422
                            [IntrReadMem, IntrArgMemOnly]>;
423
def int_gcwrite : Intrinsic<[],
424
                            [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty],
425
                            [IntrArgMemOnly, NoCapture<ArgIndex<1>>,
426
                             NoCapture<ArgIndex<2>>]>;
427
 
428
//===------------------- ObjC ARC runtime Intrinsics --------------------===//
429
//
430
// Note these are to support the Objective-C ARC optimizer which wants to
431
// eliminate retain and releases where possible.
432
 
433
def int_objc_autorelease                    : Intrinsic<[llvm_ptr_ty],
434
                                                        [llvm_ptr_ty]>;
435
def int_objc_autoreleasePoolPop             : Intrinsic<[], [llvm_ptr_ty]>;
436
def int_objc_autoreleasePoolPush            : Intrinsic<[llvm_ptr_ty], []>;
437
def int_objc_autoreleaseReturnValue         : Intrinsic<[llvm_ptr_ty],
438
                                                        [llvm_ptr_ty]>;
439
def int_objc_copyWeak                       : Intrinsic<[],
440
                                                        [llvm_ptrptr_ty,
441
                                                         llvm_ptrptr_ty]>;
442
def int_objc_destroyWeak                    : Intrinsic<[], [llvm_ptrptr_ty]>;
443
def int_objc_initWeak                       : Intrinsic<[llvm_ptr_ty],
444
                                                        [llvm_ptrptr_ty,
445
                                                         llvm_ptr_ty]>;
446
def int_objc_loadWeak                       : Intrinsic<[llvm_ptr_ty],
447
                                                        [llvm_ptrptr_ty]>;
448
def int_objc_loadWeakRetained               : Intrinsic<[llvm_ptr_ty],
449
                                                        [llvm_ptrptr_ty]>;
450
def int_objc_moveWeak                       : Intrinsic<[],
451
                                                        [llvm_ptrptr_ty,
452
                                                         llvm_ptrptr_ty]>;
453
def int_objc_release                        : Intrinsic<[], [llvm_ptr_ty]>;
454
def int_objc_retain                         : Intrinsic<[llvm_ptr_ty],
455
                                                        [llvm_ptr_ty]>;
456
def int_objc_retainAutorelease              : Intrinsic<[llvm_ptr_ty],
457
                                                        [llvm_ptr_ty]>;
458
def int_objc_retainAutoreleaseReturnValue   : Intrinsic<[llvm_ptr_ty],
459
                                                        [llvm_ptr_ty]>;
460
def int_objc_retainAutoreleasedReturnValue  : Intrinsic<[llvm_ptr_ty],
461
                                                        [llvm_ptr_ty]>;
462
def int_objc_retainBlock                    : Intrinsic<[llvm_ptr_ty],
463
                                                        [llvm_ptr_ty]>;
464
def int_objc_storeStrong                    : Intrinsic<[],
465
                                                        [llvm_ptrptr_ty,
466
                                                         llvm_ptr_ty]>;
467
def int_objc_storeWeak                      : Intrinsic<[llvm_ptr_ty],
468
                                                        [llvm_ptrptr_ty,
469
                                                         llvm_ptr_ty]>;
470
def int_objc_clang_arc_use                  : Intrinsic<[],
471
                                                        [llvm_vararg_ty]>;
472
def int_objc_clang_arc_noop_use : DefaultAttrsIntrinsic<[],
473
                                                        [llvm_vararg_ty],
474
                                                        [IntrInaccessibleMemOnly]>;
475
def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
476
                                                            [llvm_ptr_ty]>;
477
def int_objc_retainedObject                 : Intrinsic<[llvm_ptr_ty],
478
                                                        [llvm_ptr_ty]>;
479
def int_objc_unretainedObject               : Intrinsic<[llvm_ptr_ty],
480
                                                        [llvm_ptr_ty]>;
481
def int_objc_unretainedPointer              : Intrinsic<[llvm_ptr_ty],
482
                                                        [llvm_ptr_ty]>;
483
def int_objc_retain_autorelease             : Intrinsic<[llvm_ptr_ty],
484
                                                        [llvm_ptr_ty]>;
485
def int_objc_sync_enter                     : Intrinsic<[llvm_i32_ty],
486
                                                        [llvm_ptr_ty]>;
487
def int_objc_sync_exit                      : Intrinsic<[llvm_i32_ty],
488
                                                        [llvm_ptr_ty]>;
489
def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
490
                                                        [llvm_ptrptr_ty,
491
                                                         llvm_ptrptr_ty]>;
492
def int_objc_arc_annotation_topdown_bbend   : Intrinsic<[],
493
                                                        [llvm_ptrptr_ty,
494
                                                         llvm_ptrptr_ty]>;
495
def int_objc_arc_annotation_bottomup_bbstart  : Intrinsic<[],
496
                                                          [llvm_ptrptr_ty,
497
                                                           llvm_ptrptr_ty]>;
498
def int_objc_arc_annotation_bottomup_bbend  : Intrinsic<[],
499
                                                        [llvm_ptrptr_ty,
500
                                                         llvm_ptrptr_ty]>;
501
//===--------------- Swift asynchronous context intrinsics ----------------===//
502
 
503
// Returns the location of the Swift asynchronous context (usually stored just
504
// before the frame pointer), and triggers the creation of a null context if it
505
// would otherwise be unneeded.
506
def int_swift_async_context_addr : Intrinsic<[llvm_ptrptr_ty], [], []>;
507
 
508
//===--------------------- Code Generator Intrinsics ----------------------===//
509
//
510
def int_returnaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_i32_ty],
511
                                  [IntrNoMem, ImmArg<ArgIndex<0>>]>;
512
def int_addressofreturnaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
513
def int_frameaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_i32_ty],
514
                                 [IntrNoMem, ImmArg<ArgIndex<0>>]>;
515
def int_sponentry  : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
516
def int_read_register  : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
517
                                   [IntrReadMem], "llvm.read_register">;
518
def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
519
                                   [IntrNoCallback], "llvm.write_register">;
520
def int_read_volatile_register  : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
521
                                            [IntrHasSideEffects],
522
                                             "llvm.read_volatile_register">;
523
 
524
// Gets the address of the local variable area. This is typically a copy of the
525
// stack, frame, or base pointer depending on the type of prologue.
526
def int_localaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
527
 
528
// Escapes local variables to allow access from other functions.
529
def int_localescape : DefaultAttrsIntrinsic<[], [llvm_vararg_ty]>;
530
 
531
// Given a function and the localaddress of a parent frame, returns a pointer
532
// to an escaped allocation indicated by the index.
533
def int_localrecover : DefaultAttrsIntrinsic<[llvm_ptr_ty],
534
                                 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
535
                                 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
536
 
537
// Given the frame pointer passed into an SEH filter function, returns a
538
// pointer to the local variable area suitable for use with llvm.localrecover.
539
def int_eh_recoverfp : DefaultAttrsIntrinsic<[llvm_ptr_ty],
540
                                 [llvm_ptr_ty, llvm_ptr_ty],
541
                                 [IntrNoMem]>;
542
 
543
// To mark the beginning/end of a try-scope for Windows SEH -EHa
544
//  calls/invokes to these intrinsics are placed to model control flows
545
//    caused by HW exceptions under option -EHa.
546
//  calls/invokes to these intrinsics will be discarded during a codegen pass
547
//   after EH tables are generated
548
def int_seh_try_begin : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
549
def int_seh_try_end : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
550
def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
551
def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>;
552
 
553
// Note: we treat stacksave/stackrestore as writemem because we don't otherwise
554
// model their dependencies on allocas.
555
def int_stacksave     : DefaultAttrsIntrinsic<[llvm_ptr_ty]>,
556
                        ClangBuiltin<"__builtin_stack_save">;
557
def int_stackrestore  : DefaultAttrsIntrinsic<[], [llvm_ptr_ty]>,
558
                        ClangBuiltin<"__builtin_stack_restore">;
559
 
560
def int_get_dynamic_area_offset : DefaultAttrsIntrinsic<[llvm_anyint_ty]>;
561
 
562
def int_thread_pointer : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
563
                         ClangBuiltin<"__builtin_thread_pointer">;
564
 
565
// IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
566
// necessary for prefetch, however it does conveniently prevent the prefetch
567
// from being reordered overly much with respect to nearby access to the same
568
// memory while not impeding optimization.
569
def int_prefetch
570
    : DefaultAttrsIntrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
571
                [IntrInaccessibleMemOrArgMemOnly, IntrWillReturn,
572
                 ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>,
573
                 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
574
def int_pcmarker      : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
575
 
576
def int_readcyclecounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>;
577
 
578
// The assume intrinsic is marked InaccessibleMemOnly so that proper control
579
// dependencies will be maintained.
580
def int_assume : DefaultAttrsIntrinsic<
581
    [], [llvm_i1_ty], [IntrInaccessibleMemOnly, NoUndef<ArgIndex<0>>]>;
582
 
583
// 'llvm.experimental.noalias.scope.decl' intrinsic: Inserted at the location of
584
// noalias scope declaration. Makes it possible to identify that a noalias scope
585
// is only valid inside the body of a loop.
586
//
587
// Purpose of the different arguments:
588
// - arg0: id.scope: metadata representing the scope declaration.
589
def int_experimental_noalias_scope_decl
590
    : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
591
        [IntrInaccessibleMemOnly]>; // blocks LICM and some more
592
 
593
// Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
594
// guard to the correct place on the stack frame.
595
def int_stackprotector : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>;
596
def int_stackguard : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], []>;
597
 
598
// A cover for instrumentation based profiling.
599
def int_instrprof_cover : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty,
600
                                         llvm_i32_ty, llvm_i32_ty]>;
601
 
602
// A counter increment for instrumentation based profiling.
603
def int_instrprof_increment : Intrinsic<[],
604
                                        [llvm_ptr_ty, llvm_i64_ty,
605
                                         llvm_i32_ty, llvm_i32_ty]>;
606
 
607
// A counter increment with step for instrumentation based profiling.
608
def int_instrprof_increment_step : Intrinsic<[],
609
                                        [llvm_ptr_ty, llvm_i64_ty,
610
                                         llvm_i32_ty, llvm_i32_ty, llvm_i64_ty]>;
611
 
612
// A call to profile runtime for value profiling of target expressions
613
// through instrumentation based profiling.
614
def int_instrprof_value_profile : Intrinsic<[],
615
                                            [llvm_ptr_ty, llvm_i64_ty,
616
                                             llvm_i64_ty, llvm_i32_ty,
617
                                             llvm_i32_ty]>;
618
 
619
def int_call_preallocated_setup : DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty]>;
620
def int_call_preallocated_arg : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty]>;
621
def int_call_preallocated_teardown : DefaultAttrsIntrinsic<[], [llvm_token_ty]>;
622
 
623
//===------------------- Standard C Library Intrinsics --------------------===//
624
//
625
 
626
def int_memcpy  : Intrinsic<[],
627
                            [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
628
                             llvm_i1_ty],
629
                            [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
630
                             IntrNoCallback,
631
                             NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
632
                             NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
633
                             WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
634
                             ImmArg<ArgIndex<3>>]>;
635
 
636
// Memcpy semantic that is guaranteed to be inlined.
637
// In particular this means that the generated code is not allowed to call any
638
// external function.
639
// The third argument (specifying the size) must be a constant.
640
def int_memcpy_inline
641
    : Intrinsic<[],
642
      [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i1_ty],
643
      [IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
644
       NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
645
       NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
646
       WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
647
       ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
648
 
649
def int_memmove : Intrinsic<[],
650
                            [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
651
                             llvm_i1_ty],
652
                            [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
653
                             IntrNoCallback,
654
                             NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
655
                             WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
656
                             ImmArg<ArgIndex<3>>]>;
657
def int_memset  : Intrinsic<[],
658
                            [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
659
                             llvm_i1_ty],
660
                            [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
661
                             IntrNoFree, IntrNoCallback,
662
                             NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
663
                             ImmArg<ArgIndex<3>>]>;
664
 
665
// Memset version that is guaranteed to be inlined.
666
// In particular this means that the generated code is not allowed to call any
667
// external function.
668
// The third argument (specifying the size) must be a constant.
669
def int_memset_inline
670
    : Intrinsic<[],
671
      [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i1_ty],
672
      [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
673
       NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
674
       ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
675
 
676
// FIXME: Add version of these floating point intrinsics which allow non-default
677
// rounding modes and FP exception handling.
678
 
679
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
680
  def int_fma  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
681
                           [LLVMMatchType<0>, LLVMMatchType<0>,
682
                            LLVMMatchType<0>]>;
683
  def int_fmuladd : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
684
                              [LLVMMatchType<0>, LLVMMatchType<0>,
685
                               LLVMMatchType<0>]>;
686
 
687
  // These functions do not read memory, but are sensitive to the
688
  // rounding mode. LLVM purposely does not model changes to the FP
689
  // environment so they can be treated as readnone.
690
  def int_sqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
691
  def int_powi : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_anyint_ty]>;
692
  def int_sin  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
693
  def int_cos  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
694
  def int_pow  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
695
                           [LLVMMatchType<0>, LLVMMatchType<0>]>;
696
  def int_log  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
697
  def int_log10: DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
698
  def int_log2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
699
  def int_exp  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
700
  def int_exp2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
701
  def int_fabs : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
702
  def int_copysign : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
703
                               [LLVMMatchType<0>, LLVMMatchType<0>]>;
704
  def int_floor : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
705
  def int_ceil  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
706
  def int_trunc : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
707
  def int_rint  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
708
  def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
709
  def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
710
  def int_roundeven    : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
711
 
712
  // Truncate a floating point number with a specific rounding mode
713
  def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
714
                                                [ llvm_anyfloat_ty, llvm_metadata_ty ]>;
715
 
716
  def int_canonicalize : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
717
                                   [IntrNoMem]>;
718
  // Arithmetic fence intrinsic.
719
  def int_arithmetic_fence : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
720
                                                   [IntrNoMem]>;
721
 
722
  def int_lround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
723
  def int_llround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
724
  def int_lrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
725
  def int_llrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
726
}
727
 
728
def int_minnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
729
  [LLVMMatchType<0>, LLVMMatchType<0>],
730
  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
731
>;
732
def int_maxnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
733
  [LLVMMatchType<0>, LLVMMatchType<0>],
734
  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
735
>;
736
def int_minimum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
737
  [LLVMMatchType<0>, LLVMMatchType<0>],
738
  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
739
>;
740
def int_maximum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
741
  [LLVMMatchType<0>, LLVMMatchType<0>],
742
  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
743
>;
744
 
745
// Internal interface for object size checking
746
def int_objectsize : DefaultAttrsIntrinsic<[llvm_anyint_ty],
747
                               [llvm_anyptr_ty, llvm_i1_ty,
748
                                llvm_i1_ty, llvm_i1_ty],
749
                               [IntrNoMem, IntrSpeculatable, IntrWillReturn,
750
                                ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>,
751
                                ImmArg<ArgIndex<3>>]>,
752
                               ClangBuiltin<"__builtin_object_size">;
753
 
754
//===--------------- Access to Floating Point Environment -----------------===//
755
//
756
 
757
let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
758
  def int_get_rounding  : DefaultAttrsIntrinsic<[llvm_i32_ty], []>;
759
  def int_set_rounding  : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
760
}
761
 
762
//===--------------- Floating Point Properties ----------------------------===//
763
//
764
 
765
def int_is_fpclass
766
    : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
767
                            [llvm_anyfloat_ty, llvm_i32_ty],
768
                            [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
769
 
770
//===--------------- Constrained Floating Point Intrinsics ----------------===//
771
//
772
 
773
let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
774
  def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
775
                                                    [ LLVMMatchType<0>,
776
                                                      LLVMMatchType<0>,
777
                                                      llvm_metadata_ty,
778
                                                      llvm_metadata_ty ]>;
779
  def int_experimental_constrained_fsub : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
780
                                                    [ LLVMMatchType<0>,
781
                                                      LLVMMatchType<0>,
782
                                                      llvm_metadata_ty,
783
                                                      llvm_metadata_ty ]>;
784
  def int_experimental_constrained_fmul : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
785
                                                    [ LLVMMatchType<0>,
786
                                                      LLVMMatchType<0>,
787
                                                      llvm_metadata_ty,
788
                                                      llvm_metadata_ty ]>;
789
  def int_experimental_constrained_fdiv : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
790
                                                    [ LLVMMatchType<0>,
791
                                                      LLVMMatchType<0>,
792
                                                      llvm_metadata_ty,
793
                                                      llvm_metadata_ty ]>;
794
  def int_experimental_constrained_frem : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
795
                                                    [ LLVMMatchType<0>,
796
                                                      LLVMMatchType<0>,
797
                                                      llvm_metadata_ty,
798
                                                      llvm_metadata_ty ]>;
799
 
800
  def int_experimental_constrained_fma : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
801
                                                    [ LLVMMatchType<0>,
802
                                                      LLVMMatchType<0>,
803
                                                      LLVMMatchType<0>,
804
                                                      llvm_metadata_ty,
805
                                                      llvm_metadata_ty ]>;
806
 
807
  def int_experimental_constrained_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
808
                                                       [ LLVMMatchType<0>,
809
                                                         LLVMMatchType<0>,
810
                                                         LLVMMatchType<0>,
811
                                                         llvm_metadata_ty,
812
                                                         llvm_metadata_ty ]>;
813
 
814
  def int_experimental_constrained_fptosi : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
815
                                                    [ llvm_anyfloat_ty,
816
                                                      llvm_metadata_ty ]>;
817
 
818
  def int_experimental_constrained_fptoui : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
819
                                                    [ llvm_anyfloat_ty,
820
                                                      llvm_metadata_ty ]>;
821
 
822
  def int_experimental_constrained_sitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
823
                                                       [ llvm_anyint_ty,
824
                                                         llvm_metadata_ty,
825
                                                         llvm_metadata_ty ]>;
826
 
827
  def int_experimental_constrained_uitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
828
                                                       [ llvm_anyint_ty,
829
                                                         llvm_metadata_ty,
830
                                                         llvm_metadata_ty ]>;
831
 
832
  def int_experimental_constrained_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
833
                                                       [ llvm_anyfloat_ty,
834
                                                         llvm_metadata_ty,
835
                                                         llvm_metadata_ty ]>;
836
 
837
  def int_experimental_constrained_fpext : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
838
                                                     [ llvm_anyfloat_ty,
839
                                                       llvm_metadata_ty ]>;
840
 
841
  // These intrinsics are sensitive to the rounding mode so we need constrained
842
  // versions of each of them.  When strict rounding and exception control are
843
  // not required the non-constrained versions of these intrinsics should be
844
  // used.
845
  def int_experimental_constrained_sqrt : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
846
                                                    [ LLVMMatchType<0>,
847
                                                      llvm_metadata_ty,
848
                                                      llvm_metadata_ty ]>;
849
  def int_experimental_constrained_powi : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
850
                                                    [ LLVMMatchType<0>,
851
                                                      llvm_i32_ty,
852
                                                      llvm_metadata_ty,
853
                                                      llvm_metadata_ty ]>;
854
  def int_experimental_constrained_sin  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
855
                                                    [ LLVMMatchType<0>,
856
                                                      llvm_metadata_ty,
857
                                                      llvm_metadata_ty ]>;
858
  def int_experimental_constrained_cos  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
859
                                                    [ LLVMMatchType<0>,
860
                                                      llvm_metadata_ty,
861
                                                      llvm_metadata_ty ]>;
862
  def int_experimental_constrained_pow  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
863
                                                    [ LLVMMatchType<0>,
864
                                                      LLVMMatchType<0>,
865
                                                      llvm_metadata_ty,
866
                                                      llvm_metadata_ty ]>;
867
  def int_experimental_constrained_log  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
868
                                                    [ LLVMMatchType<0>,
869
                                                      llvm_metadata_ty,
870
                                                      llvm_metadata_ty ]>;
871
  def int_experimental_constrained_log10: DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
872
                                                    [ LLVMMatchType<0>,
873
                                                      llvm_metadata_ty,
874
                                                      llvm_metadata_ty ]>;
875
  def int_experimental_constrained_log2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
876
                                                    [ LLVMMatchType<0>,
877
                                                      llvm_metadata_ty,
878
                                                      llvm_metadata_ty ]>;
879
  def int_experimental_constrained_exp  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
880
                                                    [ LLVMMatchType<0>,
881
                                                      llvm_metadata_ty,
882
                                                      llvm_metadata_ty ]>;
883
  def int_experimental_constrained_exp2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
884
                                                    [ LLVMMatchType<0>,
885
                                                      llvm_metadata_ty,
886
                                                      llvm_metadata_ty ]>;
887
  def int_experimental_constrained_rint  : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
888
                                                     [ LLVMMatchType<0>,
889
                                                       llvm_metadata_ty,
890
                                                       llvm_metadata_ty ]>;
891
  def int_experimental_constrained_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
892
                                                         [ LLVMMatchType<0>,
893
                                                           llvm_metadata_ty,
894
                                                           llvm_metadata_ty ]>;
895
  def int_experimental_constrained_lrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
896
                                                     [ llvm_anyfloat_ty,
897
                                                       llvm_metadata_ty,
898
                                                       llvm_metadata_ty ]>;
899
  def int_experimental_constrained_llrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
900
                                                      [ llvm_anyfloat_ty,
901
                                                        llvm_metadata_ty,
902
                                                        llvm_metadata_ty ]>;
903
  def int_experimental_constrained_maxnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
904
                                                      [ LLVMMatchType<0>,
905
                                                        LLVMMatchType<0>,
906
                                                        llvm_metadata_ty ]>;
907
  def int_experimental_constrained_minnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
908
                                                      [ LLVMMatchType<0>,
909
                                                        LLVMMatchType<0>,
910
                                                        llvm_metadata_ty ]>;
911
  def int_experimental_constrained_maximum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
912
                                                       [ LLVMMatchType<0>,
913
                                                         LLVMMatchType<0>,
914
                                                         llvm_metadata_ty ]>;
915
  def int_experimental_constrained_minimum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
916
                                                       [ LLVMMatchType<0>,
917
                                                         LLVMMatchType<0>,
918
                                                         llvm_metadata_ty ]>;
919
  def int_experimental_constrained_ceil : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
920
                                                    [ LLVMMatchType<0>,
921
                                                      llvm_metadata_ty ]>;
922
  def int_experimental_constrained_floor : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
923
                                                     [ LLVMMatchType<0>,
924
                                                       llvm_metadata_ty ]>;
925
  def int_experimental_constrained_lround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
926
                                                      [ llvm_anyfloat_ty,
927
                                                        llvm_metadata_ty ]>;
928
  def int_experimental_constrained_llround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
929
                                                       [ llvm_anyfloat_ty,
930
                                                         llvm_metadata_ty ]>;
931
  def int_experimental_constrained_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
932
                                                     [ LLVMMatchType<0>,
933
                                                      llvm_metadata_ty ]>;
934
  def int_experimental_constrained_roundeven : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
935
                                                         [ LLVMMatchType<0>,
936
                                                           llvm_metadata_ty ]>;
937
  def int_experimental_constrained_trunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
938
                                                     [ LLVMMatchType<0>,
939
                                                       llvm_metadata_ty ]>;
940
 
941
  // Constrained floating-point comparison (quiet and signaling variants).
942
  // Third operand is the predicate represented as a metadata string.
943
  def int_experimental_constrained_fcmp
944
      : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
945
                  [ llvm_anyfloat_ty, LLVMMatchType<0>,
946
                    llvm_metadata_ty, llvm_metadata_ty ]>;
947
  def int_experimental_constrained_fcmps
948
      : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
949
                  [ llvm_anyfloat_ty, LLVMMatchType<0>,
950
                    llvm_metadata_ty, llvm_metadata_ty ]>;
951
}
952
// FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
953
 
954
 
955
//===------------------------- Expect Intrinsics --------------------------===//
956
//
957
def int_expect : DefaultAttrsIntrinsic<[llvm_anyint_ty],
958
  [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
959
 
960
def int_expect_with_probability : DefaultAttrsIntrinsic<[llvm_anyint_ty],
961
  [LLVMMatchType<0>, LLVMMatchType<0>, llvm_double_ty],
962
  [IntrNoMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
963
 
964
//===-------------------- Bit Manipulation Intrinsics ---------------------===//
965
//
966
 
967
// None of these intrinsics accesses memory at all.
968
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
969
  def int_bswap: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
970
  def int_ctpop: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
971
  def int_bitreverse : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
972
  def int_fshl : DefaultAttrsIntrinsic<[llvm_anyint_ty],
973
      [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
974
  def int_fshr : DefaultAttrsIntrinsic<[llvm_anyint_ty],
975
      [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
976
}
977
 
978
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn,
979
                      ImmArg<ArgIndex<1>>] in {
980
  def int_ctlz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
981
  def int_cttz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
982
}
983
 
984
//===------------------------ Debugger Intrinsics -------------------------===//
985
//
986
 
987
// None of these intrinsics accesses memory at all...but that doesn't
988
// mean the optimizers can change them aggressively.  Special handling
989
// needed in a few places. These synthetic intrinsics have no
990
// side-effects and just mark information about their operands.
991
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
992
  def int_dbg_declare      : DefaultAttrsIntrinsic<[],
993
                                       [llvm_metadata_ty,
994
                                        llvm_metadata_ty,
995
                                        llvm_metadata_ty]>;
996
  def int_dbg_value        : DefaultAttrsIntrinsic<[],
997
                                       [llvm_metadata_ty,
998
                                        llvm_metadata_ty,
999
                                        llvm_metadata_ty]>;
1000
  def int_dbg_addr         : DefaultAttrsIntrinsic<[],
1001
                                       [llvm_metadata_ty,
1002
                                        llvm_metadata_ty,
1003
                                        llvm_metadata_ty]>;
1004
  def int_dbg_assign        : DefaultAttrsIntrinsic<[],
1005
                                       [llvm_metadata_ty,
1006
                                        llvm_metadata_ty,
1007
                                        llvm_metadata_ty,
1008
                                        llvm_metadata_ty,
1009
                                        llvm_metadata_ty,
1010
                                        llvm_metadata_ty]>;
1011
  def int_dbg_label        : DefaultAttrsIntrinsic<[],
1012
                                       [llvm_metadata_ty]>;
1013
}
1014
 
1015
//===------------------ Exception Handling Intrinsics----------------------===//
1016
//
1017
 
1018
// The result of eh.typeid.for depends on the enclosing function, but inside a
1019
// given function it is 'const' and may be CSE'd etc.
1020
def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>;
1021
 
1022
def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
1023
def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
1024
 
1025
// eh.exceptionpointer returns the pointer to the exception caught by
1026
// the given `catchpad`.
1027
def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
1028
                                        [IntrNoMem]>;
1029
 
1030
// Gets the exception code from a catchpad token. Only used on some platforms.
1031
def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
1032
 
1033
// __builtin_unwind_init is an undocumented GCC intrinsic that causes all
1034
// callee-saved registers to be saved and restored (regardless of whether they
1035
// are used) in the calling function. It is used by libgcc_eh.
1036
def int_eh_unwind_init: Intrinsic<[]>,
1037
                        ClangBuiltin<"__builtin_unwind_init">;
1038
 
1039
def int_eh_dwarf_cfa  : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
1040
 
1041
def int_eh_sjlj_lsda             : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1042
def int_eh_sjlj_callsite         : Intrinsic<[], [llvm_i32_ty], [IntrNoMem, ImmArg<ArgIndex<0>>]>;
1043
 
1044
def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
1045
def int_eh_sjlj_setjmp          : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
1046
def int_eh_sjlj_longjmp         : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
1047
def int_eh_sjlj_setup_dispatch  : Intrinsic<[], []>;
1048
 
1049
//===---------------- Generic Variable Attribute Intrinsics----------------===//
1050
//
1051
def int_var_annotation : DefaultAttrsIntrinsic<
1052
    [], [llvm_anyptr_ty, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
1053
    [IntrInaccessibleMemOnly], "llvm.var.annotation">;
1054
 
1055
def int_ptr_annotation : DefaultAttrsIntrinsic<
1056
    [LLVMAnyPointerType<llvm_anyint_ty>],
1057
    [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
1058
    [IntrInaccessibleMemOnly], "llvm.ptr.annotation">;
1059
 
1060
def int_annotation : DefaultAttrsIntrinsic<
1061
    [llvm_anyint_ty],
1062
    [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty],
1063
    [IntrInaccessibleMemOnly], "llvm.annotation">;
1064
 
1065
// Annotates the current program point with metadata strings which are emitted
1066
// as CodeView debug info records. This is expensive, as it disables inlining
1067
// and is modelled as having side effects.
1068
def int_codeview_annotation : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
1069
                                        [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
1070
                                        "llvm.codeview.annotation">;
1071
 
1072
//===------------------------ Trampoline Intrinsics -----------------------===//
1073
//
1074
def int_init_trampoline : DefaultAttrsIntrinsic<
1075
    [], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1076
    [IntrArgMemOnly, NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1077
     ReadNone<ArgIndex<1>>, ReadNone<ArgIndex<2>>]>,
1078
    ClangBuiltin<"__builtin_init_trampoline">;
1079
 
1080
def int_adjust_trampoline : DefaultAttrsIntrinsic<
1081
    [llvm_ptr_ty], [llvm_ptr_ty], [IntrReadMem, IntrArgMemOnly]>,
1082
    ClangBuiltin<"__builtin_adjust_trampoline">;
1083
 
1084
//===------------------------ Overflow Intrinsics -------------------------===//
1085
//
1086
 
1087
// Expose the carry flag from add operations on two integrals.
1088
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1089
  def int_sadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1090
                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1091
                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1092
  def int_uadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1093
                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1094
                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1095
 
1096
  def int_ssub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1097
                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1098
                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1099
  def int_usub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1100
                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1101
                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1102
 
1103
  def int_smul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1104
                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1105
                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1106
  def int_umul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1107
                                          LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1108
                                         [LLVMMatchType<0>, LLVMMatchType<0>]>;
1109
}
1110
//===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
1111
//
1112
def int_sadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1113
                             [LLVMMatchType<0>, LLVMMatchType<0>],
1114
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
1115
def int_uadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1116
                             [LLVMMatchType<0>, LLVMMatchType<0>],
1117
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
1118
def int_ssub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1119
                             [LLVMMatchType<0>, LLVMMatchType<0>],
1120
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1121
def int_usub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1122
                             [LLVMMatchType<0>, LLVMMatchType<0>],
1123
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1124
def int_sshl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1125
                             [LLVMMatchType<0>, LLVMMatchType<0>],
1126
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1127
def int_ushl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1128
                             [LLVMMatchType<0>, LLVMMatchType<0>],
1129
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1130
 
1131
//===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
1132
//
1133
def int_smul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1134
                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1135
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1136
                              Commutative, ImmArg<ArgIndex<2>>]>;
1137
 
1138
def int_umul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1139
                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1140
                             [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1141
                              Commutative, ImmArg<ArgIndex<2>>]>;
1142
 
1143
def int_sdiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1144
                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1145
                             [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1146
 
1147
def int_udiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1148
                             [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1149
                             [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1150
 
1151
//===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
1152
//
1153
def int_smul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1154
                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1155
                                 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1156
                                  Commutative, ImmArg<ArgIndex<2>>]>;
1157
def int_umul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1158
                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1159
                                 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1160
                                  Commutative, ImmArg<ArgIndex<2>>]>;
1161
 
1162
def int_sdiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1163
                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1164
                                 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1165
 
1166
def int_udiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1167
                                 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1168
                                 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1169
 
1170
//===------------------ Integer Min/Max/Abs Intrinsics --------------------===//
1171
//
1172
def int_abs : DefaultAttrsIntrinsic<
1173
    [llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty],
1174
    [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
1175
 
1176
def int_smax : DefaultAttrsIntrinsic<
1177
    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1178
    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1179
def int_smin : DefaultAttrsIntrinsic<
1180
    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1181
    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1182
def int_umax : DefaultAttrsIntrinsic<
1183
    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1184
    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1185
def int_umin : DefaultAttrsIntrinsic<
1186
    [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1187
    [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1188
 
1189
//===------------------------- Memory Use Markers -------------------------===//
1190
//
1191
def int_lifetime_start  : DefaultAttrsIntrinsic<[],
1192
                                    [llvm_i64_ty, llvm_anyptr_ty],
1193
                                    [IntrArgMemOnly, IntrWillReturn,
1194
                                     NoCapture<ArgIndex<1>>,
1195
                                     ImmArg<ArgIndex<0>>]>;
1196
def int_lifetime_end    : DefaultAttrsIntrinsic<[],
1197
                                    [llvm_i64_ty, llvm_anyptr_ty],
1198
                                    [IntrArgMemOnly, IntrWillReturn,
1199
                                     NoCapture<ArgIndex<1>>,
1200
                                     ImmArg<ArgIndex<0>>]>;
1201
def int_invariant_start : DefaultAttrsIntrinsic<[llvm_descriptor_ty],
1202
                                    [llvm_i64_ty, llvm_anyptr_ty],
1203
                                    [IntrArgMemOnly, IntrWillReturn,
1204
                                     NoCapture<ArgIndex<1>>,
1205
                                     ImmArg<ArgIndex<0>>]>;
1206
def int_invariant_end   : DefaultAttrsIntrinsic<[],
1207
                                    [llvm_descriptor_ty, llvm_i64_ty,
1208
                                     llvm_anyptr_ty],
1209
                                    [IntrArgMemOnly, IntrWillReturn,
1210
                                     NoCapture<ArgIndex<2>>,
1211
                                     ImmArg<ArgIndex<1>>]>;
1212
 
1213
// launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
1214
// because it would cause CSE of two barriers with the same argument.
1215
// Inaccessiblememonly says that the barrier doesn't read the argument,
1216
// but it changes state not accessible to this module. This way
1217
// we can DSE through the barrier because it doesn't read the value
1218
// after store. Although the barrier doesn't modify any memory it
1219
// can't be marked as readonly, because it would be possible to
1220
// CSE 2 barriers with store in between.
1221
// The argument also can't be marked with 'returned' attribute, because
1222
// it would remove barrier.
1223
// Note that it is still experimental, which means that its semantics
1224
// might change in the future.
1225
def int_launder_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
1226
                                            [LLVMMatchType<0>],
1227
                                            [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
1228
 
1229
 
1230
def int_strip_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
1231
                                          [LLVMMatchType<0>],
1232
                                          [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
1233
 
1234
//===------------------------ Stackmap Intrinsics -------------------------===//
1235
//
1236
def int_experimental_stackmap : DefaultAttrsIntrinsic<[],
1237
                                  [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
1238
                                  [Throws]>;
1239
def int_experimental_patchpoint_void : Intrinsic<[],
1240
                                                 [llvm_i64_ty, llvm_i32_ty,
1241
                                                  llvm_ptr_ty, llvm_i32_ty,
1242
                                                  llvm_vararg_ty],
1243
                                                  [Throws]>;
1244
def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty],
1245
                                                [llvm_i64_ty, llvm_i32_ty,
1246
                                                 llvm_ptr_ty, llvm_i32_ty,
1247
                                                 llvm_vararg_ty],
1248
                                                 [Throws]>;
1249
 
1250
 
1251
//===------------------------ Garbage Collection Intrinsics ---------------===//
1252
// These are documented in docs/Statepoint.rst
1253
 
1254
def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
1255
                               [llvm_i64_ty, llvm_i32_ty,
1256
                                llvm_anyptr_ty, llvm_i32_ty,
1257
                                llvm_i32_ty, llvm_vararg_ty],
1258
                               [Throws, ImmArg<ArgIndex<0>>,
1259
                                ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<3>>,
1260
                                ImmArg<ArgIndex<4>>]>;
1261
 
1262
def int_experimental_gc_result : DefaultAttrsIntrinsic<
1263
    [llvm_any_ty], [llvm_token_ty], [IntrNoMem]>;
1264
 
1265
def int_experimental_gc_relocate : DefaultAttrsIntrinsic<
1266
    [llvm_any_ty], [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
1267
    [IntrNoMem, ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
1268
 
1269
def int_experimental_gc_get_pointer_base : DefaultAttrsIntrinsic<
1270
    [llvm_anyptr_ty], [llvm_anyptr_ty],
1271
    [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
1272
 
1273
def int_experimental_gc_get_pointer_offset : DefaultAttrsIntrinsic<
1274
    [llvm_i64_ty], [llvm_anyptr_ty],
1275
    [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
1276
 
1277
//===------------------------ Coroutine Intrinsics ---------------===//
1278
// These are documented in docs/Coroutines.rst
1279
 
1280
// Coroutine Structure Intrinsics.
1281
 
1282
def int_coro_id : DefaultAttrsIntrinsic<[llvm_token_ty],
1283
    [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1284
    [IntrArgMemOnly, IntrReadMem, ReadNone<ArgIndex<1>>, ReadOnly<ArgIndex<2>>,
1285
     NoCapture<ArgIndex<2>>]>;
1286
def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
1287
    [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1288
     llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1289
    []>;
1290
def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
1291
    [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1292
     llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1293
    []>;
1294
def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
1295
def int_coro_id_async : Intrinsic<[llvm_token_ty],
1296
  [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty],
1297
  []>;
1298
def int_coro_async_context_alloc : Intrinsic<[llvm_ptr_ty],
1299
    [llvm_ptr_ty, llvm_ptr_ty],
1300
    []>;
1301
def int_coro_async_context_dealloc : Intrinsic<[],
1302
    [llvm_ptr_ty],
1303
    []>;
1304
def int_coro_async_resume : Intrinsic<[llvm_ptr_ty],
1305
    [],
1306
    [IntrNoMerge]>;
1307
def int_coro_async_size_replace : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>;
1308
def int_coro_suspend_async
1309
    : Intrinsic<[llvm_any_ty],
1310
                [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty],
1311
                [IntrNoMerge]>;
1312
def int_coro_prepare_async : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1313
                                       [IntrNoMem]>;
1314
def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1315
                               [WriteOnly<ArgIndex<1>>]>;
1316
 
1317
def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1318
                              [IntrReadMem, IntrArgMemOnly,
1319
                               ReadOnly<ArgIndex<1>>,
1320
                               NoCapture<ArgIndex<1>>]>;
1321
def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty], []>;
1322
def int_coro_end_async
1323
    : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_vararg_ty], []>;
1324
 
1325
def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1326
def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1327
def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1328
def int_coro_align : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1329
 
1330
def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], [IntrNoMerge]>;
1331
def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1332
def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1333
def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1334
                                        [IntrNoMem]>;
1335
def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1336
                                      [llvm_anyint_ty, llvm_i32_ty], []>;
1337
def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1338
def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1339
 
1340
// Coroutine Manipulation Intrinsics.
1341
 
1342
def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1343
def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1344
def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1345
                              [IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
1346
                               NoCapture<ArgIndex<0>>]>;
1347
def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1348
                                 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1349
                                 [IntrNoMem, NoCapture<ArgIndex<0>>]>;
1350
 
1351
// Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1352
 
1353
def int_coro_subfn_addr : DefaultAttrsIntrinsic<
1354
    [llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1355
    [IntrReadMem, IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
1356
     NoCapture<ArgIndex<0>>]>;
1357
 
1358
///===-------------------------- Other Intrinsics --------------------------===//
1359
//
1360
def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
1361
               ClangBuiltin<"__builtin_trap">;
1362
def int_debugtrap : Intrinsic<[]>,
1363
                    ClangBuiltin<"__builtin_debugtrap">;
1364
def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],
1365
                              [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>;
1366
 
1367
// Support for dynamic deoptimization (or de-specialization)
1368
def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1369
                                            [Throws]>;
1370
 
1371
// Support for speculative runtime guards
1372
def int_experimental_guard : DefaultAttrsIntrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1373
                                       [Throws]>;
1374
 
1375
// Supports widenable conditions for guards represented as explicit branches.
1376
def int_experimental_widenable_condition : DefaultAttrsIntrinsic<[llvm_i1_ty], [],
1377
        [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable]>;
1378
 
1379
// NOP: calls/invokes to this intrinsic are removed by codegen
1380
def int_donothing : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1381
 
1382
// This instruction has no actual effect, though it is treated by the optimizer
1383
// has having opaque side effects. This may be inserted into loops to ensure
1384
// that they are not removed even if they turn out to be empty, for languages
1385
// which specify that infinite loops must be preserved.
1386
def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1387
 
1388
// The pseudoprobe intrinsic works as a place holder to the block it probes.
1389
// Like the sideeffect intrinsic defined above, this intrinsic is treated by the
1390
// optimizer as having opaque side effects so that it won't be get rid of or moved
1391
// out of the block it probes.
1392
def int_pseudoprobe : DefaultAttrsIntrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
1393
                                    [IntrInaccessibleMemOnly, IntrWillReturn]>;
1394
 
1395
// Intrinsics to support half precision floating point format
1396
let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1397
def int_convert_to_fp16   : DefaultAttrsIntrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1398
def int_convert_from_fp16 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1399
}
1400
 
1401
// Saturating floating point to integer intrinsics
1402
let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1403
def int_fptoui_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1404
def int_fptosi_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1405
}
1406
 
1407
// Clear cache intrinsic, default to ignore (ie. emit nothing)
1408
// maps to void __clear_cache() on supporting platforms
1409
def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1410
                                [], "llvm.clear_cache">;
1411
 
1412
// Intrinsic to detect whether its argument is a constant.
1413
def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty],
1414
                                [IntrNoMem, IntrWillReturn, IntrConvergent],
1415
                                "llvm.is.constant">;
1416
 
1417
// Intrinsic to mask out bits of a pointer.
1418
def int_ptrmask: DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>, llvm_anyint_ty],
1419
                           [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1420
 
1421
// Intrinsic to wrap a thread local variable.
1422
def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>],
1423
                                                    [NonNull<RetIndex>, NonNull<ArgIndex<0>>,
1424
                                                     IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1425
 
1426
def int_experimental_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1427
                                                        [], [IntrNoMem]>;
1428
 
1429
//===---------------- Vector Predication Intrinsics --------------===//
1430
// Memory Intrinsics
1431
def int_vp_store : DefaultAttrsIntrinsic<[],
1432
                             [ llvm_anyvector_ty,
1433
                               LLVMAnyPointerType<LLVMMatchType<0>>,
1434
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1435
                               llvm_i32_ty],
1436
                             [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
1437
 
1438
def int_vp_load  : DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
1439
                             [ LLVMAnyPointerType<LLVMMatchType<0>>,
1440
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1441
                               llvm_i32_ty],
1442
                             [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
1443
 
1444
def int_vp_gather: DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
1445
                             [ LLVMVectorOfAnyPointersToElt<0>,
1446
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1447
                               llvm_i32_ty],
1448
                             [ IntrReadMem, IntrNoSync, IntrWillReturn]>;
1449
 
1450
def int_vp_scatter: DefaultAttrsIntrinsic<[],
1451
                             [ llvm_anyvector_ty,
1452
                               LLVMVectorOfAnyPointersToElt<0>,
1453
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1454
                               llvm_i32_ty],
1455
                             [ IntrNoSync, IntrWillReturn ]>; // TODO allow IntrNoCapture for vectors of pointers
1456
 
1457
// Experimental strided memory accesses
1458
def int_experimental_vp_strided_store : DefaultAttrsIntrinsic<[],
1459
                             [ llvm_anyvector_ty,
1460
                               LLVMAnyPointerToElt<0>,
1461
                               llvm_anyint_ty, // Stride in bytes
1462
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1463
                               llvm_i32_ty],
1464
                             [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
1465
 
1466
def int_experimental_vp_strided_load  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1467
                             [ LLVMAnyPointerToElt<0>,
1468
                               llvm_anyint_ty, // Stride in bytes
1469
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1470
                               llvm_i32_ty],
1471
                             [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
1472
 
1473
// Operators
1474
let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn] in {
1475
  // Integer arithmetic
1476
  def int_vp_add : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1477
                             [ LLVMMatchType<0>,
1478
                               LLVMMatchType<0>,
1479
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1480
                               llvm_i32_ty]>;
1481
  def int_vp_sub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1482
                             [ LLVMMatchType<0>,
1483
                               LLVMMatchType<0>,
1484
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1485
                               llvm_i32_ty]>;
1486
  def int_vp_mul  : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1487
                             [ LLVMMatchType<0>,
1488
                               LLVMMatchType<0>,
1489
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1490
                               llvm_i32_ty]>;
1491
  def int_vp_ashr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1492
                             [ LLVMMatchType<0>,
1493
                               LLVMMatchType<0>,
1494
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1495
                               llvm_i32_ty]>;
1496
  def int_vp_lshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1497
                             [ LLVMMatchType<0>,
1498
                               LLVMMatchType<0>,
1499
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1500
                               llvm_i32_ty]>;
1501
  def int_vp_shl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1502
                             [ LLVMMatchType<0>,
1503
                               LLVMMatchType<0>,
1504
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1505
                               llvm_i32_ty]>;
1506
  def int_vp_or : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1507
                             [ LLVMMatchType<0>,
1508
                               LLVMMatchType<0>,
1509
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1510
                               llvm_i32_ty]>;
1511
  def int_vp_and : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1512
                             [ LLVMMatchType<0>,
1513
                               LLVMMatchType<0>,
1514
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1515
                               llvm_i32_ty]>;
1516
  def int_vp_xor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1517
                             [ LLVMMatchType<0>,
1518
                               LLVMMatchType<0>,
1519
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1520
                               llvm_i32_ty]>;
1521
  def int_vp_sdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1522
                             [ LLVMMatchType<0>,
1523
                               LLVMMatchType<0>,
1524
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1525
                               llvm_i32_ty]>;
1526
  def int_vp_udiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1527
                             [ LLVMMatchType<0>,
1528
                               LLVMMatchType<0>,
1529
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1530
                               llvm_i32_ty]>;
1531
  def int_vp_srem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1532
                             [ LLVMMatchType<0>,
1533
                               LLVMMatchType<0>,
1534
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1535
                               llvm_i32_ty]>;
1536
  def int_vp_urem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1537
                             [ LLVMMatchType<0>,
1538
                               LLVMMatchType<0>,
1539
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1540
                               llvm_i32_ty]>;
1541
  def int_vp_abs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1542
                             [ LLVMMatchType<0>,
1543
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1544
                               llvm_i32_ty,
1545
                               llvm_i1_ty]>;
1546
  def int_vp_smin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1547
                             [ LLVMMatchType<0>,
1548
                               LLVMMatchType<0>,
1549
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1550
                               llvm_i32_ty]>;
1551
  def int_vp_smax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1552
                             [ LLVMMatchType<0>,
1553
                               LLVMMatchType<0>,
1554
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1555
                               llvm_i32_ty]>;
1556
  def int_vp_umin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1557
                             [ LLVMMatchType<0>,
1558
                               LLVMMatchType<0>,
1559
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1560
                               llvm_i32_ty]>;
1561
  def int_vp_umax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1562
                             [ LLVMMatchType<0>,
1563
                               LLVMMatchType<0>,
1564
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1565
                               llvm_i32_ty]>;
1566
  def int_vp_bswap : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1567
                             [ LLVMMatchType<0>,
1568
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1569
                               llvm_i32_ty]>;
1570
  def int_vp_bitreverse : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1571
                             [ LLVMMatchType<0>,
1572
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1573
                               llvm_i32_ty]>;
1574
  def int_vp_ctpop : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1575
                             [ LLVMMatchType<0>,
1576
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1577
                               llvm_i32_ty]>;
1578
  def int_vp_fshl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1579
                             [ LLVMMatchType<0>,
1580
                               LLVMMatchType<0>,
1581
                               LLVMMatchType<0>,
1582
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1583
                               llvm_i32_ty]>;
1584
  def int_vp_fshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1585
                             [ LLVMMatchType<0>,
1586
                               LLVMMatchType<0>,
1587
                               LLVMMatchType<0>,
1588
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1589
                               llvm_i32_ty]>;
1590
 
1591
  // Floating-point arithmetic
1592
  def int_vp_fadd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1593
                             [ LLVMMatchType<0>,
1594
                               LLVMMatchType<0>,
1595
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1596
                               llvm_i32_ty]>;
1597
  def int_vp_fsub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1598
                             [ LLVMMatchType<0>,
1599
                               LLVMMatchType<0>,
1600
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1601
                               llvm_i32_ty]>;
1602
  def int_vp_fmul  : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1603
                             [ LLVMMatchType<0>,
1604
                               LLVMMatchType<0>,
1605
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1606
                               llvm_i32_ty]>;
1607
  def int_vp_fdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1608
                             [ LLVMMatchType<0>,
1609
                               LLVMMatchType<0>,
1610
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1611
                               llvm_i32_ty]>;
1612
  def int_vp_frem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1613
                             [ LLVMMatchType<0>,
1614
                               LLVMMatchType<0>,
1615
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1616
                               llvm_i32_ty]>;
1617
  def int_vp_fneg : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1618
                             [ LLVMMatchType<0>,
1619
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1620
                               llvm_i32_ty]>;
1621
  def int_vp_fabs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1622
                             [ LLVMMatchType<0>,
1623
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1624
                               llvm_i32_ty]>;
1625
  def int_vp_sqrt : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1626
                             [ LLVMMatchType<0>,
1627
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1628
                               llvm_i32_ty]>;
1629
  def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1630
                             [ LLVMMatchType<0>,
1631
                               LLVMMatchType<0>,
1632
                               LLVMMatchType<0>,
1633
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1634
                               llvm_i32_ty]>;
1635
  def int_vp_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1636
                             [ LLVMMatchType<0>,
1637
                               LLVMMatchType<0>,
1638
                               LLVMMatchType<0>,
1639
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1640
                               llvm_i32_ty]>;
1641
  def int_vp_minnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1642
                             [ LLVMMatchType<0>,
1643
                               LLVMMatchType<0>,
1644
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1645
                               llvm_i32_ty]>;
1646
  def int_vp_maxnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1647
                             [ LLVMMatchType<0>,
1648
                               LLVMMatchType<0>,
1649
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1650
                               llvm_i32_ty]>;
1651
  def int_vp_copysign : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1652
                             [ LLVMMatchType<0>,
1653
                               LLVMMatchType<0>,
1654
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1655
                               llvm_i32_ty]>;
1656
  def int_vp_ceil : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1657
                             [ LLVMMatchType<0>,
1658
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1659
                               llvm_i32_ty]>;
1660
  def int_vp_floor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1661
                             [ LLVMMatchType<0>,
1662
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1663
                               llvm_i32_ty]>;
1664
  def int_vp_round : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1665
                             [ LLVMMatchType<0>,
1666
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1667
                               llvm_i32_ty]>;
1668
  def int_vp_roundeven : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1669
                             [ LLVMMatchType<0>,
1670
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1671
                               llvm_i32_ty]>;
1672
  def int_vp_roundtozero : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1673
                             [ LLVMMatchType<0>,
1674
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1675
                               llvm_i32_ty]>;
1676
  def int_vp_rint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1677
                             [ LLVMMatchType<0>,
1678
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1679
                               llvm_i32_ty]>;
1680
  def int_vp_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1681
                             [ LLVMMatchType<0>,
1682
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1683
                               llvm_i32_ty]>;
1684
 
1685
  // Casts
1686
  def int_vp_trunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1687
                             [ llvm_anyvector_ty,
1688
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1689
                               llvm_i32_ty]>;
1690
  def int_vp_zext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1691
                             [ llvm_anyvector_ty,
1692
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1693
                               llvm_i32_ty]>;
1694
  def int_vp_sext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1695
                             [ llvm_anyvector_ty,
1696
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1697
                               llvm_i32_ty]>;
1698
  def int_vp_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1699
                             [ llvm_anyvector_ty,
1700
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1701
                               llvm_i32_ty]>;
1702
  def int_vp_fpext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1703
                             [ llvm_anyvector_ty,
1704
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1705
                               llvm_i32_ty]>;
1706
  def int_vp_fptoui : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1707
                             [ llvm_anyvector_ty,
1708
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1709
                               llvm_i32_ty]>;
1710
  def int_vp_fptosi : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1711
                             [ llvm_anyvector_ty,
1712
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1713
                               llvm_i32_ty]>;
1714
  def int_vp_uitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1715
                             [ llvm_anyvector_ty,
1716
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1717
                               llvm_i32_ty]>;
1718
  def int_vp_sitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1719
                             [ llvm_anyvector_ty,
1720
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1721
                               llvm_i32_ty]>;
1722
  def int_vp_ptrtoint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1723
                             [ llvm_anyvector_ty,
1724
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1725
                               llvm_i32_ty]>;
1726
  def int_vp_inttoptr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1727
                             [ llvm_anyvector_ty,
1728
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1729
                               llvm_i32_ty]>;
1730
  // Shuffles
1731
  def int_vp_select : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1732
                             [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1733
                               LLVMMatchType<0>,
1734
                               LLVMMatchType<0>,
1735
                               llvm_i32_ty]>;
1736
  def int_vp_merge : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1737
                             [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1738
                               LLVMMatchType<0>,
1739
                               LLVMMatchType<0>,
1740
                               llvm_i32_ty]>;
1741
 
1742
  // Comparisons
1743
  def int_vp_fcmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1744
                             [ llvm_anyvector_ty,
1745
                               LLVMMatchType<0>,
1746
                               llvm_metadata_ty,
1747
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1748
                               llvm_i32_ty]>;
1749
  def int_vp_icmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1750
                             [ llvm_anyvector_ty,
1751
                               LLVMMatchType<0>,
1752
                               llvm_metadata_ty,
1753
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1754
                               llvm_i32_ty]>;
1755
 
1756
  // Reductions
1757
  def int_vp_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1758
                             [ LLVMVectorElementType<0>,
1759
                               llvm_anyvector_ty,
1760
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1761
                               llvm_i32_ty]>;
1762
  def int_vp_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1763
                             [ LLVMVectorElementType<0>,
1764
                               llvm_anyvector_ty,
1765
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1766
                               llvm_i32_ty]>;
1767
  def int_vp_reduce_add  : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1768
                             [ LLVMVectorElementType<0>,
1769
                               llvm_anyvector_ty,
1770
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1771
                               llvm_i32_ty]>;
1772
  def int_vp_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1773
                             [ LLVMVectorElementType<0>,
1774
                               llvm_anyvector_ty,
1775
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1776
                               llvm_i32_ty]>;
1777
  def int_vp_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1778
                             [ LLVMVectorElementType<0>,
1779
                               llvm_anyvector_ty,
1780
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1781
                               llvm_i32_ty]>;
1782
  def int_vp_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1783
                             [ LLVMVectorElementType<0>,
1784
                               llvm_anyvector_ty,
1785
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1786
                               llvm_i32_ty]>;
1787
  def int_vp_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1788
                             [ LLVMVectorElementType<0>,
1789
                               llvm_anyvector_ty,
1790
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1791
                               llvm_i32_ty]>;
1792
  def int_vp_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1793
                             [ LLVMVectorElementType<0>,
1794
                               llvm_anyvector_ty,
1795
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1796
                               llvm_i32_ty]>;
1797
  def int_vp_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1798
                             [ LLVMVectorElementType<0>,
1799
                               llvm_anyvector_ty,
1800
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1801
                               llvm_i32_ty]>;
1802
  def int_vp_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1803
                             [ LLVMVectorElementType<0>,
1804
                               llvm_anyvector_ty,
1805
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1806
                               llvm_i32_ty]>;
1807
  def int_vp_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1808
                             [ LLVMVectorElementType<0>,
1809
                               llvm_anyvector_ty,
1810
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1811
                               llvm_i32_ty]>;
1812
  def int_vp_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1813
                             [ LLVMVectorElementType<0>,
1814
                               llvm_anyvector_ty,
1815
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1816
                               llvm_i32_ty]>;
1817
  def int_vp_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1818
                             [ LLVMVectorElementType<0>,
1819
                               llvm_anyvector_ty,
1820
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1821
                               llvm_i32_ty]>;
1822
}
1823
 
1824
let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<3>>] in {
1825
  def int_vp_ctlz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1826
                             [ LLVMMatchType<0>,
1827
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1828
                               llvm_i32_ty,
1829
                               llvm_i1_ty]>;
1830
  def int_vp_cttz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1831
                             [ LLVMMatchType<0>,
1832
                               LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1833
                               llvm_i32_ty,
1834
                               llvm_i1_ty]>;
1835
}
1836
 
1837
def int_get_active_lane_mask:
1838
  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1839
            [llvm_anyint_ty, LLVMMatchType<1>],
1840
            [IntrNoMem, IntrNoSync, IntrWillReturn]>;
1841
 
1842
def int_experimental_vp_splice:
1843
  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1844
            [LLVMMatchType<0>,
1845
             LLVMMatchType<0>,
1846
             llvm_i32_ty,
1847
             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1848
             llvm_i32_ty, llvm_i32_ty],
1849
            [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1850
 
1851
//===-------------------------- Masked Intrinsics -------------------------===//
1852
//
1853
def int_masked_load:
1854
  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1855
            [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
1856
             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1857
            [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<ArgIndex<1>>,
1858
             NoCapture<ArgIndex<0>>]>;
1859
 
1860
def int_masked_store:
1861
  DefaultAttrsIntrinsic<[],
1862
            [llvm_anyvector_ty, LLVMAnyPointerType<LLVMMatchType<0>>,
1863
             llvm_i32_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1864
            [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
1865
             ImmArg<ArgIndex<2>>, NoCapture<ArgIndex<1>>]>;
1866
 
1867
def int_masked_gather:
1868
  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1869
            [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1870
             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
1871
            [IntrReadMem, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
1872
 
1873
def int_masked_scatter:
1874
  DefaultAttrsIntrinsic<[],
1875
            [llvm_anyvector_ty, LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
1876
             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1877
            [IntrWriteMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
1878
 
1879
def int_masked_expandload:
1880
  DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1881
            [LLVMPointerToElt<0>, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1882
             LLVMMatchType<0>],
1883
            [IntrReadMem, IntrWillReturn, NoCapture<ArgIndex<0>>]>;
1884
 
1885
def int_masked_compressstore:
1886
  DefaultAttrsIntrinsic<[],
1887
            [llvm_anyvector_ty, LLVMPointerToElt<0>,
1888
             LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1889
            [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
1890
             NoCapture<ArgIndex<1>>]>;
1891
 
1892
// Test whether a pointer is associated with a type metadata identifier.
1893
def int_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1894
                              [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
1895
 
1896
// Safely loads a function pointer from a virtual table pointer using type metadata.
1897
def int_type_checked_load : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty],
1898
                                      [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
1899
                                      [IntrNoMem, IntrWillReturn]>;
1900
 
1901
// Test whether a pointer is associated with a type metadata identifier. Used
1902
// for public visibility classes that may later be refined to private
1903
// visibility.
1904
def int_public_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
1905
                              [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
1906
 
1907
// Create a branch funnel that implements an indirect call to a limited set of
1908
// callees. This needs to be a musttail call.
1909
def int_icall_branch_funnel : DefaultAttrsIntrinsic<[], [llvm_vararg_ty], []>;
1910
 
1911
def int_load_relative: DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
1912
                                 [IntrReadMem, IntrArgMemOnly]>;
1913
 
1914
def int_asan_check_memaccess :
1915
  Intrinsic<[],[llvm_ptr_ty, llvm_i32_ty], [ImmArg<ArgIndex<1>>]>;
1916
 
1917
def int_hwasan_check_memaccess :
1918
  Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
1919
            [ImmArg<ArgIndex<2>>]>;
1920
def int_hwasan_check_memaccess_shortgranules :
1921
  Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
1922
            [ImmArg<ArgIndex<2>>]>;
1923
 
1924
// Xray intrinsics
1925
//===----------------------------------------------------------------------===//
1926
// Custom event logging for x-ray.
1927
// Takes a pointer to a string and the length of the string.
1928
def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
1929
                                     [IntrWriteMem, NoCapture<ArgIndex<0>>,
1930
                                      ReadOnly<ArgIndex<0>>]>;
1931
// Typed event logging for x-ray.
1932
// Takes a numeric type tag, a pointer to a string and the length of the string.
1933
def int_xray_typedevent : Intrinsic<[], [llvm_i16_ty, llvm_ptr_ty, llvm_i32_ty],
1934
                                        [IntrWriteMem, NoCapture<ArgIndex<1>>,
1935
                                         ReadOnly<ArgIndex<1>>]>;
1936
//===----------------------------------------------------------------------===//
1937
 
1938
//===------ Memory intrinsics with element-wise atomicity guarantees ------===//
1939
//
1940
 
1941
// @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
1942
def int_memcpy_element_unordered_atomic
1943
    : Intrinsic<[],
1944
                [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
1945
                [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
1946
                 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
1947
                 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
1948
                 ImmArg<ArgIndex<3>>]>;
1949
 
1950
// @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
1951
def int_memmove_element_unordered_atomic
1952
    : Intrinsic<[],
1953
                [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
1954
                [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
1955
                 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
1956
                 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
1957
                 ImmArg<ArgIndex<3>>]>;
1958
 
1959
// @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
1960
def int_memset_element_unordered_atomic
1961
    : Intrinsic<[], [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty],
1962
                [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoSync,
1963
                 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1964
                 ImmArg<ArgIndex<3>>]>;
1965
 
1966
//===------------------------ Reduction Intrinsics ------------------------===//
1967
//
1968
let IntrProperties = [IntrNoMem] in {
1969
 
1970
  def int_vector_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1971
                                         [LLVMVectorElementType<0>,
1972
                                          llvm_anyvector_ty]>;
1973
  def int_vector_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1974
                                         [LLVMVectorElementType<0>,
1975
                                          llvm_anyvector_ty]>;
1976
  def int_vector_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1977
                                        [llvm_anyvector_ty]>;
1978
  def int_vector_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1979
                                        [llvm_anyvector_ty]>;
1980
  def int_vector_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1981
                                        [llvm_anyvector_ty]>;
1982
  def int_vector_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1983
                                       [llvm_anyvector_ty]>;
1984
  def int_vector_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1985
                                        [llvm_anyvector_ty]>;
1986
  def int_vector_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1987
                                         [llvm_anyvector_ty]>;
1988
  def int_vector_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1989
                                         [llvm_anyvector_ty]>;
1990
  def int_vector_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1991
                                         [llvm_anyvector_ty]>;
1992
  def int_vector_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1993
                                         [llvm_anyvector_ty]>;
1994
  def int_vector_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1995
                                         [llvm_anyvector_ty]>;
1996
  def int_vector_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1997
                                         [llvm_anyvector_ty]>;
1998
}
1999
 
2000
//===----- Matrix intrinsics ---------------------------------------------===//
2001
 
2002
def int_matrix_transpose
2003
  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2004
              [LLVMMatchType<0>, llvm_i32_ty, llvm_i32_ty],
2005
              [ IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>,
2006
               ImmArg<ArgIndex<2>>]>;
2007
 
2008
def int_matrix_multiply
2009
  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2010
              [llvm_anyvector_ty, llvm_anyvector_ty, llvm_i32_ty, llvm_i32_ty,
2011
               llvm_i32_ty],
2012
              [IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>,
2013
               ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>]>;
2014
 
2015
def int_matrix_column_major_load
2016
  : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2017
              [LLVMPointerToElt<0>, llvm_anyint_ty, llvm_i1_ty,
2018
               llvm_i32_ty, llvm_i32_ty],
2019
              [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrReadMem,
2020
               NoCapture<ArgIndex<0>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>,
2021
               ImmArg<ArgIndex<4>>]>;
2022
 
2023
def int_matrix_column_major_store
2024
  : DefaultAttrsIntrinsic<[],
2025
              [llvm_anyvector_ty, LLVMPointerToElt<0>,
2026
               llvm_anyint_ty, llvm_i1_ty, llvm_i32_ty, llvm_i32_ty],
2027
              [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrWriteMem,
2028
               WriteOnly<ArgIndex<1>>, NoCapture<ArgIndex<1>>,
2029
               ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>, ImmArg<ArgIndex<5>>]>;
2030
 
2031
//===---------- Intrinsics to control hardware supported loops ----------===//
2032
 
2033
// Specify that the value given is the number of iterations that the next loop
2034
// will execute.
2035
def int_set_loop_iterations :
2036
  DefaultAttrsIntrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
2037
 
2038
// Same as the above, but produces a value (the same as the input operand) to
2039
// be fed into the loop.
2040
def int_start_loop_iterations :
2041
  DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], [IntrNoDuplicate]>;
2042
 
2043
// Specify that the value given is the number of iterations that the next loop
2044
// will execute. Also test that the given count is not zero, allowing it to
2045
// control entry to a 'while' loop.
2046
def int_test_set_loop_iterations :
2047
  DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
2048
 
2049
// Same as the above, but produces an extra value (the same as the input
2050
// operand) to be fed into the loop.
2051
def int_test_start_loop_iterations :
2052
  DefaultAttrsIntrinsic<[llvm_anyint_ty, llvm_i1_ty], [LLVMMatchType<0>],
2053
                        [IntrNoDuplicate]>;
2054
 
2055
// Decrement loop counter by the given argument. Return false if the loop
2056
// should exit.
2057
def int_loop_decrement :
2058
  DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
2059
 
2060
// Decrement the first operand (the loop counter) by the second operand (the
2061
// maximum number of elements processed in an iteration). Return the remaining
2062
// number of iterations still to be executed. This is effectively a sub which
2063
// can be used with a phi, icmp and br to control the number of iterations
2064
// executed, as usual. Any optimisations are allowed to treat it is a sub, and
2065
// it's scevable, so it's the backends responsibility to handle cases where it
2066
// may be optimised.
2067
def int_loop_decrement_reg :
2068
  DefaultAttrsIntrinsic<[llvm_anyint_ty],
2069
            [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoDuplicate]>;
2070
 
2071
//===----- Intrinsics that are used to provide predicate information -----===//
2072
 
2073
def int_ssa_copy : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>],
2074
                             [IntrNoMem, Returned<ArgIndex<0>>]>;
2075
 
2076
//===------- Intrinsics that are used to preserve debug information -------===//
2077
 
2078
def int_preserve_array_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2079
                                                [llvm_anyptr_ty, llvm_i32_ty,
2080
                                                 llvm_i32_ty],
2081
                                                [IntrNoMem,
2082
                                                 ImmArg<ArgIndex<1>>,
2083
                                                 ImmArg<ArgIndex<2>>]>;
2084
def int_preserve_union_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2085
                                                [llvm_anyptr_ty, llvm_i32_ty],
2086
                                                [IntrNoMem,
2087
                                                 ImmArg<ArgIndex<1>>]>;
2088
def int_preserve_struct_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2089
                                                 [llvm_anyptr_ty, llvm_i32_ty,
2090
                                                  llvm_i32_ty],
2091
                                                 [IntrNoMem,
2092
                                                  ImmArg<ArgIndex<1>>,
2093
                                                  ImmArg<ArgIndex<2>>]>;
2094
 
2095
//===------------ Intrinsics to perform common vector shuffles ------------===//
2096
 
2097
def int_experimental_vector_reverse : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2098
                                                            [LLVMMatchType<0>],
2099
                                                            [IntrNoMem]>;
2100
 
2101
def int_experimental_vector_splice : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2102
                                                           [LLVMMatchType<0>,
2103
                                                            LLVMMatchType<0>,
2104
                                                            llvm_i32_ty],
2105
                                                           [IntrNoMem, ImmArg<ArgIndex<2>>]>;
2106
 
2107
//===---------- Intrinsics to query properties of scalable vectors --------===//
2108
def int_vscale : DefaultAttrsIntrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
2109
 
2110
//===---------- Intrinsics to perform subvector insertion/extraction ------===//
2111
def int_vector_insert : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2112
                                              [LLVMMatchType<0>, llvm_anyvector_ty, llvm_i64_ty],
2113
                                              [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>]>;
2114
 
2115
def int_vector_extract : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2116
                                               [llvm_anyvector_ty, llvm_i64_ty],
2117
                                               [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
2118
 
2119
//===----------------- Pointer Authentication Intrinsics ------------------===//
2120
//
2121
 
2122
// Sign an unauthenticated pointer using the specified key and discriminator,
2123
// passed in that order.
2124
// Returns the first argument, with some known bits replaced with a signature.
2125
def int_ptrauth_sign :
2126
  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
2127
                        [IntrNoMem, ImmArg<ArgIndex<1>>]>;
2128
 
2129
// Authenticate a signed pointer, using the specified key and discriminator.
2130
// Returns the first argument, with the signature bits removed.
2131
// The signature must be valid.
2132
def int_ptrauth_auth : Intrinsic<[llvm_i64_ty],
2133
                                 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
2134
                                 [IntrNoMem,ImmArg<ArgIndex<1>>]>;
2135
 
2136
// Authenticate a signed pointer and resign it.
2137
// The second (key) and third (discriminator) arguments specify the signing
2138
// schema used for authenticating.
2139
// The fourth and fifth arguments specify the schema used for signing.
2140
// The signature must be valid.
2141
// This is a combined form of @llvm.ptrauth.sign and @llvm.ptrauth.auth, with
2142
// an additional integrity guarantee on the intermediate value.
2143
def int_ptrauth_resign : Intrinsic<[llvm_i64_ty],
2144
                                   [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty,
2145
                                    llvm_i32_ty, llvm_i64_ty],
2146
                                   [IntrNoMem, ImmArg<ArgIndex<1>>,
2147
                                    ImmArg<ArgIndex<3>>]>;
2148
 
2149
// Strip the embedded signature out of a signed pointer.
2150
// The second argument specifies the key.
2151
// This behaves like @llvm.ptrauth.auth, but doesn't require the signature to
2152
// be valid.
2153
def int_ptrauth_strip :
2154
  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty],
2155
                        [IntrNoMem, ImmArg<ArgIndex<1>>]>;
2156
 
2157
// Blend a small integer discriminator with an address discriminator, producing
2158
// a new discriminator value.
2159
def int_ptrauth_blend :
2160
  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2161
 
2162
// Compute the signature of a value, using a given discriminator.
2163
// This differs from @llvm.ptrauth.sign in that it doesn't embed the computed
2164
// signature in the pointer, but instead returns the signature as a value.
2165
// That allows it to be used to sign non-pointer data: in that sense, it is
2166
// generic.  There is no generic @llvm.ptrauth.auth: instead, the signature
2167
// can be computed using @llvm.ptrauth.sign_generic, and compared with icmp.
2168
def int_ptrauth_sign_generic :
2169
  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2170
 
2171
//===----------------------------------------------------------------------===//
2172
 
2173
//===----------------------------------------------------------------------===//
2174
// Target-specific intrinsics
2175
//===----------------------------------------------------------------------===//
2176
 
2177
include "llvm/IR/IntrinsicsPowerPC.td"
2178
include "llvm/IR/IntrinsicsX86.td"
2179
include "llvm/IR/IntrinsicsARM.td"
2180
include "llvm/IR/IntrinsicsAArch64.td"
2181
include "llvm/IR/IntrinsicsXCore.td"
2182
include "llvm/IR/IntrinsicsHexagon.td"
2183
include "llvm/IR/IntrinsicsNVVM.td"
2184
include "llvm/IR/IntrinsicsMips.td"
2185
include "llvm/IR/IntrinsicsAMDGPU.td"
2186
include "llvm/IR/IntrinsicsBPF.td"
2187
include "llvm/IR/IntrinsicsSystemZ.td"
2188
include "llvm/IR/IntrinsicsWebAssembly.td"
2189
include "llvm/IR/IntrinsicsRISCV.td"
2190
include "llvm/IR/IntrinsicsSPIRV.td"
2191
include "llvm/IR/IntrinsicsVE.td"
2192
include "llvm/IR/IntrinsicsDirectX.td"
2193
include "llvm/IR/IntrinsicsLoongArch.td"