diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Instructions.h | 10 | ||||
-rw-r--r-- | include/llvm/IntrinsicInst.h | 62 | ||||
-rw-r--r-- | include/llvm/Support/CallSite.h | 16 |
3 files changed, 47 insertions, 41 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index d6dd94d9e9..413a595ab3 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1031,17 +1031,17 @@ public: /// indirect function invocation. /// Function *getCalledFunction() const { - return dyn_cast<Function>(Op<-1>()); + return dyn_cast<Function>(Op<0>()); } /// getCalledValue - Get a pointer to the function that is invoked by this /// instruction. - const Value *getCalledValue() const { return Op<-1>(); } - Value *getCalledValue() { return Op<-1>(); } + const Value *getCalledValue() const { return Op<0>(); } + Value *getCalledValue() { return Op<0>(); } /// setCalledFunction - Set the function called. void setCalledFunction(Value* Fn) { - Op<-1>() = Fn; + Op<0>() = Fn; } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -1071,7 +1071,7 @@ CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, ->getElementType())->getReturnType(), Instruction::Call, OperandTraits<CallInst>::op_end(this) - (ArgEnd - ArgBegin + 1), - unsigned(ArgEnd - ArgBegin + 1), InsertAtEnd) { + (unsigned)(ArgEnd - ArgBegin + 1), InsertAtEnd) { init(Func, ArgBegin, ArgEnd, NameStr, typename std::iterator_traits<InputIterator>::iterator_category()); } diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h index 1e8bf8b5c9..5b0e90f5cc 100644 --- a/include/llvm/IntrinsicInst.h +++ b/include/llvm/IntrinsicInst.h @@ -43,7 +43,7 @@ namespace llvm { Intrinsic::ID getIntrinsicID() const { return (Intrinsic::ID)getCalledFunction()->getIntrinsicID(); } - + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const IntrinsicInst *) { return true; } static inline bool classof(const CallInst *I) { @@ -74,7 +74,7 @@ namespace llvm { static inline bool classof(const Value *V) { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } - + static Value *StripCast(Value *C); }; @@ -83,7 +83,7 @@ namespace llvm { class DbgDeclareInst : public DbgInfoIntrinsic { public: Value *getAddress() const; - MDNode *getVariable() const { return cast<MDNode>(getOperand(1)); } + MDNode *getVariable() const { return cast<MDNode>(getOperand(2)); } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const DbgDeclareInst *) { return true; } @@ -103,9 +103,9 @@ namespace llvm { Value *getValue(); uint64_t getOffset() const { return cast<ConstantInt>( - const_cast<Value*>(getOperand(1)))->getZExtValue(); + const_cast<Value*>(getOperand(2)))->getZExtValue(); } - MDNode *getVariable() const { return cast<MDNode>(getOperand(2)); } + MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const DbgValueInst *) { return true; } @@ -121,19 +121,19 @@ namespace llvm { /// class MemIntrinsic : public IntrinsicInst { public: - Value *getRawDest() const { return const_cast<Value*>(getOperand(0)); } + Value *getRawDest() const { return const_cast<Value*>(getOperand(1)); } - Value *getLength() const { return const_cast<Value*>(getOperand(2)); } + Value *getLength() const { return const_cast<Value*>(getOperand(3)); } ConstantInt *getAlignmentCst() const { - return cast<ConstantInt>(const_cast<Value*>(getOperand(3))); + return cast<ConstantInt>(const_cast<Value*>(getOperand(4))); } - + unsigned getAlignment() const { return getAlignmentCst()->getZExtValue(); } ConstantInt *getVolatileCst() const { - return cast<ConstantInt>(const_cast<Value*>(getOperand(4))); + return cast<ConstantInt>(const_cast<Value*>(getOperand(5))); } bool isVolatile() const { return getVolatileCst()->getZExtValue() != 0; @@ -149,27 +149,27 @@ namespace llvm { void setDest(Value *Ptr) { assert(getRawDest()->getType() == Ptr->getType() && "setDest called with pointer of wrong type!"); - setOperand(0, Ptr); + setOperand(1, Ptr); } void setLength(Value *L) { assert(getLength()->getType() == L->getType() && "setLength called with value of wrong type!"); - setOperand(2, L); + setOperand(3, L); } - + void setAlignment(Constant* A) { - setOperand(3, A); + setOperand(4, A); } void setVolatile(Constant* V) { - setOperand(4, V); + setOperand(5, V); } const Type *getAlignmentType() const { - return getOperand(3)->getType(); + return getOperand(4)->getType(); } - + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MemIntrinsic *) { return true; } static inline bool classof(const IntrinsicInst *I) { @@ -192,14 +192,14 @@ namespace llvm { public: /// get* - Return the arguments to the instruction. /// - Value *getValue() const { return const_cast<Value*>(getOperand(1)); } - + Value *getValue() const { return const_cast<Value*>(getOperand(2)); } + void setValue(Value *Val) { assert(getValue()->getType() == Val->getType() && - "setValue called with value of wrong type!"); - setOperand(1, Val); + "setSource called with pointer of wrong type!"); + setOperand(2, Val); } - + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MemSetInst *) { return true; } static inline bool classof(const IntrinsicInst *I) { @@ -209,26 +209,26 @@ namespace llvm { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } }; - + /// MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics. /// class MemTransferInst : public MemIntrinsic { public: /// get* - Return the arguments to the instruction. /// - Value *getRawSource() const { return const_cast<Value*>(getOperand(1)); } - + Value *getRawSource() const { return const_cast<Value*>(getOperand(2)); } + /// getSource - This is just like getRawSource, but it strips off any cast /// instructions that feed it, giving the original input. The returned /// value is guaranteed to be a pointer. Value *getSource() const { return getRawSource()->stripPointerCasts(); } - + void setSource(Value *Ptr) { assert(getRawSource()->getType() == Ptr->getType() && "setSource called with pointer of wrong type!"); - setOperand(1, Ptr); + setOperand(2, Ptr); } - + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MemTransferInst *) { return true; } static inline bool classof(const IntrinsicInst *I) { @@ -239,8 +239,8 @@ namespace llvm { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } }; - - + + /// MemCpyInst - This class wraps the llvm.memcpy intrinsic. /// class MemCpyInst : public MemTransferInst { @@ -282,7 +282,7 @@ namespace llvm { return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); } }; - + /// MemoryUseIntrinsic - This is the common base class for the memory use /// marker intrinsics. /// diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index 7667ba03e3..0650b61fbc 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -255,21 +255,27 @@ public: private: /// Returns the operand number of the first argument unsigned getArgumentOffset() const { + if (isCall()) + return 1; // Skip Function (ATM) + else return 0; // Args are at the front } unsigned getArgumentEndOffset() const { if (isCall()) - return 1; // Skip Function + return 0; // Unchanged (ATM) else return 3; // Skip BB, BB, Function } IterTy getCallee() const { - // FIXME: this is slow, since we do not have the fast versions - // of the op_*() functions here. See CallSite::getCallee. - // - return arg_end(); + // FIXME: this is slow, since we do not have the fast versions + // of the op_*() functions here. See CallSite::getCallee. + // + if (isCall()) + return getInstruction()->op_begin(); // Unchanged (ATM) + else + return getInstruction()->op_end() - 3; // Skip BB, BB, Function } }; |