[PATCH] D35419: [CodeGen] Add begin-end iterators to MachineInstr

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 09:26:28 PDT 2017


rovka added a reviewer: echristo.
rovka added a subscriber: echristo.
rovka added inline comments.


================
Comment at: include/llvm/CodeGen/MachineInstr.h:308
+  const_iterator begin() const { return Operands; }
+  const_iterator end() const { return Operands + NumOperands; }
+
----------------
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?


================
Comment at: lib/Target/ARM/ARMMCInstLower.cpp:156
 
-  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
-    const MachineOperand &MO = MI->getOperand(i);
-
+  for (auto MO : *MI) {
     MCOperand MCOp;
----------------
Unless I'm missing something (Friday evening etc etc), you can use 
```
for (const auto &MO : MI->operands())
``` 
to the same effect.


https://reviews.llvm.org/D35419





More information about the llvm-commits mailing list