2013-08-07 06:31:59 +08:00
|
|
|
//===- lib/ReaderWriter/CoreLinkingContext.cpp ----------------------------===//
|
2013-04-05 02:59:24 +08:00
|
|
|
//
|
|
|
|
// The LLVM Linker
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-02-06 04:05:33 +08:00
|
|
|
#include "lld/Core/DefinedAtom.h"
|
|
|
|
#include "lld/Core/File.h"
|
2013-04-05 02:59:24 +08:00
|
|
|
#include "lld/Core/Pass.h"
|
|
|
|
#include "lld/Core/PassManager.h"
|
2014-06-12 05:47:51 +08:00
|
|
|
#include "lld/Core/Simple.h"
|
2015-02-06 04:05:33 +08:00
|
|
|
#include "lld/ReaderWriter/CoreLinkingContext.h"
|
2013-04-05 02:59:24 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2015-06-20 03:55:25 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2013-04-05 02:59:24 +08:00
|
|
|
|
|
|
|
using namespace lld;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2015-02-06 04:05:33 +08:00
|
|
|
class OrderPass : public Pass {
|
|
|
|
public:
|
|
|
|
/// Sorts atoms by position
|
2015-06-20 03:43:43 +08:00
|
|
|
std::error_code perform(SimpleFile &file) override {
|
|
|
|
SimpleFile::DefinedAtomRange defined = file.definedAtoms();
|
2015-02-06 04:05:33 +08:00
|
|
|
std::sort(defined.begin(), defined.end(), DefinedAtom::compareByPosition);
|
2015-06-20 01:51:46 +08:00
|
|
|
return std::error_code();
|
2015-02-06 04:05:33 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-04-05 02:59:24 +08:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2013-08-07 06:31:59 +08:00
|
|
|
CoreLinkingContext::CoreLinkingContext() {}
|
2013-04-05 02:59:24 +08:00
|
|
|
|
2013-10-08 23:43:48 +08:00
|
|
|
bool CoreLinkingContext::validateImpl(raw_ostream &) {
|
|
|
|
_writer = createWriterYAML(*this);
|
2013-09-25 07:26:34 +08:00
|
|
|
return true;
|
2013-06-11 20:36:05 +08:00
|
|
|
}
|
2013-04-05 02:59:24 +08:00
|
|
|
|
2013-10-29 13:12:14 +08:00
|
|
|
void CoreLinkingContext::addPasses(PassManager &pm) {
|
2013-04-05 02:59:24 +08:00
|
|
|
for (StringRef name : _passNames) {
|
2015-06-20 03:55:25 +08:00
|
|
|
(void)name;
|
2015-06-20 03:43:43 +08:00
|
|
|
assert(name == "order" && "bad pass name");
|
2015-06-20 03:55:25 +08:00
|
|
|
pm.add(llvm::make_unique<OrderPass>());
|
2013-04-05 02:59:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-08 23:43:48 +08:00
|
|
|
Writer &CoreLinkingContext::writer() const { return *_writer; }
|