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 virtual Instruction *clone() const { return new CallInst(*this); }
57 bool hasSideEffects() const { return true; }
59 const Function *getCalledFunction() const {
60 return dyn_cast<Function>(Operands[0].get());
62 Function *getCalledFunction() {
63 return dyn_cast<Function>(Operands[0].get());
66 // getCalledValue - Get a pointer to a method that is invoked by this inst.
67 inline const Value *getCalledValue() const { return Operands[0]; }
68 inline Value *getCalledValue() { return Operands[0]; }
70 // Methods for support type inquiry through isa, cast, and dyn_cast:
71 static inline bool classof(const CallInst *) { return true; }
72 static inline bool classof(const Instruction *I) {
73 return I->getOpcode() == Instruction::Call;
75 static inline bool classof(const Value *V) {
76 return isa<Instruction>(V) && classof(cast<Instruction>(V));
81 //===----------------------------------------------------------------------===//
83 //===----------------------------------------------------------------------===//
85 // ShiftInst - This class represents left and right shift instructions.
87 class ShiftInst : public Instruction {
88 ShiftInst(const ShiftInst &SI) : Instruction(SI.getType(), SI.getOpcode()) {
90 Operands.push_back(Use(SI.Operands[0], this));
91 Operands.push_back(Use(SI.Operands[1], this));
94 ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "",
95 Instruction *InsertBefore = 0)
96 : Instruction(S->getType(), Opcode, Name, InsertBefore) {
97 assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
99 Operands.push_back(Use(S, this));
100 Operands.push_back(Use(SA, this));
103 OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
105 virtual Instruction *clone() const { return new ShiftInst(*this); }
107 // Methods for support type inquiry through isa, cast, and dyn_cast:
108 static inline bool classof(const ShiftInst *) { return true; }
109 static inline bool classof(const Instruction *I) {
110 return (I->getOpcode() == Instruction::Shr) |
111 (I->getOpcode() == Instruction::Shl);
113 static inline bool classof(const Value *V) {
114 return isa<Instruction>(V) && classof(cast<Instruction>(V));