16#include "llvm/IR/IntrinsicsAArch64.h"
17#include "llvm/IR/IntrinsicsAMDGPU.h"
18#include "llvm/IR/IntrinsicsARM.h"
19#include "llvm/IR/IntrinsicsBPF.h"
20#include "llvm/IR/IntrinsicsHexagon.h"
21#include "llvm/IR/IntrinsicsLoongArch.h"
22#include "llvm/IR/IntrinsicsMips.h"
23#include "llvm/IR/IntrinsicsNVPTX.h"
24#include "llvm/IR/IntrinsicsPowerPC.h"
25#include "llvm/IR/IntrinsicsR600.h"
26#include "llvm/IR/IntrinsicsRISCV.h"
27#include "llvm/IR/IntrinsicsS390.h"
28#include "llvm/IR/IntrinsicsVE.h"
29#include "llvm/IR/IntrinsicsX86.h"
30#include "llvm/IR/IntrinsicsXCore.h"
37#define GET_INTRINSIC_NAME_TABLE
38#include "llvm/IR/IntrinsicImpl.inc"
39#undef GET_INTRINSIC_NAME_TABLE
42 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
43 return IntrinsicNameTable + IntrinsicNameOffsetTable[
id];
47 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
49 "This version of getName does not support overloading");
67 if (
PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
68 Result +=
"p" + utostr(PTyp->getAddressSpace());
69 }
else if (
ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
70 Result +=
"a" + utostr(ATyp->getNumElements()) +
72 }
else if (
StructType *STyp = dyn_cast<StructType>(Ty)) {
73 if (!STyp->isLiteral()) {
76 Result += STyp->getName();
78 HasUnnamedType =
true;
81 for (
auto *Elem : STyp->elements())
86 }
else if (
FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
88 for (
size_t i = 0; i < FT->getNumParams(); i++)
94 }
else if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
98 Result +=
"v" + utostr(EC.getKnownMinValue()) +
100 }
else if (
TargetExtType *TETy = dyn_cast<TargetExtType>(Ty)) {
102 Result += TETy->getName();
103 for (
Type *ParamTy : TETy->type_params())
105 for (
unsigned IntParam : TETy->int_params())
106 Result +=
"_" + utostr(IntParam);
117 Result +=
"Metadata";
144 Result +=
"i" + utostr(cast<IntegerType>(Ty)->
getBitWidth());
153 bool EarlyModuleCheck) {
155 assert(Id < Intrinsic::num_intrinsics &&
"Invalid intrinsic ID!");
157 "This version of getName is for overloaded intrinsics only");
158 (void)EarlyModuleCheck;
159 assert((!EarlyModuleCheck || M ||
160 !
any_of(Tys, [](
Type *
T) {
return isa<PointerType>(
T); })) &&
161 "Intrinsic overloading on pointer types need to provide a Module");
162 bool HasUnnamedType =
false;
166 if (HasUnnamedType) {
167 assert(M &&
"unnamed types need a module");
172 "Provided FunctionType must match arguments");
173 return M->getUniqueIntrinsicName(Result, Id, FT);
180 assert(M &&
"We need to have a Module");
193#define GET_INTRINSIC_IITINFO
194#include "llvm/IR/IntrinsicImpl.inc"
195#undef GET_INTRINSIC_IITINFO
202 using namespace Intrinsic;
204 bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
207 unsigned StructElts = 2;
211 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Void, 0));
214 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
217 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
220 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
223 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Token, 0));
226 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
229 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Half, 0));
232 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
235 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Float, 0));
238 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Double, 0));
241 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
244 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
247 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
250 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
253 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
255 case IIT_AARCH64_SVCOUNT:
256 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::AArch64Svcount, 0));
259 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
262 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 16));
265 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
268 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
271 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
274 OutputTable.
push_back(IITDescriptor::getVector(1, IsScalableVector));
278 OutputTable.
push_back(IITDescriptor::getVector(2, IsScalableVector));
282 OutputTable.
push_back(IITDescriptor::getVector(3, IsScalableVector));
286 OutputTable.
push_back(IITDescriptor::getVector(4, IsScalableVector));
290 OutputTable.
push_back(IITDescriptor::getVector(6, IsScalableVector));
294 OutputTable.
push_back(IITDescriptor::getVector(8, IsScalableVector));
298 OutputTable.
push_back(IITDescriptor::getVector(10, IsScalableVector));
302 OutputTable.
push_back(IITDescriptor::getVector(16, IsScalableVector));
306 OutputTable.
push_back(IITDescriptor::getVector(32, IsScalableVector));
310 OutputTable.
push_back(IITDescriptor::getVector(64, IsScalableVector));
314 OutputTable.
push_back(IITDescriptor::getVector(128, IsScalableVector));
318 OutputTable.
push_back(IITDescriptor::getVector(256, IsScalableVector));
322 OutputTable.
push_back(IITDescriptor::getVector(512, IsScalableVector));
326 OutputTable.
push_back(IITDescriptor::getVector(1024, IsScalableVector));
330 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
333 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
336 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
340 IITDescriptor::get(IITDescriptor::Pointer, Infos[NextElt++]));
343 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
344 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Argument,
ArgInfo));
347 case IIT_EXTEND_ARG: {
348 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
350 IITDescriptor::get(IITDescriptor::ExtendArgument,
ArgInfo));
353 case IIT_TRUNC_ARG: {
354 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
356 IITDescriptor::get(IITDescriptor::TruncArgument,
ArgInfo));
359 case IIT_HALF_VEC_ARG: {
360 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
362 IITDescriptor::get(IITDescriptor::HalfVecArgument,
ArgInfo));
365 case IIT_SAME_VEC_WIDTH_ARG: {
366 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
368 IITDescriptor::get(IITDescriptor::SameVecWidthArgument,
ArgInfo));
371 case IIT_VEC_OF_ANYPTRS_TO_ELT: {
372 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
373 unsigned short RefNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
375 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
378 case IIT_EMPTYSTRUCT:
379 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
404 IITDescriptor::get(IITDescriptor::Struct, StructElts));
406 for (
unsigned i = 0; i != StructElts; ++i)
410 case IIT_SUBDIVIDE2_ARG: {
411 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
413 IITDescriptor::get(IITDescriptor::Subdivide2Argument,
ArgInfo));
416 case IIT_SUBDIVIDE4_ARG: {
417 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
419 IITDescriptor::get(IITDescriptor::Subdivide4Argument,
ArgInfo));
422 case IIT_VEC_ELEMENT: {
423 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
425 IITDescriptor::get(IITDescriptor::VecElementArgument,
ArgInfo));
428 case IIT_SCALABLE_VEC: {
432 case IIT_VEC_OF_BITCASTS_TO_INT: {
433 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
435 IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt,
ArgInfo));
442#define GET_INTRINSIC_GENERATOR_GLOBAL
443#include "llvm/IR/IntrinsicImpl.inc"
444#undef GET_INTRINSIC_GENERATOR_GLOBAL
448 static_assert(
sizeof(IIT_Table[0]) == 2,
449 "Expect 16-bit entries in IIT_Table");
451 uint16_t TableVal = IIT_Table[
id - 1];
456 unsigned NextElt = 0;
457 if (TableVal >> 15) {
459 IITEntries = IIT_LongEncodingTable;
462 NextElt = TableVal & 0x7fff;
471 IITEntries = IITValues;
477 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
483 using namespace Intrinsic;
485 IITDescriptor
D = Infos.
front();
486 Infos = Infos.
slice(1);
489 case IITDescriptor::Void:
491 case IITDescriptor::VarArg:
493 case IITDescriptor::MMX:
495 case IITDescriptor::AMX:
497 case IITDescriptor::Token:
499 case IITDescriptor::Metadata:
501 case IITDescriptor::Half:
503 case IITDescriptor::BFloat:
505 case IITDescriptor::Float:
507 case IITDescriptor::Double:
509 case IITDescriptor::Quad:
511 case IITDescriptor::PPCQuad:
513 case IITDescriptor::AArch64Svcount:
516 case IITDescriptor::Integer:
518 case IITDescriptor::Vector:
521 case IITDescriptor::Pointer:
522 return PointerType::get(Context,
D.Pointer_AddressSpace);
523 case IITDescriptor::Struct: {
525 for (
unsigned i = 0, e =
D.Struct_NumElements; i != e; ++i)
529 case IITDescriptor::Argument:
530 return Tys[
D.getArgumentNumber()];
531 case IITDescriptor::ExtendArgument: {
532 Type *Ty = Tys[
D.getArgumentNumber()];
533 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
534 return VectorType::getExtendedElementVectorType(VTy);
538 case IITDescriptor::TruncArgument: {
539 Type *Ty = Tys[
D.getArgumentNumber()];
540 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
541 return VectorType::getTruncatedElementVectorType(VTy);
547 case IITDescriptor::Subdivide2Argument:
548 case IITDescriptor::Subdivide4Argument: {
549 Type *Ty = Tys[
D.getArgumentNumber()];
551 assert(VTy &&
"Expected an argument of Vector Type");
552 int SubDivs =
D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
553 return VectorType::getSubdividedVectorType(VTy, SubDivs);
555 case IITDescriptor::HalfVecArgument:
556 return VectorType::getHalfElementsVectorType(
557 cast<VectorType>(Tys[
D.getArgumentNumber()]));
558 case IITDescriptor::SameVecWidthArgument: {
560 Type *Ty = Tys[
D.getArgumentNumber()];
561 if (
auto *VTy = dyn_cast<VectorType>(Ty))
562 return VectorType::get(EltTy, VTy->getElementCount());
565 case IITDescriptor::VecElementArgument: {
566 Type *Ty = Tys[
D.getArgumentNumber()];
567 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
568 return VTy->getElementType();
571 case IITDescriptor::VecOfBitcastsToInt: {
572 Type *Ty = Tys[
D.getArgumentNumber()];
574 assert(VTy &&
"Expected an argument of Vector Type");
575 return VectorType::getInteger(VTy);
577 case IITDescriptor::VecOfAnyPtrsToElt:
579 return Tys[
D.getOverloadArgNumber()];
599 if (!ArgTys.
empty() && ArgTys.
back()->isVoidTy()) {
601 return FunctionType::get(ResultTy, ArgTys,
true);
603 return FunctionType::get(ResultTy, ArgTys,
false);
607#define GET_INTRINSIC_OVERLOAD_TABLE
608#include "llvm/IR/IntrinsicImpl.inc"
609#undef GET_INTRINSIC_OVERLOAD_TABLE
613#define GET_INTRINSIC_TARGET_DATA
614#include "llvm/IR/IntrinsicImpl.inc"
615#undef GET_INTRINSIC_TARGET_DATA
618 return IID > TargetInfos[0].Count;
627 assert(
Name.starts_with(
"llvm.") &&
"Unexpected intrinsic prefix");
639 CmpEnd += 1 +
Target.size();
641 const unsigned *
Low = NameOffsetTable.
begin();
642 const unsigned *
High = NameOffsetTable.
end();
643 const unsigned *LastLow =
Low;
645 size_t CmpStart = CmpEnd;
646 CmpEnd =
Name.find(
'.', CmpStart + 1);
648 auto Cmp = [CmpStart, CmpEnd](
auto LHS,
auto RHS) {
653 if constexpr (std::is_integral_v<
decltype(
LHS)>) {
654 LHSStr = &IntrinsicNameTable[
LHS];
659 if constexpr (std::is_integral_v<
decltype(
RHS)>) {
660 RHSStr = &IntrinsicNameTable[
RHS];
664 return strncmp(LHSStr + CmpStart, RHSStr + CmpStart, CmpEnd - CmpStart) <
673 if (LastLow == NameOffsetTable.
end())
675 StringRef NameFound = &IntrinsicNameTable[*LastLow];
676 if (
Name == NameFound ||
677 (
Name.starts_with(NameFound) &&
Name[NameFound.
size()] ==
'.'))
678 return LastLow - NameOffsetTable.
begin();
687static std::pair<ArrayRef<unsigned>,
StringRef>
696 Targets, [=](
const IntrinsicTargetInfo &TI) {
return TI.Name <
Target; });
699 const auto &TI = It != Targets.
end() && It->Name ==
Target ? *It : Targets[0];
700 return {
ArrayRef(&IntrinsicNameOffsetTable[1] + TI.Offset, TI.Count),
714 int Adjust = NameOffsetTable.data() - IntrinsicNameOffsetTable;
719 const auto MatchSize = strlen(&IntrinsicNameTable[NameOffsetTable[
Idx]]);
720 assert(
Name.size() >= MatchSize &&
"Expected either exact or prefix match");
721 bool IsExactMatch =
Name.size() == MatchSize;
727#define GET_INTRINSIC_ATTRIBUTES
728#include "llvm/IR/IntrinsicImpl.inc"
729#undef GET_INTRINSIC_ATTRIBUTES
736 return cast<Function>(
737 M->getOrInsertFunction(
743 return M->getFunction(
getName(
id));
749 return M->getFunction(
getName(
id,
Tys, M, FT));
753#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
754#include "llvm/IR/IntrinsicImpl.inc"
755#undef GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
758#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
759#include "llvm/IR/IntrinsicImpl.inc"
760#undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
764#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
765 case Intrinsic::INTRINSIC:
766#include "llvm/IR/ConstrainedOps.def"
776#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
777 case Intrinsic::INTRINSIC: \
778 return ROUND_MODE == 1;
779#include "llvm/IR/ConstrainedOps.def"
787 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
793 bool IsDeferredCheck) {
794 using namespace Intrinsic;
801 auto InfosRef = Infos;
802 auto DeferCheck = [&DeferredChecks, &InfosRef](
Type *
T) {
807 IITDescriptor
D = Infos.
front();
808 Infos = Infos.
slice(1);
811 case IITDescriptor::Void:
813 case IITDescriptor::VarArg:
815 case IITDescriptor::MMX: {
820 case IITDescriptor::AMX:
822 case IITDescriptor::Token:
824 case IITDescriptor::Metadata:
826 case IITDescriptor::Half:
828 case IITDescriptor::BFloat:
830 case IITDescriptor::Float:
832 case IITDescriptor::Double:
834 case IITDescriptor::Quad:
836 case IITDescriptor::PPCQuad:
838 case IITDescriptor::Integer:
840 case IITDescriptor::AArch64Svcount:
841 return !isa<TargetExtType>(Ty) ||
842 cast<TargetExtType>(Ty)->getName() !=
"aarch64.svcount";
843 case IITDescriptor::Vector: {
845 return !VT || VT->getElementCount() !=
D.Vector_Width ||
847 DeferredChecks, IsDeferredCheck);
849 case IITDescriptor::Pointer: {
851 return !PT || PT->getAddressSpace() !=
D.Pointer_AddressSpace;
854 case IITDescriptor::Struct: {
856 if (!ST || !ST->isLiteral() || ST->isPacked() ||
857 ST->getNumElements() !=
D.Struct_NumElements)
860 for (
unsigned i = 0, e =
D.Struct_NumElements; i != e; ++i)
862 DeferredChecks, IsDeferredCheck))
867 case IITDescriptor::Argument:
870 if (
D.getArgumentNumber() < ArgTys.
size())
871 return Ty != ArgTys[
D.getArgumentNumber()];
873 if (
D.getArgumentNumber() > ArgTys.
size() ||
874 D.getArgumentKind() == IITDescriptor::AK_MatchType)
875 return IsDeferredCheck || DeferCheck(Ty);
877 assert(
D.getArgumentNumber() == ArgTys.
size() && !IsDeferredCheck &&
878 "Table consistency error");
881 switch (
D.getArgumentKind()) {
882 case IITDescriptor::AK_Any:
884 case IITDescriptor::AK_AnyInteger:
886 case IITDescriptor::AK_AnyFloat:
888 case IITDescriptor::AK_AnyVector:
889 return !isa<VectorType>(Ty);
890 case IITDescriptor::AK_AnyPointer:
891 return !isa<PointerType>(Ty);
897 case IITDescriptor::ExtendArgument: {
899 if (
D.getArgumentNumber() >= ArgTys.
size())
900 return IsDeferredCheck || DeferCheck(Ty);
902 Type *NewTy = ArgTys[
D.getArgumentNumber()];
903 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
904 NewTy = VectorType::getExtendedElementVectorType(VTy);
905 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
912 case IITDescriptor::TruncArgument: {
914 if (
D.getArgumentNumber() >= ArgTys.
size())
915 return IsDeferredCheck || DeferCheck(Ty);
917 Type *NewTy = ArgTys[
D.getArgumentNumber()];
918 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
919 NewTy = VectorType::getTruncatedElementVectorType(VTy);
920 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
927 case IITDescriptor::HalfVecArgument:
929 if (
D.getArgumentNumber() >= ArgTys.
size())
930 return IsDeferredCheck || DeferCheck(Ty);
931 return !isa<VectorType>(ArgTys[
D.getArgumentNumber()]) ||
932 VectorType::getHalfElementsVectorType(
933 cast<VectorType>(ArgTys[
D.getArgumentNumber()])) != Ty;
934 case IITDescriptor::SameVecWidthArgument: {
935 if (
D.getArgumentNumber() >= ArgTys.
size()) {
937 Infos = Infos.
slice(1);
938 return IsDeferredCheck || DeferCheck(Ty);
940 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
941 auto *ThisArgType = dyn_cast<VectorType>(Ty);
947 if (
ReferenceType->getElementCount() != ThisArgType->getElementCount())
949 EltTy = ThisArgType->getElementType();
954 case IITDescriptor::VecOfAnyPtrsToElt: {
955 unsigned RefArgNumber =
D.getRefArgNumber();
956 if (RefArgNumber >= ArgTys.
size()) {
962 return DeferCheck(Ty);
965 if (!IsDeferredCheck) {
966 assert(
D.getOverloadArgNumber() == ArgTys.
size() &&
967 "Table consistency error");
974 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
975 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
977 (
ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
979 return !ThisArgVecTy->getElementType()->isPointerTy();
981 case IITDescriptor::VecElementArgument: {
982 if (
D.getArgumentNumber() >= ArgTys.
size())
983 return IsDeferredCheck ?
true : DeferCheck(Ty);
984 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
987 case IITDescriptor::Subdivide2Argument:
988 case IITDescriptor::Subdivide4Argument: {
990 if (
D.getArgumentNumber() >= ArgTys.
size())
991 return IsDeferredCheck || DeferCheck(Ty);
993 Type *NewTy = ArgTys[
D.getArgumentNumber()];
994 if (
auto *VTy = dyn_cast<VectorType>(NewTy)) {
995 int SubDivs =
D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
996 NewTy = VectorType::getSubdividedVectorType(VTy, SubDivs);
1001 case IITDescriptor::VecOfBitcastsToInt: {
1002 if (
D.getArgumentNumber() >= ArgTys.
size())
1003 return IsDeferredCheck || DeferCheck(Ty);
1004 auto *
ReferenceType = dyn_cast<VectorType>(ArgTys[
D.getArgumentNumber()]);
1005 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1008 return ThisArgVecTy != VectorType::getInteger(
ReferenceType);
1023 unsigned NumDeferredReturnChecks = DeferredChecks.
size();
1025 for (
auto *Ty : FTy->
params())
1029 for (
unsigned I = 0, E = DeferredChecks.
size();
I != E; ++
I) {
1047 if (Infos.
size() != 1)
1052 Infos = Infos.
slice(1);
1053 if (
D.Kind == IITDescriptor::VarArg)
1069 Intrinsic::MatchIntrinsicTypesResult::MatchIntrinsicTypes_Match) {
1086 return std::nullopt;
1090 std::string WantedName =
1092 if (
Name == WantedName)
1093 return std::nullopt;
1096 if (
auto *ExistingGV =
F->getParent()->getNamedValue(WantedName)) {
1097 if (
auto *ExistingF = dyn_cast<Function>(ExistingGV))
1098 if (ExistingF->getFunctionType() ==
F->getFunctionType())
1105 ExistingGV->
setName(WantedName +
".renamed");
1112 "Shouldn't change the signature");
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)
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 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 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 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 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 Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static Type * getBFloatTy(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 Type * getX86_AMXTy(LLVMContext &C)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
static Type * getMetadataTy(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)
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
bool isFP128Ty() const
Return true if this is 'fp128'.
static Type * getVoidTy(LLVMContext &C)
static Type * getFP128Ty(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.
static Type * getTokenTy(LLVMContext &C)
bool isX86_AMXTy() const
Return true if this is X86 AMX.
static Type * getFloatTy(LLVMContext &C)
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'.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
static Type * getPPC_FP128Ty(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
bool isMetadataTy() const
Return true if this is 'metadata'.
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.
ID ArrayRef< Type * > Tys
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
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
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
std::optional< Function * > remangleIntrinsicFunction(Function *F)
bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take ...
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics".
ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Function * getDeclarationIfExists(Module *M, ID id, ArrayRef< Type * > Tys, FunctionType *FT=nullptr)
This version supports overloaded intrinsics.
StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys={})
Return the function type for an intrinsic.
bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
bool isTargetIntrinsic(ID IID)
isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
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.
Helper struct shared between Function Specialization and SCCP Solver.
This is a type descriptor which explains the type requirements of an intrinsic.