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