diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index e1b53f02355..6fdf3604ea3 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -44,10 +44,10 @@ public: virtual const char *getOpcodeName() const { return "ret"; } inline const Value *getReturnValue() const { - return Operands.size() ? Operands[0] : 0; + return Operands.size() ? Operands[0].get() : 0; } inline Value *getReturnValue() { - return Operands.size() ? Operands[0] : 0; + return Operands.size() ? Operands[0].get() : 0; } // Additionally, they must provide a method to get at the successors of this @@ -84,10 +84,10 @@ public: } inline const Value *getCondition() const { - return isUnconditional() ? 0 : Operands[2]; + return isUnconditional() ? 0 : Operands[2].get(); } inline Value *getCondition() { - return isUnconditional() ? 0 : Operands[2]; + return isUnconditional() ? 0 : Operands[2].get(); } virtual const char *getOpcodeName() const { return "br"; } @@ -190,4 +190,70 @@ public: } }; + +//===--------------------------------------------------------------------------- +// InvokeInst - Invoke instruction +// +class InvokeInst : public TerminatorInst { + InvokeInst(const InvokeInst &BI); +public: + InvokeInst(Value *Meth, BasicBlock *IfNormal, BasicBlock *IfException, + const vector &Params, const string &Name = ""); + + virtual Instruction *clone() const { return new InvokeInst(*this); } + + // getCalledMethod - Return the method called, or null if this is an indirect + // method invocation... + // + inline const Method *getCalledMethod() const { + return dyn_cast(Operands[0].get()); + } + inline Method *getCalledMethod() { + return dyn_cast(Operands[0].get()); + } + + // getCalledValue - Get a pointer to a method that is invoked by this inst. + inline const Value *getCalledValue() const { return Operands[0]; } + inline Value *getCalledValue() { return Operands[0]; } + + // get*Dest - Return the destination basic blocks... + inline const BasicBlock *getNormalDest() const { + return cast(Operands[1]); + } + inline BasicBlock *getNormalDest() { + return cast(Operands[1]); + } + inline const BasicBlock *getExceptionalDest() const { + return cast(Operands[2]); + } + inline BasicBlock *getExceptionalDest() { + return cast(Operands[2]); + } + + virtual const char *getOpcodeName() const { return "invoke"; } + + // Additionally, they must provide a method to get at the successors of this + // terminator instruction. + // + virtual const BasicBlock *getSuccessor(unsigned i) const { + return (i == 0) ? getNormalDest() : + ((i == 1) ? getExceptionalDest() : 0); + } + inline BasicBlock *getSuccessor(unsigned i) { + return (i == 0) ? getNormalDest() : + ((i == 1) ? getExceptionalDest() : 0); + } + + virtual unsigned getNumSuccessors() const { return 2; } + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const InvokeInst *) { return true; } + static inline bool classof(const Instruction *I) { + return (I->getOpcode() == Instruction::Invoke); + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; + #endif