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"
43 unsigned NumArgs,
bool IsVarArg,
48#define GET_INTRINSIC_NAME_TABLE
49#include "llvm/IR/IntrinsicImpl.inc"
52 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
53 return IntrinsicNameTable[IntrinsicNameOffsetTable[id]];
57 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
59 "This version of getName does not support overloading");
78 Result +=
"p" +
utostr(PTyp->getAddressSpace());
80 Result +=
"a" +
utostr(ATyp->getNumElements()) +
83 if (!STyp->isLiteral()) {
86 Result += STyp->getName();
88 HasUnnamedType =
true;
91 for (
auto *Elem : STyp->elements())
98 for (
size_t i = 0; i < FT->getNumParams(); i++)
108 Result +=
"v" +
utostr(EC.getKnownMinValue()) +
112 Result += TETy->getName();
113 for (
Type *ParamTy : TETy->type_params())
115 for (
unsigned IntParam : TETy->int_params())
116 Result +=
"_" +
utostr(IntParam);
120 switch (Ty->getTypeID()) {
127 Result +=
"Metadata";
167 bool EarlyModuleCheck) {
169 assert(Id < Intrinsic::num_intrinsics &&
"Invalid intrinsic ID!");
171 "This version of getName is for overloaded intrinsics only");
172 (void)EarlyModuleCheck;
173 assert((!EarlyModuleCheck || M ||
175 "Intrinsic overloading on pointer types need to provide a Module");
176 bool HasUnnamedType =
false;
178 for (
Type *Ty : OverloadTys)
180 if (HasUnnamedType) {
181 assert(M &&
"unnamed types need a module");
186 "Provided FunctionType must match arguments");
187 return M->getUniqueIntrinsicName(Result, Id, FT);
194 assert(M &&
"We need to have a Module");
208#define GET_INTRINSIC_IITINFO
209#include "llvm/IR/IntrinsicImpl.inc"
212static_assert(IIT_Done == 0,
"IIT_Done expected to be 0");
219 auto IsScalableVector = [&]() {
221 if (NextInfo != IIT_SCALABLE_VEC)
232 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Void, 0));
235 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
238 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
241 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
244 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Token, 0));
247 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
250 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Half, 0));
253 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
256 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Float, 0));
259 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Double, 0));
262 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
265 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
268 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
271 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
274 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
276 case IIT_AARCH64_SVCOUNT:
277 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AArch64Svcount, 0));
280 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
283 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 16));
286 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
289 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
292 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
295 OutputTable.
push_back(IITDescriptor::getVector(1, IsScalableVector()));
299 OutputTable.
push_back(IITDescriptor::getVector(2, IsScalableVector()));
303 OutputTable.
push_back(IITDescriptor::getVector(3, IsScalableVector()));
307 OutputTable.
push_back(IITDescriptor::getVector(4, IsScalableVector()));
311 OutputTable.
push_back(IITDescriptor::getVector(6, IsScalableVector()));
315 OutputTable.
push_back(IITDescriptor::getVector(8, IsScalableVector()));
319 OutputTable.
push_back(IITDescriptor::getVector(10, IsScalableVector()));
323 OutputTable.
push_back(IITDescriptor::getVector(16, IsScalableVector()));
327 OutputTable.
push_back(IITDescriptor::getVector(32, IsScalableVector()));
331 OutputTable.
push_back(IITDescriptor::getVector(64, IsScalableVector()));
335 OutputTable.
push_back(IITDescriptor::getVector(128, IsScalableVector()));
339 OutputTable.
push_back(IITDescriptor::getVector(256, IsScalableVector()));
343 OutputTable.
push_back(IITDescriptor::getVector(512, IsScalableVector()));
347 OutputTable.
push_back(IITDescriptor::getVector(1024, IsScalableVector()));
351 OutputTable.
push_back(IITDescriptor::getVector(2048, IsScalableVector()));
355 OutputTable.
push_back(IITDescriptor::getVector(4096, IsScalableVector()));
359 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
362 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
365 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
369 IITDescriptor::get(IITDescriptor::Pointer, Infos[NextElt++]));
372 unsigned OverloadInfo = Infos[NextElt++];
374 IITDescriptor::get(IITDescriptor::Overloaded, OverloadInfo));
377 case IIT_EXTEND_ARG: {
378 unsigned OverloadIndex = Infos[NextElt++];
380 IITDescriptor::get(IITDescriptor::Extend, OverloadIndex));
383 case IIT_TRUNC_ARG: {
384 unsigned OverloadIndex = Infos[NextElt++];
386 IITDescriptor::get(IITDescriptor::Trunc, OverloadIndex));
389 case IIT_ONE_NTH_ELTS_VEC_ARG: {
390 unsigned short OverloadIndex = Infos[NextElt++];
391 unsigned short N = Infos[NextElt++];
392 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::OneNthEltsVec,
396 case IIT_SAME_VEC_WIDTH_ARG: {
397 unsigned OverloadIndex = Infos[NextElt++];
399 IITDescriptor::get(IITDescriptor::SameVecWidth, OverloadIndex));
404 case IIT_VEC_OF_ANYPTRS_TO_ELT: {
405 unsigned short OverloadIndex = Infos[NextElt++];
406 unsigned short RefOverloadIndex = Infos[NextElt++];
407 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt,
413 unsigned StructElts = Infos[NextElt++] + 2;
416 IITDescriptor::get(IITDescriptor::Struct, StructElts));
418 for (
unsigned i = 0; i != StructElts; ++i)
422 case IIT_SUBDIVIDE2_ARG: {
423 unsigned OverloadIndex = Infos[NextElt++];
425 IITDescriptor::get(IITDescriptor::Subdivide2, OverloadIndex));
428 case IIT_SUBDIVIDE4_ARG: {
429 unsigned OverloadIndex = Infos[NextElt++];
431 IITDescriptor::get(IITDescriptor::Subdivide4, OverloadIndex));
434 case IIT_VEC_ELEMENT: {
435 unsigned OverloadIndex = Infos[NextElt++];
437 IITDescriptor::get(IITDescriptor::VecElement, OverloadIndex));
440 case IIT_VEC_OF_BITCASTS_TO_INT: {
441 unsigned OverloadIndex = Infos[NextElt++];
443 IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt, OverloadIndex));
446 case IIT_SCALABLE_VEC:
452#define GET_INTRINSIC_GENERATOR_GLOBAL
453#include "llvm/IR/IntrinsicImpl.inc"
455std::tuple<ArrayRef<Intrinsic::IITDescriptor>,
unsigned,
bool>
461 constexpr unsigned FixedEncodingBits =
sizeof(FixedEncodingTy) * CHAR_BIT;
462 constexpr unsigned MSBPosition = FixedEncodingBits - 1;
464 constexpr unsigned Mask = (1U << MSBPosition) - 1;
466 FixedEncodingTy TableVal = IIT_Table[
id - 1];
476 unsigned char IITValues[FixedEncodingBits / 4 + 1] = {0};
479 unsigned NextElt = 0;
482 if (TableVal >> MSBPosition) {
484 IITEntries = IIT_LongEncodingTable;
487 NextElt = TableVal & Mask;
492 IITValues[NextElt++] = TableVal & 0xF;
496 IITEntries = IITValues;
502 unsigned NumArgs = 0;
503 while (IITEntries[NextElt] != IIT_Done) {
510 bool IsVarArg =
false;
516 return {
TableRef, NumArgs, IsVarArg};
527 case IITDescriptor::Void:
529 case IITDescriptor::MMX:
531 case IITDescriptor::AMX:
533 case IITDescriptor::Token:
535 case IITDescriptor::Metadata:
537 case IITDescriptor::Half:
539 case IITDescriptor::BFloat:
541 case IITDescriptor::Float:
543 case IITDescriptor::Double:
545 case IITDescriptor::Quad:
547 case IITDescriptor::PPCQuad:
549 case IITDescriptor::AArch64Svcount:
552 case IITDescriptor::Integer:
554 case IITDescriptor::Vector:
557 case IITDescriptor::Pointer:
559 case IITDescriptor::Struct: {
561 for (
unsigned i = 0, e =
D.StructNumElements; i != e; ++i)
567 case IITDescriptor::Overloaded:
568 case IITDescriptor::VecOfAnyPtrsToElt:
569 return OverloadTys[
D.getOverloadIndex()];
570 case IITDescriptor::Extend:
571 return OverloadTys[
D.getOverloadIndex()]->getExtendedType();
572 case IITDescriptor::Trunc:
573 return OverloadTys[
D.getOverloadIndex()]->getTruncatedType();
574 case IITDescriptor::Subdivide2:
575 case IITDescriptor::Subdivide4: {
576 Type *Ty = OverloadTys[
D.getOverloadIndex()];
578 assert(VTy &&
"Expected overload type to be a Vector Type");
579 int SubDivs =
D.Kind == IITDescriptor::Subdivide2 ? 1 : 2;
582 case IITDescriptor::OneNthEltsVec:
585 D.getVectorDivisor());
586 case IITDescriptor::SameVecWidth: {
588 Type *Ty = OverloadTys[
D.getOverloadIndex()];
593 case IITDescriptor::VecElement: {
594 Type *Ty = OverloadTys[
D.getOverloadIndex()];
596 return VTy->getElementType();
599 case IITDescriptor::VecOfBitcastsToInt: {
600 Type *Ty = OverloadTys[
D.getOverloadIndex()];
602 assert(VTy &&
"Expected overload type to be a Vector Type");
605 case IITDescriptor::VarArg:
627#define GET_INTRINSIC_OVERLOAD_TABLE
628#include "llvm/IR/IntrinsicImpl.inc"
632#define GET_INTRINSIC_SCALARIZABLE_TABLE
633#include "llvm/IR/IntrinsicImpl.inc"
637#define GET_INTRINSIC_PRETTY_PRINT_TABLE
638#include "llvm/IR/IntrinsicImpl.inc"
642#define GET_INTRINSIC_TARGET_DATA
643#include "llvm/IR/IntrinsicImpl.inc"
646 return IID > TargetInfos[0].Count;
655 assert(Name.starts_with(
"llvm.") &&
"Unexpected intrinsic prefix");
656 assert(Name.drop_front(5).starts_with(
Target) &&
"Unexpected target");
667 CmpEnd += 1 +
Target.size();
669 const unsigned *
Low = NameOffsetTable.
begin();
670 const unsigned *
High = NameOffsetTable.
end();
671 const unsigned *LastLow =
Low;
672 while (CmpEnd < Name.size() &&
High -
Low > 0) {
673 size_t CmpStart = CmpEnd;
674 CmpEnd = Name.find(
'.', CmpStart + 1);
676 auto Cmp = [CmpStart, CmpEnd](
auto LHS,
auto RHS) {
681 if constexpr (std::is_integral_v<
decltype(
LHS)>)
682 LHSStr = IntrinsicNameTable.getCString(
LHS);
687 if constexpr (std::is_integral_v<
decltype(
RHS)>)
688 RHSStr = IntrinsicNameTable.getCString(
RHS);
692 return strncmp(LHSStr + CmpStart, RHSStr + CmpStart, CmpEnd - CmpStart) <
696 std::tie(
Low,
High) = std::equal_range(
Low,
High, Name.data(), Cmp);
701 if (LastLow == NameOffsetTable.
end())
703 StringRef NameFound = IntrinsicNameTable[*LastLow];
704 if (Name == NameFound ||
705 (Name.starts_with(NameFound) && Name[NameFound.
size()] ==
'.'))
706 return LastLow - NameOffsetTable.
begin();
715static std::pair<ArrayRef<unsigned>,
StringRef>
717 assert(Name.starts_with(
"llvm."));
724 Targets, [=](
const IntrinsicTargetInfo &TI) {
return TI.Name <
Target; });
727 const auto &TI = It != Targets.
end() && It->Name ==
Target ? *It : Targets[0];
728 return {
ArrayRef(&IntrinsicNameOffsetTable[1] + TI.Offset, TI.Count),
742 int Adjust = NameOffsetTable.data() - IntrinsicNameOffsetTable;
747 const auto MatchSize = IntrinsicNameTable[NameOffsetTable[Idx]].size();
748 assert(Name.size() >= MatchSize &&
"Expected either exact or prefix match");
749 bool IsExactMatch = Name.size() == MatchSize;
755#define GET_INTRINSIC_ATTRIBUTES
756#include "llvm/IR/IntrinsicImpl.inc"
762 std::string Name = OverloadTys.
empty()
766 if (
F->getFunctionType() == FT)
774 F->setName(
F->getName() +
".invalid");
775 return cast<Function>(M->getOrInsertFunction(Name, FT).getCallee());
801 assert(IsValid &&
"intrinsic signature mismatch");
816#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
817#include "llvm/IR/IntrinsicImpl.inc"
820#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
821#include "llvm/IR/IntrinsicImpl.inc"
825#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
826 case Intrinsic::INTRINSIC:
827#include "llvm/IR/ConstrainedOps.def"
837#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
838 case Intrinsic::INTRINSIC: \
839 return ROUND_MODE == 1;
840#include "llvm/IR/ConstrainedOps.def"
848 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
854 bool IsDeferredCheck) {
862 auto InfosRef = Infos;
863 auto DeferCheck = [&DeferredChecks, &InfosRef](
Type *
T) {
871 case IITDescriptor::Void:
872 return !Ty->isVoidTy();
873 case IITDescriptor::MMX: {
878 case IITDescriptor::AMX:
879 return !Ty->isX86_AMXTy();
880 case IITDescriptor::Token:
881 return !Ty->isTokenTy();
882 case IITDescriptor::Metadata:
883 return !Ty->isMetadataTy();
884 case IITDescriptor::Half:
885 return !Ty->isHalfTy();
886 case IITDescriptor::BFloat:
887 return !Ty->isBFloatTy();
888 case IITDescriptor::Float:
889 return !Ty->isFloatTy();
890 case IITDescriptor::Double:
891 return !Ty->isDoubleTy();
892 case IITDescriptor::Quad:
893 return !Ty->isFP128Ty();
894 case IITDescriptor::PPCQuad:
895 return !Ty->isPPC_FP128Ty();
896 case IITDescriptor::Integer:
897 return !Ty->isIntegerTy(
D.IntegerWidth);
898 case IITDescriptor::AArch64Svcount:
901 case IITDescriptor::Vector: {
903 return !VT || VT->getElementCount() !=
D.VectorWidth ||
905 DeferredChecks, IsDeferredCheck);
907 case IITDescriptor::Pointer: {
909 return !PT || PT->getAddressSpace() !=
D.PointerAddressSpace;
912 case IITDescriptor::Struct: {
914 if (!ST || !ST->isLiteral() || ST->isPacked() ||
915 ST->getNumElements() !=
D.StructNumElements)
918 for (
unsigned i = 0, e =
D.StructNumElements; i != e; ++i)
920 DeferredChecks, IsDeferredCheck))
925 case IITDescriptor::Overloaded:
928 if (
D.getOverloadIndex() < OverloadTys.
size())
929 return Ty != OverloadTys[
D.getOverloadIndex()];
931 if (
D.getOverloadIndex() > OverloadTys.
size() ||
932 D.getOverloadKind() == IITDescriptor::AK_MatchType)
933 return IsDeferredCheck || DeferCheck(Ty);
935 assert(
D.getOverloadIndex() == OverloadTys.
size() && !IsDeferredCheck &&
936 "Table consistency error");
939 switch (
D.getOverloadKind()) {
940 case IITDescriptor::AK_Any:
942 case IITDescriptor::AK_AnyInteger:
943 return !Ty->isIntOrIntVectorTy();
944 case IITDescriptor::AK_AnyFloat:
945 return !Ty->isFPOrFPVectorTy();
946 case IITDescriptor::AK_AnyVector:
948 case IITDescriptor::AK_AnyPointer:
955 case IITDescriptor::Extend: {
957 if (
D.getOverloadIndex() >= OverloadTys.
size())
958 return IsDeferredCheck || DeferCheck(Ty);
960 Type *NewTy = OverloadTys[
D.getOverloadIndex()]->getExtendedType();
963 case IITDescriptor::Trunc: {
965 if (
D.getOverloadIndex() >= OverloadTys.
size())
966 return IsDeferredCheck || DeferCheck(Ty);
968 Type *NewTy = OverloadTys[
D.getOverloadIndex()]->getTruncatedType();
971 case IITDescriptor::OneNthEltsVec: {
973 if (
D.getOverloadIndex() >= OverloadTys.
size())
974 return IsDeferredCheck || DeferCheck(Ty);
978 if (!VTy->getElementCount().isKnownMultipleOf(
D.getVectorDivisor()))
983 case IITDescriptor::SameVecWidth: {
984 if (
D.getOverloadIndex() >= OverloadTys.
size()) {
987 return IsDeferredCheck || DeferCheck(Ty);
997 if (
ReferenceType->getElementCount() != ThisArgType->getElementCount())
999 EltTy = ThisArgType->getElementType();
1004 case IITDescriptor::VecOfAnyPtrsToElt: {
1005 unsigned RefOverloadIndex =
D.getRefOverloadIndex();
1006 if (RefOverloadIndex >= OverloadTys.
size()) {
1007 if (IsDeferredCheck)
1012 return DeferCheck(Ty);
1015 if (!IsDeferredCheck) {
1016 assert(
D.getOverloadIndex() == OverloadTys.
size() &&
1017 "Table consistency error");
1027 (
ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
1029 return !ThisArgVecTy->getElementType()->isPointerTy();
1031 case IITDescriptor::VecElement: {
1032 if (
D.getOverloadIndex() >= OverloadTys.
size())
1033 return IsDeferredCheck ?
true : DeferCheck(Ty);
1038 case IITDescriptor::Subdivide2:
1039 case IITDescriptor::Subdivide4: {
1041 if (
D.getOverloadIndex() >= OverloadTys.
size())
1042 return IsDeferredCheck || DeferCheck(Ty);
1044 Type *NewTy = OverloadTys[
D.getOverloadIndex()];
1046 int SubDivs =
D.Kind == IITDescriptor::Subdivide2 ? 1 : 2;
1052 case IITDescriptor::VecOfBitcastsToInt: {
1053 if (
D.getOverloadIndex() >= OverloadTys.
size())
1054 return IsDeferredCheck || DeferCheck(Ty);
1062 case IITDescriptor::VarArg:
1079 unsigned NumArgs,
bool IsVarArg,
1084 DeferredChecks,
false)) {
1085 OS <<
"intrinsic has incorrect return type!";
1088 unsigned NumDeferredReturnChecks = DeferredChecks.
size();
1090 if (FTy->getNumParams() != NumArgs) {
1091 OS <<
"intrinsic has incorrect number of args. Expected " << NumArgs
1092 <<
", but got " << FTy->getNumParams();
1096 for (
Type *Ty : FTy->params()) {
1098 OS <<
"intrinsic has incorrect argument type!";
1103 for (
unsigned I = 0,
E = DeferredChecks.
size();
I !=
E; ++
I) {
1106 DeferredChecks,
true))
1108 if (
I < NumDeferredReturnChecks)
1109 OS <<
"intrinsic has incorrect return type!";
1111 OS <<
"intrinsic has incorrect argument type!";
1115 if (!Infos.
empty()) {
1116 OS <<
"intrinsic has too few arguments!";
1120 if (FTy->isVarArg() != IsVarArg) {
1122 OS <<
"intrinsic was not defined with variable arguments!";
1124 OS <<
"intrinsic was defined with variable arguments!";
1147 return ::isSignatureValid(FT,
TableRef, NumArgs, IsVarArg, OverloadTys, OS);
1160 return std::nullopt;
1164 std::string WantedName =
1166 if (Name == WantedName)
1167 return std::nullopt;
1170 if (
auto *ExistingGV =
F->getParent()->getNamedValue(WantedName)) {
1172 if (ExistingF->getFunctionType() ==
F->getFunctionType())
1179 ExistingGV->setName(WantedName +
".renamed");
1186 "Shouldn't change the signature");
1195 {Intrinsic::vector_interleave2, Intrinsic::vector_deinterleave2},
1196 {Intrinsic::vector_interleave3, Intrinsic::vector_deinterleave3},
1197 {Intrinsic::vector_interleave4, Intrinsic::vector_deinterleave4},
1198 {Intrinsic::vector_interleave5, Intrinsic::vector_deinterleave5},
1199 {Intrinsic::vector_interleave6, Intrinsic::vector_deinterleave6},
1200 {Intrinsic::vector_interleave7, Intrinsic::vector_deinterleave7},
1201 {Intrinsic::vector_interleave8, Intrinsic::vector_deinterleave8},
1205 assert(Factor >= 2 && Factor <= 8 &&
"Unexpected factor");
1210 assert(Factor >= 2 && Factor <= 8 &&
"Unexpected factor");
1214#define GET_INTRINSIC_PRETTY_PRINT_ARGUMENTS
1215#include "llvm/IR/IntrinsicImpl.inc"
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef< TableEntry > TableRef
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Module.h This file contains the declarations for the Module class.
static bool isSignatureValid(FunctionType *FTy, ArrayRef< Intrinsic::IITDescriptor > &Infos, unsigned NumArgs, bool IsVarArg, SmallVectorImpl< Type * > &OverloadTys, raw_ostream &OS)
Return true if the function type FTy is a valid type signature for the type constraints specified in ...
static InterleaveIntrinsic InterleaveIntrinsics[]
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &OverloadTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
static std::pair< ArrayRef< unsigned >, StringRef > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameOffsetTable for intrinsics with the same target as Name,...
static Function * getOrInsertIntrinsicDeclarationImpl(Module *M, Intrinsic::ID id, ArrayRef< Type * > OverloadTys, FunctionType *FT)
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef< Type * > OverloadTys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > OverloadTys, 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...
This file contains the definitions of the enumerations and flags associated with NVVM Intrinsics,...
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.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
const T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Class to represent function types.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
const Function & getFunction() const
void setCallingConv(CallingConv::ID CC)
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an 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.
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
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.
Represent a constant reference to a string, i.e.
static constexpr size_t npos
std::string str() const
Get the contents as an std::string.
constexpr size_t size() const
Get the string size.
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 * getX86_AMXTy(LLVMContext &C)
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
static LLVM_ABI Type * getTokenTy(LLVMContext &C)
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
@ 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)
@ ByteTyID
Arbitrary bit width bytes.
@ FP128TyID
128-bit floating point type (112-bit significand)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
static VectorType * getOneNthElementsVectorType(VectorType *VTy, unsigned Denominator)
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Type * getElementType() const
This class implements an extremely fast bulk output stream that can only output to a stream.
#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.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
LLVM_ABI Intrinsic::ID getDeinterleaveIntrinsicID(unsigned Factor)
Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor N.
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::optional< Function * > remangleIntrinsicFunction(Function *F)
LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-Point Intrinsics" that take r...
LLVM_ABI StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-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 bool hasPrettyPrintedArgs(ID id)
Returns true if the intrinsic has pretty printed immediate arguments.
LLVM_ABI std::tuple< ArrayRef< IITDescriptor >, unsigned, bool > getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Fill the IIT table descriptor for the intrinsic id into an array of IITDescriptors.
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 * > OverloadTys={})
Return the function type for an intrinsic.
LLVM_ABI bool isSignatureValid(Intrinsic::ID ID, FunctionType *FT, SmallVectorImpl< Type * > &OverloadTys, raw_ostream &OS=nulls())
Returns true if FT is a valid function type for intrinsic ID.
LLVM_ABI bool hasStructReturnType(ID id)
Returns true if id has a struct return type.
LLVM_ABI bool isTriviallyScalarizable(ID id)
Returns true if the intrinsic is trivially scalarizable.
LLVM_ABI bool isTargetIntrinsic(ID IID)
isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
LLVM_ABI std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > OverloadTys)
Return the LLVM name for an intrinsic.
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
std::string utostr(uint64_t X, bool isNeg=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.
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
Intrinsic::ID Deinterleave