Remove extranous #include
[oota-llvm.git] / include / llvm / iOther.h
1 //===-- llvm/iOther.h - "Other" instruction node definitions -----*- C++ -*--=//
2 //
3 // This file contains the declarations for instructions that fall into the 
4 // grandios 'other' catagory...
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_IOTHER_H
9 #define LLVM_IOTHER_H
10
11 #include "llvm/InstrTypes.h"
12 #include "llvm/Method.h"
13
14 //===----------------------------------------------------------------------===//
15 //                                 CastInst Class
16 //===----------------------------------------------------------------------===//
17
18 // CastInst - This class represents a cast from Operand[0] to the type of
19 // the instruction (i->getType()).
20 //
21 class CastInst : public Instruction {
22   CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
23     Operands.reserve(1);
24     Operands.push_back(Use(CI.Operands[0], this));
25   }
26 public:
27   CastInst(Value *S, const Type *Ty, const std::string &Name = "")
28     : Instruction(Ty, Cast, Name) {
29     Operands.reserve(1);
30     Operands.push_back(Use(S, this));
31   }
32
33   virtual Instruction *clone() const { return new CastInst(*this); }
34   virtual const char *getOpcodeName() const { return "cast"; }
35
36   // Methods for support type inquiry through isa, cast, and dyn_cast:
37   static inline bool classof(const CastInst *) { return true; }
38   static inline bool classof(const Instruction *I) {
39     return I->getOpcode() == Cast;
40   }
41   static inline bool classof(const Value *V) {
42     return isa<Instruction>(V) && classof(cast<Instruction>(V));
43   }
44 };
45
46
47 //===----------------------------------------------------------------------===//
48 //                           MethodArgument Class
49 //===----------------------------------------------------------------------===//
50
51 class MethodArgument : public Value {  // Defined in the InstrType.cpp file
52   Method *Parent;
53
54   friend class ValueHolder<MethodArgument,Method,Method>;
55   inline void setParent(Method *parent) { Parent = parent; }
56
57 public:
58   MethodArgument(const Type *Ty, const std::string &Name = "") 
59     : Value(Ty, Value::MethodArgumentVal, Name) {
60     Parent = 0;
61   }
62
63   // Specialize setName to handle symbol table majik...
64   virtual void setName(const std::string &name, SymbolTable *ST = 0);
65
66   inline const Method *getParent() const { return Parent; }
67   inline       Method *getParent()       { return Parent; }
68
69   // Methods for support type inquiry through isa, cast, and dyn_cast:
70   static inline bool classof(const MethodArgument *) { return true; }
71   static inline bool classof(const Value *V) {
72     return V->getValueType() == MethodArgumentVal;
73   }
74 };
75
76
77 //===----------------------------------------------------------------------===//
78 //             Classes to function calls and method invocations
79 //===----------------------------------------------------------------------===//
80
81 class CallInst : public Instruction {
82   CallInst(const CallInst &CI);
83 public:
84   CallInst(Value *M, const std::vector<Value*> &Par, const std::string & = "");
85
86   virtual const char *getOpcodeName() const { return "call"; }
87
88   virtual Instruction *clone() const { return new CallInst(*this); }
89   bool hasSideEffects() const { return true; }
90
91   const Method *getCalledMethod() const {
92     return dyn_cast<Method>(Operands[0]);
93   }
94   Method *getCalledMethod() {
95     return dyn_cast<Method>(Operands[0]); 
96   }
97
98   // getCalledValue - Get a pointer to a method that is invoked by this inst.
99   inline const Value *getCalledValue() const { return Operands[0]; }
100   inline       Value *getCalledValue()       { return Operands[0]; }
101
102   // Methods for support type inquiry through isa, cast, and dyn_cast:
103   static inline bool classof(const CallInst *) { return true; }
104   static inline bool classof(const Instruction *I) {
105     return I->getOpcode() == Instruction::Call; 
106   }
107   static inline bool classof(const Value *V) {
108     return isa<Instruction>(V) && classof(cast<Instruction>(V));
109   }
110 };
111
112
113 //===----------------------------------------------------------------------===//
114 //                                 ShiftInst Class
115 //===----------------------------------------------------------------------===//
116
117 // ShiftInst - This class represents left and right shift instructions.
118 //
119 class ShiftInst : public Instruction {
120   ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
121     Operands.reserve(2);
122     Operands.push_back(Use(SI.Operands[0], this));
123     Operands.push_back(Use(SI.Operands[1], this));
124   }
125 public:
126   ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "")
127     : Instruction(S->getType(), Opcode, Name) {
128     assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
129     Operands.reserve(2);
130     Operands.push_back(Use(S, this));
131     Operands.push_back(Use(SA, this));
132   }
133
134   OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
135
136   virtual Instruction *clone() const { return new ShiftInst(*this); }
137   virtual const char *getOpcodeName() const {
138     return getOpcode() == Shl ? "shl" : "shr"; 
139   }
140
141   // Methods for support type inquiry through isa, cast, and dyn_cast:
142   static inline bool classof(const ShiftInst *) { return true; }
143   static inline bool classof(const Instruction *I) {
144     return (I->getOpcode() == Instruction::Shr) | 
145            (I->getOpcode() == Instruction::Shl);
146   }
147   static inline bool classof(const Value *V) {
148     return isa<Instruction>(V) && classof(cast<Instruction>(V));
149   }
150 };
151
152 #endif