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