[Mlir-commits] [mlir] [mlir][python] Expose AsmState python side. (PR #66819)
Jacques Pienaar
llvmlistbot at llvm.org
Wed Sep 20 11:22:44 PDT 2023
================
@@ -748,6 +748,31 @@ class PyRegion {
MlirRegion region;
};
+/// Wrapper around an MlirAsmState.
+class PyAsmState {
+ public:
+ PyAsmState(MlirValue value, bool useLocalScope) {
+ flags = mlirOpPrintingFlagsCreate();
+ // The OpPrintingFlags are not exposed Python side, create locally and
+ // associate lifetime with the state.
+ if (useLocalScope)
+ mlirOpPrintingFlagsUseLocalScope(flags);
+ state = mlirAsmStateCreateForValue(value, flags);
+ }
+ ~PyAsmState() {
+ mlirOpPrintingFlagsDestroy(flags);
+ }
+ // Delete copy constructors.
+ PyAsmState(PyAsmState &other) = delete;
+ PyAsmState(const PyAsmState &other) = delete;
----------------
jpienaar wrote:
Its to avoid accidentally copying this and then having the flags get destroyed multiple times in the copy's destructor (I was using a wrong accessor and ended up copying these, so avoid the footgun for myself :)).
https://github.com/llvm/llvm-project/pull/66819
More information about the Mlir-commits
mailing list