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 87// NonNull - The specified argument is not null. 88class NonNull<AttrIndex idx> : IntrinsicProperty { 89 int ArgNo = idx.Value; 90} 91 92class Align<AttrIndex idx, int align> : IntrinsicProperty { 93 int ArgNo = idx.Value; 94 int Align = align; 95} 96 97class Dereferenceable<AttrIndex idx, int bytes> : IntrinsicProperty { 98 int ArgNo = idx.Value; 99 int Bytes = bytes; 100} 101 102// Returned - The specified argument is always the return value of the 103// intrinsic. 104class Returned<AttrIndex idx> : IntrinsicProperty { 105 int ArgNo = idx.Value; 106} 107 108// ImmArg - The specified argument must be an immediate. 109class ImmArg<AttrIndex idx> : IntrinsicProperty { 110 int ArgNo = idx.Value; 111} 112 113// ReadOnly - The specified argument pointer is not written to through the 114// pointer by the intrinsic. 115class ReadOnly<AttrIndex idx> : IntrinsicProperty { 116 int ArgNo = idx.Value; 117} 118 119// WriteOnly - The intrinsic does not read memory through the specified 120// argument pointer. 121class WriteOnly<AttrIndex idx> : IntrinsicProperty { 122 int ArgNo = idx.Value; 123} 124 125// ReadNone - The specified argument pointer is not dereferenced by the 126// intrinsic. 127class ReadNone<AttrIndex idx> : IntrinsicProperty { 128 int ArgNo = idx.Value; 129} 130 131def IntrNoReturn : IntrinsicProperty; 132 133// Applied by default. 134def IntrNoCallback : IntrinsicProperty<1>; 135 136// IntrNoSync - Threads executing the intrinsic will not synchronize using 137// memory or other means. Applied by default. 138def IntrNoSync : IntrinsicProperty<1>; 139 140// Applied by default. 141def IntrNoFree : IntrinsicProperty<1>; 142 143// Applied by default. 144def IntrWillReturn : IntrinsicProperty<1>; 145 146// IntrCold - Calls to this intrinsic are cold. 147// Parallels the cold attribute on LLVM IR functions. 148def IntrCold : IntrinsicProperty; 149 150// IntrNoDuplicate - Calls to this intrinsic cannot be duplicated. 151// Parallels the noduplicate attribute on LLVM IR functions. 152def IntrNoDuplicate : IntrinsicProperty; 153 154// IntrNoMerge - Calls to this intrinsic cannot be merged 155// Parallels the nomerge attribute on LLVM IR functions. 156def IntrNoMerge : IntrinsicProperty; 157 158// IntrConvergent - Calls to this intrinsic are convergent and may not be made 159// control-dependent on any additional values. 160// Parallels the convergent attribute on LLVM IR functions. 161def IntrConvergent : IntrinsicProperty; 162 163// This property indicates that the intrinsic is safe to speculate. 164def IntrSpeculatable : IntrinsicProperty; 165 166// This property can be used to override the 'has no other side effects' 167// language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly 168// intrinsic properties. By default, intrinsics are assumed to have side 169// effects, so this property is only necessary if you have defined one of 170// the memory properties listed above. 171// For this property, 'side effects' has the same meaning as 'side effects' 172// defined by the hasSideEffects property of the TableGen Instruction class. 173def IntrHasSideEffects : IntrinsicProperty; 174 175//===----------------------------------------------------------------------===// 176// IIT constants and utils 177//===----------------------------------------------------------------------===// 178 179// llvm::Intrinsic::IITDescriptor::ArgKind::AK_% 180def ArgKind { 181 int Any = 0; 182 int AnyInteger = 1; 183 int AnyFloat = 2; 184 int AnyVector = 3; 185 int AnyPointer = 4; 186 187 int MatchType = 7; 188} 189 190// Encode placeholder. 191// [15:8] is the ID used how to resolve ArgCode. 192 193// (ACIdx << 3) | ArgCode 194class EncAnyType<int ArgCode=0> { 195 int ID = 0x100; 196 int ret = !or(ID, ArgCode); 197} 198 199// (Mapping[Num] << 3) | AK.MatchType 200class EncMatchType<int Num=0> { 201 int ID = 0x200; 202 int ret = !or(ID, Num); 203} 204 205// (Mapping[Num] << 3) | ArgCodes[Mapping[Num]] 206class EncSameWidth<int Num=0> { 207 int ID = 0x300; 208 int ret = !or(ID, Num); 209} 210 211// ACIdx 212class EncNextArgA<int dummy=0> { 213 int ID = 0x400; 214 int ret = !or(ID, dummy); 215} 216 217// Mapping[Num] 218class EncNextArgN<int Num=0> { 219 int ID = 0x500; 220 int ret = !or(ID, Num); 221} 222 223class ResolveArgCode< 224 list<int> Mapping, 225 list<int> ArgCodes, 226 int ACIdx, 227 int ax> { 228 int ah = !and(ax, 0xFF00); 229 int al = !and(ax, 0x00FF); 230 int num = Mapping[al]; 231 int ret = !cond( 232 !eq(ah, EncAnyType<>.ID) : !or(!shl(ACIdx, 3), al), 233 !eq(ah, EncMatchType<>.ID) : !or(!shl(num, 3), ArgKind.MatchType), 234 !eq(ah, EncSameWidth<>.ID) : !or(!shl(num, 3), ArgCodes[num]), 235 !eq(ah, EncNextArgA<>.ID) : ACIdx, 236 !eq(ah, EncNextArgN<>.ID) : num, 237 true : al); 238} 239 240//===----------------------------------------------------------------------===// 241// IIT_Info 242//===----------------------------------------------------------------------===// 243 244class IIT_Base<int num> { 245 int Number = num; 246 list<ValueType> VTs = ?; 247} 248 249class IIT_VT<ValueType vt, int num> : IIT_Base<num> { 250 let VTs = [vt]; 251} 252 253class IIT_Int<int size, int num> : IIT_Base<num> { 254 let VTs = !filter(vti, ValueTypes, 255 !and(vti.isInteger, !eq(vti.Size, size))); 256} 257 258class IIT_Vec<int nelem, int num> : IIT_Base<num> { 259 let VTs = !filter(vti, ValueTypes, 260 !and(vti.isVector, !eq(vti.nElem, nelem))); 261} 262 263defset list<IIT_Base> IIT_all = { 264def IIT_Done : IIT_Base< 0>; 265def IIT_I1 : IIT_Int<1, 1>; 266def IIT_I8 : IIT_Int<8, 2>; 267def IIT_I16 : IIT_Int<16, 3>; 268def IIT_I32 : IIT_Int<32, 4>; 269def IIT_I64 : IIT_Int<64, 5>; 270def IIT_F16 : IIT_VT<f16, 6>; 271def IIT_F32 : IIT_VT<f32, 7>; 272def IIT_F64 : IIT_VT<f64, 8>; 273def IIT_V2 : IIT_Vec<2, 9>; 274def IIT_V4 : IIT_Vec<4, 10>; 275def IIT_V8 : IIT_Vec<8, 11>; 276def IIT_V16 : IIT_Vec<16, 12>; 277def IIT_V32 : IIT_Vec<32, 13>; 278def IIT_PTR : IIT_Base< 14>; 279def IIT_ARG : IIT_Base< 15>; 280 281def IIT_V64 : IIT_Vec<64, 16>; 282def IIT_MMX : IIT_VT<x86mmx, 17>; 283def IIT_TOKEN : IIT_VT<token, 18>; 284def IIT_METADATA : IIT_VT<MetadataVT, 19>; 285def IIT_EMPTYSTRUCT : IIT_VT<OtherVT, 20>; 286def IIT_STRUCT2 : IIT_Base<21>; 287def IIT_STRUCT3 : IIT_Base<22>; 288def IIT_STRUCT4 : IIT_Base<23>; 289def IIT_STRUCT5 : IIT_Base<24>; 290def IIT_EXTEND_ARG : IIT_Base<25>; 291def IIT_TRUNC_ARG : IIT_Base<26>; 292def IIT_ANYPTR : IIT_Base<27>; 293def IIT_V1 : IIT_Vec<1, 28>; 294def IIT_VARARG : IIT_VT<isVoid, 29>; 295def IIT_HALF_VEC_ARG : IIT_Base<30>; 296def IIT_SAME_VEC_WIDTH_ARG : IIT_Base<31>; 297def IIT_VEC_OF_ANYPTRS_TO_ELT : IIT_Base<34>; 298def IIT_I128 : IIT_Int<128, 35>; 299def IIT_V512 : IIT_Vec<512, 36>; 300def IIT_V1024 : IIT_Vec<1024, 37>; 301def IIT_STRUCT6 : IIT_Base<38>; 302def IIT_STRUCT7 : IIT_Base<39>; 303def IIT_STRUCT8 : IIT_Base<40>; 304def IIT_F128 : IIT_VT<f128, 41>; 305def IIT_VEC_ELEMENT : IIT_Base<42>; 306def IIT_SCALABLE_VEC : IIT_Base<43>; 307def IIT_SUBDIVIDE2_ARG : IIT_Base<44>; 308def IIT_SUBDIVIDE4_ARG : IIT_Base<45>; 309def IIT_VEC_OF_BITCASTS_TO_INT : IIT_Base<46>; 310def IIT_V128 : IIT_Vec<128, 47>; 311def IIT_BF16 : IIT_VT<bf16, 48>; 312def IIT_STRUCT9 : IIT_Base<49>; 313def IIT_V256 : IIT_Vec<256, 50>; 314def IIT_AMX : IIT_VT<x86amx, 51>; 315def IIT_PPCF128 : IIT_VT<ppcf128, 52>; 316def IIT_V3 : IIT_Vec<3, 53>; 317def IIT_EXTERNREF : IIT_VT<externref, 54>; 318def IIT_FUNCREF : IIT_VT<funcref, 55>; 319def IIT_I2 : IIT_Int<2, 57>; 320def IIT_I4 : IIT_Int<4, 58>; 321def IIT_AARCH64_SVCOUNT : IIT_VT<aarch64svcount, 59>; 322def IIT_V6 : IIT_Vec<6, 60>; 323def IIT_V10 : IIT_Vec<10, 61>; 324} 325 326defvar IIT_all_FixedTypes = !filter(iit, IIT_all, 327 !or(!isa<IIT_VT>(iit), !isa<IIT_Int>(iit))); 328 329defvar IIT_all_VectorTypes = !filter(iit, IIT_all, 330 !isa<IIT_Vec>(iit)); 331 332defvar IIT_RetNumbers = [ 333 [IIT_Done.Number], 334 []<int>, 335 [IIT_STRUCT2.Number], 336 [IIT_STRUCT3.Number], 337 [IIT_STRUCT4.Number], 338 [IIT_STRUCT5.Number], 339 [IIT_STRUCT6.Number], 340 [IIT_STRUCT7.Number], 341 [IIT_STRUCT8.Number], 342 [IIT_STRUCT9.Number], 343]; 344 345//===----------------------------------------------------------------------===// 346// Types used by intrinsics. 347//===----------------------------------------------------------------------===// 348 349class LLVMType<ValueType vt> { 350 ValueType VT = vt; 351 int isAny = vt.isOverloaded; 352 353 int ArgCode = ?; 354 int Number = ?; 355 356 list<IIT_Base> IITs = !filter(iit, IIT_all_FixedTypes, 357 !not(!empty(!filter(iit_vt, iit.VTs, 358 !eq(iit_vt, !if(vt.isVector, vt.ElementType, vt)))))); 359 assert !le(!size(IITs), 1), "Duplicate type"; 360 361 list<IIT_Base> IIT_Vecs = !if(vt.isVector, 362 !filter(iit, IIT_all_VectorTypes, 363 !not(!empty(!filter(iit_vt, iit.VTs, !and( 364 !eq(iit_vt.ElementType, vt.ElementType), 365 !eq(iit_vt.nElem, vt.nElem)))))), 366 []); 367 assert !le(!size(IIT_Vecs), 1), "Duplicate type"; 368 369 list<int> Sig = !listconcat( 370 !if(vt.isScalable, [IIT_SCALABLE_VEC.Number], []), 371 !foreach(iit, IIT_Vecs, iit.Number), 372 !foreach(iit, IITs, iit.Number)); 373} 374 375class LLVMAnyType<ValueType vt> : LLVMType<vt> { 376 let ArgCode = !cond( 377 !eq(vt, Any) : ArgKind.Any, 378 !eq(vt, iAny) : ArgKind.AnyInteger, 379 !eq(vt, fAny) : ArgKind.AnyFloat, 380 !eq(vt, vAny) : ArgKind.AnyVector, 381 !eq(vt, iPTRAny) : ArgKind.AnyPointer, 382 ); 383 let Sig = [ 384 IIT_ARG.Number, 385 EncAnyType<ArgCode>.ret, 386 ]; 387 388 assert isAny, "LLVMAnyType.VT should have isOverloaded"; 389} 390 391class LLVMQualPointerType<int addrspace> 392 : LLVMType<iPTR> { 393 assert !and(!le(0, addrspace), !le(addrspace, 255)), 394 "Address space exceeds 255"; 395 396 let Sig = 397 !if(addrspace, [ 398 IIT_ANYPTR.Number, 399 addrspace, 400 ], [ 401 IIT_PTR.Number, 402 ]); 403} 404 405class LLVMAnyPointerType : LLVMAnyType<iPTRAny> { 406 assert isAny, "iPTRAny should have isOverloaded"; 407} 408 409// Match the type of another intrinsic parameter. Number is an index into the 410// list of overloaded types for the intrinsic, excluding all the fixed types. 411// The Number value must refer to a previously listed type. For example: 412// Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]> 413// has two overloaded types, the 2nd and 3rd arguments. LLVMMatchType<0> 414// refers to the first overloaded type, which is the 2nd argument. 415class LLVMMatchType<int num, IIT_Base IIT_Info = IIT_ARG> 416 : LLVMType<OtherVT>{ 417 let Number = num; 418 let Sig = [ 419 IIT_Info.Number, 420 EncMatchType<num>.ret, 421 ]; 422} 423 424class LLVMMatchTypeNextArg<int num, IIT_Base IIT_Info> 425 : LLVMMatchType<num, IIT_Info> { 426 let Sig = [ 427 IIT_Info.Number, 428 EncNextArgA<>.ret, 429 EncNextArgN<num>.ret, 430 ]; 431} 432 433// Match the type of another intrinsic parameter that is expected to be based on 434// an integral type (i.e. either iN or <N x iM>), but change the scalar size to 435// be twice as wide or half as wide as the other type. This is only useful when 436// the intrinsic is overloaded, so the matched type should be declared as iAny. 437class LLVMExtendedType<int num> : LLVMMatchType<num, IIT_EXTEND_ARG>; 438class LLVMTruncatedType<int num> : LLVMMatchType<num, IIT_TRUNC_ARG>; 439 440// Match the scalar/vector of another intrinsic parameter but with a different 441// element type. Either both are scalars or both are vectors with the same 442// number of elements. 443class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty> 444 : LLVMMatchType<idx, IIT_SAME_VEC_WIDTH_ARG> { 445 let Sig = !listconcat([ 446 IIT_SAME_VEC_WIDTH_ARG.Number, 447 EncSameWidth<idx>.ret, 448 ], elty.Sig); 449} 450 451class LLVMVectorOfAnyPointersToElt<int num> 452 : LLVMMatchTypeNextArg<num, IIT_VEC_OF_ANYPTRS_TO_ELT>; 453class LLVMVectorElementType<int num> : LLVMMatchType<num, IIT_VEC_ELEMENT>; 454 455// Match the type of another intrinsic parameter that is expected to be a 456// vector type, but change the element count to be half as many. 457class LLVMHalfElementsVectorType<int num> 458 : LLVMMatchType<num, IIT_HALF_VEC_ARG>; 459 460// Match the type of another intrinsic parameter that is expected to be a 461// vector type (i.e. <N x iM>) but with each element subdivided to 462// form a vector with more elements that are smaller than the original. 463class LLVMSubdivide2VectorType<int num> 464 : LLVMMatchType<num, IIT_SUBDIVIDE2_ARG>; 465class LLVMSubdivide4VectorType<int num> 466 : LLVMMatchType<num, IIT_SUBDIVIDE4_ARG>; 467 468// Match the element count and bit width of another intrinsic parameter, but 469// change the element type to an integer. 470class LLVMVectorOfBitcastsToInt<int num> 471 : LLVMMatchType<num, IIT_VEC_OF_BITCASTS_TO_INT>; 472 473def llvm_void_ty : LLVMType<isVoid>; 474 475def llvm_any_ty : LLVMAnyType<Any>; 476def llvm_anyint_ty : LLVMAnyType<iAny>; 477def llvm_anyfloat_ty : LLVMAnyType<fAny>; 478def llvm_anyvector_ty : LLVMAnyType<vAny>; 479 480def llvm_i1_ty : LLVMType<i1>; 481def llvm_i8_ty : LLVMType<i8>; 482def llvm_i16_ty : LLVMType<i16>; 483def llvm_i32_ty : LLVMType<i32>; 484def llvm_i64_ty : LLVMType<i64>; 485def llvm_i128_ty : LLVMType<i128>; 486def llvm_half_ty : LLVMType<f16>; 487def llvm_bfloat_ty : LLVMType<bf16>; 488def llvm_float_ty : LLVMType<f32>; 489def llvm_double_ty : LLVMType<f64>; 490def llvm_f80_ty : LLVMType<f80>; 491def llvm_f128_ty : LLVMType<f128>; 492def llvm_ppcf128_ty : LLVMType<ppcf128>; 493def llvm_ptr_ty : LLVMQualPointerType<0>; // ptr 494def llvm_anyptr_ty : LLVMAnyPointerType; // ptr addrspace(N) 495def llvm_empty_ty : LLVMType<OtherVT>; // { } 496def llvm_metadata_ty : LLVMType<MetadataVT>; // !{...} 497def llvm_token_ty : LLVMType<token>; // token 498 499def llvm_x86mmx_ty : LLVMType<x86mmx>; 500 501def llvm_aarch64_svcount_ty : LLVMType<aarch64svcount>; 502 503def llvm_x86amx_ty : LLVMType<x86amx>; 504 505def llvm_v2i1_ty : LLVMType<v2i1>; // 2 x i1 506def llvm_v4i1_ty : LLVMType<v4i1>; // 4 x i1 507def llvm_v8i1_ty : LLVMType<v8i1>; // 8 x i1 508def llvm_v16i1_ty : LLVMType<v16i1>; // 16 x i1 509def llvm_v32i1_ty : LLVMType<v32i1>; // 32 x i1 510def llvm_v64i1_ty : LLVMType<v64i1>; // 64 x i1 511def llvm_v128i1_ty : LLVMType<v128i1>; // 128 x i1 512def llvm_v256i1_ty : LLVMType<v256i1>; // 256 x i1 513def llvm_v512i1_ty : LLVMType<v512i1>; // 512 x i1 514def llvm_v1024i1_ty : LLVMType<v1024i1>; //1024 x i1 515def llvm_v2048i1_ty : LLVMType<v2048i1>; //2048 x i1 516 517def llvm_v1i8_ty : LLVMType<v1i8>; // 1 x i8 518def llvm_v2i8_ty : LLVMType<v2i8>; // 2 x i8 519def llvm_v3i8_ty : LLVMType<v3i8>; // 3 x i8 520def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8 521def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8 522def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8 523def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8 524def llvm_v64i8_ty : LLVMType<v64i8>; // 64 x i8 525def llvm_v128i8_ty : LLVMType<v128i8>; //128 x i8 526def llvm_v256i8_ty : LLVMType<v256i8>; //256 x i8 527 528def llvm_v1i16_ty : LLVMType<v1i16>; // 1 x i16 529def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16 530def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16 531def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16 532def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16 533def llvm_v32i16_ty : LLVMType<v32i16>; // 32 x i16 534def llvm_v64i16_ty : LLVMType<v64i16>; // 64 x i16 535def llvm_v128i16_ty : LLVMType<v128i16>; //128 x i16 536 537def llvm_v1i32_ty : LLVMType<v1i32>; // 1 x i32 538def llvm_v2i32_ty : LLVMType<v2i32>; // 2 x i32 539def llvm_v3i32_ty : LLVMType<v3i32>; // 3 x i32 540def llvm_v4i32_ty : LLVMType<v4i32>; // 4 x i32 541def llvm_v6i32_ty : LLVMType<v6i32>; // 6 x i32 542def llvm_v8i32_ty : LLVMType<v8i32>; // 8 x i32 543def llvm_v16i32_ty : LLVMType<v16i32>; // 16 x i32 544def llvm_v32i32_ty : LLVMType<v32i32>; // 32 x i32 545def llvm_v64i32_ty : LLVMType<v64i32>; // 64 x i32 546def llvm_v256i32_ty : LLVMType<v256i32>; //256 x i32 547 548def llvm_v1i64_ty : LLVMType<v1i64>; // 1 x i64 549def llvm_v2i64_ty : LLVMType<v2i64>; // 2 x i64 550def llvm_v4i64_ty : LLVMType<v4i64>; // 4 x i64 551def llvm_v8i64_ty : LLVMType<v8i64>; // 8 x i64 552def llvm_v16i64_ty : LLVMType<v16i64>; // 16 x i64 553def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64 554 555def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128 556 557def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16) 558def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16) 559def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16) 560def llvm_v16f16_ty : LLVMType<v16f16>; // 16 x half (__fp16) 561def llvm_v32f16_ty : LLVMType<v32f16>; // 32 x half (__fp16) 562def llvm_v2bf16_ty : LLVMType<v2bf16>; // 2 x bfloat (__bf16) 563def llvm_v4bf16_ty : LLVMType<v4bf16>; // 4 x bfloat (__bf16) 564def llvm_v8bf16_ty : LLVMType<v8bf16>; // 8 x bfloat (__bf16) 565def llvm_v16bf16_ty : LLVMType<v16bf16>; // 16 x bfloat (__bf16) 566def llvm_v32bf16_ty : LLVMType<v32bf16>; // 32 x bfloat (__bf16) 567def llvm_v1f32_ty : LLVMType<v1f32>; // 1 x float 568def llvm_v2f32_ty : LLVMType<v2f32>; // 2 x float 569def llvm_v3f32_ty : LLVMType<v3f32>; // 3 x float 570def llvm_v4f32_ty : LLVMType<v4f32>; // 4 x float 571def llvm_v8f32_ty : LLVMType<v8f32>; // 8 x float 572def llvm_v16f32_ty : LLVMType<v16f32>; // 16 x float 573def llvm_v32f32_ty : LLVMType<v32f32>; // 32 x float 574def llvm_v1f64_ty : LLVMType<v1f64>; // 1 x double 575def llvm_v2f64_ty : LLVMType<v2f64>; // 2 x double 576def llvm_v4f64_ty : LLVMType<v4f64>; // 4 x double 577def llvm_v8f64_ty : LLVMType<v8f64>; // 8 x double 578def llvm_v16f64_ty : LLVMType<v16f64>; // 16 x double 579 580def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here 581 582def llvm_externref_ty : LLVMType<externref>; 583def llvm_funcref_ty : LLVMType<funcref>; 584 585//===----------------------------------------------------------------------===// 586 587class MakeIdx<list<int> Set> { 588 list<int> IdxsR = !foreach(i, !range(Set), 589 !if(Set[i], 590 !foldl(0, !range(0, i), m, j, !add(m, Set[j])), 591 -1)); 592 593 list<int> RIdxsR = !foreach(i, !range(Set), 594 !foldl(-1, !range(Set), m, j, 595 !if(!and(Set[j], !eq(IdxsR[j], i)), j, m))); 596 597 list<int> Idxs = !foreach(a, IdxsR, !if(!ge(a, 0), a, ?)); 598 list<int> RIdxs = !foreach(a, RIdxsR, !if(!ge(a, 0), a, ?)); 599} 600 601class TypeInfoGen< 602 list<LLVMType> RetTypes, 603 list<LLVMType> ParamTypes> { 604 list<LLVMType> AllTypes = !listconcat(RetTypes, ParamTypes); 605 606 // ArgCodes for NextArg -- isAny or MatchTypeNextArg 607 list<int> ACIdxs = MakeIdx< 608 !foreach(ty, AllTypes, 609 !or(ty.isAny, !isa<LLVMMatchTypeNextArg>(ty)))>.Idxs; 610 611 // ArgCodes (only for isAny or MatchTypeNextArg) 612 list<LLVMType> ACTys = !filter(ty, AllTypes, 613 !or(ty.isAny, !isa<LLVMMatchTypeNextArg>(ty))); 614 615 list<int> ArgCodes = !foreach(ty, ACTys, ty.ArgCode); 616 617 // Mappings MatchTypeIdx to ACTys 618 list<int> MappingRIdxs = MakeIdx< 619 !foreach(ty, ACTys, ty.isAny)>.RIdxs; 620 621 // D63507: Exclude LLVMPointerType<llvm_any_ty> 622 bit isOverloaded = !not(!empty(!filter(ty, AllTypes, 623 !isa<LLVMAnyType>(ty)))); 624 625 list<LLVMType> Types = !foreach(ty, AllTypes, 626 !if(!isa<LLVMMatchType>(ty), ACTys[MappingRIdxs[ty.Number]], ty)); 627 628 list<list<int>> TypeSig = !listconcat( 629 [IIT_RetNumbers[!size(RetTypes)]], 630 !foreach(i, !range(AllTypes), 631 !foreach(a, AllTypes[i].Sig, 632 ResolveArgCode< 633 MappingRIdxs, 634 ArgCodes, 635 ACIdxs[i], 636 a>.ret))); 637} 638 639//===----------------------------------------------------------------------===// 640// Intrinsic Definitions. 641//===----------------------------------------------------------------------===// 642 643// Intrinsic class - This is used to define one LLVM intrinsic. The name of the 644// intrinsic definition should start with "int_", then match the LLVM intrinsic 645// name with the "llvm." prefix removed, and all "."s turned into "_"s. For 646// example, llvm.bswap.i16 -> int_bswap_i16. 647// 648// * RetTypes is a list containing the return types expected for the 649// intrinsic. 650// * ParamTypes is a list containing the parameter types expected for the 651// intrinsic. 652// * Properties can be set to describe the behavior of the intrinsic. 653// 654class Intrinsic<list<LLVMType> ret_types, 655 list<LLVMType> param_types = [], 656 list<IntrinsicProperty> intr_properties = [], 657 string name = "", 658 list<SDNodeProperty> sd_properties = [], 659 bit disable_default_attributes = true> : SDPatternOperator { 660 string LLVMName = name; 661 string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics. 662 list<LLVMType> RetTypes = ret_types; 663 list<LLVMType> ParamTypes = param_types; 664 list<IntrinsicProperty> IntrProperties = intr_properties; 665 let Properties = sd_properties; 666 667 // Disable applying IntrinsicProperties that are marked default with 668 // IntrinsicProperty<1> 669 bit DisableDefaultAttributes = disable_default_attributes; 670 671 bit isTarget = false; 672 673 TypeInfoGen TypeInfo = TypeInfoGen<RetTypes, ParamTypes>; 674 bit isOverloaded = TypeInfo.isOverloaded; 675 list<LLVMType> Types = TypeInfo.Types; 676 list<list<int>> TypeSig = TypeInfo.TypeSig; 677} 678 679// Intrinsic with default attributes (disable_default_attributes = false). 680class DefaultAttrsIntrinsic<list<LLVMType> ret_types, 681 list<LLVMType> param_types = [], 682 list<IntrinsicProperty> intr_properties = [], 683 string name = "", 684 list<SDNodeProperty> sd_properties = []> 685 : Intrinsic<ret_types, param_types, 686 intr_properties, name, 687 sd_properties, /*disable_default_attributes*/ 0> {} 688 689/// ClangBuiltin - If this intrinsic exactly corresponds to a Clang builtin, this 690/// specifies the name of the builtin. This provides automatic CBE and CFE 691/// support. 692class ClangBuiltin<string name> { 693 string ClangBuiltinName = name; 694} 695 696class MSBuiltin<string name> { 697 string MSBuiltinName = name; 698} 699 700#ifndef TEST_INTRINSICS_SUPPRESS_DEFS 701 702//===--------------- Variable Argument Handling Intrinsics ----------------===// 703// 704 705def int_vastart : DefaultAttrsIntrinsic<[], 706 [llvm_anyptr_ty], [], "llvm.va_start">; 707def int_vacopy : DefaultAttrsIntrinsic<[], 708 [llvm_anyptr_ty, LLVMMatchType<0>], [], 709 "llvm.va_copy">; 710def int_vaend : DefaultAttrsIntrinsic<[], 711 [llvm_anyptr_ty], [], "llvm.va_end">; 712 713//===------------------- Garbage Collection Intrinsics --------------------===// 714// 715def int_gcroot : Intrinsic<[], 716 [llvm_ptr_ty, llvm_ptr_ty]>; 717def int_gcread : Intrinsic<[llvm_ptr_ty], 718 [llvm_ptr_ty, llvm_ptr_ty], 719 [IntrReadMem, IntrArgMemOnly]>; 720def int_gcwrite : Intrinsic<[], 721 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 722 [IntrArgMemOnly, NoCapture<ArgIndex<1>>, 723 NoCapture<ArgIndex<2>>]>; 724 725//===------------------- ObjC ARC runtime Intrinsics --------------------===// 726// 727// Note these are to support the Objective-C ARC optimizer which wants to 728// eliminate retain and releases where possible. 729 730def int_objc_autorelease : Intrinsic<[llvm_ptr_ty], 731 [llvm_ptr_ty], 732 [Returned<ArgIndex<0>>]>; 733def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>; 734def int_objc_autoreleasePoolPush : Intrinsic<[llvm_ptr_ty], []>; 735def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty], 736 [llvm_ptr_ty], 737 [Returned<ArgIndex<0>>]>; 738def int_objc_copyWeak : Intrinsic<[], 739 [llvm_ptr_ty, 740 llvm_ptr_ty]>; 741def int_objc_destroyWeak : Intrinsic<[], [llvm_ptr_ty]>; 742def int_objc_initWeak : Intrinsic<[llvm_ptr_ty], 743 [llvm_ptr_ty, 744 llvm_ptr_ty]>; 745def int_objc_loadWeak : Intrinsic<[llvm_ptr_ty], 746 [llvm_ptr_ty]>; 747def int_objc_loadWeakRetained : Intrinsic<[llvm_ptr_ty], 748 [llvm_ptr_ty]>; 749def int_objc_moveWeak : Intrinsic<[], 750 [llvm_ptr_ty, 751 llvm_ptr_ty]>; 752def int_objc_release : Intrinsic<[], [llvm_ptr_ty]>; 753def int_objc_retain : Intrinsic<[llvm_ptr_ty], 754 [llvm_ptr_ty], 755 [Returned<ArgIndex<0>>]>; 756def int_objc_retainAutorelease : Intrinsic<[llvm_ptr_ty], 757 [llvm_ptr_ty], 758 [Returned<ArgIndex<0>>]>; 759def int_objc_retainAutoreleaseReturnValue : Intrinsic<[llvm_ptr_ty], 760 [llvm_ptr_ty], 761 [Returned<ArgIndex<0>>]>; 762def int_objc_retainAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty], 763 [llvm_ptr_ty]>; 764def int_objc_retainBlock : Intrinsic<[llvm_ptr_ty], 765 [llvm_ptr_ty]>; 766def int_objc_storeStrong : Intrinsic<[], 767 [llvm_ptr_ty, 768 llvm_ptr_ty]>; 769def int_objc_storeWeak : Intrinsic<[llvm_ptr_ty], 770 [llvm_ptr_ty, 771 llvm_ptr_ty]>; 772def int_objc_clang_arc_use : Intrinsic<[], 773 [llvm_vararg_ty]>; 774def int_objc_clang_arc_noop_use : DefaultAttrsIntrinsic<[], 775 [llvm_vararg_ty], 776 [IntrInaccessibleMemOnly]>; 777def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty], 778 [llvm_ptr_ty]>; 779def int_objc_retainedObject : Intrinsic<[llvm_ptr_ty], 780 [llvm_ptr_ty]>; 781def int_objc_unretainedObject : Intrinsic<[llvm_ptr_ty], 782 [llvm_ptr_ty]>; 783def int_objc_unretainedPointer : Intrinsic<[llvm_ptr_ty], 784 [llvm_ptr_ty]>; 785def int_objc_retain_autorelease : Intrinsic<[llvm_ptr_ty], 786 [llvm_ptr_ty], 787 [Returned<ArgIndex<0>>]>; 788def int_objc_sync_enter : Intrinsic<[llvm_i32_ty], 789 [llvm_ptr_ty]>; 790def int_objc_sync_exit : Intrinsic<[llvm_i32_ty], 791 [llvm_ptr_ty]>; 792def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[], 793 [llvm_ptr_ty, 794 llvm_ptr_ty]>; 795def int_objc_arc_annotation_topdown_bbend : Intrinsic<[], 796 [llvm_ptr_ty, 797 llvm_ptr_ty]>; 798def int_objc_arc_annotation_bottomup_bbstart : Intrinsic<[], 799 [llvm_ptr_ty, 800 llvm_ptr_ty]>; 801def int_objc_arc_annotation_bottomup_bbend : Intrinsic<[], 802 [llvm_ptr_ty, 803 llvm_ptr_ty]>; 804//===--------------- Swift asynchronous context intrinsics ----------------===// 805 806// Returns the location of the Swift asynchronous context (usually stored just 807// before the frame pointer), and triggers the creation of a null context if it 808// would otherwise be unneeded. 809def int_swift_async_context_addr : Intrinsic<[llvm_ptr_ty], [], []>; 810 811//===--------------------- Code Generator Intrinsics ----------------------===// 812// 813def int_returnaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_i32_ty], 814 [IntrNoMem, ImmArg<ArgIndex<0>>]>; 815def int_addressofreturnaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>; 816def int_frameaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_i32_ty], 817 [IntrNoMem, ImmArg<ArgIndex<0>>]>; 818def int_sponentry : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>; 819def int_read_register : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_metadata_ty], 820 [IntrReadMem], "llvm.read_register">; 821def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty], 822 [IntrNoCallback], "llvm.write_register">; 823def int_read_volatile_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty], 824 [IntrHasSideEffects], 825 "llvm.read_volatile_register">; 826 827// Gets the address of the local variable area. This is typically a copy of the 828// stack, frame, or base pointer depending on the type of prologue. 829def int_localaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 830 831// Escapes local variables to allow access from other functions. 832def int_localescape : DefaultAttrsIntrinsic<[], [llvm_vararg_ty]>; 833 834// Given a function and the localaddress of a parent frame, returns a pointer 835// to an escaped allocation indicated by the index. 836def int_localrecover : DefaultAttrsIntrinsic<[llvm_ptr_ty], 837 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], 838 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 839 840// Given the frame pointer passed into an SEH filter function, returns a 841// pointer to the local variable area suitable for use with llvm.localrecover. 842def int_eh_recoverfp : DefaultAttrsIntrinsic<[llvm_ptr_ty], 843 [llvm_ptr_ty, llvm_ptr_ty], 844 [IntrNoMem]>; 845 846// To mark the beginning/end of a try-scope for Windows SEH -EHa 847// calls/invokes to these intrinsics are placed to model control flows 848// caused by HW exceptions under option -EHa. 849// calls/invokes to these intrinsics will be discarded during a codegen pass 850// after EH tables are generated 851def int_seh_try_begin : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>; 852def int_seh_try_end : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>; 853def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>; 854def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>; 855 856// Note: we treat stacksave/stackrestore as writemem because we don't otherwise 857// model their dependencies on allocas. 858def int_stacksave : DefaultAttrsIntrinsic<[llvm_anyptr_ty]>, 859 ClangBuiltin<"__builtin_stack_save">; 860def int_stackrestore : DefaultAttrsIntrinsic<[], [llvm_anyptr_ty]>, 861 ClangBuiltin<"__builtin_stack_restore">; 862 863def int_get_dynamic_area_offset : DefaultAttrsIntrinsic<[llvm_anyint_ty]>; 864 865def int_thread_pointer : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>, 866 ClangBuiltin<"__builtin_thread_pointer">; 867 868// IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly 869// necessary for prefetch, however it does conveniently prevent the prefetch 870// from being reordered overly much with respect to nearby access to the same 871// memory while not impeding optimization. 872def int_prefetch 873 : DefaultAttrsIntrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ], 874 [IntrInaccessibleMemOrArgMemOnly, IntrWillReturn, 875 ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>, 876 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>; 877def int_pcmarker : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>; 878 879def int_readcyclecounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>; 880 881def int_readsteadycounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>; 882 883// The assume intrinsic is marked InaccessibleMemOnly so that proper control 884// dependencies will be maintained. 885def int_assume : DefaultAttrsIntrinsic< 886 [], [llvm_i1_ty], [IntrWriteMem, IntrInaccessibleMemOnly, NoUndef<ArgIndex<0>>]>; 887 888// 'llvm.experimental.noalias.scope.decl' intrinsic: Inserted at the location of 889// noalias scope declaration. Makes it possible to identify that a noalias scope 890// is only valid inside the body of a loop. 891// 892// Purpose of the different arguments: 893// - arg0: id.scope: metadata representing the scope declaration. 894def int_experimental_noalias_scope_decl 895 : DefaultAttrsIntrinsic<[], [llvm_metadata_ty], 896 [IntrInaccessibleMemOnly]>; // blocks LICM and some more 897 898// Stack Protector Intrinsic - The stackprotector intrinsic writes the stack 899// guard to the correct place on the stack frame. 900def int_stackprotector : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>; 901def int_stackguard : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], []>; 902 903// A cover for instrumentation based profiling. 904def int_instrprof_cover : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty, 905 llvm_i32_ty, llvm_i32_ty]>; 906 907// A counter increment for instrumentation based profiling. 908def int_instrprof_increment : Intrinsic<[], 909 [llvm_ptr_ty, llvm_i64_ty, 910 llvm_i32_ty, llvm_i32_ty]>; 911 912// A counter increment with step for instrumentation based profiling. 913def int_instrprof_increment_step : Intrinsic<[], 914 [llvm_ptr_ty, llvm_i64_ty, 915 llvm_i32_ty, llvm_i32_ty, llvm_i64_ty]>; 916 917// Callsite instrumentation for contextual profiling 918def int_instrprof_callsite : Intrinsic<[], 919 [llvm_ptr_ty, llvm_i64_ty, 920 llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty]>; 921 922// A timestamp for instrumentation based profiling. 923def int_instrprof_timestamp : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty, 924 llvm_i32_ty, llvm_i32_ty]>; 925 926// A call to profile runtime for value profiling of target expressions 927// through instrumentation based profiling. 928def int_instrprof_value_profile : Intrinsic<[], 929 [llvm_ptr_ty, llvm_i64_ty, 930 llvm_i64_ty, llvm_i32_ty, 931 llvm_i32_ty]>; 932 933// A parameter configuration for instrumentation based MCDC profiling. 934def int_instrprof_mcdc_parameters : Intrinsic<[], 935 [llvm_ptr_ty, llvm_i64_ty, 936 llvm_i32_ty]>; 937 938// A test vector bitmap update for instrumentation based MCDC profiling. 939def int_instrprof_mcdc_tvbitmap_update : Intrinsic<[], 940 [llvm_ptr_ty, llvm_i64_ty, 941 llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty]>; 942 943// A condition bitmap value update for instrumentation based MCDC profiling. 944def int_instrprof_mcdc_condbitmap_update : Intrinsic<[], 945 [llvm_ptr_ty, llvm_i64_ty, 946 llvm_i32_ty, llvm_ptr_ty, llvm_i1_ty]>; 947 948def int_call_preallocated_setup : DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty]>; 949def int_call_preallocated_arg : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty]>; 950def int_call_preallocated_teardown : DefaultAttrsIntrinsic<[], [llvm_token_ty]>; 951 952// This intrinsic is intentionally undocumented and users shouldn't call it; 953// it's produced then quickly consumed during codegen. 954def int_callbr_landingpad : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>], 955 [IntrNoMerge]>; 956 957//===------------------- Standard C Library Intrinsics --------------------===// 958// 959 960def int_memcpy : Intrinsic<[], 961 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, 962 llvm_i1_ty], 963 [IntrArgMemOnly, IntrWillReturn, IntrNoFree, 964 IntrNoCallback, 965 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>, 966 NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>, 967 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>, 968 ImmArg<ArgIndex<3>>]>; 969 970// Memcpy semantic that is guaranteed to be inlined. 971// In particular this means that the generated code is not allowed to call any 972// external function. 973// The third argument (specifying the size) must be a constant. 974def int_memcpy_inline 975 : Intrinsic<[], 976 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i1_ty], 977 [IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback, 978 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>, 979 NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>, 980 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>, 981 ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>; 982 983def int_memmove : Intrinsic<[], 984 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, 985 llvm_i1_ty], 986 [IntrArgMemOnly, IntrWillReturn, IntrNoFree, 987 IntrNoCallback, 988 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>, 989 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>, 990 ImmArg<ArgIndex<3>>]>; 991def int_memset : Intrinsic<[], 992 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, 993 llvm_i1_ty], 994 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, 995 IntrNoFree, IntrNoCallback, 996 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>, 997 ImmArg<ArgIndex<3>>]>; 998 999// Memset version that is guaranteed to be inlined. 1000// In particular this means that the generated code is not allowed to call any 1001// external function. 1002// The third argument (specifying the size) must be a constant. 1003def int_memset_inline 1004 : Intrinsic<[], 1005 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i1_ty], 1006 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback, 1007 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>, 1008 ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>; 1009 1010// FIXME: Add version of these floating point intrinsics which allow non-default 1011// rounding modes and FP exception handling. 1012 1013let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in { 1014 def int_fma : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1015 [LLVMMatchType<0>, LLVMMatchType<0>, 1016 LLVMMatchType<0>]>; 1017 def int_fmuladd : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1018 [LLVMMatchType<0>, LLVMMatchType<0>, 1019 LLVMMatchType<0>]>; 1020 1021 // These functions do not read memory, but are sensitive to the 1022 // rounding mode. LLVM purposely does not model changes to the FP 1023 // environment so they can be treated as readnone. 1024 def int_sqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1025 def int_powi : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_anyint_ty]>; 1026 def int_sin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1027 def int_cos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1028 def int_tan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1029 def int_pow : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1030 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1031 def int_log : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1032 def int_log10: DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1033 def int_log2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1034 def int_exp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1035 def int_exp2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1036 def int_exp10 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1037 def int_fabs : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1038 def int_copysign : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1039 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1040 def int_floor : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1041 def int_ceil : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1042 def int_trunc : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1043 def int_rint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1044 def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1045 def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1046 def int_roundeven : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 1047 1048 // Truncate a floating point number with a specific rounding mode 1049 def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1050 [ llvm_anyfloat_ty, llvm_metadata_ty ]>; 1051 1052 def int_canonicalize : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], 1053 [IntrNoMem]>; 1054 // Arithmetic fence intrinsic. 1055 def int_arithmetic_fence : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], 1056 [IntrNoMem]>; 1057 1058 def int_lround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>; 1059 def int_llround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>; 1060 def int_lrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>; 1061 def int_llrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>; 1062 1063 // TODO: int operand should be constrained to same number of elements as the result. 1064 def int_ldexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, 1065 llvm_anyint_ty]>; 1066 1067 // TODO: Should constrain all element counts to match 1068 def int_frexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty, llvm_anyint_ty], [LLVMMatchType<0>]>; 1069} 1070 1071def int_minnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1072 [LLVMMatchType<0>, LLVMMatchType<0>], 1073 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative] 1074>; 1075def int_maxnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1076 [LLVMMatchType<0>, LLVMMatchType<0>], 1077 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative] 1078>; 1079def int_minimum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1080 [LLVMMatchType<0>, LLVMMatchType<0>], 1081 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative] 1082>; 1083def int_maximum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 1084 [LLVMMatchType<0>, LLVMMatchType<0>], 1085 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative] 1086>; 1087 1088// Internal interface for object size checking 1089def int_objectsize : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1090 [llvm_anyptr_ty, llvm_i1_ty, 1091 llvm_i1_ty, llvm_i1_ty], 1092 [IntrNoMem, IntrSpeculatable, IntrWillReturn, 1093 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>, 1094 ImmArg<ArgIndex<3>>]>, 1095 ClangBuiltin<"__builtin_object_size">; 1096 1097//===--------------- Access to Floating Point Environment -----------------===// 1098// 1099 1100let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in { 1101 def int_get_rounding : DefaultAttrsIntrinsic<[llvm_i32_ty], []>; 1102 def int_set_rounding : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>; 1103 def int_get_fpenv : DefaultAttrsIntrinsic<[llvm_anyint_ty], []>; 1104 def int_set_fpenv : DefaultAttrsIntrinsic<[], [llvm_anyint_ty]>; 1105 def int_reset_fpenv : DefaultAttrsIntrinsic<[], []>; 1106 def int_get_fpmode : DefaultAttrsIntrinsic<[llvm_anyint_ty], []>; 1107 def int_set_fpmode : DefaultAttrsIntrinsic<[], [llvm_anyint_ty]>; 1108 def int_reset_fpmode : DefaultAttrsIntrinsic<[], []>; 1109} 1110 1111//===--------------- Floating Point Properties ----------------------------===// 1112// 1113 1114def int_is_fpclass 1115 : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1116 [llvm_anyfloat_ty, llvm_i32_ty], 1117 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>; 1118 1119//===--------------- Constrained Floating Point Intrinsics ----------------===// 1120// 1121 1122/// IntrStrictFP - The intrinsic is allowed to be used in an alternate 1123/// floating point environment. 1124def IntrStrictFP : IntrinsicProperty; 1125 1126let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn, IntrStrictFP] in { 1127 def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1128 [ LLVMMatchType<0>, 1129 LLVMMatchType<0>, 1130 llvm_metadata_ty, 1131 llvm_metadata_ty ]>; 1132 def int_experimental_constrained_fsub : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1133 [ LLVMMatchType<0>, 1134 LLVMMatchType<0>, 1135 llvm_metadata_ty, 1136 llvm_metadata_ty ]>; 1137 def int_experimental_constrained_fmul : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1138 [ LLVMMatchType<0>, 1139 LLVMMatchType<0>, 1140 llvm_metadata_ty, 1141 llvm_metadata_ty ]>; 1142 def int_experimental_constrained_fdiv : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1143 [ LLVMMatchType<0>, 1144 LLVMMatchType<0>, 1145 llvm_metadata_ty, 1146 llvm_metadata_ty ]>; 1147 def int_experimental_constrained_frem : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1148 [ LLVMMatchType<0>, 1149 LLVMMatchType<0>, 1150 llvm_metadata_ty, 1151 llvm_metadata_ty ]>; 1152 1153 def int_experimental_constrained_fma : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1154 [ LLVMMatchType<0>, 1155 LLVMMatchType<0>, 1156 LLVMMatchType<0>, 1157 llvm_metadata_ty, 1158 llvm_metadata_ty ]>; 1159 1160 def int_experimental_constrained_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1161 [ LLVMMatchType<0>, 1162 LLVMMatchType<0>, 1163 LLVMMatchType<0>, 1164 llvm_metadata_ty, 1165 llvm_metadata_ty ]>; 1166 1167 def int_experimental_constrained_fptosi : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 1168 [ llvm_anyfloat_ty, 1169 llvm_metadata_ty ]>; 1170 1171 def int_experimental_constrained_fptoui : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 1172 [ llvm_anyfloat_ty, 1173 llvm_metadata_ty ]>; 1174 1175 def int_experimental_constrained_sitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1176 [ llvm_anyint_ty, 1177 llvm_metadata_ty, 1178 llvm_metadata_ty ]>; 1179 1180 def int_experimental_constrained_uitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1181 [ llvm_anyint_ty, 1182 llvm_metadata_ty, 1183 llvm_metadata_ty ]>; 1184 1185 def int_experimental_constrained_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1186 [ llvm_anyfloat_ty, 1187 llvm_metadata_ty, 1188 llvm_metadata_ty ]>; 1189 1190 def int_experimental_constrained_fpext : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1191 [ llvm_anyfloat_ty, 1192 llvm_metadata_ty ]>; 1193 1194 // These intrinsics are sensitive to the rounding mode so we need constrained 1195 // versions of each of them. When strict rounding and exception control are 1196 // not required the non-constrained versions of these intrinsics should be 1197 // used. 1198 def int_experimental_constrained_sqrt : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1199 [ LLVMMatchType<0>, 1200 llvm_metadata_ty, 1201 llvm_metadata_ty ]>; 1202 def int_experimental_constrained_powi : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1203 [ LLVMMatchType<0>, 1204 llvm_i32_ty, 1205 llvm_metadata_ty, 1206 llvm_metadata_ty ]>; 1207 def int_experimental_constrained_ldexp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1208 [ LLVMMatchType<0>, 1209 llvm_anyint_ty, 1210 llvm_metadata_ty, 1211 llvm_metadata_ty ]>; 1212 def int_experimental_constrained_sin : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1213 [ LLVMMatchType<0>, 1214 llvm_metadata_ty, 1215 llvm_metadata_ty ]>; 1216 def int_experimental_constrained_cos : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1217 [ LLVMMatchType<0>, 1218 llvm_metadata_ty, 1219 llvm_metadata_ty ]>; 1220 def int_experimental_constrained_pow : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1221 [ LLVMMatchType<0>, 1222 LLVMMatchType<0>, 1223 llvm_metadata_ty, 1224 llvm_metadata_ty ]>; 1225 def int_experimental_constrained_log : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1226 [ LLVMMatchType<0>, 1227 llvm_metadata_ty, 1228 llvm_metadata_ty ]>; 1229 def int_experimental_constrained_log10: DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1230 [ LLVMMatchType<0>, 1231 llvm_metadata_ty, 1232 llvm_metadata_ty ]>; 1233 def int_experimental_constrained_log2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1234 [ LLVMMatchType<0>, 1235 llvm_metadata_ty, 1236 llvm_metadata_ty ]>; 1237 def int_experimental_constrained_exp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1238 [ LLVMMatchType<0>, 1239 llvm_metadata_ty, 1240 llvm_metadata_ty ]>; 1241 def int_experimental_constrained_exp2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1242 [ LLVMMatchType<0>, 1243 llvm_metadata_ty, 1244 llvm_metadata_ty ]>; 1245 def int_experimental_constrained_rint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1246 [ LLVMMatchType<0>, 1247 llvm_metadata_ty, 1248 llvm_metadata_ty ]>; 1249 def int_experimental_constrained_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1250 [ LLVMMatchType<0>, 1251 llvm_metadata_ty, 1252 llvm_metadata_ty ]>; 1253 def int_experimental_constrained_lrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 1254 [ llvm_anyfloat_ty, 1255 llvm_metadata_ty, 1256 llvm_metadata_ty ]>; 1257 def int_experimental_constrained_llrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 1258 [ llvm_anyfloat_ty, 1259 llvm_metadata_ty, 1260 llvm_metadata_ty ]>; 1261 def int_experimental_constrained_maxnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1262 [ LLVMMatchType<0>, 1263 LLVMMatchType<0>, 1264 llvm_metadata_ty ]>; 1265 def int_experimental_constrained_minnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1266 [ LLVMMatchType<0>, 1267 LLVMMatchType<0>, 1268 llvm_metadata_ty ]>; 1269 def int_experimental_constrained_maximum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1270 [ LLVMMatchType<0>, 1271 LLVMMatchType<0>, 1272 llvm_metadata_ty ]>; 1273 def int_experimental_constrained_minimum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1274 [ LLVMMatchType<0>, 1275 LLVMMatchType<0>, 1276 llvm_metadata_ty ]>; 1277 def int_experimental_constrained_ceil : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1278 [ LLVMMatchType<0>, 1279 llvm_metadata_ty ]>; 1280 def int_experimental_constrained_floor : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1281 [ LLVMMatchType<0>, 1282 llvm_metadata_ty ]>; 1283 def int_experimental_constrained_lround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 1284 [ llvm_anyfloat_ty, 1285 llvm_metadata_ty ]>; 1286 def int_experimental_constrained_llround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 1287 [ llvm_anyfloat_ty, 1288 llvm_metadata_ty ]>; 1289 def int_experimental_constrained_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1290 [ LLVMMatchType<0>, 1291 llvm_metadata_ty ]>; 1292 def int_experimental_constrained_roundeven : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1293 [ LLVMMatchType<0>, 1294 llvm_metadata_ty ]>; 1295 def int_experimental_constrained_trunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ], 1296 [ LLVMMatchType<0>, 1297 llvm_metadata_ty ]>; 1298 1299 // Constrained floating-point comparison (quiet and signaling variants). 1300 // Third operand is the predicate represented as a metadata string. 1301 def int_experimental_constrained_fcmp 1302 : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ], 1303 [ llvm_anyfloat_ty, LLVMMatchType<0>, 1304 llvm_metadata_ty, llvm_metadata_ty ]>; 1305 def int_experimental_constrained_fcmps 1306 : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ], 1307 [ llvm_anyfloat_ty, LLVMMatchType<0>, 1308 llvm_metadata_ty, llvm_metadata_ty ]>; 1309} 1310// FIXME: Consider maybe adding intrinsics for sitofp, uitofp. 1311 1312 1313//===------------------------- Expect Intrinsics --------------------------===// 1314// 1315def int_expect : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1316 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>; 1317 1318def int_expect_with_probability : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1319 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_double_ty], 1320 [IntrNoMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>; 1321 1322//===-------------------- Bit Manipulation Intrinsics ---------------------===// 1323// 1324 1325// None of these intrinsics accesses memory at all. 1326let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in { 1327 def int_bswap: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>; 1328 def int_ctpop: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>; 1329 def int_bitreverse : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>; 1330 def int_fshl : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1331 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>; 1332 def int_fshr : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1333 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>; 1334} 1335 1336let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn, 1337 ImmArg<ArgIndex<1>>] in { 1338 def int_ctlz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>; 1339 def int_cttz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>; 1340} 1341 1342//===------------------------ Debugger Intrinsics -------------------------===// 1343// 1344 1345// None of these intrinsics accesses memory at all...but that doesn't 1346// mean the optimizers can change them aggressively. Special handling 1347// needed in a few places. These synthetic intrinsics have no 1348// side-effects and just mark information about their operands. 1349let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in { 1350 def int_dbg_declare : DefaultAttrsIntrinsic<[], 1351 [llvm_metadata_ty, 1352 llvm_metadata_ty, 1353 llvm_metadata_ty]>; 1354 def int_dbg_value : DefaultAttrsIntrinsic<[], 1355 [llvm_metadata_ty, 1356 llvm_metadata_ty, 1357 llvm_metadata_ty]>; 1358 def int_dbg_assign : DefaultAttrsIntrinsic<[], 1359 [llvm_metadata_ty, 1360 llvm_metadata_ty, 1361 llvm_metadata_ty, 1362 llvm_metadata_ty, 1363 llvm_metadata_ty, 1364 llvm_metadata_ty]>; 1365 def int_dbg_label : DefaultAttrsIntrinsic<[], 1366 [llvm_metadata_ty]>; 1367} 1368 1369//===------------------ Exception Handling Intrinsics----------------------===// 1370// 1371 1372// The result of eh.typeid.for depends on the enclosing function, but inside a 1373// given function it is 'const' and may be CSE'd etc. 1374def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>; 1375 1376def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>; 1377def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>; 1378 1379// eh.exceptionpointer returns the pointer to the exception caught by 1380// the given `catchpad`. 1381def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty], 1382 [IntrNoMem]>; 1383 1384// Gets the exception code from a catchpad token. Only used on some platforms. 1385def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>; 1386 1387// __builtin_unwind_init is an undocumented GCC intrinsic that causes all 1388// callee-saved registers to be saved and restored (regardless of whether they 1389// are used) in the calling function. It is used by libgcc_eh. 1390def int_eh_unwind_init: Intrinsic<[]>, 1391 ClangBuiltin<"__builtin_unwind_init">; 1392 1393def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>; 1394 1395def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 1396def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty], [IntrNoMem, ImmArg<ArgIndex<0>>]>; 1397 1398def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>; 1399def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; 1400def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>; 1401def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>; 1402 1403//===---------------- Generic Variable Attribute Intrinsics----------------===// 1404// 1405def int_var_annotation : DefaultAttrsIntrinsic< 1406 [], [llvm_anyptr_ty, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>], 1407 [IntrInaccessibleMemOnly], "llvm.var.annotation">; 1408 1409def int_ptr_annotation : DefaultAttrsIntrinsic< 1410 [llvm_anyptr_ty], 1411 [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>], 1412 [IntrInaccessibleMemOnly], "llvm.ptr.annotation">; 1413 1414def int_annotation : DefaultAttrsIntrinsic< 1415 [llvm_anyint_ty], 1416 [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty], 1417 [IntrInaccessibleMemOnly], "llvm.annotation">; 1418 1419// Annotates the current program point with metadata strings which are emitted 1420// as CodeView debug info records. This is expensive, as it disables inlining 1421// and is modelled as having side effects. 1422def int_codeview_annotation : DefaultAttrsIntrinsic<[], [llvm_metadata_ty], 1423 [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn], 1424 "llvm.codeview.annotation">; 1425 1426//===------------------------ Trampoline Intrinsics -----------------------===// 1427// 1428def int_init_trampoline : DefaultAttrsIntrinsic< 1429 [], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1430 [IntrArgMemOnly, NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>, 1431 ReadNone<ArgIndex<1>>, ReadNone<ArgIndex<2>>]>, 1432 ClangBuiltin<"__builtin_init_trampoline">; 1433 1434def int_adjust_trampoline : DefaultAttrsIntrinsic< 1435 [llvm_ptr_ty], [llvm_ptr_ty], [IntrReadMem, IntrArgMemOnly]>, 1436 ClangBuiltin<"__builtin_adjust_trampoline">; 1437 1438//===------------------------ Overflow Intrinsics -------------------------===// 1439// 1440 1441// Expose the carry flag from add operations on two integrals. 1442let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in { 1443 def int_sadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty, 1444 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1445 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1446 def int_uadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty, 1447 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1448 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1449 1450 def int_ssub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty, 1451 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1452 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1453 def int_usub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty, 1454 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1455 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1456 1457 def int_smul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty, 1458 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1459 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1460 def int_umul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty, 1461 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 1462 [LLVMMatchType<0>, LLVMMatchType<0>]>; 1463} 1464//===------------------------- Saturation Arithmetic Intrinsics ---------------------===// 1465// 1466def int_sadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1467 [LLVMMatchType<0>, LLVMMatchType<0>], 1468 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>; 1469def int_uadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1470 [LLVMMatchType<0>, LLVMMatchType<0>], 1471 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>; 1472def int_ssub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1473 [LLVMMatchType<0>, LLVMMatchType<0>], 1474 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1475def int_usub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1476 [LLVMMatchType<0>, LLVMMatchType<0>], 1477 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1478def int_sshl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1479 [LLVMMatchType<0>, LLVMMatchType<0>], 1480 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1481def int_ushl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1482 [LLVMMatchType<0>, LLVMMatchType<0>], 1483 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1484 1485//===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===// 1486// 1487def int_smul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1488 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1489 [IntrNoMem, IntrSpeculatable, IntrWillReturn, 1490 Commutative, ImmArg<ArgIndex<2>>]>; 1491 1492def int_umul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1493 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1494 [IntrNoMem, IntrSpeculatable, IntrWillReturn, 1495 Commutative, ImmArg<ArgIndex<2>>]>; 1496 1497def int_sdiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1498 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1499 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 1500 1501def int_udiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1502 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1503 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 1504 1505//===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===// 1506// 1507def int_smul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1508 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1509 [IntrNoMem, IntrSpeculatable, IntrWillReturn, 1510 Commutative, ImmArg<ArgIndex<2>>]>; 1511def int_umul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1512 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1513 [IntrNoMem, IntrSpeculatable, IntrWillReturn, 1514 Commutative, ImmArg<ArgIndex<2>>]>; 1515 1516def int_sdiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1517 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1518 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 1519 1520def int_udiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], 1521 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], 1522 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 1523 1524//===------------------ Integer Min/Max/Abs Intrinsics --------------------===// 1525// 1526def int_abs : DefaultAttrsIntrinsic< 1527 [llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty], 1528 [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<ArgIndex<1>>]>; 1529 1530def int_smax : DefaultAttrsIntrinsic< 1531 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>], 1532 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1533def int_smin : DefaultAttrsIntrinsic< 1534 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>], 1535 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1536def int_umax : DefaultAttrsIntrinsic< 1537 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>], 1538 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1539def int_umin : DefaultAttrsIntrinsic< 1540 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>], 1541 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1542def int_scmp : DefaultAttrsIntrinsic< 1543 [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>], 1544 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1545def int_ucmp : DefaultAttrsIntrinsic< 1546 [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>], 1547 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1548 1549//===------------------------- Memory Use Markers -------------------------===// 1550// 1551def int_lifetime_start : DefaultAttrsIntrinsic<[], 1552 [llvm_i64_ty, llvm_anyptr_ty], 1553 [IntrArgMemOnly, IntrWillReturn, 1554 NoCapture<ArgIndex<1>>, 1555 ImmArg<ArgIndex<0>>]>; 1556def int_lifetime_end : DefaultAttrsIntrinsic<[], 1557 [llvm_i64_ty, llvm_anyptr_ty], 1558 [IntrArgMemOnly, IntrWillReturn, 1559 NoCapture<ArgIndex<1>>, 1560 ImmArg<ArgIndex<0>>]>; 1561def int_invariant_start : DefaultAttrsIntrinsic<[llvm_ptr_ty], 1562 [llvm_i64_ty, llvm_anyptr_ty], 1563 [IntrArgMemOnly, IntrWillReturn, 1564 NoCapture<ArgIndex<1>>, 1565 ImmArg<ArgIndex<0>>]>; 1566def int_invariant_end : DefaultAttrsIntrinsic<[], 1567 [llvm_ptr_ty, llvm_i64_ty, 1568 llvm_anyptr_ty], 1569 [IntrArgMemOnly, IntrWillReturn, 1570 NoCapture<ArgIndex<2>>, 1571 ImmArg<ArgIndex<1>>]>; 1572 1573// launder.invariant.group can't be marked with 'readnone' (IntrNoMem), 1574// because it would cause CSE of two barriers with the same argument. 1575// Inaccessiblememonly says that the barrier doesn't read the argument, 1576// but it changes state not accessible to this module. This way 1577// we can DSE through the barrier because it doesn't read the value 1578// after store. Although the barrier doesn't modify any memory it 1579// can't be marked as readonly, because it would be possible to 1580// CSE 2 barriers with store in between. 1581// The argument also can't be marked with 'returned' attribute, because 1582// it would remove barrier. 1583// Note that it is still experimental, which means that its semantics 1584// might change in the future. 1585def int_launder_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty], 1586 [LLVMMatchType<0>], 1587 [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>; 1588 1589 1590def int_strip_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty], 1591 [LLVMMatchType<0>], 1592 [IntrSpeculatable, IntrNoMem, IntrWillReturn]>; 1593 1594//===------------------------ Stackmap Intrinsics -------------------------===// 1595// 1596def int_experimental_stackmap : DefaultAttrsIntrinsic<[], 1597 [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty], 1598 [Throws]>; 1599def int_experimental_patchpoint_void : Intrinsic<[], 1600 [llvm_i64_ty, llvm_i32_ty, 1601 llvm_ptr_ty, llvm_i32_ty, 1602 llvm_vararg_ty], 1603 [Throws]>; 1604def int_experimental_patchpoint : Intrinsic<[llvm_any_ty], 1605 [llvm_i64_ty, llvm_i32_ty, 1606 llvm_ptr_ty, llvm_i32_ty, 1607 llvm_vararg_ty], 1608 [Throws]>; 1609 1610 1611//===------------------------ Garbage Collection Intrinsics ---------------===// 1612// These are documented in docs/Statepoint.rst 1613 1614def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty], 1615 [llvm_i64_ty, llvm_i32_ty, 1616 llvm_anyptr_ty, llvm_i32_ty, 1617 llvm_i32_ty, llvm_vararg_ty], 1618 [Throws, ImmArg<ArgIndex<0>>, 1619 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<3>>, 1620 ImmArg<ArgIndex<4>>]>; 1621 1622def int_experimental_gc_result : DefaultAttrsIntrinsic< 1623 [llvm_any_ty], [llvm_token_ty], [IntrNoMem]>; 1624 1625def int_experimental_gc_relocate : DefaultAttrsIntrinsic< 1626 [llvm_any_ty], [llvm_token_ty, llvm_i32_ty, llvm_i32_ty], 1627 [IntrNoMem, ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>; 1628 1629def int_experimental_gc_get_pointer_base : DefaultAttrsIntrinsic< 1630 [llvm_anyptr_ty], [llvm_anyptr_ty], 1631 [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>; 1632 1633def int_experimental_gc_get_pointer_offset : DefaultAttrsIntrinsic< 1634 [llvm_i64_ty], [llvm_anyptr_ty], 1635 [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>; 1636 1637//===------------------------ Coroutine Intrinsics ---------------===// 1638// These are documented in docs/Coroutines.rst 1639 1640// Coroutine Structure Intrinsics. 1641 1642def int_coro_id : DefaultAttrsIntrinsic<[llvm_token_ty], 1643 [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1644 [IntrArgMemOnly, IntrReadMem, ReadNone<ArgIndex<1>>, ReadOnly<ArgIndex<2>>, 1645 NoCapture<ArgIndex<2>>]>; 1646def int_coro_id_retcon : Intrinsic<[llvm_token_ty], 1647 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, 1648 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1649 []>; 1650def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty], 1651 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, 1652 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1653 []>; 1654def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>; 1655def int_coro_id_async : Intrinsic<[llvm_token_ty], 1656 [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty], 1657 []>; 1658def int_coro_async_context_alloc : Intrinsic<[llvm_ptr_ty], 1659 [llvm_ptr_ty, llvm_ptr_ty], 1660 []>; 1661def int_coro_async_context_dealloc : Intrinsic<[], 1662 [llvm_ptr_ty], 1663 []>; 1664def int_coro_async_resume : Intrinsic<[llvm_ptr_ty], 1665 [], 1666 [IntrNoMerge]>; 1667def int_coro_async_size_replace : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>; 1668def int_coro_suspend_async 1669 : Intrinsic<[llvm_any_ty], 1670 [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty], 1671 [IntrNoMerge]>; 1672def int_coro_prepare_async : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty], 1673 [IntrNoMem]>; 1674def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty], 1675 [WriteOnly<ArgIndex<1>>]>; 1676 1677def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty], 1678 [IntrReadMem, IntrArgMemOnly, 1679 ReadOnly<ArgIndex<1>>, 1680 NoCapture<ArgIndex<1>>]>; 1681def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_token_ty], []>; 1682def int_coro_end_results : Intrinsic<[llvm_token_ty], [llvm_vararg_ty]>; 1683def int_coro_end_async 1684 : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_vararg_ty], []>; 1685 1686def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 1687def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 1688def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>; 1689def int_coro_align : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>; 1690 1691def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], [IntrNoMerge]>; 1692def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>; 1693def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>; 1694def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty], 1695 [IntrNoMem]>; 1696def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty], 1697 [llvm_anyint_ty, llvm_i32_ty], []>; 1698def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>; 1699def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>; 1700 1701// Coroutine Manipulation Intrinsics. 1702 1703def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>; 1704def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>; 1705def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty], 1706 [IntrArgMemOnly, ReadOnly<ArgIndex<0>>, 1707 NoCapture<ArgIndex<0>>]>; 1708def int_coro_promise : Intrinsic<[llvm_ptr_ty], 1709 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty], 1710 [IntrNoMem, NoCapture<ArgIndex<0>>]>; 1711 1712def int_coro_await_suspend_void : Intrinsic<[], 1713 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1714 [Throws]>; 1715 1716def int_coro_await_suspend_bool : Intrinsic<[llvm_i1_ty], 1717 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1718 [Throws]>; 1719 1720def int_coro_await_suspend_handle : Intrinsic<[llvm_ptr_ty], 1721 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 1722 [Throws]>; 1723 1724// Coroutine Lowering Intrinsics. Used internally by coroutine passes. 1725 1726def int_coro_subfn_addr : DefaultAttrsIntrinsic< 1727 [llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty], 1728 [IntrReadMem, IntrArgMemOnly, ReadOnly<ArgIndex<0>>, 1729 NoCapture<ArgIndex<0>>]>; 1730 1731///===-------------------------- Other Intrinsics --------------------------===// 1732// 1733// TODO: We should introduce a new memory kind fo traps (and other side effects 1734// we only model to keep things alive). 1735def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold, IntrInaccessibleMemOnly, 1736 IntrWriteMem]>, ClangBuiltin<"__builtin_trap">; 1737def int_debugtrap : Intrinsic<[]>, 1738 ClangBuiltin<"__builtin_debugtrap">; 1739def int_ubsantrap : Intrinsic<[], [llvm_i8_ty], 1740 [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>; 1741 1742// Return true if ubsan check is allowed. 1743def int_allow_ubsan_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i8_ty], 1744 [IntrInaccessibleMemOnly, IntrWriteMem, ImmArg<ArgIndex<0>>, NoUndef<RetIndex>]>; 1745 1746// Return true if runtime check is allowed. 1747def int_allow_runtime_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_metadata_ty], 1748 [IntrInaccessibleMemOnly, IntrWriteMem, NoUndef<RetIndex>]>, 1749 ClangBuiltin<"__builtin_allow_runtime_check">; 1750 1751// Support for dynamic deoptimization (or de-specialization) 1752def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], 1753 [Throws]>; 1754 1755// Support for speculative runtime guards 1756def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty], 1757 [Throws]>; 1758 1759// Supports widenable conditions for guards represented as explicit branches. 1760def int_experimental_widenable_condition : DefaultAttrsIntrinsic<[llvm_i1_ty], [], 1761 [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable, NoUndef<RetIndex>]>; 1762 1763// NOP: calls/invokes to this intrinsic are removed by codegen 1764def int_donothing : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrWillReturn]>; 1765 1766// This instruction has no actual effect, though it is treated by the optimizer 1767// has having opaque side effects. This may be inserted into loops to ensure 1768// that they are not removed even if they turn out to be empty, for languages 1769// which specify that infinite loops must be preserved. 1770def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>; 1771 1772// The pseudoprobe intrinsic works as a place holder to the block it probes. 1773// Like the sideeffect intrinsic defined above, this intrinsic is treated by the 1774// optimizer as having opaque side effects so that it won't be get rid of or moved 1775// out of the block it probes. 1776def int_pseudoprobe : DefaultAttrsIntrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty], 1777 [IntrInaccessibleMemOnly, IntrWillReturn]>; 1778 1779// Intrinsics to support half precision floating point format 1780let IntrProperties = [IntrNoMem, IntrWillReturn] in { 1781def int_convert_to_fp16 : DefaultAttrsIntrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>; 1782def int_convert_from_fp16 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>; 1783} 1784 1785// Saturating floating point to integer intrinsics 1786let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in { 1787def int_fptoui_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>; 1788def int_fptosi_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>; 1789} 1790 1791// Clear cache intrinsic, default to ignore (ie. emit nothing) 1792// maps to void __clear_cache() on supporting platforms 1793def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], 1794 [], "llvm.clear_cache">; 1795 1796// Intrinsic to detect whether its argument is a constant. 1797def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty], 1798 [IntrNoMem, IntrWillReturn, IntrConvergent], 1799 "llvm.is.constant">; 1800 1801// Intrinsic to mask out bits of a pointer. 1802// First argument must be pointer or vector of pointer. This is checked by the 1803// verifier. 1804def int_ptrmask: DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, llvm_anyint_ty], 1805 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1806 1807// Intrinsic to wrap a thread local variable. 1808def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>], 1809 [NonNull<RetIndex>, NonNull<ArgIndex<0>>, 1810 IntrNoMem, IntrSpeculatable, IntrWillReturn]>; 1811 1812def int_experimental_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 1813 [], [IntrNoMem]>; 1814 1815//===---------------- Vector Predication Intrinsics --------------===// 1816// Memory Intrinsics 1817def int_vp_store : DefaultAttrsIntrinsic<[], 1818 [ llvm_anyvector_ty, 1819 llvm_anyptr_ty, 1820 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1821 llvm_i32_ty], 1822 [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>; 1823 1824def int_vp_load : DefaultAttrsIntrinsic<[ llvm_anyvector_ty], 1825 [ llvm_anyptr_ty, 1826 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1827 llvm_i32_ty], 1828 [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>; 1829 1830def int_vp_gather: DefaultAttrsIntrinsic<[ llvm_anyvector_ty], 1831 [ LLVMVectorOfAnyPointersToElt<0>, 1832 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1833 llvm_i32_ty], 1834 [ IntrReadMem, IntrNoSync, IntrWillReturn]>; 1835 1836def int_vp_scatter: DefaultAttrsIntrinsic<[], 1837 [ llvm_anyvector_ty, 1838 LLVMVectorOfAnyPointersToElt<0>, 1839 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1840 llvm_i32_ty], 1841 [ IntrNoSync, IntrWillReturn ]>; // TODO allow IntrNoCapture for vectors of pointers 1842 1843// Experimental strided memory accesses 1844def int_experimental_vp_strided_store : DefaultAttrsIntrinsic<[], 1845 [ llvm_anyvector_ty, 1846 llvm_anyptr_ty, 1847 llvm_anyint_ty, // Stride in bytes 1848 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1849 llvm_i32_ty], 1850 [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>; 1851 1852def int_experimental_vp_strided_load : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 1853 [ llvm_anyptr_ty, 1854 llvm_anyint_ty, // Stride in bytes 1855 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1856 llvm_i32_ty], 1857 [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>; 1858 1859// Operators 1860let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn] in { 1861 // Integer arithmetic 1862 def int_vp_add : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1863 [ LLVMMatchType<0>, 1864 LLVMMatchType<0>, 1865 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1866 llvm_i32_ty]>; 1867 def int_vp_sub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1868 [ LLVMMatchType<0>, 1869 LLVMMatchType<0>, 1870 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1871 llvm_i32_ty]>; 1872 def int_vp_mul : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1873 [ LLVMMatchType<0>, 1874 LLVMMatchType<0>, 1875 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1876 llvm_i32_ty]>; 1877 def int_vp_ashr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1878 [ LLVMMatchType<0>, 1879 LLVMMatchType<0>, 1880 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1881 llvm_i32_ty]>; 1882 def int_vp_lshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1883 [ LLVMMatchType<0>, 1884 LLVMMatchType<0>, 1885 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1886 llvm_i32_ty]>; 1887 def int_vp_shl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1888 [ LLVMMatchType<0>, 1889 LLVMMatchType<0>, 1890 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1891 llvm_i32_ty]>; 1892 def int_vp_or : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1893 [ LLVMMatchType<0>, 1894 LLVMMatchType<0>, 1895 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1896 llvm_i32_ty]>; 1897 def int_vp_and : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1898 [ LLVMMatchType<0>, 1899 LLVMMatchType<0>, 1900 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1901 llvm_i32_ty]>; 1902 def int_vp_xor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1903 [ LLVMMatchType<0>, 1904 LLVMMatchType<0>, 1905 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1906 llvm_i32_ty]>; 1907 def int_vp_sdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1908 [ LLVMMatchType<0>, 1909 LLVMMatchType<0>, 1910 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1911 llvm_i32_ty]>; 1912 def int_vp_udiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1913 [ LLVMMatchType<0>, 1914 LLVMMatchType<0>, 1915 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1916 llvm_i32_ty]>; 1917 def int_vp_srem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1918 [ LLVMMatchType<0>, 1919 LLVMMatchType<0>, 1920 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1921 llvm_i32_ty]>; 1922 def int_vp_urem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1923 [ LLVMMatchType<0>, 1924 LLVMMatchType<0>, 1925 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1926 llvm_i32_ty]>; 1927 def int_vp_abs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1928 [ LLVMMatchType<0>, 1929 llvm_i1_ty, 1930 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1931 llvm_i32_ty]>; 1932 def int_vp_smin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1933 [ LLVMMatchType<0>, 1934 LLVMMatchType<0>, 1935 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1936 llvm_i32_ty]>; 1937 def int_vp_smax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1938 [ LLVMMatchType<0>, 1939 LLVMMatchType<0>, 1940 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1941 llvm_i32_ty]>; 1942 def int_vp_umin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1943 [ LLVMMatchType<0>, 1944 LLVMMatchType<0>, 1945 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1946 llvm_i32_ty]>; 1947 def int_vp_umax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1948 [ LLVMMatchType<0>, 1949 LLVMMatchType<0>, 1950 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1951 llvm_i32_ty]>; 1952 def int_vp_bswap : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1953 [ LLVMMatchType<0>, 1954 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1955 llvm_i32_ty]>; 1956 def int_vp_bitreverse : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1957 [ LLVMMatchType<0>, 1958 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1959 llvm_i32_ty]>; 1960 def int_vp_ctpop : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1961 [ LLVMMatchType<0>, 1962 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1963 llvm_i32_ty]>; 1964 def int_vp_fshl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1965 [ LLVMMatchType<0>, 1966 LLVMMatchType<0>, 1967 LLVMMatchType<0>, 1968 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1969 llvm_i32_ty]>; 1970 def int_vp_fshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1971 [ LLVMMatchType<0>, 1972 LLVMMatchType<0>, 1973 LLVMMatchType<0>, 1974 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1975 llvm_i32_ty]>; 1976 def int_vp_sadd_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1977 [ LLVMMatchType<0>, 1978 LLVMMatchType<0>, 1979 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1980 llvm_i32_ty]>; 1981 def int_vp_uadd_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1982 [ LLVMMatchType<0>, 1983 LLVMMatchType<0>, 1984 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1985 llvm_i32_ty]>; 1986 def int_vp_ssub_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1987 [ LLVMMatchType<0>, 1988 LLVMMatchType<0>, 1989 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1990 llvm_i32_ty]>; 1991 def int_vp_usub_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1992 [ LLVMMatchType<0>, 1993 LLVMMatchType<0>, 1994 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 1995 llvm_i32_ty]>; 1996 1997 // Floating-point arithmetic 1998 def int_vp_fadd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 1999 [ LLVMMatchType<0>, 2000 LLVMMatchType<0>, 2001 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2002 llvm_i32_ty]>; 2003 def int_vp_fsub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2004 [ LLVMMatchType<0>, 2005 LLVMMatchType<0>, 2006 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2007 llvm_i32_ty]>; 2008 def int_vp_fmul : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2009 [ LLVMMatchType<0>, 2010 LLVMMatchType<0>, 2011 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2012 llvm_i32_ty]>; 2013 def int_vp_fdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2014 [ LLVMMatchType<0>, 2015 LLVMMatchType<0>, 2016 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2017 llvm_i32_ty]>; 2018 def int_vp_frem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2019 [ LLVMMatchType<0>, 2020 LLVMMatchType<0>, 2021 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2022 llvm_i32_ty]>; 2023 def int_vp_fneg : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2024 [ LLVMMatchType<0>, 2025 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2026 llvm_i32_ty]>; 2027 def int_vp_fabs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2028 [ LLVMMatchType<0>, 2029 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2030 llvm_i32_ty]>; 2031 def int_vp_sqrt : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2032 [ LLVMMatchType<0>, 2033 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2034 llvm_i32_ty]>; 2035 def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2036 [ LLVMMatchType<0>, 2037 LLVMMatchType<0>, 2038 LLVMMatchType<0>, 2039 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2040 llvm_i32_ty]>; 2041 def int_vp_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2042 [ LLVMMatchType<0>, 2043 LLVMMatchType<0>, 2044 LLVMMatchType<0>, 2045 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2046 llvm_i32_ty]>; 2047 def int_vp_minnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2048 [ LLVMMatchType<0>, 2049 LLVMMatchType<0>, 2050 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2051 llvm_i32_ty]>; 2052 def int_vp_maxnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2053 [ LLVMMatchType<0>, 2054 LLVMMatchType<0>, 2055 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2056 llvm_i32_ty]>; 2057 def int_vp_minimum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2058 [ LLVMMatchType<0>, 2059 LLVMMatchType<0>, 2060 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2061 llvm_i32_ty]>; 2062 def int_vp_maximum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2063 [ LLVMMatchType<0>, 2064 LLVMMatchType<0>, 2065 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2066 llvm_i32_ty]>; 2067 def int_vp_copysign : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2068 [ LLVMMatchType<0>, 2069 LLVMMatchType<0>, 2070 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2071 llvm_i32_ty]>; 2072 def int_vp_ceil : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2073 [ LLVMMatchType<0>, 2074 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2075 llvm_i32_ty]>; 2076 def int_vp_floor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2077 [ LLVMMatchType<0>, 2078 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2079 llvm_i32_ty]>; 2080 def int_vp_round : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2081 [ LLVMMatchType<0>, 2082 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2083 llvm_i32_ty]>; 2084 def int_vp_roundeven : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2085 [ LLVMMatchType<0>, 2086 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2087 llvm_i32_ty]>; 2088 def int_vp_roundtozero : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2089 [ LLVMMatchType<0>, 2090 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2091 llvm_i32_ty]>; 2092 def int_vp_rint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2093 [ LLVMMatchType<0>, 2094 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2095 llvm_i32_ty]>; 2096 def int_vp_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2097 [ LLVMMatchType<0>, 2098 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2099 llvm_i32_ty]>; 2100 def int_vp_lrint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2101 [ llvm_anyvector_ty, 2102 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2103 llvm_i32_ty]>; 2104 def int_vp_llrint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2105 [ llvm_anyvector_ty, 2106 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2107 llvm_i32_ty]>; 2108 2109 // Casts 2110 def int_vp_trunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2111 [ llvm_anyvector_ty, 2112 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2113 llvm_i32_ty]>; 2114 def int_vp_zext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2115 [ llvm_anyvector_ty, 2116 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2117 llvm_i32_ty]>; 2118 def int_vp_sext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2119 [ llvm_anyvector_ty, 2120 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2121 llvm_i32_ty]>; 2122 def int_vp_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2123 [ llvm_anyvector_ty, 2124 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2125 llvm_i32_ty]>; 2126 def int_vp_fpext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2127 [ llvm_anyvector_ty, 2128 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2129 llvm_i32_ty]>; 2130 def int_vp_fptoui : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2131 [ llvm_anyvector_ty, 2132 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2133 llvm_i32_ty]>; 2134 def int_vp_fptosi : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2135 [ llvm_anyvector_ty, 2136 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2137 llvm_i32_ty]>; 2138 def int_vp_uitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2139 [ llvm_anyvector_ty, 2140 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2141 llvm_i32_ty]>; 2142 def int_vp_sitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2143 [ llvm_anyvector_ty, 2144 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2145 llvm_i32_ty]>; 2146 def int_vp_ptrtoint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2147 [ llvm_anyvector_ty, 2148 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2149 llvm_i32_ty]>; 2150 def int_vp_inttoptr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2151 [ llvm_anyvector_ty, 2152 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2153 llvm_i32_ty]>; 2154 // Shuffles 2155 def int_vp_select : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2156 [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2157 LLVMMatchType<0>, 2158 LLVMMatchType<0>, 2159 llvm_i32_ty]>; 2160 def int_vp_merge : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2161 [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2162 LLVMMatchType<0>, 2163 LLVMMatchType<0>, 2164 llvm_i32_ty]>; 2165 2166 // Comparisons 2167 def int_vp_fcmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ], 2168 [ llvm_anyvector_ty, 2169 LLVMMatchType<0>, 2170 llvm_metadata_ty, 2171 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2172 llvm_i32_ty]>; 2173 def int_vp_icmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ], 2174 [ llvm_anyvector_ty, 2175 LLVMMatchType<0>, 2176 llvm_metadata_ty, 2177 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2178 llvm_i32_ty]>; 2179 2180 // Reductions 2181 def int_vp_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2182 [ LLVMVectorElementType<0>, 2183 llvm_anyvector_ty, 2184 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2185 llvm_i32_ty]>; 2186 def int_vp_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2187 [ LLVMVectorElementType<0>, 2188 llvm_anyvector_ty, 2189 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2190 llvm_i32_ty]>; 2191 def int_vp_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2192 [ LLVMVectorElementType<0>, 2193 llvm_anyvector_ty, 2194 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2195 llvm_i32_ty]>; 2196 def int_vp_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2197 [ LLVMVectorElementType<0>, 2198 llvm_anyvector_ty, 2199 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2200 llvm_i32_ty]>; 2201 def int_vp_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2202 [ LLVMVectorElementType<0>, 2203 llvm_anyvector_ty, 2204 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2205 llvm_i32_ty]>; 2206 def int_vp_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2207 [ LLVMVectorElementType<0>, 2208 llvm_anyvector_ty, 2209 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2210 llvm_i32_ty]>; 2211 def int_vp_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2212 [ LLVMVectorElementType<0>, 2213 llvm_anyvector_ty, 2214 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2215 llvm_i32_ty]>; 2216 def int_vp_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2217 [ LLVMVectorElementType<0>, 2218 llvm_anyvector_ty, 2219 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2220 llvm_i32_ty]>; 2221 def int_vp_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2222 [ LLVMVectorElementType<0>, 2223 llvm_anyvector_ty, 2224 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2225 llvm_i32_ty]>; 2226 def int_vp_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2227 [ LLVMVectorElementType<0>, 2228 llvm_anyvector_ty, 2229 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2230 llvm_i32_ty]>; 2231 def int_vp_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2232 [ LLVMVectorElementType<0>, 2233 llvm_anyvector_ty, 2234 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2235 llvm_i32_ty]>; 2236 def int_vp_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2237 [ LLVMVectorElementType<0>, 2238 llvm_anyvector_ty, 2239 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2240 llvm_i32_ty]>; 2241 def int_vp_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2242 [ LLVMVectorElementType<0>, 2243 llvm_anyvector_ty, 2244 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2245 llvm_i32_ty]>; 2246} 2247 2248let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<1>>] in { 2249 def int_vp_ctlz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2250 [ LLVMMatchType<0>, 2251 llvm_i1_ty, 2252 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2253 llvm_i32_ty]>; 2254 def int_vp_cttz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], 2255 [ LLVMMatchType<0>, 2256 llvm_i1_ty, 2257 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2258 llvm_i32_ty]>; 2259 2260 def int_vp_cttz_elts : DefaultAttrsIntrinsic<[ llvm_anyint_ty ], 2261 [ llvm_anyvector_ty, 2262 llvm_i1_ty, 2263 LLVMScalarOrSameVectorWidth<1, llvm_i1_ty>, 2264 llvm_i32_ty]>; 2265} 2266 2267def int_get_active_lane_mask: 2268 DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2269 [llvm_anyint_ty, LLVMMatchType<1>], 2270 [IntrNoMem, IntrNoSync, IntrWillReturn]>; 2271 2272def int_experimental_get_vector_length: 2273 DefaultAttrsIntrinsic<[llvm_i32_ty], 2274 [llvm_anyint_ty, llvm_i32_ty, llvm_i1_ty], 2275 [IntrNoMem, IntrNoSync, IntrWillReturn, 2276 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>; 2277 2278def int_experimental_cttz_elts: 2279 DefaultAttrsIntrinsic<[llvm_anyint_ty], 2280 [llvm_anyvector_ty, llvm_i1_ty], 2281 [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<1>>]>; 2282 2283def int_experimental_vp_splice: 2284 DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2285 [LLVMMatchType<0>, 2286 LLVMMatchType<0>, 2287 llvm_i32_ty, 2288 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2289 llvm_i32_ty, llvm_i32_ty], 2290 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 2291 2292def int_experimental_vp_reverse: 2293 DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2294 [LLVMMatchType<0>, 2295 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2296 llvm_i32_ty], 2297 [IntrNoMem]>; 2298 2299def int_vp_is_fpclass: 2300 DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 2301 [ llvm_anyvector_ty, 2302 llvm_i32_ty, 2303 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2304 llvm_i32_ty], 2305 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>; 2306 2307//===-------------------------- Masked Intrinsics -------------------------===// 2308// 2309def int_masked_load: 2310 DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2311 [llvm_anyptr_ty, llvm_i32_ty, 2312 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>], 2313 [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<ArgIndex<1>>, 2314 NoCapture<ArgIndex<0>>]>; 2315 2316def int_masked_store: 2317 DefaultAttrsIntrinsic<[], 2318 [llvm_anyvector_ty, llvm_anyptr_ty, 2319 llvm_i32_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 2320 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, 2321 ImmArg<ArgIndex<2>>, NoCapture<ArgIndex<1>>]>; 2322 2323def int_masked_gather: 2324 DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2325 [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty, 2326 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>], 2327 [IntrReadMem, IntrWillReturn, ImmArg<ArgIndex<1>>]>; 2328 2329def int_masked_scatter: 2330 DefaultAttrsIntrinsic<[], 2331 [llvm_anyvector_ty, LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty, 2332 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 2333 [IntrWriteMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>; 2334 2335def int_masked_expandload: 2336 DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2337 [llvm_ptr_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, 2338 LLVMMatchType<0>], 2339 [IntrReadMem, IntrWillReturn, NoCapture<ArgIndex<0>>]>; 2340 2341def int_masked_compressstore: 2342 DefaultAttrsIntrinsic<[], 2343 [llvm_anyvector_ty, llvm_ptr_ty, 2344 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], 2345 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, 2346 NoCapture<ArgIndex<1>>]>; 2347 2348// Test whether a pointer is associated with a type metadata identifier. 2349def int_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty], 2350 [IntrNoMem, IntrWillReturn, IntrSpeculatable]>; 2351 2352// Safely loads a function pointer from a virtual table pointer using type metadata. 2353def int_type_checked_load : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty], 2354 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty], 2355 [IntrNoMem, IntrWillReturn]>; 2356 2357// Safely loads a relative function pointer from a virtual table pointer using type metadata. 2358def int_type_checked_load_relative : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty], 2359 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty], 2360 [IntrNoMem, IntrWillReturn]>; 2361 2362// Test whether a pointer is associated with a type metadata identifier. Used 2363// for public visibility classes that may later be refined to private 2364// visibility. 2365def int_public_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty], 2366 [IntrNoMem, IntrWillReturn, IntrSpeculatable]>; 2367 2368// Create a branch funnel that implements an indirect call to a limited set of 2369// callees. This needs to be a musttail call. 2370def int_icall_branch_funnel : DefaultAttrsIntrinsic<[], [llvm_vararg_ty], []>; 2371 2372def int_load_relative: DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty], 2373 [IntrReadMem, IntrArgMemOnly]>; 2374 2375def int_asan_check_memaccess : 2376 Intrinsic<[],[llvm_ptr_ty, llvm_i32_ty], [ImmArg<ArgIndex<1>>]>; 2377 2378// HWASan intrinsics to test whether a pointer is addressable. 2379//===----------------------------------------------------------------------===// 2380// 2381// Variant 1) is the OG memaccess intrinsic 2382// Parameters: Shadow base (passed in a register), pointer to be checked for 2383// validity, AccessInfo (AccessInfo is defined in HWAddressSanitizer.h) 2384def int_hwasan_check_memaccess : 2385 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], 2386 [ImmArg<ArgIndex<2>>]>; 2387 2388// Variant 2) supports short granule checks 2389// Parameters: same as Variant 1 2390def int_hwasan_check_memaccess_shortgranules : 2391 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], 2392 [ImmArg<ArgIndex<2>>]>; 2393 2394// Variant 3) assumes a fixed shadow offset 2395// Parameters: Pointer to be checked for validity, AccessInfo, Shadow base 2396def int_hwasan_check_memaccess_fixedshadow : 2397 Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i64_ty], 2398 [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>; 2399 2400// Variant 4) supports short granule checks and assumes a fixed shadow offset 2401// Parameters: same as Variant 3 2402def int_hwasan_check_memaccess_shortgranules_fixedshadow : 2403 Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i64_ty], 2404 [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>; 2405 2406// Xray intrinsics 2407//===----------------------------------------------------------------------===// 2408// Custom event logging for x-ray. 2409// Takes a pointer to a string and the length of the string. 2410def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty], 2411 [IntrWriteMem, NoCapture<ArgIndex<0>>, 2412 ReadOnly<ArgIndex<0>>]>; 2413// Typed event logging for x-ray. 2414// Takes a numeric type tag, a pointer to a string and the length of the string. 2415def int_xray_typedevent : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty, llvm_i64_ty], 2416 [IntrWriteMem, NoCapture<ArgIndex<1>>, 2417 ReadOnly<ArgIndex<1>>]>; 2418//===----------------------------------------------------------------------===// 2419 2420//===------ Memory intrinsics with element-wise atomicity guarantees ------===// 2421// 2422 2423// @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize) 2424def int_memcpy_element_unordered_atomic 2425 : Intrinsic<[], 2426 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty], 2427 [IntrArgMemOnly, IntrWillReturn, IntrNoSync, 2428 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>, 2429 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>, 2430 ImmArg<ArgIndex<3>>]>; 2431 2432// @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize) 2433def int_memmove_element_unordered_atomic 2434 : Intrinsic<[], 2435 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty], 2436 [IntrArgMemOnly, IntrWillReturn, IntrNoSync, 2437 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>, 2438 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>, 2439 ImmArg<ArgIndex<3>>]>; 2440 2441// @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize) 2442def int_memset_element_unordered_atomic 2443 : Intrinsic<[], [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty], 2444 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoSync, 2445 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>, 2446 ImmArg<ArgIndex<3>>]>; 2447 2448//===------------------------ Reduction Intrinsics ------------------------===// 2449// 2450let IntrProperties = [IntrNoMem, IntrSpeculatable] in { 2451 2452 def int_vector_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2453 [LLVMVectorElementType<0>, 2454 llvm_anyvector_ty]>; 2455 def int_vector_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2456 [LLVMVectorElementType<0>, 2457 llvm_anyvector_ty]>; 2458 def int_vector_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2459 [llvm_anyvector_ty]>; 2460 def int_vector_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2461 [llvm_anyvector_ty]>; 2462 def int_vector_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2463 [llvm_anyvector_ty]>; 2464 def int_vector_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2465 [llvm_anyvector_ty]>; 2466 def int_vector_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2467 [llvm_anyvector_ty]>; 2468 def int_vector_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2469 [llvm_anyvector_ty]>; 2470 def int_vector_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2471 [llvm_anyvector_ty]>; 2472 def int_vector_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2473 [llvm_anyvector_ty]>; 2474 def int_vector_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2475 [llvm_anyvector_ty]>; 2476 def int_vector_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2477 [llvm_anyvector_ty]>; 2478 def int_vector_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2479 [llvm_anyvector_ty]>; 2480 def int_vector_reduce_fminimum: DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2481 [llvm_anyvector_ty]>; 2482 def int_vector_reduce_fmaximum: DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 2483 [llvm_anyvector_ty]>; 2484} 2485 2486//===----- Matrix intrinsics ---------------------------------------------===// 2487 2488def int_matrix_transpose 2489 : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2490 [LLVMMatchType<0>, llvm_i32_ty, llvm_i32_ty], 2491 [ IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>, 2492 ImmArg<ArgIndex<2>>]>; 2493 2494def int_matrix_multiply 2495 : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2496 [llvm_anyvector_ty, llvm_anyvector_ty, llvm_i32_ty, llvm_i32_ty, 2497 llvm_i32_ty], 2498 [IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>, 2499 ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>]>; 2500 2501def int_matrix_column_major_load 2502 : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2503 [llvm_ptr_ty, llvm_anyint_ty, llvm_i1_ty, 2504 llvm_i32_ty, llvm_i32_ty], 2505 [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrReadMem, 2506 NoCapture<ArgIndex<0>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>, 2507 ImmArg<ArgIndex<4>>]>; 2508 2509def int_matrix_column_major_store 2510 : DefaultAttrsIntrinsic<[], 2511 [llvm_anyvector_ty, llvm_ptr_ty, 2512 llvm_anyint_ty, llvm_i1_ty, llvm_i32_ty, llvm_i32_ty], 2513 [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrWriteMem, 2514 WriteOnly<ArgIndex<1>>, NoCapture<ArgIndex<1>>, 2515 ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>, ImmArg<ArgIndex<5>>]>; 2516 2517//===---------- Intrinsics to control hardware supported loops ----------===// 2518 2519// Specify that the value given is the number of iterations that the next loop 2520// will execute. 2521def int_set_loop_iterations : 2522 DefaultAttrsIntrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>; 2523 2524// Same as the above, but produces a value (the same as the input operand) to 2525// be fed into the loop. 2526def int_start_loop_iterations : 2527 DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], [IntrNoDuplicate]>; 2528 2529// Specify that the value given is the number of iterations that the next loop 2530// will execute. Also test that the given count is not zero, allowing it to 2531// control entry to a 'while' loop. 2532def int_test_set_loop_iterations : 2533 DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>; 2534 2535// Same as the above, but produces an extra value (the same as the input 2536// operand) to be fed into the loop. 2537def int_test_start_loop_iterations : 2538 DefaultAttrsIntrinsic<[llvm_anyint_ty, llvm_i1_ty], [LLVMMatchType<0>], 2539 [IntrNoDuplicate]>; 2540 2541// Decrement loop counter by the given argument. Return false if the loop 2542// should exit. 2543def int_loop_decrement : 2544 DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>; 2545 2546// Decrement the first operand (the loop counter) by the second operand (the 2547// maximum number of elements processed in an iteration). Return the remaining 2548// number of iterations still to be executed. This is effectively a sub which 2549// can be used with a phi, icmp and br to control the number of iterations 2550// executed, as usual. Any optimisations are allowed to treat it is a sub, and 2551// it's scevable, so it's the backends responsibility to handle cases where it 2552// may be optimised. 2553def int_loop_decrement_reg : 2554 DefaultAttrsIntrinsic<[llvm_anyint_ty], 2555 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoDuplicate]>; 2556 2557//===----- Intrinsics that are used to provide predicate information -----===// 2558 2559def int_ssa_copy : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>], 2560 [IntrNoMem, Returned<ArgIndex<0>>]>; 2561 2562//===------- Intrinsics that are used to preserve debug information -------===// 2563 2564def int_preserve_array_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty], 2565 [llvm_anyptr_ty, llvm_i32_ty, 2566 llvm_i32_ty], 2567 [IntrNoMem, 2568 ImmArg<ArgIndex<1>>, 2569 ImmArg<ArgIndex<2>>]>; 2570def int_preserve_union_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty], 2571 [llvm_anyptr_ty, llvm_i32_ty], 2572 [IntrNoMem, 2573 ImmArg<ArgIndex<1>>]>; 2574def int_preserve_struct_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty], 2575 [llvm_anyptr_ty, llvm_i32_ty, 2576 llvm_i32_ty], 2577 [IntrNoMem, 2578 ImmArg<ArgIndex<1>>, 2579 ImmArg<ArgIndex<2>>]>; 2580def int_preserve_static_offset : DefaultAttrsIntrinsic<[llvm_ptr_ty], 2581 [llvm_ptr_ty], 2582 [IntrNoMem, IntrSpeculatable, 2583 ReadNone <ArgIndex<0>>]>; 2584 2585//===------------ Intrinsics to perform common vector shuffles ------------===// 2586 2587def int_vector_reverse : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2588 [LLVMMatchType<0>], 2589 [IntrNoMem]>; 2590 2591def int_vector_splice : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2592 [LLVMMatchType<0>, 2593 LLVMMatchType<0>, 2594 llvm_i32_ty], 2595 [IntrNoMem, ImmArg<ArgIndex<2>>]>; 2596 2597//===---------- Intrinsics to query properties of scalable vectors --------===// 2598def int_vscale : DefaultAttrsIntrinsic<[llvm_anyint_ty], [], [IntrNoMem]>; 2599 2600//===---------- Intrinsics to perform subvector insertion/extraction ------===// 2601def int_vector_insert : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2602 [LLVMMatchType<0>, llvm_anyvector_ty, llvm_i64_ty], 2603 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>]>; 2604 2605def int_vector_extract : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2606 [llvm_anyvector_ty, llvm_i64_ty], 2607 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>; 2608 2609 2610def int_vector_interleave2 : DefaultAttrsIntrinsic<[llvm_anyvector_ty], 2611 [LLVMHalfElementsVectorType<0>, 2612 LLVMHalfElementsVectorType<0>], 2613 [IntrNoMem]>; 2614 2615def int_vector_deinterleave2 : DefaultAttrsIntrinsic<[LLVMHalfElementsVectorType<0>, 2616 LLVMHalfElementsVectorType<0>], 2617 [llvm_anyvector_ty], 2618 [IntrNoMem]>; 2619 2620//===----------------- Pointer Authentication Intrinsics ------------------===// 2621// 2622 2623// Sign an unauthenticated pointer using the specified key and discriminator, 2624// passed in that order. 2625// Returns the first argument, with some known bits replaced with a signature. 2626def int_ptrauth_sign : 2627 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty], 2628 [IntrNoMem, ImmArg<ArgIndex<1>>]>; 2629 2630// Authenticate a signed pointer, using the specified key and discriminator. 2631// Returns the first argument, with the signature bits removed. 2632// The signature must be valid. 2633def int_ptrauth_auth : Intrinsic<[llvm_i64_ty], 2634 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty], 2635 [IntrNoMem,ImmArg<ArgIndex<1>>]>; 2636 2637// Authenticate a signed pointer and resign it. 2638// The second (key) and third (discriminator) arguments specify the signing 2639// schema used for authenticating. 2640// The fourth and fifth arguments specify the schema used for signing. 2641// The signature must be valid. 2642// This is a combined form of @llvm.ptrauth.sign and @llvm.ptrauth.auth, with 2643// an additional integrity guarantee on the intermediate value. 2644def int_ptrauth_resign : Intrinsic<[llvm_i64_ty], 2645 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty, 2646 llvm_i32_ty, llvm_i64_ty], 2647 [IntrNoMem, ImmArg<ArgIndex<1>>, 2648 ImmArg<ArgIndex<3>>]>; 2649 2650// Strip the embedded signature out of a signed pointer. 2651// The second argument specifies the key. 2652// This behaves like @llvm.ptrauth.auth, but doesn't require the signature to 2653// be valid. 2654def int_ptrauth_strip : 2655 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty], 2656 [IntrNoMem, ImmArg<ArgIndex<1>>]>; 2657 2658// Blend a small integer discriminator with an address discriminator, producing 2659// a new discriminator value. 2660def int_ptrauth_blend : 2661 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>; 2662 2663// Compute the signature of a value, using a given discriminator. 2664// This differs from @llvm.ptrauth.sign in that it doesn't embed the computed 2665// signature in the pointer, but instead returns the signature as a value. 2666// That allows it to be used to sign non-pointer data: in that sense, it is 2667// generic. There is no generic @llvm.ptrauth.auth: instead, the signature 2668// can be computed using @llvm.ptrauth.sign_generic, and compared with icmp. 2669def int_ptrauth_sign_generic : 2670 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>; 2671 2672//===----------------------------------------------------------------------===// 2673//===------- Convergence Intrinsics ---------------------------------------===// 2674 2675def int_experimental_convergence_entry 2676 : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>; 2677def int_experimental_convergence_anchor 2678 : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>; 2679def int_experimental_convergence_loop 2680 : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>; 2681 2682//===----------------------------------------------------------------------===// 2683// Target-specific intrinsics 2684//===----------------------------------------------------------------------===// 2685 2686include "llvm/IR/IntrinsicsPowerPC.td" 2687include "llvm/IR/IntrinsicsX86.td" 2688include "llvm/IR/IntrinsicsARM.td" 2689include "llvm/IR/IntrinsicsAArch64.td" 2690include "llvm/IR/IntrinsicsXCore.td" 2691include "llvm/IR/IntrinsicsHexagon.td" 2692include "llvm/IR/IntrinsicsNVVM.td" 2693include "llvm/IR/IntrinsicsMips.td" 2694include "llvm/IR/IntrinsicsAMDGPU.td" 2695include "llvm/IR/IntrinsicsBPF.td" 2696include "llvm/IR/IntrinsicsSystemZ.td" 2697include "llvm/IR/IntrinsicsWebAssembly.td" 2698include "llvm/IR/IntrinsicsRISCV.td" 2699include "llvm/IR/IntrinsicsSPIRV.td" 2700include "llvm/IR/IntrinsicsVE.td" 2701include "llvm/IR/IntrinsicsDirectX.td" 2702include "llvm/IR/IntrinsicsLoongArch.td" 2703 2704#endif // TEST_INTRINSICS_SUPPRESS_DEFS 2705