diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -108,6 +108,28 @@ /// Return the operation that this refers to. Operation *getOperation() { return state; } + /// Return the dialect that this refers to. + Dialect *getDialect() { return getOperation()->getDialect(); } + + /// Return the parent Region of this operation. + Region *getParentRegion() { return getOperation()->getParentRegion(); } + + /// Returns the closest surrounding operation that contains this operation + /// or nullptr if this is a top-level operation. + Operation *getParentOp() { return getOperation()->getParentOp(); } + + /// Return the closest surrounding parent operation that is of type 'OpTy'. + template + OpTy getParentOfType() { + return getOperation()->getParentOfType(); + } + + /// Returns the closest surrounding parent operation with trait `Trait`. + template