34 #include "llvm/IR/IntrinsicsAArch64.h" 35 #include "llvm/IR/IntrinsicsAMDGPU.h" 36 #include "llvm/IR/IntrinsicsARM.h" 37 #include "llvm/IR/IntrinsicsBPF.h" 38 #include "llvm/IR/IntrinsicsHexagon.h" 39 #include "llvm/IR/IntrinsicsMips.h" 40 #include "llvm/IR/IntrinsicsNVPTX.h" 41 #include "llvm/IR/IntrinsicsPowerPC.h" 42 #include "llvm/IR/IntrinsicsR600.h" 43 #include "llvm/IR/IntrinsicsRISCV.h" 44 #include "llvm/IR/IntrinsicsS390.h" 45 #include "llvm/IR/IntrinsicsWebAssembly.h" 46 #include "llvm/IR/IntrinsicsX86.h" 47 #include "llvm/IR/IntrinsicsXCore.h" 80 :
Value(Ty,
Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
84 void Argument::setParent(
Function *parent) {
89 if (!
getType()->isPointerTy())
return false;
94 getType()->getPointerAddressSpace()))
100 if (!
getType()->isPointerTy())
return false;
113 if (!
getType()->isPointerTy())
return false;
118 if (!
getType()->isPointerTy())
return false;
125 assert(
getType()->isPointerTy() &&
"Only pointers have alignments");
130 assert(
getType()->isPointerTy() &&
"Only pointers have alignments");
135 assert(
getType()->isPointerTy() &&
"Only pointers have byval types");
141 "Only pointers have dereferenceable bytes");
147 "Only pointers have dereferenceable bytes");
152 if (!
getType()->isPointerTy())
return false;
157 if (!
getType()->isPointerTy())
return false;
162 if (!
getType()->isPointerTy())
return false;
167 if (!
getType()->isPointerTy())
return false;
228 unsigned NumInstrs = 0;
230 NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
231 BB.instructionsWithoutDebug().end());
241 getParent()->getFunctionList().remove(getIterator());
245 getParent()->getFunctionList().erase(getIterator());
255 if (AddrSpace == static_cast<unsigned>(-1))
267 "invalid return type");
268 setGlobalObjectSubClassData(0);
272 SymTab = std::make_unique<ValueSymbolTable>();
300 void Function::BuildLazyArguments()
const {
302 auto *FT = getFunctionType();
304 Arguments = std::allocator<Argument>().allocate(NumArgs);
305 for (
unsigned i = 0,
e = NumArgs; i !=
e; ++i) {
306 Type *ArgTy = FT->getParamType(i);
307 assert(!ArgTy->
isVoidTy() &&
"Cannot have void typed arguments!");
316 assert(!hasLazyArguments());
323 void Function::clearArguments() {
328 std::allocator<Argument>().deallocate(
Arguments, NumArgs);
333 assert(isDeclaration() &&
"Expected no references to current arguments");
336 if (!hasLazyArguments()) {
339 "Expected arguments to be unused in declaration");
351 Src.Arguments =
nullptr;
365 assert(!hasLazyArguments());
378 setIsMaterializable(
false);
385 while (!BasicBlocks.empty())
386 BasicBlocks.begin()->eraseFromParent();
389 if (getNumOperands()) {
391 setNumHungOffUseOperands(0);
497 assert(hasGC() &&
"Function has no collector");
502 setValueSubclassDataBit(14, !Str.empty());
510 setValueSubclassDataBit(14,
false);
534 #define GET_INTRINSIC_NAME_TABLE 535 #include "llvm/IR/IntrinsicImpl.inc" 536 #undef GET_INTRINSIC_NAME_TABLE 540 #define GET_INTRINSIC_TARGET_DATA 541 #include "llvm/IR/IntrinsicImpl.inc" 542 #undef GET_INTRINSIC_TARGET_DATA 556 Targets, [=](
const IntrinsicTargetInfo &TI) {
return TI.Name < Target; });
559 const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0];
560 return makeArrayRef(&IntrinsicNameTable[1] + TI.Offset, TI.Count);
578 const auto MatchSize = strlen(NameTable[Idx]);
579 assert(Name.
size() >= MatchSize &&
"Expected either exact or prefix match");
580 bool IsExactMatch = Name.
size() == MatchSize;
588 HasLLVMReservedName =
false;
592 HasLLVMReservedName =
true;
593 IntID = lookupIntrinsicID(Name);
609 if (
PointerType* PTyp = dyn_cast<PointerType>(Ty)) {
610 Result +=
"p" +
utostr(PTyp->getAddressSpace()) +
612 }
else if (
ArrayType* ATyp = dyn_cast<ArrayType>(Ty)) {
613 Result +=
"a" +
utostr(ATyp->getNumElements()) +
615 }
else if (
StructType *STyp = dyn_cast<StructType>(Ty)) {
616 if (!STyp->isLiteral()) {
618 Result += STyp->getName();
621 for (
auto Elem : STyp->elements())
626 }
else if (
FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
628 for (
size_t i = 0; i < FT->getNumParams(); i++)
634 }
else if (
VectorType* VTy = dyn_cast<VectorType>(Ty)) {
635 if (VTy->isScalable())
637 Result +=
"v" +
utostr(VTy->getVectorNumElements()) +
660 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
662 "This version of getName does not support overloading");
663 return IntrinsicNameTable[id];
667 assert(
id < num_intrinsics &&
"Invalid intrinsic ID!");
668 std::string Result(IntrinsicNameTable[
id]);
669 for (
Type *Ty : Tys) {
734 using namespace Intrinsic;
737 unsigned StructElts = 2;
741 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Void, 0));
744 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
747 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
750 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Token, 0));
753 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
756 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Half, 0));
765 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
822 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
826 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer,
832 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
833 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Argument, ArgInfo));
837 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
838 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::ExtendArgument,
843 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
844 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::TruncArgument,
849 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
850 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::HalfVecArgument,
855 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
856 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::SameVecWidthArgument,
861 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
862 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PtrToArgument,
867 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
868 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PtrToElt, ArgInfo));
872 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
873 unsigned short RefNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
875 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
879 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
888 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
890 for (
unsigned i = 0; i != StructElts; ++i)
895 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
896 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Subdivide2Argument,
901 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
902 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Subdivide4Argument,
907 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
908 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VecElementArgument,
913 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::ScalableVecArgument,
919 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
920 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt,
928 #define GET_INTRINSIC_GENERATOR_GLOBAL 929 #include "llvm/IR/IntrinsicImpl.inc" 930 #undef GET_INTRINSIC_GENERATOR_GLOBAL 935 unsigned TableVal = IIT_Table[
id-1];
940 unsigned NextElt = 0;
941 if ((TableVal >> 31) != 0) {
943 IITEntries = IIT_LongEncodingTable;
946 NextElt = (TableVal << 1) >> 1;
955 IITEntries = IITValues;
961 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
967 using namespace Intrinsic;
969 IITDescriptor
D = Infos.
front();
970 Infos = Infos.
slice(1);
987 case IITDescriptor::Pointer:
989 D.Pointer_AddressSpace);
990 case IITDescriptor::Struct: {
992 for (
unsigned i = 0,
e = D.Struct_NumElements; i !=
e; ++i)
996 case IITDescriptor::Argument:
997 return Tys[D.getArgumentNumber()];
998 case IITDescriptor::ExtendArgument: {
999 Type *Ty = Tys[D.getArgumentNumber()];
1000 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1005 case IITDescriptor::TruncArgument: {
1006 Type *Ty = Tys[D.getArgumentNumber()];
1007 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1014 case IITDescriptor::Subdivide2Argument:
1015 case IITDescriptor::Subdivide4Argument: {
1016 Type *Ty = Tys[D.getArgumentNumber()];
1018 assert(VTy &&
"Expected an argument of Vector Type");
1019 int SubDivs = D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1022 case IITDescriptor::HalfVecArgument:
1024 Tys[D.getArgumentNumber()]));
1025 case IITDescriptor::SameVecWidthArgument: {
1027 Type *Ty = Tys[D.getArgumentNumber()];
1028 if (
auto *VTy = dyn_cast<VectorType>(Ty))
1032 case IITDescriptor::PtrToArgument: {
1033 Type *Ty = Tys[D.getArgumentNumber()];
1036 case IITDescriptor::PtrToElt: {
1037 Type *Ty = Tys[D.getArgumentNumber()];
1044 case IITDescriptor::VecElementArgument: {
1045 Type *Ty = Tys[D.getArgumentNumber()];
1046 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1047 return VTy->getElementType();
1050 case IITDescriptor::VecOfBitcastsToInt: {
1051 Type *Ty = Tys[D.getArgumentNumber()];
1053 assert(VTy &&
"Expected an argument of Vector Type");
1056 case IITDescriptor::VecOfAnyPtrsToElt:
1058 return Tys[D.getOverloadArgNumber()];
1059 case IITDescriptor::ScalableVecArgument: {
1077 while (!TableRef.
empty())
1082 if (!ArgTys.
empty() && ArgTys.
back()->isVoidTy()) {
1090 #define GET_INTRINSIC_OVERLOAD_TABLE 1091 #include "llvm/IR/IntrinsicImpl.inc" 1092 #undef GET_INTRINSIC_OVERLOAD_TABLE 1100 case Intrinsic::experimental_gc_statepoint:
1101 case Intrinsic::experimental_patchpoint_void:
1102 case Intrinsic::experimental_patchpoint_i64:
1108 #define GET_INTRINSIC_ATTRIBUTES 1109 #include "llvm/IR/IntrinsicImpl.inc" 1110 #undef GET_INTRINSIC_ATTRIBUTES 1115 return cast<Function>(
1122 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN 1123 #include "llvm/IR/IntrinsicImpl.inc" 1124 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN 1127 #define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN 1128 #include "llvm/IR/IntrinsicImpl.inc" 1129 #undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN 1132 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
1138 bool IsDeferredCheck) {
1139 using namespace Intrinsic;
1142 if (Infos.
empty())
return true;
1145 auto InfosRef = Infos;
1146 auto DeferCheck = [&DeferredChecks, &InfosRef](
Type *
T) {
1151 IITDescriptor
D = Infos.
front();
1152 Infos = Infos.
slice(1);
1155 case IITDescriptor::Void:
return !Ty->
isVoidTy();
1156 case IITDescriptor::VarArg:
return true;
1157 case IITDescriptor::MMX:
return !Ty->
isX86_MMXTy();
1158 case IITDescriptor::Token:
return !Ty->
isTokenTy();
1159 case IITDescriptor::Metadata:
return !Ty->
isMetadataTy();
1160 case IITDescriptor::Half:
return !Ty->
isHalfTy();
1163 case IITDescriptor::Quad:
return !Ty->
isFP128Ty();
1169 DeferredChecks, IsDeferredCheck);
1171 case IITDescriptor::Pointer: {
1175 DeferredChecks, IsDeferredCheck);
1178 case IITDescriptor::Struct: {
1183 for (
unsigned i = 0,
e = D.Struct_NumElements; i !=
e; ++i)
1185 DeferredChecks, IsDeferredCheck))
1190 case IITDescriptor::Argument:
1193 if (D.getArgumentNumber() < ArgTys.
size())
1194 return Ty != ArgTys[D.getArgumentNumber()];
1196 if (D.getArgumentNumber() > ArgTys.
size() ||
1197 D.getArgumentKind() == IITDescriptor::AK_MatchType)
1198 return IsDeferredCheck || DeferCheck(Ty);
1200 assert(D.getArgumentNumber() == ArgTys.
size() && !IsDeferredCheck &&
1201 "Table consistency error");
1204 switch (D.getArgumentKind()) {
1205 case IITDescriptor::AK_Any:
return false;
1208 case IITDescriptor::AK_AnyVector:
return !isa<VectorType>(Ty);
1209 case IITDescriptor::AK_AnyPointer:
return !isa<PointerType>(Ty);
1214 case IITDescriptor::ExtendArgument: {
1216 if (D.getArgumentNumber() >= ArgTys.
size())
1217 return IsDeferredCheck || DeferCheck(Ty);
1219 Type *NewTy = ArgTys[D.getArgumentNumber()];
1220 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
1222 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1229 case IITDescriptor::TruncArgument: {
1231 if (D.getArgumentNumber() >= ArgTys.
size())
1232 return IsDeferredCheck || DeferCheck(Ty);
1234 Type *NewTy = ArgTys[D.getArgumentNumber()];
1235 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
1237 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1244 case IITDescriptor::HalfVecArgument:
1246 if (D.getArgumentNumber() >= ArgTys.
size())
1247 return IsDeferredCheck || DeferCheck(Ty);
1248 return !isa<VectorType>(ArgTys[D.getArgumentNumber()]) ||
1250 cast<VectorType>(ArgTys[D.getArgumentNumber()])) != Ty;
1251 case IITDescriptor::SameVecWidthArgument: {
1252 if (D.getArgumentNumber() >= ArgTys.
size()) {
1254 Infos = Infos.
slice(1);
1255 return IsDeferredCheck || DeferCheck(Ty);
1265 ThisArgType->getElementCount())
1272 case IITDescriptor::PtrToArgument: {
1273 if (D.getArgumentNumber() >= ArgTys.
size())
1274 return IsDeferredCheck || DeferCheck(Ty);
1277 return (!ThisArgType || ThisArgType->
getElementType() != ReferenceType);
1279 case IITDescriptor::PtrToElt: {
1280 if (D.getArgumentNumber() >= ArgTys.
size())
1281 return IsDeferredCheck || DeferCheck(Ty);
1286 return (!ThisArgType || !ReferenceType ||
1289 case IITDescriptor::VecOfAnyPtrsToElt: {
1290 unsigned RefArgNumber = D.getRefArgNumber();
1291 if (RefArgNumber >= ArgTys.
size()) {
1292 if (IsDeferredCheck)
1297 return DeferCheck(Ty);
1300 if (!IsDeferredCheck){
1301 assert(D.getOverloadArgNumber() == ArgTys.
size() &&
1302 "Table consistency error");
1311 if (!ThisArgVecTy || !ReferenceType ||
1313 ThisArgVecTy->getVectorNumElements()))
1322 case IITDescriptor::VecElementArgument: {
1323 if (D.getArgumentNumber() >= ArgTys.
size())
1324 return IsDeferredCheck ?
true : DeferCheck(Ty);
1328 case IITDescriptor::Subdivide2Argument:
1329 case IITDescriptor::Subdivide4Argument: {
1331 if (D.getArgumentNumber() >= ArgTys.
size())
1332 return IsDeferredCheck || DeferCheck(Ty);
1334 Type *NewTy = ArgTys[D.getArgumentNumber()];
1335 if (
auto *VTy = dyn_cast<VectorType>(NewTy)) {
1336 int SubDivs = D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1342 case IITDescriptor::ScalableVecArgument: {
1349 case IITDescriptor::VecOfBitcastsToInt: {
1350 if (D.getArgumentNumber() >= ArgTys.
size())
1351 return IsDeferredCheck || DeferCheck(Ty);
1371 unsigned NumDeferredReturnChecks = DeferredChecks.size();
1373 for (
auto Ty : FTy->
params())
1377 for (
unsigned I = 0,
E = DeferredChecks.size();
I !=
E; ++
I) {
1396 if (Infos.
size() != 1)
1401 Infos = Infos.
slice(1);
1402 if (D.
Kind == IITDescriptor::VarArg)
1433 assert(NewDecl->getFunctionType() == FTy &&
"Shouldn't change the signature");
1441 const User *FU = U.getUser();
1442 if (isa<BlockAddress>(FU))
1450 if (!Call->isCallee(&U)) {
1461 if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
1462 !hasAvailableExternallyLinkage())
1467 if (!isa<BlockAddress>(U))
1477 if (
const auto *Call = dyn_cast<CallBase>(&
I))
1478 if (Call->hasFnAttr(Attribute::ReturnsTwice))
1485 assert(hasPersonalityFn() && getNumOperands());
1486 return cast<Constant>(Op<0>());
1490 setHungoffOperand<0>(Fn);
1491 setValueSubclassDataBit(3, Fn !=
nullptr);
1495 assert(hasPrefixData() && getNumOperands());
1496 return cast<Constant>(Op<1>());
1500 setHungoffOperand<1>(PrefixData);
1501 setValueSubclassDataBit(1, PrefixData !=
nullptr);
1505 assert(hasPrologueData() && getNumOperands());
1506 return cast<Constant>(Op<2>());
1510 setHungoffOperand<2>(PrologueData);
1511 setValueSubclassDataBit(2, PrologueData !=
nullptr);
1514 void Function::allocHungoffUselist() {
1516 if (getNumOperands())
1519 allocHungoffUses(3,
false);
1520 setNumHungOffUseOperands(3);
1530 void Function::setHungoffOperand(
Constant *
C) {
1532 allocHungoffUselist();
1534 }
else if (getNumOperands()) {
1540 void Function::setValueSubclassDataBit(
unsigned Bit,
bool On) {
1541 assert(Bit < 16 &&
"SubclassData contains only 16 bits");
1551 #if !defined(NDEBUG) 1552 auto PrevCount = getEntryCount();
1553 assert(!PrevCount.hasValue() || PrevCount.getType() == Count.
getType());
1556 auto ImportGUIDs = getImportGUIDs();
1557 if (S ==
nullptr && ImportGUIDs.
size())
1562 LLVMContext::MD_prof,
1572 MDNode *MD = getMetadata(LLVMContext::MD_prof);
1575 if (MDS->getString().equals(
"function_entry_count")) {
1580 if (Count == (uint64_t)-1)
1583 }
else if (AllowSynthetic &&
1584 MDS->getString().equals(
"synthetic_function_entry_count")) {
1595 if (
MDNode *MD = getMetadata(LLVMContext::MD_prof))
1596 if (
MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
1597 if (MDS->getString().equals(
"function_entry_count"))
1598 for (
unsigned i = 2; i < MD->getNumOperands(); i++)
1599 R.
insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
1612 if (
MDNode *MD = getMetadata(LLVMContext::MD_section_prefix)) {
1613 assert(cast<MDString>(MD->getOperand(0))
1615 .equals(
"function_section_prefix") &&
1616 "Metadata not match");
1617 return cast<MDString>(MD->getOperand(1))->getString();
1623 return getFnAttribute(
"null-pointer-is-valid")
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
const T & front() const
front - Get the first element.
bool hasNestAttr() const
Return true if this argument has the nest attribute.
static bool Check(DecodeStatus &Out, DecodeStatus In)
Type * getVectorElementType() const
unsigned short getSubclassDataFromValue() const
reference emplace_back(ArgTypes &&... Args)
iterator_range< use_iterator > uses()
bool hasAttribute(Attribute::AttrKind Kind) const
Check if an argument has a given attribute.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
static Type * getDoubleTy(LLVMContext &C)
uint64_t getZExtValue() const
Get zero extended value.
This class represents an incoming formal argument to a Function.
uint64_t getDereferenceableOrNullBytes() const
If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be de...
void dropAllReferences()
Drop all references to operands.
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
bool isMetadataTy() const
Return true if this is 'metadata'.
MatchIntrinsicTypesResult
This class represents lattice values for constants.
Type * getElementType(unsigned N) const
void removeAttr(Attribute::AttrKind Kind)
Remove attributes from an argument.
Argument(Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0)
Argument constructor.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
A Module instance is used to store all the information related to an LLVM module. ...
2: 32-bit floating point type
const std::string & getGC(const Function &Fn)
Return the GC for a function.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void addDereferenceableAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes.
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Implements a dense probed hash-table based set.
unsigned getNumElements() const
Random access to the elements.
void push_back(const T &Elt)
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
bool hasByValOrInAllocaAttr() const
Return true if this argument has the byval attribute or inalloca attribute.
bool isFP128Ty() const
Return true if this is 'fp128'.
void setGC(const Function &Fn, std::string GCName)
Define the GC for a function.
void setGC(std::string Str)
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
The two locations do not alias at all.
void addAttrs(AttrBuilder &B)
Add attributes to an argument.
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
LLVMContext & getContext() const
All values hold a context through their type.
static MutableArrayRef< Argument > makeArgArray(Argument *Args, size_t Count)
bool hasPrologueData() const
Check whether this function has prologue data.
void setSectionPrefix(StringRef Prefix)
Set the section prefix for this function.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
4: 80-bit floating point type (X87)
This is a type descriptor which explains the type requirements of an intrinsic.
static bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
const MDOperand & getOperand(unsigned I) const
1: 16-bit floating point type
static Type * getMetadataTy(LLVMContext &C)
This defines the Use class.
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
static Type * getX86_MMXTy(LLVMContext &C)
bool hasByValAttr() const
Return true if this argument has the byval attribute.
LLVM_NODISCARD AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO, to enable the same inlines as the profiled optimized binary.
Constant * getPrologueData() const
Get the prologue data associated with this function.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Type * getParamByValType() const
If this is a byval argument, return its type.
bool hasPrefixData() const
Check whether this function has prefix data.
MDNode * createFunctionEntryCount(uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports)
Return metadata containing the entry Count for a function, a boolean indicating whether the counts w...
static Type * getTokenTy(LLVMContext &C)
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
static Type * getFloatTy(LLVMContext &C)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
TypeID getTypeID() const
Return the type id for the type.
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
A Use represents the edge between a Value definition and its users.
void deleteGC(const Function &Fn)
Remove the GC for a function.
LLVM_NODISCARD AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isIntegerTy() const
True if this is an instance of IntegerType.
This file contains the simple types necessary to represent the attributes associated with functions a...
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
MaybeAlign getParamAlign() const
If this is a byval or inalloca argument, return its alignment.
void setName(const Twine &Name)
Change the name of the value.
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Constant * getPrefixData() const
Get the prefix data associated with this function.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
llvm::Optional< Function * > remangleIntrinsicFunction(Function *F)
auto partition_point(R &&Range, Predicate P) -> decltype(adl_begin(Range))
Binary search for the first iterator in a range where a predicate is false.
Class to represent function types.
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
Type * getType() const
All values are typed, get the type of this value.
LLVM_NODISCARD AttributeList removeAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &AttrsToRemove) const
Remove the specified attributes at the specified index from this attribute list.
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
Class to represent array types.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
const APInt & getValue() const
Return the constant as an APInt value reference.
const std::string & getGC() const
void addDereferenceableOrNullAttr(unsigned i, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes.
AttributeList getAttributes() const
Return the attribute list for this Function.
bool hasPersonalityFn() const
Check whether this function has a personality function.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type *> Tys, LLVMContext &Context)
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Analysis containing CSE Info
Class to represent pointers.
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute.
11: Arbitrary bit width integers
static std::string getMangledTypeStr(Type *Ty)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
bool isVoidTy() const
Return true if this is 'void'.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
void setCallingConv(CallingConv::ID CC)
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void addAttr(Attribute::AttrKind Kind)
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM_NODISCARD AttributeList addDereferenceableOrNullAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given index.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
bool isLeaf(ID id)
Returns true if the intrinsic is a leaf, i.e.
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
uint64_t getCount() const
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
LLVM Basic Block Representation.
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
bool hasNonNullAttr() const
Return true if this argument has the nonnull attribute.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool hasSExtAttr() const
Return true if this argument has the sext attribute.
std::pair< iterator, bool > insert(const ValueT &V)
void removeAttribute(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
AMDGPU Lower Kernel Arguments
ProfileCount getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
LLVM_NODISCARD AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
ArrayRef< Type * > params() const
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
static Type * getVoidTy(LLVMContext &C)
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type...
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
6: 128-bit floating point type (two 64-bits, PowerPC)
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
bool hasReturnedAttr() const
Return true if this argument has the returned attribute.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
void recalculateIntrinsicID()
Recalculate the ID for this function if it is an Intrinsic defined in llvm/Intrinsics.h.
Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
gets the specified attribute from the list of attributes.
bool isX86_MMXTy() const
Return true if this is X86 MMX.
Optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
Class to represent integer types.
void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
removes the attribute from the list of attributes.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
bool hasInAllocaAttr() const
Return true if this argument has the inalloca attribute.
Class to represent profile counts.
static ArrayRef< const char * > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameTable for intrinsics with the same target as Name, or the generic table if Name is not target specific.
C setMetadata(LLVMContext::MD_range, MDNode::get(Context, LowAndHigh))
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static Type * getFP128Ty(LLVMContext &C)
LLVM_NODISCARD AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
enum llvm::Intrinsic::IITDescriptor::IITDescriptorKind Kind
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
bool isScalable() const
Returns whether or not this is a scalable vector (meaning the total element count is a multiple of th...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned getParamAlignment() const
If this is a byval or inalloca argument, return its alignment.
Module.h This file contains the declarations for the Module class.
MaybeAlign getParamAlign(unsigned ArgNo) const
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type *> Tys=None)
Return the function type for an intrinsic.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool hasSwiftSelfAttr() const
Return true if this argument has the swiftself attribute.
MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type *> &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
Type * getReturnType() const
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
unsigned getProgramAddressSpace() const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static ProfileCount getInvalid()
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
std::string utostr(uint64_t X, bool isNeg=false)
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
void setValueSubclassData(unsigned short D)
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
unsigned getVectorNumElements() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Class to represent vector types.
Target - Wrapper for Target specific information.
void push_back(pointer val)
LinkageTypes
An enumeration for the kinds of linkage for global values.
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
iterator_range< user_iterator > users()
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...
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
static unsigned computeAddrSpace(unsigned AddrSpace, Module *M)
Function::ProfileCount ProfileCount
void removeAttributes(unsigned i, const AttrBuilder &Attrs)
removes the attributes from the list of attributes.
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
bool hasInRegAttr() const
Return true if this argument has the inreg attribute.
const Function * getParent() const
LLVM_NODISCARD AttributeList addDereferenceableAttr(LLVMContext &C, unsigned Index, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given index.
Linkage
Describes symbol linkage.
LLVM_NODISCARD bool empty() const
bool isTokenTy() const
Return true if this is 'token'.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
StringRef getName() const
Return a constant reference to the value's name.
LLVM_NODISCARD AttributeList removeAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
bool hasSwiftErrorAttr() const
Return true if this argument has the swifterror attribute.
void setPrologueData(Constant *PrologueData)
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
Compile-time customization of User operands.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
LLVM_NODISCARD AttributeList addAttributes(LLVMContext &C, unsigned Index, const AttrBuilder &B) const
Add attributes to the attribute set at the given index.
LLVM_NODISCARD AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
3: 64-bit floating point type
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
void addAttributes(unsigned i, const AttrBuilder &Attrs)
adds the attributes to the list of attributes.
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type *> &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
ProfileCountType getType() const
bool hasZExtAttr() const
Return true if this argument has the zext attribute.
static const char *const IntrinsicNameTable[]
Table of string intrinsic names indexed by enum value.
Type * getElementType() const
MDNode * createFunctionSectionPrefix(StringRef Prefix)
Return metadata containing the section prefix for a function.
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
int lookupLLVMIntrinsicByName(ArrayRef< const char *> NameTable, StringRef Name)
Looks up Name in NameTable via binary search.
void setPersonalityFn(Constant *Fn)
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
9: MMX vectors (64 bits, X86 specific)
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute.
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
void copyAttributesFrom(const GlobalObject *Src)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
Attribute getAttribute(Attribute::AttrKind Kind) const
uint64_t getDereferenceableBytes() const
If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenc...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand...
Type * getElementType() const
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
bool empty() const
empty - Check if the array is empty.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
5: 128-bit floating point type (112-bit mantissa)
void setPrefixData(Constant *PrefixData)