From: Benjamin Kramer Date: Mon, 6 Jul 2015 23:59:45 +0000 (+0000) Subject: [Driver] Use llvm::Triple methods to handle -EL and -EB. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=162079e4aff02c885eb8f1a5fb4169f7b1bebf13;p=clang [Driver] Use llvm::Triple methods to handle -EL and -EB. Add a test for ppc64(le), which wasn't handled before. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241528 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index b9dc35d621..c23768e686 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1932,19 +1932,13 @@ static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple, 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); } } diff --git a/test/Driver/ppc-endian.c b/test/Driver/ppc-endian.c new file mode 100644 index 0000000000..4d8db38943 --- /dev/null +++ b/test/Driver/ppc-endian.c @@ -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{{.*}}"