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