#define LLVM_CODEGEN_MACHINEINSTR_H
#include "Support/Annotation.h"
-#include "Support/ilist"
+#include "Support/iterator"
#include <vector>
namespace llvm {
///
MachineOperandType getType() const { return opType; }
+ /// getUseType - Returns the MachineOperandUseType of this operand.
+ ///
+ MOTy::UseType getUseType() const {
+ return isUse() ^ isDef() ? MOTy::UseAndDef :
+ (isUse() ? MOTy::Use : MOTy::Def);
+ }
+
/// isPCRelative - This returns the value of the PCRELATIVE flag, which
/// indicates whether this operand should be emitted as a PC relative value
/// instead of a global address. This is used for operands of the forms:
}
// used to get the reg number if when one is allocated
- int getAllocatedRegNum() const {
+ unsigned getReg() const {
assert(hasAllocatedReg());
return regNum;
}
// ********** TODO: get rid of this duplicate code! ***********
- unsigned getReg() const {
- return getAllocatedRegNum();
- }
void setReg(unsigned Reg) {
assert(hasAllocatedReg() && "This operand cannot have a register number!");
regNum = Reg;
///
MachineInstr(MachineBasicBlock *MBB, short Opcode, unsigned numOps);
+ ~MachineInstr();
+
const MachineBasicBlock* getParent() const { return parent; }
MachineBasicBlock* getParent() { return parent; }
}
};
-// ilist_traits
-template <>
-class ilist_traits<MachineInstr>
-{
- typedef ilist_traits<MachineInstr> self;
-
- // this is only set by the MachineBasicBlock owning the ilist
- friend class MachineBasicBlock;
- MachineBasicBlock* parent;
-
-public:
- ilist_traits<MachineInstr>() : parent(0) { }
-
- static MachineInstr* getPrev(MachineInstr* N) { return N->prev; }
- static MachineInstr* getNext(MachineInstr* N) { return N->next; }
-
- static const MachineInstr*
- getPrev(const MachineInstr* N) { return N->prev; }
-
- static const MachineInstr*
- getNext(const MachineInstr* N) { return N->next; }
-
- static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; }
- static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; }
-
- static MachineInstr* createNode() { return new MachineInstr(0, 0); }
-
- void addNodeToList(MachineInstr* N) {
- assert(N->parent == 0 && "machine instruction already in a basic block");
- N->parent = parent;
- }
-
- void removeNodeFromList(MachineInstr* N) {
- assert(N->parent != 0 && "machine instruction not in a basic block");
- N->parent = 0;
- }
-
- void transferNodesFromList(iplist<MachineInstr, self>& toList,
- ilist_iterator<MachineInstr> first,
- ilist_iterator<MachineInstr> last) {
- if (parent != toList.parent)
- for (; first != last; ++first)
- first->parent = toList.parent;
- }
-};
-
//===----------------------------------------------------------------------===//
// Debugging Support