[llvm-commits] CVS: llvm/include/llvm/Constants.h InstrTypes.h Instruction.def Instruction.h Instructions.h Pass.h

Reid Spencer reid at x10sys.com
Fri Dec 22 22:06:59 PST 2006



Changes in directory llvm/include/llvm:

Constants.h updated: 1.111 -> 1.112
InstrTypes.h updated: 1.55 -> 1.56
Instruction.def updated: 1.27 -> 1.28
Instruction.h updated: 1.76 -> 1.77
Instructions.h updated: 1.47 -> 1.48
Pass.h updated: 1.66 -> 1.67
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and 
been replaced with ICmpInst and FCmpInst.


---
Diffs of the changes:  (+96 -134)

 Constants.h     |   13 +------
 InstrTypes.h    |   14 +++++++
 Instruction.def |   86 ++++++++++++++++++++++--------------------------
 Instruction.h   |   16 +++++----
 Instructions.h  |   99 ++++++++++++++++----------------------------------------
 Pass.h          |    2 -
 6 files changed, 96 insertions(+), 134 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.111 llvm/include/llvm/Constants.h:1.112
--- llvm/include/llvm/Constants.h:1.111	Mon Dec 18 19:34:39 2006
+++ llvm/include/llvm/Constants.h	Sat Dec 23 00:05:40 2006
@@ -496,8 +496,8 @@
   // ConstantExprs in intermediate forms.
   static Constant *getTy(const Type *Ty, unsigned Opcode,
                          Constant *C1, Constant *C2);
