DenseMap<unsigned, int> L2SEHRegs; // LLVM to SEH regs mapping
public:
+ /// RegListIterator. This iterator class is used to traverse lists of
+ /// super-registers, sub-registers, and overlapping registers. Don't use it
+ /// directly, use one of the sub-classes defined below.
+ class RegListIterator {
+ const uint16_t *Pos;
+ public:
+ explicit RegListIterator(const uint16_t *Table)
+ : Pos(Table) {}
+
+ /// isValid - Return false when the end of the list is reached.
+ bool isValid() const { return *Pos; }
+
+ /// Dereference the iterator to get the current register.
+ unsigned operator*() const { return *Pos; }
+
+ /// Pre-increment. Move to the next register.
+ void operator++() { ++Pos; }
+ };
+
/// DiffListIterator - Base iterator class that can traverse the
/// differentially encoded register and regunit lists in DiffLists.
/// Don't use this class directly, use one of the specialized sub-classes
}
};
- // These iterators are allowed to sub-class DiffListIterator and access
- // internal list pointers.
+ // These iterators are allowed to sub-class RegListIterator and
+ // DiffListIterator and access internal list pointers.
+ friend class MCSubRegIterator;
+ friend class MCSuperRegIterator;
+ friend class MCRegAliasIterator;
friend class MCRegUnitIterator;
/// InitMCRegisterInfo - Initialize MCRegisterInfo, called by TableGen
};
+//===----------------------------------------------------------------------===//
+// Register List Iterators
+//===----------------------------------------------------------------------===//
+
+// MCRegisterInfo provides lists of super-registers, sub-registers, and
+// aliasing registers. Use these iterator classes to traverse the lists.
+
+/// MCSubRegIterator enumerates all sub-registers of Reg.
+class MCSubRegIterator : public MCRegisterInfo::RegListIterator {
+public:
+ MCSubRegIterator(unsigned Reg, const MCRegisterInfo *MCRI)
+ : RegListIterator(MCRI->RegLists + MCRI->get(Reg).SubRegs) {}
+};
+
+/// MCSuperRegIterator enumerates all super-registers of Reg.
+class MCSuperRegIterator : public MCRegisterInfo::RegListIterator {
+public:
+ MCSuperRegIterator(unsigned Reg, const MCRegisterInfo *MCRI)
+ : RegListIterator(MCRI->RegLists + MCRI->get(Reg).SuperRegs) {}
+};
+
+/// MCRegAliasIterator enumerates all registers aliasing Reg.
+/// If IncludeSelf is set, Reg itself is included in the list.
+class MCRegAliasIterator : public MCRegisterInfo::RegListIterator {
+public:
+ MCRegAliasIterator(unsigned Reg, const MCRegisterInfo *MCRI, bool IncludeSelf)
+ : RegListIterator(MCRI->RegLists + MCRI->get(Reg).Overlaps + !IncludeSelf)
+ {}
+};
+
//===----------------------------------------------------------------------===//
// Register Units
//===----------------------------------------------------------------------===//