X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FMC%2FMCRegisterInfo.h;h=a4d5e0867232025715a9b2f09bde66c44156b25a;hb=6e17bb78bae19a9e2462aa0542eea5d0e3cf7478;hp=e02f35d2cddf0db98d32703f10b53c08f227543e;hpb=84cc6ec88948083632c6aa4db586e8d576be1b31;p=oota-llvm.git diff --git a/include/llvm/MC/MCRegisterInfo.h b/include/llvm/MC/MCRegisterInfo.h index e02f35d2cdd..a4d5e086723 100644 --- a/include/llvm/MC/MCRegisterInfo.h +++ b/include/llvm/MC/MCRegisterInfo.h @@ -233,6 +233,7 @@ public: // These iterators are allowed to sub-class DiffListIterator and access // internal list pointers. friend class MCSubRegIterator; + friend class MCSubRegIndexIterator; friend class MCSuperRegIterator; friend class MCRegUnitIterator; friend class MCRegUnitMaskIterator; @@ -461,6 +462,38 @@ public: } }; +/// Iterator that enumerates the sub-registers of a Reg and the associated +/// sub-register indices. +class MCSubRegIndexIterator { + MCSubRegIterator SRIter; + const uint16_t *SRIndex; +public: + /// Constructs an iterator that traverses subregisters and their + /// associated subregister indices. + MCSubRegIndexIterator(unsigned Reg, const MCRegisterInfo *MCRI) + : SRIter(Reg, MCRI) { + SRIndex = MCRI->SubRegIndices + MCRI->get(Reg).SubRegIndices; + } + + /// Returns current sub-register. + unsigned getSubReg() const { + return *SRIter; + } + /// Returns sub-register index of the current sub-register. + unsigned getSubRegIndex() const { + return *SRIndex; + } + + /// Returns true if this iterator is not yet at the end. + bool isValid() const { return SRIter.isValid(); } + + /// Moves to the next position. + void operator++() { + ++SRIter; + ++SRIndex; + } +}; + /// MCSuperRegIterator enumerates all super-registers of Reg. /// If IncludeSelf is set, Reg itself is included in the list. class MCSuperRegIterator : public MCRegisterInfo::DiffListIterator { @@ -599,7 +632,7 @@ private: unsigned Reg; const MCRegisterInfo *MCRI; bool IncludeSelf; - + MCRegUnitIterator RI; MCRegUnitRootIterator RRI; MCSuperRegIterator SI; @@ -619,10 +652,8 @@ public: } } - bool isValid() const { - return RI.isValid(); - } - + bool isValid() const { return RI.isValid(); } + unsigned operator*() const { assert (SI.isValid() && "Cannot dereference an invalid iterator."); return *SI;