• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- InitAllTranslations.h - MLIR Translations Registration ---*- C++ -*-===//
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 file defines a helper to trigger the registration of all translations
10 // in and out of MLIR to the system.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_INITALLTRANSLATIONS_H
15 #define MLIR_INITALLTRANSLATIONS_H
16 
17 namespace mlir {
18 
19 void registerFromLLVMIRTranslation();
20 void registerFromSPIRVTranslation();
21 void registerToLLVMIRTranslation();
22 void registerToSPIRVTranslation();
23 void registerToNVVMIRTranslation();
24 void registerToROCDLIRTranslation();
25 void registerAVX512ToLLVMIRTranslation();
26 
27 // This function should be called before creating any MLIRContext if one
28 // expects all the possible translations to be made available to the context
29 // automatically.
registerAllTranslations()30 inline void registerAllTranslations() {
31   static bool initOnce = []() {
32     registerFromLLVMIRTranslation();
33     registerFromSPIRVTranslation();
34     registerToLLVMIRTranslation();
35     registerToSPIRVTranslation();
36     registerToNVVMIRTranslation();
37     registerToROCDLIRTranslation();
38     registerAVX512ToLLVMIRTranslation();
39     return true;
40   }();
41   (void)initOnce;
42 }
43 } // namespace mlir
44 
45 #endif // MLIR_INITALLTRANSLATIONS_H
46