50 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// This is the top-level file for the Transform dialect tutorial chapter 2.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 24namespace test {25void registerTestTransformDialectExtension(mlir::DialectRegistry &);26} // namespace test27 28int main(int argc, char **argv) {29 // Register all "core" dialects and our transform dialect extension.30 mlir::DialectRegistry registry;31 mlir::registerAllDialects(registry);32 mlir::registerAllExtensions(registry);33 registerMyExtension(registry);34 35 // Register transform interpreter pass.36 mlir::transform::registerInterpreterPass();37 38 // Register a handful of cleanup passes that we can run to make the output IR39 // look nicer.40 mlir::registerCanonicalizerPass();41 mlir::registerCSEPass();42 mlir::registerSymbolDCEPass();43 44 // Delegate to the MLIR utility for parsing and pass management.45 return mlir::MlirOptMain(argc, argv, "transform-opt-ch2", registry)46 .succeeded()47 ? EXIT_SUCCESS48 : EXIT_FAILURE;49}50