1//===- standalone-translate.cpp ---------------------------------*- C++ -*-===//
2//
3// This file is licensed 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 a command line utility that translates a file from/to MLIR using one
10// of the registered translations.
11//
12//===----------------------------------------------------------------------===//
13
14#include "Standalone/StandaloneDialect.h"
15#include "mlir/IR/DialectRegistry.h"
16#include "mlir/IR/Operation.h"
17#include "mlir/InitAllTranslations.h"
18#include "mlir/Support/LogicalResult.h"
19#include "mlir/Tools/mlir-translate/MlirTranslateMain.h"
20#include "mlir/Tools/mlir-translate/Translation.h"
21#include "llvm/Support/raw_ostream.h"
22
23int main(int argc, char **argv) {
24 mlir::registerAllTranslations();
25
26 // TODO: Register standalone translations here.
27 mlir::TranslateFromMLIRRegistration withdescription(
28 "option", "different from option",
29 [](mlir::Operation *op, llvm::raw_ostream &output) {
30 return mlir::LogicalResult::success();
31 },
32 [](mlir::DialectRegistry &a) {});
33
34 return failed(
35 result: mlir::mlirTranslateMain(argc, argv, toolName: "MLIR Translation Testing Tool"));
36}
37

source code of mlir/examples/standalone/standalone-translate/standalone-translate.cpp