[lld] r246335 - [Mips] Make "emulation" option less dependent on the "-target" option.
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 14:39:06 PDT 2015
Author: atanasyan
Date: Fri Aug 28 16:39:06 2015
New Revision: 246335
URL: http://llvm.org/viewvc/llvm-project?rev=246335&view=rev
Log:
[Mips] Make "emulation" option less dependent on the "-target" option.
Now it is possible to have mips-linux-gnu-ld executable and link MIPS 64-bit
little-endian binaries providing -melf64ltsmip command line argument.
Modified:
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=246335&r1=246334&r2=246335&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Fri Aug 28 16:39:06 2015
@@ -165,19 +165,15 @@ getArchType(const llvm::Triple &triple,
return llvm::Triple::x86_64;
return llvm::None;
case llvm::Triple::mips:
- case llvm::Triple::mips64:
- if (value == "elf32btsmip")
- return llvm::Triple::mips;
- if (value == "elf64btsmip")
- return llvm::Triple::mips64;
- return llvm::None;
case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
case llvm::Triple::mips64el:
- if (value == "elf32ltsmip")
- return llvm::Triple::mipsel;
- if (value == "elf64ltsmip")
- return llvm::Triple::mips64el;
- return llvm::None;
+ return llvm::StringSwitch<llvm::Optional<llvm::Triple::ArchType>>(value)
+ .Case("elf32btsmip", llvm::Triple::mips)
+ .Case("elf32ltsmip", llvm::Triple::mipsel)
+ .Case("elf64btsmip", llvm::Triple::mips64)
+ .Case("elf64ltsmip", llvm::Triple::mips64el)
+ .Default(llvm::None);
case llvm::Triple::aarch64:
if (value == "aarch64linux")
return llvm::Triple::aarch64;
Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=246335&r1=246334&r2=246335&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Fri Aug 28 16:39:06 2015
@@ -199,6 +199,16 @@ TEST_F(GnuLdParserTest, AsNeeded) {
EXPECT_FALSE(cast<FileNode>(nodes[3].get())->asNeeded());
}
+// Emulation
+
+TEST_F(GnuLdParserTest, Emulation) {
+ EXPECT_TRUE(parse("mips-linux-gnu-ld", "a.o", "-m", "elf64ltsmip", nullptr));
+ EXPECT_EQ(Triple::mips64el, _ctx->getTriple().getArch());
+ EXPECT_TRUE(
+ parse("mips64el-linux-gnu-ld", "a.o", "-m", "elf32btsmip", nullptr));
+ EXPECT_EQ(Triple::mips, _ctx->getTriple().getArch());
+}
+
// Linker script
TEST_F(LinkerScriptTest, Input) {
More information about the llvm-commits
mailing list