[llvm] r182490 - Add the IncludeSelf parameter to the MCSubRegIterator and MCSuperRegIterator
Chad Rosier
mcrosier at apple.com
Wed May 22 15:28:54 PDT 2013
On May 22, 2013, at 11:49 AM, Chad Rosier <mcrosier at apple.com> wrote:
>
> On May 22, 2013, at 11:46 AM, Rafael EspĂndola <rafael.espindola at gmail.com> wrote:
>
>> On 22 May 2013 13:26, Chad Rosier <mcrosier at apple.com> wrote:
>>> Author: mcrosier
>>> Date: Wed May 22 12:26:26 2013
>>> New Revision: 182490
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=182490&view=rev
>>> Log:
>>> Add the IncludeSelf parameter to the MCSubRegIterator and MCSuperRegIterator
>>> constructors. No functional change.
>>> Part of rdar://12906217
>>
>> Can you provide a bit more context on how this will be used?
>
> This can simplify a few things. For example, LiveVariables.cpp has a lot of code like this:
>
> Live.insert(SubReg);
> for (MCSubRegIterator SS(SubReg, TRI); SS.isValid(); ++SS)
> Live.insert(*SS);
>
> An includeSelf argument would be useful here. I.e.,
>
> for (MCSubRegIterator SS(SubReg, TRI, /*IncludeSelf=*/true); SS.isValid(); ++SS)
> Live.insert(*SS);
Cleaned up LiveVariables.cpp in revision 182526.
> My forthcoming patch uses it in a similar way. Hope this helps.
>
> Chad
>
>>
>>> Modified:
>>> llvm/trunk/include/llvm/MC/MCRegisterInfo.h
>>>
>>> Modified: llvm/trunk/include/llvm/MC/MCRegisterInfo.h
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCRegisterInfo.h?rev=182490&r1=182489&r2=182490&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/MC/MCRegisterInfo.h (original)
>>> +++ llvm/trunk/include/llvm/MC/MCRegisterInfo.h Wed May 22 12:26:26 2013
>>> @@ -421,20 +421,28 @@ public:
>>> // aliasing registers. Use these iterator classes to traverse the lists.
>>>
>>> /// MCSubRegIterator enumerates all sub-registers of Reg.
>>> +/// If IncludeSelf is set, Reg itself is included in the list.
>>> class MCSubRegIterator : public MCRegisterInfo::DiffListIterator {
>>> public:
>>> - MCSubRegIterator(unsigned Reg, const MCRegisterInfo *MCRI) {
>>> + MCSubRegIterator(unsigned Reg, const MCRegisterInfo *MCRI,
>>> + bool IncludeSelf = false) {
>>> init(Reg, MCRI->DiffLists + MCRI->get(Reg).SubRegs);
>>> - ++*this;
>>> + // Initially, the iterator points to Reg itself.
>>> + if (!IncludeSelf)
>>> + ++*this;
>>> }
>>> };
>>>
>>> /// MCSuperRegIterator enumerates all super-registers of Reg.
>>> +/// If IncludeSelf is set, Reg itself is included in the list.
>>> class MCSuperRegIterator : public MCRegisterInfo::DiffListIterator {
>>> public:
>>> - MCSuperRegIterator(unsigned Reg, const MCRegisterInfo *MCRI) {
>>> + MCSuperRegIterator(unsigned Reg, const MCRegisterInfo *MCRI,
>>> + bool IncludeSelf = false) {
>>> init(Reg, MCRI->DiffLists + MCRI->get(Reg).SuperRegs);
>>> - ++*this;
>>> + // Initially, the iterator points to Reg itself.
>>> + if (!IncludeSelf)
>>> + ++*this;
>>> }
>>> };
>>>
>>> @@ -443,7 +451,7 @@ public:
>>> class MCRegAliasIterator : public MCRegisterInfo::DiffListIterator {
>>> public:
>>> MCRegAliasIterator(unsigned Reg, const MCRegisterInfo *MCRI,
>>> - bool IncludeSelf) {
>>> + bool IncludeSelf = false) {
>>> init(Reg, MCRI->DiffLists + MCRI->get(Reg).Overlaps);
>>> // Initially, the iterator points to Reg itself.
>>> if (!IncludeSelf)
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list