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"
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(Ty, Cast, Name) {
29 Operands.push_back(Use(S, this));
32 virtual Instruction *clone() const { return new CastInst(*this); }
34 // Methods for support type inquiry through isa, cast, and dyn_cast:
35 static inline bool classof(const CastInst *) { return true; }
36 static inline bool classof(const Instruction *I) {
37 return I->getOpcode() == Cast;
39 static inline bool classof(const Value *V) {
40 return isa<Instruction>(V) && classof(cast<Instruction>(V));
45 //===----------------------------------------------------------------------===//
46 // Classes to function calls and method invocations
47 //===----------------------------------------------------------------------===//
49 class CallInst : public Instruction {
50 CallInst(const CallInst &CI);
52 CallInst(Value *M, const std::vector<Value*> &Par, const std::string & = "");
54 virtual Instruction *clone() const { return new CallInst(*this); }
55 bool hasSideEffects() const { return true; }
57 const Function *getCalledFunction() const {
58 return dyn_cast<Function>(Operands[0].get());
60 Function *getCalledFunction() {
61 return dyn_cast<Function>(Operands[0].get());
64 // getCalledValue - Get a pointer to a method that is invoked by this inst.
65 inline const Value *getCalledValue() const { return Operands[0]; }
66 inline Value *getCalledValue() { return Operands[0]; }
68 // Methods for support type inquiry through isa, cast, and dyn_cast:
69 static inline bool classof(const CallInst *) { return true; }
70 static inline bool classof(const Instruction *I) {
71 return I->getOpcode() == Instruction::Call;
73 static inline bool classof(const Value *V) {
74 return isa<Instruction>(V) && classof(cast<Instruction>(V));
79 //===----------------------------------------------------------------------===//
81 //===----------------------------------------------------------------------===//
83 // ShiftInst - This class represents left and right shift instructions.
85 class ShiftInst : public Instruction {
86 ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
88 Operands.push_back(Use(SI.Operands[0], this));
89 Operands.push_back(Use(SI.Operands[1], this));
92 ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "")
93 : Instruction(S->getType(), Opcode, Name) {
94 assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
96 Operands.push_back(Use(S, this));
97 Operands.push_back(Use(SA, this));
100 OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
102 virtual Instruction *clone() const { return new ShiftInst(*this); }
104 // Methods for support type inquiry through isa, cast, and dyn_cast:
105 static inline bool classof(const ShiftInst *) { return true; }
106 static inline bool classof(const Instruction *I) {
107 return (I->getOpcode() == Instruction::Shr) |
108 (I->getOpcode() == Instruction::Shl);
110 static inline bool classof(const Value *V) {
111 return isa<Instruction>(V) && classof(cast<Instruction>(V));