[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / mlir / tools / mlir-opt / mlir-opt.cpp
blob94bc67a1e96093e953dbe33969c59107c427f2e1
1 //===- mlir-opt.cpp - MLIR Optimizer Driver -------------------------------===//
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 // Main entry function for mlir-opt for when built as standalone binary.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Config/mlir-config.h"
14 #include "mlir/IR/AsmState.h"
15 #include "mlir/IR/Dialect.h"
16 #include "mlir/IR/MLIRContext.h"
17 #include "mlir/InitAllDialects.h"
18 #include "mlir/InitAllExtensions.h"
19 #include "mlir/InitAllPasses.h"
20 #include "mlir/Pass/Pass.h"
21 #include "mlir/Pass/PassManager.h"
22 #include "mlir/Support/FileUtilities.h"
23 #include "mlir/Target/LLVMIR/Dialect/All.h"
24 #include "mlir/Tools/mlir-opt/MlirOptMain.h"
25 #include "llvm/Support/CommandLine.h"
26 #include "llvm/Support/InitLLVM.h"
27 #include "llvm/Support/SourceMgr.h"
28 #include "llvm/Support/ToolOutputFile.h"
30 using namespace llvm;
31 using namespace mlir;
33 // Defined in the test directory, no public header.
34 namespace mlir {
35 void registerCloneTestPasses();
36 void registerConvertToTargetEnvPass();
37 void registerLazyLoadingTestPasses();
38 void registerLoopLikeInterfaceTestPasses();
39 void registerPassManagerTestPass();
40 void registerPrintSpirvAvailabilityPass();
41 void registerRegionTestPasses();
42 void registerShapeFunctionTestPasses();
43 void registerSideEffectTestPasses();
44 void registerSliceAnalysisTestPass();
45 void registerSymbolTestPasses();
46 void registerTestAffineAccessAnalysisPass();
47 void registerTestAffineDataCopyPass();
48 void registerTestAffineLoopUnswitchingPass();
49 void registerTestAffineReifyValueBoundsPass();
50 void registerTestAffineWalk();
51 void registerTestBytecodeRoundtripPasses();
52 void registerTestDecomposeAffineOpPass();
53 void registerTestFunc();
54 void registerTestGpuLoweringPasses();
55 void registerTestGpuMemoryPromotionPass();
56 void registerTestLoopPermutationPass();
57 void registerTestMatchers();
58 void registerTestOperationEqualPass();
59 void registerTestPreserveUseListOrders();
60 void registerTestPrintDefUsePass();
61 void registerTestPrintInvalidPass();
62 void registerTestPrintNestingPass();
63 void registerTestReducer();
64 void registerTestSpirvEntryPointABIPass();
65 void registerTestSpirvModuleCombinerPass();
66 void registerTestTraitsPass();
67 void registerTosaTestQuantUtilAPIPass();
68 void registerVectorizerTestPass();
70 namespace test {
71 void registerCommutativityUtils();
72 void registerConvertCallOpPass();
73 void registerConvertFuncOpPass();
74 void registerInliner();
75 void registerMemRefBoundCheck();
76 void registerPatternsTestPass();
77 void registerSimpleParametricTilingPass();
78 void registerTestAffineLoopParametricTilingPass();
79 void registerTestAliasAnalysisPass();
80 void registerTestArithEmulateWideIntPass();
81 void registerTestBuiltinAttributeInterfaces();
82 void registerTestBuiltinDistinctAttributes();
83 void registerTestCallGraphPass();
84 void registerTestCfAssertPass();
85 void registerTestCFGLoopInfoPass();
86 void registerTestComposeSubView();
87 void registerTestCompositePass();
88 void registerTestConstantFold();
89 void registerTestControlFlowSink();
90 void registerTestDataLayoutPropagation();
91 void registerTestDataLayoutQuery();
92 void registerTestDeadCodeAnalysisPass();
93 void registerTestDecomposeCallGraphTypes();
94 void registerTestDiagnosticsPass();
95 void registerTestDiagnosticsMetadataPass();
96 void registerTestDominancePass();
97 void registerTestDynamicPipelinePass();
98 void registerTestEmulateNarrowTypePass();
99 void registerTestExpandMathPass();
100 void registerTestFooAnalysisPass();
101 void registerTestComposeSubView();
102 void registerTestMultiBuffering();
103 void registerTestIRVisitorsPass();
104 void registerTestGenericIRVisitorsPass();
105 void registerTestInterfaces();
106 void registerTestIRVisitorsPass();
107 void registerTestLastModifiedPass();
108 void registerTestLinalgDecomposeOps();
109 void registerTestLinalgDropUnitDims();
110 void registerTestLinalgElementwiseFusion();
111 void registerTestLinalgGreedyFusion();
112 void registerTestLinalgRankReduceContractionOps();
113 void registerTestLinalgTransforms();
114 void registerTestLivenessAnalysisPass();
115 void registerTestLivenessPass();
116 void registerTestLLVMLegalizePatternsPass();
117 void registerTestLoopFusion();
118 void registerTestLoopMappingPass();
119 void registerTestLoopUnrollingPass();
120 void registerTestLowerToArmNeon();
121 void registerTestLowerToArmSME();
122 void registerTestLowerToLLVM();
123 void registerTestMakeIsolatedFromAbovePass();
124 void registerTestMatchReductionPass();
125 void registerTestMathAlgebraicSimplificationPass();
126 void registerTestMathPolynomialApproximationPass();
127 void registerTestMathToVCIXPass();
128 void registerTestMemRefDependenceCheck();
129 void registerTestMemRefStrideCalculation();
130 void registerTestMeshReshardingSpmdizationPass();
131 void registerTestMeshSimplificationsPass();
132 void registerTestMultiBuffering();
133 void registerTestNextAccessPass();
134 void registerTestNVGPULowerings();
135 void registerTestOneToNTypeConversionPass();
136 void registerTestOpaqueLoc();
137 void registerTestOpLoweringPasses();
138 void registerTestPadFusion();
139 void registerTestRecursiveTypesPass();
140 void registerTestSCFUpliftWhileToFor();
141 void registerTestSCFUtilsPass();
142 void registerTestSCFWhileOpBuilderPass();
143 void registerTestSCFWrapInZeroTripCheckPasses();
144 void registerTestShapeMappingPass();
145 void registerTestSliceAnalysisPass();
146 void registerTestSPIRVCPURunnerPipeline();
147 void registerTestSPIRVFuncSignatureConversion();
148 void registerTestSPIRVVectorUnrolling();
149 void registerTestTensorCopyInsertionPass();
150 void registerTestTensorTransforms();
151 void registerTestTopologicalSortAnalysisPass();
152 void registerTestTransformDialectEraseSchedulePass();
153 void registerTestPassStateExtensionCommunication();
154 void registerTestVectorLowerings();
155 void registerTestVectorReductionToSPIRVDotProd();
156 void registerTestWrittenToPass();
157 #if MLIR_ENABLE_PDL_IN_PATTERNMATCH
158 void registerTestDialectConversionPasses();
159 void registerTestPDLByteCodePass();
160 void registerTestPDLLPasses();
161 #endif
162 } // namespace test
163 } // namespace mlir
165 namespace test {
166 void registerTestDialect(DialectRegistry &);
167 void registerTestDynDialect(DialectRegistry &);
168 void registerTestTilingInterfaceTransformDialectExtension(DialectRegistry &);
169 void registerTestTransformDialectExtension(DialectRegistry &);
170 } // namespace test
172 #ifdef MLIR_INCLUDE_TESTS
173 void registerTestPasses() {
174 registerCloneTestPasses();
175 registerConvertToTargetEnvPass();
176 registerLazyLoadingTestPasses();
177 registerLoopLikeInterfaceTestPasses();
178 registerPassManagerTestPass();
179 registerPrintSpirvAvailabilityPass();
180 registerRegionTestPasses();
181 registerShapeFunctionTestPasses();
182 registerSideEffectTestPasses();
183 registerSliceAnalysisTestPass();
184 registerSymbolTestPasses();
185 registerTestAffineAccessAnalysisPass();
186 registerTestAffineDataCopyPass();
187 registerTestAffineLoopUnswitchingPass();
188 registerTestAffineReifyValueBoundsPass();
189 registerTestAffineWalk();
190 registerTestBytecodeRoundtripPasses();
191 registerTestDecomposeAffineOpPass();
192 registerTestFunc();
193 registerTestGpuLoweringPasses();
194 registerTestGpuMemoryPromotionPass();
195 registerTestLoopPermutationPass();
196 registerTestMatchers();
197 registerTestOperationEqualPass();
198 registerTestPreserveUseListOrders();
199 registerTestPrintDefUsePass();
200 registerTestPrintInvalidPass();
201 registerTestPrintNestingPass();
202 registerTestReducer();
203 registerTestSpirvEntryPointABIPass();
204 registerTestSpirvModuleCombinerPass();
205 registerTestTraitsPass();
206 registerTosaTestQuantUtilAPIPass();
207 registerVectorizerTestPass();
209 mlir::test::registerCommutativityUtils();
210 mlir::test::registerConvertCallOpPass();
211 mlir::test::registerConvertFuncOpPass();
212 mlir::test::registerInliner();
213 mlir::test::registerMemRefBoundCheck();
214 mlir::test::registerPatternsTestPass();
215 mlir::test::registerSimpleParametricTilingPass();
216 mlir::test::registerTestAffineLoopParametricTilingPass();
217 mlir::test::registerTestAliasAnalysisPass();
218 mlir::test::registerTestArithEmulateWideIntPass();
219 mlir::test::registerTestBuiltinAttributeInterfaces();
220 mlir::test::registerTestBuiltinDistinctAttributes();
221 mlir::test::registerTestCallGraphPass();
222 mlir::test::registerTestCfAssertPass();
223 mlir::test::registerTestCFGLoopInfoPass();
224 mlir::test::registerTestComposeSubView();
225 mlir::test::registerTestCompositePass();
226 mlir::test::registerTestConstantFold();
227 mlir::test::registerTestControlFlowSink();
228 mlir::test::registerTestDataLayoutPropagation();
229 mlir::test::registerTestDataLayoutQuery();
230 mlir::test::registerTestDeadCodeAnalysisPass();
231 mlir::test::registerTestDecomposeCallGraphTypes();
232 mlir::test::registerTestDiagnosticsPass();
233 mlir::test::registerTestDiagnosticsMetadataPass();
234 mlir::test::registerTestDominancePass();
235 mlir::test::registerTestDynamicPipelinePass();
236 mlir::test::registerTestEmulateNarrowTypePass();
237 mlir::test::registerTestExpandMathPass();
238 mlir::test::registerTestFooAnalysisPass();
239 mlir::test::registerTestComposeSubView();
240 mlir::test::registerTestMultiBuffering();
241 mlir::test::registerTestIRVisitorsPass();
242 mlir::test::registerTestGenericIRVisitorsPass();
243 mlir::test::registerTestInterfaces();
244 mlir::test::registerTestIRVisitorsPass();
245 mlir::test::registerTestLastModifiedPass();
246 mlir::test::registerTestLinalgDecomposeOps();
247 mlir::test::registerTestLinalgDropUnitDims();
248 mlir::test::registerTestLinalgElementwiseFusion();
249 mlir::test::registerTestLinalgGreedyFusion();
250 mlir::test::registerTestLinalgRankReduceContractionOps();
251 mlir::test::registerTestLinalgTransforms();
252 mlir::test::registerTestLivenessAnalysisPass();
253 mlir::test::registerTestLivenessPass();
254 mlir::test::registerTestLLVMLegalizePatternsPass();
255 mlir::test::registerTestLoopFusion();
256 mlir::test::registerTestLoopMappingPass();
257 mlir::test::registerTestLoopUnrollingPass();
258 mlir::test::registerTestLowerToArmNeon();
259 mlir::test::registerTestLowerToArmSME();
260 mlir::test::registerTestLowerToLLVM();
261 mlir::test::registerTestMakeIsolatedFromAbovePass();
262 mlir::test::registerTestMatchReductionPass();
263 mlir::test::registerTestMathAlgebraicSimplificationPass();
264 mlir::test::registerTestMathPolynomialApproximationPass();
265 mlir::test::registerTestMathToVCIXPass();
266 mlir::test::registerTestMemRefDependenceCheck();
267 mlir::test::registerTestMemRefStrideCalculation();
268 mlir::test::registerTestMeshReshardingSpmdizationPass();
269 mlir::test::registerTestMeshSimplificationsPass();
270 mlir::test::registerTestMultiBuffering();
271 mlir::test::registerTestNextAccessPass();
272 mlir::test::registerTestNVGPULowerings();
273 mlir::test::registerTestOneToNTypeConversionPass();
274 mlir::test::registerTestOpaqueLoc();
275 mlir::test::registerTestOpLoweringPasses();
276 mlir::test::registerTestPadFusion();
277 mlir::test::registerTestRecursiveTypesPass();
278 mlir::test::registerTestSCFUpliftWhileToFor();
279 mlir::test::registerTestSCFUtilsPass();
280 mlir::test::registerTestSCFWhileOpBuilderPass();
281 mlir::test::registerTestSCFWrapInZeroTripCheckPasses();
282 mlir::test::registerTestShapeMappingPass();
283 mlir::test::registerTestSliceAnalysisPass();
284 mlir::test::registerTestSPIRVCPURunnerPipeline();
285 mlir::test::registerTestSPIRVFuncSignatureConversion();
286 mlir::test::registerTestSPIRVVectorUnrolling();
287 mlir::test::registerTestTensorCopyInsertionPass();
288 mlir::test::registerTestTensorTransforms();
289 mlir::test::registerTestTopologicalSortAnalysisPass();
290 mlir::test::registerTestTransformDialectEraseSchedulePass();
291 mlir::test::registerTestPassStateExtensionCommunication();
292 mlir::test::registerTestVectorLowerings();
293 mlir::test::registerTestVectorReductionToSPIRVDotProd();
294 mlir::test::registerTestWrittenToPass();
295 #if MLIR_ENABLE_PDL_IN_PATTERNMATCH
296 mlir::test::registerTestDialectConversionPasses();
297 mlir::test::registerTestPDLByteCodePass();
298 mlir::test::registerTestPDLLPasses();
299 #endif
301 #endif
303 int main(int argc, char **argv) {
304 registerAllPasses();
305 #ifdef MLIR_INCLUDE_TESTS
306 registerTestPasses();
307 #endif
308 DialectRegistry registry;
309 registerAllDialects(registry);
310 registerAllExtensions(registry);
312 // TODO: Remove this and the corresponding MLIRToLLVMIRTranslationRegistration
313 // cmake dependency when a safe dialect interface registration mechanism is
314 // implemented, see D157703 (and corresponding note on the declaration).
315 registerAllGPUToLLVMIRTranslations(registry);
317 #ifdef MLIR_INCLUDE_TESTS
318 ::test::registerTestDialect(registry);
319 ::test::registerTestTransformDialectExtension(registry);
320 ::test::registerTestTilingInterfaceTransformDialectExtension(registry);
321 ::test::registerTestDynDialect(registry);
322 #endif
323 return mlir::asMainReturnCode(mlir::MlirOptMain(
324 argc, argv, "MLIR modular optimizer driver\n", registry));