From 92a97a9166e359e195d949e63d7e24a4a33284cf Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 6 Sep 2009 00:11:24 +0000 Subject: Revert "Include optional subclass flags, such as inbounds, nsw, etc., ...", this breaks MiniSAT on x86_64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81098 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Constants.h | 9 ++----- include/llvm/InstrTypes.h | 27 +++++-------------- include/llvm/Instructions.h | 12 +++------ include/llvm/Operator.h | 66 +++++++++++---------------------------------- include/llvm/Value.h | 13 +++++---- 5 files changed, 34 insertions(+), 93 deletions(-) (limited to 'include/llvm') diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index e79ca54..da6fe96 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -571,17 +571,13 @@ protected: // These private methods are used by the type resolution code to create // ConstantExprs in intermediate forms. static Constant *getTy(const Type *Ty, unsigned Opcode, - Constant *C1, Constant *C2, - unsigned Flags = 0); + Constant *C1, Constant *C2); static Constant *getCompareTy(unsigned short pred, Constant *C1, Constant *C2); static Constant *getSelectTy(const Type *Ty, Constant *C1, Constant *C2, Constant *C3); static Constant *getGetElementPtrTy(const Type *Ty, Constant *C, Value* const *Idxs, unsigned NumIdxs); - static Constant *getInBoundsGetElementPtrTy(const Type *Ty, Constant *C, - Value* const *Idxs, - unsigned NumIdxs); static Constant *getExtractElementTy(const Type *Ty, Constant *Val, Constant *Idx); static Constant *getInsertElementTy(const Type *Ty, Constant *Val, @@ -722,8 +718,7 @@ public: /// get - Return a binary or shift operator constant expression, /// folding if possible. /// - static Constant *get(unsigned Opcode, Constant *C1, Constant *C2, - unsigned Flags = 0); + static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); /// @brief Return an ICmp or FCmp comparison operator constant expression. static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2); diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 032a1e7..35d7534 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -200,19 +200,19 @@ public: static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, const Twine &Name = "") { BinaryOperator *BO = CreateAdd(V1, V2, Name); - BO->setHasNoSignedWrap(true); + cast(BO)->setHasNoSignedWrap(true); return BO; } static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { BinaryOperator *BO = CreateAdd(V1, V2, Name, BB); - BO->setHasNoSignedWrap(true); + cast(BO)->setHasNoSignedWrap(true); return BO; } static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, const Twine &Name, Instruction *I) { BinaryOperator *BO = CreateAdd(V1, V2, Name, I); - BO->setHasNoSignedWrap(true); + cast(BO)->setHasNoSignedWrap(true); return BO; } @@ -221,19 +221,19 @@ public: static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2, const Twine &Name = "") { BinaryOperator *BO = CreateSDiv(V1, V2, Name); - BO->setIsExact(true); + cast(BO)->setIsExact(true); return BO; } static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { BinaryOperator *BO = CreateSDiv(V1, V2, Name, BB); - BO->setIsExact(true); + cast(BO)->setIsExact(true); return BO; } static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2, const Twine &Name, Instruction *I) { BinaryOperator *BO = CreateSDiv(V1, V2, Name, I); - BO->setIsExact(true); + cast(BO)->setIsExact(true); return BO; } @@ -287,21 +287,6 @@ public: /// bool swapOperands(); - /// setHasNoUnsignedWrap - Set or clear the nsw flag on this instruction, - /// which must be an operator which supports this flag. See LangRef.html - /// for the meaning of this flag. - void setHasNoUnsignedWrap(bool); - - /// setHasNoSignedWrap - Set or clear the nsw flag on this instruction, - /// which must be an operator which supports this flag. See LangRef.html - /// for the meaning of this flag. - void setHasNoSignedWrap(bool); - - /// setIsExact - Set or clear the exact flag on this instruction, - /// which must be an operator which supports this flag. See LangRef.html - /// for the meaning of this flag. - void setIsExact(bool); - // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const BinaryOperator *) { return true; } static inline bool classof(const Instruction *I) { diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 57cff17..71f4738 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -496,7 +496,7 @@ public: Instruction *InsertBefore = 0) { GetElementPtrInst *GEP = Create(Ptr, IdxBegin, IdxEnd, NameStr, InsertBefore); - GEP->setIsInBounds(true); + cast(GEP)->setIsInBounds(true); return GEP; } template @@ -507,21 +507,21 @@ public: BasicBlock *InsertAtEnd) { GetElementPtrInst *GEP = Create(Ptr, IdxBegin, IdxEnd, NameStr, InsertAtEnd); - GEP->setIsInBounds(true); + cast(GEP)->setIsInBounds(true); return GEP; } static GetElementPtrInst *CreateInBounds(Value *Ptr, Value *Idx, const Twine &NameStr = "", Instruction *InsertBefore = 0) { GetElementPtrInst *GEP = Create(Ptr, Idx, NameStr, InsertBefore); - GEP->setIsInBounds(true); + cast(GEP)->setIsInBounds(true); return GEP; } static GetElementPtrInst *CreateInBounds(Value *Ptr, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd) { GetElementPtrInst *GEP = Create(Ptr, Idx, NameStr, InsertAtEnd); - GEP->setIsInBounds(true); + cast(GEP)->setIsInBounds(true); return GEP; } @@ -602,10 +602,6 @@ public: /// a constant offset between them. bool hasAllConstantIndices() const; - /// setIsInBounds - Set or clear the inbounds flag on this GEP instruction. - /// See LangRef.html for the meaning of inbounds on a getelementptr. - void setIsInBounds(bool); - // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GetElementPtrInst *) { return true; } static inline bool classof(const Instruction *I) { diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h index 06eb243..48ac09d 100644 --- a/include/llvm/Operator.h +++ b/include/llvm/Operator.h @@ -21,8 +21,6 @@ namespace llvm { class GetElementPtrInst; -class BinaryOperator; -class ConstantExpr; /// Operator - This is a utility class that provides an abstraction for the /// common functionality between Instructions and ConstantExprs. @@ -69,37 +67,24 @@ public: /// despite that operator having the potential for overflow. /// class OverflowingBinaryOperator : public Operator { -public: - enum { - NoUnsignedWrap = (1 << 0), - NoSignedWrap = (1 << 1) - }; - -private: ~OverflowingBinaryOperator(); // do not implement - - friend class BinaryOperator; - friend class ConstantExpr; - void setHasNoUnsignedWrap(bool B) { - SubclassOptionalData = - (SubclassOptionalData & ~NoUnsignedWrap) | (B * NoUnsignedWrap); - } - void setHasNoSignedWrap(bool B) { - SubclassOptionalData = - (SubclassOptionalData & ~NoSignedWrap) | (B * NoSignedWrap); - } - public: /// hasNoUnsignedWrap - Test whether this operation is known to never /// undergo unsigned overflow, aka the nuw property. bool hasNoUnsignedWrap() const { - return SubclassOptionalData & NoUnsignedWrap; + return SubclassOptionalData & (1 << 0); + } + void setHasNoUnsignedWrap(bool B) { + SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0); } /// hasNoSignedWrap - Test whether this operation is known to never /// undergo signed overflow, aka the nsw property. bool hasNoSignedWrap() const { - return SubclassOptionalData & NoSignedWrap; + return SubclassOptionalData & (1 << 1); + } + void setHasNoSignedWrap(bool B) { + SubclassOptionalData = (SubclassOptionalData & ~(1 << 1)) | (B << 1); } static inline bool classof(const OverflowingBinaryOperator *) { return true; } @@ -176,25 +161,15 @@ public: /// SDivOperator - An Operator with opcode Instruction::SDiv. /// class SDivOperator : public Operator { -public: - enum { - IsExact = (1 << 0) - }; - -private: ~SDivOperator(); // do not implement - - friend class BinaryOperator; - friend class ConstantExpr; - void setIsExact(bool B) { - SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact); - } - public: /// isExact - Test whether this division is known to be exact, with /// zero remainder. bool isExact() const { - return SubclassOptionalData & IsExact; + return SubclassOptionalData & (1 << 0); + } + void setIsExact(bool B) { + SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0); } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -212,24 +187,15 @@ public: }; class GEPOperator : public Operator { - enum { - IsInBounds = (1 << 0) - }; - ~GEPOperator(); // do not implement - - friend class GetElementPtrInst; - friend class ConstantExpr; - void setIsInBounds(bool B) { - SubclassOptionalData = - (SubclassOptionalData & ~IsInBounds) | (B * IsInBounds); - } - public: /// isInBounds - Test whether this is an inbounds GEP, as defined /// by LangRef.html. bool isInBounds() const { - return SubclassOptionalData & IsInBounds; + return SubclassOptionalData & (1 << 0); + } + void setIsInBounds(bool B) { + SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0); } inline op_iterator idx_begin() { return op_begin()+1; } diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 415b8fb..fdc3aeb 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -146,6 +146,12 @@ public: // Only use when in type resolution situations! void uncheckedReplaceAllUsesWith(Value *V); + /// clearOptionalData - Clear any optional optimization data from this Value. + /// Transformation passes must call this method whenever changing the IR + /// in a way that would affect the values produced by this Value, unless + /// it takes special care to ensure correctness in some other way. + void clearOptionalData() { SubclassOptionalData = 0; } + //---------------------------------------------------------------------- // Methods for handling the chain of uses of this Value. // @@ -234,13 +240,6 @@ public: return SubclassID; } - /// getRawSubclassOptionalData - Return the raw optional flags value - /// contained in this value. This should only be used when testing two - /// Values for equivalence. - unsigned getRawSubclassOptionalData() const { - return SubclassOptionalData; - } - /// hasSameSubclassOptionalData - Test whether the optional flags contained /// in this value are equal to the optional flags in the given value. bool hasSameSubclassOptionalData(const Value *V) const { -- cgit v1.1