[llvm-commits] [lld] r171710 - in /lld/trunk: include/lld/Driver/LinkerOptions.h lib/Driver/CoreOptions.td lib/Driver/Drivers.cpp lib/Driver/LDOptions.td lib/Driver/Targets.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Mon Jan 7 00:00:25 PST 2013
Author: mspencer
Date: Mon Jan 7 02:00:25 2013
New Revision: 171710
URL: http://llvm.org/viewvc/llvm-project?rev=171710&view=rev
Log:
[lld] Add -emit-yaml option. This outputs yaml instead of a binary.
Modified:
lld/trunk/include/lld/Driver/LinkerOptions.h
lld/trunk/lib/Driver/CoreOptions.td
lld/trunk/lib/Driver/Drivers.cpp
lld/trunk/lib/Driver/LDOptions.td
lld/trunk/lib/Driver/Targets.cpp
Modified: lld/trunk/include/lld/Driver/LinkerOptions.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/LinkerOptions.h?rev=171710&r1=171709&r2=171710&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/LinkerOptions.h (original)
+++ lld/trunk/include/lld/Driver/LinkerOptions.h Mon Jan 7 02:00:25 2013
@@ -111,7 +111,8 @@
, _outputPath(std::move(other._outputPath))
, _entrySymbol(std::move(other._entrySymbol))
, _relocatable(other._relocatable)
- , _outputCommands(other._outputCommands) {}
+ , _outputCommands(other._outputCommands)
+ , _outputYAML(other._outputYAML) {}
std::vector<LinkerInput> _input;
std::string _target;
@@ -120,6 +121,7 @@
unsigned _relocatable : 1;
/// \brief -###
unsigned _outputCommands : 1;
+ unsigned _outputYAML : 1;
private:
LinkerOptions(const LinkerOptions&) LLVM_DELETED_FUNCTION;
Modified: lld/trunk/lib/Driver/CoreOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreOptions.td?rev=171710&r1=171709&r2=171710&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CoreOptions.td (original)
+++ lld/trunk/lib/Driver/CoreOptions.td Mon Jan 7 02:00:25 2013
@@ -8,3 +8,5 @@
def relocatable : Flag<["-"], "relocatable">;
def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
+
+def emit_yaml : Flag<["-"], "emit-yaml">;
Modified: lld/trunk/lib/Driver/Drivers.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Drivers.cpp?rev=171710&r1=171709&r2=171710&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Drivers.cpp (original)
+++ lld/trunk/lib/Driver/Drivers.cpp Mon Jan 7 02:00:25 2013
@@ -136,6 +136,9 @@
newArgs->AddFlagArg(A, _core.getOption(
core::OPT_OCTOTHORPE_OCTOTHORPE_OCTOTHORPE));
+ if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_emit_yaml))
+ newArgs->AddFlagArg(A, _core.getOption(core::OPT_emit_yaml));
+
// Copy input args.
for (llvm::opt::arg_iterator it = _inputArgs->filtered_begin(ld::OPT_INPUT),
ie = _inputArgs->filtered_end();
@@ -197,6 +200,7 @@
ret._entrySymbol = args.getLastArgValue(core::OPT_entry);
ret._relocatable = args.hasArg(core::OPT_relocatable);
ret._outputCommands = args.hasArg(core::OPT_OCTOTHORPE_OCTOTHORPE_OCTOTHORPE);
+ ret._outputYAML = args.hasArg(core::OPT_emit_yaml);
return std::move(ret);
}
Modified: lld/trunk/lib/Driver/LDOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/LDOptions.td?rev=171710&r1=171709&r2=171710&view=diff
==============================================================================
--- lld/trunk/lib/Driver/LDOptions.td (original)
+++ lld/trunk/lib/Driver/LDOptions.td Mon Jan 7 02:00:25 2013
@@ -13,3 +13,5 @@
def relocatable_r : Flag<["-"], "r">, Alias<relocatable>;
def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
+
+def emit_yaml : Flag<["-"], "emit-yaml">;
Modified: lld/trunk/lib/Driver/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Targets.cpp?rev=171710&r1=171709&r2=171710&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Targets.cpp (original)
+++ lld/trunk/lib/Driver/Targets.cpp Mon Jan 7 02:00:25 2013
@@ -19,8 +19,12 @@
#include "lld/ReaderWriter/ReaderELF.h"
#include "lld/ReaderWriter/ReaderYAML.h"
#include "lld/ReaderWriter/WriterELF.h"
+#include "lld/ReaderWriter/WriterYAML.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include <set>
using namespace lld;
@@ -30,6 +34,7 @@
_readerELF.reset(createReaderELF(_roe, _roa));
_readerYAML.reset(createReaderYAML(_roy));
_writer.reset(createWriterELF(_woe));
+ _writerYAML.reset(createWriterYAML(_woy));
}
virtual ErrorOr<lld::Reader&> getReader(const LinkerInput &input) {
@@ -47,7 +52,7 @@
}
virtual ErrorOr<lld::Writer&> getWriter() {
- return *_writer;
+ return _options._outputYAML ? *_writerYAML : *_writer;
}
private:
@@ -72,8 +77,20 @@
}
} _woe;
+ struct WYOpts : lld::WriterOptionsYAML {
+ virtual StringRef kindToString(Reference::Kind k) const {
+ std::string str;
+ llvm::raw_string_ostream rso(str);
+ rso << (unsigned)k;
+ rso.flush();
+ return *_strings.insert(str).first;
+ }
+
+ mutable std::set<std::string> _strings;
+ } _woy;
+
std::unique_ptr<lld::Reader> _readerELF, _readerYAML;
- std::unique_ptr<lld::Writer> _writer;
+ std::unique_ptr<lld::Writer> _writer, _writerYAML;
};
class X86_64LinuxTarget final : public Target {
@@ -83,6 +100,7 @@
_readerELF.reset(createReaderELF(_roe, _roa));
_readerYAML.reset(createReaderYAML(_roy));
_writer.reset(createWriterELF(_woe));
+ _writerYAML.reset(createWriterYAML(_woy));
}
virtual ErrorOr<lld::Reader&> getReader(const LinkerInput &input) {
@@ -100,7 +118,7 @@
}
virtual ErrorOr<lld::Writer&> getWriter() {
- return *_writer;
+ return _options._outputYAML ? *_writerYAML : *_writer;
}
private:
@@ -125,8 +143,20 @@
}
} _woe;
+ struct WYOpts : lld::WriterOptionsYAML {
+ virtual StringRef kindToString(Reference::Kind k) const {
+ std::string str;
+ llvm::raw_string_ostream rso(str);
+ rso << (unsigned)k;
+ rso.flush();
+ return *_strings.insert(str).first;
+ }
+
+ mutable std::set<std::string> _strings;
+ } _woy;
+
std::unique_ptr<lld::Reader> _readerELF, _readerYAML;
- std::unique_ptr<lld::Writer> _writer;
+ std::unique_ptr<lld::Writer> _writer, _writerYAML;
};
std::unique_ptr<Target> Target::create(const LinkerOptions &lo) {
More information about the llvm-commits
mailing list