Rename the intrinsic enum values for llvm.va_* from Intrinsic::va_* to
[oota-llvm.git] / include / llvm / iOther.h
1 //===-- llvm/iOther.h - "Other" instruction node definitions ----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declarations for instructions that fall into the 
11 // grandiose 'other' catagory...
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_IOTHER_H
16 #define LLVM_IOTHER_H
17
18 #include "llvm/InstrTypes.h"
19
20 namespace llvm {
21
22 //===----------------------------------------------------------------------===//
23 //                                 CastInst Class
24 //===----------------------------------------------------------------------===//
25
26 /// CastInst - This class represents a cast from Operand[0] to the type of
27 /// the instruction (i->getType()).
28 ///
29 class CastInst : public Instruction {
30   CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
31     Operands.reserve(1);
32     Operands.push_back(Use(CI.Operands[0], this));
33   }
34 public:
35   CastInst(Value *S, const Type *Ty, const std::string &Name = "",
36            Instruction *InsertBefore = 0)
37     : Instruction(Ty, Cast, Name, InsertBefore) {
38     Operands.reserve(1);
39     Operands.push_back(Use(S, this));
40   }
41
42   virtual Instruction *clone() const { return new CastInst(*this); }
43
44   // Methods for support type inquiry through isa, cast, and dyn_cast:
45   static inline bool classof(const CastInst *) { return true; }
46   static inline bool classof(const Instruction *I) {
47     return I->getOpcode() == Cast;
48   }
49   static inline bool classof(const Value *V) {
50     return isa<Instruction>(V) && classof(cast<Instruction>(V));
51   }
52 };
53
54
55 //===----------------------------------------------------------------------===//
56 //                                 CallInst Class
57 //===----------------------------------------------------------------------===//
58
59 /// CallInst - This class represents a function call, abstracting a target
60 /// machine's calling convention.
61 ///
62 class CallInst : public Instruction {
63   CallInst(const CallInst &CI);
64 public:
65   CallInst(Value *F, const std::vector<Value*> &Par,
66            const std::string &Name = "", Instruction *InsertBefore = 0);
67
68   // Alternate CallInst ctors w/ no actuals & one actual, respectively.
69   CallInst(Value *F, const std::string &Name = "", 
70            Instruction *InsertBefore = 0);
71   CallInst(Value *F, Value *Actual, const std::string& Name = "",
72            Instruction *InsertBefore = 0);
73
74   virtual Instruction *clone() const { return new CallInst(*this); }
75   bool mayWriteToMemory() const { return true; }
76
77   // FIXME: These methods should be inline once we eliminate
78   // ConstantPointerRefs!
79   const Function *getCalledFunction() const;
80   Function *getCalledFunction();
81
82   // getCalledValue - Get a pointer to a method that is invoked by this inst.
83   inline const Value *getCalledValue() const { return Operands[0]; }
84   inline       Value *getCalledValue()       { return Operands[0]; }
85
86   // Methods for support type inquiry through isa, cast, and dyn_cast:
87   static inline bool classof(const CallInst *) { return true; }
88   static inline bool classof(const Instruction *I) {
89     return I->getOpcode() == Instruction::Call; 
90   }
91   static inline bool classof(const Value *V) {
92     return isa<Instruction>(V) && classof(cast<Instruction>(V));
93   }
94 };
95
96
97 //===----------------------------------------------------------------------===//
98 //                                 ShiftInst Class
99 //===----------------------------------------------------------------------===//
100
101 /// ShiftInst - This class represents left and right shift instructions.
102 ///
103 class ShiftInst : public Instruction {
104   ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
105     Operands.reserve(2);
106     Operands.push_back(Use(SI.Operands[0], this));
107     Operands.push_back(Use(SI.Operands[1], this));
108   }
109 public:
110   ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
111             Instruction *InsertBefore = 0)
112     : Instruction(S->getType(), Opcode, Name, InsertBefore) {
113     assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
114     Operands.reserve(2);
115     Operands.push_back(Use(S, this));
116     Operands.push_back(Use(SA, this));
117   }
118
119   OtherOps getOpcode() const {
120     return static_cast<OtherOps>(Instruction::getOpcode());
121   }
122
123   virtual Instruction *clone() const { return new ShiftInst(*this); }
124
125   // Methods for support type inquiry through isa, cast, and dyn_cast:
126   static inline bool classof(const ShiftInst *) { return true; }
127   static inline bool classof(const Instruction *I) {
128     return (I->getOpcode() == Instruction::Shr) | 
129            (I->getOpcode() == Instruction::Shl);
130   }
131   static inline bool classof(const Value *V) {
132     return isa<Instruction>(V) && classof(cast<Instruction>(V));
133   }
134 };
135
136 //===----------------------------------------------------------------------===//
137 //                               SelectInst Class
138 //===----------------------------------------------------------------------===//
139
140 /// SelectInst - This class represents the LLVM 'select' instruction.
141 ///
142 class SelectInst : public Instruction {
143   SelectInst(const SelectInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
144     Operands.reserve(3);
145     Operands.push_back(Use(SI.Operands[0], this));
146     Operands.push_back(Use(SI.Operands[1], this));
147     Operands.push_back(Use(SI.Operands[2], this));
148   }
149 public:
150   SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
151              Instruction *InsertBefore = 0)
152     : Instruction(S1->getType(), Instruction::Select, Name, InsertBefore) {
153     Operands.reserve(3);
154     Operands.push_back(Use(C, this));
155     Operands.push_back(Use(S1, this));
156     Operands.push_back(Use(S2, this));
157   }
158
159   Value *getCondition() const { return Operands[0]; }
160   Value *getTrueValue() const { return Operands[1]; }
161   Value *getFalseValue() const { return Operands[2]; }
162
163   OtherOps getOpcode() const {
164     return static_cast<OtherOps>(Instruction::getOpcode());
165   }
166
167   virtual Instruction *clone() const { return new SelectInst(*this); }
168
169   // Methods for support type inquiry through isa, cast, and dyn_cast:
170   static inline bool classof(const SelectInst *) { return true; }
171   static inline bool classof(const Instruction *I) {
172     return I->getOpcode() == Instruction::Select;
173   }
174   static inline bool classof(const Value *V) {
175     return isa<Instruction>(V) && classof(cast<Instruction>(V));
176   }
177 };
178
179
180 //===----------------------------------------------------------------------===//
181 //                                VANextInst Class
182 //===----------------------------------------------------------------------===//
183
184 /// VANextInst - This class represents the va_next llvm instruction, which
185 /// advances a vararg list passed an argument of the specified type, returning
186 /// the resultant list.
187 ///
188 class VANextInst : public Instruction {
189   PATypeHolder ArgTy;
190   VANextInst(const VANextInst &VAN)
191     : Instruction(VAN.getType(), VANext), ArgTy(VAN.getArgType()) {
192     Operands.reserve(1);
193     Operands.push_back(Use(VAN.Operands[0], this));
194   }
195 public:
196   VANextInst(Value *List, const Type *Ty, const std::string &Name = "",
197              Instruction *InsertBefore = 0)
198     : Instruction(List->getType(), VANext, Name, InsertBefore), ArgTy(Ty) {
199     Operands.reserve(1);
200     Operands.push_back(Use(List, this));
201   }
202
203   const Type *getArgType() const { return ArgTy; }
204
205   virtual Instruction *clone() const { return new VANextInst(*this); }
206
207   // Methods for support type inquiry through isa, cast, and dyn_cast:
208   static inline bool classof(const VANextInst *) { return true; }
209   static inline bool classof(const Instruction *I) {
210     return I->getOpcode() == VANext;
211   }
212   static inline bool classof(const Value *V) {
213     return isa<Instruction>(V) && classof(cast<Instruction>(V));
214   }
215 };
216
217
218 //===----------------------------------------------------------------------===//
219 //                                VAArgInst Class
220 //===----------------------------------------------------------------------===//
221
222 /// VAArgInst - This class represents the va_arg llvm instruction, which returns
223 /// an argument of the specified type given a va_list.
224 ///
225 class VAArgInst : public Instruction {
226   VAArgInst(const VAArgInst &VAA)
227     : Instruction(VAA.getType(), VAArg) {
228     Operands.reserve(1);
229     Operands.push_back(Use(VAA.Operands[0], this));
230   }
231 public:
232   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
233              Instruction *InsertBefore = 0)
234     : Instruction(Ty, VAArg, Name, InsertBefore) {
235     Operands.reserve(1);
236     Operands.push_back(Use(List, this));
237   }
238
239   virtual Instruction *clone() const { return new VAArgInst(*this); }
240
241   // Methods for support type inquiry through isa, cast, and dyn_cast:
242   static inline bool classof(const VAArgInst *) { return true; }
243   static inline bool classof(const Instruction *I) {
244     return I->getOpcode() == VAArg;
245   }
246   static inline bool classof(const Value *V) {
247     return isa<Instruction>(V) && classof(cast<Instruction>(V));
248   }
249 };
250
251 } // End llvm namespace
252
253 #endif