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