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