Nick Kledzik | 77595fc | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 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" |
Devang Patel | a93ae71 | 2008-07-03 22:53:14 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/SmallVector.h" |
Nick Kledzik | 77595fc | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 21 | |
Nick Kledzik | ef194ed | 2008-02-27 22:25:36 +0000 | [diff] [blame] | 22 | #include <string> |
Nick Kledzik | 77595fc | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 23 | |
| 24 | |
| 25 | // |
| 26 | // C++ class which implements the opaque lto_code_gen_t |
| 27 | // |
| 28 | class LTOCodeGenerator { |
| 29 | public: |
| 30 | static const char* getVersionString(); |
| 31 | |
| 32 | LTOCodeGenerator(); |
| 33 | ~LTOCodeGenerator(); |
| 34 | |
| 35 | bool addModule(class LTOModule*, std::string& errMsg); |
| 36 | bool setDebugInfo(lto_debug_model, std::string& errMsg); |
| 37 | bool setCodePICModel(lto_codegen_model, std::string& errMsg); |
| 38 | void addMustPreserveSymbol(const char* sym); |
Nick Kledzik | ef194ed | 2008-02-27 22:25:36 +0000 | [diff] [blame] | 39 | bool writeMergedModules(const char* path, |
| 40 | std::string& errMsg); |
| 41 | const void* compile(size_t* length, std::string& errMsg); |
Nick Kledzik | 920ae98 | 2008-07-08 21:14:10 +0000 | [diff] [blame] | 42 | void setCodeGenDebugOptions(const char *opts); |
Nick Kledzik | 77595fc | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 43 | private: |
| 44 | bool generateAssemblyCode(std::ostream& out, |
| 45 | std::string& errMsg); |
| 46 | bool assemble(const std::string& asmPath, |
| 47 | const std::string& objPath, std::string& errMsg); |
| 48 | void applyScopeRestrictions(); |
| 49 | bool determineTarget(std::string& errMsg); |
| 50 | |
| 51 | typedef llvm::StringMap<uint8_t> StringSet; |
| 52 | |
| 53 | llvm::Linker _linker; |
| 54 | llvm::TargetMachine* _target; |
| 55 | bool _emitDwarfDebugInfo; |
| 56 | bool _scopeRestrictionsDone; |
| 57 | lto_codegen_model _codeModel; |
| 58 | StringSet _mustPreserveSymbols; |
Nick Kledzik | ef194ed | 2008-02-27 22:25:36 +0000 | [diff] [blame] | 59 | llvm::MemoryBuffer* _nativeObjectFile; |
Nick Kledzik | 920ae98 | 2008-07-08 21:14:10 +0000 | [diff] [blame] | 60 | std::vector<const char*> _codegenOptions; |
Nick Kledzik | 77595fc | 2008-02-26 20:26:43 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | #endif // LTO_CODE_GENERATOR_H |
| 64 | |