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