// Terminators must implement the methods required by Instruction...
virtual Instruction *clone() const = 0;
- virtual const char *getOpcodeName() const = 0;
// Additionally, they must provide a method to get at the successors of this
// terminator instruction. 'idx' may not be >= the number of successors
return create(getOpcode(), Operands[0]);
}
- virtual const char *getOpcodeName() const = 0;
-
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const UnaryOperator *) { return true; }
static inline bool classof(const Instruction *I) {
return create(getOpcode(), Operands[0], Operands[1]);
}
- virtual const char *getOpcodeName() const = 0;
-
// swapOperands - Exchange the two operands to this instruction.
// This instruction is safe to use on any binary instruction and
// does not modify the semantics of the instruction. If the
// Subclass classification... getOpcode() returns a member of
// one of the enums that is coming soon (down below)...
//
- virtual const char *getOpcodeName() const = 0;
unsigned getOpcode() const { return iType; }
+ virtual const char *getOpcodeName() const {
+ return getOpcodeName(getOpcode());
+ }
+ static const char* getOpcodeName(unsigned OpCode);
inline bool isTerminator() const { // Instance of TerminatorInst?
return iType >= FirstTermOp && iType < NumTermOps;
return new MallocInst((Type*)getType(), (Value*)Operands[0].get());
}
- virtual const char *getOpcodeName() const { return "malloc"; }
-
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const MallocInst *) { return true; }
static inline bool classof(const Instruction *I) {
return new AllocaInst((Type*)getType(), (Value*)Operands[0].get());
}
- virtual const char *getOpcodeName() const { return "alloca"; }
-
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const AllocaInst *) { return true; }
static inline bool classof(const Instruction *I) {
virtual Instruction *clone() const { return new FreeInst(Operands[0]); }
- virtual const char *getOpcodeName() const { return "free"; }
-
virtual bool hasSideEffects() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
LoadInst(Value *Ptr, const std::string &Name = "");
virtual Instruction *clone() const { return new LoadInst(*this); }
- virtual const char *getOpcodeName() const { return "load"; }
virtual unsigned getFirstIndexOperandNumber() const { return 1; }
StoreInst(Value *Val, Value *Ptr);
virtual Instruction *clone() const { return new StoreInst(*this); }
- virtual const char *getOpcodeName() const { return "store"; }
-
virtual bool hasSideEffects() const { return true; }
virtual unsigned getFirstIndexOperandNumber() const { return 2; }
GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
const std::string &Name = "");
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
- virtual const char *getOpcodeName() const { return "getelementptr"; }
virtual unsigned getFirstIndexOperandNumber() const { return 1; }
// getType - Overload to return most specific pointer type...
GenericUnaryInst(UnaryOps Opcode, Value *S1, const std::string &Name = "")
: UnaryOperator(S1, Opcode, Name) {
}
-
- virtual const char *getOpcodeName() const;
};
//===----------------------------------------------------------------------===//
const std::string &Name = "")
: BinaryOperator(Opcode, S1, S2, Name) {
}
-
- virtual const char *getOpcodeName() const;
};
class SetCondInst : public BinaryOperator {
public:
SetCondInst(BinaryOps opType, Value *S1, Value *S2,
const std::string &Name = "");
-
- virtual const char *getOpcodeName() const;
};
#endif
}
virtual Instruction *clone() const { return new CastInst(*this); }
- virtual const char *getOpcodeName() const { return "cast"; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const CastInst *) { return true; }
public:
CallInst(Value *M, const std::vector<Value*> &Par, const std::string & = "");
- virtual const char *getOpcodeName() const { return "call"; }
-
virtual Instruction *clone() const { return new CallInst(*this); }
bool hasSideEffects() const { return true; }
OtherOps getOpcode() const { return (OtherOps)Instruction::getOpcode(); }
virtual Instruction *clone() const { return new ShiftInst(*this); }
- virtual const char *getOpcodeName() const {
- return getOpcode() == Shl ? "shl" : "shr";
- }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ShiftInst *) { return true; }
PHINode(const Type *Ty, const std::string &Name = "");
virtual Instruction *clone() const { return new PHINode(*this); }
- virtual const char *getOpcodeName() const { return "phi"; }
// getNumIncomingValues - Return the number of incoming edges the PHI node has
inline unsigned getNumIncomingValues() const { return Operands.size()/2; }
virtual Instruction *clone() const { return new ReturnInst(*this); }
- virtual const char *getOpcodeName() const { return "ret"; }
-
inline const Value *getReturnValue() const {
return Operands.size() ? Operands[0].get() : 0;
}
return isUnconditional() ? 0 : Operands[2].get();
}
- virtual const char *getOpcodeName() const { return "br"; }
-
// setUnconditionalDest - Change the current branch to an unconditional branch
// targeting the specified block.
//
void dest_push_back(Constant *OnVal, BasicBlock *Dest);
- virtual const char *getOpcodeName() const { return "switch"; }
-
virtual const BasicBlock *getSuccessor(unsigned idx) const {
assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");
return cast<BasicBlock>(Operands[idx*2+1].get());
Operands[2] = (Value*)B;
}
- virtual const char *getOpcodeName() const { return "invoke"; }
-
virtual const BasicBlock *getSuccessor(unsigned i) const {
assert(i < 2 && "Successor # out of range for invoke!");
return i == 0 ? getNormalDest() : getExceptionalDest();