[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / mlir / examples / transform / Ch2 / transform-opt / transform-opt.cpp
blob3a975313f93ff0e630829fbb49952bacc7d579bd
1 //===-- transform-opt.cpp - Transform dialect tutorial entry point --------===//
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 // 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"
21 #include <cstdlib>
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
31 namespace test {
32 void registerTestTransformDialectExtension(mlir::DialectRegistry &);
33 } // namespace test
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
43 // look nicer.
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);
53 #else
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)
60 .succeeded()
61 ? EXIT_SUCCESS
62 : EXIT_FAILURE;