[llvm] [NFC][LLVM] Refactor MachineInstr operand accessors (PR #137261)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 08:50:15 PDT 2025
================
@@ -676,68 +672,61 @@ class MachineInstr
const_mop_iterator operands_begin() const { return Operands; }
const_mop_iterator operands_end() const { return Operands + NumOperands; }
- iterator_range<mop_iterator> operands() {
- return make_range(operands_begin(), operands_end());
+ MutableArrayRef<MachineOperand> operands() {
----------------
jurahul wrote:
Thanks. I see your point. `iterator_range<>` does not have a `[]` operator, so it's not possible for clients to use direct indexing, but with `ArrarRef` they can. My slight pushback is that `mop_iterator` itself is a pointer, so nothing prevents someone to do `operands_begin()[i]` today as well, so in that sense the sequential nature of the store is still exposed through that API, just that with `ArrayRef` it will be exposed at more places. May be a compromise is to use `ArrayRef` internally in the impl of these functions (which is really what I was after). Let me give that a stab and we can see if its worth it.
https://github.com/llvm/llvm-project/pull/137261
More information about the llvm-commits
mailing list