X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FInstructions.h;h=146d1f50a645d0aede3f2ff7e934766f01a0e15a;hb=7adb53e7b1a4ec0cda17cbc946da44147c141d69;hp=337ae2a463b78b07fb58c52a302935b114db8699;hpb=3da43849f2a2319ded6ed379ec8e7d620d6ac8c6;p=oota-llvm.git diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 337ae2a463b..146d1f50a64 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -26,6 +26,7 @@ class PointerType; class VectorType; class ConstantRange; class APInt; +class ParamAttrsList; //===----------------------------------------------------------------------===// // AllocationInst Class @@ -210,9 +211,11 @@ public: /// SubclassData field in Value to store whether or not the load is volatile. /// class LoadInst : public UnaryInstruction { + LoadInst(const LoadInst &LI) : UnaryInstruction(LI.getType(), Load, LI.getOperand(0)) { setVolatile(LI.isVolatile()); + setAlignment(LI.getAlignment()); #ifndef NDEBUG AssertOK(); @@ -222,14 +225,16 @@ class LoadInst : public UnaryInstruction { public: LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore); LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd); - LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false, + LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false, + Instruction *InsertBefore = 0); + LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, unsigned Align, Instruction *InsertBefore = 0); LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, BasicBlock *InsertAtEnd); LoadInst(Value *Ptr, const char *Name, Instruction *InsertBefore); LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAtEnd); - explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false, + explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false, Instruction *InsertBefore = 0); LoadInst(Value *Ptr, const char *Name, bool isVolatile, BasicBlock *InsertAtEnd); @@ -237,14 +242,24 @@ public: /// isVolatile - Return true if this is a load from a volatile memory /// location. /// - bool isVolatile() const { return SubclassData; } + bool isVolatile() const { return SubclassData & 1; } /// setVolatile - Specify whether this is a volatile load or not. /// - void setVolatile(bool V) { SubclassData = V; } + void setVolatile(bool V) { + SubclassData = (SubclassData & ~1) | ((V) ? 1 : 0); + } virtual LoadInst *clone() const; + /// getAlignment - Return the alignment of the access that is being performed + /// + unsigned getAlignment() const { + return (1 << (SubclassData>>1)) >> 1; + } + + void setAlignment(unsigned Align); + Value *getPointerOperand() { return getOperand(0); } const Value *getPointerOperand() const { return getOperand(0); } static unsigned getPointerOperandIndex() { return 0U; } @@ -268,10 +283,13 @@ public: /// class StoreInst : public Instruction { Use Ops[2]; + StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) { Ops[0].init(SI.Ops[0], this); Ops[1].init(SI.Ops[1], this); setVolatile(SI.isVolatile()); + setAlignment(SI.getAlignment()); + #ifndef NDEBUG AssertOK(); #endif @@ -282,17 +300,21 @@ public: StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd); StoreInst(Value *Val, Value *Ptr, bool isVolatile = false, Instruction *InsertBefore = 0); + StoreInst(Value *Val, Value *Ptr, bool isVolatile, + unsigned Align, Instruction *InsertBefore = 0); StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd); /// isVolatile - Return true if this is a load from a volatile memory /// location. /// - bool isVolatile() const { return SubclassData; } + bool isVolatile() const { return SubclassData & 1; } /// setVolatile - Specify whether this is a volatile load or not. /// - void setVolatile(bool V) { SubclassData = V; } + void setVolatile(bool V) { + SubclassData = (SubclassData & ~1) | ((V) ? 1 : 0); + } /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { @@ -305,7 +327,14 @@ public: } unsigned getNumOperands() const { return 2; } - + /// getAlignment - Return the alignment of the access that is being performed + /// + unsigned getAlignment() const { + return (1 << (SubclassData>>1)) >> 1; + } + + void setAlignment(unsigned Align); + virtual StoreInst *clone() const; Value *getPointerOperand() { return getOperand(1); } @@ -407,6 +436,17 @@ public: inline bool hasIndices() const { return getNumOperands() > 1; } + + /// hasAllZeroIndices - Return true if all of the indices of this GEP are + /// zeros. If so, the result pointer and the first operand have the same + /// value, just potentially different types. + bool hasAllZeroIndices() const; + + /// hasAllConstantIndices - Return true if all of the indices of this GEP are + /// constant integers. If so, the result pointer and the first operand have + /// a constant offset between them. + bool hasAllConstantIndices() const; + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GetElementPtrInst *) { return true; } @@ -694,6 +734,7 @@ public: /// hold the calling convention of the call. /// class CallInst : public Instruction { + ParamAttrsList *ParamAttrs; ///< parameter attributes for call CallInst(const CallInst &CI); void init(Value *Func, Value* const *Params, unsigned NumParams); void init(Value *Func, Value *Actual1, Value *Actual2); @@ -735,6 +776,17 @@ public: SubclassData = (SubclassData & 1) | (CC << 1); } + /// Obtains a pointer to the ParamAttrsList object which holds the + /// parameter attributes information, if any. + /// @returns 0 if no attributes have been set. + /// @brief Get the parameter attributes. + ParamAttrsList *getParamAttrs() const { return ParamAttrs; } + + /// Sets the parameter attributes for this CallInst. To construct a + /// ParamAttrsList, see ParameterAttributes.h + /// @brief Set the parameter attributes. + void setParamAttrs(ParamAttrsList *attrs); + /// getCalledFunction - Return the function being called by this instruction /// if it is a direct call. If it is a call through a function pointer, /// return null. @@ -1433,6 +1485,7 @@ private: /// calling convention of the call. /// class InvokeInst : public TerminatorInst { + ParamAttrsList *ParamAttrs; InvokeInst(const InvokeInst &BI); void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, Value* const *Args, unsigned NumArgs); @@ -1454,6 +1507,17 @@ public: SubclassData = CC; } + /// Obtains a pointer to the ParamAttrsList object which holds the + /// parameter attributes information, if any. + /// @returns 0 if no attributes have been set. + /// @brief Get the parameter attributes. + ParamAttrsList *getParamAttrs() const { return ParamAttrs; } + + /// Sets the parameter attributes for this InvokeInst. To construct a + /// ParamAttrsList, see ParameterAttributes.h + /// @brief Set the parameter attributes. + void setParamAttrs(ParamAttrsList *attrs); + /// getCalledFunction - Return the function called, or null if this is an /// indirect function invocation. ///