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