[Mlir-commits] [mlir] c647705 - Remove static registration for dialects, and the "alwayslink" hack for passes
Mehdi Amini
llvmlistbot at llvm.org
Wed Feb 12 01:14:17 PST 2020
Author: Mehdi Amini
Date: 2020-02-12T09:13:02Z
New Revision: c64770506b89a2376fe13080bc3b72789e6c752d
URL: https://github.com/llvm/llvm-project/commit/c64770506b89a2376fe13080bc3b72789e6c752d
DIFF: https://github.com/llvm/llvm-project/commit/c64770506b89a2376fe13080bc3b72789e6c752d.diff
LOG: Remove static registration for dialects, and the "alwayslink" hack for passes
In the previous state, we were relying on forcing the linker to include
all libraries in the final binary and the global initializer to self-register
every piece of the system. This change help moving away from this model, and
allow users to compose pieces more freely. The current change is only "fixing"
the dialect registration and avoiding relying on "whole link" for the passes.
The translation is still relying on the global registry, and some refactoring
is needed to make this all more convenient.
Differential Revision: https://reviews.llvm.org/D74461
Added:
mlir/include/mlir/InitAllDialects.h
mlir/include/mlir/InitAllPasses.h
Modified:
mlir/examples/toy/Ch5/CMakeLists.txt
mlir/examples/toy/Ch5/toyc.cpp
mlir/examples/toy/Ch6/CMakeLists.txt
mlir/examples/toy/Ch6/toyc.cpp
mlir/examples/toy/Ch7/CMakeLists.txt
mlir/examples/toy/Ch7/toyc.cpp
mlir/include/mlir/Analysis/Passes.h
mlir/include/mlir/Quantizer/Transforms/Passes.h
mlir/include/mlir/Transforms/Passes.h
mlir/lib/Dialect/AffineOps/CMakeLists.txt
mlir/lib/Dialect/CMakeLists.txt
mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
mlir/lib/Dialect/GPU/CMakeLists.txt
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
mlir/lib/Dialect/QuantOps/CMakeLists.txt
mlir/lib/Dialect/SDBM/CMakeLists.txt
mlir/lib/Dialect/SPIRV/CMakeLists.txt
mlir/lib/Dialect/VectorOps/CMakeLists.txt
mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
mlir/lib/Support/JitRunner.cpp
mlir/lib/Transforms/OpStats.cpp
mlir/test/Dialect/SPIRV/TestAvailability.cpp
mlir/test/EDSC/builder-api-test.cpp
mlir/test/SDBM/sdbm-api-test.cpp
mlir/test/lib/IR/TestFunc.cpp
mlir/test/lib/IR/TestMatchers.cpp
mlir/test/lib/IR/TestSymbolUses.cpp
mlir/test/lib/Pass/TestPassManager.cpp
mlir/test/lib/TestDialect/TestPatterns.cpp
mlir/test/lib/Transforms/TestAllReduceLowering.cpp
mlir/test/lib/Transforms/TestCallGraph.cpp
mlir/test/lib/Transforms/TestConstantFold.cpp
mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
mlir/test/lib/Transforms/TestInlining.cpp
mlir/test/lib/Transforms/TestLinalgTransforms.cpp
mlir/test/lib/Transforms/TestLiveness.cpp
mlir/test/lib/Transforms/TestLoopFusion.cpp
mlir/test/lib/Transforms/TestLoopMapping.cpp
mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp
mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
mlir/test/lib/Transforms/TestOpaqueLoc.cpp
mlir/test/lib/Transforms/TestParallelismDetection.cpp
mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp
mlir/test/lib/Transforms/TestVectorTransforms.cpp
mlir/test/lib/Transforms/TestVectorizationUtils.cpp
mlir/tools/mlir-cpu-runner/CMakeLists.txt
mlir/tools/mlir-opt/CMakeLists.txt
mlir/tools/mlir-opt/mlir-opt.cpp
mlir/tools/mlir-translate/CMakeLists.txt
mlir/tools/mlir-translate/mlir-translate.cpp
mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp
mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
mlir/unittests/SDBM/SDBMTest.cpp
Removed:
mlir/lib/Dialect/AffineOps/DialectRegistration.cpp
mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp
mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp
mlir/lib/Dialect/Linalg/IR/LinalgRegistration.cpp
mlir/lib/Dialect/LoopOps/DialectRegistration.cpp
mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp
mlir/lib/Dialect/SDBM/SDBMDialect.cpp
mlir/lib/Dialect/SPIRV/DialectRegistration.cpp
mlir/lib/Dialect/StandardOps/DialectRegistration.cpp
mlir/lib/Dialect/VectorOps/DialectRegistration.cpp
################################################################################
diff --git a/mlir/examples/toy/Ch5/CMakeLists.txt b/mlir/examples/toy/Ch5/CMakeLists.txt
index de868daa9b7a..df71c35a7a77 100644
--- a/mlir/examples/toy/Ch5/CMakeLists.txt
+++ b/mlir/examples/toy/Ch5/CMakeLists.txt
@@ -27,15 +27,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
target_link_libraries(toyc-ch5
PRIVATE
- MLIRAffineOps
+ MLIRAllDialects
MLIRAnalysis
MLIRIR
MLIRParser
MLIRPass
- MLIRStandardOps
MLIRTransforms)
-whole_archive_link(toyc-ch5
- MLIRAffineOps
- MLIRStandardOps
- )
diff --git a/mlir/examples/toy/Ch5/toyc.cpp b/mlir/examples/toy/Ch5/toyc.cpp
index d3a83a971587..c9a52c606b21 100644
--- a/mlir/examples/toy/Ch5/toyc.cpp
+++ b/mlir/examples/toy/Ch5/toyc.cpp
@@ -18,6 +18,7 @@
#include "mlir/Analysis/Verifier.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Module.h"
+#include "mlir/InitAllDialects.h"
#include "mlir/Parser.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
@@ -171,6 +172,7 @@ int dumpAST() {
}
int main(int argc, char **argv) {
+ mlir::registerAllDialects();
mlir::registerPassManagerCLOptions();
cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
diff --git a/mlir/examples/toy/Ch6/CMakeLists.txt b/mlir/examples/toy/Ch6/CMakeLists.txt
index a539d591b90c..1497cc349868 100644
--- a/mlir/examples/toy/Ch6/CMakeLists.txt
+++ b/mlir/examples/toy/Ch6/CMakeLists.txt
@@ -29,7 +29,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
target_link_libraries(toyc-ch6
PRIVATE
- MLIRAffineOps
+ MLIRAllDialects
MLIRAffineToStandard
MLIRAnalysis
MLIRExecutionEngine
@@ -38,15 +38,8 @@ target_link_libraries(toyc-ch6
MLIRLoopToStandard
MLIRParser
MLIRPass
- MLIRStandardOps
MLIRStandardToLLVM
MLIRTargetLLVMIR
MLIRTransforms
)
-whole_archive_link(toyc-ch6
- MLIRAffineToStandard
- MLIRAffineOps
- MLIRLLVMIR
- MLIRStandardOps
- )
diff --git a/mlir/examples/toy/Ch6/toyc.cpp b/mlir/examples/toy/Ch6/toyc.cpp
index f33f7390344a..3c54f731ff42 100644
--- a/mlir/examples/toy/Ch6/toyc.cpp
+++ b/mlir/examples/toy/Ch6/toyc.cpp
@@ -20,6 +20,7 @@
#include "mlir/ExecutionEngine/OptUtils.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Module.h"
+#include "mlir/InitAllDialects.h"
#include "mlir/Parser.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
@@ -238,6 +239,7 @@ int runJit(mlir::ModuleOp module) {
}
int main(int argc, char **argv) {
+ mlir::registerAllDialects();
mlir::registerPassManagerCLOptions();
cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
diff --git a/mlir/examples/toy/Ch7/CMakeLists.txt b/mlir/examples/toy/Ch7/CMakeLists.txt
index 66d543987752..ece8c873786e 100644
--- a/mlir/examples/toy/Ch7/CMakeLists.txt
+++ b/mlir/examples/toy/Ch7/CMakeLists.txt
@@ -29,24 +29,15 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
target_link_libraries(toyc-ch7
PRIVATE
- MLIRAffineOps
+ MLIRAllDialects
MLIRAffineToStandard
MLIRAnalysis
MLIRExecutionEngine
MLIRIR
- MLIRLLVMIR
MLIRLoopToStandard
MLIRParser
MLIRPass
- MLIRStandardOps
MLIRStandardToLLVM
MLIRTargetLLVMIR
MLIRTransforms
)
-
-whole_archive_link(toyc-ch7
- MLIRAffineToStandard
- MLIRAffineOps
- MLIRLLVMIR
- MLIRStandardOps
- )
diff --git a/mlir/examples/toy/Ch7/toyc.cpp b/mlir/examples/toy/Ch7/toyc.cpp
index 199fff96d3b3..1f5f988caca3 100644
--- a/mlir/examples/toy/Ch7/toyc.cpp
+++ b/mlir/examples/toy/Ch7/toyc.cpp
@@ -20,6 +20,7 @@
#include "mlir/ExecutionEngine/OptUtils.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Module.h"
+#include "mlir/InitAllDialects.h"
#include "mlir/Parser.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
@@ -239,6 +240,7 @@ int runJit(mlir::ModuleOp module) {
}
int main(int argc, char **argv) {
+ mlir::registerAllDialects();
mlir::registerPassManagerCLOptions();
cl::ParseCommandLineOptions(argc, argv, "toy compiler\n");
diff --git a/mlir/include/mlir/Analysis/Passes.h b/mlir/include/mlir/Analysis/Passes.h
index db53f60b4954..296b3b9838c5 100644
--- a/mlir/include/mlir/Analysis/Passes.h
+++ b/mlir/include/mlir/Analysis/Passes.h
@@ -28,9 +28,6 @@ std::unique_ptr<OpPassBase<FuncOp>> createTestMemRefBoundCheckPass();
/// Creates a pass to check memref access dependences in a Function.
std::unique_ptr<OpPassBase<FuncOp>> createTestMemRefDependenceCheckPass();
-/// Creates a pass to test parallelism detection; emits note for parallel loops.
-std::unique_ptr<OpPassBase<FuncOp>> createParallelismDetectionTestPass();
-
} // end namespace mlir
#endif // MLIR_ANALYSIS_PASSES_H
diff --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h
new file mode 100644
index 000000000000..eeac773cff94
--- /dev/null
+++ b/mlir/include/mlir/InitAllDialects.h
@@ -0,0 +1,59 @@
+//===- InitAllDialects.h - MLIR Dialects Registration -----------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines a helper to trigger the registration of all dialects and
+// passes to the system.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_INITALLDIALECTS_H_
+#define MLIR_INITALLDIALECTS_H_
+
+#include "mlir/Dialect/AffineOps/AffineOps.h"
+#include "mlir/Dialect/FxpMathOps/FxpMathOps.h"
+#include "mlir/Dialect/GPU/GPUDialect.h"
+#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
+#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
+#include "mlir/Dialect/LLVMIR/ROCDLDialect.h"
+#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
+#include "mlir/Dialect/LoopOps/LoopOps.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/Dialect/QuantOps/QuantOps.h"
+#include "mlir/Dialect/SDBM/SDBMDialect.h"
+#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/StandardOps/Ops.h"
+#include "mlir/Dialect/VectorOps/VectorOps.h"
+#include "mlir/IR/Dialect.h"
+
+namespace mlir {
+
+// This function should be called before creating any MLIRContext if one expect
+// all the possible dialects to be made available to the context automatically.
+inline void registerAllDialects() {
+ static bool init_once = []() {
+ registerDialect<AffineOpsDialect>();
+ registerDialect<fxpmath::FxpMathOpsDialect>();
+ registerDialect<gpu::GPUDialect>();
+ registerDialect<LLVM::LLVMDialect>();
+ registerDialect<linalg::LinalgDialect>();
+ registerDialect<loop::LoopOpsDialect>();
+ registerDialect<omp::OpenMPDialect>();
+ registerDialect<quant::QuantizationDialect>();
+ registerDialect<spirv::SPIRVDialect>();
+ registerDialect<StandardOpsDialect>();
+ registerDialect<vector::VectorOpsDialect>();
+ registerDialect<NVVM::NVVMDialect>();
+ registerDialect<ROCDL::ROCDLDialect>();
+ registerDialect<SDBMDialect>();
+ return true;
+ }();
+ (void)init_once;
+}
+} // namespace mlir
+
+#endif // MLIR_INITALLDIALECTS_H_
diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h
new file mode 100644
index 000000000000..e48af6f5ff9e
--- /dev/null
+++ b/mlir/include/mlir/InitAllPasses.h
@@ -0,0 +1,124 @@
+//===- LinkAllPassesAndDialects.h - MLIR Registration -----------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines a helper to trigger the registration of all dialects and
+// passes to the system.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_INITALLPASSES_H_
+#define MLIR_INITALLPASSES_H_
+
+#include "mlir/Analysis/Passes.h"
+#include "mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h"
+#include "mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h"
+#include "mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"
+#include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.h"
+#include "mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h"
+#include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h"
+#include "mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h"
+#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
+#include "mlir/Dialect/FxpMathOps/Passes.h"
+#include "mlir/Dialect/GPU/Passes.h"
+#include "mlir/Dialect/Linalg/Passes.h"
+#include "mlir/Dialect/QuantOps/Passes.h"
+#include "mlir/Dialect/SPIRV/Passes.h"
+#include "mlir/Quantizer/Transforms/Passes.h"
+#include "mlir/Transforms/LocationSnapshot.h"
+#include "mlir/Transforms/Passes.h"
+
+#include <cstdlib>
+
+namespace mlir {
+
+// This function may be called to register the MLIR passes with the
+// global registry.
+// If you're building a compiler, you likely don't need this: you would build a
+// pipeline programmatically without the need to register with the global
+// registry, since it would already be calling the creation routine of the
+// individual passes.
+// The global registry is interesting to interact with the command-line tools.
+inline void registerAllPasses() {
+ // At the moment we still rely on global initializers for registering passes,
+ // but we may not do it in the future.
+ // We must reference the passes in such a way that compilers will not
+ // delete it all as dead code, even with whole program optimization,
+ // yet is effectively a NO-OP. As the compiler isn't smart enough
+ // to know that getenv() never returns -1, this will do the job.
+ if (std::getenv("bar") != (char *)-1)
+ return;
+
+ // Init general passes
+ createCanonicalizerPass();
+ createCSEPass();
+ createVectorizePass({});
+ createLoopUnrollPass();
+ createLoopUnrollAndJamPass();
+ createSimplifyAffineStructuresPass();
+ createLoopFusionPass();
+ createLoopInvariantCodeMotionPass();
+ createAffineLoopInvariantCodeMotionPass();
+ createPipelineDataTransferPass();
+ createLowerAffinePass();
+ createLoopTilingPass(0);
+ createLoopCoalescingPass();
+ createAffineDataCopyGenerationPass(0, 0);
+ createMemRefDataFlowOptPass();
+ createStripDebugInfoPass();
+ createPrintOpStatsPass();
+ createInlinerPass();
+ createSymbolDCEPass();
+ createLocationSnapshotPass({});
+
+ // GPUtoRODCLPass
+ createLowerGpuOpsToROCDLOpsPass();
+
+ // FxpOpsDialect passes
+ fxpmath::createLowerUniformRealMathPass();
+ fxpmath::createLowerUniformCastsPass();
+
+ // GPU
+ createGpuKernelOutliningPass();
+ createSimpleLoopsToGPUPass(0, 0);
+ createLoopToGPUPass({}, {});
+
+ // CUDA
+ createConvertGpuLaunchFuncToCudaCallsPass();
+ createConvertGPUKernelToCubinPass(
+ [](const std::string &, Location, StringRef) { return nullptr; });
+ createLowerGpuOpsToNVVMOpsPass();
+
+ // Linalg
+ createLinalgFusionPass();
+ createLinalgTilingPass();
+ createLinalgTilingToParallelLoopsPass();
+ createLinalgPromotionPass(0);
+ createConvertLinalgToLoopsPass();
+ createConvertLinalgToParallelLoopsPass();
+ createConvertLinalgToAffineLoopsPass();
+ createConvertLinalgToLLVMPass();
+
+ // QuantOps
+ quant::createConvertSimulatedQuantPass();
+ quant::createConvertConstPass();
+ quantizer::createAddDefaultStatsPass();
+ quantizer::createRemoveInstrumentationPass();
+ quantizer::registerInferQuantizedTypesPass();
+
+ // SPIR-V
+ spirv::createDecorateSPIRVCompositeTypeLayoutPass();
+ spirv::createLowerABIAttributesPass();
+ createConvertGPUToSPIRVPass();
+ createConvertStandardToSPIRVPass();
+ createLegalizeStdOpsForSPIRVLoweringPass();
+ createLinalgToSPIRVPass();
+}
+
+} // namespace mlir
+
+#endif // MLIR_INITALLPASSES_H_
diff --git a/mlir/include/mlir/Quantizer/Transforms/Passes.h b/mlir/include/mlir/Quantizer/Transforms/Passes.h
index a8a53b95fae8..3cd0475d2f8e 100644
--- a/mlir/include/mlir/Quantizer/Transforms/Passes.h
+++ b/mlir/include/mlir/Quantizer/Transforms/Passes.h
@@ -28,6 +28,9 @@ std::unique_ptr<OpPassBase<ModuleOp>>
createInferQuantizedTypesPass(SolverContext &solverContext,
const TargetConfiguration &config);
+/// Registers the InferQuantizedTypes pass with the global registry.
+void registerInferQuantizedTypesPass();
+
/// Creates a pass which removes any instrumentation and hint ops which have
/// no effect on final runtime.
std::unique_ptr<OpPassBase<FuncOp>> createRemoveInstrumentationPass();
diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h
index 133b716e4c59..8b7495ec0e58 100644
--- a/mlir/include/mlir/Transforms/Passes.h
+++ b/mlir/include/mlir/Transforms/Passes.h
@@ -37,10 +37,6 @@ std::unique_ptr<Pass> createCSEPass();
std::unique_ptr<OpPassBase<FuncOp>>
createVectorizePass(ArrayRef<int64_t> virtualVectorSize);
-/// Creates a pass to allow independent testing of vectorizer functionality with
-/// FileCheck.
-std::unique_ptr<OpPassBase<FuncOp>> createVectorizerTestPass();
-
/// Creates a loop unrolling pass with the provided parameters.
/// 'getUnrollFactor' is a function callback for clients to supply a function
/// that computes an unroll factor - the callback takes precedence over unroll
@@ -91,12 +87,6 @@ std::unique_ptr<OpPassBase<FuncOp>> createLowerAffinePass();
std::unique_ptr<OpPassBase<FuncOp>>
createLoopTilingPass(uint64_t cacheSizeBytes);
-/// Creates a pass that performs parametric tiling so that the outermost loops
-/// have the given fixed number of iterations. Assumes outermost loop nests
-/// are permutable.
-std::unique_ptr<OpPassBase<FuncOp>>
-createSimpleParametricTilingPass(ArrayRef<int64_t> outerLoopSizes);
-
/// Creates a pass that transforms perfectly nested loops with independent
/// bounds into a single loop.
std::unique_ptr<OpPassBase<FuncOp>> createLoopCoalescingPass();
@@ -116,11 +106,12 @@ std::unique_ptr<OpPassBase<FuncOp>> createMemRefDataFlowOptPass();
/// Creates a pass to strip debug information from a function.
std::unique_ptr<Pass> createStripDebugInfoPass();
-/// Creates a pass which tests loop fusion utilities.
-std::unique_ptr<OpPassBase<FuncOp>> createTestLoopFusionPass();
+/// Creates a pass which prints the list of ops and the number of occurences in
+/// the module.
+std::unique_ptr<OpPassBase<ModuleOp>> createPrintOpStatsPass();
-/// Creates a pass which inlines calls and callable operations as defined by the
-/// CallGraph.
+/// Creates a pass which inlines calls and callable operations as defined by
+/// the CallGraph.
std::unique_ptr<Pass> createInlinerPass();
/// Creates a pass which delete symbol operations that are unreachable. This
diff --git a/mlir/lib/Dialect/AffineOps/CMakeLists.txt b/mlir/lib/Dialect/AffineOps/CMakeLists.txt
index 9648f27f1067..3d07cde5d6e6 100644
--- a/mlir/lib/Dialect/AffineOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/AffineOps/CMakeLists.txt
@@ -1,9 +1,8 @@
add_llvm_library(MLIRAffineOps
AffineOps.cpp
AffineValueMap.cpp
- DialectRegistration.cpp
EDSC/Builders.cpp
-
+
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/AffineOps
)
diff --git a/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp b/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp
deleted file mode 100644
index b9535b5f0d2a..000000000000
--- a/mlir/lib/Dialect/AffineOps/DialectRegistration.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-//===- DialectRegistration.cpp - Register Affine Op dialect ---------------===//
-//
-// 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/Dialect/AffineOps/AffineOps.h"
-using namespace mlir;
-
-// Static initialization for Affine op dialect registration.
-static DialectRegistration<AffineOpsDialect> StandardOps;
diff --git a/mlir/lib/Dialect/CMakeLists.txt b/mlir/lib/Dialect/CMakeLists.txt
index f1d30d86d321..0542830c1660 100644
--- a/mlir/lib/Dialect/CMakeLists.txt
+++ b/mlir/lib/Dialect/CMakeLists.txt
@@ -12,6 +12,11 @@ add_subdirectory(SPIRV)
add_subdirectory(StandardOps)
add_subdirectory(VectorOps)
+
+set(LLVM_OPTIONAL_SOURCES
+ Traits.cpp
+)
+
add_llvm_library(MLIRDialect
Traits.cpp
@@ -19,3 +24,29 @@ add_llvm_library(MLIRDialect
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect
)
target_link_libraries(MLIRDialect MLIRIR)
+
+# Create a dummy MLIRAllDialects library for the purpose
+# of having an easy tracking of all dialects when linking
+# them in tools.
+# Empty libraries aren't possible with CMake, create a dummy file.
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/all_dialects.c "typedef int make_iso_compilers_happy;\n")
+add_llvm_library(MLIRAllDialects
+ ${CMAKE_CURRENT_BINARY_DIR}/all_dialects.c
+)
+target_link_libraries(MLIRAllDialects
+ MLIRAffineOps
+ MLIRFxpMathOps
+ MLIRGPU
+ MLIRLLVMIR
+ MLIRNVVMIR
+ MLIRROCDLIR
+ MLIRLinalgOps
+ MLIRLoopOps
+ MLIROpenMP
+ MLIRQuantOps
+ MLIRSDBM
+ MLIRShape
+ MLIRSPIRV
+ MLIRStandardOps
+ MLIRVectorOps
+)
diff --git a/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt b/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
index 61806e0d8089..ba9a3001154e 100644
--- a/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/FxpMathOps/CMakeLists.txt
@@ -1,6 +1,5 @@
add_llvm_library(MLIRFxpMathOps
IR/FxpMathOps.cpp
- IR/DialectRegistration.cpp
Transforms/LowerUniformRealMath.cpp
ADDITIONAL_HEADER_DIRS
diff --git a/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp b/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp
deleted file mode 100644
index d732ff944b6d..000000000000
--- a/mlir/lib/Dialect/FxpMathOps/IR/DialectRegistration.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===- DialectRegistration.cpp - Register FxpMathOps dialect --------------===//
-//
-// 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/Dialect/FxpMathOps/FxpMathOps.h"
-
-using namespace mlir;
-using namespace mlir::fxpmath;
-
-// Static initialization for the fxpmath ops dialect registration.
-static mlir::DialectRegistration<FxpMathOpsDialect> FxpMathOps;
diff --git a/mlir/lib/Dialect/GPU/CMakeLists.txt b/mlir/lib/Dialect/GPU/CMakeLists.txt
index 063aa1ea5ce6..17342f85f9d2 100644
--- a/mlir/lib/Dialect/GPU/CMakeLists.txt
+++ b/mlir/lib/Dialect/GPU/CMakeLists.txt
@@ -1,6 +1,5 @@
add_llvm_library(MLIRGPU
IR/GPUDialect.cpp
- IR/DialectRegistration.cpp
Transforms/AllReduceLowering.cpp
Transforms/KernelOutlining.cpp
Transforms/MemoryPromotion.cpp
diff --git a/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp b/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp
deleted file mode 100644
index 2a1b68779dcd..000000000000
--- a/mlir/lib/Dialect/GPU/IR/DialectRegistration.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-//===- DialectRegistration.cpp - MLIR GPU dialect registration ------------===//
-//
-// 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/Dialect/GPU/GPUDialect.h"
-
-// Static initialization for GPU dialect registration.
-static mlir::DialectRegistration<mlir::gpu::GPUDialect> kernelDialect;
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 8e2e3c5ff065..a63a593dfc1e 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1658,8 +1658,6 @@ LogicalResult LLVMDialect::verifyRegionArgAttribute(Operation *op,
return success();
}
-static DialectRegistration<LLVMDialect> llvmDialect;
-
//===----------------------------------------------------------------------===//
// LLVMType.
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index b7b32df12ca6..210507a61fc3 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -159,4 +159,3 @@ namespace NVVM {
} // namespace NVVM
} // namespace mlir
-static DialectRegistration<NVVMDialect> nvvmDialect;
diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
index 28ee28f71e86..83d3ffb1d761 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp
@@ -52,4 +52,3 @@ namespace ROCDL {
} // namespace ROCDL
} // namespace mlir
-static DialectRegistration<ROCDLDialect> rocdlDialect;
diff --git a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
index df71c831a7f7..40ce1724235a 100644
--- a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
@@ -7,7 +7,6 @@ set(LIBS
add_llvm_library(MLIRLinalgOps
LinalgOps.cpp
LinalgTypes.cpp
- LinalgRegistration.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Linalg
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgRegistration.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgRegistration.cpp
deleted file mode 100644
index f9c2c9b4b637..000000000000
--- a/mlir/lib/Dialect/Linalg/IR/LinalgRegistration.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-//===- LinalgRegistration.cpp - Register the linalg dialect statically ----===//
-//
-// 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/Dialect/Linalg/IR/LinalgOps.h"
-#include "mlir/Dialect/Linalg/IR/LinalgTypes.h"
-
-using namespace mlir;
-using namespace mlir::linalg;
-
-// Static initialization for LinalgOps dialect registration.
-static DialectRegistration<LinalgDialect> LinalgOps;
diff --git a/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp b/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp
deleted file mode 100644
index c0ca419d506c..000000000000
--- a/mlir/lib/Dialect/LoopOps/DialectRegistration.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-//===- DialectRegistration.cpp - Register loop dialect --------------------===//
-//
-// 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/Dialect/LoopOps/LoopOps.h"
-using namespace mlir;
-
-// Static initialization for loop dialect registration.
-static DialectRegistration<loop::LoopOpsDialect> LoopOps;
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 445323b42e46..edb1a4eb5eb4 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -30,5 +30,3 @@ namespace omp {
#include "mlir/Dialect/OpenMP/OpenMPOps.cpp.inc"
} // namespace omp
} // namespace mlir
-
-static DialectRegistration<OpenMPDialect> ompDialect;
diff --git a/mlir/lib/Dialect/QuantOps/CMakeLists.txt b/mlir/lib/Dialect/QuantOps/CMakeLists.txt
index bfbcbdbd3a6e..483056675ef4 100644
--- a/mlir/lib/Dialect/QuantOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/QuantOps/CMakeLists.txt
@@ -1,5 +1,4 @@
add_llvm_library(MLIRQuantOps
- IR/DialectRegistration.cpp
IR/QuantOps.cpp
IR/QuantTypes.cpp
IR/TypeDetail.h
diff --git a/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp b/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp
deleted file mode 100644
index 8321e88b0b6c..000000000000
--- a/mlir/lib/Dialect/QuantOps/IR/DialectRegistration.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===- DialectRegistration.cpp - Register Quantization dialect ------------===//
-//
-// 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/Dialect/QuantOps/QuantOps.h"
-
-using namespace mlir;
-using namespace mlir::quant;
-
-// Static initialization for Quantization dialect registration.
-static mlir::DialectRegistration<QuantizationDialect> QuantizationOps;
diff --git a/mlir/lib/Dialect/SDBM/CMakeLists.txt b/mlir/lib/Dialect/SDBM/CMakeLists.txt
index e36308e0edaf..36be9466c573 100644
--- a/mlir/lib/Dialect/SDBM/CMakeLists.txt
+++ b/mlir/lib/Dialect/SDBM/CMakeLists.txt
@@ -1,7 +1,6 @@
add_llvm_library(MLIRSDBM
SDBM.cpp
SDBMExpr.cpp
- SDBMDialect.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SDBM
diff --git a/mlir/lib/Dialect/SDBM/SDBMDialect.cpp b/mlir/lib/Dialect/SDBM/SDBMDialect.cpp
deleted file mode 100644
index 9b18a126958b..000000000000
--- a/mlir/lib/Dialect/SDBM/SDBMDialect.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-//===- SDBMDialect.cpp - Dialect for striped
diff erence-bound matrices ----===//
-//
-// 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/Dialect/SDBM/SDBMDialect.h"
-
-static mlir::DialectRegistration<mlir::SDBMDialect> SDBMDialect;
diff --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
index da7fd1ae7541..d0ff25ef68f0 100644
--- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
@@ -3,7 +3,6 @@ mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
add_llvm_library(MLIRSPIRV
- DialectRegistration.cpp
LayoutUtils.cpp
SPIRVDialect.cpp
SPIRVOps.cpp
diff --git a/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp b/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp
deleted file mode 100644
index 2af7593487c0..000000000000
--- a/mlir/lib/Dialect/SPIRV/DialectRegistration.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-//===- DialectRegistration.cpp - MLIR SPIR-V dialect registration ---------===//
-//
-// 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/Dialect/SPIRV/SPIRVDialect.h"
-
-// Static initialization for SPIR-V dialect registration.
-static mlir::DialectRegistration<mlir::spirv::SPIRVDialect> spirvDialect;
diff --git a/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp b/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp
deleted file mode 100644
index 54d35f0bf8a7..000000000000
--- a/mlir/lib/Dialect/StandardOps/DialectRegistration.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-//===- DialectRegistration.cpp - Register standard Op dialect -------------===//
-//
-// 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/Dialect/StandardOps/Ops.h"
-using namespace mlir;
-
-// Static initialization for standard op dialect registration.
-static DialectRegistration<StandardOpsDialect> StandardOps;
diff --git a/mlir/lib/Dialect/VectorOps/CMakeLists.txt b/mlir/lib/Dialect/VectorOps/CMakeLists.txt
index 2a9071036331..27cb10f53c20 100644
--- a/mlir/lib/Dialect/VectorOps/CMakeLists.txt
+++ b/mlir/lib/Dialect/VectorOps/CMakeLists.txt
@@ -1,5 +1,4 @@
add_llvm_library(MLIRVectorOps
- DialectRegistration.cpp
VectorOps.cpp
VectorTransforms.cpp
VectorUtils.cpp
diff --git a/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp b/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp
deleted file mode 100644
index 848504f8c52e..000000000000
--- a/mlir/lib/Dialect/VectorOps/DialectRegistration.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-//===- DialectRegistration.cpp - Register super vectorization dialect -----===//
-//
-// 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/Dialect/VectorOps/VectorOps.h"
-using namespace mlir;
-
-// Static initialization for VectorOps dialect registration.
-static DialectRegistration<vector::VectorOpsDialect> VectorOps;
diff --git a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
index dac67fb7ffae..48c2ca2c075e 100644
--- a/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
+++ b/mlir/lib/Quantizer/Transforms/InferQuantizedTypesPass.cpp
@@ -282,6 +282,11 @@ mlir::quantizer::createInferQuantizedTypesPass(
SolverContext &solverContext, const TargetConfiguration &config) {
return std::make_unique<InferQuantizedTypesPass>(solverContext, config);
}
+void mlir::quantizer::registerInferQuantizedTypesPass() {
+ // Do nothing, this will be enough to force link this file and the static
+ // registration will kick-in. This is temporary while we're refactoring pass
+ // registration to move away from static constructors.
+}
static PassRegistration<InferQuantizedTypesPass>
pass("quantizer-infer-quantized-types",
diff --git a/mlir/lib/Support/JitRunner.cpp b/mlir/lib/Support/JitRunner.cpp
index ab7f0bb9ca03..dd8f0832afb5 100644
--- a/mlir/lib/Support/JitRunner.cpp
+++ b/mlir/lib/Support/JitRunner.cpp
@@ -22,6 +22,7 @@
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Module.h"
#include "mlir/IR/StandardTypes.h"
+#include "mlir/InitAllDialects.h"
#include "mlir/Parser.h"
#include "mlir/Support/FileUtilities.h"
@@ -209,6 +210,7 @@ static Error compileAndExecuteSingleFloatReturnFunction(
int mlir::JitRunnerMain(
int argc, char **argv,
function_ref<LogicalResult(mlir::ModuleOp)> mlirTransformer) {
+ registerAllDialects();
llvm::InitLLVM y(argc, argv);
initializeLLVM();
diff --git a/mlir/lib/Transforms/OpStats.cpp b/mlir/lib/Transforms/OpStats.cpp
index dd684d373562..0377b719f6d2 100644
--- a/mlir/lib/Transforms/OpStats.cpp
+++ b/mlir/lib/Transforms/OpStats.cpp
@@ -10,6 +10,7 @@
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/Passes.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
@@ -80,5 +81,9 @@ void PrintOpStatsPass::printSummary() {
}
}
+std::unique_ptr<OpPassBase<ModuleOp>> mlir::createPrintOpStatsPass() {
+ return std::make_unique<PrintOpStatsPass>();
+}
+
static PassRegistration<PrintOpStatsPass>
pass("print-op-stats", "Print statistics of operations");
diff --git a/mlir/test/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/Dialect/SPIRV/TestAvailability.cpp
index 373397bdc2cd..0055085c1661 100644
--- a/mlir/test/Dialect/SPIRV/TestAvailability.cpp
+++ b/mlir/test/Dialect/SPIRV/TestAvailability.cpp
@@ -213,6 +213,9 @@ ConvertToSubgroupBallot::matchAndRewrite(Operation *op,
return matchSuccess();
}
-static PassRegistration<ConvertToTargetEnv>
- convertToTargetEnvPass("test-spirv-target-env",
- "Test SPIR-V target environment");
+namespace mlir {
+void registerConvertToTargetEnvPass() {
+ PassRegistration<ConvertToTargetEnv> convertToTargetEnvPass(
+ "test-spirv-target-env", "Test SPIR-V target environment");
+}
+} // namespace mlir
diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp
index 92f05680e432..2cf808642905 100644
--- a/mlir/test/EDSC/builder-api-test.cpp
+++ b/mlir/test/EDSC/builder-api-test.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-// RUN: mlir-edsc-builder-api-test | FileCheck %s
+// RUN: mlir-edsc-builder-api-test | FileCheck %s -dump-input-on-failure
#include "mlir/Dialect/AffineOps/EDSC/Intrinsics.h"
#include "mlir/Dialect/Linalg/EDSC/Intrinsics.h"
@@ -37,6 +37,15 @@ using namespace mlir::edsc;
using namespace mlir::edsc::intrinsics;
static MLIRContext &globalContext() {
+ static bool init_once = []() {
+ registerDialect<AffineOpsDialect>();
+ registerDialect<linalg::LinalgDialect>();
+ registerDialect<loop::LoopOpsDialect>();
+ registerDialect<StandardOpsDialect>();
+ registerDialect<vector::VectorOpsDialect>();
+ return true;
+ }();
+ (void)init_once;
static thread_local MLIRContext context;
return context;
}
diff --git a/mlir/test/SDBM/sdbm-api-test.cpp b/mlir/test/SDBM/sdbm-api-test.cpp
index 4606df9a85e1..0b58e2948145 100644
--- a/mlir/test/SDBM/sdbm-api-test.cpp
+++ b/mlir/test/SDBM/sdbm-api-test.cpp
@@ -19,6 +19,9 @@
using namespace mlir;
+// Load the SDBM dialect
+static DialectRegistration<SDBMDialect> SDBMRegistration;
+
static MLIRContext *ctx() {
static thread_local MLIRContext context;
return &context;
diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp
index 7003600984f9..0e885c555e38 100644
--- a/mlir/test/lib/IR/TestFunc.cpp
+++ b/mlir/test/lib/IR/TestFunc.cpp
@@ -51,8 +51,12 @@ struct TestFuncSetType : public ModulePass<TestFuncSetType> {
};
} // end anonymous namespace
-static PassRegistration<TestFuncEraseArg> pass("test-func-erase-arg",
- "Test erasing func args.");
-
-static PassRegistration<TestFuncSetType> pass2("test-func-set-type",
- "Test FuncOp::setType.");
+namespace mlir {
+void registerTestFunc() {
+ PassRegistration<TestFuncEraseArg> pass("test-func-erase-arg",
+ "Test erasing func args.");
+
+ PassRegistration<TestFuncSetType> pass2("test-func-set-type",
+ "Test FuncOp::setType.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/IR/TestMatchers.cpp b/mlir/test/lib/IR/TestMatchers.cpp
index 5620df3d6ed8..c6c144ef1fd0 100644
--- a/mlir/test/lib/IR/TestMatchers.cpp
+++ b/mlir/test/lib/IR/TestMatchers.cpp
@@ -146,5 +146,8 @@ void TestMatchers::runOnFunction() {
test2(f);
}
-static PassRegistration<TestMatchers> pass("test-matchers",
- "Test C++ pattern matchers.");
+namespace mlir {
+void registerTestMatchers() {
+ PassRegistration<TestMatchers>("test-matchers", "Test C++ pattern matchers.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/IR/TestSymbolUses.cpp b/mlir/test/lib/IR/TestSymbolUses.cpp
index 7757da5c968a..6082cdcbe72b 100644
--- a/mlir/test/lib/IR/TestSymbolUses.cpp
+++ b/mlir/test/lib/IR/TestSymbolUses.cpp
@@ -103,8 +103,12 @@ struct SymbolReplacementPass : public ModulePass<SymbolReplacementPass> {
};
} // end anonymous namespace
-static PassRegistration<SymbolUsesPass> pass("test-symbol-uses",
- "Test detection of symbol uses");
+namespace mlir {
+void registerSymbolTestPasses() {
+ PassRegistration<SymbolUsesPass>("test-symbol-uses",
+ "Test detection of symbol uses");
-static PassRegistration<SymbolReplacementPass>
- rauwPass("test-symbol-rauw", "Test replacement of symbol uses");
+ PassRegistration<SymbolReplacementPass>("test-symbol-rauw",
+ "Test replacement of symbol uses");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp
index 4097fd0675e9..95bef9b878e2 100644
--- a/mlir/test/lib/Pass/TestPassManager.cpp
+++ b/mlir/test/lib/Pass/TestPassManager.cpp
@@ -88,40 +88,43 @@ static void testNestedPipelineTextual(OpPassManager &pm) {
(void)parsePassPipeline("test-pm-nested-pipeline", pm);
}
-static PassRegistration<TestOptionsPass>
- reg("test-options-pass", "Test options parsing capabilities");
-
-static PassRegistration<TestModulePass>
- unusedMP("test-module-pass", "Test a module pass in the pass manager");
-static PassRegistration<TestFunctionPass>
- unusedFP("test-function-pass", "Test a function pass in the pass manager");
-
-static PassRegistration<TestCrashRecoveryPass>
- unusedCrashP("test-pass-crash",
- "Test a pass in the pass manager that always crashes");
-
-static PassRegistration<TestStatisticPass> unusedStatP("test-stats-pass",
- "Test pass statistics");
-
-static PassPipelineRegistration<>
- unused("test-pm-nested-pipeline",
- "Test a nested pipeline in the pass manager", testNestedPipeline);
-static PassPipelineRegistration<>
- unusedTextual("test-textual-pm-nested-pipeline",
- "Test a nested pipeline in the pass manager",
- testNestedPipelineTextual);
-static PassPipelineRegistration<>
- unusedDump("test-dump-pipeline",
- "Dumps the pipeline build so far for debugging purposes",
- [](OpPassManager &pm) {
- pm.printAsTextualPipeline(llvm::errs());
- llvm::errs() << "\n";
- });
-
-static PassPipelineRegistration<TestOptionsPass::Options>
- registerOptionsPassPipeline(
- "test-options-pass-pipeline",
- "Parses options using pass pipeline registration",
- [](OpPassManager &pm, const TestOptionsPass::Options &options) {
- pm.addPass(std::make_unique<TestOptionsPass>(options));
- });
+namespace mlir {
+void registerPassManagerTestPass() {
+ PassRegistration<TestOptionsPass>("test-options-pass",
+ "Test options parsing capabilities");
+
+ PassRegistration<TestModulePass>("test-module-pass",
+ "Test a module pass in the pass manager");
+
+ PassRegistration<TestFunctionPass>(
+ "test-function-pass", "Test a function pass in the pass manager");
+
+ PassRegistration<TestCrashRecoveryPass>(
+ "test-pass-crash", "Test a pass in the pass manager that always crashes");
+
+ PassRegistration<TestStatisticPass> unusedStatP("test-stats-pass",
+ "Test pass statistics");
+
+ PassPipelineRegistration<>("test-pm-nested-pipeline",
+ "Test a nested pipeline in the pass manager",
+ testNestedPipeline);
+ PassPipelineRegistration<>("test-textual-pm-nested-pipeline",
+ "Test a nested pipeline in the pass manager",
+ testNestedPipelineTextual);
+ PassPipelineRegistration<>(
+ "test-dump-pipeline",
+ "Dumps the pipeline build so far for debugging purposes",
+ [](OpPassManager &pm) {
+ pm.printAsTextualPipeline(llvm::errs());
+ llvm::errs() << "\n";
+ });
+
+ PassPipelineRegistration<TestOptionsPass::Options>
+ registerOptionsPassPipeline(
+ "test-options-pass-pipeline",
+ "Parses options using pass pipeline registration",
+ [](OpPassManager &pm, const TestOptionsPass::Options &options) {
+ pm.addPass(std::make_unique<TestOptionsPass>(options));
+ });
+}
+} // namespace mlir
diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp
index 30330052d5e5..d975d6719170 100644
--- a/mlir/test/lib/TestDialect/TestPatterns.cpp
+++ b/mlir/test/lib/TestDialect/TestPatterns.cpp
@@ -50,9 +50,6 @@ struct TestPatternDriver : public FunctionPass<TestPatternDriver> {
};
} // end anonymous namespace
-static mlir::PassRegistration<TestPatternDriver>
- pass("test-patterns", "Run test dialect patterns");
-
//===----------------------------------------------------------------------===//
// ReturnType Driver.
//===----------------------------------------------------------------------===//
@@ -107,9 +104,6 @@ struct TestReturnTypeDriver : public FunctionPass<TestReturnTypeDriver> {
};
} // end anonymous namespace
-static mlir::PassRegistration<TestReturnTypeDriver>
- rt_pass("test-return-type", "Run return type functions");
-
//===----------------------------------------------------------------------===//
// Legalization Driver.
//===----------------------------------------------------------------------===//
@@ -440,13 +434,6 @@ static llvm::cl::opt<TestLegalizePatternDriver::ConversionMode>
clEnumValN(TestLegalizePatternDriver::ConversionMode::Partial,
"partial", "Perform a partial conversion")));
-static mlir::PassRegistration<TestLegalizePatternDriver>
- legalizer_pass("test-legalize-patterns",
- "Run test dialect legalization patterns", [] {
- return std::make_unique<TestLegalizePatternDriver>(
- legalizerConversionMode);
- });
-
//===----------------------------------------------------------------------===//
// ConversionPatternRewriter::getRemappedValue testing. This method is used
// to get the remapped value of a original value that was replaced using
@@ -505,6 +492,22 @@ struct TestRemappedValue : public mlir::FunctionPass<TestRemappedValue> {
};
} // end anonymous namespace
-static PassRegistration<TestRemappedValue> remapped_value_pass(
- "test-remapped-value",
- "Test public remapped value mechanism in ConversionPatternRewriter");
+namespace mlir {
+void registerPatternsTestPass() {
+ mlir::PassRegistration<TestReturnTypeDriver>("test-return-type",
+ "Run return type functions");
+
+ mlir::PassRegistration<TestPatternDriver>("test-patterns",
+ "Run test dialect patterns");
+
+ mlir::PassRegistration<TestLegalizePatternDriver>(
+ "test-legalize-patterns", "Run test dialect legalization patterns", [] {
+ return std::make_unique<TestLegalizePatternDriver>(
+ legalizerConversionMode);
+ });
+
+ PassRegistration<TestRemappedValue>(
+ "test-remapped-value",
+ "Test public remapped value mechanism in ConversionPatternRewriter");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestAllReduceLowering.cpp b/mlir/test/lib/Transforms/TestAllReduceLowering.cpp
index fef08050d2f5..508f70887350 100644
--- a/mlir/test/lib/Transforms/TestAllReduceLowering.cpp
+++ b/mlir/test/lib/Transforms/TestAllReduceLowering.cpp
@@ -27,6 +27,10 @@ struct TestAllReduceLoweringPass
};
} // namespace
-static PassRegistration<TestAllReduceLoweringPass>
- pass("test-all-reduce-lowering",
- "Lowers gpu.all-reduce ops within the GPU dialect.");
+namespace mlir {
+void registerTestAllReduceLoweringPass() {
+ PassRegistration<TestAllReduceLoweringPass> pass(
+ "test-all-reduce-lowering",
+ "Lowers gpu.all-reduce ops within the GPU dialect.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestCallGraph.cpp b/mlir/test/lib/Transforms/TestCallGraph.cpp
index 13115c9cc578..89c25da9e8ed 100644
--- a/mlir/test/lib/Transforms/TestCallGraph.cpp
+++ b/mlir/test/lib/Transforms/TestCallGraph.cpp
@@ -25,6 +25,9 @@ struct TestCallGraphPass : public ModulePass<TestCallGraphPass> {
};
} // end anonymous namespace
-static PassRegistration<TestCallGraphPass>
- pass("test-print-callgraph",
- "Print the contents of a constructed callgraph.");
+namespace mlir {
+void registerTestCallGraphPass() {
+ PassRegistration<TestCallGraphPass> pass(
+ "test-print-callgraph", "Print the contents of a constructed callgraph.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestConstantFold.cpp b/mlir/test/lib/Transforms/TestConstantFold.cpp
index 4c19f7932da0..269f5f613c18 100644
--- a/mlir/test/lib/Transforms/TestConstantFold.cpp
+++ b/mlir/test/lib/Transforms/TestConstantFold.cpp
@@ -64,5 +64,9 @@ void TestConstantFold::runOnFunction() {
}
}
-static PassRegistration<TestConstantFold>
- pass("test-constant-fold", "Test operation constant folding");
+namespace mlir {
+void registerTestConstantFold() {
+ PassRegistration<TestConstantFold>("test-constant-fold",
+ "Test operation constant folding");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
index 24ea0d95cf41..72304244d8fc 100644
--- a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
+++ b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
@@ -35,6 +35,10 @@ class TestGpuMemoryPromotionPass
};
} // end namespace
-static PassRegistration<TestGpuMemoryPromotionPass> registration(
- "test-gpu-memory-promotion",
- "Promotes the annotated arguments of gpu.func to workgroup memory.");
+namespace mlir {
+void registerTestGpuMemoryPromotionPass() {
+ PassRegistration<TestGpuMemoryPromotionPass>(
+ "test-gpu-memory-promotion",
+ "Promotes the annotated arguments of gpu.func to workgroup memory.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestInlining.cpp b/mlir/test/lib/Transforms/TestInlining.cpp
index 3d64b55c46ac..513594f655cc 100644
--- a/mlir/test/lib/Transforms/TestInlining.cpp
+++ b/mlir/test/lib/Transforms/TestInlining.cpp
@@ -60,5 +60,8 @@ struct Inliner : public FunctionPass<Inliner> {
};
} // end anonymous namespace
-static PassRegistration<Inliner> pass("test-inline",
- "Test inlining region calls");
+namespace mlir {
+void registerInliner() {
+ PassRegistration<Inliner>("test-inline", "Test inlining region calls");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
index 94e4a887a4e3..645ce887135d 100644
--- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
@@ -47,6 +47,10 @@ void TestLinalgTransforms::runOnFunction() {
});
}
-static PassRegistration<TestLinalgTransforms>
- pass("test-linalg-transform-patterns",
- "Test Linalg transformation patterns by applying them greedily.");
+namespace mlir {
+void registerTestLinalgTransforms() {
+ PassRegistration<TestLinalgTransforms>(
+ "test-linalg-transform-patterns",
+ "Test Linalg transformation patterns by applying them greedily.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestLiveness.cpp b/mlir/test/lib/Transforms/TestLiveness.cpp
index 64276157ced9..9b98ebd49a9c 100644
--- a/mlir/test/lib/Transforms/TestLiveness.cpp
+++ b/mlir/test/lib/Transforms/TestLiveness.cpp
@@ -28,6 +28,10 @@ struct TestLivenessPass : public FunctionPass<TestLivenessPass> {
} // end anonymous namespace
-static PassRegistration<TestLivenessPass>
- pass("test-print-liveness",
- "Print the contents of a constructed liveness information.");
+namespace mlir {
+void registerTestLivenessPass() {
+ PassRegistration<TestLivenessPass>(
+ "test-print-liveness",
+ "Print the contents of a constructed liveness information.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp
index 93e6fd450160..9ffa347173f6 100644
--- a/mlir/test/lib/Transforms/TestLoopFusion.cpp
+++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp
@@ -54,10 +54,6 @@ struct TestLoopFusion : public FunctionPass<TestLoopFusion> {
} // end anonymous namespace
-std::unique_ptr<OpPassBase<FuncOp>> mlir::createTestLoopFusionPass() {
- return std::make_unique<TestLoopFusion>();
-}
-
// Gathers all AffineForOps in 'block' at 'currLoopDepth' in 'depthToLoops'.
static void
gatherLoops(Block *block, unsigned currLoopDepth,
@@ -218,5 +214,9 @@ void TestLoopFusion::runOnFunction() {
iterateLoops(depthToLoops, testSliceComputation);
}
-static PassRegistration<TestLoopFusion>
- pass("test-loop-fusion", "Tests loop fusion utility functions.");
+namespace mlir {
+void registerTestLoopFusion() {
+ PassRegistration<TestLoopFusion>("test-loop-fusion",
+ "Tests loop fusion utility functions.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp
index f20a0ba19c33..ee96d630ae0e 100644
--- a/mlir/test/lib/Transforms/TestLoopMapping.cpp
+++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp
@@ -50,7 +50,10 @@ class TestLoopMappingPass : public FunctionPass<TestLoopMappingPass> {
};
} // end namespace
-static PassRegistration<TestLoopMappingPass>
- reg("test-mapping-to-processing-elements",
- "test mapping a single loop on a virtual processor grid",
- [] { return std::make_unique<TestLoopMappingPass>(); });
+namespace mlir {
+void registerTestLoopMappingPass() {
+ PassRegistration<TestLoopMappingPass>(
+ "test-mapping-to-processing-elements",
+ "test mapping a single loop on a virtual processor grid");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
index 0ef602a746f3..f82ea3aed284 100644
--- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
+++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
@@ -48,12 +48,11 @@ class SimpleParametricLoopTilingPass
};
} // end namespace
-std::unique_ptr<OpPassBase<FuncOp>>
-mlir::createSimpleParametricTilingPass(ArrayRef<int64_t> outerLoopSizes) {
- return std::make_unique<SimpleParametricLoopTilingPass>(outerLoopSizes);
+namespace mlir {
+void registerSimpleParametricTilingPass() {
+ PassRegistration<SimpleParametricLoopTilingPass>(
+ "test-extract-fixed-outer-loops",
+ "test application of parametric tiling to the outer loops so that the "
+ "ranges of outer loops become static");
}
-
-static PassRegistration<SimpleParametricLoopTilingPass>
- reg("test-extract-fixed-outer-loops",
- "test application of parametric tiling to the outer loops so that the "
- "ranges of outer loops become static");
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
index bd53956ee1f4..224d9c34e73d 100644
--- a/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
+++ b/mlir/test/lib/Transforms/TestMemRefBoundCheck.cpp
@@ -48,6 +48,9 @@ void TestMemRefBoundCheck::runOnFunction() {
});
}
-static PassRegistration<TestMemRefBoundCheck>
- memRefBoundCheck("test-memref-bound-check",
- "Check memref access bounds in a Function");
+namespace mlir {
+void registerMemRefBoundCheck() {
+ PassRegistration<TestMemRefBoundCheck>(
+ "test-memref-bound-check", "Check memref access bounds in a Function");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp
index f9c45c5cb338..289c9a75f5b1 100644
--- a/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp
+++ b/mlir/test/lib/Transforms/TestMemRefDependenceCheck.cpp
@@ -116,6 +116,10 @@ void TestMemRefDependenceCheck::runOnFunction() {
checkDependences(loadsAndStores);
}
-static PassRegistration<TestMemRefDependenceCheck>
- pass("test-memref-dependence-check",
- "Checks dependences between all pairs of memref accesses.");
+namespace mlir {
+void registerTestMemRefDependenceCheck() {
+ PassRegistration<TestMemRefDependenceCheck> pass(
+ "test-memref-dependence-check",
+ "Checks dependences between all pairs of memref accesses.");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
index 3c80741c1d7d..52af86e39682 100644
--- a/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
+++ b/mlir/test/lib/Transforms/TestMemRefStrideCalculation.cpp
@@ -50,5 +50,9 @@ void TestMemRefStrideCalculation::runOnFunction() {
llvm::outs().flush();
}
-static PassRegistration<TestMemRefStrideCalculation>
- pass("test-memref-stride-calculation", "Test operation constant folding");
+namespace mlir {
+void registerTestMemRefStrideCalculation() {
+ PassRegistration<TestMemRefStrideCalculation> pass(
+ "test-memref-stride-calculation", "Test operation constant folding");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp
index 1b21b0013d97..5f2dab20ea09 100644
--- a/mlir/test/lib/Transforms/TestOpaqueLoc.cpp
+++ b/mlir/test/lib/Transforms/TestOpaqueLoc.cpp
@@ -80,5 +80,9 @@ struct TestOpaqueLoc : public ModulePass<TestOpaqueLoc> {
} // end anonymous namespace
-static PassRegistration<TestOpaqueLoc>
- pass("test-opaque-loc", "Changes all leaf locations to opaque locations");
+namespace mlir {
+void registerTestOpaqueLoc() {
+ PassRegistration<TestOpaqueLoc> pass(
+ "test-opaque-loc", "Changes all leaf locations to opaque locations");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestParallelismDetection.cpp b/mlir/test/lib/Transforms/TestParallelismDetection.cpp
index eca8dda4aaa7..7c16a259723f 100644
--- a/mlir/test/lib/Transforms/TestParallelismDetection.cpp
+++ b/mlir/test/lib/Transforms/TestParallelismDetection.cpp
@@ -27,9 +27,6 @@ struct TestParallelismDetection
} // end anonymous namespace
-std::unique_ptr<OpPassBase<FuncOp>> mlir::createParallelismDetectionTestPass() {
- return std::make_unique<TestParallelismDetection>();
-}
// Walks the function and emits a note for all 'affine.for' ops detected as
// parallel.
@@ -44,5 +41,9 @@ void TestParallelismDetection::runOnFunction() {
});
}
-static PassRegistration<TestParallelismDetection>
- pass("test-detect-parallel", "Test parallelism detection ");
+namespace mlir {
+void registerTestParallelismDetection() {
+ PassRegistration<TestParallelismDetection> pass(
+ "test-detect-parallel", "Test parallelism detection ");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp
index 2d4329db3aa2..88d08ce63119 100644
--- a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp
+++ b/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp
@@ -29,6 +29,10 @@ struct TestVectorToLoopsPass
} // end anonymous namespace
-static PassRegistration<TestVectorToLoopsPass>
- pass("test-convert-vector-to-loops",
- "Converts vector transfer ops to loops over scalars and vector casts");
+namespace mlir {
+void registerTestVectorToLoopsPass() {
+ PassRegistration<TestVectorToLoopsPass> pass(
+ "test-convert-vector-to-loops",
+ "Converts vector transfer ops to loops over scalars and vector casts");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestVectorTransforms.cpp b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
index 09561cfb1861..d0ac7189a4d9 100644
--- a/mlir/test/lib/Transforms/TestVectorTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestVectorTransforms.cpp
@@ -44,10 +44,14 @@ struct TestVectorSlicesConversion
} // end anonymous namespace
-static PassRegistration<TestVectorToVectorConversion>
- pass("test-vector-to-vector-conversion",
- "Test conversion patterns between ops in the vector dialect");
-
-static PassRegistration<TestVectorSlicesConversion> slices_pass(
- "test-vector-slices-conversion",
- "Test conversion patterns that lower slices ops in the vector dialect");
+namespace mlir {
+void registerTestVectorConversions() {
+ PassRegistration<TestVectorToVectorConversion> pass(
+ "test-vector-to-vector-conversion",
+ "Test conversion patterns between ops in the vector dialect");
+
+ PassRegistration<TestVectorSlicesConversion> slices_pass(
+ "test-vector-slices-conversion",
+ "Test conversion patterns that lower slices ops in the vector dialect");
+}
+} // namespace mlir
diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp
index 05705ae5f72a..50086e5c333a 100644
--- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp
+++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp
@@ -281,12 +281,9 @@ void VectorizerTestPass::runOnFunction() {
}
}
-std::unique_ptr<OpPassBase<FuncOp>> mlir::createVectorizerTestPass() {
- return std::make_unique<VectorizerTestPass>();
+namespace mlir {
+void registerVectorizerTestPass() {
+ PassRegistration<VectorizerTestPass> pass(
+ "affine-vectorizer-test", "Tests vectorizer standalone functionality.");
}
-
-static PassRegistration<VectorizerTestPass>
- pass("affine-vectorizer-test",
- "Tests vectorizer standalone functionality.");
-
-#undef DEBUG_TYPE
+} // namespace mlir
diff --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
index 21da9052d05c..b0676ef7de71 100644
--- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
@@ -2,13 +2,8 @@ add_llvm_tool(mlir-cpu-runner
mlir-cpu-runner.cpp
)
llvm_update_compile_flags(mlir-cpu-runner)
-whole_archive_link(mlir-cpu-runner
- MLIRAffineOps
- MLIRLLVMIR
- MLIRTargetLLVMIR
- MLIRTranslation
-)
target_link_libraries(mlir-cpu-runner PRIVATE
+ MLIRAllDialects
MLIRAnalysis
MLIREDSC
MLIRExecutionEngine
diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index 2277c4110d3d..b7e1b4442e21 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -18,7 +18,7 @@ target_link_libraries(MLIRMlirOptMain
${LIB_LIBS}
)
-set(FULL_LINK_LIBS
+set(LIBS
MLIRLoopAnalysis
MLIRAnalysis
MLIRAffineOps
@@ -68,8 +68,6 @@ set(FULL_LINK_LIBS
MLIRVectorOps
MLIRVectorToLLVM
MLIRVectorToLoops
-)
-set(LIBS
MLIRIR
MLIROptLib
LLVMSupport
@@ -82,19 +80,12 @@ if(MLIR_CUDA_CONVERSIONS_ENABLED)
LLVMNVPTXCodeGen
LLVMNVPTXDesc
LLVMNVPTXInfo
- MLIRTargetNVVMIR
- )
- # Order matters here, so insert at front.
- list(INSERT FULL_LINK_LIBS 0
MLIRGPUtoCUDATransforms
+ MLIRTargetNVVMIR
)
endif()
add_llvm_tool(mlir-opt
mlir-opt.cpp
)
llvm_update_compile_flags(mlir-opt)
-# It is necessary to use whole_archive_link to ensure that all static
-# initializers are called. However, whole_archive_link libraries cannot
-# also be target_link_libraries.
-whole_archive_link(mlir-opt ${FULL_LINK_LIBS})
target_link_libraries(mlir-opt PRIVATE ${LIBS})
diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index f637a2feea95..bf6b57c2b624 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -11,6 +11,8 @@
//===----------------------------------------------------------------------===//
#include "mlir/Analysis/Passes.h"
+#include "mlir/InitAllDialects.h"
+#include "mlir/InitAllPasses.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/FileUtilities.h"
@@ -23,6 +25,34 @@
using namespace llvm;
using namespace mlir;
+namespace mlir {
+// Defined in the test directory, no public header.
+void registerConvertToTargetEnvPass();
+void registerInliner();
+void registerMemRefBoundCheck();
+void registerPassManagerTestPass();
+void registerPatternsTestPass();
+void registerSimpleParametricTilingPass();
+void registerSymbolTestPasses();
+void registerTestAllReduceLoweringPass();
+void registerTestCallGraphPass();
+void registerTestConstantFold();
+void registerTestFunc();
+void registerTestGpuMemoryPromotionPass();
+void registerTestLinalgTransforms();
+void registerTestLivenessPass();
+void registerTestLoopFusion();
+void registerTestLoopMappingPass();
+void registerTestMatchers();
+void registerTestMemRefDependenceCheck();
+void registerTestMemRefStrideCalculation();
+void registerTestOpaqueLoc();
+void registerTestParallelismDetection();
+void registerTestVectorConversions();
+void registerTestVectorToLoopsPass();
+void registerVectorizerTestPass();
+} // namespace mlir
+
static cl::opt<std::string>
inputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
@@ -47,7 +77,45 @@ static cl::opt<bool>
cl::desc("Run the verifier after each transformation pass"),
cl::init(true));
+void registerTestPasses() {
+ registerConvertToTargetEnvPass();
+ registerInliner();
+ registerMemRefBoundCheck();
+ registerPassManagerTestPass();
+ registerPatternsTestPass();
+ registerSimpleParametricTilingPass();
+ registerSymbolTestPasses();
+ registerTestAllReduceLoweringPass();
+ registerTestCallGraphPass();
+ registerTestConstantFold();
+ registerTestFunc();
+ registerTestGpuMemoryPromotionPass();
+ registerTestLinalgTransforms();
+ registerTestLivenessPass();
+ registerTestLoopFusion();
+ registerTestLoopMappingPass();
+ registerTestMatchers();
+ registerTestMemRefDependenceCheck();
+ registerTestMemRefStrideCalculation();
+ registerTestOpaqueLoc();
+ registerTestParallelismDetection();
+ registerTestVectorConversions();
+ registerTestVectorToLoopsPass();
+ registerVectorizerTestPass();
+
+ // The following passes are using global initializers, just link them in.
+ if (std::getenv("bar") != (char *)-1)
+ return;
+
+ // TODO: move these to the test folder.
+ createTestMemRefBoundCheckPass();
+ createTestMemRefDependenceCheckPass();
+}
+
int main(int argc, char **argv) {
+ registerAllDialects();
+ registerAllPasses();
+ registerTestPasses();
InitLLVM y(argc, argv);
// Register any pass manager command line options.
diff --git a/mlir/tools/mlir-translate/CMakeLists.txt b/mlir/tools/mlir-translate/CMakeLists.txt
index 9d585579060d..4b95a953e867 100644
--- a/mlir/tools/mlir-translate/CMakeLists.txt
+++ b/mlir/tools/mlir-translate/CMakeLists.txt
@@ -1,4 +1,5 @@
set(LIBS
+ MLIRAllDialects
MLIRParser
MLIRPass
MLIRSPIRV
@@ -9,9 +10,15 @@ set(LIBS
MLIRTranslation
MLIRSupport
)
+set(FULL_LIBS
+ MLIRSPIRVSerialization
+ MLIRTargetLLVMIR
+ MLIRTargetNVVMIR
+ MLIRTargetROCDLIR
+)
add_llvm_tool(mlir-translate
mlir-translate.cpp
)
llvm_update_compile_flags(mlir-translate)
-whole_archive_link(mlir-translate ${LIBS})
+whole_archive_link(mlir-translate ${FULL_LIBS})
target_link_libraries(mlir-translate PRIVATE MLIRIR MLIRTranslateClParser ${LIBS} LLVMSupport)
diff --git a/mlir/tools/mlir-translate/mlir-translate.cpp b/mlir/tools/mlir-translate/mlir-translate.cpp
index 5181436d7c8d..cd1b226deff7 100644
--- a/mlir/tools/mlir-translate/mlir-translate.cpp
+++ b/mlir/tools/mlir-translate/mlir-translate.cpp
@@ -13,6 +13,7 @@
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/MLIRContext.h"
+#include "mlir/InitAllDialects.h"
#include "mlir/Support/FileUtilities.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Support/ToolUtilities.h"
@@ -45,6 +46,7 @@ static llvm::cl::opt<bool> verifyDiagnostics(
llvm::cl::init(false));
int main(int argc, char **argv) {
+ registerAllDialects();
llvm::InitLLVM y(argc, argv);
// Add flags for all the registered translations.
diff --git a/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp b/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp
index 46dc57fb4da3..e6188ea0de7e 100644
--- a/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp
+++ b/mlir/unittests/Dialect/QuantOps/QuantizationUtilsTest.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "mlir/Dialect/QuantOps/QuantOps.h"
#include "mlir/Dialect/QuantOps/QuantizeUtils.h"
#include "mlir/Dialect/QuantOps/UniformSupport.h"
#include "mlir/IR/Attributes.h"
@@ -16,6 +17,9 @@
using namespace mlir;
using namespace mlir::quant;
+// Load the quant dialect
+static DialectRegistration<QuantizationDialect> QuantOpsRegistration;
+
namespace {
// Test UniformQuantizedValueConverter converts all APFloat to a magic number 5.
diff --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
index bcc3d1cb29ae..bee6a2d434b3 100644
--- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
+++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVBinaryUtils.h"
+#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Serialization.h"
#include "mlir/IR/Diagnostics.h"
@@ -23,6 +24,9 @@
using namespace mlir;
+// Load the SPIRV dialect
+static DialectRegistration<spirv::SPIRVDialect> SPIRVRegistration;
+
using ::testing::StrEq;
//===----------------------------------------------------------------------===//
diff --git a/mlir/unittests/SDBM/SDBMTest.cpp b/mlir/unittests/SDBM/SDBMTest.cpp
index eadb3597f1dd..e599094ee592 100644
--- a/mlir/unittests/SDBM/SDBMTest.cpp
+++ b/mlir/unittests/SDBM/SDBMTest.cpp
@@ -17,6 +17,9 @@
using namespace mlir;
+// Load the SDBM dialect
+static DialectRegistration<SDBMDialect> SDBMRegistration;
+
static MLIRContext *ctx() {
static thread_local MLIRContext context;
return &context;
More information about the Mlir-commits
mailing list