1 //===-- llvm/iOther.h - "Other" instruction node definitions -----*- C++ -*--=//
3 // This file contains the declarations for instructions that fall into the
4 // grandiose 'other' catagory...
6 //===----------------------------------------------------------------------===//
11 #include "llvm/InstrTypes.h"
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
17 /// CastInst - This class represents a cast from Operand[0] to the type of
18 /// the instruction (i->getType()).
20 class CastInst : public Instruction {
21 CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
23 Operands.push_back(Use(CI.Operands[0], this));
26 CastInst(Value *S, const Type *Ty, const std::string &Name = "",
27 Instruction *InsertBefore = 0)
28 : Instruction(Ty, Cast, Name, InsertBefore) {
30 Operands.push_back(Use(S, this));
33 virtual Instruction *clone() const { return new CastInst(*this); }
35 // Methods for support type inquiry through isa, cast, and dyn_cast:
36 static inline bool classof(const CastInst *) { return true; }
37 static inline bool classof(const Instruction *I) {
38 return I->getOpcode() == Cast;
40 static inline bool classof(const Value *V) {
41 return isa<Instruction>(V) && classof(cast<Instruction>(V));
46 //===----------------------------------------------------------------------===//
48 //===----------------------------------------------------------------------===//
50 class CallInst : public Instruction {
51 CallInst(const CallInst &CI);
53 CallInst(Value *F, const std::vector<Value*> &Par,
54 const std::string &Name = "", Instruction *InsertBefore = 0);
56 // Alternate CallInst ctors w/ no actuals & one actual, respectively.
57 CallInst(Value *F, const std::string &Name = "",
58 Instruction *InsertBefore = 0);
59 CallInst(Value *F, Value *Actual, const std::string& Name = "",
60 Instruction* InsertBefore = 0);
62 virtual Instruction *clone() const { return new CallInst(*this); }
63 bool mayWriteToMemory() const { return true; }
65 const Function *getCalledFunction() const {
66 return dyn_cast<Function>(Operands[0].get());
68 Function *getCalledFunction() {
69 return dyn_cast<Function>(Operands[0].get());
72 // getCalledValue - Get a pointer to a method that is invoked by this inst.
73 inline const Value *getCalledValue() const { return Operands[0]; }
74 inline Value *getCalledValue() { return Operands[0]; }
76 // Methods for support type inquiry through isa, cast, and dyn_cast:
77 static inline bool classof(const CallInst *) { return true; }
78 static inline bool classof(const Instruction *I) {
79 return I->getOpcode() == Instruction::Call;
81 static inline bool classof(const Value *V) {
82 return isa<Instruction>(V) && classof(cast<Instruction>(V));
87 //===----------------------------------------------------------------------===//
89 //===----------------------------------------------------------------------===//
91 // ShiftInst - This class represents left and right shift instructions.
93 class ShiftInst : public Instruction {
94 ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
96 Operands.push_back(Use(SI.Operands[0], this));
97 Operands.push_back(Use(SI.Operands[1], this));
100 ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
101 Instruction *InsertBefore = 0)
102 : Instruction(S->getType(), Opcode, Name, InsertBefore) {
103 assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
105 Operands.push_back(Use(S, this));
106 Operands.push_back(Use(SA, this));
109 OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
111 virtual Instruction *clone() const { return new ShiftInst(*this); }
113 // Methods for support type inquiry through isa, cast, and dyn_cast:
114 static inline bool classof(const ShiftInst *) { return true; }
115 static inline bool classof(const Instruction *I) {
116 return (I->getOpcode() == Instruction::Shr) |
117 (I->getOpcode() == Instruction::Shl);
119 static inline bool classof(const Value *V) {
120 return isa<Instruction>(V) && classof(cast<Instruction>(V));
125 //===----------------------------------------------------------------------===//
127 //===----------------------------------------------------------------------===//
129 /// VarArgInst - This class represents the va_arg llvm instruction, which reads
130 /// an argument of the destination type from the va_list operand pointed to by
131 /// the only operand.
133 class VarArgInst : public Instruction {
134 VarArgInst(const VarArgInst &VAI) : Instruction(VAI.getType(), VarArg) {
136 Operands.push_back(Use(VAI.Operands[0], this));
139 VarArgInst(Value *S, const Type *Ty, const std::string &Name = "",
140 Instruction *InsertBefore = 0)
141 : Instruction(Ty, VarArg, Name, InsertBefore) {
143 Operands.push_back(Use(S, this));
146 virtual Instruction *clone() const { return new VarArgInst(*this); }
148 bool mayWriteToMemory() const { return true; }
150 // Methods for support type inquiry through isa, cast, and dyn_cast:
151 static inline bool classof(const VarArgInst *) { return true; }
152 static inline bool classof(const Instruction *I) {
153 return I->getOpcode() == VarArg;
155 static inline bool classof(const Value *V) {
156 return isa<Instruction>(V) && classof(cast<Instruction>(V));