Ugh, the old sparc backend attaches MachineCodeForInstruction annotations on
[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 //===----------------------------------------------------------------------===//
138 //                                VANextInst Class
139 //===----------------------------------------------------------------------===//
140
141 /// VANextInst - This class represents the va_next llvm instruction, which
142 /// advances a vararg list passed an argument of the specified type, returning
143 /// the resultant list.
144 ///
145 class VANextInst : public Instruction {
146   PATypeHolder ArgTy;
147   VANextInst(const VANextInst &VAN)
148     : Instruction(VAN.getType(), VANext), ArgTy(VAN.getArgType()) {
149     Operands.reserve(1);
150     Operands.push_back(Use(VAN.Operands[0], this));
151   }
152 public:
153   VANextInst(Value *List, const Type *Ty, const std::string &Name = "",
154              Instruction *InsertBefore = 0)
155     : Instruction(List->getType(), VANext, Name, InsertBefore), ArgTy(Ty) {
156     Operands.reserve(1);
157     Operands.push_back(Use(List, this));
158   }
159
160   const Type *getArgType() const { return ArgTy; }
161
162   virtual Instruction *clone() const { return new VANextInst(*this); }
163
164   // Methods for support type inquiry through isa, cast, and dyn_cast:
165   static inline bool classof(const VANextInst *) { return true; }
166   static inline bool classof(const Instruction *I) {
167     return I->getOpcode() == VANext;
168   }
169   static inline bool classof(const Value *V) {
170     return isa<Instruction>(V) && classof(cast<Instruction>(V));
171   }
172 };
173
174 /// VAArgInst - This class represents the va_arg llvm instruction, which returns
175 /// an argument of the specified type given a va_list.
176 ///
177 class VAArgInst : public Instruction {
178   VAArgInst(const VAArgInst &VAA)
179     : Instruction(VAA.getType(), VAArg) {
180     Operands.reserve(1);
181     Operands.push_back(Use(VAA.Operands[0], this));
182   }
183 public:
184   VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
185              Instruction *InsertBefore = 0)
186     : Instruction(Ty, VAArg, Name, InsertBefore) {
187     Operands.reserve(1);
188     Operands.push_back(Use(List, this));
189   }
190
191   virtual Instruction *clone() const { return new VAArgInst(*this); }
192
193   // Methods for support type inquiry through isa, cast, and dyn_cast:
194   static inline bool classof(const VAArgInst *) { return true; }
195   static inline bool classof(const Instruction *I) {
196     return I->getOpcode() == VAArg;
197   }
198   static inline bool classof(const Value *V) {
199     return isa<Instruction>(V) && classof(cast<Instruction>(V));
200   }
201 };
202
203 } // End llvm namespace
204
205 #endif