r186694 - [SystemZ] Add -march= command-line option
Richard Sandiford
rsandifo at linux.vnet.ibm.com
Fri Jul 19 09:51:51 PDT 2013
Author: rsandifo
Date: Fri Jul 19 11:51:51 2013
New Revision: 186694
URL: http://llvm.org/viewvc/llvm-project?rev=186694&view=rev
Log:
[SystemZ] Add -march= command-line option
Added:
cfe/trunk/test/Driver/systemz-march.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/linux-as.c
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=186694&r1=186693&r2=186694&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jul 19 11:51:51 2013
@@ -4396,6 +4396,17 @@ namespace {
virtual BuiltinVaListKind getBuiltinVaListKind() const {
return TargetInfo::SystemZBuiltinVaList;
}
+ virtual bool setCPU(const std::string &Name) {
+ bool CPUKnown = llvm::StringSwitch<bool>(Name)
+ .Case("z10", true)
+ .Case("z196", true)
+ .Case("zEC12", true)
+ .Default(false);
+
+ // No need to store the CPU yet. There aren't any CPU-specific
+ // macros to define.
+ return CPUKnown;
+ }
};
const char *const SystemZTargetInfo::GCCRegNames[] = {
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=186694&r1=186693&r2=186694&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 19 11:51:51 2013
@@ -1217,6 +1217,19 @@ void Clang::AddSparcTargetArgs(const Arg
}
}
+static const char *getSystemZTargetCPU(const ArgList &Args) {
+ if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+ return A->getValue();
+ return "z10";
+}
+
+void Clang::AddSystemZTargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ const char *CPUName = getSystemZTargetCPU(Args);
+ CmdArgs.push_back("-target-cpu");
+ CmdArgs.push_back(CPUName);
+}
+
static const char *getX86TargetCPU(const ArgList &Args,
const llvm::Triple &Triple) {
if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
@@ -2454,6 +2467,10 @@ void Clang::ConstructJob(Compilation &C,
AddSparcTargetArgs(Args, CmdArgs);
break;
+ case llvm::Triple::systemz:
+ AddSystemZTargetArgs(Args, CmdArgs);
+ break;
+
case llvm::Triple::x86:
case llvm::Triple::x86_64:
AddX86TargetArgs(Args, CmdArgs);
@@ -5926,8 +5943,10 @@ void gnutools::Assemble::ConstructJob(Co
CmdArgs.push_back("-KPIC");
}
} else if (getToolChain().getArch() == llvm::Triple::systemz) {
- // At the moment we always produce z10 code.
- CmdArgs.push_back("-march=z10");
+ // Always pass an -march option, since our default of z10 is later
+ // than the GNU assembler's default.
+ StringRef CPUName = getSystemZTargetCPU(Args);
+ CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
}
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=186694&r1=186693&r2=186694&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Fri Jul 19 11:51:51 2013
@@ -59,6 +59,8 @@ using llvm::opt::ArgStringList;
llvm::opt::ArgStringList &CmdArgs) const;
void AddSparcTargetArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
+ void AddSystemZTargetArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const;
void AddX86TargetArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
void AddHexagonTargetArgs(const llvm::opt::ArgList &Args,
Modified: cfe/trunk/test/Driver/linux-as.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-as.c?rev=186694&r1=186693&r2=186694&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-as.c (original)
+++ cfe/trunk/test/Driver/linux-as.c Fri Jul 19 11:51:51 2013
@@ -1,4 +1,4 @@
-// Check passing options to the assembler for ARM targets.
+// Check passing options to the assembler for various linux targets.
//
// RUN: %clang -target arm-linux -### \
// RUN: -no-integrated-as -c %s 2>&1 \
@@ -54,3 +54,12 @@
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=PPC-NO-MCPU %s
// CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu"
+//
+// RUN: %clang -target s390x-linux -### -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=Z-DEFAULT-ARCH %s
+// CHECK-Z-DEFAULT-ARCH: as{{.*}} "-march=z10"
+//
+// RUN: %clang -target s390x-linux -march=z196 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=Z-ARCH-Z196 %s
+// CHECK-Z-ARCH-Z196: as{{.*}} "-march=z196"
Added: cfe/trunk/test/Driver/systemz-march.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/systemz-march.c?rev=186694&view=auto
==============================================================================
--- cfe/trunk/test/Driver/systemz-march.c (added)
+++ cfe/trunk/test/Driver/systemz-march.c Fri Jul 19 11:51:51 2013
@@ -0,0 +1,13 @@
+// Check that -march works for all supported targets.
+
+// RUN: not %clang -target s390x -S -emit-llvm -march=z9 %s -o - 2>&1 | FileCheck --check-prefix=CHECK-Z9 %s
+// RUN: %clang -target s390x -S -emit-llvm -march=z10 %s
+// RUN: %clang -target s390x -S -emit-llvm -march=z196 %s
+// RUN: %clang -target s390x -S -emit-llvm -march=zEC12 %s
+
+// CHECK-Z9: error: unknown target CPU 'z9'
+// CHECK-Z10: "-target-cpu" "z10"
+// CHECK-Z196: "-target-cpu" "z196"
+// CHECK-ZEC12: "-target-cpu" "zEC12"
+
+int x;
More information about the cfe-commits
mailing list