MLIR 24.0.0git
MainModule.cpp
Go to the documentation of this file.
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 "Pass.h"
10#include "Rewrite.h"
16
17namespace nb = nanobind;
19
20namespace mlir {
21namespace python {
23void populateIRAffine(nb::module_ &m);
24void populateIRAttributes(nb::module_ &m);
25void populateIRInterfaces(nb::module_ &m);
26void populateIRTypes(nb::module_ &m);
27void populateIRCore(nb::module_ &m);
28void populateIRRemarks(nb::module_ &m);
29void populateRoot(nb::module_ &m);
30} // namespace MLIR_BINDINGS_PYTHON_DOMAIN
31} // namespace python
32} // namespace mlir
33
34// -----------------------------------------------------------------------------
35// Module initialization.
36// -----------------------------------------------------------------------------
37NB_MODULE(_mlir, m) {
38 // disable leak warnings which tend to be false positives.
39 nb::set_leak_warnings(false);
40
41 m.doc() = "MLIR Python Native Extension";
42 populateRoot(m);
43 // Define and populate IR submodule.
44 auto irModule = m.def_submodule("ir", "MLIR IR Bindings");
45 // The remark enums are default arguments of the Context bindings.
46 populateIRRemarks(irModule);
47 populateIRCore(irModule);
48 populateIRAffine(irModule);
49 populateIRAttributes(irModule);
50 populateIRInterfaces(irModule);
51 populateIRTypes(irModule);
52
53 auto rewriteModule = m.def_submodule("rewrite", "MLIR Rewrite Bindings");
54 populateRewriteSubmodule(rewriteModule);
55
56 // Define and populate PassManager submodule.
57 auto passManagerModule =
58 m.def_submodule("passmanager", "MLIR Pass Management Bindings");
59 populatePassManagerSubmodule(passManagerModule);
60}
NB_MODULE(_mlir, m)
MLIR_PYTHON_API_EXPORTED void populateRoot(nanobind::module_ &m)
void populateRewriteSubmodule(nb::module_ &m)
Create the mlir.rewrite here.
Definition Rewrite.cpp:541
MLIR_PYTHON_API_EXPORTED void populateIRTypes(nanobind::module_ &m)
MLIR_PYTHON_API_EXPORTED void populateIRRemarks(nanobind::module_ &m)
void populatePassManagerSubmodule(nb::module_ &m)
Create the mlir.passmanager here.
Definition Pass.cpp:66
MLIR_PYTHON_API_EXPORTED void populateIRCore(nanobind::module_ &m)
MLIR_PYTHON_API_EXPORTED void populateIRAttributes(nanobind::module_ &m)
Include the generated interface declarations.