#define LLVM_INSTRUCTION_H
#include "llvm/User.h"
+#include "Support/Annotation.h"
-class AssemblyAnnotationWriter;
+namespace llvm {
+
+struct AssemblyAnnotationWriter;
template<typename SC> struct ilist_traits;
template<typename ValueSubClass, typename ItemParentClass, typename SymTabClass,
typename SubClass> class SymbolTableListTraits;
-class Instruction : public User {
+class Instruction : public User, public Annotable {
BasicBlock *Parent;
Instruction *Prev, *Next; // Next and Prev links for our intrusive linked list
friend class SymbolTableListTraits<Instruction, BasicBlock, Function,
ilist_traits<Instruction> >;
void setParent(BasicBlock *P);
+ void init();
+
protected:
unsigned iType; // InstructionType: The opcode of the instruction
Instruction(const Type *Ty, unsigned iType, const std::string &Name = "",
Instruction *InsertBefore = 0);
+ Instruction(const Type *Ty, unsigned iType, const std::string &Name,
+ BasicBlock *InsertAtEnd);
public:
+ ~Instruction() {
+ assert(Parent == 0 && "Instruction still linked in the program!");
+ }
+
// Specialize setName to handle symbol table majik...
virtual void setName(const std::string &name, SymbolTable *ST = 0);
}
static const char* getOpcodeName(unsigned OpCode);
+ static inline bool isTerminator(unsigned OpCode) {
+ return OpCode >= TermOpsBegin && OpCode < TermOpsEnd;
+ }
+
inline bool isTerminator() const { // Instance of TerminatorInst?
- return iType >= TermOpsBegin && iType < TermOpsEnd;
+ return isTerminator(iType);
}
+
inline bool isBinaryOp() const {
return iType >= BinaryOpsBegin && iType < BinaryOpsEnd;
}
bool isCommutative() const { return isCommutative(getOpcode()); }
static bool isCommutative(unsigned op);
+ /// isRelational - Return true if the instruction is a Set* instruction:
+ ///
+ bool isRelational() const { return isRelational(getOpcode()); }
+ static bool isRelational(unsigned op);
+
+
/// isTrappingInstruction - Return true if the instruction may trap.
///
bool isTrapping() const {
};
};
+} // End llvm namespace
+
#endif