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
17namespace mlir {
18
19void registerFromLLVMIRTranslation();
20void registerFromSPIRVTranslation();
21void registerToCppTranslation();
22void registerToLLVMIRTranslation();
23void registerToSPIRVTranslation();
24
25// This function should be called before creating any MLIRContext if one
26// expects all the possible translations to be made available to the context
27// automatically.
28inline void registerAllTranslations() {
29 static bool initOnce = []() {
30 registerFromLLVMIRTranslation();
31 registerFromSPIRVTranslation();
32 registerToCppTranslation();
33 registerToLLVMIRTranslation();
34 registerToSPIRVTranslation();
35 return true;
36 }();
37 (void)initOnce;
38}
39} // namespace mlir
40
41#endif // MLIR_INITALLTRANSLATIONS_H
42

source code of mlir/include/mlir/InitAllTranslations.h