remove deprecated getInstType() method
[oota-llvm.git] / include / llvm / Instruction.h
1 //===-- llvm/Instruction.h - Instruction class definition --------*- C++ -*--=//
2 //
3 // This file contains the declaration of the Instruction class, which is the
4 // base class for all of the VM instructions.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_INSTRUCTION_H
9 #define LLVM_INSTRUCTION_H
10
11 #include "llvm/User.h"
12
13 class Instruction : public User {
14   BasicBlock *Parent;
15
16   friend class ValueHolder<Instruction,BasicBlock,Function>;
17   inline void setParent(BasicBlock *P) { Parent = P; }
18 protected:
19   unsigned iType;      // InstructionType
20 public:
21   Instruction(const Type *Ty, unsigned iType, const std::string &Name = "");
22   virtual ~Instruction() {
23     assert(Parent == 0 && "Instruction still embedded in basic block!");
24   }
25
26   // Specialize setName to handle symbol table majik...
27   virtual void setName(const std::string &name, SymbolTable *ST = 0);
28   
29   // clone() - Create a copy of 'this' instruction that is identical in all ways
30   // except the following:
31   //   * The instruction has no parent
32   //   * The instruction has no name
33   //
34   virtual Instruction *clone() const = 0;
35   
36   // Accessor methods...
37   //
38   inline const BasicBlock *getParent() const { return Parent; }
39   inline       BasicBlock *getParent()       { return Parent; }
40   virtual bool hasSideEffects() const { return false; }  // Memory & Call insts
41
42   // ---------------------------------------------------------------------------
43   // Subclass classification... getOpcode() returns a member of 
44   // one of the enums that is coming soon (down below)...
45   //
46   virtual const char *getOpcodeName() const = 0;
47   unsigned getOpcode() const { return iType; }
48
49   inline bool isTerminator() const {   // Instance of TerminatorInst?
50     return iType >= FirstTermOp && iType < NumTermOps;
51   }
52   inline bool isDefinition() const { return !isTerminator(); }
53   inline bool isUnaryOp() const {
54     return iType >= FirstUnaryOp && iType < NumUnaryOps;
55   }
56   inline bool isBinaryOp() const {
57     return iType >= FirstBinaryOp && iType < NumBinaryOps;
58   }
59
60   virtual void print(std::ostream &OS) const;
61
62   // Methods for support type inquiry through isa, cast, and dyn_cast:
63   static inline bool classof(const Instruction *I) { return true; }
64   static inline bool classof(const Value *V) {
65     return V->getValueType() == Value::InstructionVal;
66   }
67   
68   //----------------------------------------------------------------------
69   // Exported enumerations...
70   //
71   enum TermOps {       // These terminate basic blocks
72 #define  FIRST_TERM_INST(N)             FirstTermOp = N,
73 #define HANDLE_TERM_INST(N, OPC, CLASS) OPC = N,
74 #define   LAST_TERM_INST(N)             NumTermOps = N+1,
75 #include "llvm/Instruction.def"
76   };
77
78   enum UnaryOps {
79 #define  FIRST_UNARY_INST(N)             FirstUnaryOp = N,
80 #define HANDLE_UNARY_INST(N, OPC, CLASS) OPC = N,
81 #define   LAST_UNARY_INST(N)             NumUnaryOps = N+1,
82 #include "llvm/Instruction.def"
83   };
84
85   enum BinaryOps {
86 #define  FIRST_BINARY_INST(N)             FirstBinaryOp = N,
87 #define HANDLE_BINARY_INST(N, OPC, CLASS) OPC = N,
88 #define   LAST_BINARY_INST(N)             NumBinaryOps = N+1,
89 #include "llvm/Instruction.def"
90   };
91
92   enum MemoryOps {
93 #define  FIRST_MEMORY_INST(N)             FirstMemoryOp = N,
94 #define HANDLE_MEMORY_INST(N, OPC, CLASS) OPC = N,
95 #define   LAST_MEMORY_INST(N)             NumMemoryOps = N+1,
96 #include "llvm/Instruction.def"
97   };
98
99   enum OtherOps {
100 #define  FIRST_OTHER_INST(N)             FirstOtherOp = N,
101 #define HANDLE_OTHER_INST(N, OPC, CLASS) OPC = N,
102 #define   LAST_OTHER_INST(N)             NumOtherOps = N+1,
103 #include "llvm/Instruction.def"
104   };
105 };
106
107 #endif