[Mlir-commits] [mlir] [MLIR][Python] Make the TypeID allocator globally defined in `PassManager.add` (PR #162594)
Maksim Levental
llvmlistbot at llvm.org
Wed Oct 8 21:15:53 PDT 2025
================
@@ -52,6 +52,23 @@ class PyPassManager {
MlirPassManager passManager;
};
+class PyTypeIDAllocator {
+public:
+ PyTypeIDAllocator() : allocator(mlirTypeIDAllocatorCreate()) {}
+ ~PyTypeIDAllocator() {
+ if (!allocator.ptr)
+ mlirTypeIDAllocatorDestroy(allocator);
+ }
+
+ MlirTypeIDAllocator get() { return allocator; }
+ MlirTypeID allocate() { return mlirTypeIDAllocatorAllocateTypeID(allocator); }
+
+private:
+ MlirTypeIDAllocator allocator;
+};
+
+PyTypeIDAllocator globalTypeIDAllocator;
----------------
makslevental wrote:
Better to put this into PyGlobals https://github.com/llvm/llvm-project/blob/1244fd24d9b61cfcebc12a05726a8fc82da0109e/mlir/lib/Bindings/Python/Globals.h#L174
https://github.com/llvm/llvm-project/pull/162594
More information about the Mlir-commits
mailing list