1 //===-- llvm/iOther.h - "Other" instruction node definitions -----*- C++ -*--=//
3 // This file contains the declarations for instructions that fall into the
4 // grandios 'other' catagory...
6 //===----------------------------------------------------------------------===//
11 #include "llvm/InstrTypes.h"
12 #include "llvm/Method.h"
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
18 // CastInst - This class represents a cast from Operand[0] to the type of
19 // the instruction (i->getType()).
21 class CastInst : public Instruction {
22 CastInst(const CastInst &CI) : Instruction(CI.getType(), Cast) {
24 Operands.push_back(Use(CI.Operands[0], this));
27 CastInst(Value *S, const Type *Ty, const std::string &Name = "")
28 : Instruction(Ty, Cast, Name) {
30 Operands.push_back(Use(S, this));
33 virtual Instruction *clone() const { return new CastInst(*this); }
34 virtual const char *getOpcodeName() const { return "cast"; }
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;
41 static inline bool classof(const Value *V) {
42 return isa<Instruction>(V) && classof(cast<Instruction>(V));
47 //===----------------------------------------------------------------------===//
48 // MethodArgument Class
49 //===----------------------------------------------------------------------===//
51 class MethodArgument : public Value { // Defined in the InstrType.cpp file
54 friend class ValueHolder<MethodArgument,Method,Method>;
55 inline void setParent(Method *parent) { Parent = parent; }
58 MethodArgument(const Type *Ty, const std::string &Name = "")
59 : Value(Ty, Value::MethodArgumentVal, Name) {
63 // Specialize setName to handle symbol table majik...
64 virtual void setName(const std::string &name, SymbolTable *ST = 0);
66 inline const Method *getParent() const { return Parent; }
67 inline Method *getParent() { return Parent; }
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;
77 //===----------------------------------------------------------------------===//
78 // Classes to function calls and method invocations
79 //===----------------------------------------------------------------------===//
81 class CallInst : public Instruction {
82 CallInst(const CallInst &CI);
84 CallInst(Value *M, const std::vector<Value*> &Par, const std::string & = "");
86 virtual const char *getOpcodeName() const { return "call"; }
88 virtual Instruction *clone() const { return new CallInst(*this); }
89 bool hasSideEffects() const { return true; }
91 const Method *getCalledMethod() const {
92 return dyn_cast<Method>(Operands[0]);
94 Method *getCalledMethod() {
95 return dyn_cast<Method>(Operands[0]);
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]; }
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;
107 static inline bool classof(const Value *V) {
108 return isa<Instruction>(V) && classof(cast<Instruction>(V));
113 //===----------------------------------------------------------------------===//
115 //===----------------------------------------------------------------------===//
117 // ShiftInst - This class represents left and right shift instructions.
119 class ShiftInst : public Instruction {
120 ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
122 Operands.push_back(Use(SI.Operands[0], this));
123 Operands.push_back(Use(SI.Operands[1], this));
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!");
130 Operands.push_back(Use(S, this));
131 Operands.push_back(Use(SA, this));
134 OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
136 virtual Instruction *clone() const { return new ShiftInst(*this); }
137 virtual const char *getOpcodeName() const {
138 return getOpcode() == Shl ? "shl" : "shr";
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);
147 static inline bool classof(const Value *V) {
148 return isa<Instruction>(V) && classof(cast<Instruction>(V));