Author: Paul Robinson Date: 2022-06-01T13:30:29-07:00 New Revision: 5d005d8256ecd7d57c72e24e7169c4e3d40a773a
URL: https://github.com/llvm/llvm-project/commit/5d005d8256ecd7d57c72e24e7169c4e3d40a773a DIFF: https://github.com/llvm/llvm-project/commit/5d005d8256ecd7d57c72e24e7169c4e3d40a773a.diff LOG: Refactor PS4OSTargetInfo into a base class and PS4 subclass; prep for PS5 Added: Modified: clang/lib/Basic/Targets/OSTargets.h Removed: ################################################################################ diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index e9832977c7fe8..cf317f58540e3 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -541,8 +541,9 @@ class LLVM_LIBRARY_VISIBILITY PS3PPUTargetInfo : public OSTargetInfo<Target> { } }; +// Common base class for PS4/PS5 targets. template <typename Target> -class LLVM_LIBRARY_VISIBILITY PS4OSTargetInfo : public OSTargetInfo<Target> { +class LLVM_LIBRARY_VISIBILITY PSOSTargetInfo : public OSTargetInfo<Target> { protected: void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override { @@ -552,36 +553,49 @@ class LLVM_LIBRARY_VISIBILITY PS4OSTargetInfo : public OSTargetInfo<Target> { DefineStd(Builder, "unix", Opts); Builder.defineMacro("__ELF__"); Builder.defineMacro("__SCE__"); - Builder.defineMacro("__ORBIS__"); } public: - PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + PSOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { this->WCharType = TargetInfo::UnsignedShort; - // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits). + // On PS4/PS5, TLS variable cannot be aligned to more than 32 bytes (256 + // bits). this->MaxTLSAlign = 256; - // On PS4, do not honor explicit bit field alignment, + // On PS4/PS5, do not honor explicit bit field alignment, // as in "__attribute__((aligned(2))) int b : 1;". this->UseExplicitBitFieldAlignment = false; - switch (Triple.getArch()) { - default: - case llvm::Triple::x86_64: - this->MCountName = ".mcount"; - this->NewAlign = 256; - this->SuitableAlign = 256; - break; - } + this->MCountName = ".mcount"; + this->NewAlign = 256; + this->SuitableAlign = 256; } + TargetInfo::CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error; } }; +// PS4 Target +template <typename Target> +class LLVM_LIBRARY_VISIBILITY PS4OSTargetInfo : public PSOSTargetInfo<Target> { +protected: + void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, + MacroBuilder &Builder) const override { + // Start with base class defines. + PSOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder); + + Builder.defineMacro("__ORBIS__"); + } + +public: + PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) + : PSOSTargetInfo<Target>(Triple, Opts) {} +}; + // RTEMS Target template <typename Target> class LLVM_LIBRARY_VISIBILITY RTEMSTargetInfo : public OSTargetInfo<Target> { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits