From 8e67039e31dc77f4762173c45052928983d0cb4e Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 30 Sep 2019 12:35:21 -0700 Subject: [PATCH] NFC: Change `classof` on registered operations to use pointer comparison. The current implementation always uses string comparison, but if the operation is registered the AbstractOperation instance can be used to provide faster pointer comparison. PiperOrigin-RevId: 272041333 --- mlir/include/mlir/IR/OpDefinition.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 9235659..6d99206 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -923,10 +923,9 @@ public: Region *getParentRegion() { return getOperation()->getParentRegion(); } /// Return true if this "op class" can match against the specified operation. - /// This hook can be overridden with a more specific implementation in - /// the subclass of Base. - /// static bool classof(Operation *op) { + if (auto *abstractOp = op->getAbstractOperation()) + return &classof == abstractOp->classof; return op->getName().getStringRef() == ConcreteType::getOperationName(); } -- 2.7.4