sink clone() down the class hierarchy from CmpInst into ICmpInst/FCmpInst.
authorChris Lattner <sabre@nondot.org>
Fri, 24 Aug 2007 20:48:18 +0000 (20:48 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 24 Aug 2007 20:48:18 +0000 (20:48 +0000)
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

include/llvm/InstrTypes.h
include/llvm/Instructions.h
lib/VMCore/Instructions.cpp

index d96b20f76b4962a319b59760a87d2131143612ee..f7644e3dfa6ae96c9cab9be19f710fba954e550d 100644 (file)
@@ -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());
index e4f7504d1b5d36e887f7eda51408df69d2903e16..677378382d04cefb131c4076dc33353baa03f56e 100644 (file)
@@ -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) {
index 5297374e251db649ba75deb6893a4ef3cffbf160..43f89760af81366c9d22d64914e7f1f8ce468bde 100644 (file)
@@ -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); }