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