From 0cf7e4b252fe1458fddb8e3dbfcae43450e9c04c Mon Sep 17 00:00:00 2001 From: Christian Sigg Date: Mon, 14 Dec 2020 22:45:37 +0100 Subject: [PATCH] Revert "[mlir] Remove methods from mlir::OpState that just forward to mlir::Operation." This reverts commit 6f271e921ba48f4c4fa54bbd2c7a4c548ca5e59e. Differential Revision: https://reviews.llvm.org/D93242 --- mlir/include/mlir/IR/OpDefinition.h | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 2edc48d..9e4da63 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -108,6 +108,28 @@ public: /// 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