1 //===-LTOCodeGenerator.h - LLVM Link Time Optimizer -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the LTOCodeGenerator class.
12 //===----------------------------------------------------------------------===//
15 #ifndef LTO_CODE_GENERATOR_H
16 #define LTO_CODE_GENERATOR_H
18 #include "llvm/Linker.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/SmallVector.h"
26 // C++ class which implements the opaque lto_code_gen_t
29 class LTOCodeGenerator {
31 static const char* getVersionString();
36 bool addModule(class LTOModule*, std::string& errMsg);
37 bool setDebugInfo(lto_debug_model, std::string& errMsg);
38 bool setCodePICModel(lto_codegen_model, std::string& errMsg);
39 void setGccPath(const char* path);
40 void setAssemblerPath(const char* path);
41 void addMustPreserveSymbol(const char* sym);
42 bool writeMergedModules(const char* path,
44 const void* compile(size_t* length, std::string& errMsg);
45 void setCodeGenDebugOptions(const char *opts);
47 bool generateAssemblyCode(llvm::raw_ostream& out,
49 bool assemble(const std::string& asmPath,
50 const std::string& objPath, std::string& errMsg);
51 void applyScopeRestrictions();
52 bool determineTarget(std::string& errMsg);
54 typedef llvm::StringMap<uint8_t> StringSet;
57 llvm::TargetMachine* _target;
58 bool _emitDwarfDebugInfo;
59 bool _scopeRestrictionsDone;
60 lto_codegen_model _codeModel;
61 StringSet _mustPreserveSymbols;
62 llvm::MemoryBuffer* _nativeObjectFile;
63 std::vector<const char*> _codegenOptions;
64 llvm::sys::Path* _gccPath;
65 llvm::sys::Path* _assemblerPath;
68 #endif // LTO_CODE_GENERATOR_H