Skip to content

Commit

Permalink
[Driver] Use llvm::Triple methods to handle -EL and -EB.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
d0k committed Jul 6, 2015
1 parent af612f8 commit 162079e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/Driver/ppc-endian.c
Original file line number Diff line number Diff line change
@@ -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{{.*}}"

0 comments on commit 162079e

Please sign in to comment.