Add an extra operand to LABEL nodes which distinguishes between debug, EH, or misc...
[oota-llvm.git] / include / llvm / InstrTypes.h
index d96b20f76b4962a319b59760a87d2131143612ee..7441a104b56f8b5c2847c569875cfa874302a514 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -84,12 +84,15 @@ public:
 
 class UnaryInstruction : public Instruction {
   Use Op;
+  
+  // avoiding warning: 'this' : used in base member initializer list
+  UnaryInstruction* this_() { return this; }
 protected:
   UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0)
-    : Instruction(Ty, iType, &Op, 1, IB), Op(V, this) {
+    : Instruction(Ty, iType, &Op, 1, IB), Op(V, this_()) {
   }
   UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
-    : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this) {
+    : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) {
   }
 public:
   // Out of line virtual method, so the vtable, etc has a home.
@@ -105,6 +108,20 @@ public:
     Op = Val;
   }
   unsigned getNumOperands() const { return 1; }
+  
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const UnaryInstruction *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::Malloc ||
+           I->getOpcode() == Instruction::Alloca ||
+           I->getOpcode() == Instruction::Free ||
+           I->getOpcode() == Instruction::Load ||
+           I->getOpcode() == Instruction::VAArg ||
+           (I->getOpcode() >= CastOpsBegin && I->getOpcode() < CastOpsEnd);
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
 };
 
 //===----------------------------------------------------------------------===//
@@ -381,8 +398,14 @@ public:
     BasicBlock *InsertAtEnd  ///< The block to insert the instruction into
   );
 
+  /// @brief Check whether it is valid to call getCastOpcode for these types.
+  static bool isCastable(
+    const Type *SrcTy, ///< The Type from which the value should be cast.
+    const Type *DestTy ///< The Type to which the value should be cast.
+  );
+
   /// Returns the opcode necessary to cast Val into Ty using usual casting
-  /// rules. 
+  /// rules.
   /// @brief Infer the opcode for cast operand and type
   static Instruction::CastOps getCastOpcode(
     const Value *Val, ///< The value to cast
@@ -494,9 +517,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());