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