diff options
author | Jacques Pienaar <jpienaar@google.com> | 2023-09-25 12:25:08 -0700 |
---|---|---|
committer | Jacques Pienaar <jpienaar@google.com> | 2023-09-25 12:25:08 -0700 |
commit | a677a173273f7735a3a5447a47851591b984e7aa (patch) | |
tree | 102c247520f87c8cc99dad328a38f41e54fe7436 /mlir/lib/Bindings/Python/IRModule.h | |
parent | 8586cd5ad8a7fa4f84b5913cbeaf634d68500095 (diff) | |
download | llvm-a677a173273f7735a3a5447a47851591b984e7aa.zip llvm-a677a173273f7735a3a5447a47851591b984e7aa.tar.gz llvm-a677a173273f7735a3a5447a47851591b984e7aa.tar.bz2 |
[mlir][py] Enable AsmState overload for operation.
Diffstat (limited to 'mlir/lib/Bindings/Python/IRModule.h')
-rw-r--r-- | mlir/lib/Bindings/Python/IRModule.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h index 23338f7..3ca7dd8 100644 --- a/mlir/lib/Bindings/Python/IRModule.h +++ b/mlir/lib/Bindings/Python/IRModule.h @@ -759,6 +759,16 @@ class PyAsmState { mlirOpPrintingFlagsUseLocalScope(flags); state = mlirAsmStateCreateForValue(value, flags); } + + PyAsmState(PyOperationBase &operation, bool useLocalScope) { + flags = mlirOpPrintingFlagsCreate(); + // The OpPrintingFlags are not exposed Python side, create locally and + // associate lifetime with the state. + if (useLocalScope) + mlirOpPrintingFlagsUseLocalScope(flags); + state = + mlirAsmStateCreateForOperation(operation.getOperation().get(), flags); + } ~PyAsmState() { mlirOpPrintingFlagsDestroy(flags); } |