r178232 - [Mips] Handle pseudo-target flags '-EL' and '-EB' and properly adjust
Simon Atanasyan
simon at atanasyan.com
Thu Mar 28 04:36:22 PDT 2013
Author: atanasyan
Date: Thu Mar 28 06:36:22 2013
New Revision: 178232
URL: http://llvm.org/viewvc/llvm-project?rev=178232&view=rev
Log:
[Mips] Handle pseudo-target flags '-EL' and '-EB' and properly adjust
toolchain flags for MIPS targets.
Added:
cfe/trunk/test/Driver/mips-eleb.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=178232&r1=178231&r2=178232&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar 28 06:36:22 2013
@@ -822,6 +822,8 @@ def keep__private__externs : Flag<["-"],
def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>;
def lazy__framework : Separate<["-"], "lazy_framework">, Flags<[LinkerInput]>;
def lazy__library : Separate<["-"], "lazy_library">, Flags<[LinkerInput]>;
+def EL : Flag<["-"], "EL">, Flags<[DriverOption]>;
+def EB : Flag<["-"], "EB">, Flags<[DriverOption]>;
def m32 : Flag<["-"], "m32">, Group<m_Group>, Flags<[DriverOption]>;
def mqdsp6_compat : Flag<["-"], "mqdsp6-compat">, Group<m_Group>, Flags<[DriverOption,CC1Option]>,
HelpText<"Enable hexagon-qdsp6 backward compatibility">;
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=178232&r1=178231&r2=178232&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Mar 28 06:36:22 2013
@@ -1653,6 +1653,21 @@ static llvm::Triple computeTargetTriple(
}
}
+ // Handle pseudo-target flags '-EL' and '-EB'.
+ if (Arg *A = Args.getLastArg(options::OPT_EL, options::OPT_EB)) {
+ if (A->getOption().matches(options::OPT_EL)) {
+ 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::mipsel)
+ Target.setArch(llvm::Triple::mips);
+ else if (Target.getArch() == llvm::Triple::mips64el)
+ Target.setArch(llvm::Triple::mips64);
+ }
+ }
+
// Skip further flag support on OSes which don't support '-m32' or '-m64'.
if (Target.getArchName() == "tce" ||
Target.getOS() == llvm::Triple::AuroraUX ||
Added: cfe/trunk/test/Driver/mips-eleb.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-eleb.c?rev=178232&view=auto
==============================================================================
--- cfe/trunk/test/Driver/mips-eleb.c (added)
+++ cfe/trunk/test/Driver/mips-eleb.c Thu Mar 28 06:36:22 2013
@@ -0,0 +1,31 @@
+// REQUIRES: mips-registered-target
+//
+// Check that -EL/-EB options adjust the toolchain flags.
+//
+// RUN: %clang -target mips-unknown-linux-gnu -### \
+// RUN: -EL -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EL %s
+// MIPS32-EL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mipsel-unknown-linux-gnu"
+// MIPS32-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+// MIPS32-EL: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf32ltsmip"
+//
+// RUN: %clang -target mips64-unknown-linux-gnu -### \
+// RUN: -EL -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EL %s
+// MIPS64-EL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips64el-unknown-linux-gnu"
+// MIPS64-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+// MIPS64-EL: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf64ltsmip"
+//
+// RUN: %clang -target mipsel-unknown-linux-gnu -### \
+// RUN: -EB -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EB %s
+// MIPS32-EB: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips-unknown-linux-gnu"
+// MIPS32-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+// MIPS32-EB: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf32btsmip"
+//
+// RUN: %clang -target mips64el-unknown-linux-gnu -### \
+// RUN: -EB -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EB %s
+// MIPS64-EB: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips64-unknown-linux-gnu"
+// MIPS64-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+// MIPS64-EB: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf64btsmip"
More information about the cfe-commits
mailing list