18#include "llvm/IR/IntrinsicsAArch64.h"
19#include "llvm/IR/IntrinsicsAMDGPU.h"
20#include "llvm/IR/IntrinsicsARM.h"
21#include "llvm/IR/IntrinsicsBPF.h"
22#include "llvm/IR/IntrinsicsHexagon.h"
23#include "llvm/IR/IntrinsicsLoongArch.h"
24#include "llvm/IR/IntrinsicsMips.h"
25#include "llvm/IR/IntrinsicsNVPTX.h"
26#include "llvm/IR/IntrinsicsPowerPC.h"
27#include "llvm/IR/IntrinsicsR600.h"
28#include "llvm/IR/IntrinsicsRISCV.h"
29#include "llvm/IR/IntrinsicsS390.h"
30#include "llvm/IR/IntrinsicsSPIRV.h"
31#include "llvm/IR/IntrinsicsVE.h"
32#include "llvm/IR/IntrinsicsX86.h"
33#include "llvm/IR/IntrinsicsXCore.h"
40#define GET_INTRINSIC_NAME_TABLE
41#include "llvm/IR/IntrinsicImpl.inc"
42#undef GET_INTRINSIC_NAME_TABLE
45 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
46 return IntrinsicNameTable[IntrinsicNameOffsetTable[id]];
50 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
52 "This version of getName does not support overloading");
70 if (
PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
71 Result +=
"p" + utostr(PTyp->getAddressSpace());
72 }
else if (
ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
73 Result +=
"a" + utostr(ATyp->getNumElements()) +
75 }
else if (
StructType *STyp = dyn_cast<StructType>(Ty)) {
76 if (!STyp->isLiteral()) {
79 Result += STyp->getName();
81 HasUnnamedType =
true;
84 for (
auto *Elem : STyp->elements())
89 }
else if (
FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
91 for (
size_t i = 0; i < FT->getNumParams(); i++)
97 }
else if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
101 Result +=
"v" + utostr(EC.getKnownMinValue()) +
103 }
else if (
TargetExtType *TETy = dyn_cast<TargetExtType>(Ty)) {
105 Result += TETy->getName();
106 for (
Type *ParamTy : TETy->type_params())
108 for (
unsigned IntParam : TETy->int_params())
109 Result +=
"_" + utostr(IntParam);
120 Result +=
"Metadata";
147 Result +=
"i" + utostr(cast<IntegerType>(Ty)->
getBitWidth());
156 bool EarlyModuleCheck) {
158 assert(Id < Intrinsic::num_intrinsics &&
"Invalid intrinsic ID!");
160 "This version of getName is for overloaded intrinsics only");
161 (void)EarlyModuleCheck;
162 assert((!EarlyModuleCheck || M ||
163 !
any_of(Tys, [](
Type *
T) {
return isa<PointerType>(
T); })) &&
164 "Intrinsic overloading on pointer types need to provide a Module");
165 bool HasUnnamedType =
false;
169 if (HasUnnamedType) {
170 assert(M &&
"unnamed types need a module");
175 "Provided FunctionType must match arguments");
176 return M->getUniqueIntrinsicName(Result, Id, FT);
183 assert(M &&
"We need to have a Module");
196#define GET_INTRINSIC_IITINFO
197#include "llvm/IR/IntrinsicImpl.inc"
198#undef GET_INTRINSIC_IITINFO
205 using namespace Intrinsic;
207 bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
210 unsigned StructElts = 2;
214 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Void, 0));
217 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
220 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
223 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
226 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Token, 0));
229 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
232 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Half, 0));
235 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
238 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Float, 0));
241 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Double, 0));
244 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
247 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
250 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
253 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
256 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
258 case IIT_AARCH64_SVCOUNT:
259 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AArch64Svcount, 0));
262 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
265 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 16));
268 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
271 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
274 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
277 OutputTable.
push_back(IITDescriptor::getVector(1, IsScalableVector));
281 OutputTable.
push_back(IITDescriptor::getVector(2, IsScalableVector));
285 OutputTable.
push_back(IITDescriptor::getVector(3, IsScalableVector));
289 OutputTable.
push_back(IITDescriptor::getVector(4, IsScalableVector));
293 OutputTable.
push_back(IITDescriptor::getVector(6, IsScalableVector));
297 OutputTable.
push_back(IITDescriptor::getVector(8, IsScalableVector));
301 OutputTable.
push_back(IITDescriptor::getVector(10, IsScalableVector));
305 OutputTable.
push_back(IITDescriptor::getVector(16, IsScalableVector));
309 OutputTable.
push_back(IITDescriptor::getVector(32, IsScalableVector));
313 OutputTable.
push_back(IITDescriptor::getVector(64, IsScalableVector));
317 OutputTable.
push_back(IITDescriptor::getVector(128, IsScalableVector));
321 OutputTable.
push_back(IITDescriptor::getVector(256, IsScalableVector));
325 OutputTable.
push_back(IITDescriptor::getVector(512, IsScalableVector));
329 OutputTable.
push_back(IITDescriptor::getVector(1024, IsScalableVector));
333 OutputTable.
push_back(IITDescriptor::getVector(2048, IsScalableVector));
337 OutputTable.
push_back(IITDescriptor::getVector(4096, IsScalableVector));
341 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
344 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
347 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
351 IITDescriptor::get(IITDescriptor::Pointer, Infos[NextElt++]));
354 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
355 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Argument,
ArgInfo));
358 case IIT_EXTEND_ARG: {
359 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
361 IITDescriptor::get(IITDescriptor::ExtendArgument,
ArgInfo));
364 case IIT_TRUNC_ARG: {
365 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
367 IITDescriptor::get(IITDescriptor::TruncArgument,
ArgInfo));
370 case IIT_ONE_NTH_ELTS_VEC_ARG: {
371 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
372 unsigned short N = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
374 IITDescriptor::get(IITDescriptor::OneNthEltsVecArgument,
N, ArgNo));
377 case IIT_SAME_VEC_WIDTH_ARG: {
378 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
380 IITDescriptor::get(IITDescriptor::SameVecWidthArgument,
ArgInfo));
383 case IIT_VEC_OF_ANYPTRS_TO_ELT: {
384 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
385 unsigned short RefNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
387 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
390 case IIT_EMPTYSTRUCT:
391 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
416 IITDescriptor::get(IITDescriptor::Struct, StructElts));
418 for (
unsigned i = 0; i != StructElts; ++i)
422 case IIT_SUBDIVIDE2_ARG: {
423 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
425 IITDescriptor::get(IITDescriptor::Subdivide2Argument,
ArgInfo));
428 case IIT_SUBDIVIDE4_ARG: {
429 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
431 IITDescriptor::get(IITDescriptor::Subdivide4Argument,
ArgInfo));
434 case IIT_VEC_ELEMENT: {
435 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
437 IITDescriptor::get(IITDescriptor::VecElementArgument,
ArgInfo));
440 case IIT_SCALABLE_VEC: {
444 case IIT_VEC_OF_BITCASTS_TO_INT: {
445 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
447 IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt,
ArgInfo));
454#define GET_INTRINSIC_GENERATOR_GLOBAL
455#include "llvm/IR/IntrinsicImpl.inc"
456#undef GET_INTRINSIC_GENERATOR_GLOBAL
460 static_assert(
sizeof(IIT_Table[0]) == 2,
461 "Expect 16-bit entries in IIT_Table");
463 uint16_t TableVal = IIT_Table[
id - 1];
468 unsigned NextElt = 0;
469 if (TableVal >> 15) {
471 IITEntries = IIT_LongEncodingTable;
474 NextElt = TableVal & 0x7fff;
483 IITEntries = IITValues;
489 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
495 using namespace Intrinsic;
497 IITDescriptor
D = Infos.
front();
498 Infos = Infos.
slice(1);
501 case IITDescriptor::Void:
503 case IITDescriptor::VarArg:
505 case IITDescriptor::MMX:
507 case IITDescriptor::AMX:
509 case IITDescriptor::Token:
511 case IITDescriptor::Metadata:
513 case IITDescriptor::Half:
515 case IITDescriptor::BFloat:
517 case IITDescriptor::Float:
519 case IITDescriptor::Double:
521 case IITDescriptor::Quad:
523 case IITDescriptor::PPCQuad:
525 case IITDescriptor::AArch64Svcount:
528 case IITDescriptor::Integer:
530 case IITDescriptor::Vector:
533 case IITDescriptor::Pointer:
534 return PointerType::get(
Context,
D.Pointer_AddressSpace);
535 case IITDescriptor::Struct: {
537 for (
unsigned i = 0, e =
D.Struct_NumElements; i != e; ++i)
541 case IITDescriptor::Argument:
542 return Tys[
D.getArgumentNumber()];
543 case IITDescriptor::ExtendArgument: {
544 Type *Ty = Tys[
D.getArgumentNumber()];
545 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
546 return VectorType::getExtendedElementVectorType(VTy);
550 case IITDescriptor::TruncArgument: {
551 Type *Ty = Tys[
D.getArgumentNumber()];
552 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
553 return VectorType::getTruncatedElementVectorType(VTy);
559 case IITDescriptor::Subdivide2Argument:
560 case IITDescriptor::Subdivide4Argument: {
561 Type *Ty = Tys[
D.getArgumentNumber()];
563 assert(VTy &&
"Expected an argument of Vector Type");
564 int SubDivs =
D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
565 return VectorType::getSubdividedVectorType(VTy, SubDivs);
567 case IITDescriptor::OneNthEltsVecArgument:
568 return VectorType::getOneNthElementsVectorType(
569 cast<VectorType>(Tys[
D.getRefArgNumber()]),
D.getVectorDivisor());
570 case IITDescriptor::SameVecWidthArgument: {
572 Type *Ty = Tys[
D.getArgumentNumber()];
573 if (
auto *VTy = dyn_cast<VectorType>(Ty))
574 return VectorType::get(EltTy, VTy->getElementCount());
577 case IITDescriptor::VecElementArgument: {
578 Type *Ty = Tys[
D.getArgumentNumber()];
579 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
580 return VTy->getElementType();
583 case IITDescriptor::VecOfBitcastsToInt: {
584 Type *Ty = Tys[
D.getArgumentNumber()];
586 assert(VTy &&
"Expected an argument of Vector Type");
587 return VectorType::getInteger(VTy);
589 case IITDescriptor::VecOfAnyPtrsToElt:
591 return Tys[
D.getOverloadArgNumber()];
611 if (!ArgTys.
empty() && ArgTys.
back()->isVoidTy()) {
613 return FunctionType::get(ResultTy, ArgTys,
true);
615 return FunctionType::get(ResultTy, ArgTys,
false);
619#define GET_INTRINSIC_OVERLOAD_TABLE
620#include "llvm/IR/IntrinsicImpl.inc"
621#undef GET_INTRINSIC_OVERLOAD_TABLE
625#define GET_INTRINSIC_TARGET_DATA
626#include "llvm/IR/IntrinsicImpl.inc"
627#undef GET_INTRINSIC_TARGET_DATA
630 return IID > TargetInfos[0].Count;
639 assert(
Name.starts_with(
"llvm.") &&
"Unexpected intrinsic prefix");
651 CmpEnd += 1 +
Target.size();
653 const unsigned *
Low = NameOffsetTable.
begin();
654 const unsigned *
High = NameOffsetTable.
end();
655 const unsigned *LastLow =
Low;
657 size_t CmpStart = CmpEnd;
658 CmpEnd =
Name.find(
'.', CmpStart + 1);
660 auto Cmp = [CmpStart, CmpEnd](
auto LHS,
auto RHS) {
665 if constexpr (std::is_integral_v<
decltype(
LHS)>)
666 LHSStr = IntrinsicNameTable.getCString(
LHS);
671 if constexpr (std::is_integral_v<
decltype(
RHS)>)
672 RHSStr = IntrinsicNameTable.getCString(
RHS);
676 return strncmp(LHSStr + CmpStart, RHSStr + CmpStart, CmpEnd - CmpStart) <
685 if (LastLow == NameOffsetTable.
end())
687 StringRef NameFound = IntrinsicNameTable[*LastLow];
688 if (
Name == NameFound ||
689 (
Name.starts_with(NameFound) &&
Name[NameFound.
size()] ==
'.'))
690 return LastLow - NameOffsetTable.
begin();
699static std::pair<ArrayRef<unsigned>,
StringRef>
708 Targets, [=](
const IntrinsicTargetInfo &TI) {
return TI.Name <
Target; });
711 const auto &TI = It != Targets.
end() && It->Name ==
Target ? *It : Targets[0];
712 return {
ArrayRef(&IntrinsicNameOffsetTable[1] + TI.Offset, TI.Count),
726 int Adjust = NameOffsetTable.data() - IntrinsicNameOffsetTable;
731 const auto MatchSize = IntrinsicNameTable[NameOffsetTable[
Idx]].size();
732 assert(
Name.size() >= MatchSize &&
"Expected either exact or prefix match");
733 bool IsExactMatch =
Name.size() == MatchSize;
739#define GET_INTRINSIC_ATTRIBUTES
740#include "llvm/IR/IntrinsicImpl.inc"
741#undef GET_INTRINSIC_ATTRIBUTES
746 uint16_t PackedID = IntrinsicsToAttributesMap[
id - 1];
747 uint8_t FnAttrID = PackedID >> 8;
748 return getIntrinsicFnAttributeSet(
C, FnAttrID);
755 auto *FT =
getType(M->getContext(),
id, Tys);
756 return cast<Function>(
757 M->getOrInsertFunction(
763 return M->getFunction(
getName(
id));
769 return M->getFunction(
getName(
id, Tys, M, FT));
773#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
774#include "llvm/IR/IntrinsicImpl.inc"
775#undef GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
778#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
779#include "llvm/IR/IntrinsicImpl.inc"
780#undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
784#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
785 case Intrinsic::INTRINSIC:
786#include "llvm/IR/ConstrainedOps.def"
796#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
797 case Intrinsic::INTRINSIC: \
798 return ROUND_MODE == 1;
799#include "llvm/IR/ConstrainedOps.def"
807 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
813 bool IsDeferredCheck) {
814 using namespace Intrinsic;
821 auto InfosRef = Infos;
822 auto DeferCheck = [&DeferredChecks, &InfosRef](
Type *
T) {
827 IITDescriptor
D = Infos.
front();
828 Infos = Infos.
slice(1);
831 case IITDescriptor::Void:
833 case IITDescriptor::VarArg:
835 case IITDescriptor::MMX: {
840 case IITDescriptor::AMX:
842 case IITDescriptor::Token:
844 case IITDescriptor::Metadata:
846 case IITDescriptor::Half:
848 case IITDescriptor::BFloat:
850 case IITDescriptor::Float:
852 case IITDescriptor::Double:
854 case IITDescriptor::Quad:
856 case IITDescriptor::PPCQuad:
858 case IITDescriptor::Integer:
860 case IITDescriptor::AArch64Svcount:
861 return !isa<TargetExtType>(Ty) ||
862 cast<TargetExtType>(Ty)->getName() !=
"aarch64.svcount";
863 case IITDescriptor::Vector: {
865 return !VT || VT->getElementCount() !=
D.Vector_Width ||
867 DeferredChecks, IsDeferredCheck);
869 case IITDescriptor::Pointer: {
871 return !PT || PT->getAddressSpace() !=
D.Pointer_AddressSpace;
874 case IITDescriptor::Struct: {
876 if (!ST || !ST->isLiteral() || ST->isPacked() ||
877 ST->getNumElements() !=
D.Struct_NumElements)
880 for (
unsigned i = 0, e =
D.Struct_NumElements; i != e; ++i)
882 DeferredChecks, IsDeferredCheck))
887 case IITDescriptor::Argument:
890 if (
D.getArgumentNumber() < ArgTys.
size())
891 return Ty != ArgTys[
D.getArgumentNumber()];
893 if (
D.getArgumentNumber() > ArgTys.
size() ||
894 D.getArgumentKind() == IITDescriptor::AK_MatchType)
895 return IsDeferredCheck || DeferCheck(Ty);
897 assert(
D.getArgumentNumber() == ArgTys.
size() && !IsDeferredCheck &&
898 "Table consistency error");
901 switch (
D.getArgumentKind()) {
902 case IITDescriptor::AK_Any:
904 case IITDescriptor::AK_AnyInteger:
906 case IITDescriptor::AK_AnyFloat:
908 case IITDescriptor::AK_AnyVector:
909 return !isa<VectorType>(Ty);
910 case IITDescriptor::AK_AnyPointer:
911 return !isa<PointerType>(Ty);
917 case IITDescriptor::ExtendArgument: {
919 if (
D.getArgumentNumber() >= ArgTys.
size())
920 return IsDeferredCheck || DeferCheck(Ty);
922 Type *NewTy = ArgTys[
D.getArgumentNumber()];
923 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
924 NewTy = VectorType::getExtendedElementVectorType(VTy);
925 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
932 case IITDescriptor::TruncArgument: {
934 if (
D.getArgumentNumber() >= ArgTys.
size())
935 return IsDeferredCheck || DeferCheck(Ty);
937 Type *NewTy = ArgTys[
D.getArgumentNumber()];
938 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
939 NewTy = VectorType::getTruncatedElementVectorType(VTy);
940 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
947 case IITDescriptor::OneNthEltsVecArgument:
949 if (
D.getRefArgNumber() >= ArgTys.
size())
950 return IsDeferredCheck || DeferCheck(Ty);
951 return !isa<VectorType>(ArgTys[
D.getRefArgNumber()]) ||
952 VectorType::getOneNthElementsVectorType(
953 cast<VectorType>(ArgTys[
D.getRefArgNumber()]),
954 D.getVectorDivisor()) != Ty;
955 case IITDescriptor::SameVecWidthArgument: {
956 if (
D.getArgumentNumber() >= ArgTys.
size()) {
958 Infos = Infos.
slice(1);
959 return IsDeferredCheck || DeferCheck(Ty);
961 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
962 auto *ThisArgType = dyn_cast<VectorType>(Ty);
968 if (
ReferenceType->getElementCount() != ThisArgType->getElementCount())
970 EltTy = ThisArgType->getElementType();
975 case IITDescriptor::VecOfAnyPtrsToElt: {
976 unsigned RefArgNumber =
D.getRefArgNumber();
977 if (RefArgNumber >= ArgTys.
size()) {
983 return DeferCheck(Ty);
986 if (!IsDeferredCheck) {
987 assert(
D.getOverloadArgNumber() == ArgTys.
size() &&
988 "Table consistency error");
995 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
996 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
998 (
ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
1000 return !ThisArgVecTy->getElementType()->isPointerTy();
1002 case IITDescriptor::VecElementArgument: {
1003 if (
D.getArgumentNumber() >= ArgTys.
size())
1004 return IsDeferredCheck ?
true : DeferCheck(Ty);
1005 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
1008 case IITDescriptor::Subdivide2Argument:
1009 case IITDescriptor::Subdivide4Argument: {
1011 if (
D.getArgumentNumber() >= ArgTys.
size())
1012 return IsDeferredCheck || DeferCheck(Ty);
1014 Type *NewTy = ArgTys[
D.getArgumentNumber()];
1015 if (
auto *VTy = dyn_cast<VectorType>(NewTy)) {
1016 int SubDivs =
D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1017 NewTy = VectorType::getSubdividedVectorType(VTy, SubDivs);
1022 case IITDescriptor::VecOfBitcastsToInt: {
1023 if (
D.getArgumentNumber() >= ArgTys.
size())
1024 return IsDeferredCheck || DeferCheck(Ty);
1025 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
1026 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1029 return ThisArgVecTy != VectorType::getInteger(
ReferenceType);
1044 unsigned NumDeferredReturnChecks = DeferredChecks.
size();
1046 for (
auto *Ty : FTy->
params())
1050 for (
unsigned I = 0, E = DeferredChecks.
size();
I != E; ++
I) {
1068 if (Infos.
size() != 1)
1073 Infos = Infos.
slice(1);
1074 if (
D.Kind == IITDescriptor::VarArg)
1090 Intrinsic::MatchIntrinsicTypesResult::MatchIntrinsicTypes_Match) {
1107 return std::nullopt;
1111 std::string WantedName =
1113 if (
Name == WantedName)
1114 return std::nullopt;
1117 if (
auto *ExistingGV =
F->getParent()->getNamedValue(WantedName)) {
1118 if (
auto *ExistingF = dyn_cast<Function>(ExistingGV))
1119 if (ExistingF->getFunctionType() ==
F->getFunctionType())
1126 ExistingGV->
setName(WantedName +
".renamed");
1133 "Shouldn't change the signature");
1142 {Intrinsic::vector_interleave2, Intrinsic::vector_deinterleave2},
1143 {Intrinsic::vector_interleave3, Intrinsic::vector_deinterleave3},
1144 {Intrinsic::vector_interleave4, Intrinsic::vector_deinterleave4},
1145 {Intrinsic::vector_interleave5, Intrinsic::vector_deinterleave5},
1146 {Intrinsic::vector_interleave6, Intrinsic::vector_deinterleave6},
1147 {Intrinsic::vector_interleave7, Intrinsic::vector_deinterleave7},
1148 {Intrinsic::vector_interleave8, Intrinsic::vector_deinterleave8},
1152 assert(Factor >= 2 && Factor <= 8 &&
"Unexpected factor");
1157 assert(Factor >= 2 && Factor <= 8 &&
"Unexpected factor");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Module.h This file contains the declarations for the Module class.
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef< Type * > Tys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
static InterleaveIntrinsic InterleaveIntrinsics[]
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
static std::pair< ArrayRef< unsigned >, StringRef > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameOffsetTable for intrinsics with the same target as Name,...
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, IIT_Info LastInfo, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
static int lookupLLVMIntrinsicByName(ArrayRef< unsigned > NameOffsetTable, StringRef Name, StringRef Target="")
Looks up Name in NameTable via binary search.
static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
static StringRef getName(Value *V)
static SymbolRef::Type getType(const Symbol *Sym)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Class to represent function types.
ArrayRef< Type * > params() const
Type * getReturnType() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
void setCallingConv(CallingConv::ID CC)
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
static constexpr size_t npos
Class to represent struct types.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
static LLVM_ABI TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ HalfTyID
16-bit floating point type
@ VoidTyID
type with no size
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
static LLVM_ABI Type * getX86_AMXTy(LLVMContext &C)
bool isFP128Ty() const
Return true if this is 'fp128'.
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isX86_AMXTy() const
Return true if this is X86 AMX.
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeID getTypeID() const
Return the type id for the type.
bool isTokenTy() const
Return true if this is 'token'.
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
bool isVoidTy() const
Return true if this is 'void'.
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
bool isMetadataTy() const
Return true if this is 'metadata'.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
Type * getElementType() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI Intrinsic::ID getDeinterleaveIntrinsicID(unsigned Factor)
Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor N.
LLVM_ABI MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
LLVM_ABI AttributeSet getFnAttributes(LLVMContext &C, ID id)
Return the function attributes for an intrinsic.
LLVM_ABI void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
MatchIntrinsicTypesResult
@ MatchIntrinsicTypes_Match
@ MatchIntrinsicTypes_NoMatchRet
@ MatchIntrinsicTypes_NoMatchArg
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
LLVM_ABI std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
LLVM_ABI std::optional< Function * > remangleIntrinsicFunction(Function *F)
LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take ...
LLVM_ABI StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
LLVM_ABI bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics".
LLVM_ABI ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
LLVM_ABI StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
LLVM_ABI Intrinsic::ID getInterleaveIntrinsicID(unsigned Factor)
Returns the corresponding llvm.vector.interleaveN intrinsic for factor N.
LLVM_ABI bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
LLVM_ABI FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys={})
Return the function type for an intrinsic.
LLVM_ABI bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
LLVM_ABI bool isTargetIntrinsic(ID IID)
isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
LLVM_ABI bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Intrinsic::ID Deinterleave
Helper struct shared between Function Specialization and SCCP Solver.
This is a type descriptor which explains the type requirements of an intrinsic.