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 3.
10//
11//===----------------------------------------------------------------------===//
12
13#include "MyExtension.h"
14
15#include "mlir/Dialect/Transform/Transforms/Passes.h"
16#include "mlir/IR/DialectRegistry.h"
17#include "mlir/IR/MLIRContext.h"
18#include "mlir/InitAllDialects.h"
19#include "mlir/InitAllExtensions.h"
20#include "mlir/Tools/mlir-opt/MlirOptMain.h"
21#include "mlir/Transforms/Passes.h"
22#include <cstdlib>
23
24int main(int argc, char **argv) {
25 // Register all "core" dialects and our transform dialect extension.
26 mlir::DialectRegistry registry;
27 mlir::registerAllDialects(registry);
28 mlir::registerAllExtensions(registry);
29 registerMyExtension(registry);
30
31 // Register the interpreter pass.
32 mlir::transform::registerInterpreterPass();
33
34 // Register a handful of cleanup passes that we can run to make the output IR
35 // look nicer.
36 mlir::registerCanonicalizerPass();
37 mlir::registerCSEPass();
38 mlir::registerSymbolDCEPass();
39
40 // Delegate to the MLIR utility for parsing and pass management.
41 return mlir::MlirOptMain(argc, argv, toolName: "transform-opt-ch3", registry)
42 .succeeded()
43 ? EXIT_SUCCESS
44 : EXIT_FAILURE;
45}
46

source code of mlir/examples/transform/Ch3/transform-opt/transform-opt.cpp