r241528 - [Driver] Use llvm::Triple methods to handle -EL and -EB.

Benjamin Kramer benny.kra at googlemail.com
Mon Jul 6 16:59:45 PDT 2015


Author: d0k
Date: Mon Jul  6 18:59:45 2015
New Revision: 241528

URL: http://llvm.org/viewvc/llvm-project?rev=241528&view=rev
Log:
[Driver] Use llvm::Triple methods to handle -EL and -EB.

Add a test for ppc64(le), which wasn't handled before.

Added:
    cfe/trunk/test/Driver/ppc-endian.c
Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=241528&r1=241527&r2=241528&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jul  6 18:59:45 2015
@@ -1932,19 +1932,13 @@ static llvm::Triple computeTargetTriple(
   if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
                                options::OPT_mbig_endian)) {
     if (A->getOption().matches(options::OPT_mlittle_endian)) {
-      if (Target.getArch() == llvm::Triple::mips)
-        Target.setArch(llvm::Triple::mipsel);
-      else if (Target.getArch() == llvm::Triple::mips64)
-        Target.setArch(llvm::Triple::mips64el);
-      else if (Target.getArch() == llvm::Triple::aarch64_be)
-        Target.setArch(llvm::Triple::aarch64);
+      llvm::Triple LE = Target.getLittleEndianArchVariant();
+      if (LE.getArch() != llvm::Triple::UnknownArch)
+        Target = std::move(LE);
     } else {
-      if (Target.getArch() == llvm::Triple::mipsel)
-        Target.setArch(llvm::Triple::mips);
-      else if (Target.getArch() == llvm::Triple::mips64el)
-        Target.setArch(llvm::Triple::mips64);
-      else if (Target.getArch() == llvm::Triple::aarch64)
-        Target.setArch(llvm::Triple::aarch64_be);
+      llvm::Triple BE = Target.getBigEndianArchVariant();
+      if (BE.getArch() != llvm::Triple::UnknownArch)
+        Target = std::move(BE);
     }
   }
 

Added: cfe/trunk/test/Driver/ppc-endian.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-endian.c?rev=241528&view=auto
==============================================================================
--- cfe/trunk/test/Driver/ppc-endian.c (added)
+++ cfe/trunk/test/Driver/ppc-endian.c Mon Jul  6 18:59:45 2015
@@ -0,0 +1,9 @@
+// RUN: %clang -target powerpc64le -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE %s
+// RUN: %clang -target powerpc64le -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE %s
+// RUN: %clang -target powerpc64 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE %s
+// CHECK-LE: "-cc1"{{.*}} "-triple" "powerpc64le{{.*}}"
+
+// RUN: %clang -target powerpc64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE %s
+// RUN: %clang -target powerpc64 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE %s
+// RUN: %clang -target powerpc64le -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE %s
+// CHECK-BE: "-cc1"{{.*}} "-triple" "powerpc64{{.*}}"





More information about the cfe-commits mailing list