AMDGPU/SI: Reserve appropriate number of sgprs for flat scratch init.
[oota-llvm.git] / include / llvm / Linker / Linker.h
1 //===- Linker.h - Module Linker Interface -----------------------*- 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_LINKER_LINKER_H
11 #define LLVM_LINKER_LINKER_H
12
13 #include "llvm/IR/FunctionInfo.h"
14 #include "llvm/Linker/IRMover.h"
15
16 namespace llvm {
17 class Module;
18 class StructType;
19 class Type;
20
21 /// This class provides the core functionality of linking in LLVM. It keeps a
22 /// pointer to the merged module so far. It doesn't take ownership of the
23 /// module since it is assumed that the user of this class will want to do
24 /// something with it after the linking.
25 class Linker {
26   IRMover Mover;
27
28 public:
29   enum Flags {
30     None = 0,
31     OverrideFromSrc = (1 << 0),
32     LinkOnlyNeeded = (1 << 1),
33     InternalizeLinkedSymbols = (1 << 2)
34   };
35
36   Linker(Module &M);
37
38   /// \brief Link \p Src into the composite.
39   ///
40   /// Passing OverrideSymbols as true will have symbols from Src
41   /// shadow those in the Dest.
42   /// For ThinLTO function importing/exporting the \p FunctionInfoIndex
43   /// is passed. If \p FunctionsToImport is provided, only the functions that
44   /// are part of the set will be imported from the source module.
45   ///
46   /// Returns true on error.
47   bool linkInModule(std::unique_ptr<Module> Src, unsigned Flags = Flags::None,
48                     const FunctionInfoIndex *Index = nullptr,
49                     DenseSet<const GlobalValue *> *FunctionsToImport = nullptr);
50
51   /// This exists to implement the deprecated LLVMLinkModules C api. Don't use
52   /// for anything else.
53   bool linkInModuleForCAPI(Module &Src);
54
55   static bool linkModules(Module &Dest, std::unique_ptr<Module> Src,
56                           unsigned Flags = Flags::None);
57 };
58
59 /// Create a new module with exported local functions renamed and promoted
60 /// for ThinLTO.
61 std::unique_ptr<Module> renameModuleForThinLTO(std::unique_ptr<Module> M,
62                                                const FunctionInfoIndex *Index);
63
64 } // End llvm namespace
65
66 #endif