X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=include%2Fllvm%2FInstruction.h;h=934e890151f0cc18e8f2f7882b6666f761903c78;hb=a91a3e04895f2049f7607cfe6fd1aa7b276ed3da;hp=472ab83f2e27d2c989211fae51c553670dc6a697;hpb=870cfcf9a6189b65a8ee805b93a2c737c0183e62;p=oota-llvm.git diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 472ab83f2e2..934e890151f 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -17,7 +17,7 @@ #include "llvm/User.h" #include "llvm/ADT/ilist_node.h" -#include "llvm/Support/ValueHandle.h" +#include "llvm/Support/DebugLoc.h" namespace llvm { @@ -32,7 +32,7 @@ class Instruction : public User, public ilist_node { Instruction(const Instruction &); // Do not implement BasicBlock *Parent; - TrackingVH DbgInfo; // 'dbg' Metadata cache. + DebugLoc DbgLoc; // 'dbg' Metadata cache. enum { /// HasMetadataBit - This is a bit stored in the SubClassData field which @@ -125,7 +125,13 @@ public: /// hasMetadata() - Return true if this instruction has any metadata attached /// to it. bool hasMetadata() const { - return DbgInfo != 0 || hasMetadataHashEntry(); + return !DbgLoc.isUnknown() || hasMetadataHashEntry(); + } + + /// hasMetadataOtherThanDebugLoc - Return true if this instruction has + /// metadata attached to it other than a debug location. + bool hasMetadataOtherThanDebugLoc() const { + return hasMetadataHashEntry(); } /// getMetadata - Get the metadata of given kind attached to this Instruction. @@ -150,21 +156,25 @@ public: getAllMetadataImpl(MDs); } + /// getAllMetadataOtherThanDebugLoc - This does the same thing as + /// getAllMetadata, except that it filters out the debug location. + void getAllMetadataOtherThanDebugLoc(SmallVectorImpl > &MDs) const { + if (hasMetadataOtherThanDebugLoc()) + getAllMetadataOtherThanDebugLocImpl(MDs); + } + /// setMetadata - Set the metadata of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if /// Node is null. void setMetadata(unsigned KindID, MDNode *Node); void setMetadata(const char *Kind, MDNode *Node); - /// setDbgMetadata - This is just an optimized helper function that is - /// equivalent to setMetadata("dbg", Node); - void setDbgMetadata(MDNode *Node); + /// setDebugLoc - Set the debug location information for this instruction. + void setDebugLoc(const DebugLoc &Loc) { DbgLoc = Loc; } - /// getDbgMetadata - This is just an optimized helper function that is - /// equivalent to calling getMetadata("dbg"). - MDNode *getDbgMetadata() const { - return DbgInfo; - } + /// getDebugLoc - Return the debug location for this node as a DebugLoc. + const DebugLoc &getDebugLoc() const { return DbgLoc; } private: /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side @@ -177,7 +187,9 @@ private: MDNode *getMetadataImpl(unsigned KindID) const; MDNode *getMetadataImpl(const char *Kind) const; void getAllMetadataImpl(SmallVectorImpl > &)const; - void removeAllMetadata(); + void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl > &) const; + void clearMetadataHashEntries(); public: //===--------------------------------------------------------------------===// // Predicates and helper methods. @@ -188,11 +200,10 @@ public: /// /// Associative operators satisfy: x op (y op z) === (x op y) op z /// - /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative, when - /// not applied to floating point types. + /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative. /// - bool isAssociative() const { return isAssociative(getOpcode(), getType()); } - static bool isAssociative(unsigned op, const Type *Ty); + bool isAssociative() const { return isAssociative(getOpcode()); } + static bool isAssociative(unsigned op); /// isCommutative - Return true if the instruction is commutative: /// @@ -212,6 +223,13 @@ public: /// bool mayReadFromMemory() const; + /// mayReadOrWriteMemory - Return true if this instruction may read or + /// write memory. + /// + bool mayReadOrWriteMemory() const { + return mayReadFromMemory() || mayWriteToMemory(); + } + /// mayThrow - Return true if this instruction may throw an exception. /// bool mayThrow() const; @@ -354,9 +372,9 @@ protected: return getSubclassDataFromValue() & ~HasMetadataBit; } - Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, + Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, Instruction *InsertBefore = 0); - Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, + Instruction(Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd); virtual Instruction *clone_impl() const = 0;