diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -310,6 +310,9 @@ /// Return the name of the dialect this operation is registered to. StringRef getDialect() const; + /// Return the operation name with dialect name stripped, if it has one. + StringRef stripDialect() const; + /// Return the name of this operation. This always succeeds. StringRef getStringRef() const; diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -38,6 +38,12 @@ return getStringRef().split('.').first; } +/// Return the operation name with dialect name stripped, if it has one. +StringRef OperationName::stripDialect() const { + auto splitName = getStringRef().split("."); + return splitName.second.empty() ? splitName.first : splitName.second; +} + /// Return the name of this operation. This always succeeds. StringRef OperationName::getStringRef() const { if (auto *op = representation.dyn_cast())