| 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/LLVM.h" |
| 16 | #include "mlir/Tools/mlir-translate/MlirTranslateMain.h" |
| 17 | #include "llvm/Support/InitLLVM.h" |
| 18 | |
| 19 | using namespace mlir; |
| 20 | |
| 21 | namespace mlir { |
| 22 | // Defined in the test directory, no public header. |
| 23 | void registerTestRoundtripSPIRV(); |
| 24 | void registerTestRoundtripDebugSPIRV(); |
| 25 | #ifdef MLIR_INCLUDE_TESTS |
| 26 | void registerTestToLLVMIR(); |
| 27 | void registerTestFromLLVMIR(); |
| 28 | #endif |
| 29 | } // namespace mlir |
| 30 | |
| 31 | static void registerTestTranslations() { |
| 32 | registerTestRoundtripSPIRV(); |
| 33 | registerTestRoundtripDebugSPIRV(); |
| 34 | #ifdef MLIR_INCLUDE_TESTS |
| 35 | registerTestToLLVMIR(); |
| 36 | registerTestFromLLVMIR(); |
| 37 | #endif |
| 38 | } |
| 39 | |
| 40 | int main(int argc, char **argv) { |
| 41 | llvm::InitLLVM y(argc, argv); |
| 42 | registerAllTranslations(); |
| 43 | registerTestTranslations(); |
| 44 | return failed(Result: mlirTranslateMain(argc, argv, toolName: "MLIR Translation Testing Tool" )); |
| 45 | } |
| 46 | |