#define LLVM_INSTRUCTION_TYPES_H
#include "llvm/Instruction.h"
-#include <list>
-#include <vector>
class Method;
class SymTabValue;
//
class TerminatorInst : public Instruction {
public:
- TerminatorInst(unsigned iType);
+ TerminatorInst(Instruction::TermOps iType);
+ TerminatorInst(const Type *Ty, Instruction::TermOps iType,
+ const string &Name = "");
inline ~TerminatorInst() {}
// Terminators must implement the methods required by Instruction...
inline BasicBlock *getSuccessor(unsigned idx) {
return (BasicBlock*)((const TerminatorInst *)this)->getSuccessor(idx);
}
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const TerminatorInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() >= FirstTermOp && I->getOpcode() < NumTermOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
// create() - Construct a unary instruction, given the opcode
// and its operand.
//
- static UnaryOperator *create(UnaryOps Op, Value *Source,
- const Type *DestTy = 0);
+ static UnaryOperator *create(UnaryOps Op, Value *Source);
- UnaryOperator(Value *S, UnaryOps iType, const Type *ResultType,
- const string &Name = "")
- : Instruction(ResultType, iType, Name) {
+ UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
+ : Instruction(S->getType(), iType, Name) {
Operands.reserve(1);
Operands.push_back(Use(S, this));
}
}
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 I->getOpcode() >= FirstUnaryOp && I->getOpcode() < NumUnaryOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
}
virtual const char *getOpcodeName() const = 0;
+
+ // swapOperands - Exchange the two operands to this instruction
+ void swapOperands() {
+ swap(Operands[0], Operands[1]);
+ }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BinaryOperator *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() >= FirstBinaryOp && I->getOpcode() < NumBinaryOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
};
#endif