From a96f3a3da45cf6f37998df918f3c90ec9e6e2fec Mon Sep 17 00:00:00 2001 From: Shankar Easwaran Date: Mon, 7 Oct 2013 02:47:09 +0000 Subject: [lld][InputGraph] Change the Resolver to use inputGraph Changes :- a) Functionality in InputGraph to insert Input elements at any position b) Functionality in the Resolver to use nextFile c) Move the functionality of assigning file ordinals to InputGraph d) Changes all inputs to MemoryBuffers e) Remove LinkerInput, InputFiles, ReaderArchive llvm-svn: 192081 --- lld/lib/Core/LinkingContext.cpp | 51 +++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'lld/lib/Core/LinkingContext.cpp') diff --git a/lld/lib/Core/LinkingContext.cpp b/lld/lib/Core/LinkingContext.cpp index c049d2a256d..23ae0fbad91 100644 --- a/lld/lib/Core/LinkingContext.cpp +++ b/lld/lib/Core/LinkingContext.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "lld/Core/LinkingContext.h" -#include "lld/Core/InputFiles.h" +#include "lld/Core/Resolver.h" #include "lld/ReaderWriter/Writer.h" #include "lld/ReaderWriter/Simple.h" @@ -17,19 +17,20 @@ namespace lld { LinkingContext::LinkingContext() - : Reader(*this), _deadStrip(false), _globalsAreDeadStripRoots(false), + : _deadStrip(false), _globalsAreDeadStripRoots(false), _searchArchivesToOverrideTentativeDefinitions(false), _searchSharedLibrariesToOverrideTentativeDefinitions(false), _warnIfCoalesableAtomsHaveDifferentCanBeNull(false), _warnIfCoalesableAtomsHaveDifferentLoadName(false), - _printRemainingUndefines(true), - _allowRemainingUndefines(false), _logInputFiles(false), - _allowShlibUndefines(false), _outputFileType(OutputFileType::Default) {} + _printRemainingUndefines(true), _allowRemainingUndefines(false), + _logInputFiles(false), _allowShlibUndefines(false), + _outputFileType(OutputFileType::Default), _currentInputElement(nullptr) {} LinkingContext::~LinkingContext() {} bool LinkingContext::validate(raw_ostream &diagnostics) { _yamlReader = createReaderYAML(*this); + _nativeReader = createReaderNative(*this); return validateImpl(diagnostics); } @@ -37,11 +38,12 @@ error_code LinkingContext::writeFile(const File &linkedFile) const { return this->writer().writeFile(linkedFile, _outputPath); } -void LinkingContext::addImplicitFiles(InputFiles &inputs) const { - this->writer().addFiles(inputs); +bool LinkingContext::createImplicitFiles( + std::vector > &result) const { + return this->writer().createImplicitFiles(result); } -std::unique_ptr LinkingContext::createEntrySymbolFile() { +std::unique_ptr LinkingContext::createEntrySymbolFile() const { if (entrySymbolName().empty()) return nullptr; std::unique_ptr entryFile( @@ -51,7 +53,7 @@ std::unique_ptr LinkingContext::createEntrySymbolFile() { return std::move(entryFile); } -std::unique_ptr LinkingContext::createUndefinedSymbolFile() { +std::unique_ptr LinkingContext::createUndefinedSymbolFile() const { if (_initialUndefinedSymbols.empty()) return nullptr; std::unique_ptr undefinedSymFile( @@ -62,8 +64,8 @@ std::unique_ptr LinkingContext::createUndefinedSymbolFile() { return std::move(undefinedSymFile); } -std::vector > LinkingContext::createInternalFiles() { - std::vector > result; +bool LinkingContext::createInternalFiles( + std::vector > &result) const { std::unique_ptr internalFile; internalFile = createEntrySymbolFile(); if (internalFile) @@ -71,7 +73,32 @@ std::vector > LinkingContext::createInternalFiles() { internalFile = createUndefinedSymbolFile(); if (internalFile) result.push_back(std::move(internalFile)); - return result; + return true; +} + +void LinkingContext::setResolverState(int32_t state) const { + _currentInputElement->setResolverState(state); +} + +ErrorOr LinkingContext::nextFile() const { + if (_currentInputElement == nullptr) { + ErrorOr elem = inputGraph().getNextInputElement(); + if (error_code(elem) == input_graph_error::no_more_elements) + return make_error_code(input_graph_error::no_more_files); + _currentInputElement = *elem; + } + do { + ErrorOr nextFile = _currentInputElement->getNextFile(); + if (error_code(nextFile) == input_graph_error::no_more_files) { + ErrorOr elem = inputGraph().getNextInputElement(); + if (error_code(elem) == input_graph_error::no_more_elements) + return make_error_code(input_graph_error::no_more_files); + _currentInputElement = *elem; + } else { + return std::move(nextFile); + } + } while (_currentInputElement != nullptr); + return make_error_code(input_graph_error::no_more_files); } void LinkingContext::addPasses(PassManager &pm) const {} -- cgit v1.2.3