This is an archive of the discontinued LLVM Phabricator instance.

[MC] Use regunits instead of MCRegUnitIterator. NFC.
ClosedPublic

Authored by foad on Jun 16 2023, 3:27 AM.

Diff Detail

Event Timeline

foad created this revision.Jun 16 2023, 3:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 3:27 AM
foad requested review of this revision.Jun 16 2023, 3:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 3:27 AM
foad added inline comments.Jun 16 2023, 3:28 AM
llvm/lib/MC/MCRegisterInfo.cpp
138

This still mentions MCRegUnitIterator but it gets away from the non-standard isValid style of iteration, towards the standard iterator_range style.

barannikov88 added inline comments.Jun 16 2023, 3:41 AM
llvm/lib/MC/MCRegisterInfo.cpp
138

This still mentions MCRegUnitIterator

I think this is fine.

(suggestion) The default constructor of MCRegUnitIterator creates an end iterator, it can be used to simplify code a bit:

...
MCRegUnitIterator IA = regunits(RegA).begin();
MCRegUnitIterator IB = regunits(RegB).begin();
MCRegUnitIterator E;
...
} while (*IA < *IB ? ++IA != E : ++IB != E);
llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
1023

There is range_size just for this.

foad added inline comments.Jun 16 2023, 3:52 AM
llvm/lib/MC/MCRegisterInfo.cpp
138

That is certainly simpler, but less standard. I'm not sure which I prefer.

llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
1023

Thanks! But why don't we have iterator_range::size like Boost does?

foad updated this revision to Diff 532082.Jun 16 2023, 3:54 AM

Use range_size.

barannikov88 added inline comments.Jun 16 2023, 4:09 AM
llvm/lib/MC/MCRegisterInfo.cpp
138

std::istreambuf_iterator behaves similarly.

llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
1023

Probably no one took care of implementing it. There is only a handful uses of this function.

barannikov88 accepted this revision.Jun 16 2023, 4:10 AM
This revision is now accepted and ready to land.Jun 16 2023, 4:10 AM
This revision was landed with ongoing or failed builds.Jun 16 2023, 4:21 AM
This revision was automatically updated to reflect the committed changes.