first commit of new LTO system. It is not hooked up in the llvm/tools/Makefile,...
[oota-llvm.git] / tools / lto2 / LTOCodeGenerator.h
1 //===-LTOCodeGenerator.h - LLVM Link Time Optimizer -----------------------===//
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 // This file declares the LTOCodeGenerator class. 
11 //
12 //===----------------------------------------------------------------------===//
13
14
15 #ifndef LTO_CODE_GENERATOR_H
16 #define LTO_CODE_GENERATOR_H
17
18 #include "llvm/Linker.h"
19 #include "llvm/ADT/StringMap.h"
20
21
22
23 //
24 // C++ class which implements the opaque lto_code_gen_t
25 //
26 class LTOCodeGenerator {
27 public:
28     static const char*        getVersionString();
29     
30                             LTOCodeGenerator();
31                             ~LTOCodeGenerator();
32                             
33     bool                addModule(class LTOModule*, std::string& errMsg);
34     bool                setDebugInfo(lto_debug_model, std::string& errMsg);
35     bool                setCodePICModel(lto_codegen_model, std::string& errMsg);
36     void                addMustPreserveSymbol(const char* sym);
37     bool                writeMergedModules(const char* path, std::string& errMsg);
38     void*               compile(size_t* length, std::string& errMsg);
39     
40 private:
41     bool                generateAssemblyCode(std::ostream& out, 
42                                                         std::string& errMsg);
43     bool                assemble(const std::string& asmPath, 
44                             const std::string& objPath, std::string& errMsg);
45     void                applyScopeRestrictions();
46     bool                determineTarget(std::string& errMsg);
47     
48     typedef llvm::StringMap<uint8_t> StringSet;
49
50     llvm::Linker                _linker;
51     llvm::TargetMachine*        _target;
52     bool                        _emitDwarfDebugInfo;
53     bool                        _scopeRestrictionsDone;
54     lto_codegen_model           _codeModel;
55     StringSet                   _mustPreserveSymbols;
56 };
57
58 #endif // LTO_CODE_GENERATOR_H
59