68 :
Value(Ty,
Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
72 void Argument::setParent(
Function *parent) {
77 if (!
getType()->isPointerTy())
return false;
82 getType()->getPointerAddressSpace()))
88 if (!
getType()->isPointerTy())
return false;
101 if (!
getType()->isPointerTy())
return false;
106 if (!
getType()->isPointerTy())
return false;
113 assert(
getType()->isPointerTy() &&
"Only pointers have alignments");
119 "Only pointers have dereferenceable bytes");
125 "Only pointers have dereferenceable bytes");
130 if (!
getType()->isPointerTy())
return false;
135 if (!
getType()->isPointerTy())
return false;
140 if (!
getType()->isPointerTy())
return false;
145 if (!
getType()->isPointerTy())
return false;
198 unsigned NumInstrs = 0;
200 NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
201 BB.instructionsWithoutDebug().end());
211 getParent()->getFunctionList().remove(getIterator());
215 getParent()->getFunctionList().erase(getIterator());
225 if (AddrSpace == static_cast<unsigned>(-1))
230 Function::Function(
FunctionType *Ty, LinkageTypes Linkage,
unsigned AddrSpace,
237 "invalid return type");
238 setGlobalObjectSubClassData(0);
242 SymTab = make_unique<ValueSymbolTable>();
270 void Function::BuildLazyArguments()
const {
272 auto *FT = getFunctionType();
274 Arguments = std::allocator<Argument>().allocate(NumArgs);
275 for (
unsigned i = 0, e = NumArgs; i != e; ++i) {
276 Type *ArgTy = FT->getParamType(i);
277 assert(!ArgTy->
isVoidTy() &&
"Cannot have void typed arguments!");
285 assert(!hasLazyArguments());
292 void Function::clearArguments() {
297 std::allocator<Argument>().deallocate(
Arguments, NumArgs);
302 assert(isDeclaration() &&
"Expected no references to current arguments");
305 if (!hasLazyArguments()) {
308 "Expected arguments to be unused in declaration");
320 Src.Arguments =
nullptr;
334 assert(!hasLazyArguments());
347 setIsMaterializable(
false);
354 while (!BasicBlocks.empty())
355 BasicBlocks.begin()->eraseFromParent();
358 if (getNumOperands()) {
360 setNumHungOffUseOperands(0);
466 assert(hasGC() &&
"Function has no collector");
471 setValueSubclassDataBit(14, !Str.empty());
479 setValueSubclassDataBit(14,
false);
503 #define GET_INTRINSIC_NAME_TABLE 504 #include "llvm/IR/IntrinsicImpl.inc" 505 #undef GET_INTRINSIC_NAME_TABLE 509 #define GET_INTRINSIC_TARGET_DATA 510 #include "llvm/IR/IntrinsicImpl.inc" 511 #undef GET_INTRINSIC_TARGET_DATA 525 [](
const IntrinsicTargetInfo &TI,
526 StringRef Target) {
return TI.Name < Target; });
529 const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0];
530 return makeArrayRef(&IntrinsicNameTable[1] + TI.Offset, TI.Count);
548 const auto MatchSize = strlen(NameTable[Idx]);
549 assert(Name.
size() >= MatchSize &&
"Expected either exact or prefix match");
550 bool IsExactMatch = Name.
size() == MatchSize;
557 HasLLVMReservedName =
false;
561 HasLLVMReservedName =
true;
562 IntID = lookupIntrinsicID(Name);
578 if (
PointerType* PTyp = dyn_cast<PointerType>(Ty)) {
579 Result +=
"p" +
utostr(PTyp->getAddressSpace()) +
581 }
else if (
ArrayType* ATyp = dyn_cast<ArrayType>(Ty)) {
582 Result +=
"a" +
utostr(ATyp->getNumElements()) +
584 }
else if (
StructType *STyp = dyn_cast<StructType>(Ty)) {
585 if (!STyp->isLiteral()) {
587 Result += STyp->getName();
590 for (
auto Elem : STyp->elements())
595 }
else if (
FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
597 for (
size_t i = 0; i < FT->getNumParams(); i++)
603 }
else if (isa<VectorType>(Ty)) {
629 "This version of getName does not support overloading");
630 return IntrinsicNameTable[id];
635 std::string Result(IntrinsicNameTable[
id]);
636 for (
Type *Ty : Tys) {
696 using namespace Intrinsic;
699 unsigned StructElts = 2;
703 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Void, 0));
706 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
709 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
712 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Token, 0));
718 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Half, 0));
727 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
748 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 1));
752 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 2));
756 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 4));
760 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 8));
764 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 16));
768 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 32));
772 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 64));
776 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 512));
780 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Vector, 1024));
784 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
788 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Pointer,
794 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
795 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Argument, ArgInfo));
799 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
800 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::ExtendArgument,
805 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
806 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::TruncArgument,
811 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
812 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::HalfVecArgument,
817 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
818 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::SameVecWidthArgument,
823 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
824 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PtrToArgument,
829 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
830 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::PtrToElt, ArgInfo));
834 unsigned short ArgNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
835 unsigned short RefNo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
837 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
841 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
850 OutputTable.
push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
852 for (
unsigned i = 0; i != StructElts; ++i)
860 #define GET_INTRINSIC_GENERATOR_GLOBAL 861 #include "llvm/IR/IntrinsicImpl.inc" 862 #undef GET_INTRINSIC_GENERATOR_GLOBAL 867 unsigned TableVal = IIT_Table[
id-1];
872 unsigned NextElt = 0;
873 if ((TableVal >> 31) != 0) {
875 IITEntries = IIT_LongEncodingTable;
878 NextElt = (TableVal << 1) >> 1;
887 IITEntries = IITValues;
893 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
899 using namespace Intrinsic;
901 IITDescriptor
D = Infos.
front();
902 Infos = Infos.
slice(1);
917 case IITDescriptor::Vector:
919 case IITDescriptor::Pointer:
921 D.Pointer_AddressSpace);
922 case IITDescriptor::Struct: {
924 for (
unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
928 case IITDescriptor::Argument:
929 return Tys[D.getArgumentNumber()];
930 case IITDescriptor::ExtendArgument: {
931 Type *Ty = Tys[D.getArgumentNumber()];
932 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
937 case IITDescriptor::TruncArgument: {
938 Type *Ty = Tys[D.getArgumentNumber()];
939 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
946 case IITDescriptor::HalfVecArgument:
948 Tys[D.getArgumentNumber()]));
949 case IITDescriptor::SameVecWidthArgument: {
951 Type *Ty = Tys[D.getArgumentNumber()];
952 if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
957 case IITDescriptor::PtrToArgument: {
958 Type *Ty = Tys[D.getArgumentNumber()];
961 case IITDescriptor::PtrToElt: {
962 Type *Ty = Tys[D.getArgumentNumber()];
969 case IITDescriptor::VecOfAnyPtrsToElt:
971 return Tys[D.getOverloadArgNumber()];
985 while (!TableRef.
empty())
998 #define GET_INTRINSIC_OVERLOAD_TABLE 999 #include "llvm/IR/IntrinsicImpl.inc" 1000 #undef GET_INTRINSIC_OVERLOAD_TABLE 1016 #define GET_INTRINSIC_ATTRIBUTES 1017 #include "llvm/IR/IntrinsicImpl.inc" 1018 #undef GET_INTRINSIC_ATTRIBUTES 1029 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN 1030 #include "llvm/IR/IntrinsicImpl.inc" 1031 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN 1034 #define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN 1035 #include "llvm/IR/IntrinsicImpl.inc" 1036 #undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN 1040 using namespace Intrinsic;
1043 if (Infos.
empty())
return true;
1045 Infos = Infos.
slice(1);
1048 case IITDescriptor::Void:
return !Ty->
isVoidTy();
1049 case IITDescriptor::VarArg:
return true;
1050 case IITDescriptor::MMX:
return !Ty->
isX86_MMXTy();
1051 case IITDescriptor::Token:
return !Ty->
isTokenTy();
1053 case IITDescriptor::Half:
return !Ty->
isHalfTy();
1056 case IITDescriptor::Quad:
return !Ty->
isFP128Ty();
1058 case IITDescriptor::Vector: {
1063 case IITDescriptor::Pointer: {
1069 case IITDescriptor::Struct: {
1080 case IITDescriptor::Argument:
1092 case IITDescriptor::AK_Any:
return false;
1095 case IITDescriptor::AK_AnyVector:
return !isa<VectorType>(Ty);
1096 case IITDescriptor::AK_AnyPointer:
return !isa<PointerType>(Ty);
1100 case IITDescriptor::ExtendArgument: {
1106 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
1108 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1115 case IITDescriptor::TruncArgument: {
1121 if (
VectorType *VTy = dyn_cast<VectorType>(NewTy))
1123 else if (
IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1130 case IITDescriptor::HalfVecArgument:
1136 case IITDescriptor::SameVecWidthArgument: {
1142 if (!ThisArgType || !ReferenceType ||
1144 ThisArgType->getVectorNumElements()))
1149 case IITDescriptor::PtrToArgument: {
1154 return (!ThisArgType || ThisArgType->
getElementType() != ReferenceType);
1156 case IITDescriptor::PtrToElt: {
1163 return (!ThisArgType || !ReferenceType ||
1166 case IITDescriptor::VecOfAnyPtrsToElt: {
1170 if (RefArgNumber >= ArgTys.
size())
1175 "Table consistency error");
1183 if (!ThisArgVecTy || !ReferenceType ||
1185 ThisArgVecTy->getVectorNumElements()))
1206 if (Infos.
size() != 1)
1211 Infos = Infos.
slice(1);
1212 if (D.
Kind == IITDescriptor::VarArg)
1235 for (
auto Ty : FTy->
params())
1248 assert(NewDecl->getFunctionType() == FTy &&
"Shouldn't change the signature");
1256 const User *FU = U.getUser();
1257 if (isa<BlockAddress>(FU))
1265 if (!Call->isCallee(&U)) {
1276 if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
1277 !hasAvailableExternallyLinkage())
1282 if (!isa<BlockAddress>(U))
1292 if (
const auto *Call = dyn_cast<CallBase>(&
I))
1300 assert(hasPersonalityFn() && getNumOperands());
1301 return cast<Constant>(Op<0>());
1305 setHungoffOperand<0>(Fn);
1306 setValueSubclassDataBit(3, Fn !=
nullptr);
1310 assert(hasPrefixData() && getNumOperands());
1311 return cast<Constant>(Op<1>());
1315 setHungoffOperand<1>(PrefixData);
1316 setValueSubclassDataBit(1, PrefixData !=
nullptr);
1320 assert(hasPrologueData() && getNumOperands());
1321 return cast<Constant>(Op<2>());
1325 setHungoffOperand<2>(PrologueData);
1326 setValueSubclassDataBit(2, PrologueData !=
nullptr);
1329 void Function::allocHungoffUselist() {
1331 if (getNumOperands())
1334 allocHungoffUses(3,
false);
1335 setNumHungOffUseOperands(3);
1345 void Function::setHungoffOperand(
Constant *
C) {
1347 allocHungoffUselist();
1349 }
else if (getNumOperands()) {
1355 void Function::setValueSubclassDataBit(
unsigned Bit,
bool On) {
1356 assert(Bit < 16 &&
"SubclassData contains only 16 bits");
1366 #if !defined(NDEBUG) 1367 auto PrevCount = getEntryCount();
1368 assert(!PrevCount.hasValue() || PrevCount.getType() == Count.
getType());
1385 if (MDS->getString().equals(
"function_entry_count")) {
1390 if (Count == (uint64_t)-1)
1393 }
else if (MDS->getString().equals(
"synthetic_function_entry_count")) {
1405 if (
MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
1406 if (MDS->getString().equals(
"function_entry_count"))
1407 for (
unsigned i = 2; i < MD->getNumOperands(); i++)
1408 R.
insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
1422 assert(cast<MDString>(MD->getOperand(0))
1424 .equals(
"function_section_prefix") &&
1425 "Metadata not match");
1426 return cast<MDString>(MD->getOperand(1))->getString();
1432 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.
Type * getVectorElementType() const
unsigned short getSubclassDataFromValue() const
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...
ArgKind getArgumentKind() const
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'.
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.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
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.
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.
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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...
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)
This static method is like getInteger except that the element types are half as wide as the elements ...
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.
bool hasPrefixData() const
Check whether this function has prefix data.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.
ProfileCount getEntryCount() const
Get the entry count for this function.
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.
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.
void setName(const Twine &Name)
Change the name of the value.
uint64_t getNumElements() const
unsigned getArgumentNumber() const
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_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
llvm::Optional< Function * > remangleIntrinsicFunction(Function *F)
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.
unsigned Struct_NumElements
Class to represent array types.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
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.
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.
This is an important base class in LLVM.
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
unsigned Pointer_AddressSpace
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
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)
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.
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 LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
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.
unsigned getOverloadArgNumber() const
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.
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.
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.
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()
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.
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...
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.
unsigned getRefArgNumber() const
LLVM_NODISCARD bool empty() const
bool isTokenTy() const
Return true if this is 'token'.
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 matchIntrinsicType(Type *Ty, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type *> &ArgTys)
Match the specified type (which comes from an intrinsic argument or return value) with the type const...
bool hasSwiftErrorAttr() const
Return true if this argument has the swifterror attribute.
void setPrologueData(Constant *PrologueData)
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())
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.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
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 ...
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...
std::vector< uint32_t > Metadata
PAL metadata represented as a vector.
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)