[clang] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: > We are trying to remove such cmake variables in favor of configuration file. I'm not sure which configuration file(s) you are referring to. I assume you mean the cache files in clang/cmake/caches. If so, I don't think we want to put it there because `CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH` is a value defined for all the builds. It's not a value controlling how the build is done and we aren't trying to override the value of `CLANG_SYSTEMZ_DEFAULT_ARCH` for a particular build configuration. I might need to explain some more. If the user compiles with `-target=s390x-unknown-linux` then the default arch is arch8/z10. If the user compiles with `-target=s390x-ibm-zos` then the default arch is arch10/zEC12. The arch value is determined at runtime when clang is run. I could see us using a cache file to override the value of `CLANG_SYSTEMZ_DEFAULT_ARCH` if both values weren't needed by the compiler at the same time. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Set the default arch for z/OS to be arch10 (PR #89854)
MaskRay wrote: We are trying to remove such cmake variables in favor of configuration file. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Set the default arch for z/OS to be arch10 (PR #89854)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Sean Perry (perry-ca) Changes The default arch level on z/OS is arch10. Update the code so z/OS has arch10 without changing the default for zLinux. --- Full diff: https://github.com/llvm/llvm-project/pull/89854.diff 8 Files Affected: - (modified) clang/CMakeLists.txt (+2) - (modified) clang/include/clang/Config/config.h.cmake (+3) - (modified) clang/lib/Basic/Targets/SystemZ.h (+3-4) - (modified) clang/lib/Driver/ToolChains/Arch/SystemZ.cpp (+4-1) - (modified) clang/lib/Driver/ToolChains/Arch/SystemZ.h (+2-1) - (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+2-1) - (modified) clang/test/Preprocessor/predefined-arch-macros.c (+16) ``diff diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f07..f06fbec1d02f91 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..004c5c95c00cff 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8ad..45fb7e447b6429 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -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; @@ -33,7 +32,8 @@ 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(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,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; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb8114..7baeffc00053a7 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -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 Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c20..438dab8765bc34 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -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 Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd79..73f5abfaafcba0 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b
[clang] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/89854 The default arch level on z/OS is arch10. Update the code so z/OS has arch10 without changing the default for zLinux. >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f07..f06fbec1d02f91 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..004c5c95c00cff 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8ad..45fb7e447b6429 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -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; @@ -33,7 +32,8 @@ 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(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,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; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb8114..7baeffc00053a7 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -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 Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c20..438dab8765bc34 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -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 Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChai