[PATCH] D153122: [MC] Use regunits instead of MCRegUnitIterator. NFC.

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 03:41:54 PDT 2023


barannikov88 added inline comments.


================
Comment at: llvm/lib/MC/MCRegisterInfo.cpp:138
+  auto RangeA = regunits(RegA);
+  MCRegUnitIterator IA = RangeA.begin(), EA = RangeA.end();
+  auto RangeB = regunits(RegB);
----------------
foad wrote:
> This still mentions `MCRegUnitIterator` but it gets away from the non-standard `isValid` style of iteration, towards the standard `iterator_range` style.
> 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);
```



================
Comment at: llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp:1023
+    auto CCUnits = TRI->regunits(MCRegister::from(SystemZ::CC));
+    assert(std::distance(CCUnits.begin(), CCUnits.end()) == 1 &&
+           "CC only has one reg unit.");
----------------
There is `range_size` just for this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153122/new/

https://reviews.llvm.org/D153122



More information about the llvm-commits mailing list