This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Add begin-end iterators to MachineInstr
ClosedPublic

Authored by javed.absar on Jul 14 2017, 8:35 AM.

Details

Summary

Probably there are more use cases of this,
but I got triggered by the one included in this patch

Diff Detail

Event Timeline

javed.absar created this revision.Jul 14 2017, 8:35 AM

There is already MachineInstr::operands. Why do we need this?

rovka added a subscriber: echristo.
rovka added inline comments.
include/llvm/CodeGen/MachineInstr.h
308 ↗(On Diff #106643)

This looks identical to operands_begin/operands_end. I don't see a good reason for having both.
I don't know what to say about being concise vs being explicit in this context. @echristo, WDYT?

lib/Target/ARM/ARMMCInstLower.cpp
156

Unless I'm missing something (Friday evening etc etc), you can use

for (const auto &MO : MI->operands())

to the same effect.

echristo added inline comments.Jul 14 2017, 10:07 AM
lib/Target/ARM/ARMMCInstLower.cpp
156

Agreed, and it's more clear what you mean here.

Ok, I see that now too. Will use MI->operands() as suggested, as that will suffice.

javed.absar marked 2 inline comments as done.
rovka accepted this revision.Jul 17 2017, 1:30 AM

LGTM.

This revision is now accepted and ready to land.Jul 17 2017, 1:30 AM
This revision was automatically updated to reflect the committed changes.