r198943 - Implement -m32 and -m64 with llvm::Triple functions.
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Jan 10 07:25:23 PST 2014
Author: stoklund
Date: Fri Jan 10 09:25:23 2014
New Revision: 198943
URL: http://llvm.org/viewvc/llvm-project?rev=198943&view=rev
Log:
Implement -m32 and -m64 with llvm::Triple functions.
Don't repeat the 32 <-> 64 architecture mapping incompletely.
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/unknown-gcc-arch.c
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=198943&r1=198942&r2=198943&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 10 09:25:23 2014
@@ -1911,19 +1911,14 @@ static llvm::Triple computeTargetTriple(
return Target;
// Handle pseudo-target flags '-m32' and '-m64'.
- // FIXME: Should this information be in llvm::Triple?
if (Arg *A = Args.getLastArg(options::OPT_m32, options::OPT_m64)) {
- if (A->getOption().matches(options::OPT_m32)) {
- if (Target.getArch() == llvm::Triple::x86_64)
- Target.setArch(llvm::Triple::x86);
- if (Target.getArch() == llvm::Triple::ppc64)
- Target.setArch(llvm::Triple::ppc);
- } else {
- if (Target.getArch() == llvm::Triple::x86)
- Target.setArch(llvm::Triple::x86_64);
- if (Target.getArch() == llvm::Triple::ppc)
- Target.setArch(llvm::Triple::ppc64);
- }
+ llvm::Triple::ArchType AT;
+ if (A->getOption().matches(options::OPT_m32))
+ AT = Target.get32BitArchVariant().getArch();
+ else
+ AT = Target.get64BitArchVariant().getArch();
+ if (AT != llvm::Triple::UnknownArch)
+ Target.setArch(AT);
}
return Target;
Modified: cfe/trunk/test/Driver/unknown-gcc-arch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-gcc-arch.c?rev=198943&r1=198942&r2=198943&view=diff
==============================================================================
--- cfe/trunk/test/Driver/unknown-gcc-arch.c (original)
+++ cfe/trunk/test/Driver/unknown-gcc-arch.c Fri Jan 10 09:25:23 2014
@@ -30,3 +30,11 @@
// RUN: %clang -target powerpc-unknown-unknown -c -x assembler %s -### -m64 2>&1 \
// RUN: | FileCheck -check-prefix=PPC-M64 %s
// PPC-M64: {{.*as.*-a64}}
+
+// RUN: %clang -target sparc64-unknown-unknown -no-integrated-as -c -x assembler %s -### -m32 2>&1 \
+// RUN: | FileCheck -check-prefix=SPARCV8 %s
+// SPARCV8: {{.*as.*-32}}
+
+// RUN: %clang -target sparc-unknown-unknown -no-integrated-as -c -x assembler %s -### -m64 2>&1 \
+// RUN: | FileCheck -check-prefix=SPARCV9 %s
+// SPARCV9: {{.*as.*-64}}
More information about the cfe-commits
mailing list