From: bzcheeseman <12992886+bzcheeseman@users.noreply.github.com> Date: Wed, 11 May 2022 19:25:04 +0000 (-0400) Subject: [MLIR][Operation] Simplify Operation casting, NFC X-Git-Tag: upstream/15.0.7~7967 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc22b5c9a2f729460ffdf7627b3534a8d9f3f767;p=platform%2Fupstream%2Fllvm.git [MLIR][Operation] Simplify Operation casting, NFC We can simplify the code needed to implement dyn_cast/cast/isa support for MLIR operations with documented interfaces via the CastInfo structures. This will also provide an example of how to use CastInfo. Depends on D123901 Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D124963 --- diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 4594cb6..86b5a94 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -172,7 +172,8 @@ public: Operation *getParentOp() { return block ? block->getParentOp() : nullptr; } /// Return the closest surrounding parent operation that is of type 'OpTy'. - template OpTy getParentOfType() { + template + OpTy getParentOfType() { auto *op = this; while ((op = op->getParentOp())) if (auto parentOp = dyn_cast(op)) @@ -521,14 +522,16 @@ public: /// Returns true if the operation was registered with a particular trait, e.g. /// hasTrait(). - template