[PATCH] D87624: [SystemZ][z/OS] Set default wchar_t type for zOS
Abhina Sree via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 14 11:49:58 PDT 2020
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: abdulras, uweigand, hubert.reinterpretcast, fanbo-meng, Kai, ro, zibi, SeanP.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abhina.sreeskantharajan requested review of this revision.
Set the default wchar_t type on z/OS, and unsigned as the default.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87624
Files:
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/wchar-size.c
clang/test/Lexer/wchar-signedness.c
clang/test/Preprocessor/wchar_t.c
clang/test/Sema/wchar.c
Index: clang/test/Sema/wchar.c
===================================================================
--- clang/test/Sema/wchar.c
+++ clang/test/Sema/wchar.c
@@ -6,7 +6,7 @@
#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
|| defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR)
#define WCHAR_T_TYPE unsigned short
-#elif defined(__arm) || defined(__aarch64__)
+#elif defined(__arm) || defined(__aarch64__) || defined(__MVS__)
#define WCHAR_T_TYPE unsigned int
#elif defined(__sun)
#if defined(__LP64__)
Index: clang/test/Preprocessor/wchar_t.c
===================================================================
--- clang/test/Preprocessor/wchar_t.c
+++ clang/test/Preprocessor/wchar_t.c
@@ -48,6 +48,11 @@
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
+// RUN: %clang_cc1 -triple s390x-none-zos -fwchar-type=int -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// CHECK-ZOS: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ZOS: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+
// RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
// CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
// CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
Index: clang/test/Lexer/wchar-signedness.c
===================================================================
--- clang/test/Lexer/wchar-signedness.c
+++ clang/test/Lexer/wchar-signedness.c
@@ -1,9 +1,13 @@
// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-X86
// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple s390x-none-zos | FileCheck %s --check-prefix=CHECK-ZOS
// CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
// CHECK-X86: #define __WINT_UNSIGNED__ 1
// CHECK-ARM: #define __WCHAR_UNSIGNED__ 1
// CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1
+
+// CHECK-ZOS: #define __WCHAR_UNSIGNED__ 1
+// CHECK-ZOS-NOT: #define __WINT_UNSIGNED__ 1
Index: clang/test/CodeGen/wchar-size.c
===================================================================
--- clang/test/CodeGen/wchar-size.c
+++ clang/test/CodeGen/wchar-size.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=LONG-WCHAR
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | FileCheck %s -check-prefix=SHORT-WCHAR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - -fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple s390x-none-zos -emit-llvm -o - %s | FileCheck %s -check-prefix=LONG-WCHAR
// Note: -fno-short-wchar implies the target default is used; so there is no
// need to test this separately here.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3408,8 +3408,8 @@
} else {
bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
CmdArgs.push_back("-fwchar-type=int");
- if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
- T.isOSOpenBSD()))
+ if (T.isOSzOS() ||
+ (IsARM && !(T.isOSWindows() || T.isOSNetBSD() || T.isOSOpenBSD())))
CmdArgs.push_back("-fno-signed-wchar");
else
CmdArgs.push_back("-fsigned-wchar");
Index: clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -774,7 +774,9 @@
public:
ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
- : OSTargetInfo<Target>(Triple, Opts) {}
+ : OSTargetInfo<Target>(Triple, Opts) {
+ this->WCharType = TargetInfo::UnsignedInt;
+ }
};
void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87624.291633.patch
Type: text/x-patch
Size: 4287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200914/dea94eb2/attachment.bin>
More information about the cfe-commits
mailing list