diff --git a/mlir/include/mlir-c/Registration.h b/mlir/include/mlir-c/Registration.h --- a/mlir/include/mlir-c/Registration.h +++ b/mlir/include/mlir-c/Registration.h @@ -60,6 +60,9 @@ /// Register all translations to LLVM IR for dialects that can support it. MLIR_CAPI_EXPORTED void mlirRegisterAllLLVMTranslations(MlirContext context); +/// Register all compiler passes of MLIR. +MLIR_CAPI_EXPORTED void mlirRegisterAllPasses(); + #ifdef __cplusplus } #endif diff --git a/mlir/lib/Bindings/Python/AllPasses.cpp b/mlir/lib/Bindings/Python/AllPasses.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/Bindings/Python/AllPasses.cpp @@ -0,0 +1,22 @@ +//===- AllPasses.cpp - Pybind module that registers all MLIR passes -------===// +// +// 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 "mlir-c/Registration.h" + +#include + +// ----------------------------------------------------------------------------- +// Module initialization. +// ----------------------------------------------------------------------------- + +PYBIND11_MODULE(_mlirAllPasses, m) { + m.doc() = "MLIR All Passes Convenience Module"; + + // Register all passes on load. + mlirRegisterAllPasses(); +} diff --git a/mlir/lib/CAPI/Registration/Registration.cpp b/mlir/lib/CAPI/Registration/Registration.cpp --- a/mlir/lib/CAPI/Registration/Registration.cpp +++ b/mlir/lib/CAPI/Registration/Registration.cpp @@ -10,6 +10,7 @@ #include "mlir/CAPI/IR.h" #include "mlir/InitAllDialects.h" +#include "mlir/InitAllPasses.h" #include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h" void mlirRegisterAllDialects(MlirContext context) { @@ -21,3 +22,5 @@ void mlirRegisterAllLLVMTranslations(MlirContext context) { mlir::registerLLVMDialectTranslation(*unwrap(context)); } + +void mlirRegisterAllPasses() { mlir::registerAllPasses(); } diff --git a/mlir/python/mlir/all_passes/__init__.py b/mlir/python/mlir/all_passes/__init__.py new file mode 100644 --- /dev/null +++ b/mlir/python/mlir/all_passes/__init__.py @@ -0,0 +1,8 @@ +# 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 + +from .._cext_loader import _load_extension + +_cextAllPasses = _load_extension("_mlirAllPasses") +del _load_extension