From 8ce2274d0d29cfd77d531ae0b3085ade5285dc4b Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sun, 1 Sep 2019 16:15:14 -0700 Subject: [PATCH] Add a convenient `clone()` method on the `Op` class that forward to the underlying `Operation` (NFC) PiperOrigin-RevId: 266685852 --- mlir/include/mlir/IR/OpDefinition.h | 10 ++++++++++ mlir/include/mlir/IR/Operation.h | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 883e994..7edd56a 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -906,6 +906,16 @@ public: /// Return the operation that this refers to. Operation *getOperation() { return OpState::getOperation(); } + /// Create a deep copy of this operation. + ConcreteType clone() { return cast(getOperation()->clone()); } + + /// Create a partial copy of this operation without traversing into attached + /// regions. The new operation will have the same number of regions as the + /// original one, but they will be left empty. + ConcreteType cloneWithoutRegions() { + return cast(getOperation()->cloneWithoutRegions()); + } + /// Return the dialect that this refers to. Dialect *getDialect() { return getOperation()->getDialect(); } diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 97225d0..76e6c77 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -94,10 +94,16 @@ public: Operation *clone(BlockAndValueMapping &mapper); Operation *clone(); - /// Create a deep copy of this operation but keep the operation regions empty. + /// Create a partial copy of this operation without traversing into attached + /// regions. The new operation will have the same number of regions as the + /// original one, but they will be left empty. /// Operands are remapped using `mapper` (if present), and `mapper` is updated /// to contain the results. Operation *cloneWithoutRegions(BlockAndValueMapping &mapper); + + /// Create a partial copy of this operation without traversing into attached + /// regions. The new operation will have the same number of regions as the + /// original one, but they will be left empty. Operation *cloneWithoutRegions(); /// Returns the operation block that contains this operation. -- 2.7.4