X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Flto2%2FLTOModule.h;h=40f92f9816523bb2091d9ddecfea38e09ab7ff29;hb=180c1691c7fd79e2376bdd59e962d190607e20fa;hp=9770757339b5879b5200a7fd7e3f1b248632327c;hpb=77595fc35642f990bfc5ad05b8e68d4056695eca;p=oota-llvm.git diff --git a/tools/lto2/LTOModule.h b/tools/lto2/LTOModule.h index 9770757339b..40f92f98165 100644 --- a/tools/lto2/LTOModule.h +++ b/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 +#include + + +// forward references to llvm classes +namespace llvm { + class Mangler; + class MemoryBuffer; + class GlobalValue; + class Value; + class Function; +} // @@ -44,26 +53,36 @@ 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); + static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length); + typedef llvm::StringMap StringSet; struct NameAndAttributes { @@ -71,13 +90,16 @@ private: lto_symbol_attributes attributes; }; - llvm::Module * _module; - llvm::TargetMachine * _target; - bool _symbolsParsed; - std::vector _symbols; - StringSet _defines; // only needed to disambiguate tentative definitions - StringSet _undefines; // only needed to disambiguate tentative definitions + llvm::OwningPtr _module; + llvm::OwningPtr _target; + bool _symbolsParsed; + std::vector _symbols; + // _defines and _undefines only needed to disambiguate tentative definitions + StringSet _defines; + StringSet _undefines; }; +extern std::string getFeatureString(const char *TargetTriple); + #endif // LTO_MODULE_H