[llvm-commits] [PATCH] [lld] Changes for adding hexagon target and add noinhibit-exec option
Shankar Kalpathi Easwaran
shankarke at gmail.com
Thu Jan 10 21:14:06 PST 2013
Hi Bigcheese, kledzik,
This is for adding hexagon target to lld and add noinhibit-exec option.
http://llvm-reviews.chandlerc.com/D282
Files:
test/Driver/x86_64-target.test
test/Driver/hexagon-target.test
include/lld/Driver/LinkerOptions.h
lib/Driver/Drivers.cpp
lib/Driver/LinkerInvocation.cpp
lib/Driver/LDOptions.td
lib/Driver/CoreOptions.td
lib/Driver/Targets.cpp
Index: test/Driver/x86_64-target.test
===================================================================
--- test/Driver/x86_64-target.test
+++ test/Driver/x86_64-target.test
@@ -1,2 +1,4 @@
# Will fail with unersolved symbol
RUN: lld -flavor ld -target x86_64-linux || exit 0
+# Will say unresolved symbols but not fail
+RUN: lld -flavor ld -target x86_64-linux --noinhibit-exec
Index: test/Driver/hexagon-target.test
===================================================================
--- test/Driver/hexagon-target.test
+++ test/Driver/hexagon-target.test
@@ -0,0 +1,4 @@
+# Will fail with unresolved symbol
+RUN: lld -flavor ld -target hexagon || exit 0
+# Will say unresolved symbols but not fail
+RUN: lld -flavor ld -target hexagon --noinhibit-exec
Index: include/lld/Driver/LinkerOptions.h
===================================================================
--- include/lld/Driver/LinkerOptions.h
+++ include/lld/Driver/LinkerOptions.h
@@ -116,7 +116,8 @@
, _entrySymbol(std::move(other._entrySymbol))
, _relocatable(other._relocatable)
, _outputCommands(other._outputCommands)
- , _outputYAML(other._outputYAML) {}
+ , _outputYAML(other._outputYAML)
+ , _noInhibitExec(other._noInhibitExec) {}
std::vector<LinkerInput> _input;
std::vector<std::string> _llvmArgs;
@@ -127,6 +128,7 @@
/// \brief -###
unsigned _outputCommands : 1;
unsigned _outputYAML : 1;
+ unsigned _noInhibitExec : 1;
private:
LinkerOptions(const LinkerOptions&) LLVM_DELETED_FUNCTION;
Index: lib/Driver/Drivers.cpp
===================================================================
--- lib/Driver/Drivers.cpp
+++ lib/Driver/Drivers.cpp
@@ -146,6 +146,9 @@
if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_emit_yaml))
newArgs->AddFlagArg(A, _core.getOption(core::OPT_emit_yaml));
+ if (llvm::opt::Arg *A = _inputArgs->getLastArg(ld::OPT_noinhibit_exec))
+ newArgs->AddFlagArg(A, _core.getOption(core::OPT_noinhibit_exec));
+
// Copy input args.
for (llvm::opt::arg_iterator it = _inputArgs->filtered_begin(ld::OPT_INPUT),
ie = _inputArgs->filtered_end();
@@ -228,6 +231,7 @@
ret._relocatable = args.hasArg(core::OPT_relocatable);
ret._outputCommands = args.hasArg(core::OPT_OCTOTHORPE_OCTOTHORPE_OCTOTHORPE);
ret._outputYAML = args.hasArg(core::OPT_emit_yaml);
+ ret._noInhibitExec = args.hasArg(core::OPT_noinhibit_exec);
return std::move(ret);
}
Index: lib/Driver/LinkerInvocation.cpp
===================================================================
--- lib/Driver/LinkerInvocation.cpp
+++ lib/Driver/LinkerInvocation.cpp
@@ -67,11 +67,11 @@
}
struct Blah : ResolverOptions {
- Blah()
+ Blah(const LinkerOptions &options)
: ResolverOptions() {
- _undefinesAreErrors = true;
+ _undefinesAreErrors = !options._noInhibitExec;
}
- } ro;
+ } ro(_options);
auto writer = target->getWriter();
Index: lib/Driver/LDOptions.td
===================================================================
--- lib/Driver/LDOptions.td
+++ lib/Driver/LDOptions.td
@@ -23,3 +23,5 @@
def static : Flag<["-"], "static">;
def L : Joined<["-"], "L">;
+
+def noinhibit_exec : Flag<["--"], "noinhibit-exec">;
Index: lib/Driver/CoreOptions.td
===================================================================
--- lib/Driver/CoreOptions.td
+++ lib/Driver/CoreOptions.td
@@ -11,3 +11,5 @@
def OCTOTHORPE_OCTOTHORPE_OCTOTHORPE : Flag<["-"], "###">;
def emit_yaml : Flag<["-"], "emit-yaml">;
+
+def noinhibit_exec : Flag<["--"], "noinhibit-exec">;
Index: lib/Driver/Targets.cpp
===================================================================
--- lib/Driver/Targets.cpp
+++ lib/Driver/Targets.cpp
@@ -159,12 +159,81 @@
std::unique_ptr<lld::Writer> _writer, _writerYAML;
};
+class HexagonTarget final : public Target {
+public:
+ HexagonTarget(const LinkerOptions &lo)
+ : Target(lo), _woe(lo._entrySymbol) {
+ _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) {
+ auto kind = input.getKind();
+ if (!kind)
+ return error_code(kind);
+
+ if (*kind == InputKind::YAML)
+ return *_readerYAML;
+
+ if (*kind == InputKind::Object)
+ return *_readerELF;
+
+ return llvm::make_error_code(llvm::errc::invalid_argument);
+ }
+
+ virtual ErrorOr<lld::Writer&> getWriter() {
+ return _options._outputYAML ? *_writerYAML : *_writer;
+ }
+
+private:
+ lld::ReaderOptionsELF _roe;
+ lld::ReaderOptionsArchive _roa;
+ struct : lld::ReaderOptionsYAML {
+ virtual Reference::Kind kindFromString(StringRef kindName) const {
+ int k;
+ if (kindName.getAsInteger(0, k))
+ k = 0;
+ return k;
+ }
+ } _roy;
+
+ struct WOpts : lld::WriterOptionsELF {
+ WOpts(StringRef entry) {
+ _endianness = llvm::support::little;
+ _is64Bit = true;
+ _type = llvm::ELF::ET_EXEC;
+ _machine = llvm::ELF::EM_HEXAGON;
+ _entryPoint = entry;
+ }
+ } _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, _writerYAML;
+};
+
std::unique_ptr<Target> Target::create(const LinkerOptions &lo) {
llvm::Triple t(lo._target);
if (t.getOS() == llvm::Triple::Linux && t.getArch() == llvm::Triple::x86)
return std::unique_ptr<Target>(new X86LinuxTarget(lo));
else if (t.getOS() == llvm::Triple::Linux &&
t.getArch() == llvm::Triple::x86_64)
return std::unique_ptr<Target>(new X86_64LinuxTarget(lo));
+ else if (t.getArch() == llvm::Triple::hexagon)
+ return std::unique_ptr<Target>(new HexagonTarget(lo));
return std::unique_ptr<Target>();
}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D282.1.patch
Type: text/x-patch
Size: 6190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130110/b462ddf9/attachment.bin>
More information about the llvm-commits
mailing list