- Change the horrible N^2 isRegReDefinedByTwoAddr. Now callers must supply the operan...
[oota-llvm.git] / include / llvm / InstrTypes.h
index 527ee89ad324fcae1987f43dd1b61841fdd0fc40..0a3fbed804f0604b0d5160db13116ad15188a9fe 100644 (file)
@@ -118,6 +118,7 @@ public:
            I->getOpcode() == Instruction::Load ||
            I->getOpcode() == Instruction::VAArg ||
            I->getOpcode() == Instruction::GetResult ||
+           I->getOpcode() == Instruction::ExtractValue ||
            (I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
   }
   static inline bool classof(const Value *V) {
@@ -656,16 +657,40 @@ public:
     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 
-  /// short. This facilitates comparison of CmpInst instances without delving
-  /// into the subclasses since predicate values are distinct between the
-  /// CmpInst subclasses.
   /// @brief Return the predicate for this instruction.
-  unsigned short getPredicate() const {
-    return SubclassData;
-  }
+  Predicate getPredicate() const { return Predicate(SubclassData); }
+
+  /// @brief Set the predicate for this instruction to the specified value.
+  void setPredicate(Predicate P) { SubclassData = P; }
+  
+  /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
+  ///              OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
+  /// @returns the inverse predicate for the instruction's current predicate. 
+  /// @brief Return the inverse of the instruction's predicate.
+  Predicate getInversePredicate() const {
+    return getInversePredicate(getPredicate());
+  }
+
+  /// For example, EQ -> NE, UGT -> ULE, SLT -> SGE,
+  ///              OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
+  /// @returns the inverse predicate for predicate provided in \p pred. 
+  /// @brief Return the inverse of a given predicate
+  static Predicate getInversePredicate(Predicate pred);
+
+  /// For example, EQ->EQ, SLE->SGE, ULT->UGT,
+  ///              OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
+  /// @returns the predicate that would be the result of exchanging the two 
+  /// operands of the CmpInst instruction without changing the result 
+  /// produced.  
+  /// @brief Return the predicate as if the operands were swapped
+  Predicate getSwappedPredicate() const {
+    return getSwappedPredicate(getPredicate());
+  }
+
+  /// This is a static version that you can use without an instruction 
+  /// available.
+  /// @brief Return the predicate as if the operands were swapped.
+  static Predicate getSwappedPredicate(Predicate pred);
 
   /// @brief Provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);