[all-commits] [llvm/llvm-project] 0f952c: [mlir][IR] Change `MutableOperandRange::operator[]...

Matthias Springer via All-commits all-commits at lists.llvm.org
Mon Sep 18 00:43:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0f952cfe24db4f498ad7a33518758954a77f4520
      https://github.com/llvm/llvm-project/commit/0f952cfe24db4f498ad7a33518758954a77f4520
  Author: Matthias Springer <me at m-sp.org>
  Date:   2023-09-18 (Mon, 18 Sep 2023)

  Changed paths:
    M mlir/include/mlir/IR/ValueRange.h
    M mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
    M mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
    M mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
    M mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
    M mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/IR/OperationSupport.cpp
    M mlir/lib/Transforms/Utils/CFGToSCF.cpp

  Log Message:
  -----------
  [mlir][IR] Change `MutableOperandRange::operator[]` to return an `OpOperand &` (#66515)

`operator[]` returns `OpOperand &` instead of `Value`.

* This allows users to get OpOperands by name instead of "magic" number.
E.g., `extractSliceOp->getOpOperand(0)` can be written as
`extractSliceOp.getSourceMutable()[0]`.
* `OperandRange` provides a read-only API to operands: `operator[]`
returns `Value`. `MutableOperandRange` now provides a mutable API:
`operator[]` returns `OpOperand &`, which can be used to set operands.

Note: The TableGen code generator could be changed to return `OpOperand
&` (instead of `MutableOperandRange`) for non-variadic and non-optional
arguments in a subsequent change. Then the `[0]` part in the above
example would no longer be necessary.




More information about the All-commits mailing list