[Mlir-commits] [mlir] [MLIR] Add a non-const ActionHandler getter to MLIRContext (PR #199652)
Kigyosi Alexandru
llvmlistbot at llvm.org
Tue May 26 21:06:05 PDT 2026
https://github.com/akigyosi updated https://github.com/llvm/llvm-project/pull/199652
>From ddd6c56015e3712b437b7ceb6f97400008921b39 Mon Sep 17 00:00:00 2001
From: Alexandru Kigyosi <alexandru.kigyosi at intel.com>
Date: Tue, 26 May 2026 10:20:53 +0000
Subject: [PATCH 1/2] non-const getter
---
mlir/include/mlir/IR/MLIRContext.h | 3 ++-
mlir/lib/IR/MLIRContext.cpp | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h
index ab121777a1296..d2e0c4a9a1b7f 100644
--- a/mlir/include/mlir/IR/MLIRContext.h
+++ b/mlir/include/mlir/IR/MLIRContext.h
@@ -269,7 +269,8 @@ class MLIRContext {
/// Return a reference to the currently registered action handler. Its target
/// can be used to gain access to the handler's state, if any.
- const HandlerTy &getActionHandler();
+ const HandlerTy &getActionHandler() const;
+ HandlerTy &getActionHandler();
/// Return true if a valid ActionHandler is set.
bool hasActionHandler();
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 624121c2733ba..da891a7e6e014 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -380,7 +380,11 @@ void MLIRContext::registerActionHandler(HandlerTy handler) {
getImpl().actionHandler = std::move(handler);
}
-const MLIRContext::HandlerTy &MLIRContext::getActionHandler() {
+const MLIRContext::HandlerTy &MLIRContext::getActionHandler() const {
+ return getImpl().actionHandler;
+}
+
+MLIRContext::HandlerTy &MLIRContext::getActionHandler() {
return getImpl().actionHandler;
}
>From 9255e23c116c91c19350f5b46335e72920393e3e Mon Sep 17 00:00:00 2001
From: Alexandru Kigyosi <alexandru.kigyosi at intel.com>
Date: Tue, 26 May 2026 10:33:32 +0000
Subject: [PATCH 2/2] geimpl const
---
mlir/include/mlir/IR/MLIRContext.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h
index d2e0c4a9a1b7f..12cd00b60215e 100644
--- a/mlir/include/mlir/IR/MLIRContext.h
+++ b/mlir/include/mlir/IR/MLIRContext.h
@@ -211,6 +211,7 @@ class MLIRContext {
// This is effectively private given that only MLIRContext.cpp can see the
// MLIRContextImpl type.
MLIRContextImpl &getImpl() { return *impl; }
+ const MLIRContextImpl &getImpl() const { return *impl; }
/// Returns the diagnostic engine for this context.
DiagnosticEngine &getDiagEngine();
More information about the Mlir-commits
mailing list