1//===- mlir-translate.cpp - MLIR Translate Driver -------------------------===//
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 a command line utility that translates a file from/to MLIR using one
10// of the registered translations.
11//
12//===----------------------------------------------------------------------===//
13
14#include "mlir/InitAllTranslations.h"
15#include "mlir/Support/LogicalResult.h"
16#include "mlir/Tools/mlir-translate/MlirTranslateMain.h"
17
18using namespace mlir;
19
20namespace mlir {
21// Defined in the test directory, no public header.
22void registerTestRoundtripSPIRV();
23void registerTestRoundtripDebugSPIRV();
24#ifdef MLIR_INCLUDE_TESTS
25void registerTestToLLVMIR();
26void registerTestFromLLVMIR();
27#endif
28} // namespace mlir
29
30static void registerTestTranslations() {
31 registerTestRoundtripSPIRV();
32 registerTestRoundtripDebugSPIRV();
33#ifdef MLIR_INCLUDE_TESTS
34 registerTestToLLVMIR();
35 registerTestFromLLVMIR();
36#endif
37}
38
39int main(int argc, char **argv) {
40 registerAllTranslations();
41 registerTestTranslations();
42 return failed(result: mlirTranslateMain(argc, argv, toolName: "MLIR Translation Testing Tool"));
43}
44

source code of mlir/tools/mlir-translate/mlir-translate.cpp