diff options
Diffstat (limited to 'llvm/tools/lto2/LTOModule.h')
-rw-r--r-- | llvm/tools/lto2/LTOModule.h | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/llvm/tools/lto2/LTOModule.h b/llvm/tools/lto2/LTOModule.h index 9770757339b..7735e2f2a57 100644 --- a/llvm/tools/lto2/LTOModule.h +++ b/llvm/tools/lto2/LTOModule.h @@ -15,15 +15,24 @@ #define LTO_MODULE_H #include "llvm/Module.h" -#include "llvm/GlobalValue.h" -#include "llvm/Constants.h" -#include "llvm/Support/Mangler.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/Target/TargetMachine.h" #include "llvm/ADT/StringMap.h" #include "llvm-c/lto.h" #include <vector> +#include <string> + + +// forward references to llvm classes +namespace llvm { + class Mangler; + class MemoryBuffer; + class GlobalValue; + class Value; + class Function; +} // @@ -44,26 +53,35 @@ public: static LTOModule* makeLTOModule(const char* path, std::string& errMsg); static LTOModule* makeLTOModule(const void* mem, size_t length, std::string& errMsg); - ~LTOModule(); const char* getTargetTriple(); uint32_t getSymbolCount(); lto_symbol_attributes getSymbolAttributes(uint32_t index); const char* getSymbolName(uint32_t index); - llvm::Module * getLLVVMModule() { return _module; } - bool targetSupported() { return (_target != NULL); } + llvm::Module * getLLVVMModule() { return _module.get(); } private: LTOModule(llvm::Module* m, llvm::TargetMachine* t); + void lazyParseSymbols(); void addDefinedSymbol(llvm::GlobalValue* def, llvm::Mangler& mangler, bool isFunction); - void addUndefinedSymbol(const char* name); + void addPotentialUndefinedSymbol(llvm::GlobalValue* decl, + llvm::Mangler &mangler); void findExternalRefs(llvm::Value* value, llvm::Mangler& mangler); + void addDefinedFunctionSymbol(llvm::Function* f, + llvm::Mangler &mangler); + void addDefinedDataSymbol(llvm::GlobalValue* v, + llvm::Mangler &mangler); + static bool isTargetMatch(llvm::MemoryBuffer* memBuffer, + const char* triplePrefix); + static LTOModule* makeLTOModule(llvm::MemoryBuffer* buffer, + std::string& errMsg); + typedef llvm::StringMap<uint8_t> StringSet; struct NameAndAttributes { @@ -71,12 +89,13 @@ private: lto_symbol_attributes attributes; }; - llvm::Module * _module; - llvm::TargetMachine * _target; - bool _symbolsParsed; - std::vector<NameAndAttributes> _symbols; - StringSet _defines; // only needed to disambiguate tentative definitions - StringSet _undefines; // only needed to disambiguate tentative definitions + llvm::OwningPtr<llvm::Module> _module; + llvm::OwningPtr<llvm::TargetMachine> _target; + bool _symbolsParsed; + std::vector<NameAndAttributes> _symbols; + // _defines and _undefines only needed to disambiguate tentative definitions + StringSet _defines; + StringSet _undefines; }; #endif // LTO_MODULE_H |