aboutsummaryrefslogtreecommitdiffstats
path: root/python/StandaloneExtension.cpp
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2022-09-26 19:08:01 +0100
committerYann Herklotz <git@yannherklotz.com>2022-09-26 19:08:48 +0100
commit0034f32d6d85d7f21cf04c82083860cdb2fe1ddb (patch)
treef37f65190acd6040a262cdb7d2dbf6e2b17556f5 /python/StandaloneExtension.cpp
parentb018c1ef00eade87c9efbf48cc2e3466877ea79d (diff)
downloadgsa-mlir-master.tar.gz
gsa-mlir-master.zip
Update MLIR files and include LLVM directoryHEADmaster
Diffstat (limited to 'python/StandaloneExtension.cpp')
-rw-r--r--python/StandaloneExtension.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/StandaloneExtension.cpp b/python/StandaloneExtension.cpp
new file mode 100644
index 0000000..4c2043a
--- /dev/null
+++ b/python/StandaloneExtension.cpp
@@ -0,0 +1,31 @@
+//===- StandaloneExtension.cpp - Extension module -------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Standalone-c/Dialects.h"
+#include "mlir/Bindings/Python/PybindAdaptors.h"
+
+namespace py = pybind11;
+using namespace mlir::python::adaptors;
+
+PYBIND11_MODULE(_standaloneDialects, m) {
+ //===--------------------------------------------------------------------===//
+ // standalone dialect
+ //===--------------------------------------------------------------------===//
+ auto standalone_m = m.def_submodule("standalone");
+
+ standalone_m.def(
+ "register_dialect",
+ [](MlirContext context, bool load) {
+ MlirDialectHandle handle = mlirGetDialectHandle__standalone__();
+ mlirDialectHandleRegisterDialect(handle, context);
+ if (load) {
+ mlirDialectHandleLoadDialect(handle, context);
+ }
+ },
+ py::arg("context") = py::none(), py::arg("load") = true);
+}