diff options
Diffstat (limited to 'lld/wasm/InputFiles.h')
-rw-r--r-- | lld/wasm/InputFiles.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lld/wasm/InputFiles.h b/lld/wasm/InputFiles.h index e08079a41eb..75d20e63cf5 100644 --- a/lld/wasm/InputFiles.h +++ b/lld/wasm/InputFiles.h @@ -14,6 +14,7 @@ #include "lld/Common/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/LTO/LTO.h" #include "llvm/Object/Archive.h" #include "llvm/Object/Wasm.h" #include "llvm/Support/MemoryBuffer.h" @@ -28,6 +29,12 @@ using llvm::wasm::WasmImport; using llvm::wasm::WasmRelocation; using llvm::wasm::WasmSignature; +namespace llvm { +namespace lto { +class InputFile; +} +} // namespace llvm + namespace lld { namespace wasm { @@ -42,6 +49,7 @@ public: enum Kind { ObjectKind, ArchiveKind, + BitcodeKind, }; virtual ~InputFile() {} @@ -57,10 +65,15 @@ public: // An archive file name if this file is created from an archive. StringRef ParentName; + ArrayRef<Symbol *> getSymbols() const { return Symbols; } + protected: InputFile(Kind K, MemoryBufferRef M) : MB(M), FileKind(K) {} MemoryBufferRef MB; + // List of all symbols referenced or defined by this file. + std::vector<Symbol *> Symbols; + private: const Kind FileKind; }; @@ -113,7 +126,6 @@ public: std::vector<InputSection *> CustomSections; llvm::DenseMap<uint32_t, InputSection *> CustomSectionsByIndex; - ArrayRef<Symbol *> getSymbols() const { return Symbols; } Symbol *getSymbol(uint32_t Index) const { return Symbols[Index]; } FunctionSymbol *getFunctionSymbol(uint32_t Index) const; DataSymbol *getDataSymbol(uint32_t Index) const; @@ -126,12 +138,18 @@ private: bool isExcludedByComdat(InputChunk *Chunk) const; - // List of all symbols referenced or defined by this file. - std::vector<Symbol *> Symbols; - std::unique_ptr<WasmObjectFile> WasmObj; }; +class BitcodeFile : public InputFile { +public: + explicit BitcodeFile(MemoryBufferRef M) : InputFile(BitcodeKind, M) {} + static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } + + void parse() override; + std::unique_ptr<llvm::lto::InputFile> Obj; +}; + // Opens a given file. llvm::Optional<MemoryBufferRef> readFile(StringRef Path); |