[PATCH] D35419: [CodeGen] Add begin-end iterators to MachineInstr
Javed Absar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 08:35:44 PDT 2017
javed.absar created this revision.
Probably there are more use cases of this,
but I got triggered by the one included in this patch
https://reviews.llvm.org/D35419
Files:
include/llvm/CodeGen/MachineInstr.h
lib/Target/ARM/ARMMCInstLower.cpp
Index: lib/Target/ARM/ARMMCInstLower.cpp
===================================================================
--- lib/Target/ARM/ARMMCInstLower.cpp
+++ lib/Target/ARM/ARMMCInstLower.cpp
@@ -153,9 +153,7 @@
break;
}
- for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
- const MachineOperand &MO = MI->getOperand(i);
-
+ for (auto MO : *MI) {
MCOperand MCOp;
if (AP.lowerOperand(MO, MCOp)) {
if (MCOp.isImm() && EncodeImms) {
Index: include/llvm/CodeGen/MachineInstr.h
===================================================================
--- include/llvm/CodeGen/MachineInstr.h
+++ include/llvm/CodeGen/MachineInstr.h
@@ -296,13 +296,17 @@
/// iterator/begin/end - Iterate over all operands of a machine instruction.
using mop_iterator = MachineOperand *;
using const_mop_iterator = const MachineOperand *;
+ using const_iterator = const MachineOperand *;
mop_iterator operands_begin() { return Operands; }
mop_iterator operands_end() { return Operands + NumOperands; }
const_mop_iterator operands_begin() const { return Operands; }
const_mop_iterator operands_end() const { return Operands + NumOperands; }
+ const_iterator begin() const { return Operands; }
+ const_iterator end() const { return Operands + NumOperands; }
+
iterator_range<mop_iterator> operands() {
return make_range(operands_begin(), operands_end());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35419.106643.patch
Type: text/x-patch
Size: 1405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170714/ce223d18/attachment.bin>
More information about the llvm-commits
mailing list