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