My Project
Translation.h
Go to the documentation of this file.
1 //===- Translation.h - Translation registry ---------------------*- C++ -*-===//
2 //
3 // Part of the MLIR 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 // Registry for user-provided translations.
10 //
11 //===----------------------------------------------------------------------===//
12 #ifndef MLIR_TRANSLATION_H
13 #define MLIR_TRANSLATION_H
14 
15 #include "llvm/ADT/StringMap.h"
16 
17 #include <memory>
18 
19 namespace llvm {
20 class MemoryBuffer;
21 class SourceMgr;
22 class StringRef;
23 } // namespace llvm
24 
25 namespace mlir {
26 struct LogicalResult;
27 class MLIRContext;
28 class ModuleOp;
29 class OwningModuleRef;
30 
36  std::function<OwningModuleRef(llvm::SourceMgr &sourceMgr, MLIRContext *)>;
37 
43  std::function<OwningModuleRef(llvm::StringRef, MLIRContext *)>;
44 
48  std::function<LogicalResult(ModuleOp, llvm::raw_ostream &output)>;
49 
55 using TranslateFunction = std::function<LogicalResult(
56  llvm::SourceMgr &sourceMgr, llvm::raw_ostream &output, MLIRContext *)>;
57 
69  TranslateToMLIRRegistration(llvm::StringRef name,
70  const TranslateSourceMgrToMLIRFunction &function);
71  TranslateToMLIRRegistration(llvm::StringRef name,
72  const TranslateStringRefToMLIRFunction &function);
73 };
74 
76  TranslateFromMLIRRegistration(llvm::StringRef name,
77  const TranslateFromMLIRFunction &function);
78 };
80  TranslateRegistration(llvm::StringRef name,
81  const TranslateFunction &function);
82 };
84 
86 const llvm::StringMap<TranslateSourceMgrToMLIRFunction> &
88 const llvm::StringMap<TranslateFromMLIRFunction> &
90 const llvm::StringMap<TranslateFunction> &getTranslationRegistry();
91 
92 } // namespace mlir
93 
94 #endif // MLIR_TRANSLATION_H
Definition: Translation.h:68
Definition: InferTypeOpInterface.cpp:20
Definition: PassRegistry.cpp:413
const llvm::StringMap< TranslateSourceMgrToMLIRFunction > & getTranslationToMLIRRegistry()
Get a read-only reference to the translator registry.
Definition: Translation.cpp:100
Definition: Translation.h:79
Definition: LogicalResult.h:18
const llvm::StringMap< TranslateFromMLIRFunction > & getTranslationFromMLIRRegistry()
Definition: Translation.cpp:105
Definition: Translation.h:75
std::function< LogicalResult(ModuleOp, llvm::raw_ostream &output)> TranslateFromMLIRFunction
Definition: Translation.h:48
std::function< OwningModuleRef(llvm::SourceMgr &sourceMgr, MLIRContext *)> TranslateSourceMgrToMLIRFunction
Definition: Translation.h:36
Definition: MLIRContext.h:34
std::function< OwningModuleRef(llvm::StringRef, MLIRContext *)> TranslateStringRefToMLIRFunction
Definition: Translation.h:43
std::function< LogicalResult(llvm::SourceMgr &sourceMgr, llvm::raw_ostream &output, MLIRContext *)> TranslateFunction
Definition: Translation.h:56
const llvm::StringMap< TranslateFunction > & getTranslationRegistry()
Definition: Translation.cpp:109