Skip to content

Commit e62bf7c

Browse files
authored
[z/OS] Set the default arch for z/OS to be arch10 (#89854)
The default arch level on z/OS is arch10. Update the code so z/OS has arch10 without changing the default for zLinux.
1 parent 98815f7 commit e62bf7c

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

clang/lib/Basic/Targets/SystemZ.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ static const unsigned ZOSAddressMap[] = {
4848
class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
4949

5050
static const char *const GCCRegNames[];
51-
std::string CPU;
5251
int ISARevision;
5352
bool HasTransactionalExecution;
5453
bool HasVector;
@@ -58,7 +57,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
5857

5958
public:
6059
SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
61-
: TargetInfo(Triple), CPU("z10"), ISARevision(8),
60+
: TargetInfo(Triple), ISARevision(getISARevision("z10")),
6261
HasTransactionalExecution(false), HasVector(false), SoftFloat(false),
6362
UnalignedSymbols(false) {
6463
IntMaxType = SignedLong;
@@ -168,8 +167,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
168167
}
169168

170169
bool setCPU(const std::string &Name) override {
171-
CPU = Name;
172-
ISARevision = getISARevision(CPU);
170+
ISARevision = getISARevision(Name);
173171
return ISARevision != -1;
174172
}
175173

clang/lib/Driver/ToolChains/Arch/SystemZ.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D,
3434
return ABI;
3535
}
3636

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

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

4950
return std::string(CPUName);
5051
}
52+
if (T.isOSzOS())
53+
return "zEC12";
5154
return CLANG_SYSTEMZ_DEFAULT_ARCH;
5255
}
5356

clang/lib/Driver/ToolChains/Arch/SystemZ.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ enum class FloatABI {
2727

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

30-
std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args);
30+
std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args,
31+
const llvm::Triple &T);
3132

3233
void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
3334
std::vector<llvm::StringRef> &Features);

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
674674
return getLanaiTargetCPU(Args);
675675

676676
case llvm::Triple::systemz:
677-
return systemz::getSystemZTargetCPU(Args);
677+
return systemz::getSystemZTargetCPU(Args, T);
678678

679679
case llvm::Triple::r600:
680680
case llvm::Triple::amdgcn:

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
937937
case llvm::Triple::systemz: {
938938
// Always pass an -march option, since our default of z10 is later
939939
// than the GNU assembler's default.
940-
std::string CPUName = systemz::getSystemZTargetCPU(Args);
940+
std::string CPUName =
941+
systemz::getSystemZTargetCPU(Args, getToolChain().getTriple());
941942
CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
942943
break;
943944
}

clang/test/Preprocessor/predefined-arch-macros.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4053,6 +4053,20 @@
40534053

40544054
// Begin SystemZ/GCC/Linux tests ----------------
40554055

4056+
// RUN: %clang -E -dM %s -o - 2>&1 \
4057+
// RUN: -target s390x-ibm-zos \
4058+
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZOS
4059+
// CHECK_SYSTEMZ_ZOS: #define __ARCH__ 10
4060+
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
4061+
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
4062+
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
4063+
// CHECK_SYSTEMZ_ZOS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
4064+
// CHECK_SYSTEMZ_ZOS: #define __HTM__ 1
4065+
// CHECK_SYSTEMZ_ZOS: #define __LONG_DOUBLE_128__ 1
4066+
// CHECK_SYSTEMZ_ZOS: #define __s390__ 1
4067+
// CHECK_SYSTEMZ_ZOS: #define __s390x__ 1
4068+
// CHECK_SYSTEMZ_ZOS: #define __zarch__ 1
4069+
40564070
// RUN: %clang -march=arch8 -E -dM %s -o - 2>&1 \
40574071
// RUN: -target s390x-unknown-linux \
40584072
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
@@ -4064,6 +4078,7 @@
40644078
// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
40654079
// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
40664080
// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
4081+
// CHECK_SYSTEMZ_ARCH8-NOT: #define __HTM__ 1
40674082
// CHECK_SYSTEMZ_ARCH8: #define __LONG_DOUBLE_128__ 1
40684083
// CHECK_SYSTEMZ_ARCH8: #define __s390__ 1
40694084
// CHECK_SYSTEMZ_ARCH8: #define __s390x__ 1
@@ -4080,6 +4095,7 @@
40804095
// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
40814096
// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
40824097
// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
4098+
// CHECK_SYSTEMZ_ARCH9-NOT: #define __HTM__ 1
40834099
// CHECK_SYSTEMZ_ARCH9: #define __LONG_DOUBLE_128__ 1
40844100
// CHECK_SYSTEMZ_ARCH9: #define __s390__ 1
40854101
// CHECK_SYSTEMZ_ARCH9: #define __s390x__ 1

0 commit comments

Comments
 (0)