From 8869ba366268c644200784b15c4e6b8efe891397 Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Wed, 1 Jun 2022 11:02:10 -0700 Subject: [PATCH] [PS5] Add PS5OSTargetInfo class, update affected tests --- clang/lib/Basic/LangStandards.cpp | 4 ++-- clang/lib/Basic/Targets.cpp | 2 ++ clang/lib/Basic/Targets/OSTargets.h | 17 +++++++++++++++++ clang/test/Preprocessor/init.c | 9 ++++++--- clang/test/Sema/wchar.c | 4 ++-- .../Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp | 4 ++-- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index a21898d..5bacc3b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -61,8 +61,8 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified) return CLANG_DEFAULT_STD_C; - // The PS4 uses C99 as the default C standard. - if (T.isPS4()) + // The PS4 and PS5 use C99 as the default C standard. + if (T.isPS()) return LangStandard::lang_gnu99; return LangStandard::lang_gnu17; case Language::ObjC: diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 85c73ab..2d6ef99 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -592,6 +592,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, return new NaClTargetInfo(Triple, Opts); case llvm::Triple::PS4: return new PS4OSTargetInfo(Triple, Opts); + case llvm::Triple::PS5: + return new PS5OSTargetInfo(Triple, Opts); default: return new X86_64TargetInfo(Triple, Opts); } diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index cf317f5..a814f68 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -596,6 +596,23 @@ public: : PSOSTargetInfo(Triple, Opts) {} }; +// PS5 Target +template +class LLVM_LIBRARY_VISIBILITY PS5OSTargetInfo : public PSOSTargetInfo { +protected: + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, + MacroBuilder &Builder) const override { + // Start with base class defines. + PSOSTargetInfo::getOSDefines(Opts, Triple, Builder); + + Builder.defineMacro("__PROSPERO__"); + } + +public: + PS5OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : PSOSTargetInfo(Triple, Opts) {} +}; + // RTEMS Target template class LLVM_LIBRARY_VISIBILITY RTEMSTargetInfo : public OSTargetInfo { diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 07b5fb8..61324fd 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1241,7 +1241,8 @@ // TCE:#define __tce__ 1 // TCE:#define tce 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4 %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-scei-ps4 < /dev/null | FileCheck --match-full-lines --check-prefixes=PS4,PS4ONLY %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-sie-ps5 < /dev/null | FileCheck --match-full-lines --check-prefixes=PS4,PS5ONLY %s // // PS4:#define _LP64 1 // PS4:#define __BIGGEST_ALIGNMENT__ 32 @@ -1311,8 +1312,9 @@ // PS4:#define __LP64__ 1 // PS4:#define __MMX__ 1 // PS4:#define __NO_MATH_INLINES 1 -// PS4:#define __ORBIS__ 1 +// PS4ONLY:#define __ORBIS__ 1 // PS4:#define __POINTER_WIDTH__ 64 +// PS5ONLY:#define __PROSPERO__ 1 // PS4:#define __PTRDIFF_MAX__ 9223372036854775807L // PS4:#define __PTRDIFF_TYPE__ long int // PS4:#define __PTRDIFF_WIDTH__ 64 @@ -1357,7 +1359,8 @@ // PS4:#define __x86_64__ 1 // PS4:#define unix 1 // -// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < /dev/null | FileCheck --match-full-lines --check-prefix PS4-CXX %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-sie-ps5 < /dev/null | FileCheck --match-full-lines --check-prefix PS4-CXX %s // PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL // // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s diff --git a/clang/test/Sema/wchar.c b/clang/test/Sema/wchar.c index 5566207..fa32ae6 100644 --- a/clang/test/Sema/wchar.c +++ b/clang/test/Sema/wchar.c @@ -4,8 +4,8 @@ typedef __WCHAR_TYPE__ wchar_t; #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \ - || defined(_M_X64) || defined(__ORBIS__) || defined(SHORT_WCHAR) \ - || (defined(_AIX) && !defined(__64BIT__)) + || defined(_M_X64) || defined(__ORBIS__) || defined(__PROSPERO__) \ + || defined(SHORT_WCHAR) || (defined(_AIX) && !defined(__64BIT__)) #define WCHAR_T_TYPE unsigned short #elif defined(__aarch64__) // See AArch64TargetInfo constructor -- unsigned on non-darwin non-OpenBSD non-NetBSD. diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp index 4eaa163..183b0d3 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp @@ -87,8 +87,8 @@ TEST(RecursiveASTVisitor, VisitsLambdaExprAndImplicitClass) { } TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) { - if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).isPS4()) - GTEST_SKIP(); // PS4 does not support fastcall. + if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).isPS()) + GTEST_SKIP(); // PS4/PS5 do not support fastcall. LambdaExprVisitor Visitor; Visitor.ExpectMatch("", 1, 12); EXPECT_TRUE(Visitor.runOver( -- 2.7.4