Warning, /include/llvm/IR/Intrinsics.td is written in an unsupported language. File is not indexed.
0001 //===- Intrinsics.td - Defines all LLVM intrinsics ---------*- tablegen -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines properties of all LLVM intrinsics.
0010 //
0011 //===----------------------------------------------------------------------===//
0012
0013 include "llvm/CodeGen/ValueTypes.td"
0014 include "llvm/CodeGen/SDNodeProperties.td"
0015
0016 //===----------------------------------------------------------------------===//
0017 // Properties we keep track of for intrinsics.
0018 //===----------------------------------------------------------------------===//
0019
0020 class IntrinsicProperty<bit is_default = false> {
0021 bit IsDefault = is_default;
0022 }
0023
0024 // Intr*Mem - Memory properties. If no property is set, the worst case
0025 // is assumed (it may read and write any memory it can get access to and it may
0026 // have other side effects).
0027
0028 // IntrNoMem - The intrinsic does not access memory or have any other side
0029 // effects. It may be CSE'd deleted if dead, etc.
0030 def IntrNoMem : IntrinsicProperty;
0031
0032 // IntrReadMem - This intrinsic only reads from memory. It does not write to
0033 // memory and has no other side effects. Therefore, it cannot be moved across
0034 // potentially aliasing stores. However, it can be reordered otherwise and can
0035 // be deleted if dead.
0036 def IntrReadMem : IntrinsicProperty;
0037
0038 // IntrWriteMem - This intrinsic only writes to memory, but does not read from
0039 // memory, and has no other side effects. This means dead stores before calls
0040 // to this intrinsics may be removed.
0041 def IntrWriteMem : IntrinsicProperty;
0042
0043 // IntrArgMemOnly - This intrinsic only accesses memory that its pointer-typed
0044 // argument(s) points to, but may access an unspecified amount. Other than
0045 // reads from and (possibly volatile) writes to memory, it has no side effects.
0046 def IntrArgMemOnly : IntrinsicProperty;
0047
0048 // IntrInaccessibleMemOnly -- This intrinsic only accesses memory that is not
0049 // accessible by the module being compiled. This is a weaker form of IntrNoMem.
0050 def IntrInaccessibleMemOnly : IntrinsicProperty;
0051
0052 // IntrInaccessibleMemOrArgMemOnly -- This intrinsic only accesses memory that
0053 // its pointer-typed arguments point to or memory that is not accessible
0054 // by the module being compiled. This is a weaker form of IntrArgMemOnly.
0055 def IntrInaccessibleMemOrArgMemOnly : IntrinsicProperty;
0056
0057 // Commutative - This intrinsic is commutative: X op Y == Y op X.
0058 def Commutative : IntrinsicProperty;
0059
0060 // Throws - This intrinsic can throw.
0061 def Throws : IntrinsicProperty;
0062
0063 // Attribute index needs to match `AttrIndex` defined `Attributes.h`.
0064 class AttrIndex<int idx> {
0065 int Value = idx;
0066 }
0067 def RetIndex : AttrIndex<0>;
0068 class ArgIndex<int argNo> : AttrIndex<!add(argNo, 1)>;
0069
0070 // Note: Properties that are applicable either to arguments or return values
0071 // use AttrIndex. Properties applicable only to arguments use ArgIndex. Please
0072 // refer to Attributes.td.
0073
0074 // NoCapture - The specified argument pointer is not captured by the intrinsic.
0075 class NoCapture<ArgIndex idx> : IntrinsicProperty {
0076 int ArgNo = idx.Value;
0077 }
0078
0079 // NoAlias - The return value or the specified argument pointer is not aliasing
0080 // other "noalias" pointer arguments of the intrinsic wrt. the intrinsic scope.
0081 class NoAlias<AttrIndex idx> : IntrinsicProperty {
0082 int ArgNo = idx.Value;
0083 }
0084
0085 // NoUndef - The return value or specified argument is neither undef nor poison.
0086 class NoUndef<AttrIndex idx> : IntrinsicProperty {
0087 int ArgNo = idx.Value;
0088 }
0089
0090 // NonNull - The return value or specified argument is not null.
0091 class NonNull<AttrIndex idx> : IntrinsicProperty {
0092 int ArgNo = idx.Value;
0093 }
0094
0095 // Align - Alignment for return value or the specified argument.
0096 class Align<AttrIndex idx, int align> : IntrinsicProperty {
0097 int ArgNo = idx.Value;
0098 int Align = align;
0099 }
0100
0101 // Dereferenceable -- Return value or the specified argument is dereferenceable
0102 // upto `bytes` bytes in size.
0103 class Dereferenceable<AttrIndex idx, int bytes> : IntrinsicProperty {
0104 int ArgNo = idx.Value;
0105 int Bytes = bytes;
0106 }
0107
0108 // Returned - The specified argument is always the return value of the
0109 // intrinsic.
0110 class Returned<ArgIndex idx> : IntrinsicProperty {
0111 int ArgNo = idx.Value;
0112 }
0113
0114 // ImmArg - The specified argument must be an immediate.
0115 class ImmArg<ArgIndex idx> : IntrinsicProperty {
0116 int ArgNo = idx.Value;
0117 }
0118
0119 // ReadOnly - The specified argument pointer is not written to through the
0120 // pointer by the intrinsic.
0121 class ReadOnly<ArgIndex idx> : IntrinsicProperty {
0122 int ArgNo = idx.Value;
0123 }
0124
0125 // WriteOnly - The intrinsic does not read memory through the specified
0126 // argument pointer.
0127 class WriteOnly<ArgIndex idx> : IntrinsicProperty {
0128 int ArgNo = idx.Value;
0129 }
0130
0131 // ReadNone - The specified argument pointer is not dereferenced by the
0132 // intrinsic.
0133 class ReadNone<ArgIndex idx> : IntrinsicProperty {
0134 int ArgNo = idx.Value;
0135 }
0136
0137 def IntrNoReturn : IntrinsicProperty;
0138
0139 // Applied by default.
0140 def IntrNoCallback : IntrinsicProperty<1>;
0141
0142 // IntrNoSync - Threads executing the intrinsic will not synchronize using
0143 // memory or other means. Applied by default.
0144 def IntrNoSync : IntrinsicProperty<1>;
0145
0146 // Applied by default.
0147 def IntrNoFree : IntrinsicProperty<1>;
0148
0149 // Applied by default.
0150 def IntrWillReturn : IntrinsicProperty<1>;
0151
0152 // IntrCold - Calls to this intrinsic are cold.
0153 // Parallels the cold attribute on LLVM IR functions.
0154 def IntrCold : IntrinsicProperty;
0155
0156 // IntrNoDuplicate - Calls to this intrinsic cannot be duplicated.
0157 // Parallels the noduplicate attribute on LLVM IR functions.
0158 def IntrNoDuplicate : IntrinsicProperty;
0159
0160 // IntrNoMerge - Calls to this intrinsic cannot be merged
0161 // Parallels the nomerge attribute on LLVM IR functions.
0162 def IntrNoMerge : IntrinsicProperty;
0163
0164 // IntrConvergent - Calls to this intrinsic are convergent and may not be made
0165 // control-dependent on any additional values.
0166 // Parallels the convergent attribute on LLVM IR functions.
0167 def IntrConvergent : IntrinsicProperty;
0168
0169 // This property indicates that the intrinsic is safe to speculate.
0170 def IntrSpeculatable : IntrinsicProperty;
0171
0172 // This property can be used to override the 'has no other side effects'
0173 // language of the IntrNoMem, IntrReadMem, IntrWriteMem, and IntrArgMemOnly
0174 // intrinsic properties. By default, intrinsics are assumed to have side
0175 // effects, so this property is only necessary if you have defined one of
0176 // the memory properties listed above.
0177 // For this property, 'side effects' has the same meaning as 'side effects'
0178 // defined by the hasSideEffects property of the TableGen Instruction class.
0179 def IntrHasSideEffects : IntrinsicProperty;
0180
0181 //===----------------------------------------------------------------------===//
0182 // IIT constants and utils
0183 //===----------------------------------------------------------------------===//
0184
0185 // llvm::Intrinsic::IITDescriptor::ArgKind::AK_%
0186 def ArgKind {
0187 int Any = 0;
0188 int AnyInteger = 1;
0189 int AnyFloat = 2;
0190 int AnyVector = 3;
0191 int AnyPointer = 4;
0192
0193 int MatchType = 7;
0194 }
0195
0196 // Encode placeholder.
0197 // [15:8] is the ID used how to resolve ArgCode.
0198
0199 // (ACIdx << 3) | ArgCode
0200 class EncAnyType<int ArgCode=0> {
0201 int ID = 0x100;
0202 int ret = !or(ID, ArgCode);
0203 }
0204
0205 // (Mapping[Num] << 3) | AK.MatchType
0206 class EncMatchType<int Num=0> {
0207 int ID = 0x200;
0208 int ret = !or(ID, Num);
0209 }
0210
0211 // (Mapping[Num] << 3) | ArgCodes[Mapping[Num]]
0212 class EncSameWidth<int Num=0> {
0213 int ID = 0x300;
0214 int ret = !or(ID, Num);
0215 }
0216
0217 // ACIdx
0218 class EncNextArgA<int dummy=0> {
0219 int ID = 0x400;
0220 int ret = !or(ID, dummy);
0221 }
0222
0223 // Mapping[Num]
0224 class EncNextArgN<int Num=0> {
0225 int ID = 0x500;
0226 int ret = !or(ID, Num);
0227 }
0228
0229 class ResolveArgCode<
0230 list<int> Mapping,
0231 list<int> ArgCodes,
0232 int ACIdx,
0233 int ax> {
0234 int ah = !and(ax, 0xFF00);
0235 int al = !and(ax, 0x00FF);
0236 int num = Mapping[al];
0237 int ret = !cond(
0238 !eq(ah, EncAnyType<>.ID) : !or(!shl(ACIdx, 3), al),
0239 !eq(ah, EncMatchType<>.ID) : !or(!shl(num, 3), ArgKind.MatchType),
0240 !eq(ah, EncSameWidth<>.ID) : !or(!shl(num, 3), ArgCodes[num]),
0241 !eq(ah, EncNextArgA<>.ID) : ACIdx,
0242 !eq(ah, EncNextArgN<>.ID) : num,
0243 true : al);
0244 }
0245
0246 //===----------------------------------------------------------------------===//
0247 // IIT_Info
0248 //===----------------------------------------------------------------------===//
0249
0250 class IIT_Base<int num> {
0251 int Number = num;
0252 list<ValueType> VTs = ?;
0253 }
0254
0255 class IIT_VT<ValueType vt, int num> : IIT_Base<num> {
0256 let VTs = [vt];
0257 }
0258
0259 class IIT_Int<int size, int num> : IIT_Base<num> {
0260 let VTs = !filter(vti, ValueTypes,
0261 !and(vti.isInteger, !eq(vti.Size, size)));
0262 }
0263
0264 class IIT_Vec<int nelem, int num> : IIT_Base<num> {
0265 let VTs = !filter(vti, ValueTypes,
0266 !and(vti.isVector, !eq(vti.nElem, nelem)));
0267 }
0268
0269 defset list<IIT_Base> IIT_all = {
0270 def IIT_Done : IIT_Base< 0>;
0271 def IIT_I1 : IIT_Int<1, 1>;
0272 def IIT_I8 : IIT_Int<8, 2>;
0273 def IIT_I16 : IIT_Int<16, 3>;
0274 def IIT_I32 : IIT_Int<32, 4>;
0275 def IIT_I64 : IIT_Int<64, 5>;
0276 def IIT_F16 : IIT_VT<f16, 6>;
0277 def IIT_F32 : IIT_VT<f32, 7>;
0278 def IIT_F64 : IIT_VT<f64, 8>;
0279 def IIT_V2 : IIT_Vec<2, 9>;
0280 def IIT_V4 : IIT_Vec<4, 10>;
0281 def IIT_V8 : IIT_Vec<8, 11>;
0282 def IIT_V16 : IIT_Vec<16, 12>;
0283 def IIT_V32 : IIT_Vec<32, 13>;
0284 def IIT_PTR : IIT_Base< 14>;
0285 def IIT_ARG : IIT_Base< 15>;
0286
0287 def IIT_V64 : IIT_Vec<64, 16>;
0288 def IIT_MMX : IIT_VT<x86mmx, 17>;
0289 def IIT_TOKEN : IIT_VT<token, 18>;
0290 def IIT_METADATA : IIT_VT<MetadataVT, 19>;
0291 def IIT_EMPTYSTRUCT : IIT_VT<OtherVT, 20>;
0292 def IIT_STRUCT2 : IIT_Base<21>;
0293 def IIT_STRUCT3 : IIT_Base<22>;
0294 def IIT_STRUCT4 : IIT_Base<23>;
0295 def IIT_STRUCT5 : IIT_Base<24>;
0296 def IIT_EXTEND_ARG : IIT_Base<25>;
0297 def IIT_TRUNC_ARG : IIT_Base<26>;
0298 def IIT_ANYPTR : IIT_Base<27>;
0299 def IIT_V1 : IIT_Vec<1, 28>;
0300 def IIT_VARARG : IIT_VT<isVoid, 29>;
0301 def IIT_HALF_VEC_ARG : IIT_Base<30>;
0302 def IIT_SAME_VEC_WIDTH_ARG : IIT_Base<31>;
0303 def IIT_VEC_OF_ANYPTRS_TO_ELT : IIT_Base<34>;
0304 def IIT_I128 : IIT_Int<128, 35>;
0305 def IIT_V512 : IIT_Vec<512, 36>;
0306 def IIT_V1024 : IIT_Vec<1024, 37>;
0307 def IIT_STRUCT6 : IIT_Base<38>;
0308 def IIT_STRUCT7 : IIT_Base<39>;
0309 def IIT_STRUCT8 : IIT_Base<40>;
0310 def IIT_F128 : IIT_VT<f128, 41>;
0311 def IIT_VEC_ELEMENT : IIT_Base<42>;
0312 def IIT_SCALABLE_VEC : IIT_Base<43>;
0313 def IIT_SUBDIVIDE2_ARG : IIT_Base<44>;
0314 def IIT_SUBDIVIDE4_ARG : IIT_Base<45>;
0315 def IIT_VEC_OF_BITCASTS_TO_INT : IIT_Base<46>;
0316 def IIT_V128 : IIT_Vec<128, 47>;
0317 def IIT_BF16 : IIT_VT<bf16, 48>;
0318 def IIT_STRUCT9 : IIT_Base<49>;
0319 def IIT_V256 : IIT_Vec<256, 50>;
0320 def IIT_AMX : IIT_VT<x86amx, 51>;
0321 def IIT_PPCF128 : IIT_VT<ppcf128, 52>;
0322 def IIT_V3 : IIT_Vec<3, 53>;
0323 def IIT_EXTERNREF : IIT_VT<externref, 54>;
0324 def IIT_FUNCREF : IIT_VT<funcref, 55>;
0325 def IIT_I2 : IIT_Int<2, 57>;
0326 def IIT_I4 : IIT_Int<4, 58>;
0327 def IIT_AARCH64_SVCOUNT : IIT_VT<aarch64svcount, 59>;
0328 def IIT_V6 : IIT_Vec<6, 60>;
0329 def IIT_V10 : IIT_Vec<10, 61>;
0330 }
0331
0332 defvar IIT_all_FixedTypes = !filter(iit, IIT_all,
0333 !or(!isa<IIT_VT>(iit), !isa<IIT_Int>(iit)));
0334
0335 defvar IIT_all_VectorTypes = !filter(iit, IIT_all,
0336 !isa<IIT_Vec>(iit));
0337
0338 defvar IIT_RetNumbers = [
0339 [IIT_Done.Number],
0340 []<int>,
0341 [IIT_STRUCT2.Number],
0342 [IIT_STRUCT3.Number],
0343 [IIT_STRUCT4.Number],
0344 [IIT_STRUCT5.Number],
0345 [IIT_STRUCT6.Number],
0346 [IIT_STRUCT7.Number],
0347 [IIT_STRUCT8.Number],
0348 [IIT_STRUCT9.Number],
0349 ];
0350
0351 //===----------------------------------------------------------------------===//
0352 // Types used by intrinsics.
0353 //===----------------------------------------------------------------------===//
0354
0355 class LLVMType<ValueType vt> {
0356 ValueType VT = vt;
0357 int isAny = vt.isOverloaded;
0358
0359 int ArgCode = ?;
0360 int Number = ?;
0361
0362 list<IIT_Base> IITs = !filter(iit, IIT_all_FixedTypes,
0363 !not(!empty(!filter(iit_vt, iit.VTs,
0364 !eq(iit_vt, !if(vt.isVector, vt.ElementType, vt))))));
0365 assert !le(!size(IITs), 1), "Duplicate type";
0366
0367 list<IIT_Base> IIT_Vecs = !if(vt.isVector,
0368 !filter(iit, IIT_all_VectorTypes,
0369 !not(!empty(!filter(iit_vt, iit.VTs, !and(
0370 !eq(iit_vt.ElementType, vt.ElementType),
0371 !eq(iit_vt.nElem, vt.nElem)))))),
0372 []);
0373 assert !le(!size(IIT_Vecs), 1), "Duplicate type";
0374
0375 // For vector types, assert that the IIT_Vecs list is not empty.
0376 assert !or(!not(vt.isVector), !not(!empty(IIT_Vecs))),
0377 "Invalid IIT encoding for vector type v" # vt.nElem # vt.ElementType;
0378
0379 list<int> Sig = !listconcat(
0380 !if(vt.isScalable, [IIT_SCALABLE_VEC.Number], []),
0381 !foreach(iit, IIT_Vecs, iit.Number),
0382 !foreach(iit, IITs, iit.Number));
0383 }
0384
0385 class LLVMAnyType<ValueType vt> : LLVMType<vt> {
0386 let ArgCode = !cond(
0387 !eq(vt, Any) : ArgKind.Any,
0388 !eq(vt, iAny) : ArgKind.AnyInteger,
0389 !eq(vt, fAny) : ArgKind.AnyFloat,
0390 !eq(vt, vAny) : ArgKind.AnyVector,
0391 !eq(vt, pAny) : ArgKind.AnyPointer,
0392 );
0393 let Sig = [
0394 IIT_ARG.Number,
0395 EncAnyType<ArgCode>.ret,
0396 ];
0397
0398 assert isAny, "LLVMAnyType.VT should have isOverloaded";
0399 }
0400
0401 class LLVMQualPointerType<int addrspace>
0402 : LLVMType<iPTR> {
0403 assert !and(!le(0, addrspace), !le(addrspace, 255)),
0404 "Address space exceeds 255";
0405
0406 let Sig =
0407 !if(addrspace, [
0408 IIT_ANYPTR.Number,
0409 addrspace,
0410 ], [
0411 IIT_PTR.Number,
0412 ]);
0413 }
0414
0415 class LLVMAnyPointerType : LLVMAnyType<pAny> {
0416 assert isAny, "pAny should have isOverloaded";
0417 }
0418
0419 // Match the type of another intrinsic parameter. Number is an index into the
0420 // list of overloaded types for the intrinsic, excluding all the fixed types.
0421 // The Number value must refer to a previously listed type. For example:
0422 // Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_anyfloat_ty, LLVMMatchType<0>]>
0423 // has two overloaded types, the 2nd and 3rd arguments. LLVMMatchType<0>
0424 // refers to the first overloaded type, which is the 2nd argument.
0425 class LLVMMatchType<int num, IIT_Base IIT_Info = IIT_ARG>
0426 : LLVMType<OtherVT>{
0427 let Number = num;
0428 let Sig = [
0429 IIT_Info.Number,
0430 EncMatchType<num>.ret,
0431 ];
0432 }
0433
0434 class LLVMMatchTypeNextArg<int num, IIT_Base IIT_Info>
0435 : LLVMMatchType<num, IIT_Info> {
0436 let Sig = [
0437 IIT_Info.Number,
0438 EncNextArgA<>.ret,
0439 EncNextArgN<num>.ret,
0440 ];
0441 }
0442
0443 // Match the type of another intrinsic parameter that is expected to be based on
0444 // an integral type (i.e. either iN or <N x iM>), but change the scalar size to
0445 // be twice as wide or half as wide as the other type. This is only useful when
0446 // the intrinsic is overloaded, so the matched type should be declared as iAny.
0447 class LLVMExtendedType<int num> : LLVMMatchType<num, IIT_EXTEND_ARG>;
0448 class LLVMTruncatedType<int num> : LLVMMatchType<num, IIT_TRUNC_ARG>;
0449
0450 // Match the scalar/vector of another intrinsic parameter but with a different
0451 // element type. Either both are scalars or both are vectors with the same
0452 // number of elements.
0453 class LLVMScalarOrSameVectorWidth<int idx, LLVMType elty>
0454 : LLVMMatchType<idx, IIT_SAME_VEC_WIDTH_ARG> {
0455 let Sig = !listconcat([
0456 IIT_SAME_VEC_WIDTH_ARG.Number,
0457 EncSameWidth<idx>.ret,
0458 ], elty.Sig);
0459 }
0460
0461 class LLVMVectorOfAnyPointersToElt<int num>
0462 : LLVMMatchTypeNextArg<num, IIT_VEC_OF_ANYPTRS_TO_ELT>;
0463 class LLVMVectorElementType<int num> : LLVMMatchType<num, IIT_VEC_ELEMENT>;
0464
0465 // Match the type of another intrinsic parameter that is expected to be a
0466 // vector type, but change the element count to be half as many.
0467 class LLVMHalfElementsVectorType<int num>
0468 : LLVMMatchType<num, IIT_HALF_VEC_ARG>;
0469
0470 // Match the type of another intrinsic parameter that is expected to be a
0471 // vector type (i.e. <N x iM>) but with each element subdivided to
0472 // form a vector with more elements that are smaller than the original.
0473 class LLVMSubdivide2VectorType<int num>
0474 : LLVMMatchType<num, IIT_SUBDIVIDE2_ARG>;
0475 class LLVMSubdivide4VectorType<int num>
0476 : LLVMMatchType<num, IIT_SUBDIVIDE4_ARG>;
0477
0478 // Match the element count and bit width of another intrinsic parameter, but
0479 // change the element type to an integer.
0480 class LLVMVectorOfBitcastsToInt<int num>
0481 : LLVMMatchType<num, IIT_VEC_OF_BITCASTS_TO_INT>;
0482
0483 def llvm_void_ty : LLVMType<isVoid>;
0484
0485 def llvm_any_ty : LLVMAnyType<Any>;
0486 def llvm_anyint_ty : LLVMAnyType<iAny>;
0487 def llvm_anyfloat_ty : LLVMAnyType<fAny>;
0488 def llvm_anyvector_ty : LLVMAnyType<vAny>;
0489
0490 def llvm_i1_ty : LLVMType<i1>;
0491 def llvm_i8_ty : LLVMType<i8>;
0492 def llvm_i16_ty : LLVMType<i16>;
0493 def llvm_i32_ty : LLVMType<i32>;
0494 def llvm_i64_ty : LLVMType<i64>;
0495 def llvm_i128_ty : LLVMType<i128>;
0496 def llvm_half_ty : LLVMType<f16>;
0497 def llvm_bfloat_ty : LLVMType<bf16>;
0498 def llvm_float_ty : LLVMType<f32>;
0499 def llvm_double_ty : LLVMType<f64>;
0500 def llvm_f80_ty : LLVMType<f80>;
0501 def llvm_f128_ty : LLVMType<f128>;
0502 def llvm_ppcf128_ty : LLVMType<ppcf128>;
0503 def llvm_ptr_ty : LLVMQualPointerType<0>; // ptr
0504 def llvm_anyptr_ty : LLVMAnyPointerType; // ptr addrspace(N)
0505 def llvm_empty_ty : LLVMType<OtherVT>; // { }
0506 def llvm_metadata_ty : LLVMType<MetadataVT>; // !{...}
0507 def llvm_token_ty : LLVMType<token>; // token
0508
0509 def llvm_x86mmx_ty : LLVMType<x86mmx>;
0510
0511 def llvm_aarch64_svcount_ty : LLVMType<aarch64svcount>;
0512
0513 def llvm_x86amx_ty : LLVMType<x86amx>;
0514
0515 def llvm_v2i1_ty : LLVMType<v2i1>; // 2 x i1
0516 def llvm_v4i1_ty : LLVMType<v4i1>; // 4 x i1
0517 def llvm_v8i1_ty : LLVMType<v8i1>; // 8 x i1
0518 def llvm_v16i1_ty : LLVMType<v16i1>; // 16 x i1
0519 def llvm_v32i1_ty : LLVMType<v32i1>; // 32 x i1
0520 def llvm_v64i1_ty : LLVMType<v64i1>; // 64 x i1
0521 def llvm_v128i1_ty : LLVMType<v128i1>; // 128 x i1
0522 def llvm_v256i1_ty : LLVMType<v256i1>; // 256 x i1
0523 def llvm_v512i1_ty : LLVMType<v512i1>; // 512 x i1
0524 def llvm_v1024i1_ty : LLVMType<v1024i1>; //1024 x i1
0525
0526 def llvm_v1i8_ty : LLVMType<v1i8>; // 1 x i8
0527 def llvm_v2i8_ty : LLVMType<v2i8>; // 2 x i8
0528 def llvm_v3i8_ty : LLVMType<v3i8>; // 3 x i8
0529 def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8
0530 def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8
0531 def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8
0532 def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8
0533 def llvm_v64i8_ty : LLVMType<v64i8>; // 64 x i8
0534 def llvm_v128i8_ty : LLVMType<v128i8>; //128 x i8
0535 def llvm_v256i8_ty : LLVMType<v256i8>; //256 x i8
0536
0537 def llvm_v1i16_ty : LLVMType<v1i16>; // 1 x i16
0538 def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16
0539 def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16
0540 def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16
0541 def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16
0542 def llvm_v32i16_ty : LLVMType<v32i16>; // 32 x i16
0543 def llvm_v64i16_ty : LLVMType<v64i16>; // 64 x i16
0544 def llvm_v128i16_ty : LLVMType<v128i16>; //128 x i16
0545
0546 def llvm_v1i32_ty : LLVMType<v1i32>; // 1 x i32
0547 def llvm_v2i32_ty : LLVMType<v2i32>; // 2 x i32
0548 def llvm_v3i32_ty : LLVMType<v3i32>; // 3 x i32
0549 def llvm_v4i32_ty : LLVMType<v4i32>; // 4 x i32
0550 def llvm_v6i32_ty : LLVMType<v6i32>; // 6 x i32
0551 def llvm_v8i32_ty : LLVMType<v8i32>; // 8 x i32
0552 def llvm_v16i32_ty : LLVMType<v16i32>; // 16 x i32
0553 def llvm_v32i32_ty : LLVMType<v32i32>; // 32 x i32
0554 def llvm_v64i32_ty : LLVMType<v64i32>; // 64 x i32
0555 def llvm_v256i32_ty : LLVMType<v256i32>; //256 x i32
0556
0557 def llvm_v1i64_ty : LLVMType<v1i64>; // 1 x i64
0558 def llvm_v2i64_ty : LLVMType<v2i64>; // 2 x i64
0559 def llvm_v4i64_ty : LLVMType<v4i64>; // 4 x i64
0560 def llvm_v8i64_ty : LLVMType<v8i64>; // 8 x i64
0561 def llvm_v16i64_ty : LLVMType<v16i64>; // 16 x i64
0562 def llvm_v32i64_ty : LLVMType<v32i64>; // 32 x i64
0563
0564 def llvm_v1i128_ty : LLVMType<v1i128>; // 1 x i128
0565
0566 def llvm_v2f16_ty : LLVMType<v2f16>; // 2 x half (__fp16)
0567 def llvm_v4f16_ty : LLVMType<v4f16>; // 4 x half (__fp16)
0568 def llvm_v8f16_ty : LLVMType<v8f16>; // 8 x half (__fp16)
0569 def llvm_v16f16_ty : LLVMType<v16f16>; // 16 x half (__fp16)
0570 def llvm_v32f16_ty : LLVMType<v32f16>; // 32 x half (__fp16)
0571 def llvm_v2bf16_ty : LLVMType<v2bf16>; // 2 x bfloat (__bf16)
0572 def llvm_v4bf16_ty : LLVMType<v4bf16>; // 4 x bfloat (__bf16)
0573 def llvm_v8bf16_ty : LLVMType<v8bf16>; // 8 x bfloat (__bf16)
0574 def llvm_v16bf16_ty : LLVMType<v16bf16>; // 16 x bfloat (__bf16)
0575 def llvm_v32bf16_ty : LLVMType<v32bf16>; // 32 x bfloat (__bf16)
0576 def llvm_v1f32_ty : LLVMType<v1f32>; // 1 x float
0577 def llvm_v2f32_ty : LLVMType<v2f32>; // 2 x float
0578 def llvm_v3f32_ty : LLVMType<v3f32>; // 3 x float
0579 def llvm_v4f32_ty : LLVMType<v4f32>; // 4 x float
0580 def llvm_v8f32_ty : LLVMType<v8f32>; // 8 x float
0581 def llvm_v16f32_ty : LLVMType<v16f32>; // 16 x float
0582 def llvm_v32f32_ty : LLVMType<v32f32>; // 32 x float
0583 def llvm_v1f64_ty : LLVMType<v1f64>; // 1 x double
0584 def llvm_v2f64_ty : LLVMType<v2f64>; // 2 x double
0585 def llvm_v4f64_ty : LLVMType<v4f64>; // 4 x double
0586 def llvm_v8f64_ty : LLVMType<v8f64>; // 8 x double
0587 def llvm_v16f64_ty : LLVMType<v16f64>; // 16 x double
0588
0589 def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here
0590
0591 def llvm_externref_ty : LLVMType<externref>;
0592 def llvm_funcref_ty : LLVMType<funcref>;
0593 def llvm_exnref_ty : LLVMType<exnref>;
0594
0595 //===----------------------------------------------------------------------===//
0596
0597 class MakeIdx<list<int> Set> {
0598 list<int> IdxsR = !foreach(i, !range(Set),
0599 !if(Set[i],
0600 !foldl(0, !range(0, i), m, j, !add(m, Set[j])),
0601 -1));
0602
0603 list<int> RIdxsR = !foreach(i, !range(Set),
0604 !foldl(-1, !range(Set), m, j,
0605 !if(!and(Set[j], !eq(IdxsR[j], i)), j, m)));
0606
0607 list<int> Idxs = !foreach(a, IdxsR, !if(!ge(a, 0), a, ?));
0608 list<int> RIdxs = !foreach(a, RIdxsR, !if(!ge(a, 0), a, ?));
0609 }
0610
0611 class TypeInfoGen<
0612 list<LLVMType> RetTypes,
0613 list<LLVMType> ParamTypes> {
0614 list<LLVMType> AllTypes = !listconcat(RetTypes, ParamTypes);
0615
0616 // ArgCodes for NextArg -- isAny or MatchTypeNextArg
0617 list<int> ACIdxs = MakeIdx<
0618 !foreach(ty, AllTypes,
0619 !or(ty.isAny, !isa<LLVMMatchTypeNextArg>(ty)))>.Idxs;
0620
0621 // ArgCodes (only for isAny or MatchTypeNextArg)
0622 list<LLVMType> ACTys = !filter(ty, AllTypes,
0623 !or(ty.isAny, !isa<LLVMMatchTypeNextArg>(ty)));
0624
0625 list<int> ArgCodes = !foreach(ty, ACTys, ty.ArgCode);
0626
0627 // Mappings MatchTypeIdx to ACTys
0628 list<int> MappingRIdxs = MakeIdx<
0629 !foreach(ty, ACTys, ty.isAny)>.RIdxs;
0630
0631 // D63507: Exclude LLVMPointerType<llvm_any_ty>
0632 bit isOverloaded = !not(!empty(!filter(ty, AllTypes,
0633 !isa<LLVMAnyType>(ty))));
0634
0635 list<LLVMType> Types = !foreach(ty, AllTypes,
0636 !if(!isa<LLVMMatchType>(ty), ACTys[MappingRIdxs[ty.Number]], ty));
0637
0638 list<int> TypeSig = !listflatten(!listconcat(
0639 [IIT_RetNumbers[!size(RetTypes)]],
0640 !foreach(i, !range(AllTypes),
0641 !foreach(a, AllTypes[i].Sig,
0642 ResolveArgCode<
0643 MappingRIdxs,
0644 ArgCodes,
0645 ACIdxs[i],
0646 a>.ret))));
0647 }
0648
0649 //===----------------------------------------------------------------------===//
0650 // Intrinsic Definitions.
0651 //===----------------------------------------------------------------------===//
0652
0653 // Intrinsic class - This is used to define one LLVM intrinsic. The name of the
0654 // intrinsic definition should start with "int_", then match the LLVM intrinsic
0655 // name with the "llvm." prefix removed, and all "."s turned into "_"s. For
0656 // example, llvm.bswap.i16 -> int_bswap_i16.
0657 //
0658 // * RetTypes is a list containing the return types expected for the
0659 // intrinsic.
0660 // * ParamTypes is a list containing the parameter types expected for the
0661 // intrinsic.
0662 // * Properties can be set to describe the behavior of the intrinsic.
0663 //
0664 class Intrinsic<list<LLVMType> ret_types,
0665 list<LLVMType> param_types = [],
0666 list<IntrinsicProperty> intr_properties = [],
0667 string name = "",
0668 list<SDNodeProperty> sd_properties = [],
0669 bit disable_default_attributes = true> : SDPatternOperator {
0670 string LLVMName = name;
0671 string TargetPrefix = ""; // Set to a prefix for target-specific intrinsics.
0672 list<LLVMType> RetTypes = ret_types;
0673 list<LLVMType> ParamTypes = param_types;
0674 list<IntrinsicProperty> IntrProperties = intr_properties;
0675 let Properties = sd_properties;
0676
0677 // Disable applying IntrinsicProperties that are marked default with
0678 // IntrinsicProperty<1>
0679 bit DisableDefaultAttributes = disable_default_attributes;
0680
0681 TypeInfoGen TypeInfo = TypeInfoGen<RetTypes, ParamTypes>;
0682 }
0683
0684 // Intrinsic with default attributes (disable_default_attributes = false).
0685 class DefaultAttrsIntrinsic<list<LLVMType> ret_types,
0686 list<LLVMType> param_types = [],
0687 list<IntrinsicProperty> intr_properties = [],
0688 string name = "",
0689 list<SDNodeProperty> sd_properties = []>
0690 : Intrinsic<ret_types, param_types,
0691 intr_properties, name,
0692 sd_properties, /*disable_default_attributes*/ 0> {}
0693
0694 /// ClangBuiltin - If this intrinsic exactly corresponds to a Clang builtin, this
0695 /// specifies the name of the builtin. This provides automatic CBE and CFE
0696 /// support.
0697 class ClangBuiltin<string name> {
0698 string ClangBuiltinName = name;
0699 }
0700
0701 class MSBuiltin<string name> {
0702 string MSBuiltinName = name;
0703 }
0704
0705 #ifndef TEST_INTRINSICS_SUPPRESS_DEFS
0706
0707 //===--------------- Variable Argument Handling Intrinsics ----------------===//
0708 //
0709
0710 def int_vastart : DefaultAttrsIntrinsic<[],
0711 [llvm_anyptr_ty], [], "llvm.va_start">;
0712 def int_vacopy : DefaultAttrsIntrinsic<[],
0713 [llvm_anyptr_ty, LLVMMatchType<0>], [],
0714 "llvm.va_copy">;
0715 def int_vaend : DefaultAttrsIntrinsic<[],
0716 [llvm_anyptr_ty], [], "llvm.va_end">;
0717
0718 //===------------------- Garbage Collection Intrinsics --------------------===//
0719 //
0720 def int_gcroot : Intrinsic<[],
0721 [llvm_ptr_ty, llvm_ptr_ty]>;
0722 def int_gcread : Intrinsic<[llvm_ptr_ty],
0723 [llvm_ptr_ty, llvm_ptr_ty],
0724 [IntrReadMem, IntrArgMemOnly]>;
0725 def int_gcwrite : Intrinsic<[],
0726 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
0727 [IntrArgMemOnly, NoCapture<ArgIndex<1>>,
0728 NoCapture<ArgIndex<2>>]>;
0729
0730 //===------------------- ObjC ARC runtime Intrinsics --------------------===//
0731 //
0732 // Note these are to support the Objective-C ARC optimizer which wants to
0733 // eliminate retain and releases where possible.
0734
0735 def int_objc_autorelease : Intrinsic<[llvm_ptr_ty],
0736 [llvm_ptr_ty],
0737 [Returned<ArgIndex<0>>]>;
0738 def int_objc_autoreleasePoolPop : Intrinsic<[], [llvm_ptr_ty]>;
0739 def int_objc_autoreleasePoolPush : Intrinsic<[llvm_ptr_ty], []>;
0740 def int_objc_autoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
0741 [llvm_ptr_ty],
0742 [Returned<ArgIndex<0>>]>;
0743 def int_objc_copyWeak : Intrinsic<[],
0744 [llvm_ptr_ty,
0745 llvm_ptr_ty]>;
0746 def int_objc_destroyWeak : Intrinsic<[], [llvm_ptr_ty]>;
0747 def int_objc_initWeak : Intrinsic<[llvm_ptr_ty],
0748 [llvm_ptr_ty,
0749 llvm_ptr_ty]>;
0750 def int_objc_loadWeak : Intrinsic<[llvm_ptr_ty],
0751 [llvm_ptr_ty]>;
0752 def int_objc_loadWeakRetained : Intrinsic<[llvm_ptr_ty],
0753 [llvm_ptr_ty]>;
0754 def int_objc_moveWeak : Intrinsic<[],
0755 [llvm_ptr_ty,
0756 llvm_ptr_ty]>;
0757 def int_objc_release : Intrinsic<[], [llvm_ptr_ty]>;
0758 def int_objc_retain : Intrinsic<[llvm_ptr_ty],
0759 [llvm_ptr_ty],
0760 [Returned<ArgIndex<0>>]>;
0761 def int_objc_retainAutorelease : Intrinsic<[llvm_ptr_ty],
0762 [llvm_ptr_ty],
0763 [Returned<ArgIndex<0>>]>;
0764 def int_objc_retainAutoreleaseReturnValue : Intrinsic<[llvm_ptr_ty],
0765 [llvm_ptr_ty],
0766 [Returned<ArgIndex<0>>]>;
0767 def int_objc_retainAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
0768 [llvm_ptr_ty]>;
0769 def int_objc_retainBlock : Intrinsic<[llvm_ptr_ty],
0770 [llvm_ptr_ty]>;
0771 def int_objc_storeStrong : Intrinsic<[],
0772 [llvm_ptr_ty,
0773 llvm_ptr_ty]>;
0774 def int_objc_storeWeak : Intrinsic<[llvm_ptr_ty],
0775 [llvm_ptr_ty,
0776 llvm_ptr_ty]>;
0777 def int_objc_clang_arc_use : Intrinsic<[],
0778 [llvm_vararg_ty]>;
0779 def int_objc_clang_arc_noop_use : DefaultAttrsIntrinsic<[],
0780 [llvm_vararg_ty],
0781 [IntrInaccessibleMemOnly]>;
0782 def int_objc_unsafeClaimAutoreleasedReturnValue : Intrinsic<[llvm_ptr_ty],
0783 [llvm_ptr_ty]>;
0784 def int_objc_retainedObject : Intrinsic<[llvm_ptr_ty],
0785 [llvm_ptr_ty]>;
0786 def int_objc_unretainedObject : Intrinsic<[llvm_ptr_ty],
0787 [llvm_ptr_ty]>;
0788 def int_objc_unretainedPointer : Intrinsic<[llvm_ptr_ty],
0789 [llvm_ptr_ty]>;
0790 def int_objc_retain_autorelease : Intrinsic<[llvm_ptr_ty],
0791 [llvm_ptr_ty],
0792 [Returned<ArgIndex<0>>]>;
0793 def int_objc_sync_enter : Intrinsic<[llvm_i32_ty],
0794 [llvm_ptr_ty]>;
0795 def int_objc_sync_exit : Intrinsic<[llvm_i32_ty],
0796 [llvm_ptr_ty]>;
0797 def int_objc_arc_annotation_topdown_bbstart : Intrinsic<[],
0798 [llvm_ptr_ty,
0799 llvm_ptr_ty]>;
0800 def int_objc_arc_annotation_topdown_bbend : Intrinsic<[],
0801 [llvm_ptr_ty,
0802 llvm_ptr_ty]>;
0803 def int_objc_arc_annotation_bottomup_bbstart : Intrinsic<[],
0804 [llvm_ptr_ty,
0805 llvm_ptr_ty]>;
0806 def int_objc_arc_annotation_bottomup_bbend : Intrinsic<[],
0807 [llvm_ptr_ty,
0808 llvm_ptr_ty]>;
0809 //===--------------- Swift asynchronous context intrinsics ----------------===//
0810
0811 // Returns the location of the Swift asynchronous context (usually stored just
0812 // before the frame pointer), and triggers the creation of a null context if it
0813 // would otherwise be unneeded.
0814 def int_swift_async_context_addr : Intrinsic<[llvm_ptr_ty], [], []>;
0815
0816 //===--------------------- Code Generator Intrinsics ----------------------===//
0817 //
0818 def int_returnaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_i32_ty],
0819 [IntrNoMem, ImmArg<ArgIndex<0>>]>;
0820 def int_addressofreturnaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
0821 def int_frameaddress : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [llvm_i32_ty],
0822 [IntrNoMem, ImmArg<ArgIndex<0>>]>;
0823 def int_sponentry : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [], [IntrNoMem]>;
0824 def int_read_register : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
0825 [IntrReadMem], "llvm.read_register">;
0826 def int_write_register : Intrinsic<[], [llvm_metadata_ty, llvm_anyint_ty],
0827 [IntrNoCallback], "llvm.write_register">;
0828 def int_read_volatile_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
0829 [IntrHasSideEffects],
0830 "llvm.read_volatile_register">;
0831
0832 // Gets the address of the local variable area. This is typically a copy of the
0833 // stack, frame, or base pointer depending on the type of prologue.
0834 def int_localaddress : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
0835
0836 // Escapes local variables to allow access from other functions.
0837 def int_localescape : DefaultAttrsIntrinsic<[], [llvm_vararg_ty]>;
0838
0839 // Given a function and the localaddress of a parent frame, returns a pointer
0840 // to an escaped allocation indicated by the index.
0841 def int_localrecover : DefaultAttrsIntrinsic<[llvm_ptr_ty],
0842 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
0843 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
0844
0845 // Given the frame pointer passed into an SEH filter function, returns a
0846 // pointer to the local variable area suitable for use with llvm.localrecover.
0847 def int_eh_recoverfp : DefaultAttrsIntrinsic<[llvm_ptr_ty],
0848 [llvm_ptr_ty, llvm_ptr_ty],
0849 [IntrNoMem]>;
0850
0851 // To mark the beginning/end of a try-scope for Windows SEH -EHa
0852 // calls/invokes to these intrinsics are placed to model control flows
0853 // caused by HW exceptions under option -EHa.
0854 // calls/invokes to these intrinsics will be discarded during a codegen pass
0855 // after EH tables are generated
0856 def int_seh_try_begin : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
0857 def int_seh_try_end : Intrinsic<[], [], [IntrWriteMem, IntrWillReturn]>;
0858 def int_seh_scope_begin : Intrinsic<[], [], [IntrNoMem]>;
0859 def int_seh_scope_end : Intrinsic<[], [], [IntrNoMem]>;
0860
0861 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
0862 // model their dependencies on allocas.
0863 def int_stacksave : DefaultAttrsIntrinsic<[llvm_anyptr_ty]>,
0864 ClangBuiltin<"__builtin_stack_save">;
0865 def int_stackrestore : DefaultAttrsIntrinsic<[], [llvm_anyptr_ty]>,
0866 ClangBuiltin<"__builtin_stack_restore">;
0867
0868 def int_get_dynamic_area_offset : DefaultAttrsIntrinsic<[llvm_anyint_ty]>;
0869
0870 def int_thread_pointer : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], [IntrNoMem]>,
0871 ClangBuiltin<"__builtin_thread_pointer">;
0872
0873 // IntrInaccessibleMemOrArgMemOnly is a little more pessimistic than strictly
0874 // necessary for prefetch, however it does conveniently prevent the prefetch
0875 // from being reordered overly much with respect to nearby access to the same
0876 // memory while not impeding optimization.
0877 def int_prefetch
0878 : DefaultAttrsIntrinsic<[], [ llvm_anyptr_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty ],
0879 [IntrInaccessibleMemOrArgMemOnly, IntrWillReturn,
0880 ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>,
0881 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>]>;
0882 def int_pcmarker : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
0883
0884 def int_readcyclecounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>;
0885
0886 def int_readsteadycounter : DefaultAttrsIntrinsic<[llvm_i64_ty]>;
0887
0888 // The assume intrinsic is marked InaccessibleMemOnly so that proper control
0889 // dependencies will be maintained.
0890 def int_assume : DefaultAttrsIntrinsic<
0891 [], [llvm_i1_ty], [IntrWriteMem, IntrInaccessibleMemOnly, NoUndef<ArgIndex<0>>]>;
0892
0893 // 'llvm.experimental.noalias.scope.decl' intrinsic: Inserted at the location of
0894 // noalias scope declaration. Makes it possible to identify that a noalias scope
0895 // is only valid inside the body of a loop.
0896 //
0897 // Purpose of the different arguments:
0898 // - arg0: id.scope: metadata representing the scope declaration.
0899 def int_experimental_noalias_scope_decl
0900 : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
0901 [IntrInaccessibleMemOnly]>; // blocks LICM and some more
0902
0903 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
0904 // guard to the correct place on the stack frame.
0905 def int_stackprotector : DefaultAttrsIntrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>;
0906 def int_stackguard : DefaultAttrsIntrinsic<[llvm_ptr_ty], [], []>;
0907
0908 // A cover for instrumentation based profiling.
0909 def int_instrprof_cover : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty,
0910 llvm_i32_ty, llvm_i32_ty]>;
0911
0912 // A counter increment for instrumentation based profiling.
0913 def int_instrprof_increment : Intrinsic<[],
0914 [llvm_ptr_ty, llvm_i64_ty,
0915 llvm_i32_ty, llvm_i32_ty]>;
0916
0917 // A counter increment with step for instrumentation based profiling.
0918 def int_instrprof_increment_step : Intrinsic<[],
0919 [llvm_ptr_ty, llvm_i64_ty,
0920 llvm_i32_ty, llvm_i32_ty, llvm_i64_ty]>;
0921
0922 // Callsite instrumentation for contextual profiling
0923 def int_instrprof_callsite : Intrinsic<[],
0924 [llvm_ptr_ty, llvm_i64_ty,
0925 llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty]>;
0926
0927 // A timestamp for instrumentation based profiling.
0928 def int_instrprof_timestamp : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty,
0929 llvm_i32_ty, llvm_i32_ty]>;
0930
0931 // A call to profile runtime for value profiling of target expressions
0932 // through instrumentation based profiling.
0933 def int_instrprof_value_profile : Intrinsic<[],
0934 [llvm_ptr_ty, llvm_i64_ty,
0935 llvm_i64_ty, llvm_i32_ty,
0936 llvm_i32_ty]>;
0937
0938 // A parameter configuration for instrumentation based MCDC profiling.
0939 def int_instrprof_mcdc_parameters : Intrinsic<[],
0940 [llvm_ptr_ty, llvm_i64_ty,
0941 llvm_i32_ty]>;
0942
0943 // A test vector bitmap update for instrumentation based MCDC profiling.
0944 def int_instrprof_mcdc_tvbitmap_update : Intrinsic<[],
0945 [llvm_ptr_ty, llvm_i64_ty,
0946 llvm_i32_ty, llvm_ptr_ty]>;
0947
0948 def int_call_preallocated_setup : DefaultAttrsIntrinsic<[llvm_token_ty], [llvm_i32_ty]>;
0949 def int_call_preallocated_arg : DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_i32_ty]>;
0950 def int_call_preallocated_teardown : DefaultAttrsIntrinsic<[], [llvm_token_ty]>;
0951
0952 // This intrinsic is intentionally undocumented and users shouldn't call it;
0953 // it's produced then quickly consumed during codegen.
0954 def int_callbr_landingpad : Intrinsic<[llvm_any_ty], [LLVMMatchType<0>],
0955 [IntrNoMerge]>;
0956
0957 //===------------------- Standard C Library Intrinsics --------------------===//
0958 //
0959
0960 def int_memcpy : Intrinsic<[],
0961 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
0962 llvm_i1_ty],
0963 [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
0964 IntrNoCallback,
0965 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
0966 NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
0967 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
0968 ImmArg<ArgIndex<3>>]>;
0969
0970 // Memcpy semantic that is guaranteed to be inlined.
0971 // In particular this means that the generated code is not allowed to call any
0972 // external function.
0973 def int_memcpy_inline
0974 : Intrinsic<[],
0975 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i1_ty],
0976 [IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
0977 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
0978 NoAlias<ArgIndex<0>>, NoAlias<ArgIndex<1>>,
0979 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
0980 ImmArg<ArgIndex<3>>]>;
0981
0982 def int_memmove : Intrinsic<[],
0983 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty,
0984 llvm_i1_ty],
0985 [IntrArgMemOnly, IntrWillReturn, IntrNoFree,
0986 IntrNoCallback,
0987 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
0988 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
0989 ImmArg<ArgIndex<3>>]>;
0990 def int_memset : Intrinsic<[],
0991 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
0992 llvm_i1_ty],
0993 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
0994 IntrNoFree, IntrNoCallback,
0995 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
0996 ImmArg<ArgIndex<3>>]>;
0997
0998 // Memset version that is guaranteed to be inlined.
0999 // In particular this means that the generated code is not allowed to call any
1000 // external function.
1001 // The third argument (specifying the size) must be a constant.
1002 def int_memset_inline
1003 : Intrinsic<[],
1004 [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i1_ty],
1005 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
1006 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1007 ImmArg<ArgIndex<3>>]>;
1008
1009 // Memset variant that writes a given pattern.
1010 def int_experimental_memset_pattern
1011 : Intrinsic<[],
1012 [llvm_anyptr_ty, // Destination.
1013 llvm_anyint_ty, // Pattern value.
1014 llvm_anyint_ty, // Count (number of times to fill value).
1015 llvm_i1_ty], // IsVolatile.
1016 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoFree, IntrNoCallback,
1017 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1018 ImmArg<ArgIndex<3>>]>;
1019
1020 // FIXME: Add version of these floating point intrinsics which allow non-default
1021 // rounding modes and FP exception handling.
1022
1023 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1024 def int_fma : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1025 [LLVMMatchType<0>, LLVMMatchType<0>,
1026 LLVMMatchType<0>]>;
1027 def int_fmuladd : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1028 [LLVMMatchType<0>, LLVMMatchType<0>,
1029 LLVMMatchType<0>]>;
1030
1031 // These functions do not read memory, but are sensitive to the
1032 // rounding mode. LLVM purposely does not model changes to the FP
1033 // environment so they can be treated as readnone.
1034 def int_sqrt : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1035 def int_powi : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, llvm_anyint_ty]>;
1036 def int_asin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1037 def int_acos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1038 def int_atan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1039 def int_atan2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>;
1040 def int_sin : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1041 def int_cos : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1042 def int_tan : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1043 def int_sinh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1044 def int_cosh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1045 def int_tanh : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1046 def int_pow : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1047 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1048 def int_log : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1049 def int_log10: DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1050 def int_log2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1051 def int_exp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1052 def int_exp2 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1053 def int_exp10 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1054 def int_fabs : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1055 def int_copysign : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1056 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1057 def int_floor : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1058 def int_ceil : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1059 def int_trunc : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1060 def int_rint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1061 def int_nearbyint : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1062 def int_round : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1063 def int_roundeven : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>;
1064 def int_sincos : DefaultAttrsIntrinsic<[LLVMMatchType<0>, LLVMMatchType<0>],
1065 [llvm_anyfloat_ty]>;
1066
1067 // Truncate a floating point number with a specific rounding mode
1068 def int_fptrunc_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1069 [ llvm_anyfloat_ty, llvm_metadata_ty ]>;
1070
1071 def int_canonicalize : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
1072 [IntrNoMem]>;
1073 // Arithmetic fence intrinsic.
1074 def int_arithmetic_fence : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
1075 [IntrNoMem]>;
1076
1077 def int_lround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1078 def int_llround : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1079 def int_lrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1080 def int_llrint : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1081
1082 // TODO: int operand should be constrained to same number of elements as the result.
1083 def int_ldexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>,
1084 llvm_anyint_ty]>;
1085
1086 // TODO: Should constrain all element counts to match
1087 def int_frexp : DefaultAttrsIntrinsic<[llvm_anyfloat_ty, llvm_anyint_ty], [LLVMMatchType<0>]>;
1088 }
1089
1090 def int_minnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1091 [LLVMMatchType<0>, LLVMMatchType<0>],
1092 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1093 >;
1094 def int_maxnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1095 [LLVMMatchType<0>, LLVMMatchType<0>],
1096 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1097 >;
1098 def int_minimum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1099 [LLVMMatchType<0>, LLVMMatchType<0>],
1100 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1101 >;
1102 def int_maximum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1103 [LLVMMatchType<0>, LLVMMatchType<0>],
1104 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1105 >;
1106 def int_minimumnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1107 [LLVMMatchType<0>, LLVMMatchType<0>],
1108 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1109 >;
1110 def int_maximumnum : DefaultAttrsIntrinsic<[llvm_anyfloat_ty],
1111 [LLVMMatchType<0>, LLVMMatchType<0>],
1112 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
1113 >;
1114
1115 // Internal interface for object size checking
1116 def int_objectsize : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1117 [llvm_anyptr_ty, llvm_i1_ty,
1118 llvm_i1_ty, llvm_i1_ty],
1119 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1120 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>,
1121 ImmArg<ArgIndex<3>>]>,
1122 ClangBuiltin<"__builtin_object_size">;
1123
1124 //===--------------- Access to Floating Point Environment -----------------===//
1125 //
1126
1127 let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
1128 def int_get_rounding : DefaultAttrsIntrinsic<[llvm_i32_ty], []>;
1129 def int_set_rounding : DefaultAttrsIntrinsic<[], [llvm_i32_ty]>;
1130 def int_get_fpenv : DefaultAttrsIntrinsic<[llvm_anyint_ty], []>;
1131 def int_set_fpenv : DefaultAttrsIntrinsic<[], [llvm_anyint_ty]>;
1132 def int_reset_fpenv : DefaultAttrsIntrinsic<[], []>;
1133 def int_get_fpmode : DefaultAttrsIntrinsic<[llvm_anyint_ty], []>;
1134 def int_set_fpmode : DefaultAttrsIntrinsic<[], [llvm_anyint_ty]>;
1135 def int_reset_fpmode : DefaultAttrsIntrinsic<[], []>;
1136 }
1137
1138 //===--------------- Floating Point Properties ----------------------------===//
1139 //
1140
1141 def int_is_fpclass
1142 : DefaultAttrsIntrinsic<[LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1143 [llvm_anyfloat_ty, llvm_i32_ty],
1144 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
1145
1146 //===--------------- Constrained Floating Point Intrinsics ----------------===//
1147 //
1148
1149 /// IntrStrictFP - The intrinsic is allowed to be used in an alternate
1150 /// floating point environment.
1151 def IntrStrictFP : IntrinsicProperty;
1152
1153 let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn, IntrStrictFP] in {
1154 def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1155 [ LLVMMatchType<0>,
1156 LLVMMatchType<0>,
1157 llvm_metadata_ty,
1158 llvm_metadata_ty ]>;
1159 def int_experimental_constrained_fsub : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1160 [ LLVMMatchType<0>,
1161 LLVMMatchType<0>,
1162 llvm_metadata_ty,
1163 llvm_metadata_ty ]>;
1164 def int_experimental_constrained_fmul : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1165 [ LLVMMatchType<0>,
1166 LLVMMatchType<0>,
1167 llvm_metadata_ty,
1168 llvm_metadata_ty ]>;
1169 def int_experimental_constrained_fdiv : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1170 [ LLVMMatchType<0>,
1171 LLVMMatchType<0>,
1172 llvm_metadata_ty,
1173 llvm_metadata_ty ]>;
1174 def int_experimental_constrained_frem : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1175 [ LLVMMatchType<0>,
1176 LLVMMatchType<0>,
1177 llvm_metadata_ty,
1178 llvm_metadata_ty ]>;
1179
1180 def int_experimental_constrained_fma : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1181 [ LLVMMatchType<0>,
1182 LLVMMatchType<0>,
1183 LLVMMatchType<0>,
1184 llvm_metadata_ty,
1185 llvm_metadata_ty ]>;
1186
1187 def int_experimental_constrained_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1188 [ LLVMMatchType<0>,
1189 LLVMMatchType<0>,
1190 LLVMMatchType<0>,
1191 llvm_metadata_ty,
1192 llvm_metadata_ty ]>;
1193
1194 def int_experimental_constrained_fptosi : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1195 [ llvm_anyfloat_ty,
1196 llvm_metadata_ty ]>;
1197
1198 def int_experimental_constrained_fptoui : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1199 [ llvm_anyfloat_ty,
1200 llvm_metadata_ty ]>;
1201
1202 def int_experimental_constrained_sitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1203 [ llvm_anyint_ty,
1204 llvm_metadata_ty,
1205 llvm_metadata_ty ]>;
1206
1207 def int_experimental_constrained_uitofp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1208 [ llvm_anyint_ty,
1209 llvm_metadata_ty,
1210 llvm_metadata_ty ]>;
1211
1212 def int_experimental_constrained_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1213 [ llvm_anyfloat_ty,
1214 llvm_metadata_ty,
1215 llvm_metadata_ty ]>;
1216
1217 def int_experimental_constrained_fpext : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1218 [ llvm_anyfloat_ty,
1219 llvm_metadata_ty ]>;
1220
1221 // These intrinsics are sensitive to the rounding mode so we need constrained
1222 // versions of each of them. When strict rounding and exception control are
1223 // not required the non-constrained versions of these intrinsics should be
1224 // used.
1225 def int_experimental_constrained_sqrt : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1226 [ LLVMMatchType<0>,
1227 llvm_metadata_ty,
1228 llvm_metadata_ty ]>;
1229 def int_experimental_constrained_powi : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1230 [ LLVMMatchType<0>,
1231 llvm_i32_ty,
1232 llvm_metadata_ty,
1233 llvm_metadata_ty ]>;
1234 def int_experimental_constrained_ldexp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1235 [ LLVMMatchType<0>,
1236 llvm_anyint_ty,
1237 llvm_metadata_ty,
1238 llvm_metadata_ty ]>;
1239 def int_experimental_constrained_asin : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1240 [ LLVMMatchType<0>,
1241 llvm_metadata_ty,
1242 llvm_metadata_ty ]>;
1243 def int_experimental_constrained_acos : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1244 [ LLVMMatchType<0>,
1245 llvm_metadata_ty,
1246 llvm_metadata_ty ]>;
1247 def int_experimental_constrained_atan : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1248 [ LLVMMatchType<0>,
1249 llvm_metadata_ty,
1250 llvm_metadata_ty ]>;
1251 def int_experimental_constrained_atan2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1252 [ LLVMMatchType<0>,
1253 LLVMMatchType<0>,
1254 llvm_metadata_ty,
1255 llvm_metadata_ty ]>;
1256 def int_experimental_constrained_sin : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1257 [ LLVMMatchType<0>,
1258 llvm_metadata_ty,
1259 llvm_metadata_ty ]>;
1260 def int_experimental_constrained_cos : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1261 [ LLVMMatchType<0>,
1262 llvm_metadata_ty,
1263 llvm_metadata_ty ]>;
1264 def int_experimental_constrained_tan : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1265 [ LLVMMatchType<0>,
1266 llvm_metadata_ty,
1267 llvm_metadata_ty ]>;
1268 def int_experimental_constrained_sinh : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1269 [ LLVMMatchType<0>,
1270 llvm_metadata_ty,
1271 llvm_metadata_ty ]>;
1272 def int_experimental_constrained_cosh : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1273 [ LLVMMatchType<0>,
1274 llvm_metadata_ty,
1275 llvm_metadata_ty ]>;
1276 def int_experimental_constrained_tanh : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1277 [ LLVMMatchType<0>,
1278 llvm_metadata_ty,
1279 llvm_metadata_ty ]>;
1280 def int_experimental_constrained_pow : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1281 [ LLVMMatchType<0>,
1282 LLVMMatchType<0>,
1283 llvm_metadata_ty,
1284 llvm_metadata_ty ]>;
1285 def int_experimental_constrained_log : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1286 [ LLVMMatchType<0>,
1287 llvm_metadata_ty,
1288 llvm_metadata_ty ]>;
1289 def int_experimental_constrained_log10: DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1290 [ LLVMMatchType<0>,
1291 llvm_metadata_ty,
1292 llvm_metadata_ty ]>;
1293 def int_experimental_constrained_log2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1294 [ LLVMMatchType<0>,
1295 llvm_metadata_ty,
1296 llvm_metadata_ty ]>;
1297 def int_experimental_constrained_exp : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1298 [ LLVMMatchType<0>,
1299 llvm_metadata_ty,
1300 llvm_metadata_ty ]>;
1301 def int_experimental_constrained_exp2 : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1302 [ LLVMMatchType<0>,
1303 llvm_metadata_ty,
1304 llvm_metadata_ty ]>;
1305 def int_experimental_constrained_rint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1306 [ LLVMMatchType<0>,
1307 llvm_metadata_ty,
1308 llvm_metadata_ty ]>;
1309 def int_experimental_constrained_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1310 [ LLVMMatchType<0>,
1311 llvm_metadata_ty,
1312 llvm_metadata_ty ]>;
1313 def int_experimental_constrained_lrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1314 [ llvm_anyfloat_ty,
1315 llvm_metadata_ty,
1316 llvm_metadata_ty ]>;
1317 def int_experimental_constrained_llrint : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1318 [ llvm_anyfloat_ty,
1319 llvm_metadata_ty,
1320 llvm_metadata_ty ]>;
1321 def int_experimental_constrained_maxnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1322 [ LLVMMatchType<0>,
1323 LLVMMatchType<0>,
1324 llvm_metadata_ty ]>;
1325 def int_experimental_constrained_minnum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1326 [ LLVMMatchType<0>,
1327 LLVMMatchType<0>,
1328 llvm_metadata_ty ]>;
1329 def int_experimental_constrained_maximum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1330 [ LLVMMatchType<0>,
1331 LLVMMatchType<0>,
1332 llvm_metadata_ty ]>;
1333 def int_experimental_constrained_minimum : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1334 [ LLVMMatchType<0>,
1335 LLVMMatchType<0>,
1336 llvm_metadata_ty ]>;
1337 def int_experimental_constrained_ceil : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1338 [ LLVMMatchType<0>,
1339 llvm_metadata_ty ]>;
1340 def int_experimental_constrained_floor : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1341 [ LLVMMatchType<0>,
1342 llvm_metadata_ty ]>;
1343 def int_experimental_constrained_lround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1344 [ llvm_anyfloat_ty,
1345 llvm_metadata_ty ]>;
1346 def int_experimental_constrained_llround : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
1347 [ llvm_anyfloat_ty,
1348 llvm_metadata_ty ]>;
1349 def int_experimental_constrained_round : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1350 [ LLVMMatchType<0>,
1351 llvm_metadata_ty ]>;
1352 def int_experimental_constrained_roundeven : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1353 [ LLVMMatchType<0>,
1354 llvm_metadata_ty ]>;
1355 def int_experimental_constrained_trunc : DefaultAttrsIntrinsic<[ llvm_anyfloat_ty ],
1356 [ LLVMMatchType<0>,
1357 llvm_metadata_ty ]>;
1358
1359 // Constrained floating-point comparison (quiet and signaling variants).
1360 // Third operand is the predicate represented as a metadata string.
1361 def int_experimental_constrained_fcmp
1362 : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1363 [ llvm_anyfloat_ty, LLVMMatchType<0>,
1364 llvm_metadata_ty, llvm_metadata_ty ]>;
1365 def int_experimental_constrained_fcmps
1366 : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1367 [ llvm_anyfloat_ty, LLVMMatchType<0>,
1368 llvm_metadata_ty, llvm_metadata_ty ]>;
1369 }
1370 // FIXME: Consider maybe adding intrinsics for sitofp, uitofp.
1371
1372
1373 //===------------------------- Expect Intrinsics --------------------------===//
1374 //
1375 def int_expect : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1376 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem, IntrWillReturn]>;
1377
1378 def int_expect_with_probability : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1379 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_double_ty],
1380 [IntrNoMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
1381
1382 //===-------------------- Bit Manipulation Intrinsics ---------------------===//
1383 //
1384
1385 // None of these intrinsics accesses memory at all.
1386 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1387 def int_bswap: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
1388 def int_ctpop: DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
1389 def int_bitreverse : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
1390 def int_fshl : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1391 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
1392 def int_fshr : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1393 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
1394 }
1395
1396 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1397 ImmArg<ArgIndex<1>>] in {
1398 def int_ctlz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
1399 def int_cttz : DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
1400 }
1401
1402 //===------------------------ Debugger Intrinsics -------------------------===//
1403 //
1404
1405 // None of these intrinsics accesses memory at all...but that doesn't
1406 // mean the optimizers can change them aggressively. Special handling
1407 // needed in a few places. These synthetic intrinsics have no
1408 // side-effects and just mark information about their operands.
1409 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1410 def int_dbg_declare : DefaultAttrsIntrinsic<[],
1411 [llvm_metadata_ty,
1412 llvm_metadata_ty,
1413 llvm_metadata_ty]>;
1414 def int_dbg_value : DefaultAttrsIntrinsic<[],
1415 [llvm_metadata_ty,
1416 llvm_metadata_ty,
1417 llvm_metadata_ty]>;
1418 def int_dbg_assign : DefaultAttrsIntrinsic<[],
1419 [llvm_metadata_ty,
1420 llvm_metadata_ty,
1421 llvm_metadata_ty,
1422 llvm_metadata_ty,
1423 llvm_metadata_ty,
1424 llvm_metadata_ty]>;
1425 def int_dbg_label : DefaultAttrsIntrinsic<[],
1426 [llvm_metadata_ty]>;
1427 }
1428
1429 //===------------------ Exception Handling Intrinsics----------------------===//
1430 //
1431
1432 // The result of eh.typeid.for depends on the enclosing function, but inside a
1433 // given function it is 'const' and may be CSE'd etc.
1434 def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty], [IntrNoMem]>;
1435
1436 def int_eh_return_i32 : Intrinsic<[], [llvm_i32_ty, llvm_ptr_ty]>;
1437 def int_eh_return_i64 : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty]>;
1438
1439 // eh.exceptionpointer returns the pointer to the exception caught by
1440 // the given `catchpad`.
1441 def int_eh_exceptionpointer : Intrinsic<[llvm_anyptr_ty], [llvm_token_ty],
1442 [IntrNoMem]>;
1443
1444 // Gets the exception code from a catchpad token. Only used on some platforms.
1445 def int_eh_exceptioncode : Intrinsic<[llvm_i32_ty], [llvm_token_ty], [IntrNoMem]>;
1446
1447 // __builtin_unwind_init is an undocumented GCC intrinsic that causes all
1448 // callee-saved registers to be saved and restored (regardless of whether they
1449 // are used) in the calling function. It is used by libgcc_eh.
1450 def int_eh_unwind_init: Intrinsic<[]>,
1451 ClangBuiltin<"__builtin_unwind_init">;
1452
1453 def int_eh_dwarf_cfa : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
1454
1455 def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1456 def int_eh_sjlj_callsite : Intrinsic<[], [llvm_i32_ty], [IntrNoMem, ImmArg<ArgIndex<0>>]>;
1457
1458 def int_eh_sjlj_functioncontext : Intrinsic<[], [llvm_ptr_ty]>;
1459 def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
1460 def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty], [IntrNoReturn]>;
1461 def int_eh_sjlj_setup_dispatch : Intrinsic<[], []>;
1462
1463 //===---------------- Generic Variable Attribute Intrinsics----------------===//
1464 //
1465 def int_var_annotation : DefaultAttrsIntrinsic<
1466 [], [llvm_anyptr_ty, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
1467 [IntrInaccessibleMemOnly], "llvm.var.annotation">;
1468
1469 def int_ptr_annotation : DefaultAttrsIntrinsic<
1470 [llvm_anyptr_ty],
1471 [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty, LLVMMatchType<1>],
1472 [IntrInaccessibleMemOnly], "llvm.ptr.annotation">;
1473
1474 def int_annotation : DefaultAttrsIntrinsic<
1475 [llvm_anyint_ty],
1476 [LLVMMatchType<0>, llvm_anyptr_ty, LLVMMatchType<1>, llvm_i32_ty],
1477 [IntrInaccessibleMemOnly], "llvm.annotation">;
1478
1479 // Annotates the current program point with metadata strings which are emitted
1480 // as CodeView debug info records. This is expensive, as it disables inlining
1481 // and is modelled as having side effects.
1482 def int_codeview_annotation : DefaultAttrsIntrinsic<[], [llvm_metadata_ty],
1483 [IntrInaccessibleMemOnly, IntrNoDuplicate, IntrWillReturn],
1484 "llvm.codeview.annotation">;
1485
1486 //===------------------------ Trampoline Intrinsics -----------------------===//
1487 //
1488 def int_init_trampoline : DefaultAttrsIntrinsic<
1489 [], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1490 [IntrArgMemOnly, NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
1491 ReadNone<ArgIndex<1>>, ReadNone<ArgIndex<2>>]>,
1492 ClangBuiltin<"__builtin_init_trampoline">;
1493
1494 def int_adjust_trampoline : DefaultAttrsIntrinsic<
1495 [llvm_ptr_ty], [llvm_ptr_ty], [IntrReadMem, IntrArgMemOnly]>,
1496 ClangBuiltin<"__builtin_adjust_trampoline">;
1497
1498 //===------------------------ Overflow Intrinsics -------------------------===//
1499 //
1500
1501 // Expose the carry flag from add operations on two integrals.
1502 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1503 def int_sadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1504 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1505 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1506 def int_uadd_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1507 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1508 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1509
1510 def int_ssub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1511 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1512 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1513 def int_usub_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1514 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1515 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1516
1517 def int_smul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1518 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1519 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1520 def int_umul_with_overflow : DefaultAttrsIntrinsic<[llvm_anyint_ty,
1521 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
1522 [LLVMMatchType<0>, LLVMMatchType<0>]>;
1523 }
1524 //===------------------------- Saturation Arithmetic Intrinsics ---------------------===//
1525 //
1526 def int_sadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1527 [LLVMMatchType<0>, LLVMMatchType<0>],
1528 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
1529 def int_uadd_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1530 [LLVMMatchType<0>, LLVMMatchType<0>],
1531 [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]>;
1532 def int_ssub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1533 [LLVMMatchType<0>, LLVMMatchType<0>],
1534 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1535 def int_usub_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1536 [LLVMMatchType<0>, LLVMMatchType<0>],
1537 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1538 def int_sshl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1539 [LLVMMatchType<0>, LLVMMatchType<0>],
1540 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1541 def int_ushl_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1542 [LLVMMatchType<0>, LLVMMatchType<0>],
1543 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1544
1545 //===------------------------- Fixed Point Arithmetic Intrinsics ---------------------===//
1546 //
1547 def int_smul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1548 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1549 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1550 Commutative, ImmArg<ArgIndex<2>>]>;
1551
1552 def int_umul_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1553 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1554 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1555 Commutative, ImmArg<ArgIndex<2>>]>;
1556
1557 def int_sdiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1558 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1559 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1560
1561 def int_udiv_fix : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1562 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1563 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1564
1565 //===------------------- Fixed Point Saturation Arithmetic Intrinsics ----------------===//
1566 //
1567 def int_smul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1568 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1569 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1570 Commutative, ImmArg<ArgIndex<2>>]>;
1571 def int_umul_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1572 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1573 [IntrNoMem, IntrSpeculatable, IntrWillReturn,
1574 Commutative, ImmArg<ArgIndex<2>>]>;
1575
1576 def int_sdiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1577 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1578 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1579
1580 def int_udiv_fix_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty],
1581 [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty],
1582 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
1583
1584 //===------------------ Integer Min/Max/Abs Intrinsics --------------------===//
1585 //
1586 def int_abs : DefaultAttrsIntrinsic<
1587 [llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty],
1588 [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
1589
1590 def int_smax : DefaultAttrsIntrinsic<
1591 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1592 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1593 def int_smin : DefaultAttrsIntrinsic<
1594 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1595 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1596 def int_umax : DefaultAttrsIntrinsic<
1597 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1598 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1599 def int_umin : DefaultAttrsIntrinsic<
1600 [llvm_anyint_ty], [LLVMMatchType<0>, LLVMMatchType<0>],
1601 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1602 def int_scmp : DefaultAttrsIntrinsic<
1603 [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>],
1604 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1605 def int_ucmp : DefaultAttrsIntrinsic<
1606 [llvm_anyint_ty], [llvm_anyint_ty, LLVMMatchType<1>],
1607 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1608
1609 //===------------------------- Memory Use Markers -------------------------===//
1610 //
1611 def int_lifetime_start : DefaultAttrsIntrinsic<[],
1612 [llvm_i64_ty, llvm_anyptr_ty],
1613 [IntrArgMemOnly, IntrWillReturn,
1614 NoCapture<ArgIndex<1>>,
1615 ImmArg<ArgIndex<0>>]>;
1616 def int_lifetime_end : DefaultAttrsIntrinsic<[],
1617 [llvm_i64_ty, llvm_anyptr_ty],
1618 [IntrArgMemOnly, IntrWillReturn,
1619 NoCapture<ArgIndex<1>>,
1620 ImmArg<ArgIndex<0>>]>;
1621 def int_invariant_start : DefaultAttrsIntrinsic<[llvm_ptr_ty],
1622 [llvm_i64_ty, llvm_anyptr_ty],
1623 [IntrArgMemOnly, IntrWillReturn,
1624 NoCapture<ArgIndex<1>>,
1625 ImmArg<ArgIndex<0>>]>;
1626 def int_invariant_end : DefaultAttrsIntrinsic<[],
1627 [llvm_ptr_ty, llvm_i64_ty,
1628 llvm_anyptr_ty],
1629 [IntrArgMemOnly, IntrWillReturn,
1630 NoCapture<ArgIndex<2>>,
1631 ImmArg<ArgIndex<1>>]>;
1632
1633 // launder.invariant.group can't be marked with 'readnone' (IntrNoMem),
1634 // because it would cause CSE of two barriers with the same argument.
1635 // Inaccessiblememonly says that the barrier doesn't read the argument,
1636 // but it changes state not accessible to this module. This way
1637 // we can DSE through the barrier because it doesn't read the value
1638 // after store. Although the barrier doesn't modify any memory it
1639 // can't be marked as readonly, because it would be possible to
1640 // CSE 2 barriers with store in between.
1641 // The argument also can't be marked with 'returned' attribute, because
1642 // it would remove barrier.
1643 // Note that it is still experimental, which means that its semantics
1644 // might change in the future.
1645 def int_launder_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
1646 [LLVMMatchType<0>],
1647 [IntrInaccessibleMemOnly, IntrSpeculatable, IntrWillReturn]>;
1648
1649
1650 def int_strip_invariant_group : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
1651 [LLVMMatchType<0>],
1652 [IntrSpeculatable, IntrNoMem, IntrWillReturn]>;
1653
1654 //===------------------------ Stackmap Intrinsics -------------------------===//
1655 //
1656 def int_experimental_stackmap : DefaultAttrsIntrinsic<[],
1657 [llvm_i64_ty, llvm_i32_ty, llvm_vararg_ty],
1658 [Throws, ImmArg<ArgIndex<0>>, ImmArg<ArgIndex<1>>]>;
1659 def int_experimental_patchpoint_void : Intrinsic<[],
1660 [llvm_i64_ty, llvm_i32_ty,
1661 llvm_ptr_ty, llvm_i32_ty,
1662 llvm_vararg_ty],
1663 [Throws, ImmArg<ArgIndex<0>>,
1664 ImmArg<ArgIndex<1>>,
1665 ImmArg<ArgIndex<3>>]>;
1666 def int_experimental_patchpoint : Intrinsic<[llvm_any_ty],
1667 [llvm_i64_ty, llvm_i32_ty,
1668 llvm_ptr_ty, llvm_i32_ty,
1669 llvm_vararg_ty],
1670 [Throws, ImmArg<ArgIndex<0>>,
1671 ImmArg<ArgIndex<1>>,
1672 ImmArg<ArgIndex<3>>]>;
1673
1674
1675 //===------------------------ Garbage Collection Intrinsics ---------------===//
1676 // These are documented in docs/Statepoint.rst
1677
1678 def int_experimental_gc_statepoint : Intrinsic<[llvm_token_ty],
1679 [llvm_i64_ty, llvm_i32_ty,
1680 llvm_anyptr_ty, llvm_i32_ty,
1681 llvm_i32_ty, llvm_vararg_ty],
1682 [Throws, ImmArg<ArgIndex<0>>,
1683 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<3>>,
1684 ImmArg<ArgIndex<4>>]>;
1685
1686 def int_experimental_gc_result : DefaultAttrsIntrinsic<
1687 [llvm_any_ty], [llvm_token_ty], [IntrNoMem]>;
1688
1689 def int_experimental_gc_relocate : DefaultAttrsIntrinsic<
1690 [llvm_any_ty], [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
1691 [IntrNoMem, ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
1692
1693 def int_experimental_gc_get_pointer_base : DefaultAttrsIntrinsic<
1694 [llvm_anyptr_ty], [llvm_anyptr_ty],
1695 [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
1696
1697 def int_experimental_gc_get_pointer_offset : DefaultAttrsIntrinsic<
1698 [llvm_i64_ty], [llvm_anyptr_ty],
1699 [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
1700
1701 //===------------------------ Coroutine Intrinsics ---------------===//
1702 // These are documented in docs/Coroutines.rst
1703
1704 // Coroutine Structure Intrinsics.
1705
1706 def int_coro_id : DefaultAttrsIntrinsic<[llvm_token_ty],
1707 [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1708 [IntrArgMemOnly, IntrReadMem, ReadNone<ArgIndex<1>>, ReadOnly<ArgIndex<2>>,
1709 NoCapture<ArgIndex<2>>]>;
1710 def int_coro_id_retcon : Intrinsic<[llvm_token_ty],
1711 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1712 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1713 []>;
1714 def int_coro_id_retcon_once : Intrinsic<[llvm_token_ty],
1715 [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty,
1716 llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1717 []>;
1718 def int_coro_alloc : Intrinsic<[llvm_i1_ty], [llvm_token_ty], []>;
1719 def int_coro_id_async : Intrinsic<[llvm_token_ty],
1720 [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty],
1721 []>;
1722 def int_coro_async_context_alloc : Intrinsic<[llvm_ptr_ty],
1723 [llvm_ptr_ty, llvm_ptr_ty],
1724 []>;
1725 def int_coro_async_context_dealloc : Intrinsic<[],
1726 [llvm_ptr_ty],
1727 []>;
1728 def int_coro_async_resume : Intrinsic<[llvm_ptr_ty],
1729 [],
1730 [IntrNoMerge]>;
1731 def int_coro_async_size_replace : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty], []>;
1732 def int_coro_suspend_async
1733 : Intrinsic<[llvm_any_ty],
1734 [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty],
1735 [IntrNoMerge]>;
1736 def int_coro_prepare_async : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1737 [IntrNoMem]>;
1738 def int_coro_begin : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1739 [WriteOnly<ArgIndex<1>>]>;
1740 def int_coro_begin_custom_abi : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty, llvm_i32_ty],
1741 [WriteOnly<ArgIndex<1>>]>;
1742 def int_coro_free : Intrinsic<[llvm_ptr_ty], [llvm_token_ty, llvm_ptr_ty],
1743 [IntrReadMem, IntrArgMemOnly,
1744 ReadOnly<ArgIndex<1>>,
1745 NoCapture<ArgIndex<1>>]>;
1746 def int_coro_end : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_token_ty], []>;
1747 def int_coro_end_results : Intrinsic<[llvm_token_ty], [llvm_vararg_ty]>;
1748 def int_coro_end_async
1749 : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_i1_ty, llvm_vararg_ty], []>;
1750
1751 def int_coro_frame : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1752 def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
1753 def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1754 def int_coro_align : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
1755
1756 def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], [IntrNoMerge]>;
1757 def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>;
1758 def int_coro_suspend_retcon : Intrinsic<[llvm_any_ty], [llvm_vararg_ty], []>;
1759 def int_coro_prepare_retcon : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty],
1760 [IntrNoMem]>;
1761 def int_coro_alloca_alloc : Intrinsic<[llvm_token_ty],
1762 [llvm_anyint_ty, llvm_i32_ty], []>;
1763 def int_coro_alloca_get : Intrinsic<[llvm_ptr_ty], [llvm_token_ty], []>;
1764 def int_coro_alloca_free : Intrinsic<[], [llvm_token_ty], []>;
1765
1766 // Coroutine Manipulation Intrinsics.
1767
1768 def int_coro_resume : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1769 def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>;
1770 def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty],
1771 [IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
1772 NoCapture<ArgIndex<0>>]>;
1773 def int_coro_promise : Intrinsic<[llvm_ptr_ty],
1774 [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty],
1775 [IntrNoMem, NoCapture<ArgIndex<0>>]>;
1776
1777 def int_coro_await_suspend_void : Intrinsic<[],
1778 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1779 [Throws]>;
1780
1781 def int_coro_await_suspend_bool : Intrinsic<[llvm_i1_ty],
1782 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1783 [Throws]>;
1784
1785 def int_coro_await_suspend_handle : Intrinsic<[],
1786 [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty],
1787 [Throws]>;
1788
1789 // Coroutine Lowering Intrinsics. Used internally by coroutine passes.
1790
1791 def int_coro_subfn_addr : DefaultAttrsIntrinsic<
1792 [llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty],
1793 [IntrReadMem, IntrArgMemOnly, ReadOnly<ArgIndex<0>>,
1794 NoCapture<ArgIndex<0>>]>;
1795
1796 ///===-------------------------- Other Intrinsics --------------------------===//
1797 //
1798 // TODO: We should introduce a new memory kind fo traps (and other side effects
1799 // we only model to keep things alive).
1800 def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold, IntrInaccessibleMemOnly,
1801 IntrWriteMem]>, ClangBuiltin<"__builtin_trap">;
1802 def int_debugtrap : Intrinsic<[]>,
1803 ClangBuiltin<"__builtin_debugtrap">;
1804 def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],
1805 [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>;
1806
1807 // Return true if ubsan check is allowed.
1808 def int_allow_ubsan_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i8_ty],
1809 [IntrInaccessibleMemOnly, IntrWriteMem, ImmArg<ArgIndex<0>>, NoUndef<RetIndex>]>;
1810
1811 // Return true if runtime check is allowed.
1812 def int_allow_runtime_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_metadata_ty],
1813 [IntrInaccessibleMemOnly, IntrWriteMem, NoUndef<RetIndex>]>,
1814 ClangBuiltin<"__builtin_allow_runtime_check">;
1815
1816 // Support for dynamic deoptimization (or de-specialization)
1817 def int_experimental_deoptimize : Intrinsic<[llvm_any_ty], [llvm_vararg_ty],
1818 [Throws]>;
1819
1820 // Support for speculative runtime guards
1821 def int_experimental_guard : Intrinsic<[], [llvm_i1_ty, llvm_vararg_ty],
1822 [Throws]>;
1823
1824 // Supports widenable conditions for guards represented as explicit branches.
1825 def int_experimental_widenable_condition : DefaultAttrsIntrinsic<[llvm_i1_ty], [],
1826 [IntrInaccessibleMemOnly, IntrWillReturn, IntrSpeculatable, NoUndef<RetIndex>]>;
1827
1828 // NOP: calls/invokes to this intrinsic are removed by codegen
1829 def int_donothing : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrWillReturn]>;
1830
1831 // This instruction has no actual effect, though it is treated by the optimizer
1832 // has having opaque side effects. This may be inserted into loops to ensure
1833 // that they are not removed even if they turn out to be empty, for languages
1834 // which specify that infinite loops must be preserved.
1835 def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
1836
1837 // The pseudoprobe intrinsic works as a place holder to the block it probes.
1838 // Like the sideeffect intrinsic defined above, this intrinsic is treated by the
1839 // optimizer as having opaque side effects so that it won't be get rid of or moved
1840 // out of the block it probes.
1841 def int_pseudoprobe : DefaultAttrsIntrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
1842 [IntrInaccessibleMemOnly, IntrWillReturn]>;
1843
1844 // Intrinsics to support half precision floating point format
1845 let IntrProperties = [IntrNoMem, IntrWillReturn] in {
1846 def int_convert_to_fp16 : DefaultAttrsIntrinsic<[llvm_i16_ty], [llvm_anyfloat_ty]>;
1847 def int_convert_from_fp16 : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
1848 }
1849
1850 // Saturating floating point to integer intrinsics
1851 let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
1852 def int_fptoui_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1853 def int_fptosi_sat : DefaultAttrsIntrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
1854 }
1855
1856 // Clear cache intrinsic, default to ignore (ie. emit nothing)
1857 // maps to void __clear_cache() on supporting platforms
1858 def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
1859 [], "llvm.clear_cache">;
1860
1861 // Intrinsic to detect whether its argument is a constant.
1862 def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty],
1863 [IntrNoMem, IntrWillReturn, IntrConvergent],
1864 "llvm.is.constant">;
1865
1866 // Introduce a use of the argument without generating any code.
1867 def int_fake_use : Intrinsic<[], [llvm_vararg_ty]>;
1868
1869 // Intrinsic to mask out bits of a pointer.
1870 // First argument must be pointer or vector of pointer. This is checked by the
1871 // verifier.
1872 def int_ptrmask: DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, llvm_anyint_ty],
1873 [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1874
1875 // Intrinsic to wrap a thread local variable.
1876 def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>],
1877 [NonNull<RetIndex>, NonNull<ArgIndex<0>>,
1878 IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
1879
1880 def int_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1881 [], [IntrNoMem]>;
1882
1883 //===---------------- Vector Predication Intrinsics --------------===//
1884 // Memory Intrinsics
1885 def int_vp_store : DefaultAttrsIntrinsic<[],
1886 [ llvm_anyvector_ty,
1887 llvm_anyptr_ty,
1888 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1889 llvm_i32_ty],
1890 [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
1891
1892 def int_vp_load : DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
1893 [ llvm_anyptr_ty,
1894 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1895 llvm_i32_ty],
1896 [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
1897
1898 def int_vp_gather: DefaultAttrsIntrinsic<[ llvm_anyvector_ty],
1899 [ LLVMVectorOfAnyPointersToElt<0>,
1900 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1901 llvm_i32_ty],
1902 [ IntrReadMem, IntrNoSync, IntrWillReturn]>;
1903
1904 def int_vp_scatter: DefaultAttrsIntrinsic<[],
1905 [ llvm_anyvector_ty,
1906 LLVMVectorOfAnyPointersToElt<0>,
1907 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1908 llvm_i32_ty],
1909 [ IntrNoSync, IntrWillReturn ]>; // TODO allow IntrNoCapture for vectors of pointers
1910
1911 // Experimental strided memory accesses
1912 def int_experimental_vp_strided_store : DefaultAttrsIntrinsic<[],
1913 [ llvm_anyvector_ty,
1914 llvm_anyptr_ty,
1915 llvm_anyint_ty, // Stride in bytes
1916 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1917 llvm_i32_ty],
1918 [ NoCapture<ArgIndex<1>>, IntrNoSync, IntrWriteMem, IntrArgMemOnly, IntrWillReturn ]>;
1919
1920 def int_experimental_vp_strided_load : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
1921 [ llvm_anyptr_ty,
1922 llvm_anyint_ty, // Stride in bytes
1923 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1924 llvm_i32_ty],
1925 [ NoCapture<ArgIndex<0>>, IntrNoSync, IntrReadMem, IntrWillReturn, IntrArgMemOnly ]>;
1926
1927 // Experimental histogram
1928 def int_experimental_vector_histogram_add : DefaultAttrsIntrinsic<[],
1929 [ llvm_anyvector_ty, // Vector of pointers
1930 llvm_anyint_ty, // Increment
1931 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>], // Mask
1932 [ IntrArgMemOnly ]>;
1933
1934 // Experimental match
1935 def int_experimental_vector_match : DefaultAttrsIntrinsic<
1936 [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
1937 [ llvm_anyvector_ty,
1938 llvm_anyvector_ty,
1939 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ], // Mask
1940 [ IntrNoMem, IntrNoSync, IntrWillReturn ]>;
1941
1942 // Extract based on mask bits
1943 def int_experimental_vector_extract_last_active:
1944 DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
1945 [llvm_anyvector_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1946 LLVMVectorElementType<0>], [IntrNoMem]>;
1947
1948 // Operators
1949 let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn] in {
1950 // Integer arithmetic
1951 def int_vp_add : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1952 [ LLVMMatchType<0>,
1953 LLVMMatchType<0>,
1954 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1955 llvm_i32_ty]>;
1956 def int_vp_sub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1957 [ LLVMMatchType<0>,
1958 LLVMMatchType<0>,
1959 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1960 llvm_i32_ty]>;
1961 def int_vp_mul : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1962 [ LLVMMatchType<0>,
1963 LLVMMatchType<0>,
1964 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1965 llvm_i32_ty]>;
1966 def int_vp_ashr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1967 [ LLVMMatchType<0>,
1968 LLVMMatchType<0>,
1969 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1970 llvm_i32_ty]>;
1971 def int_vp_lshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1972 [ LLVMMatchType<0>,
1973 LLVMMatchType<0>,
1974 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1975 llvm_i32_ty]>;
1976 def int_vp_shl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1977 [ LLVMMatchType<0>,
1978 LLVMMatchType<0>,
1979 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1980 llvm_i32_ty]>;
1981 def int_vp_or : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1982 [ LLVMMatchType<0>,
1983 LLVMMatchType<0>,
1984 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1985 llvm_i32_ty]>;
1986 def int_vp_and : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1987 [ LLVMMatchType<0>,
1988 LLVMMatchType<0>,
1989 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1990 llvm_i32_ty]>;
1991 def int_vp_xor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1992 [ LLVMMatchType<0>,
1993 LLVMMatchType<0>,
1994 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1995 llvm_i32_ty]>;
1996 def int_vp_sdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1997 [ LLVMMatchType<0>,
1998 LLVMMatchType<0>,
1999 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2000 llvm_i32_ty]>;
2001 def int_vp_udiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2002 [ LLVMMatchType<0>,
2003 LLVMMatchType<0>,
2004 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2005 llvm_i32_ty]>;
2006 def int_vp_srem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2007 [ LLVMMatchType<0>,
2008 LLVMMatchType<0>,
2009 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2010 llvm_i32_ty]>;
2011 def int_vp_urem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2012 [ LLVMMatchType<0>,
2013 LLVMMatchType<0>,
2014 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2015 llvm_i32_ty]>;
2016 def int_vp_abs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2017 [ LLVMMatchType<0>,
2018 llvm_i1_ty,
2019 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2020 llvm_i32_ty]>;
2021 def int_vp_smin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2022 [ LLVMMatchType<0>,
2023 LLVMMatchType<0>,
2024 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2025 llvm_i32_ty]>;
2026 def int_vp_smax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2027 [ LLVMMatchType<0>,
2028 LLVMMatchType<0>,
2029 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2030 llvm_i32_ty]>;
2031 def int_vp_umin : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2032 [ LLVMMatchType<0>,
2033 LLVMMatchType<0>,
2034 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2035 llvm_i32_ty]>;
2036 def int_vp_umax : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2037 [ LLVMMatchType<0>,
2038 LLVMMatchType<0>,
2039 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2040 llvm_i32_ty]>;
2041 def int_vp_bswap : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2042 [ LLVMMatchType<0>,
2043 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2044 llvm_i32_ty]>;
2045 def int_vp_bitreverse : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2046 [ LLVMMatchType<0>,
2047 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2048 llvm_i32_ty]>;
2049 def int_vp_ctpop : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2050 [ LLVMMatchType<0>,
2051 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2052 llvm_i32_ty]>;
2053 def int_vp_fshl : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2054 [ LLVMMatchType<0>,
2055 LLVMMatchType<0>,
2056 LLVMMatchType<0>,
2057 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2058 llvm_i32_ty]>;
2059 def int_vp_fshr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2060 [ LLVMMatchType<0>,
2061 LLVMMatchType<0>,
2062 LLVMMatchType<0>,
2063 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2064 llvm_i32_ty]>;
2065 def int_vp_sadd_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2066 [ LLVMMatchType<0>,
2067 LLVMMatchType<0>,
2068 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2069 llvm_i32_ty]>;
2070 def int_vp_uadd_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2071 [ LLVMMatchType<0>,
2072 LLVMMatchType<0>,
2073 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2074 llvm_i32_ty]>;
2075 def int_vp_ssub_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2076 [ LLVMMatchType<0>,
2077 LLVMMatchType<0>,
2078 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2079 llvm_i32_ty]>;
2080 def int_vp_usub_sat : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2081 [ LLVMMatchType<0>,
2082 LLVMMatchType<0>,
2083 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2084 llvm_i32_ty]>;
2085
2086 // Floating-point arithmetic
2087 def int_vp_fadd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2088 [ LLVMMatchType<0>,
2089 LLVMMatchType<0>,
2090 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2091 llvm_i32_ty]>;
2092 def int_vp_fsub : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2093 [ LLVMMatchType<0>,
2094 LLVMMatchType<0>,
2095 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2096 llvm_i32_ty]>;
2097 def int_vp_fmul : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2098 [ LLVMMatchType<0>,
2099 LLVMMatchType<0>,
2100 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2101 llvm_i32_ty]>;
2102 def int_vp_fdiv : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2103 [ LLVMMatchType<0>,
2104 LLVMMatchType<0>,
2105 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2106 llvm_i32_ty]>;
2107 def int_vp_frem : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2108 [ LLVMMatchType<0>,
2109 LLVMMatchType<0>,
2110 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2111 llvm_i32_ty]>;
2112 def int_vp_fneg : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2113 [ LLVMMatchType<0>,
2114 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2115 llvm_i32_ty]>;
2116 def int_vp_fabs : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2117 [ LLVMMatchType<0>,
2118 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2119 llvm_i32_ty]>;
2120 def int_vp_sqrt : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2121 [ LLVMMatchType<0>,
2122 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2123 llvm_i32_ty]>;
2124 def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2125 [ LLVMMatchType<0>,
2126 LLVMMatchType<0>,
2127 LLVMMatchType<0>,
2128 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2129 llvm_i32_ty]>;
2130 def int_vp_fmuladd : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2131 [ LLVMMatchType<0>,
2132 LLVMMatchType<0>,
2133 LLVMMatchType<0>,
2134 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2135 llvm_i32_ty]>;
2136 def int_vp_minnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2137 [ LLVMMatchType<0>,
2138 LLVMMatchType<0>,
2139 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2140 llvm_i32_ty]>;
2141 def int_vp_maxnum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2142 [ LLVMMatchType<0>,
2143 LLVMMatchType<0>,
2144 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2145 llvm_i32_ty]>;
2146 def int_vp_minimum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2147 [ LLVMMatchType<0>,
2148 LLVMMatchType<0>,
2149 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2150 llvm_i32_ty]>;
2151 def int_vp_maximum : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2152 [ LLVMMatchType<0>,
2153 LLVMMatchType<0>,
2154 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2155 llvm_i32_ty]>;
2156 def int_vp_copysign : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2157 [ LLVMMatchType<0>,
2158 LLVMMatchType<0>,
2159 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2160 llvm_i32_ty]>;
2161 def int_vp_ceil : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2162 [ LLVMMatchType<0>,
2163 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2164 llvm_i32_ty]>;
2165 def int_vp_floor : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2166 [ LLVMMatchType<0>,
2167 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2168 llvm_i32_ty]>;
2169 def int_vp_round : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2170 [ LLVMMatchType<0>,
2171 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2172 llvm_i32_ty]>;
2173 def int_vp_roundeven : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2174 [ LLVMMatchType<0>,
2175 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2176 llvm_i32_ty]>;
2177 def int_vp_roundtozero : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2178 [ LLVMMatchType<0>,
2179 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2180 llvm_i32_ty]>;
2181 def int_vp_rint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2182 [ LLVMMatchType<0>,
2183 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2184 llvm_i32_ty]>;
2185 def int_vp_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2186 [ LLVMMatchType<0>,
2187 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2188 llvm_i32_ty]>;
2189 def int_vp_lrint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2190 [ llvm_anyvector_ty,
2191 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2192 llvm_i32_ty]>;
2193 def int_vp_llrint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2194 [ llvm_anyvector_ty,
2195 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2196 llvm_i32_ty]>;
2197
2198 // Casts
2199 def int_vp_trunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2200 [ llvm_anyvector_ty,
2201 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2202 llvm_i32_ty]>;
2203 def int_vp_zext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2204 [ llvm_anyvector_ty,
2205 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2206 llvm_i32_ty]>;
2207 def int_vp_sext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2208 [ llvm_anyvector_ty,
2209 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2210 llvm_i32_ty]>;
2211 def int_vp_fptrunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2212 [ llvm_anyvector_ty,
2213 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2214 llvm_i32_ty]>;
2215 def int_vp_fpext : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2216 [ llvm_anyvector_ty,
2217 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2218 llvm_i32_ty]>;
2219 def int_vp_fptoui : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2220 [ llvm_anyvector_ty,
2221 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2222 llvm_i32_ty]>;
2223 def int_vp_fptosi : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2224 [ llvm_anyvector_ty,
2225 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2226 llvm_i32_ty]>;
2227 def int_vp_uitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2228 [ llvm_anyvector_ty,
2229 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2230 llvm_i32_ty]>;
2231 def int_vp_sitofp : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2232 [ llvm_anyvector_ty,
2233 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2234 llvm_i32_ty]>;
2235 def int_vp_ptrtoint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2236 [ llvm_anyvector_ty,
2237 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2238 llvm_i32_ty]>;
2239 def int_vp_inttoptr : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2240 [ llvm_anyvector_ty,
2241 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2242 llvm_i32_ty]>;
2243 // Shuffles
2244 def int_vp_select : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2245 [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2246 LLVMMatchType<0>,
2247 LLVMMatchType<0>,
2248 llvm_i32_ty]>;
2249 def int_vp_merge : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2250 [ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2251 LLVMMatchType<0>,
2252 LLVMMatchType<0>,
2253 llvm_i32_ty]>;
2254
2255 // Comparisons
2256 def int_vp_fcmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
2257 [ llvm_anyvector_ty,
2258 LLVMMatchType<0>,
2259 llvm_metadata_ty,
2260 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2261 llvm_i32_ty]>;
2262 def int_vp_icmp : DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty> ],
2263 [ llvm_anyvector_ty,
2264 LLVMMatchType<0>,
2265 llvm_metadata_ty,
2266 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2267 llvm_i32_ty]>;
2268
2269 // Reductions
2270 def int_vp_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2271 [ LLVMVectorElementType<0>,
2272 llvm_anyvector_ty,
2273 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2274 llvm_i32_ty]>;
2275 def int_vp_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2276 [ LLVMVectorElementType<0>,
2277 llvm_anyvector_ty,
2278 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2279 llvm_i32_ty]>;
2280 def int_vp_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2281 [ LLVMVectorElementType<0>,
2282 llvm_anyvector_ty,
2283 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2284 llvm_i32_ty]>;
2285 def int_vp_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2286 [ LLVMVectorElementType<0>,
2287 llvm_anyvector_ty,
2288 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2289 llvm_i32_ty]>;
2290 def int_vp_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2291 [ LLVMVectorElementType<0>,
2292 llvm_anyvector_ty,
2293 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2294 llvm_i32_ty]>;
2295 def int_vp_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2296 [ LLVMVectorElementType<0>,
2297 llvm_anyvector_ty,
2298 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2299 llvm_i32_ty]>;
2300 def int_vp_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2301 [ LLVMVectorElementType<0>,
2302 llvm_anyvector_ty,
2303 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2304 llvm_i32_ty]>;
2305 def int_vp_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2306 [ LLVMVectorElementType<0>,
2307 llvm_anyvector_ty,
2308 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2309 llvm_i32_ty]>;
2310 def int_vp_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2311 [ LLVMVectorElementType<0>,
2312 llvm_anyvector_ty,
2313 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2314 llvm_i32_ty]>;
2315 def int_vp_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2316 [ LLVMVectorElementType<0>,
2317 llvm_anyvector_ty,
2318 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2319 llvm_i32_ty]>;
2320 def int_vp_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2321 [ LLVMVectorElementType<0>,
2322 llvm_anyvector_ty,
2323 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2324 llvm_i32_ty]>;
2325 def int_vp_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2326 [ LLVMVectorElementType<0>,
2327 llvm_anyvector_ty,
2328 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2329 llvm_i32_ty]>;
2330 def int_vp_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2331 [ LLVMVectorElementType<0>,
2332 llvm_anyvector_ty,
2333 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2334 llvm_i32_ty]>;
2335 def int_vp_reduce_fmaximum : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2336 [ LLVMVectorElementType<0>,
2337 llvm_anyvector_ty,
2338 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2339 llvm_i32_ty]>;
2340 def int_vp_reduce_fminimum : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2341 [ LLVMVectorElementType<0>,
2342 llvm_anyvector_ty,
2343 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2344 llvm_i32_ty]>;
2345 }
2346
2347 let IntrProperties = [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<1>>] in {
2348 def int_vp_ctlz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2349 [ LLVMMatchType<0>,
2350 llvm_i1_ty,
2351 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2352 llvm_i32_ty]>;
2353 def int_vp_cttz : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
2354 [ LLVMMatchType<0>,
2355 llvm_i1_ty,
2356 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2357 llvm_i32_ty]>;
2358
2359 def int_vp_cttz_elts : DefaultAttrsIntrinsic<[ llvm_anyint_ty ],
2360 [ llvm_anyvector_ty,
2361 llvm_i1_ty,
2362 LLVMScalarOrSameVectorWidth<1, llvm_i1_ty>,
2363 llvm_i32_ty]>;
2364 }
2365
2366 def int_get_active_lane_mask:
2367 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2368 [llvm_anyint_ty, LLVMMatchType<1>],
2369 [IntrNoMem, IntrNoSync, IntrWillReturn]>;
2370
2371 def int_experimental_get_vector_length:
2372 DefaultAttrsIntrinsic<[llvm_i32_ty],
2373 [llvm_anyint_ty, llvm_i32_ty, llvm_i1_ty],
2374 [IntrNoMem, IntrNoSync, IntrWillReturn,
2375 ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
2376
2377 def int_experimental_cttz_elts:
2378 DefaultAttrsIntrinsic<[llvm_anyint_ty],
2379 [llvm_anyvector_ty, llvm_i1_ty],
2380 [IntrNoMem, IntrNoSync, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
2381
2382 def int_experimental_vp_splice:
2383 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2384 [LLVMMatchType<0>,
2385 LLVMMatchType<0>,
2386 llvm_i32_ty,
2387 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2388 llvm_i32_ty, llvm_i32_ty],
2389 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
2390
2391 def int_experimental_vp_reverse:
2392 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2393 [LLVMMatchType<0>,
2394 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2395 llvm_i32_ty],
2396 [IntrNoMem]>;
2397
2398 def int_experimental_vp_splat:
2399 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2400 [LLVMVectorElementType<0>,
2401 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2402 llvm_i32_ty],
2403 [IntrNoMem]>;
2404
2405 def int_vp_is_fpclass:
2406 DefaultAttrsIntrinsic<[ LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2407 [ llvm_anyvector_ty,
2408 llvm_i32_ty,
2409 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2410 llvm_i32_ty],
2411 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
2412
2413 //===-------------------------- Masked Intrinsics -------------------------===//
2414 //
2415 def int_masked_load:
2416 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2417 [llvm_anyptr_ty, llvm_i32_ty,
2418 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
2419 [IntrReadMem, IntrArgMemOnly, IntrWillReturn, ImmArg<ArgIndex<1>>,
2420 NoCapture<ArgIndex<0>>]>;
2421
2422 def int_masked_store:
2423 DefaultAttrsIntrinsic<[],
2424 [llvm_anyvector_ty, llvm_anyptr_ty,
2425 llvm_i32_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2426 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
2427 ImmArg<ArgIndex<2>>, NoCapture<ArgIndex<1>>]>;
2428
2429 def int_masked_gather:
2430 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2431 [LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
2432 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
2433 [IntrReadMem, IntrWillReturn, ImmArg<ArgIndex<1>>]>;
2434
2435 def int_masked_scatter:
2436 DefaultAttrsIntrinsic<[],
2437 [llvm_anyvector_ty, LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
2438 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2439 [IntrWriteMem, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
2440
2441 def int_masked_expandload:
2442 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2443 [llvm_ptr_ty, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
2444 LLVMMatchType<0>],
2445 [IntrReadMem, IntrWillReturn, NoCapture<ArgIndex<0>>]>;
2446
2447 def int_masked_compressstore:
2448 DefaultAttrsIntrinsic<[],
2449 [llvm_anyvector_ty, llvm_ptr_ty,
2450 LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
2451 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn,
2452 NoCapture<ArgIndex<1>>]>;
2453
2454 def int_experimental_vector_compress:
2455 DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2456 [LLVMMatchType<0>, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
2457 [IntrNoMem, IntrWillReturn]>;
2458
2459 // Test whether a pointer is associated with a type metadata identifier.
2460 def int_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
2461 [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
2462
2463 // Safely loads a function pointer from a virtual table pointer using type metadata.
2464 def int_type_checked_load : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty],
2465 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
2466 [IntrNoMem, IntrWillReturn]>;
2467
2468 // Safely loads a relative function pointer from a virtual table pointer using type metadata.
2469 def int_type_checked_load_relative : DefaultAttrsIntrinsic<[llvm_ptr_ty, llvm_i1_ty],
2470 [llvm_ptr_ty, llvm_i32_ty, llvm_metadata_ty],
2471 [IntrNoMem, IntrWillReturn]>;
2472
2473 // Test whether a pointer is associated with a type metadata identifier. Used
2474 // for public visibility classes that may later be refined to private
2475 // visibility.
2476 def int_public_type_test : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_metadata_ty],
2477 [IntrNoMem, IntrWillReturn, IntrSpeculatable]>;
2478
2479 // Create a branch funnel that implements an indirect call to a limited set of
2480 // callees. This needs to be a musttail call.
2481 def int_icall_branch_funnel : DefaultAttrsIntrinsic<[], [llvm_vararg_ty], []>;
2482
2483 def int_load_relative: DefaultAttrsIntrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_anyint_ty],
2484 [IntrReadMem, IntrArgMemOnly]>;
2485
2486 def int_asan_check_memaccess :
2487 Intrinsic<[],[llvm_ptr_ty, llvm_i32_ty], [ImmArg<ArgIndex<1>>]>;
2488
2489 // HWASan intrinsics to test whether a pointer is addressable.
2490 //===----------------------------------------------------------------------===//
2491 //
2492 // Variant 1) is the OG memaccess intrinsic
2493 // Parameters: Shadow base (passed in a register), pointer to be checked for
2494 // validity, AccessInfo (AccessInfo is defined in HWAddressSanitizer.h)
2495 def int_hwasan_check_memaccess :
2496 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
2497 [ImmArg<ArgIndex<2>>]>;
2498
2499 // Variant 2) supports short granule checks
2500 // Parameters: same as Variant 1
2501 def int_hwasan_check_memaccess_shortgranules :
2502 Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
2503 [ImmArg<ArgIndex<2>>]>;
2504
2505 // Variant 3) assumes a fixed shadow offset
2506 // Parameters: Pointer to be checked for validity, AccessInfo, Shadow base
2507 def int_hwasan_check_memaccess_fixedshadow :
2508 Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i64_ty],
2509 [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
2510
2511 // Variant 4) supports short granule checks and assumes a fixed shadow offset
2512 // Parameters: same as Variant 3
2513 def int_hwasan_check_memaccess_shortgranules_fixedshadow :
2514 Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i64_ty],
2515 [ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
2516
2517 // Xray intrinsics
2518 //===----------------------------------------------------------------------===//
2519 // Custom event logging for x-ray.
2520 // Takes a pointer to a string and the length of the string.
2521 def int_xray_customevent : Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty],
2522 [IntrWriteMem, NoCapture<ArgIndex<0>>,
2523 ReadOnly<ArgIndex<0>>]>;
2524 // Typed event logging for x-ray.
2525 // Takes a numeric type tag, a pointer to a string and the length of the string.
2526 def int_xray_typedevent : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty, llvm_i64_ty],
2527 [IntrWriteMem, NoCapture<ArgIndex<1>>,
2528 ReadOnly<ArgIndex<1>>]>;
2529 //===----------------------------------------------------------------------===//
2530
2531 //===------ Memory intrinsics with element-wise atomicity guarantees ------===//
2532 //
2533
2534 // @llvm.memcpy.element.unordered.atomic.*(dest, src, length, elementsize)
2535 def int_memcpy_element_unordered_atomic
2536 : Intrinsic<[],
2537 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
2538 [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
2539 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
2540 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
2541 ImmArg<ArgIndex<3>>]>;
2542
2543 // @llvm.memmove.element.unordered.atomic.*(dest, src, length, elementsize)
2544 def int_memmove_element_unordered_atomic
2545 : Intrinsic<[],
2546 [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty],
2547 [IntrArgMemOnly, IntrWillReturn, IntrNoSync,
2548 NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
2549 WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
2550 ImmArg<ArgIndex<3>>]>;
2551
2552 // @llvm.memset.element.unordered.atomic.*(dest, value, length, elementsize)
2553 def int_memset_element_unordered_atomic
2554 : Intrinsic<[], [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty],
2555 [IntrWriteMem, IntrArgMemOnly, IntrWillReturn, IntrNoSync,
2556 NoCapture<ArgIndex<0>>, WriteOnly<ArgIndex<0>>,
2557 ImmArg<ArgIndex<3>>]>;
2558
2559 //===------------------------ Reduction Intrinsics ------------------------===//
2560 //
2561 let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
2562
2563 def int_vector_reduce_fadd : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2564 [LLVMVectorElementType<0>,
2565 llvm_anyvector_ty]>;
2566 def int_vector_reduce_fmul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2567 [LLVMVectorElementType<0>,
2568 llvm_anyvector_ty]>;
2569 def int_vector_reduce_add : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2570 [llvm_anyvector_ty]>;
2571 def int_vector_reduce_mul : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2572 [llvm_anyvector_ty]>;
2573 def int_vector_reduce_and : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2574 [llvm_anyvector_ty]>;
2575 def int_vector_reduce_or : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2576 [llvm_anyvector_ty]>;
2577 def int_vector_reduce_xor : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2578 [llvm_anyvector_ty]>;
2579 def int_vector_reduce_smax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2580 [llvm_anyvector_ty]>;
2581 def int_vector_reduce_smin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2582 [llvm_anyvector_ty]>;
2583 def int_vector_reduce_umax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2584 [llvm_anyvector_ty]>;
2585 def int_vector_reduce_umin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2586 [llvm_anyvector_ty]>;
2587 def int_vector_reduce_fmax : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2588 [llvm_anyvector_ty]>;
2589 def int_vector_reduce_fmin : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2590 [llvm_anyvector_ty]>;
2591 def int_vector_reduce_fminimum: DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2592 [llvm_anyvector_ty]>;
2593 def int_vector_reduce_fmaximum: DefaultAttrsIntrinsic<[LLVMVectorElementType<0>],
2594 [llvm_anyvector_ty]>;
2595 }
2596
2597 //===----- Matrix intrinsics ---------------------------------------------===//
2598
2599 def int_matrix_transpose
2600 : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2601 [LLVMMatchType<0>, llvm_i32_ty, llvm_i32_ty],
2602 [ IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>,
2603 ImmArg<ArgIndex<2>>]>;
2604
2605 def int_matrix_multiply
2606 : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2607 [llvm_anyvector_ty, llvm_anyvector_ty, llvm_i32_ty, llvm_i32_ty,
2608 llvm_i32_ty],
2609 [IntrNoSync, IntrWillReturn, IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>,
2610 ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>]>;
2611
2612 def int_matrix_column_major_load
2613 : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2614 [llvm_ptr_ty, llvm_anyint_ty, llvm_i1_ty,
2615 llvm_i32_ty, llvm_i32_ty],
2616 [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrReadMem,
2617 NoCapture<ArgIndex<0>>, ImmArg<ArgIndex<2>>, ImmArg<ArgIndex<3>>,
2618 ImmArg<ArgIndex<4>>]>;
2619
2620 def int_matrix_column_major_store
2621 : DefaultAttrsIntrinsic<[],
2622 [llvm_anyvector_ty, llvm_ptr_ty,
2623 llvm_anyint_ty, llvm_i1_ty, llvm_i32_ty, llvm_i32_ty],
2624 [IntrNoSync, IntrWillReturn, IntrArgMemOnly, IntrWriteMem,
2625 WriteOnly<ArgIndex<1>>, NoCapture<ArgIndex<1>>,
2626 ImmArg<ArgIndex<3>>, ImmArg<ArgIndex<4>>, ImmArg<ArgIndex<5>>]>;
2627
2628 //===---------- Intrinsics to control hardware supported loops ----------===//
2629
2630 // Specify that the value given is the number of iterations that the next loop
2631 // will execute.
2632 def int_set_loop_iterations :
2633 DefaultAttrsIntrinsic<[], [llvm_anyint_ty], [IntrNoDuplicate]>;
2634
2635 // Same as the above, but produces a value (the same as the input operand) to
2636 // be fed into the loop.
2637 def int_start_loop_iterations :
2638 DefaultAttrsIntrinsic<[llvm_anyint_ty], [LLVMMatchType<0>], [IntrNoDuplicate]>;
2639
2640 // Specify that the value given is the number of iterations that the next loop
2641 // will execute. Also test that the given count is not zero, allowing it to
2642 // control entry to a 'while' loop.
2643 def int_test_set_loop_iterations :
2644 DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
2645
2646 // Same as the above, but produces an extra value (the same as the input
2647 // operand) to be fed into the loop.
2648 def int_test_start_loop_iterations :
2649 DefaultAttrsIntrinsic<[llvm_anyint_ty, llvm_i1_ty], [LLVMMatchType<0>],
2650 [IntrNoDuplicate]>;
2651
2652 // Decrement loop counter by the given argument. Return false if the loop
2653 // should exit.
2654 def int_loop_decrement :
2655 DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_anyint_ty], [IntrNoDuplicate]>;
2656
2657 // Decrement the first operand (the loop counter) by the second operand (the
2658 // maximum number of elements processed in an iteration). Return the remaining
2659 // number of iterations still to be executed. This is effectively a sub which
2660 // can be used with a phi, icmp and br to control the number of iterations
2661 // executed, as usual. Any optimisations are allowed to treat it is a sub, and
2662 // it's scevable, so it's the backends responsibility to handle cases where it
2663 // may be optimised.
2664 def int_loop_decrement_reg :
2665 DefaultAttrsIntrinsic<[llvm_anyint_ty],
2666 [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoDuplicate]>;
2667
2668 //===----- Intrinsics that are used to provide predicate information -----===//
2669
2670 def int_ssa_copy : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>],
2671 [IntrNoMem, Returned<ArgIndex<0>>]>;
2672
2673 //===------- Intrinsics that are used to preserve debug information -------===//
2674
2675 def int_preserve_array_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2676 [llvm_anyptr_ty, llvm_i32_ty,
2677 llvm_i32_ty],
2678 [IntrNoMem,
2679 ImmArg<ArgIndex<1>>,
2680 ImmArg<ArgIndex<2>>]>;
2681 def int_preserve_union_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2682 [llvm_anyptr_ty, llvm_i32_ty],
2683 [IntrNoMem,
2684 ImmArg<ArgIndex<1>>]>;
2685 def int_preserve_struct_access_index : DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2686 [llvm_anyptr_ty, llvm_i32_ty,
2687 llvm_i32_ty],
2688 [IntrNoMem,
2689 ImmArg<ArgIndex<1>>,
2690 ImmArg<ArgIndex<2>>]>;
2691 def int_preserve_static_offset : DefaultAttrsIntrinsic<[llvm_ptr_ty],
2692 [llvm_ptr_ty],
2693 [IntrNoMem, IntrSpeculatable,
2694 ReadNone <ArgIndex<0>>]>;
2695
2696 //===------------ Intrinsics to perform common vector shuffles ------------===//
2697
2698 def int_vector_reverse : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2699 [LLVMMatchType<0>],
2700 [IntrNoMem]>;
2701
2702 def int_vector_splice : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2703 [LLVMMatchType<0>,
2704 LLVMMatchType<0>,
2705 llvm_i32_ty],
2706 [IntrNoMem, ImmArg<ArgIndex<2>>]>;
2707
2708 //===---------- Intrinsics to query properties of scalable vectors --------===//
2709 def int_vscale : DefaultAttrsIntrinsic<[llvm_anyint_ty], [], [IntrNoMem]>;
2710
2711 //===---------- Intrinsics to perform subvector insertion/extraction ------===//
2712 def int_vector_insert : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2713 [LLVMMatchType<0>, llvm_anyvector_ty, llvm_i64_ty],
2714 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<2>>]>;
2715
2716 def int_vector_extract : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2717 [llvm_anyvector_ty, llvm_i64_ty],
2718 [IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
2719
2720
2721 def int_vector_interleave2 : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
2722 [LLVMHalfElementsVectorType<0>,
2723 LLVMHalfElementsVectorType<0>],
2724 [IntrNoMem]>;
2725
2726 def int_vector_deinterleave2 : DefaultAttrsIntrinsic<[LLVMHalfElementsVectorType<0>,
2727 LLVMHalfElementsVectorType<0>],
2728 [llvm_anyvector_ty],
2729 [IntrNoMem]>;
2730
2731 //===-------------- Intrinsics to perform partial reduction ---------------===//
2732
2733 def int_experimental_vector_partial_reduce_add : DefaultAttrsIntrinsic<[LLVMMatchType<0>],
2734 [llvm_anyvector_ty, llvm_anyvector_ty],
2735 [IntrNoMem]>;
2736
2737 //===----------------- Pointer Authentication Intrinsics ------------------===//
2738 //
2739
2740 // Sign an unauthenticated pointer using the specified key and discriminator,
2741 // passed in that order.
2742 // Returns the first argument, with some known bits replaced with a signature.
2743 def int_ptrauth_sign :
2744 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
2745 [IntrNoMem, ImmArg<ArgIndex<1>>]>;
2746
2747 // Authenticate a signed pointer, using the specified key and discriminator.
2748 // Returns the first argument, with the signature bits removed.
2749 // The signature must be valid.
2750 def int_ptrauth_auth : Intrinsic<[llvm_i64_ty],
2751 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty],
2752 [IntrNoMem,ImmArg<ArgIndex<1>>]>;
2753
2754 // Authenticate a signed pointer and resign it.
2755 // The second (key) and third (discriminator) arguments specify the signing
2756 // schema used for authenticating.
2757 // The fourth and fifth arguments specify the schema used for signing.
2758 // The signature must be valid.
2759 // This is a combined form of @llvm.ptrauth.sign and @llvm.ptrauth.auth, with
2760 // an additional integrity guarantee on the intermediate value.
2761 def int_ptrauth_resign : Intrinsic<[llvm_i64_ty],
2762 [llvm_i64_ty, llvm_i32_ty, llvm_i64_ty,
2763 llvm_i32_ty, llvm_i64_ty],
2764 [IntrNoMem, ImmArg<ArgIndex<1>>,
2765 ImmArg<ArgIndex<3>>]>;
2766
2767 // Strip the embedded signature out of a signed pointer.
2768 // The second argument specifies the key.
2769 // This behaves like @llvm.ptrauth.auth, but doesn't require the signature to
2770 // be valid.
2771 def int_ptrauth_strip :
2772 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i32_ty],
2773 [IntrNoMem, ImmArg<ArgIndex<1>>]>;
2774
2775 // Blend a small integer discriminator with an address discriminator, producing
2776 // a new discriminator value.
2777 def int_ptrauth_blend :
2778 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2779
2780 // Compute the signature of a value, using a given discriminator.
2781 // This differs from @llvm.ptrauth.sign in that it doesn't embed the computed
2782 // signature in the pointer, but instead returns the signature as a value.
2783 // That allows it to be used to sign non-pointer data: in that sense, it is
2784 // generic. There is no generic @llvm.ptrauth.auth: instead, the signature
2785 // can be computed using @llvm.ptrauth.sign_generic, and compared with icmp.
2786 def int_ptrauth_sign_generic :
2787 DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2788
2789 //===----------------------------------------------------------------------===//
2790 //===------- Convergence Intrinsics ---------------------------------------===//
2791
2792 def int_experimental_convergence_entry
2793 : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
2794 def int_experimental_convergence_anchor
2795 : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
2796 def int_experimental_convergence_loop
2797 : DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
2798
2799 //===----------------------------------------------------------------------===//
2800 // Target-specific intrinsics
2801 //===----------------------------------------------------------------------===//
2802
2803 include "llvm/IR/IntrinsicsPowerPC.td"
2804 include "llvm/IR/IntrinsicsX86.td"
2805 include "llvm/IR/IntrinsicsARM.td"
2806 include "llvm/IR/IntrinsicsAArch64.td"
2807 include "llvm/IR/IntrinsicsXCore.td"
2808 include "llvm/IR/IntrinsicsHexagon.td"
2809 include "llvm/IR/IntrinsicsNVVM.td"
2810 include "llvm/IR/IntrinsicsMips.td"
2811 include "llvm/IR/IntrinsicsAMDGPU.td"
2812 include "llvm/IR/IntrinsicsBPF.td"
2813 include "llvm/IR/IntrinsicsSystemZ.td"
2814 include "llvm/IR/IntrinsicsWebAssembly.td"
2815 include "llvm/IR/IntrinsicsRISCV.td"
2816 include "llvm/IR/IntrinsicsSPIRV.td"
2817 include "llvm/IR/IntrinsicsVE.td"
2818 include "llvm/IR/IntrinsicsDirectX.td"
2819 include "llvm/IR/IntrinsicsLoongArch.td"
2820
2821 #endif // TEST_INTRINSICS_SUPPRESS_DEFS