1 //===- MainModule.cpp - Main pybind module --------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include <tuple>
10 
11 #include <pybind11/pybind11.h>
12 
13 #include "IRModules.h"
14 #include "mlir/IR/MLIRContext.h"
15 
16 using namespace mlir;
17 
18 PYBIND11_MODULE(_mlir, m) {
19   m.doc() = "MLIR Python Native Extension";
20 
21   m.def("get_test_value", []() {
22     // This is just calling a method on the MLIRContext as a smoketest
23     // for linkage.
24     MLIRContext context;
25     return std::make_tuple(std::string("From the native module"),
26                            context.isMultithreadingEnabled());
27   });
28 
29   // Define and populate IR submodule.
30   auto irModule = m.def_submodule("ir", "MLIR IR Bindings");
31   populateIRSubmodule(irModule);
32 }
33