-  static Constant *getCompareTy(unsigned Opcode, unsigned short pred, 
-                                Constant *C1, Constant *C2);
+  static Constant *getCompareTy(unsigned short pred, Constant *C1, 
+                                Constant *C2);
   static Constant *getShiftTy(const Type *Ty,
                               unsigned Opcode, Constant *C1, Constant *C2);
   static Constant *getSelectTy(const Type *Ty,
@@ -604,8 +604,7 @@
   static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
 
   /// @brief Return an ICmp or FCmp comparison operator constant expression.
-  static Constant *getCompare(unsigned Opcode, unsigned short pred, 
-                              Constant *C1, Constant *C2);
+  static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
 
   /// ConstantExpr::get* - Return some common constants without having to
   /// specify the full Instruction::OPCODE identifier.
@@ -624,12 +623,6 @@
   static Constant *getAnd(Constant *C1, Constant *C2);
   static Constant *getOr(Constant *C1, Constant *C2);
   static Constant *getXor(Constant *C1, Constant *C2);
-  static Constant *getSetEQ(Constant *C1, Constant *C2);
-  static Constant *getSetNE(Constant *C1, Constant *C2);
-  static Constant *getSetLT(Constant *C1, Constant *C2);
-  static Constant *getSetGT(Constant *C1, Constant *C2);
-  static Constant *getSetLE(Constant *C1, Constant *C2);
-  static Constant *getSetGE(Constant *C1, Constant *C2);
   static Constant* getICmp(unsigned short pred, Constant* LHS, Constant* RHS);
   static Constant* getFCmp(unsigned short pred, Constant* LHS, Constant* RHS);
   static Constant *getShl(Constant *C1, Constant *C2);


Index: llvm/include/llvm/InstrTypes.h
diff -u llvm/include/llvm/InstrTypes.h:1.55 llvm/include/llvm/InstrTypes.h:1.56
--- llvm/include/llvm/InstrTypes.h:1.55	Mon Dec 18 02:52:59 2006
+++ llvm/include/llvm/InstrTypes.h	Sat Dec 23 00:05:40 2006
@@ -543,6 +543,20 @@
   /// @brief Determine if this is an equals/not equals predicate.
   bool isEquality();
 
+  /// @returns true if the predicate is unsigned, false otherwise.
+  /// @brief Determine if the predicate is an unsigned operation.
+  static bool isUnsigned(unsigned short predicate);
+
+  /// @returns true if the predicate is signed, false otherwise.
+  /// @brief Determine if the predicate is an signed operation.
+  static bool isSigned(unsigned short predicate);
+
+  /// @brief Determine if the predicate is an ordered operation.
+  static bool isOrdered(unsigned short predicate);
+
+  /// @brief Determine if the predicate is an unordered operation.
+  static bool isUnordered(unsigned short predicate);
+
   /// @brief Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const CmpInst *) { return true; }
   static inline bool classof(const Instruction *I) {


Index: llvm/include/llvm/Instruction.def
diff -u llvm/include/llvm/Instruction.def:1.27 llvm/include/llvm/Instruction.def:1.28
--- llvm/include/llvm/Instruction.def:1.27	Wed Nov 29 15:37:00 2006
+++ llvm/include/llvm/Instruction.def	Sat Dec 23 00:05:40 2006
@@ -118,61 +118,53 @@
 HANDLE_BINARY_INST(16, And   , BinaryOperator)
 HANDLE_BINARY_INST(17, Or    , BinaryOperator)
 HANDLE_BINARY_INST(18, Xor   , BinaryOperator)
-
-// Binary comparison operators...
-HANDLE_BINARY_INST(19, SetEQ , SetCondInst)
-HANDLE_BINARY_INST(20, SetNE , SetCondInst)
-HANDLE_BINARY_INST(21, SetLE , SetCondInst)
-HANDLE_BINARY_INST(22, SetGE , SetCondInst)
-HANDLE_BINARY_INST(23, SetLT , SetCondInst)
-HANDLE_BINARY_INST(24, SetGT , SetCondInst)
-  LAST_BINARY_INST(24)
+  LAST_BINARY_INST(18)
 
 // Memory operators...
- FIRST_MEMORY_INST(25)
-HANDLE_MEMORY_INST(25, Malloc, MallocInst)  // Heap management instructions
-HANDLE_MEMORY_INST(26, Free  , FreeInst  )
-HANDLE_MEMORY_INST(27, Alloca, AllocaInst)  // Stack management
-HANDLE_MEMORY_INST(28, Load  , LoadInst  )  // Memory manipulation instrs
-HANDLE_MEMORY_INST(29, Store , StoreInst )
-HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
-  LAST_MEMORY_INST(30)
+ FIRST_MEMORY_INST(19)
+HANDLE_MEMORY_INST(19, Malloc, MallocInst)  // Heap management instructions
+HANDLE_MEMORY_INST(20, Free  , FreeInst  )
+HANDLE_MEMORY_INST(21, Alloca, AllocaInst)  // Stack management
+HANDLE_MEMORY_INST(22, Load  , LoadInst  )  // Memory manipulation instrs
+HANDLE_MEMORY_INST(23, Store , StoreInst )
+HANDLE_MEMORY_INST(24, GetElementPtr, GetElementPtrInst)
+  LAST_MEMORY_INST(24)
 
 // Cast operators ...
 // NOTE: The order matters here because CastInst::isEliminableCastPair 
 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
- FIRST_CAST_INST(31)
-HANDLE_CAST_INST(31, Trunc   , TruncInst   )  // Truncate integers
-HANDLE_CAST_INST(32, ZExt    , ZExtInst    )  // Zero extend integers
-HANDLE_CAST_INST(33, SExt    , SExtInst    )  // Sign extend integers
-HANDLE_CAST_INST(34, FPToUI  , FPToUIInst  )  // floating point -> UInt
-HANDLE_CAST_INST(35, FPToSI  , FPToSIInst  )  // floating point -> SInt
-HANDLE_CAST_INST(36, UIToFP  , UIToFPInst  )  // UInt -> floating point
-HANDLE_CAST_INST(37, SIToFP  , SIToFPInst  )  // SInt -> floating point
-HANDLE_CAST_INST(38, FPTrunc , FPTruncInst )  // Truncate floating point
-HANDLE_CAST_INST(39, FPExt   , FPExtInst   )  // Extend floating point
-HANDLE_CAST_INST(40, PtrToInt, PtrToIntInst)  // Pointer -> Integer
-HANDLE_CAST_INST(41, IntToPtr, IntToPtrInst)  // Integer -> Pointer
-HANDLE_CAST_INST(42, BitCast , BitCastInst )  // Type cast
-  LAST_CAST_INST(42)
+ FIRST_CAST_INST(25)
+HANDLE_CAST_INST(25, Trunc   , TruncInst   )  // Truncate integers
+HANDLE_CAST_INST(26, ZExt    , ZExtInst    )  // Zero extend integers
+HANDLE_CAST_INST(27, SExt    , SExtInst    )  // Sign extend integers
+HANDLE_CAST_INST(28, FPToUI  , FPToUIInst  )  // floating point -> UInt
+HANDLE_CAST_INST(29, FPToSI  , FPToSIInst  )  // floating point -> SInt
+HANDLE_CAST_INST(30, UIToFP  , UIToFPInst  )  // UInt -> floating point
+HANDLE_CAST_INST(31, SIToFP  , SIToFPInst  )  // SInt -> floating point
+HANDLE_CAST_INST(32, FPTrunc , FPTruncInst )  // Truncate floating point
+HANDLE_CAST_INST(33, FPExt   , FPExtInst   )  // Extend floating point
+HANDLE_CAST_INST(34, PtrToInt, PtrToIntInst)  // Pointer -> Integer
+HANDLE_CAST_INST(35, IntToPtr, IntToPtrInst)  // Integer -> Pointer
+HANDLE_CAST_INST(36, BitCast , BitCastInst )  // Type cast
+  LAST_CAST_INST(36)
 
 // Other operators...
- FIRST_OTHER_INST(43)
-HANDLE_OTHER_INST(43, ICmp   , ICmpInst   )  // Integer comparison instruction
-HANDLE_OTHER_INST(44, FCmp   , FCmpInst   )  // Floating point comparison instr.
-HANDLE_OTHER_INST(45, PHI    , PHINode    )  // PHI node instruction
-HANDLE_OTHER_INST(46, Call   , CallInst   )  // Call a function
-HANDLE_OTHER_INST(47, Shl    , ShiftInst  )  // Shift Left operations (logical)
-HANDLE_OTHER_INST(48, LShr   , ShiftInst  )  // Logical Shift right (unsigned) 
-HANDLE_OTHER_INST(49, AShr   , ShiftInst  )  // Arithmetic shift right (signed)
-HANDLE_OTHER_INST(50, Select , SelectInst )  // select instruction
-HANDLE_OTHER_INST(51, UserOp1, Instruction)  // May be used internally in a pass
-HANDLE_OTHER_INST(52, UserOp2, Instruction)  // Internal to passes only
-HANDLE_OTHER_INST(53, VAArg  , VAArgInst  )  // vaarg instruction
-HANDLE_OTHER_INST(54, ExtractElement, ExtractElementInst)// extract from vector.
-HANDLE_OTHER_INST(55, InsertElement, InsertElementInst)  // insert into vector
-HANDLE_OTHER_INST(56, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
-  LAST_OTHER_INST(56)
+ FIRST_OTHER_INST(37)
+HANDLE_OTHER_INST(37, ICmp   , ICmpInst   )  // Integer comparison instruction
+HANDLE_OTHER_INST(38, FCmp   , FCmpInst   )  // Floating point comparison instr.
+HANDLE_OTHER_INST(39, PHI    , PHINode    )  // PHI node instruction
+HANDLE_OTHER_INST(40, Call   , CallInst   )  // Call a function
+HANDLE_OTHER_INST(41, Shl    , ShiftInst  )  // Shift Left operations (logical)
+HANDLE_OTHER_INST(42, LShr   , ShiftInst  )  // Logical Shift right (unsigned) 
+HANDLE_OTHER_INST(43, AShr   , ShiftInst  )  // Arithmetic shift right (signed)
+HANDLE_OTHER_INST(44, Select , SelectInst )  // select instruction
+HANDLE_OTHER_INST(45, UserOp1, Instruction)  // May be used internally in a pass
+HANDLE_OTHER_INST(46, UserOp2, Instruction)  // Internal to passes only
+HANDLE_OTHER_INST(47, VAArg  , VAArgInst  )  // vaarg instruction
+HANDLE_OTHER_INST(48, ExtractElement, ExtractElementInst)// extract from vector.
+HANDLE_OTHER_INST(49, InsertElement, InsertElementInst)  // insert into vector
+HANDLE_OTHER_INST(50, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
+  LAST_OTHER_INST(50)
 
 #undef  FIRST_TERM_INST
 #undef HANDLE_TERM_INST


Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.76 llvm/include/llvm/Instruction.h:1.77
--- llvm/include/llvm/Instruction.h:1.76	Sat Dec 16 23:15:12 2006
+++ llvm/include/llvm/Instruction.h	Sat Dec 23 00:05:40 2006
@@ -71,6 +71,16 @@
   /// extra information (e.g. load is volatile) agree.
   bool isIdenticalTo(Instruction *I) const;
 
+  /// This function determines if the specified instruction executes the same
+  /// operation as the current one. This means that the opcodes, type, operand
+  /// types and any other factors affecting the operation must be the same. This
+  /// is similar to isIdenticalTo except the operands themselves don't have to
+  /// be identical.
+  /// @returns true if the specified instruction is the same operation as
+  /// the current one.
+  /// @brief Determine if one instruction is the same operation as another.
+  bool isSameOperationAs(Instruction *I) const;
+
   /// use_back - Specialize the methods defined in Value, as we know that an
   /// instruction can only be used by other instructions.
   Instruction       *use_back()       { return cast<Instruction>(*use_begin());}
@@ -155,12 +165,6 @@
   bool isCommutative() const { return isCommutative(getOpcode()); }
   static bool isCommutative(unsigned op);
 
-  /// isComparison - Return true if the instruction is a Set* instruction:
-  ///
-  bool isComparison() const { return isComparison(getOpcode()); }
-  static bool isComparison(unsigned op);
-
-
   /// isTrappingInstruction - Return true if the instruction may trap.
   ///
   bool isTrapping() const {


Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.47 llvm/include/llvm/Instructions.h:1.48
--- llvm/include/llvm/Instructions.h:1.47	Sun Nov 26 19:05:09 2006
+++ llvm/include/llvm/Instructions.h	Sat Dec 23 00:05:40 2006
@@ -440,7 +440,8 @@
     ICMP_SLT = 40,    ///< signed less than
     ICMP_SLE = 41,    ///< signed less or equal
     FIRST_ICMP_PREDICATE = ICMP_EQ,
-    LAST_ICMP_PREDICATE = ICMP_SLE
+    LAST_ICMP_PREDICATE = ICMP_SLE,
+    BAD_ICMP_PREDICATE = ICMP_SLE + 1
   };
 
   /// @brief Constructor with insert-before-instruction semantics.
@@ -490,16 +491,30 @@
   /// 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 Opcode);
+  static Predicate getSwappedPredicate(Predicate pred);
+
+  /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
+  /// @returns the predicate that would be the result if the operand were
+  /// regarded as signed.
+  /// @brief Return the signed version of the predicate
+  Predicate getSignedPredicate() const {
+    return getSignedPredicate(getPredicate());
+  }
+
+  /// This is a static version that you can use without an instruction.
+  /// @brief Return the signed version of the predicate.
+  static Predicate getSignedPredicate(Predicate pred);
 
   /// This also tests for commutativity. If isEquality() returns true then
-  /// the predicate is also commutative. Only the equality predicates are
-  /// commutative.
+  /// the predicate is also commutative. 
   /// @returns true if the predicate of this instruction is EQ or NE.
   /// @brief Determine if this is an equality predicate.
   bool isEquality() const {
     return SubclassData == ICMP_EQ || SubclassData == ICMP_NE;
   }
+
+  /// @returns true if the predicate of this ICmpInst is commutative
+  /// @brief Determine if this relation is commutative.
   bool isCommutative() const { return isEquality(); }
 
   /// @returns true if the predicate is relational (not EQ or NE). 
@@ -508,6 +523,14 @@
     return !isEquality();
   }
 
+  /// @returns true if the predicate of this ICmpInst is signed, false otherwise
+  /// @brief Determine if this instruction's predicate is signed.
+  bool isSignedPredicate() { return isSignedPredicate(getPredicate()); }
+
+  /// @returns true if the predicate provided is signed, false otherwise
+  /// @brief Determine if the predicate is signed.
+  static bool isSignedPredicate(Predicate pred);
+
   /// Exchange the two operands to this instruction in such a way that it does
   /// not modify the semantics of the instruction. The predicate value may be
   /// changed to retain the same result if the predicate is order dependent
@@ -559,7 +582,8 @@
     FCMP_UNE   =14, ///<  1 1 1 0    True if unordered or not equal
     FCMP_TRUE  =15, ///<  1 1 1 1    Always true (always folded)
     FIRST_FCMP_PREDICATE = FCMP_FALSE,
-    LAST_FCMP_PREDICATE = FCMP_TRUE
+    LAST_FCMP_PREDICATE = FCMP_TRUE,
+    BAD_FCMP_PREDICATE = FCMP_TRUE + 1
   };
 
   /// @brief Constructor with insert-before-instruction semantics.
@@ -646,71 +670,6 @@
   }
 };
 
