When folding memory operands in machine instructions be careful to
[oota-llvm.git] / include / llvm / CodeGen / MachineInstr.h
index 8f010917c6caf2ac5319b4b5781d57e0c22576b6..65d5ccae70a7f37c4d40c92daa26f00c83a15357 100644 (file)
@@ -17,7 +17,7 @@
 #define LLVM_CODEGEN_MACHINEINSTR_H
 
 #include "Support/Annotation.h"
-#include "Support/ilist"
+#include "Support/iterator"
 #include <vector>
 
 namespace llvm {
@@ -197,6 +197,13 @@ public:
   /// 
   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:
@@ -277,15 +284,12 @@ public:
   }
 
   // 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;
@@ -365,6 +369,8 @@ public:
   ///
   MachineInstr(MachineBasicBlock *MBB, short Opcode, unsigned numOps);
   
+  ~MachineInstr();
+
   const MachineBasicBlock* getParent() const { return parent; }
   MachineBasicBlock* getParent() { return parent; }
 
@@ -694,52 +700,6 @@ public:
   }
 };
 
-// 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