blob: eab076ebc88015dd3294161a9608872165e33cec [file] [log] [blame]
Nick Kledzik77595fc2008-02-26 20:26:43 +00001//===-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
Nick Kledzikef194ed2008-02-27 22:25:36 +000021#include <string>
Nick Kledzik77595fc2008-02-26 20:26:43 +000022
23
24//
25// C++ class which implements the opaque lto_code_gen_t
26//
27class LTOCodeGenerator {
28public:
29 static const char* getVersionString();
30
31 LTOCodeGenerator();
32 ~LTOCodeGenerator();
33
34 bool addModule(class LTOModule*, std::string& errMsg);
35 bool setDebugInfo(lto_debug_model, std::string& errMsg);
36 bool setCodePICModel(lto_codegen_model, std::string& errMsg);
37 void addMustPreserveSymbol(const char* sym);
Nick Kledzikef194ed2008-02-27 22:25:36 +000038 bool writeMergedModules(const char* path,
39 std::string& errMsg);
40 const void* compile(size_t* length, std::string& errMsg);
Nick Kledzik77595fc2008-02-26 20:26:43 +000041
42private:
43 bool generateAssemblyCode(std::ostream& out,
44 std::string& errMsg);
45 bool assemble(const std::string& asmPath,
46 const std::string& objPath, std::string& errMsg);
47 void applyScopeRestrictions();
48 bool determineTarget(std::string& errMsg);
49
50 typedef llvm::StringMap<uint8_t> StringSet;
51
52 llvm::Linker _linker;
53 llvm::TargetMachine* _target;
54 bool _emitDwarfDebugInfo;
55 bool _scopeRestrictionsDone;
56 lto_codegen_model _codeModel;
57 StringSet _mustPreserveSymbols;
Nick Kledzikef194ed2008-02-27 22:25:36 +000058 llvm::MemoryBuffer* _nativeObjectFile;
Nick Kledzik77595fc2008-02-26 20:26:43 +000059};
60
61#endif // LTO_CODE_GENERATOR_H
62