1 //===-- transform-opt.cpp - Transform dialect tutorial entry point --------===//
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
7 //===----------------------------------------------------------------------===//
9 // This is the top-level file for the Transform dialect tutorial chapter 2.
11 //===----------------------------------------------------------------------===//
13 #include "MyExtension.h"
15 #include "mlir/IR/DialectRegistry.h"
16 #include "mlir/IR/MLIRContext.h"
17 #include "mlir/InitAllDialects.h"
18 #include "mlir/InitAllExtensions.h"
19 #include "mlir/Tools/mlir-opt/MlirOptMain.h"
20 #include "mlir/Transforms/Passes.h"
23 // Forward declarations of test passes that used in this chapter for
24 // illustrative purposes. Test passes are not directly exposed for use in
25 // binaries other than mlir-opt, which is too big to serve as an example.
26 namespace mlir::test
{
27 void registerTestTransformDialectEraseSchedulePass();
28 void registerTestTransformDialectInterpreterPass();
29 } // namespace mlir::test
32 void registerTestTransformDialectExtension(mlir::DialectRegistry
&);
35 int main(int argc
, char **argv
) {
36 // Register all "core" dialects and our transform dialect extension.
37 mlir::DialectRegistry registry
;
38 mlir::registerAllDialects(registry
);
39 mlir::registerAllExtensions(registry
);
40 registerMyExtension(registry
);
42 // Register a handful of cleanup passes that we can run to make the output IR
44 mlir::registerCanonicalizerPass();
45 mlir::registerCSEPass();
46 mlir::registerSymbolDCEPass();
48 // Register the test passes.
49 #ifdef MLIR_INCLUDE_TESTS
50 mlir::test::registerTestTransformDialectEraseSchedulePass();
51 mlir::test::registerTestTransformDialectInterpreterPass();
52 test::registerTestTransformDialectExtension(registry
);
54 llvm::errs() << "warning: MLIR built without test passes, interpreter "
55 "testing will not be available\n";
56 #endif // MLIR_INCLUDE_TESTS
58 // Delegate to the MLIR utility for parsing and pass management.
59 return mlir::MlirOptMain(argc
, argv
, "transform-opt-ch2", registry
)