diff options
author | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2014-01-21 18:31:27 +0000 |
---|---|---|
committer | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2014-01-21 18:31:27 +0000 |
commit | a747cf1c4d740dfe5fd1b3cd1b3d43251892457a (patch) | |
tree | 3640e0852df6d853ed2b84c2a1ccce517a3c336a /include/llvm | |
parent | 92e658b56616cf389de242df230682f0b1c9e4fd (diff) | |
download | llvm-a747cf1c4d740dfe5fd1b3cd1b3d43251892457a.tar.gz llvm-a747cf1c4d740dfe5fd1b3cd1b3d43251892457a.tar.bz2 llvm-a747cf1c4d740dfe5fd1b3cd1b3d43251892457a.tar.xz |
Adding new LTO APIs to parse metadata nodes and extract linker options and
dependent libraries from a bitcode module.
Differential Revision: http://llvm-reviews.chandlerc.com/D2343
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199759 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/CodeGen/TargetLoweringObjectFileImpl.h | 8 | ||||
-rw-r--r-- | include/llvm/LTO/LTOModule.h | 31 | ||||
-rw-r--r-- | include/llvm/Target/TargetLoweringObjectFile.h | 6 |
3 files changed, 45 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index 5b22c9c685..4e90e141ce 100644 --- a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -80,6 +80,10 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { public: virtual ~TargetLoweringObjectFileMachO() {} + /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker + /// option string. Returns StringRef() if the option does not specify a library. + virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const; + /// emitModuleFlags - Emit the module flags that specify the garbage /// collection information. virtual void emitModuleFlags(MCStreamer &Streamer, @@ -129,6 +133,10 @@ public: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; + /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker + /// option string. Returns StringRef() if the option does not specify a library. + virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const; + /// emitModuleFlags - Emit Obj-C garbage collection and linker options. Only /// linker option emission is implemented for COFF. virtual void emitModuleFlags(MCStreamer &Streamer, diff --git a/include/llvm/LTO/LTOModule.h b/include/llvm/LTO/LTOModule.h index 78a72fe168..c70afa4196 100644 --- a/include/llvm/LTO/LTOModule.h +++ b/include/llvm/LTO/LTOModule.h @@ -51,6 +51,9 @@ private: llvm::OwningPtr<llvm::Module> _module; llvm::OwningPtr<llvm::TargetMachine> _target; llvm::MCObjectFileInfo ObjFileInfo; + StringSet _linkeropt_strings; + std::vector<const char *> _deplibs; + std::vector<const char *> _linkeropts; std::vector<NameAndAttributes> _symbols; // _defines and _undefines only needed to disambiguate tentative definitions @@ -129,6 +132,30 @@ public: return NULL; } + /// getDependentLibraryCount - Get the number of dependent libraries + uint32_t getDependentLibraryCount() { + return _deplibs.size(); + } + + /// getDependentLibrary - Get the dependent library at the specified index. + const char *getDependentLibrary(uint32_t index) { + if (index < _deplibs.size()) + return _deplibs[index]; + return NULL; + } + + /// getLinkerOptCount - Get the number of linker options + uint32_t getLinkerOptCount() { + return _linkeropts.size(); + } + + /// getLinkerOpt - Get the linker option at the specified index. + const char *getLinkerOpt(uint32_t index) { + if (index < _linkeropts.size()) + return _linkeropts[index]; + return NULL; + } + /// getLLVVMModule - Return the Module. llvm::Module *getLLVVMModule() { return _module.get(); } @@ -138,6 +165,10 @@ public: } private: + /// parseMetadata - Parse metadata from the module + // FIXME: it only parses "Linker Options" metadata at the moment + void parseMetadata(); + /// parseSymbols - Parse the symbols from the module and model-level ASM and /// add them to either the defined or undefined lists. bool parseSymbols(std::string &errMsg); diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h index 4aedd3aa31..5bf9a13563 100644 --- a/include/llvm/Target/TargetLoweringObjectFile.h +++ b/include/llvm/Target/TargetLoweringObjectFile.h @@ -57,6 +57,12 @@ public: const TargetMachine &TM, const MCSymbol *Sym) const; + /// getDepLibFromLinkerOpt - Extract the dependent library name from a linker + /// option string. Returns StringRef() if the option does not specify a library. + virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const { + return StringRef(); + } + /// emitModuleFlags - Emit the module flags that the platform cares about. virtual void emitModuleFlags(MCStreamer &, ArrayRef<Module::ModuleFlagEntry>, |