[Mlir-commits] [mlir] [mlir] Method to iterate over registered operations for a given dialect class. (PR #112344)
Mehdi Amini
llvmlistbot at llvm.org
Wed Oct 16 13:31:50 PDT 2024
================
@@ -711,6 +714,26 @@ ArrayRef<RegisteredOperationName> MLIRContext::getRegisteredOperations() {
return impl->sortedRegisteredOperations;
}
+/// Return information for registered operations by dialect.
+ArrayRef<RegisteredOperationName>
+MLIRContext::getRegisteredOperationsByDialect(StringRef dialectName) {
+ auto lowerBound =
+ std::lower_bound(impl->sortedRegisteredOperations.begin(),
+ impl->sortedRegisteredOperations.end(), dialectName,
+ [](auto &lhs, auto &rhs) {
+ return lhs.getDialect().getNamespace().compare(
+ rhs.getDialect().getNamespace());
+ });
+
+ if (lowerBound == impl->sortedRegisteredOperations.end() ||
+ lowerBound->getDialect().getNamespace() != dialectName)
+ return ArrayRef<RegisteredOperationName>();
+
+ size_t count =
+ lowerBound->getDialect().getContext()->getImpl().operationCount;
----------------
joker-eph wrote:
`lowerBound->getDialect().getContext()` will return `this` pointer here: there is a single MLIRContext object in flight.
https://github.com/llvm/llvm-project/pull/112344
More information about the Mlir-commits
mailing list