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/LLVMContext.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/SmallPtrSet.h"
28 // C++ class which implements the opaque lto_code_gen_t
31 struct LTOCodeGenerator {
32 static const char* getVersionString();
37 bool addModule(struct LTOModule*, std::string& errMsg);
38 bool setDebugInfo(lto_debug_model, std::string& errMsg);
39 bool setCodePICModel(lto_codegen_model, std::string& errMsg);
40 void setCpu(const char *cpu);
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 generateObjectFile(llvm::raw_ostream& out,
49 void applyScopeRestrictions();
50 void applyRestriction(llvm::GlobalValue &GV,
51 std::vector<const char*> &mustPreserveList,
52 llvm::SmallPtrSet<llvm::GlobalValue*, 8> &asmUsed,
53 llvm::Mangler &mangler);
54 bool determineTarget(std::string& errMsg);
56 typedef llvm::StringMap<uint8_t> StringSet;
58 llvm::LLVMContext& _context;
60 llvm::TargetMachine* _target;
61 bool _emitDwarfDebugInfo;
62 bool _scopeRestrictionsDone;
63 lto_codegen_model _codeModel;
64 StringSet _mustPreserveSymbols;
65 StringSet _asmUndefinedRefs;
66 llvm::MemoryBuffer* _nativeObjectFile;
67 std::vector<const char*> _codegenOptions;
71 #endif // LTO_CODE_GENERATOR_H