From: Chris Lattner Date: Thu, 23 May 2002 15:48:41 +0000 (+0000) Subject: Add a new setSuccessor method to terminator instructions X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=195755ced7b7fb8b941e5d085fe5bd82f36f481e;p=oota-llvm.git Add a new setSuccessor method to terminator instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2730 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 9852a32fdab..f7d63d6a900 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -35,6 +35,7 @@ public: // virtual const BasicBlock *getSuccessor(unsigned idx) const = 0; virtual unsigned getNumSuccessors() const = 0; + virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) = 0; inline BasicBlock *getSuccessor(unsigned idx) { return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx); diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index c5047bc6c3c..482684aa8ad 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -52,6 +52,9 @@ public: assert(0 && "ReturnInst has no successors!"); abort(); } + virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + assert(0 && "ReturnInst has no successors!"); + } virtual unsigned getNumSuccessors() const { return 0; } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -105,6 +108,11 @@ public: return (BasicBlock*)((const BranchInst *)this)->getSuccessor(idx); } + virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + assert(idx < getNumSuccessors() && "Successor # out of range for Branch!"); + Operands[idx] = (Value*)NewSucc; + } + virtual unsigned getNumSuccessors() const { return 1+isConditional(); } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -156,6 +164,11 @@ public: return cast(Operands[idx*2+1].get()); } + virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + assert(idx < getNumSuccessors() && "Successor # out of range for switch!"); + Operands[idx*2+1] = (Value*)NewSucc; + } + // getSuccessorValue - Return the value associated with the specified // successor. inline const Constant *getSuccessorValue(unsigned idx) const { @@ -231,6 +244,11 @@ public: return i == 0 ? getNormalDest() : getExceptionalDest(); } + virtual void setSuccessor(unsigned idx, BasicBlock *NewSucc) { + assert(idx < 2 && "Successor # out of range for invoke!"); + Operands[idx+1] = (Value*)NewSucc; + } + virtual unsigned getNumSuccessors() const { return 2; } // Methods for support type inquiry through isa, cast, and dyn_cast: