[Orc] Move Orc code into a namespace (llvm::orc), update Kaleidoscope code.
[oota-llvm.git] / include / llvm / ExecutionEngine / Orc / CloneSubModule.h
1 //===-- CloneSubModule.h - Utilities for extracting sub-modules -*- 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 // Contains utilities for extracting sub-modules. Useful for breaking up modules
11 // for lazy jitting.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H
16 #define LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H
17
18 #include "llvm/ADT/DenseSet.h"
19 #include "llvm/Transforms/Utils/ValueMapper.h"
20 #include <functional>
21
22 namespace llvm {
23
24 class Function;
25 class GlobalVariable;
26 class Module;
27
28 namespace orc {
29
30 /// @brief Functor type for describing how CloneSubModule should mutate a
31 ///        GlobalVariable.
32 typedef std::function<void(GlobalVariable &, const GlobalVariable &,
33                            ValueToValueMapTy &)> HandleGlobalVariableFtor;
34
35 /// @brief Functor type for describing how CloneSubModule should mutate a
36 ///        Function.
37 typedef std::function<void(Function &, const Function &, ValueToValueMapTy &)>
38     HandleFunctionFtor;
39
40 /// @brief Copies the initializer from Orig to New.
41 ///
42 ///   Type is suitable for implicit conversion to a HandleGlobalVariableFtor.
43 void copyGVInitializer(GlobalVariable &New, const GlobalVariable &Orig,
44                        ValueToValueMapTy &VMap);
45
46 /// @brief Copies the body of Orig to New.
47 ///
48 ///   Type is suitable for implicit conversion to a HandleFunctionFtor.
49 void copyFunctionBody(Function &New, const Function &Orig,
50                       ValueToValueMapTy &VMap);
51
52 /// @brief Clone a subset of the module Src into Dst.
53 void CloneSubModule(Module &Dst, const Module &Src,
54                     HandleGlobalVariableFtor HandleGlobalVariable,
55                     HandleFunctionFtor HandleFunction, bool KeepInlineAsm);
56
57 } // End namespace orc.
58 } // End namespace llvm.
59
60 #endif // LLVM_EXECUTIONENGINE_ORC_CLONESUBMODULE_H