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