Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[z/OS] Set the default arch for z/OS to be arch10 #89854

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions clang/lib/Basic/Targets/SystemZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace targets {
class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {

static const char *const GCCRegNames[];
std::string CPU;
int ISARevision;
bool HasTransactionalExecution;
bool HasVector;
Expand All @@ -33,7 +32,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {

public:
SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
: TargetInfo(Triple), CPU("z10"), ISARevision(8),
: TargetInfo(Triple), ISARevision(getISARevision("z10")),
HasTransactionalExecution(false), HasVector(false), SoftFloat(false),
UnalignedSymbols(false) {
IntMaxType = SignedLong;
Expand Down Expand Up @@ -140,8 +139,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
}

bool setCPU(const std::string &Name) override {
CPU = Name;
ISARevision = getISARevision(CPU);
ISARevision = getISARevision(Name);
return ISARevision != -1;
}

Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,
return ABI;
}

std::string systemz::getSystemZTargetCPU(const ArgList &Args) {
std::string systemz::getSystemZTargetCPU(const ArgList &Args,
const llvm::Triple &T) {
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
llvm::StringRef CPUName = A->getValue();

Expand All @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) {

return std::string(CPUName);
}
if (T.isOSzOS())
return "zEC12";
return CLANG_SYSTEMZ_DEFAULT_ARCH;
}

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/Arch/SystemZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ enum class FloatABI {

FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args);

std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args);
std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args,
const llvm::Triple &T);

void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
std::vector<llvm::StringRef> &Features);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
return getLanaiTargetCPU(Args);

case llvm::Triple::systemz:
return systemz::getSystemZTargetCPU(Args);
return systemz::getSystemZTargetCPU(Args, T);

case llvm::Triple::r600:
case llvm::Triple::amdgcn:
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
case llvm::Triple::systemz: {
// Always pass an -march option, since our default of z10 is later
// than the GNU assembler's default.
std::string CPUName = systemz::getSystemZTargetCPU(Args);
std::string CPUName =
systemz::getSystemZTargetCPU(Args, getToolChain().getTriple());
CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
break;
}
Expand Down
16 changes: 16 additions & 0 deletions clang/test/Preprocessor/predefined-arch-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -4141,6 +4141,20 @@

// Begin SystemZ/GCC/Linux tests ----------------

// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target s390x-ibm-zos \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--target= for new driver tests.

However, this does not test clangDriver and therefore %clang_cc1 is preferred.

(You can ignore previous lines that obey the convention. I can fix them later.)

// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZOS
// CHECK_SYSTEMZ_ZOS: #define __ARCH__ 10
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
// CHECK_SYSTEMZ_ZOS: #define __HTM__ 1
// CHECK_SYSTEMZ_ZOS: #define __LONG_DOUBLE_128__ 1
// CHECK_SYSTEMZ_ZOS: #define __s390__ 1
// CHECK_SYSTEMZ_ZOS: #define __s390x__ 1
// CHECK_SYSTEMZ_ZOS: #define __zarch__ 1

// RUN: %clang -march=arch8 -E -dM %s -o - 2>&1 \
// RUN: -target s390x-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
Expand All @@ -4152,6 +4166,7 @@
// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
// CHECK_SYSTEMZ_ARCH8-NOT: #define __HTM__ 1
// CHECK_SYSTEMZ_ARCH8: #define __LONG_DOUBLE_128__ 1
// CHECK_SYSTEMZ_ARCH8: #define __s390__ 1
// CHECK_SYSTEMZ_ARCH8: #define __s390x__ 1
Expand All @@ -4168,6 +4183,7 @@
// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
// CHECK_SYSTEMZ_ARCH9-NOT: #define __HTM__ 1
// CHECK_SYSTEMZ_ARCH9: #define __LONG_DOUBLE_128__ 1
// CHECK_SYSTEMZ_ARCH9: #define __s390__ 1
// CHECK_SYSTEMZ_ARCH9: #define __s390x__ 1
Expand Down
Loading