diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h index a2e080ef4f63f..77c2f314a9345 100644 --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -35,7 +35,7 @@ class BlockOperand : public IROperand { static IRObjectWithUseList *getUseList(Block *value); /// Return which operand this is in the BlockOperand list of the Operation. - unsigned getOperandNumber(); + unsigned getOperandNumber() const; }; //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index e72ace0920eb1..79d3fc5fd8a59 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -259,7 +259,7 @@ class OpOperand : public IROperand { } /// Return which operand this is in the OpOperand list of the Operation. - unsigned getOperandNumber(); + unsigned getOperandNumber() const; /// Set the current value being used by this operand. void assign(Value value) { set(value); } diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index fa550e4d5d5d0..cf793680f7efd 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -214,7 +214,7 @@ IRObjectWithUseList *BlockOperand::getUseList(Block *value) { } /// Return which operand this is in the operand list. -unsigned BlockOperand::getOperandNumber() { +unsigned BlockOperand::getOperandNumber() const { return this - &getOwner()->getBlockOperands()[0]; } @@ -223,6 +223,6 @@ unsigned BlockOperand::getOperandNumber() { //===----------------------------------------------------------------------===// /// Return which operand this is in the operand list. -unsigned OpOperand::getOperandNumber() { +unsigned OpOperand::getOperandNumber() const { return this - &getOwner()->getOpOperands()[0]; }