Add new SetCondInst::isRelational/isEquality methods. Rename
authorChris Lattner <sabre@nondot.org>
Sun, 17 Sep 2006 19:14:47 +0000 (19:14 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 17 Sep 2006 19:14:47 +0000 (19:14 +0000)
Instruction::isRelational to Instruction::isComparison.

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

include/llvm/Instruction.h
include/llvm/Instructions.h
lib/VMCore/ConstantFold.cpp
lib/VMCore/Constants.cpp
lib/VMCore/Instruction.cpp

index dd73213878f5d9f189dc299ca9a5c9f56a359cb8..cd024d09ea92b62a6e22ede663782c7ba1ab2734 100644 (file)
@@ -141,10 +141,10 @@ public:
   bool isCommutative() const { return isCommutative(getOpcode()); }
   static bool isCommutative(unsigned op);
 
-  /// isRelational - Return true if the instruction is a Set* instruction:
+  /// isComparison - Return true if the instruction is a Set* instruction:
   ///
-  bool isRelational() const { return isRelational(getOpcode()); }
-  static bool isRelational(unsigned op);
+  bool isComparison() const { return isComparison(getOpcode()); }
+  static bool isComparison(unsigned op);
 
 
   /// isTrappingInstruction - Return true if the instruction may trap.
index a3d70f8f14624e407ae17e7bd11edf0ef0e3d2ea..ed407acfb76ee21c626d495e15fd67f516a5cc87 100644 (file)
@@ -454,7 +454,18 @@ public:
   ///
   static BinaryOps getSwappedCondition(BinaryOps Opcode);
 
-
+  /// isEquality - Return true if this comparison is an ==/!= comparison.
+  ///
+  bool isEquality() const {
+    return getOpcode() == SetEQ || getOpcode() == SetNE;
+  }
+  
+  /// isRelational - Return true if this comparison is a </>/<=/>= comparison.
+  ///
+  bool isRelational() const {
+    return !isEquality();
+  }
+  
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SetCondInst *) { return true; }
   static inline bool classof(const Instruction *I) {
index 2263d5ed83dd17a51aa4f7adbc6307a0756bfc1c..32945c290f2ef0bbdb135b154a17a975329938d9 100644 (file)
@@ -1212,7 +1212,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
   // If we successfully folded the expression, return it now.
   if (C) return C;
 
-  if (SetCondInst::isRelational(Opcode)) {
+  if (SetCondInst::isComparison(Opcode)) {
     if (isa<UndefValue>(V1) || isa<UndefValue>(V2))
       return UndefValue::get(Type::BoolTy);
     switch (evaluateRelation(const_cast<Constant*>(V1),
index 8a1ae1eeca2143830021c67bb581f74a3541c0a6..621e2ca94bff7c87adf329dc6e1d52f957dfa099 100644 (file)
@@ -1419,7 +1419,7 @@ Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
   assert(C1->getType() == C2->getType() &&
          "Operand types in binary constant expression should match");
 
-  if (ReqTy == C1->getType() || (Instruction::isRelational(Opcode) &&
+  if (ReqTy == C1->getType() || (Instruction::isComparison(Opcode) &&
                                  ReqTy == Type::BoolTy))
     if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2))
       return FC;          // Fold a few common cases...
@@ -1462,7 +1462,7 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
   }
 #endif
 
-  if (Instruction::isRelational(Opcode))
+  if (Instruction::isComparison(Opcode))
     return getTy(Type::BoolTy, Opcode, C1, C2);
   else
     return getTy(C1->getType(), Opcode, C1, C2);
index ab4aaac745077cec6a0e9c8686a460061e109165..b2951461d7c7793c21eb63c59206776419e84dc3 100644 (file)
@@ -200,9 +200,9 @@ bool Instruction::isCommutative(unsigned op) {
   }
 }
 
-/// isRelational - Return true if the instruction is a Set* instruction:
+/// isComparison - Return true if the instruction is a Set* instruction:
 ///
-bool Instruction::isRelational(unsigned op) {
+bool Instruction::isComparison(unsigned op) {
   switch (op) {
   case SetEQ:
   case SetNE: