abhina.sreeskantharajan updated this revision to Diff 287043. abhina.sreeskantharajan added a comment.
Thanks for reviewing. I've updated the comments and removed ISOC99_SOURCE macro. I've updated the lit test to reflect these changes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D85324/new/ https://reviews.llvm.org/D85324 Files: clang/lib/Basic/Targets.cpp clang/lib/Basic/Targets/OSTargets.h clang/test/Preprocessor/init-zos.c Index: clang/test/Preprocessor/init-zos.c =================================================================== --- /dev/null +++ clang/test/Preprocessor/init-zos.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s +// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s + +// S390X-ZOS-GNUXX:#define _EXT 1 +// S390X-ZOS:#define _LONG_LONG 1 +// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1 +// S390X-ZOS:#define _OPEN_DEFAULT 1 +// S390X-ZOS:#define _UNIX03_WITHDRAWN 1 +// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600 +// S390X-ZOS:#define __370__ 1 +// S390X-ZOS:#define __64BIT__ 1 +// S390X-ZOS:#define __BFP__ 1 +// S390X-ZOS:#define __BOOL__ 1 +// S390X-ZOS-GNUXX:#define __DLL__ 1 +// S390X-ZOS:#define __LONGNAME__ 1 +// S390X-ZOS:#define __MVS__ 1 +// S390X-ZOS:#define __THW_370__ 1 +// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1 +// S390X-ZOS:#define __TOS_390__ 1 +// S390X-ZOS:#define __TOS_MVS__ 1 +// S390X-ZOS:#define __XPLINK__ 1 +// S390X-ZOS-GNUXX:#define __wchar_t 1 Index: clang/lib/Basic/Targets/OSTargets.h =================================================================== --- clang/lib/Basic/Targets/OSTargets.h +++ clang/lib/Basic/Targets/OSTargets.h @@ -727,6 +727,55 @@ bool defaultsToAIXPowerAlignment() const override { return true; } }; +// z/OS target +template <typename Target> +class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo<Target> { +protected: + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, + MacroBuilder &Builder) const override { + // FIXME: _LONG_LONG should not be defined under -std=c89. + Builder.defineMacro("_LONG_LONG"); + Builder.defineMacro("_OPEN_DEFAULT"); + // _UNIX03_WITHDRAWN is required to build libcxx. + Builder.defineMacro("_UNIX03_WITHDRAWN"); + Builder.defineMacro("__370__"); + Builder.defineMacro("__BFP__"); + // FIXME: __BOOL__ should not be defined under -std=c89. + Builder.defineMacro("__BOOL__"); + Builder.defineMacro("__LONGNAME__"); + Builder.defineMacro("__MVS__"); + Builder.defineMacro("__THW_370__"); + Builder.defineMacro("__THW_BIG_ENDIAN__"); + Builder.defineMacro("__TOS_390__"); + Builder.defineMacro("__TOS_MVS__"); + Builder.defineMacro("__XPLINK__"); + + if (this->PointerWidth == 64) + Builder.defineMacro("__64BIT__"); + + if (Opts.CPlusPlus) { + Builder.defineMacro("__DLL__"); + // XOPEN_SOURCE=600 is required to build libcxx. + Builder.defineMacro("_XOPEN_SOURCE", "600"); + } + + if (Opts.GNUMode) { + Builder.defineMacro("_MI_BUILTIN"); + Builder.defineMacro("_EXT"); + } + + if (Opts.CPlusPlus && Opts.WChar) { + // Macro __wchar_t is defined so that the wchar_t data + // type is not declared as a typedef in system headers. + Builder.defineMacro("__wchar_t"); + } + } + +public: + ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : OSTargetInfo<Target>(Triple, Opts) {} +}; + void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts, MacroBuilder &Builder); Index: clang/lib/Basic/Targets.cpp =================================================================== --- clang/lib/Basic/Targets.cpp +++ clang/lib/Basic/Targets.cpp @@ -450,6 +450,8 @@ switch (os) { case llvm::Triple::Linux: return new LinuxTargetInfo<SystemZTargetInfo>(Triple, Opts); + case llvm::Triple::ZOS: + return new ZOSTargetInfo<SystemZTargetInfo>(Triple, Opts); default: return new SystemZTargetInfo(Triple, Opts); }
Index: clang/test/Preprocessor/init-zos.c =================================================================== --- /dev/null +++ clang/test/Preprocessor/init-zos.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s +// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-GNUXX %s + +// S390X-ZOS-GNUXX:#define _EXT 1 +// S390X-ZOS:#define _LONG_LONG 1 +// S390X-ZOS-GNUXX:#define _MI_BUILTIN 1 +// S390X-ZOS:#define _OPEN_DEFAULT 1 +// S390X-ZOS:#define _UNIX03_WITHDRAWN 1 +// S390X-ZOS-GNUXX:#define _XOPEN_SOURCE 600 +// S390X-ZOS:#define __370__ 1 +// S390X-ZOS:#define __64BIT__ 1 +// S390X-ZOS:#define __BFP__ 1 +// S390X-ZOS:#define __BOOL__ 1 +// S390X-ZOS-GNUXX:#define __DLL__ 1 +// S390X-ZOS:#define __LONGNAME__ 1 +// S390X-ZOS:#define __MVS__ 1 +// S390X-ZOS:#define __THW_370__ 1 +// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1 +// S390X-ZOS:#define __TOS_390__ 1 +// S390X-ZOS:#define __TOS_MVS__ 1 +// S390X-ZOS:#define __XPLINK__ 1 +// S390X-ZOS-GNUXX:#define __wchar_t 1 Index: clang/lib/Basic/Targets/OSTargets.h =================================================================== --- clang/lib/Basic/Targets/OSTargets.h +++ clang/lib/Basic/Targets/OSTargets.h @@ -727,6 +727,55 @@ bool defaultsToAIXPowerAlignment() const override { return true; } }; +// z/OS target +template <typename Target> +class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo<Target> { +protected: + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, + MacroBuilder &Builder) const override { + // FIXME: _LONG_LONG should not be defined under -std=c89. + Builder.defineMacro("_LONG_LONG"); + Builder.defineMacro("_OPEN_DEFAULT"); + // _UNIX03_WITHDRAWN is required to build libcxx. + Builder.defineMacro("_UNIX03_WITHDRAWN"); + Builder.defineMacro("__370__"); + Builder.defineMacro("__BFP__"); + // FIXME: __BOOL__ should not be defined under -std=c89. + Builder.defineMacro("__BOOL__"); + Builder.defineMacro("__LONGNAME__"); + Builder.defineMacro("__MVS__"); + Builder.defineMacro("__THW_370__"); + Builder.defineMacro("__THW_BIG_ENDIAN__"); + Builder.defineMacro("__TOS_390__"); + Builder.defineMacro("__TOS_MVS__"); + Builder.defineMacro("__XPLINK__"); + + if (this->PointerWidth == 64) + Builder.defineMacro("__64BIT__"); + + if (Opts.CPlusPlus) { + Builder.defineMacro("__DLL__"); + // XOPEN_SOURCE=600 is required to build libcxx. + Builder.defineMacro("_XOPEN_SOURCE", "600"); + } + + if (Opts.GNUMode) { + Builder.defineMacro("_MI_BUILTIN"); + Builder.defineMacro("_EXT"); + } + + if (Opts.CPlusPlus && Opts.WChar) { + // Macro __wchar_t is defined so that the wchar_t data + // type is not declared as a typedef in system headers. + Builder.defineMacro("__wchar_t"); + } + } + +public: + ZOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : OSTargetInfo<Target>(Triple, Opts) {} +}; + void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts, MacroBuilder &Builder); Index: clang/lib/Basic/Targets.cpp =================================================================== --- clang/lib/Basic/Targets.cpp +++ clang/lib/Basic/Targets.cpp @@ -450,6 +450,8 @@ switch (os) { case llvm::Triple::Linux: return new LinuxTargetInfo<SystemZTargetInfo>(Triple, Opts); + case llvm::Triple::ZOS: + return new ZOSTargetInfo<SystemZTargetInfo>(Triple, Opts); default: return new SystemZTargetInfo(Triple, Opts); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits