43 void Argument::anchor() { }
57 void Argument::setParent(
Function *parent) {
69 assert(F &&
"Argument is not in a function");
73 for (; &*AI !=
this; ++AI)
82 if (!
getType()->isPointerTy())
return false;
88 assert(
getType()->isPointerTy() &&
"Only pointers have alignments");
96 if (!
getType()->isPointerTy())
return false;
104 if (!
getType()->isPointerTy())
return false;
112 if (!
getType()->isPointerTy())
return false;
120 if (!
getType()->isPointerTy())
return false;
146 "Trying to add more than one attribute set to an argument!");
156 "Trying to remove more than one attribute set from an argument!");
195 Function::Function(
FunctionType *Ty, LinkageTypes Linkage,
198 Value::FunctionVal, 0, 0, Linkage, name) {
200 "invalid return type");
205 setValueSubclassData(1);
223 ArgumentList.
clear();
234 void Function::BuildLazyArguments()
const {
237 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
239 "Cannot have void typed arguments!");
245 const_cast<Function*
>(
this)->setValueSubclassData(SDC &= ~1);
255 void Function::setParent(
Module *parent) {
273 I->dropAllReferences();
277 while (!BasicBlocks.
empty())
278 BasicBlocks.
begin()->eraseFromParent();
316 assert(
hasGC() &&
"Function has no collector");
318 return *(*GCNames)[
this];
348 assert(isa<Function>(Src) &&
"Expected a Function!");
350 const Function *SrcF = cast<Function>(Src);
378 if (!IntrinsicIDCache.
count(
this)) {
379 unsigned Id = lookupIntrinsicID();
380 IntrinsicIDCache[
this]=
Id;
383 return IntrinsicIDCache[
this];
388 unsigned Function::lookupIntrinsicID()
const {
393 #define GET_FUNCTION_RECOGNIZER
394 #include "llvm/IR/Intrinsics.gen"
395 #undef GET_FUNCTION_RECOGNIZER
402 static const char *
const Table[] = {
404 #define GET_INTRINSIC_NAME_TABLE
405 #include "llvm/IR/Intrinsics.gen"
406 #undef GET_INTRINSIC_NAME_TABLE
410 std::string Result(Table[
id]);
411 for (
unsigned i = 0; i < Tys.
size(); ++i) {
412 if (
PointerType* PTyp = dyn_cast<PointerType>(Tys[i])) {
413 Result +=
".p" +
llvm::utostr(PTyp->getAddressSpace()) +
414 EVT::getEVT(PTyp->getElementType()).getEVTString();
465 unsigned StructElts = 2;
466 using namespace Intrinsic;
540 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
545 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
551 unsigned ArgInfo = (NextElt == Infos.
size() ? 0 : Infos[NextElt++]);
565 for (
unsigned i = 0; i != StructElts; ++i)
574 #define GET_INTRINSIC_GENERATOR_GLOBAL
575 #include "llvm/IR/Intrinsics.gen"
576 #undef GET_INTRINSIC_GENERATOR_GLOBAL
581 unsigned TableVal = IIT_Table[
id-1];
586 unsigned NextElt = 0;
587 if ((TableVal >> 31) != 0) {
589 IITEntries = IIT_LongEncodingTable;
592 NextElt = (TableVal << 1) >> 1;
601 IITEntries = IITValues;
607 while (NextElt != IITEntries.
size() && IITEntries[NextElt] != 0)
614 using namespace Intrinsic;
615 IITDescriptor D = Infos.
front();
616 Infos = Infos.
slice(1);
633 D.Pointer_AddressSpace);
636 assert(D.Struct_NumElements <= 5 &&
"Can't handle this yet");
637 for (
unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
643 return Tys[D.getArgumentNumber()];
646 Tys[D.getArgumentNumber()]));
650 Tys[D.getArgumentNumber()]));
666 while (!TableRef.
empty())
673 #define GET_INTRINSIC_OVERLOAD_TABLE
674 #include "llvm/IR/Intrinsics.gen"
675 #undef GET_INTRINSIC_OVERLOAD_TABLE
679 #define GET_INTRINSIC_ATTRIBUTES
680 #include "llvm/IR/Intrinsics.gen"
681 #undef GET_INTRINSIC_ATTRIBUTES
692 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
693 #include "llvm/IR/Intrinsics.gen"
694 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
701 if (isa<BlockAddress>(U))
703 if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
704 return PutOffender ? (*PutOffender = U,
true) :
true;
707 return PutOffender ? (*PutOffender = U,
true) :
true;
720 if (!isa<BlockAddress>(*
I))
745 assert(PDMap.
find(
this) != PDMap.
end());
746 return cast<Constant>(PDMap.
find(
this)->second->getReturnValue());
767 setValueSubclassData(SCData);
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute on it in its containing function.
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute on it in its containing function.
bool isDefTriviallyDead() const
void push_back(const T &Elt)
static Type * getDoubleTy(LLVMContext &C)
PooledStringPtr intern(StringRef Str)
LLVMContext & getContext() const
virtual void copyAttributesFrom(const GlobalValue *Src)
LLVM Argument representation.
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute on it in its containing function...
The main container class for the LLVM Intermediate Representation.
unsigned getNumParams() const
PrefixDataMapTy PrefixDataMap
const T & front() const
front - Get the first element.
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Nested function static chain.
const char * getGC() const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
bool hasAvailableExternallyLinkage() const
Type * getReturnType() const
static bool isValidReturnType(Type *RetTy)
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
static Type * getMetadataTy(LLVMContext &C)
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
static Type * getX86_MMXTy(LLVMContext &C)
virtual void removeFromParent()
CallingConv::ID getCallingConv() const
void addAttr(AttributeSet AS)
Add a Attribute to an argument.
static void removeGarbageObject(void *Object)
void push_back(NodeTy *val)
std::string getEVTString() const
getEVTString - This function returns value type as a string, e.g. "i32".
inst_iterator inst_begin(Function *F)
static Type * getFloatTy(LLVMContext &C)
static DenseMap< const Function *, PooledStringPtr > * GCNames
#define llvm_unreachable(msg)
void setName(const Twine &Name)
void copyAttributesFrom(const GlobalValue *Src)
ScopedReader - RAII acquisition of a reader lock.
Function does not access memory.
Hidden pointer to structure to return.
Function creates no aliases of pointer.
void removeAttr(AttributeSet AS)
Remove a Attribute from an argument.
ScopedWriter - RAII acquisition of a writer lock.
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
bool hasStructRetAttr() const
Return true if this argument has the sret attribute on it in its containing function.
ArrayRef< T > slice(unsigned N) const
slice(n) - Chop off the first N elements of the array.
static StringPool * GCNamePool
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
static std::string utostr(uint64_t X, bool isNeg=false)
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
ValueName * getValueName() const
bool hasNestAttr() const
Return true if this argument has the nest attribute on it in its containing function.
void removeAttributes(unsigned i, AttributeSet attr)
removes the attributes from the list of attributes.
Type * getElementType() const
size_t size() const
size - Get the array size.
Considered to not alias after call.
bool hasAddressTaken(const User **=0) const
void setCallingConv(CallingConv::ID CC)
unsigned getNumSlots() const
Return the number of slots used in this attribute list. This is the number of arguments that have an ...
Type * getParamType(unsigned i) const
Parameter type accessors.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
const Function * getParent() const
unsigned getIntrinsicID() const LLVM_READONLY
LLVM Constant Representation.
unsigned getParamAlignment() const
If this is a byval argument, return its alignment.
Return value is always equal to this argument.
static Type * getVoidTy(LLVMContext &C)
static IITDescriptor get(IITDescriptorKind K, unsigned Field)
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
bool empty() const
empty - Check if the array is empty.
IntrinsicIDCacheTy IntrinsicIDCache
iterator erase(iterator where)
LLVMContextImpl *const pImpl
bool hasByValAttr() const
Return true if this argument has the byval attribute on it in its containing function.
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
Get or create an IntegerType instance.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
bool erase(const KeyT &Val)
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
const char * getKeyData() const
static VectorType * getExtendedElementVectorType(VectorType *VTy)
void setOperand(unsigned i, Value *Val)
AttributeSet getAttributes() const
Return the attribute list for this Function.
AttributeSet removeAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Remove the specified attributes at the specified index from this attribute list. Since attribute list...
void addAttribute(unsigned i, Attribute::AttrKind attr)
adds the attribute to the list of attributes.
static void addGarbageObject(void *Object)
Function only reads from memory.
void setGC(const char *Str)
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
bool hasLinkOnceLinkage() const
PointerType * getType() const
getType - Global values are always pointers.
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index. Since attribute sets are immutable...
unsigned short getSubclassDataFromValue() const
std::string getName(ID id, ArrayRef< Type * > Tys=None)
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
ImmutableCallSite - establish a view to a call site for examination.
FunctionType * getFunctionType() const
bool callsFunctionThatReturnsTwice() const
unsigned getKeyLength() const
bool hasPrefixData() const
virtual void eraseFromParent()
Constant * getPrefixData() const
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
AttributeSet getAttributes(LLVMContext &C, ID id)
static ReturnInst * Create(LLVMContext &C, Value *retVal=0, Instruction *InsertBefore=0)
static ManagedStatic< sys::SmartRWMutex< true > > GCLock
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
bool hasLocalLinkage() const
Type * getReturnType() const
unsigned getParamAlignment(unsigned i) const
Extract the alignment for a call or parameter (0=unknown).
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
LLVM Value Representation.
const ArgumentListType & getArgumentList() const
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
static VectorType * get(Type *ElementType, unsigned NumElements)
inst_iterator inst_end(Function *F)
Argument(Type *Ty, const Twine &Name="", Function *F=0)
Constructor.
void addAttributes(unsigned i, AttributeSet attrs)
adds the attributes to the list of attributes.
iterator find(const KeyT &Val)
AttributeSet addAttributes(LLVMContext &C, unsigned Index, AttributeSet Attrs) const
Add attributes to the attribute set at the given index. Since attribute sets are immutable, this returns a new set.
NodeTy * remove(iterator &IT)
bool hasReturnedAttr() const
Return true if this argument has the returned attribute on it in its containing function.
friend class ValueSymbolTable
bool canReturnTwice() const
Return true if the call can return twice.
LLVMContext & getContext() const
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
void setPrefixData(Constant *PrefixData)