diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-24 20:48:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-24 20:48:18 +0000 |
commit | cd406fe1236a1e0a7f210676768ddd3f69e23166 (patch) | |
tree | 8fb8ce727177526162e5d9dc972c949d7fee24f5 | |
parent | 7097e9a7103ce92405d17965f573378007efa7ce (diff) | |
download | external_llvm-cd406fe1236a1e0a7f210676768ddd3f69e23166.zip external_llvm-cd406fe1236a1e0a7f210676768ddd3f69e23166.tar.gz external_llvm-cd406fe1236a1e0a7f210676768ddd3f69e23166.tar.bz2 |
sink clone() down the class hierarchy from CmpInst into ICmpInst/FCmpInst.
This eliminates a conditional on that path, and ensures ICmpInst/FCmpInst
both have an out-of-line virtual method to home the class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41371 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/InstrTypes.h | 3 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 7 |
3 files changed, 9 insertions, 5 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index d96b20f..f7644e3 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -494,9 +494,6 @@ public: Value *S2, const std::string &Name, BasicBlock *InsertAtEnd); - /// @brief Implement superclass method. - virtual CmpInst *clone() const; - /// @brief Get the opcode casted to the right type OtherOps getOpcode() const { return static_cast<OtherOps>(Instruction::getOpcode()); diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index e4f7504..6773783 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -603,6 +603,8 @@ public: std::swap(Ops[0], Ops[1]); } + virtual ICmpInst *clone() const; + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ICmpInst *) { return true; } static inline bool classof(const Instruction *I) { @@ -725,6 +727,8 @@ public: std::swap(Ops[0], Ops[1]); } + virtual FCmpInst *clone() const; + /// @brief Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const FCmpInst *) { return true; } static inline bool classof(const Instruction *I) { diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 5297374..43f8976 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2595,8 +2595,11 @@ BinaryOperator *BinaryOperator::clone() const { return create(getOpcode(), Ops[0], Ops[1]); } -CmpInst* CmpInst::clone() const { - return create(getOpcode(), getPredicate(), Ops[0], Ops[1]); +FCmpInst* FCmpInst::clone() const { + return new FCmpInst(getPredicate(), Ops[0], Ops[1]); +} +ICmpInst* ICmpInst::clone() const { + return new ICmpInst(getPredicate(), Ops[0], Ops[1]); } MallocInst *MallocInst::clone() const { return new MallocInst(*this); } |