X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FInstructions.h;h=6837608b2c08fd69463eccb735d2e5535c6605e0;hb=a395f4df5b6d9c2feb661091ca75be2500d07cb0;hp=a79e272946c7d1126ce345c501d6551122e98c35;hpb=47cbc4e0ee6098b7be3c60108000a979f1809949;p=oota-llvm.git diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index a79e272946c..6837608b2c0 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -255,7 +255,7 @@ private: /// StoreInst - an instruction for storing to memory /// class StoreInst : public Instruction { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; void AssertOK(); protected: virtual StoreInst *clone_impl() const; @@ -382,7 +382,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(StoreInst, Value) /// FenceInst - an instruction for ordering other memory operations /// class FenceInst : public Instruction { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; void Init(AtomicOrdering Ordering, SynchronizationScope SynchScope); protected: virtual FenceInst *clone_impl() const; @@ -450,7 +450,7 @@ private: /// there. Returns the value that was loaded. /// class AtomicCmpXchgInst : public Instruction { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; void Init(Value *Ptr, Value *Cmp, Value *NewVal, AtomicOrdering Ordering, SynchronizationScope SynchScope); protected: @@ -557,7 +557,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(AtomicCmpXchgInst, Value) /// the old value. /// class AtomicRMWInst : public Instruction { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; protected: virtual AtomicRMWInst *clone_impl() const; public: @@ -778,7 +778,7 @@ public: static Type *getIndexedType(Type *Ptr, ArrayRef IdxList); static Type *getIndexedType(Type *Ptr, ArrayRef IdxList); - /// getIndexedType - Returns the address space used by the GEP pointer. + /// getAddressSpace - Returns the address space used by the GEP pointer. /// static unsigned getAddressSpace(Value *Ptr); @@ -798,7 +798,7 @@ public: } unsigned getPointerAddressSpace() const { - return cast(getType())->getAddressSpace(); + return cast(getPointerOperandType())->getAddressSpace(); } /// getPointerOperandType - Method to return the pointer operand as a @@ -1267,8 +1267,11 @@ public: /// removeAttribute - removes the attribute from the list of attributes. void removeAttribute(unsigned i, Attributes attr); - /// @brief Determine whether the call or the callee has the given attribute. - bool paramHasAttr(unsigned i, Attributes attr) const; + /// @brief Determine whether this call has the given attribute. + bool hasFnAttr(Attributes::AttrVal A) const; + + /// @brief Determine whether the call or the callee has the given attributes. + bool paramHasAttr(unsigned i, Attributes::AttrVal A) const; /// @brief Extract the alignment for a call or parameter (0=unknown). unsigned getParamAlignment(unsigned i) const { @@ -1276,63 +1279,72 @@ public: } /// @brief Return true if the call should not be inlined. - bool isNoInline() const { return paramHasAttr(~0, Attribute::NoInline); } - void setIsNoInline(bool Value = true) { - if (Value) addAttribute(~0, Attribute::NoInline); - else removeAttribute(~0, Attribute::NoInline); + bool isNoInline() const { return hasFnAttr(Attributes::NoInline); } + void setIsNoInline() { + Attributes::Builder B; + B.addAttribute(Attributes::NoInline); + addAttribute(~0, Attributes::get(B)); } /// @brief Return true if the call can return twice bool canReturnTwice() const { - return paramHasAttr(~0, Attribute::ReturnsTwice); + return hasFnAttr(Attributes::ReturnsTwice); } - void setCanReturnTwice(bool Value = true) { - if (Value) addAttribute(~0, Attribute::ReturnsTwice); - else removeAttribute(~0, Attribute::ReturnsTwice); + void setCanReturnTwice() { + Attributes::Builder B; + B.addAttribute(Attributes::ReturnsTwice); + addAttribute(~0U, Attributes::get(B)); } /// @brief Determine if the call does not access memory. bool doesNotAccessMemory() const { - return paramHasAttr(~0, Attribute::ReadNone); + return hasFnAttr(Attributes::ReadNone); } - void setDoesNotAccessMemory(bool NotAccessMemory = true) { - if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone); - else removeAttribute(~0, Attribute::ReadNone); + void setDoesNotAccessMemory() { + Attributes::Builder B; + B.addAttribute(Attributes::ReadNone); + addAttribute(~0U, Attributes::get(B)); } /// @brief Determine if the call does not access or only reads memory. bool onlyReadsMemory() const { - return doesNotAccessMemory() || paramHasAttr(~0, Attribute::ReadOnly); + return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly); } - void setOnlyReadsMemory(bool OnlyReadsMemory = true) { - if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly); - else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone); + void setOnlyReadsMemory() { + Attributes::Builder B; + B.addAttribute(Attributes::ReadOnly); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call cannot return. - bool doesNotReturn() const { return paramHasAttr(~0, Attribute::NoReturn); } - void setDoesNotReturn(bool DoesNotReturn = true) { - if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn); - else removeAttribute(~0, Attribute::NoReturn); + bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); } + void setDoesNotReturn() { + Attributes::Builder B; + B.addAttribute(Attributes::NoReturn); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call cannot unwind. - bool doesNotThrow() const { return paramHasAttr(~0, Attribute::NoUnwind); } - void setDoesNotThrow(bool DoesNotThrow = true) { - if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind); - else removeAttribute(~0, Attribute::NoUnwind); + bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); } + void setDoesNotThrow() { + Attributes::Builder B; + B.addAttribute(Attributes::NoUnwind); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call returns a structure through first /// pointer argument. bool hasStructRetAttr() const { // Be friendly and also check the callee. - return paramHasAttr(1, Attribute::StructRet); + return paramHasAttr(1, Attributes::StructRet); } /// @brief Determine if any call argument is an aggregate passed by value. bool hasByValArgument() const { - return AttributeList.hasAttrSomewhere(Attribute::ByVal); + for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I) + if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attributes::ByVal)) + return true; + return false; } /// getCalledFunction - Return the function called, or null if this is an @@ -1834,7 +1846,7 @@ ExtractValueInst::ExtractValueInst(Value *Agg, class InsertValueInst : public Instruction { SmallVector Indices; - void *operator new(size_t, unsigned); // Do not implement + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; InsertValueInst(const InsertValueInst &IVI); void init(Value *Agg, Value *Val, ArrayRef Idxs, const Twine &NameStr); @@ -1965,7 +1977,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueInst, Value) // scientist's overactive imagination. // class PHINode : public Instruction { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; /// ReservedSpace - The number of operands actually allocated. NumOperands is /// the number actually in use. unsigned ReservedSpace; @@ -2173,7 +2185,7 @@ class LandingPadInst : public Instruction { public: enum ClauseType { Catch, Filter }; private: - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; // Allocate space for exactly zero operands. void *operator new(size_t s) { return User::operator new(s, 0); @@ -2440,7 +2452,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value) /// SwitchInst - Multiway switch /// class SwitchInst : public TerminatorInst { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; unsigned ReservedSpace; // Operands format: // Operand[0] = Value to switch on @@ -2608,7 +2620,7 @@ public: } /// addCase - Add an entry to the switch instruction... - /// @Deprecated + /// @deprecated /// Note: /// This action invalidates case_end(). Old case_end() iterator will /// point to the added case. @@ -2694,7 +2706,7 @@ public: } /// Resolves case value for current case. - /// @Deprecated + /// @deprecated ConstantIntTy *getCaseValue() { assert(Index < SI->getNumCases() && "Index out the number of cases."); IntegersSubsetRef CaseRanges = *SubsetIt; @@ -2798,7 +2810,7 @@ public: CaseIt(const ParentTy& Src) : ParentTy(Src) {} /// Sets the new value for current case. - /// @Deprecated. + /// @deprecated. void setValue(ConstantInt *V) { assert(Index < SI->getNumCases() && "Index out the number of cases."); IntegersSubsetToBB Mapping; @@ -2852,7 +2864,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SwitchInst, Value) /// IndirectBrInst - Indirect Branch Instruction. /// class IndirectBrInst : public TerminatorInst { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; unsigned ReservedSpace; // Operand[0] = Value to switch on // Operand[1] = Default basic block destination @@ -3024,8 +3036,11 @@ public: /// removeAttribute - removes the attribute from the list of attributes. void removeAttribute(unsigned i, Attributes attr); - /// @brief Determine whether the call or the callee has the given attribute. - bool paramHasAttr(unsigned i, Attributes attr) const; + /// @brief Determine whether this call has the NoAlias attribute. + bool hasFnAttr(Attributes::AttrVal A) const; + + /// @brief Determine whether the call or the callee has the given attributes. + bool paramHasAttr(unsigned i, Attributes::AttrVal A) const; /// @brief Extract the alignment for a call or parameter (0=unknown). unsigned getParamAlignment(unsigned i) const { @@ -3033,54 +3048,62 @@ public: } /// @brief Return true if the call should not be inlined. - bool isNoInline() const { return paramHasAttr(~0, Attribute::NoInline); } - void setIsNoInline(bool Value = true) { - if (Value) addAttribute(~0, Attribute::NoInline); - else removeAttribute(~0, Attribute::NoInline); + bool isNoInline() const { return hasFnAttr(Attributes::NoInline); } + void setIsNoInline() { + Attributes::Builder B; + B.addAttribute(Attributes::NoInline); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call does not access memory. bool doesNotAccessMemory() const { - return paramHasAttr(~0, Attribute::ReadNone); + return hasFnAttr(Attributes::ReadNone); } - void setDoesNotAccessMemory(bool NotAccessMemory = true) { - if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone); - else removeAttribute(~0, Attribute::ReadNone); + void setDoesNotAccessMemory() { + Attributes::Builder B; + B.addAttribute(Attributes::ReadNone); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call does not access or only reads memory. bool onlyReadsMemory() const { - return doesNotAccessMemory() || paramHasAttr(~0, Attribute::ReadOnly); + return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly); } - void setOnlyReadsMemory(bool OnlyReadsMemory = true) { - if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly); - else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone); + void setOnlyReadsMemory() { + Attributes::Builder B; + B.addAttribute(Attributes::ReadOnly); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call cannot return. - bool doesNotReturn() const { return paramHasAttr(~0, Attribute::NoReturn); } - void setDoesNotReturn(bool DoesNotReturn = true) { - if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn); - else removeAttribute(~0, Attribute::NoReturn); + bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); } + void setDoesNotReturn() { + Attributes::Builder B; + B.addAttribute(Attributes::NoReturn); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call cannot unwind. - bool doesNotThrow() const { return paramHasAttr(~0, Attribute::NoUnwind); } - void setDoesNotThrow(bool DoesNotThrow = true) { - if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind); - else removeAttribute(~0, Attribute::NoUnwind); + bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); } + void setDoesNotThrow() { + Attributes::Builder B; + B.addAttribute(Attributes::NoUnwind); + addAttribute(~0, Attributes::get(B)); } /// @brief Determine if the call returns a structure through first /// pointer argument. bool hasStructRetAttr() const { // Be friendly and also check the callee. - return paramHasAttr(1, Attribute::StructRet); + return paramHasAttr(1, Attributes::StructRet); } /// @brief Determine if any call argument is an aggregate passed by value. bool hasByValArgument() const { - return AttributeList.hasAttrSomewhere(Attribute::ByVal); + for (unsigned I = 0, E = AttributeList.getNumAttrs(); I != E; ++I) + if (AttributeList.getAttributesAtIndex(I).hasAttribute(Attributes::ByVal)) + return true; + return false; } /// getCalledFunction - Return the function called, or null if this is an @@ -3241,7 +3264,7 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ResumeInst, Value) /// end of the block cannot be reached. /// class UnreachableInst : public TerminatorInst { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; protected: virtual UnreachableInst *clone_impl() const; @@ -3628,6 +3651,11 @@ public: /// @brief Clone an identical IntToPtrInst virtual IntToPtrInst *clone_impl() const; + /// @brief return the address space of the pointer. + unsigned getAddressSpace() const { + return cast(getType())->getAddressSpace(); + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const IntToPtrInst *) { return true; } static inline bool classof(const Instruction *I) { @@ -3665,6 +3693,11 @@ public: BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); + /// @brief return the address space of the pointer. + unsigned getPointerAddressSpace() const { + return cast(getOperand(0)->getType())->getAddressSpace(); + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const PtrToIntInst *) { return true; } static inline bool classof(const Instruction *I) {