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);
}
}
--- /dev/null
+// 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{{.*}}"