Provide a getOpcode() method on CmpInst to ensure the opcode is returned
authorReid Spencer <rspencer@reidspencer.com>
Thu, 7 Dec 2006 04:18:31 +0000 (04:18 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 7 Dec 2006 04:18:31 +0000 (04:18 +0000)
as the right type. Use this to shorten some code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32300 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0577db3efc43265aea11b07ffc44daf8900539c1..eaf56a301cdc843995b4144a386ab8b15c7ef363 100644 (file)
@@ -521,6 +521,11 @@ public:
   /// @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());
+  }
+
   /// The predicate for CmpInst is defined by the subclasses but stored in 
   /// the SubclassData field (see Value.h).  We allow it to be fetched here
   /// as the predicate but there is no enum type for it, just the raw unsigned 
index f9271178a4d139a6a896d6a465db7e8e492d3f58..5f1aaea909432e41786196d40840131cef405c67 100644 (file)
@@ -378,8 +378,7 @@ struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr {
   Use Ops[2];
   CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred, 
                       Constant* LHS, Constant* RHS)
-    : ConstantExpr(Type::BoolTy, Instruction::OtherOps(opc), Ops, 2),
-      predicate(pred) {
+    : ConstantExpr(Type::BoolTy, opc, Ops, 2), predicate(pred) {
     OperandList[0].init(LHS, this);
     OperandList[1].init(RHS, this);
   }
index 1cc04334cdbd2cac90c60e72d308b6c1439d3015..57dd5a56b8ab7871741fc585f590c73c8bde0262 100644 (file)
@@ -2252,8 +2252,7 @@ BinaryOperator *BinaryOperator::clone() const {
 }
 
 CmpInst* CmpInst::clone() const {
-  return create(Instruction::OtherOps(getOpcode()), getPredicate(), 
-                Ops[0], Ops[1]);
+  return create(getOpcode(), getPredicate(), Ops[0], Ops[1]);
 }
 
 MallocInst *MallocInst::clone()   const { return new MallocInst(*this); }