diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-23 15:48:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-23 15:48:41 +0000 |
commit | 54474c75ec3e716ccbd428a0037ce06dfcac6fa3 (patch) | |
tree | f31a5ff4078eaecad4b5a1b3d7b1f781edd8dabe | |
parent | d99d9d5aef19d4b354bca2cb8f8fe24410dae953 (diff) | |
download | bcm5719-llvm-54474c75ec3e716ccbd428a0037ce06dfcac6fa3.tar.gz bcm5719-llvm-54474c75ec3e716ccbd428a0037ce06dfcac6fa3.zip |
Add a new setSuccessor method to terminator instructions
llvm-svn: 2730
-rw-r--r-- | llvm/include/llvm/InstrTypes.h | 1 | ||||
-rw-r--r-- | llvm/include/llvm/iTerminators.h | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/include/llvm/InstrTypes.h b/llvm/include/llvm/InstrTypes.h index 9852a32fdab..f7d63d6a900 100644 --- a/llvm/include/llvm/InstrTypes.h +++ b/llvm/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/llvm/include/llvm/iTerminators.h b/llvm/include/llvm/iTerminators.h index c5047bc6c3c..482684aa8ad 100644 --- a/llvm/include/llvm/iTerminators.h +++ b/llvm/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<BasicBlock>(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: |