e3da8a79c23ebb450da73e881d6843acbfea2f6d
[oota-llvm.git] / include / llvm / Transforms / IPO / FunctionImport.h
1 //===- llvm/Transforms/IPO/FunctionImport.h - ThinLTO importing -*- C++ -*-===//
2 //
3 //                      The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_FUNCTIONIMPORT_H
11 #define LLVM_FUNCTIONIMPORT_H
12
13 #include "llvm/IR/DiagnosticInfo.h"
14 #include "llvm/ADT/StringMap.h"
15
16 namespace llvm {
17 class LLVMContext;
18 class Module;
19 class FunctionInfoIndex;
20
21 /// The function importer is automatically importing function from other modules
22 /// based on the provided summary informations.
23 class FunctionImporter {
24
25   /// The summaries index used to trigger importing.
26   const FunctionInfoIndex &Index;
27
28   /// Diagnostic will be sent to this handler.
29   DiagnosticHandlerFunction DiagnosticHandler;
30
31   /// Factory function to load a Module for a given identifier
32   std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader;
33
34 public:
35   /// Create a Function Importer.
36   FunctionImporter(
37       const FunctionInfoIndex &Index,
38       DiagnosticHandlerFunction DiagnosticHandler,
39       std::function<std::unique_ptr<Module>(StringRef Identifier)> ModuleLoader)
40       : Index(Index), DiagnosticHandler(DiagnosticHandler),
41         ModuleLoader(ModuleLoader) {}
42
43   /// Import functions in Module \p M based on the summary informations.
44   bool importFunctions(Module &M);
45 };
46 }
47
48 #endif // LLVM_FUNCTIONIMPORT_H