Renamed inst_const_iterator -> const_inst_iterator
[oota-llvm.git] / include / llvm / InstrTypes.h
index 8bfaca4a8a44f769daf8d8e2eac2a870885b439c..54aab3287584c6f8f6212e471ac519f370586864 100644 (file)
@@ -10,8 +10,6 @@
 #define LLVM_INSTRUCTION_TYPES_H
 
 #include "llvm/Instruction.h"
-#include <list>
-#include <vector>
 
 class Method;
 class SymTabValue;
@@ -25,7 +23,9 @@ class SymTabValue;
 //
 class TerminatorInst : public Instruction {
 public:
-  TerminatorInst(unsigned iType);
+  TerminatorInst(Instruction::TermOps iType);
+  TerminatorInst(const Type *Ty, Instruction::TermOps iType,
+                const string &Name = "");
   inline ~TerminatorInst() {}
 
   // Terminators must implement the methods required by Instruction...
@@ -42,6 +42,15 @@ public:
   inline BasicBlock *getSuccessor(unsigned idx) {
     return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx);
   }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const TerminatorInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() >= FirstTermOp && I->getOpcode() < NumTermOps; 
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
 };
 
 
@@ -55,12 +64,10 @@ public:
   // create() - Construct a unary instruction, given the opcode
   // and its operand.
   //
-  static UnaryOperator *create(UnaryOps Op, Value *Source,
-                              const Type *DestTy = 0);
+  static UnaryOperator *create(UnaryOps Op, Value *Source);
 
-  UnaryOperator(Value *S, UnaryOps iType, const Type *ResultType,
-               const string &Name = "")
-      : Instruction(ResultType, iType, Name) {
+  UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
+      : Instruction(S->getType(), iType, Name) {
     Operands.reserve(1);
     Operands.push_back(Use(S, this));
   }
@@ -74,6 +81,15 @@ public:
   }
 
   virtual const char *getOpcodeName() const = 0;
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const UnaryOperator *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() >= FirstUnaryOp && I->getOpcode() < NumUnaryOps; 
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
 };
 
 
@@ -110,6 +126,20 @@ public:
   }
 
   virtual const char *getOpcodeName() const = 0;
+
+  // swapOperands - Exchange the two operands to this instruction
+  void swapOperands() {
+    swap(Operands[0], Operands[1]);
+  }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const BinaryOperator *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() >= FirstBinaryOp && I->getOpcode() < NumBinaryOps; 
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
 };
 
 #endif