+private:
+ void HandleVRegListReallocation();
+
+public:
+ /// defusechain_iterator - This class provides iterator support for machine
+ /// operands in the function that use or define a specific register. If
+ /// ReturnUses is true it returns uses of registers, if ReturnDefs is true it
+ /// returns defs. If neither are true then you are silly and it always
+ /// returns end().
+ template<bool ReturnUses, bool ReturnDefs>
+ class defusechain_iterator
+ : public forward_iterator<MachineInstr, ptrdiff_t> {
+ MachineOperand *Op;
+ defusechain_iterator(MachineOperand *op) : Op(op) {
+ // If the first node isn't one we're interested in, advance to one that
+ // we are interested in.
+ if (op) {
+ if (!ReturnUses && op->isUse() ||
+ !ReturnDefs && op->isDef())
+ ++*this;
+ }
+ }
+ friend class MachineRegisterInfo;
+ public:
+ typedef forward_iterator<MachineInstr, ptrdiff_t>::reference reference;
+ typedef forward_iterator<MachineInstr, ptrdiff_t>::pointer pointer;
+
+ defusechain_iterator(const defusechain_iterator &I) : Op(I.Op) {}
+ defusechain_iterator() : Op(0) {}
+
+ bool operator==(const defusechain_iterator &x) const {
+ return Op == x.Op;
+ }
+ bool operator!=(const defusechain_iterator &x) const {
+ return !operator==(x);
+ }
+
+ /// atEnd - return true if this iterator is equal to reg_end() on the value.
+ bool atEnd() const { return Op == 0; }
+
+ // Iterator traversal: forward iteration only
+ defusechain_iterator &operator++() { // Preincrement
+ assert(Op && "Cannot increment end iterator!");
+ Op = Op->getNextOperandForReg();
+
+ // If this is an operand we don't care about, skip it.
+ while (Op && (!ReturnUses && Op->isUse() ||
+ !ReturnDefs && Op->isDef()))
+ Op = Op->getNextOperandForReg();
+
+ return *this;
+ }
+ defusechain_iterator operator++(int) { // Postincrement
+ defusechain_iterator tmp = *this; ++*this; return tmp;
+ }
+
+ MachineOperand &getOperand() const {
+ assert(Op && "Cannot dereference end iterator!");
+ return *Op;
+ }
+
+ /// getOperandNo - Return the operand # of this MachineOperand in its
+ /// MachineInstr.
+ unsigned getOperandNo() const {
+ assert(Op && "Cannot dereference end iterator!");
+ return Op - &Op->getParent()->getOperand(0);
+ }
+
+ // Retrieve a reference to the current operand.
+ MachineInstr &operator*() const {
+ assert(Op && "Cannot dereference end iterator!");
+ return *Op->getParent();
+ }
+
+ MachineInstr *operator->() const {
+ assert(Op && "Cannot dereference end iterator!");
+ return Op->getParent();
+ }
+ };
+