1//===- Intrinsics.td - Defines all LLVM intrinsics ---------*- tablegen -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines properties of all LLVM intrinsics. 11// 12//===----------------------------------------------------------------------===// 13 14include "llvm/CodeGen/ValueTypes.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// Commutative - This intrinsic is commutative: X op Y == Y op X. 47def Commutative : IntrinsicProperty; 48 49// Throws - This intrinsic can throw. 50def Throws : IntrinsicProperty; 51 52// NoCapture - The specified argument pointer is not captured by the intrinsic. 53class NoCapture<int argNo> : IntrinsicProperty { 54 int ArgNo = argNo; 55} 56 57// Returned - The specified argument is always the return value of the 58// intrinsic. 59class Returned<int argNo> : IntrinsicProperty { 60 int ArgNo = argNo; 61} 62 63// ReadOnly - The specified argument pointer is not written to through the 64// pointer by the intrinsic. 65class ReadOnly<int argNo> : IntrinsicProperty { 66 int ArgNo = argNo; 67} 68 69// WriteOnly - The intrinsic does not read memory through the specified 70// argument pointer. 71class WriteOnly<int argNo> : IntrinsicProperty { 72 int ArgNo = argNo; 73} 74 75// ReadNone - The specified argument pointer is not dereferenced by the 76// intrinsic. 77class ReadNone<int argNo> : IntrinsicProperty { 78 int ArgNo = argNo; 79} 80 81def IntrNoReturn : IntrinsicProperty; 82 83// IntrNoduplicate - Calls to this intrinsic cannot be duplicated. 84// Parallels the noduplicate attribute on LLVM IR functions. 85def IntrNoDuplicate : IntrinsicProperty; 86 87// IntrConvergent - Calls to this intrinsic are convergent and may not be made 88// control-dependent on any additional values. 89// Parallels the convergent attribute on LLVM IR functions. 90def IntrConvergent : IntrinsicProperty; 91 92//===----------------------------------------------------------------------===// 93// Types used by intrinsics. 94//===----------------------------------------------------------------------===// 95 96class LLVMType<ValueType vt> { 97 ValueType VT = vt; 98} 99 100class LLVMQualPointerType<LLVMType elty, int addrspace> 101 : LLVMType<iPTR>{ 102 LLVMType ElTy = elty; 103 int AddrSpace = addrspace; 104} 105 106class LLVMPointerType<LLVMType elty> 107 : LLVMQualPointerType<elty, 0>; 108 109class LLVMAnyPointerType<LLVMType elty> 110 : LLVMType<iPTRAny>{ 111 LLVMType ElTy = elty; 112} 113 114// Match the type of another intrinsic parameter. Number is an index into the 115// list of overloaded types for the intrinsic, excluding all the fixed types. 116// The Number value must refer to a previously listed type. For example: 117// Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]> 118// has two overloaded types, the 2nd and 3rd arguments. LLVMMatchType<0> 119// refers to the first overloaded type, which is the 2nd argument. 120class LLVMMatchType<int num> 121 : LLVMType<OtherVT>{ 122 int Number = num; 123} 124 125// Match the type of another intrinsic parameter that is expected to be based on 126// an integral type (i.e. either iN or <N x iM>), but change the scalar size to 127// be twice as wide or half as wide as the other type. This is only useful when 128// the intrinsic is overloaded, so the matched type should be declared as iAny. 129class LLVMExtendedType<int num> : LLVMMatchType<num>; 130class LLVMTruncatedType<int num> : LLVMMatchType<num>; 131class LLVMVectorSameWidth<int num, LLVMType elty> 132 : LLVMMatchType<num> { 133 ValueType ElTy = elty.VT; 134} 135class LLVMPointerTo<int num> : LLVMMatchType<num>; 136class LLVMVectorOfPointersToElt<int num> : LLVMMatchType<num>; 137 138// Match the type of another intrinsic parameter that is expected to be a 139// vector type, but change the element count to be half as many 140class LLVMHalfElementsVectorType<int num> : LLVMMatchType<num>; 141 142def llvm_void_ty : LLVMType<isVoid>; 143def llvm_any_ty : LLVMType<Any>; 144def llvm_anyint_ty : LLVMType<iAny>; 145def llvm_anyfloat_ty : LLVMType<fAny>; 146def llvm_anyvector_ty : LLVMType<vAny>; 147def llvm_i1_ty : LLVMType<i1>; 148def llvm_i8_ty : LLVMType<i8>; 149def llvm_i16_ty : LLVMType<i16>; 150def llvm_i32_ty : LLVMType<i32>; 151def llvm_i64_ty : LLVMType<i64>; 152def llvm_half_ty : LLVMType<f16>; 153def llvm_float_ty : LLVMType<f32>; 154def llvm_double_ty : LLVMType<f64>; 155def llvm_f80_ty : LLVMType<f80>; 156def llvm_f128_ty : LLVMType<f128>; 157def llvm_ppcf128_ty : LLVMType<ppcf128>; 158def llvm_ptr_ty : LLVMPointerType<llvm_i8_ty>; // i8* 159def llvm_ptrptr_ty : LLVMPointerType<llvm_ptr_ty>; // i8** 160def llvm_anyptr_ty : LLVMAnyPointerType<llvm_i8_ty>; // (space)i8* 161def llvm_empty_ty : LLVMType<OtherVT>; // { } 162def llvm_descriptor_ty : LLVMPointerType<llvm_empty_ty>; // { }* 163def llvm_metadata_ty : LLVMType<MetadataVT>; // !{...} 164def llvm_token_ty : LLVMType<token>; // token 165 166def llvm_x86mmx_ty : LLVMType<x86mmx>; 167def llvm_ptrx86mmx_ty : LLVMPointerType<llvm_x86mmx_ty>; // <1 x i64>* 168 169def llvm_v2i1_ty : LLVMType<v2i1>; // 2 x i1 170def llvm_v4i1_ty : LLVMType<v4i1>; // 4 x i1 171def llvm_v8i1_ty : LLVMType<v8i1>; // 8 x i1 172def llvm_v16i1_ty : LLVMType<v16i1>; // 16 x i1 173def llvm_v32i1_ty : LLVMType<v32i1>; // 32 x i1 174def llvm_v64i1_ty : LLVMType<v64i1>; // 64 x i1 175def llvm_v512i1_ty : LLVMType<v512i1>; // 512 x i1 176def llvm_v1024i1_ty : LLVMType<v1024i1>; //1024 x i1 177 178def llvm_v1i8_ty : LLVMType<v1i8>; // 1 x i8 179def llvm_v2i8_ty : LLVMType<v2i8>; // 2 x i8 180def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8 181def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8 182def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8 183def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8 184def llvm_v64i8_ty : LLVMType<v64i8>; // 64 x i8 185def llvm_v128i8_ty : LLVMType<v128i8>; //128 x i8 186def llvm_v256i8_ty : LLVMType<v256i8>; //256 x i8 187 188def llvm_v1i16_ty : LLVMType<v1i16>; // 1 x i16 189def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16 190def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16 191def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16 192def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16 193def llvm_v32i16_ty : LLVMType<v32i16>; // 32 x i16 194def llvm_v64i16_ty : LLVMType<v64i16>; // 64 x i16 195def llvm_v128i16_ty : LLVMType<v128i16>; //128 x i16 196 197def llvm_v1i32_ty : LLVMType<v1i32>; // 1 x i32 198def llvm_v2i32_ty : LLVMType<v2i32>; // 2 x i32 199def llvm_v4i32_ty : LLVMType<v4i32>; // 4 x i32 200def llvm_v8i32_ty : LLVMType<v8i32>; // 8 x i32 201def llvm_v16i32_ty : LLVMType<v16i32>; // 16 x i32 202def llvm_v32i32_ty : LLVMType<v32i32>; // 32 x i32 203def llvm_v64i32_ty : LLVMType<v64i32>; // 64 x i32 204 205def llvm_v1i64_ty : LLVMType<v1i64>; // 1 x i64 206def llvm_v2i64_ty : LLVMType<v2i64>; // 2 x i64 207def llvm_v4i64_ty : LLVMType<v4i64>; // 4 x i64 208def llvm_v8i64_ty : LLVMType<v8i64>; // 8 x i64 209def llvm_v16i64_ty : LLVMType<v16i64>; // 16 x i64 210def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64 211 212def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128 213 214def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16) 215def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16) 216def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16) 217def llvm_v1f32_ty : LLVMType<v1f32>; // 1 x float 218def llvm_v2f32_ty : LLVMType<v2f32>; // 2 x float 219def llvm_v4f32_ty : LLVMType<v4f32>; // 4 x float 220def llvm_v8f32_ty : LLVMType<v8f32>; // 8 x float 221def llvm_v16f32_ty : LLVMType<v16f32>; // 16 x float 222def llvm_v1f64_ty : LLVMType<v1f64>; // 1 x double 223def llvm_v2f64_ty : LLVMType<v2f64>; // 2 x double 224def llvm_v4f64_ty : LLVMType<v4f64>; // 4 x double 225def llvm_v8f64_ty : LLVMType<v8f64>; // 8 x double 226 227def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here 228 229 230//===----------------------------------------------------------------------===// 231// Intrinsic Definitions. 232//===----------------------------------------------------------------------===// 233 234// Intrinsic class - This is used to define one LLVM intrinsic. The name of the 235// intrinsic definition should start with "int_", then match the LLVM intrinsic 236// name with the "llvm." prefix removed, and all "."s turned into "_"s. For 237// example, llvm.bswap.i16 -> int_bswap_i16. 238// 239// * RetTypes is a list containing the return types expected for the 240// intrinsic. 241// * ParamTypes is a list containing the parameter types expected for the 242// intrinsic. 243// * Properties can be set to describe the behavior of the intrinsic. 244// 245class SDPatternOperator; 246class Intrinsic<list<LLVMType> ret_types, 247 list<LLVMType> param_types = [], 248 list<IntrinsicProperty> properties = [], 249 string name = ""> : SDPatternOperator { 250 string LLVMName = name; 251 string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics. 252 list<LLVMType> RetTypes = ret_types; 253 list<LLVMType> ParamTypes = param_types; 254 list<IntrinsicProperty> IntrProperties = properties; 255 256 bit isTarget = 0; 257} 258 259/// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this 260/// specifies the name of the builtin. This provides automatic CBE and CFE 261/// support. 262class GCCBuiltin<string name> { 263 string GCCBuiltinName = name; 264} 265 266class MSBuiltin<string name> { 267 string MSBuiltinName = name; 268} 269 270 271//===--------------- Variable Argument Handling Intrinsics ----------------===// 272// 273 274def int_vastart : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_start">; 275def int_vacopy : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], [], 276 "llvm.va_copy">; 277def int_vaend : Intrinsic<[], [llvm_ptr_ty], [], "llvm.va_end">; 278 279//===------------------- Garbage Collection Intrinsics --------------------===// 280// 281def int_gcroot : Intrinsic<[], 282 [llvm_ptrptr_ty, llvm_ptr_ty]>; 283def int_gcread : Intrinsic<[llvm_ptr_ty], 284 [llvm_ptr_ty, llvm_ptrptr_ty], 285 [IntrReadMem, IntrArgMemOnly]>; 286def int_gcwrite : Intrinsic<[], 287 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty], 288 [IntrArgMemOnly, NoCapture<1>, NoCapture<2>]>; 289 290//===--------------------- Code Generator Intrinsics ----------------------===// 291// 292def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem]>; 293def int_frameaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem]>; 294def int_read_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty], 295 [IntrReadMem], "llvm.read_register">; 296def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty], 297 [], "llvm.write_register">; 298 299// Gets the address of the local variable area. This is typically a copy of the 300// stack, frame, or base pointer depending on the type of prologue. 301def int_localaddress : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; 302 303// Escapes local variables to allow access from other functions. 304def int_localescape : Intrinsic<[], [llvm_vararg_ty]>; 305 306// Given a function and the localaddress of a parent frame, returns a pointer 307// to an escaped allocation indicated by the index. 308def int_localrecover : Intrinsic<[llvm_ptr_ty], 309 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], 310 [IntrNoMem]>; 311// Note: we treat stacksave/stackrestore as writemem because we don't otherwise 312// model their dependencies on allocas. 313def int_stacksave : Intrinsic<[llvm_ptr_ty]>, 314 GCCBuiltin<"__builtin_stack_save">; 315def int_stackrestore : Intrinsic<[], [llvm_ptr_ty]>, 316 GCCBuiltin<"__builtin_stack_restore">; 317 318def int_get_dynamic_area_offset : Intrinsic<[llvm_anyint_ty]>; 319 320def int_thread_pointer : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>, 321 GCCBuiltin<"__builtin_thread_pointer">; 322 323// IntrArgMemOnly is more pessimistic than strictly necessary for prefetch, 324// however it does conveniently prevent the prefetch from being reordered 325// with respect to nearby accesses to the same memory. 326def int_prefetch : Intrinsic<[], 327 [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty, 328 llvm_i32_ty], 329 [IntrArgMemOnly, NoCapture<0>]>; 330def int_pcmarker : Intrinsic<[], [llvm_i32_ty]>; 331 332def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>; 333 334// The assume intrinsic is marked as arbitrarily writing so that proper 335// control dependencies will be maintained. 336def int_assume : Intrinsic<[], [llvm_i1_ty], []>; 337 338// Stack Protector Intrinsic - The stackprotector intrinsic writes the stack 339// guard to the correct place on the stack frame. 340def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>; 341def int_stackguard : Intrinsic<[llvm_ptr_ty], [], []>; 342 343// A counter increment for instrumentation based profiling. 344def int_instrprof_increment : Intrinsic<[], 345 [llvm_ptr_ty, llvm_i64_ty, 346 llvm_i32_ty, llvm_i32_ty], 347 []>; 348 349// A call to profile runtime for value profiling of target expressions 350// through instrumentation based profiling. 351def int_instrprof_value_profile : Intrinsic<[], 352 [llvm_ptr_ty, llvm_i64_ty, 353 llvm_i64_ty, llvm_i32_ty, 354 llvm_i32_ty], 355 []>; 356 357//===------------------- Standard C Library Intrinsics --------------------===// 358// 359 360def int_memcpy : Intrinsic<[], 361 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, 362 llvm_i32_ty, llvm_i1_ty], 363 [IntrArgMemOnly, NoCapture<0>, NoCapture<1>, 364 WriteOnly<0>, ReadOnly<1>]>; 365def int_memmove : Intrinsic<[], 366 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, 367 llvm_i32_ty, llvm_i1_ty], 368 [IntrArgMemOnly, NoCapture<0>, NoCapture<1>, 369 ReadOnly<1>]>; 370def int_memset : Intrinsic<[], 371 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, 372 llvm_i32_ty, llvm_i1_ty], 373 [IntrArgMemOnly, NoCapture<0>, WriteOnly<0>]>; 374 375let IntrProperties = [IntrNoMem] in { 376 def int_fma : Intrinsic<[llvm_anyfloat_ty], 377 [LLVMMatchType<0>, LLVMMatchType<0>, 378 LLVMMatchType<0>]>; 379 def int_fmuladd : Intrinsic<[llvm_anyfloat_ty], 380 [LLVMMatchType<0>, LLVMMatchType<0>, 381 LLVMMatchType<0>]>; 382 383 // These functions do not read memory, but are sensitive to the 384 // rounding mode. LLVM purposely does not model changes to the FP 385 // environment so they can be treated as readnone. 386 def int_sqrt : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 387 def int_powi : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_i32_ty]>; 388 def int_sin : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 389 def int_cos : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 390 def int_pow : Intrinsic<[llvm_anyfloat_ty], 391 [LLVMMatchType<0>, LLVMMatchType<0>]>; 392 def int_log : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 393 def int_log10: Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 394 def int_log2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 395 def int_exp : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 396 def int_exp2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 397 def int_fabs : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 398 def int_copysign : Intrinsic<[llvm_anyfloat_ty], 399 [LLVMMatchType<0>, LLVMMatchType<0>]>; 400 def int_floor : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 401 def int_ceil : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 402 def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 403 def int_rint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 404 def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 405 def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; 406 def int_canonicalize : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>], 407 [IntrNoMem]>; 408} 409 410def int_minnum : Intrinsic<[llvm_anyfloat_ty], 411 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, Commutative] 412>; 413def int_maxnum : Intrinsic<[llvm_anyfloat_ty], 414 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, Commutative] 415>; 416 417// NOTE: these are internal interfaces. 418def int_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; 419def int_longjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>; 420def int_sigsetjmp : Intrinsic<[llvm_i32_ty] , [llvm_ptr_ty, llvm_i32_ty]>; 421def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>; 422 423// Internal interface for object size checking 424def int_objectsize : Intrinsic<[llvm_anyint_ty], [llvm_anyptr_ty, llvm_i1_ty], 425 [IntrNoMem]>, 426 GCCBuiltin<"__builtin_object_size">; 427 428//===------------------------- Expect Intrinsics --------------------------===// 429// 430def int_expect : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, 431 LLVMMatchType<0>], [IntrNoMem]>; 432 433//===-------------------- Bit Manipulation Intrinsics ---------------------===// 434// 435 436// None of these intrinsics accesses memory at all. 437let IntrProperties = [IntrNoMem] in { 438 def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>; 439 def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>; 440 def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>; 441 def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>; 442 def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>; 443} 444 445//===------------------------ Debugger Intrinsics -------------------------===// 446// 447 448// None of these intrinsics accesses memory at all...but that doesn't mean the 449// optimizers can change them aggressively. Special handling needed in a few 450// places. 451let IntrProperties = [IntrNoMem] in { 452 def int_dbg_declare : Intrinsic<[], 453 [llvm_metadata_ty, 454 llvm_metadata_ty, 455 llvm_metadata_ty]>; 456 def int_dbg_value : Intrinsic<[], 457 [llvm_metadata_ty, llvm_i64_ty, 458 llvm_metadata_ty, 459 llvm_metadata_ty]>; 460} 461 462//===------------------ Exception Handling Intrinsics----------------------===// 463// 464 465// The result of eh.typeid.for depends on the enclosing function, but inside a 466// given function it is 'const' and may be CSE'd etc. 467def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem]>; 468 469def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>; 470def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>; 471 472// eh.exceptionpointer returns the pointer to the exception caught by 473// the given `catchpad`. 474def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty], 475 [IntrNoMem]>; 476 477// Gets the exception code from a catchpad token. Only used on some platforms. 478def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>; 479 480// __builtin_unwind_init is an undocumented GCC intrinsic that causes all 481// callee-saved registers to be saved and restored (regardless of whether they 482// are used) in the calling function. It is used by libgcc_eh. 483def int_eh_unwind_init: Intrinsic<[]>, 484 GCCBuiltin<"__builtin_unwind_init">; 485 486def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>; 487 488let IntrProperties = [IntrNoMem] in { 489 def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty]>; 490 def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty]>; 491} 492def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>; 493def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>; 494def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>; 495def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>; 496 497//===---------------- Generic Variable Attribute Intrinsics----------------===// 498// 499def int_var_annotation : Intrinsic<[], 500 [llvm_ptr_ty, llvm_ptr_ty, 501 llvm_ptr_ty, llvm_i32_ty], 502 [], "llvm.var.annotation">; 503def int_ptr_annotation : Intrinsic<[LLVMAnyPointerType<llvm_anyint_ty>], 504 [LLVMMatchType<0>, llvm_ptr_ty, llvm_ptr_ty, 505 llvm_i32_ty], 506 [], "llvm.ptr.annotation">; 507def int_annotation : Intrinsic<[llvm_anyint_ty], 508 [LLVMMatchType<0>, llvm_ptr_ty, 509 llvm_ptr_ty, llvm_i32_ty], 510 [], "llvm.annotation">; 511 512//===------------------------ Trampoline Intrinsics -----------------------===// 513// 514def int_init_trampoline : Intrinsic<[], 515 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], 516 [IntrArgMemOnly, NoCapture<0>]>, 517 GCCBuiltin<"__builtin_init_trampoline">; 518 519def int_adjust_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty], 520 [IntrReadMem, IntrArgMemOnly]>, 521 GCCBuiltin<"__builtin_adjust_trampoline">; 522 523//===------------------------ Overflow Intrinsics -------------------------===// 524// 525 526// Expose the carry flag from add operations on two integrals. 527def int_sadd_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty], 528 [LLVMMatchType<0>, LLVMMatchType<0>], 529 [IntrNoMem]>; 530def int_uadd_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty], 531 [LLVMMatchType<0>, LLVMMatchType<0>], 532 [IntrNoMem]>; 533 534def int_ssub_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty], 535 [LLVMMatchType<0>, LLVMMatchType<0>], 536 [IntrNoMem]>; 537def int_usub_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty], 538 [LLVMMatchType<0>, LLVMMatchType<0>], 539 [IntrNoMem]>; 540 541def int_smul_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty], 542 [LLVMMatchType<0>, LLVMMatchType<0>], 543 [IntrNoMem]>; 544def int_umul_with_overflow : Intrinsic<[llvm_anyint_ty, llvm_i1_ty], 545 [LLVMMatchType<0>, LLVMMatchType<0>], 546 [IntrNoMem]>; 547 548//===------------------------- Memory Use Markers -------------------------===// 549// 550def int_lifetime_start : Intrinsic<[], 551 [llvm_i64_ty, llvm_ptr_ty], 552 [IntrArgMemOnly, NoCapture<1>]>; 553def int_lifetime_end : Intrinsic<[], 554 [llvm_i64_ty, llvm_ptr_ty], 555 [IntrArgMemOnly, NoCapture<1>]>; 556def int_invariant_start : Intrinsic<[llvm_descriptor_ty], 557 [llvm_i64_ty, llvm_ptr_ty], 558 [IntrArgMemOnly, NoCapture<1>]>; 559def int_invariant_end : Intrinsic<[], 560 [llvm_descriptor_ty, llvm_i64_ty, 561 llvm_ptr_ty], 562 [IntrArgMemOnly, NoCapture<2>]>; 563 564def int_invariant_group_barrier : Intrinsic<[llvm_ptr_ty], 565 [llvm_ptr_ty], 566 [IntrNoMem]>; 567 568//===------------------------ Stackmap Intrinsics -------------------------===// 569// 570def int_experimental_stackmap : Intrinsic<[], 571 [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty], 572 [Throws]>; 573def int_experimental_patchpoint_void : Intrinsic<[], 574 [llvm_i64_ty, llvm_i32_ty, 575 llvm_ptr_ty, llvm_i32_ty, 576 llvm_vararg_ty], 577 [Throws]>; 578def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty], 579 [llvm_i64_ty, llvm_i32_ty, 580 llvm_ptr_ty, llvm_i32_ty, 581 llvm_vararg_ty], 582 [Throws]>; 583 584 585//===------------------------ Garbage Collection Intrinsics ---------------===// 586// These are documented in docs/Statepoint.rst 587 588def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty], 589 [llvm_i64_ty, llvm_i32_ty, 590 llvm_anyptr_ty, llvm_i32_ty, 591 llvm_i32_ty, llvm_vararg_ty], 592 [Throws]>; 593 594def int_experimental_gc_result : Intrinsic<[llvm_any_ty], [llvm_token_ty], 595 [IntrReadMem]>; 596def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty], 597 [llvm_token_ty, llvm_i32_ty, llvm_i32_ty], 598 [IntrReadMem]>; 599 600//===-------------------------- Other Intrinsics --------------------------===// 601// 602def int_flt_rounds : Intrinsic<[llvm_i32_ty]>, 603 GCCBuiltin<"__builtin_flt_rounds">; 604def int_trap : Intrinsic<[], [], [IntrNoReturn]>, 605 GCCBuiltin<"__builtin_trap">; 606def int_debugtrap : Intrinsic<[]>, 607 GCCBuiltin<"__builtin_debugtrap">; 608 609// Support for dynamic deoptimization (or de-specialization) 610def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], 611 [Throws]>; 612 613// Support for speculative runtime guards 614def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty], 615 [Throws]>; 616 617// NOP: calls/invokes to this intrinsic are removed by codegen 618def int_donothing : Intrinsic<[], [], [IntrNoMem]>; 619 620// Intrisics to support half precision floating point format 621let IntrProperties = [IntrNoMem] in { 622def int_convert_to_fp16 : Intrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>; 623def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>; 624} 625 626// These convert intrinsics are to support various conversions between 627// various types with rounding and saturation. NOTE: avoid using these 628// intrinsics as they might be removed sometime in the future and 629// most targets don't support them. 630def int_convertff : Intrinsic<[llvm_anyfloat_ty], 631 [llvm_anyfloat_ty, llvm_i32_ty, llvm_i32_ty]>; 632def int_convertfsi : Intrinsic<[llvm_anyfloat_ty], 633 [llvm_anyint_ty, llvm_i32_ty, llvm_i32_ty]>; 634def int_convertfui : Intrinsic<[llvm_anyfloat_ty], 635 [llvm_anyint_ty, llvm_i32_ty, llvm_i32_ty]>; 636def int_convertsif : Intrinsic<[llvm_anyint_ty], 637 [llvm_anyfloat_ty, llvm_i32_ty, llvm_i32_ty]>; 638def int_convertuif : Intrinsic<[llvm_anyint_ty], 639 [llvm_anyfloat_ty, llvm_i32_ty, llvm_i32_ty]>; 640def int_convertss : Intrinsic<[llvm_anyint_ty], 641 [llvm_anyint_ty, llvm_i32_ty, llvm_i32_ty]>; 642def int_convertsu : Intrinsic<[llvm_anyint_ty], 643 [llvm_anyint_ty, llvm_i32_ty, llvm_i32_ty]>; 644def int_convertus : Intrinsic<[llvm_anyint_ty], 645 [llvm_anyint_ty, llvm_i32_ty, llvm_i32_ty]>; 646def int_convertuu : Intrinsic<[llvm_anyint_ty], 647 [llvm_anyint_ty, llvm_i32_ty, llvm_i32_ty]>; 648 649// Clear cache intrinsic, default to ignore (ie. emit nothing) 650// maps to void __clear_cache() on supporting platforms 651def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], 652 [], "llvm.clear_cache">; 653 654//===-------------------------- Masked Intrinsics -------------------------===// 655// 656def int_masked_store : Intrinsic<[], [llvm_anyvector_ty, 657 LLVMAnyPointerType<LLVMMatchType<0>>, 658 llvm_i32_ty, 659 LLVMVectorSameWidth<0, llvm_i1_ty>], 660 [IntrArgMemOnly]>; 661 662def int_masked_load : Intrinsic<[llvm_anyvector_ty], 663 [LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty, 664 LLVMVectorSameWidth<0, llvm_i1_ty>, LLVMMatchType<0>], 665 [IntrReadMem, IntrArgMemOnly]>; 666 667def int_masked_gather: Intrinsic<[llvm_anyvector_ty], 668 [LLVMVectorOfPointersToElt<0>, llvm_i32_ty, 669 LLVMVectorSameWidth<0, llvm_i1_ty>, 670 LLVMMatchType<0>], 671 [IntrReadMem, IntrArgMemOnly]>; 672 673def int_masked_scatter: Intrinsic<[], 674 [llvm_anyvector_ty, 675 LLVMVectorOfPointersToElt<0>, llvm_i32_ty, 676 LLVMVectorSameWidth<0, llvm_i1_ty>], 677 [IntrArgMemOnly]>; 678 679// Test whether a pointer is associated with a type metadata identifier. 680def int_type_test : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty], 681 [IntrNoMem]>; 682 683// Safely loads a function pointer from a virtual table pointer using type metadata. 684def int_type_checked_load : Intrinsic<[llvm_ptr_ty, llvm_i1_ty], 685 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty], 686 [IntrNoMem]>; 687 688def int_load_relative: Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty], 689 [IntrReadMem, IntrArgMemOnly]>; 690 691//===----------------------------------------------------------------------===// 692// Target-specific intrinsics 693//===----------------------------------------------------------------------===// 694 695include "llvm/IR/IntrinsicsPowerPC.td" 696include "llvm/IR/IntrinsicsX86.td" 697include "llvm/IR/IntrinsicsARM.td" 698include "llvm/IR/IntrinsicsAArch64.td" 699include "llvm/IR/IntrinsicsXCore.td" 700include "llvm/IR/IntrinsicsHexagon.td" 701include "llvm/IR/IntrinsicsNVVM.td" 702include "llvm/IR/IntrinsicsMips.td" 703include "llvm/IR/IntrinsicsAMDGPU.td" 704include "llvm/IR/IntrinsicsBPF.td" 705include "llvm/IR/IntrinsicsSystemZ.td" 706include "llvm/IR/IntrinsicsWebAssembly.td" 707