-
-//===----------------------------------------------------------------------===//
-//                            SetCondInst Class
-//===----------------------------------------------------------------------===//
-
-/// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt,
-/// le, or ge.
-///
-class SetCondInst : public BinaryOperator {
-public:
-  SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
-              const std::string &Name = "", Instruction *InsertBefore = 0);
-  SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
-              const std::string &Name, BasicBlock *InsertAtEnd);
-
-  /// getInverseCondition - Return the inverse of the current condition opcode.
-  /// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
-  ///
-  BinaryOps getInverseCondition() const {
-    return getInverseCondition(getOpcode());
-  }
-
-  /// getInverseCondition - Static version that you can use without an
-  /// instruction available.
-  ///
-  static BinaryOps getInverseCondition(BinaryOps Opcode);
-
-  /// getSwappedCondition - Return the condition opcode that would be the result
-  /// of exchanging the two operands of the setcc instruction without changing
-  /// the result produced.  Thus, seteq->seteq, setle->setge, setlt->setgt, etc.
-  ///
-  BinaryOps getSwappedCondition() const {
-    return getSwappedCondition(getOpcode());
-  }
-
-  /// getSwappedCondition - Static version that you can use without an
-  /// instruction available.
-  ///
-  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) {
-    return I->getOpcode() == SetEQ || I->getOpcode() == SetNE ||
-           I->getOpcode() == SetLE || I->getOpcode() == SetGE ||
-           I->getOpcode() == SetLT || I->getOpcode() == SetGT;
-  }
-  static inline bool classof(const Value *V) {
-    return isa<Instruction>(V) && classof(cast<Instruction>(V));
-  }
-};
-
-
 //===----------------------------------------------------------------------===//
 //                                 CallInst Class
 //===----------------------------------------------------------------------===//


Index: llvm/include/llvm/Pass.h
diff -u llvm/include/llvm/Pass.h:1.66 llvm/include/llvm/Pass.h:1.67
--- llvm/include/llvm/Pass.h:1.66	Fri Dec 22 16:55:30 2006
+++ llvm/include/llvm/Pass.h	Sat Dec 23 00:05:40 2006
@@ -36,7 +36,7 @@
 #include <typeinfo>
 #include <cassert>
 
-//#define USE_OLD_PASSMANAGER 1
+#define USE_OLD_PASSMANAGER 1
 
 namespace llvm {
 






More information about the llvm-commits mailing list