1 //===--- PS4CPU.h - PS4CPU ToolChain Implementations ------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H
13 #include "clang/Basic/LangOptions.h"
14 #include "clang/Driver/Tool.h"
15 #include "clang/Driver/ToolChain.h"
22 // Functions/classes in this namespace support both PS4 and PS5.
24 void addProfileRTArgs(const ToolChain
&TC
, const llvm::opt::ArgList
&Args
,
25 llvm::opt::ArgStringList
&CmdArgs
);
27 void addSanitizerArgs(const ToolChain
&TC
, const llvm::opt::ArgList
&Args
,
28 llvm::opt::ArgStringList
&CmdArgs
);
30 class LLVM_LIBRARY_VISIBILITY Assembler final
: public Tool
{
32 Assembler(const ToolChain
&TC
) : Tool("PScpu::Assembler", "assembler", TC
) {}
34 bool hasIntegratedCPP() const override
{ return false; }
36 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
37 const InputInfo
&Output
, const InputInfoList
&Inputs
,
38 const llvm::opt::ArgList
&TCArgs
,
39 const char *LinkingOutput
) const override
;
44 class LLVM_LIBRARY_VISIBILITY Linker final
: public Tool
{
46 Linker(const ToolChain
&TC
) : Tool("PS4cpu::Linker", "linker", TC
) {}
48 bool hasIntegratedCPP() const override
{ return false; }
49 bool isLinkJob() const override
{ return true; }
51 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
52 const InputInfo
&Output
, const InputInfoList
&Inputs
,
53 const llvm::opt::ArgList
&TCArgs
,
54 const char *LinkingOutput
) const override
;
59 class LLVM_LIBRARY_VISIBILITY Linker final
: public Tool
{
61 Linker(const ToolChain
&TC
) : Tool("PS5cpu::Linker", "linker", TC
) {}
63 bool hasIntegratedCPP() const override
{ return false; }
64 bool isLinkJob() const override
{ return true; }
66 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
67 const InputInfo
&Output
, const InputInfoList
&Inputs
,
68 const llvm::opt::ArgList
&TCArgs
,
69 const char *LinkingOutput
) const override
;
75 namespace toolchains
{
77 // Common Toolchain base class for PS4 and PS5.
78 class LLVM_LIBRARY_VISIBILITY PS4PS5Base
: public Generic_ELF
{
80 PS4PS5Base(const Driver
&D
, const llvm::Triple
&Triple
,
81 const llvm::opt::ArgList
&Args
, StringRef Platform
,
85 AddClangSystemIncludeArgs(const llvm::opt::ArgList
&DriverArgs
,
86 llvm::opt::ArgStringList
&CC1Args
) const override
;
87 // No support for finding a C++ standard library yet.
88 void addLibCxxIncludePaths(const llvm::opt::ArgList
&DriverArgs
,
89 llvm::opt::ArgStringList
&CC1Args
) const override
{
92 addLibStdCxxIncludePaths(const llvm::opt::ArgList
&DriverArgs
,
93 llvm::opt::ArgStringList
&CC1Args
) const override
{}
95 bool IsMathErrnoDefault() const override
{ return false; }
96 bool IsObjCNonFragileABIDefault() const override
{ return true; }
97 bool HasNativeLLVMSupport() const override
{ return true; }
98 bool isPICDefault() const override
{ return true; }
100 LangOptions::StackProtectorMode
101 GetDefaultStackProtectorLevel(bool KernelOrKext
) const override
{
102 return LangOptions::SSPStrong
;
105 llvm::DebuggerKind
getDefaultDebuggerTuning() const override
{
106 return llvm::DebuggerKind::SCE
;
109 SanitizerMask
getSupportedSanitizers() const override
;
111 void addClangTargetOptions(
112 const llvm::opt::ArgList
&DriverArgs
, llvm::opt::ArgStringList
&CC1Args
,
113 Action::OffloadKind DeviceOffloadingKind
) const override
;
115 llvm::DenormalMode
getDefaultDenormalModeForType(
116 const llvm::opt::ArgList
&DriverArgs
, const JobAction
&JA
,
117 const llvm::fltSemantics
*FPType
) const override
{
118 // DAZ and FTZ are on by default.
119 return llvm::DenormalMode::getPreserveSign();
122 // Helper methods for PS4/PS5.
123 virtual const char *getLinkerBaseName() const = 0;
124 virtual std::string
qualifyPSCmdName(StringRef CmdName
) const = 0;
125 virtual void addSanitizerArgs(const llvm::opt::ArgList
&Args
,
126 llvm::opt::ArgStringList
&CmdArgs
,
128 const char *Suffix
) const = 0;
129 virtual const char *getProfileRTLibName() const = 0;
131 StringRef
getSDKLibraryRootDir() const { return SDKLibraryRootDir
; }
134 // We compute the SDK locations in the ctor, and use them later.
135 std::string SDKHeaderRootDir
;
136 std::string SDKLibraryRootDir
;
139 // PS4-specific Toolchain class.
140 class LLVM_LIBRARY_VISIBILITY PS4CPU
: public PS4PS5Base
{
142 PS4CPU(const Driver
&D
, const llvm::Triple
&Triple
,
143 const llvm::opt::ArgList
&Args
);
145 unsigned GetDefaultDwarfVersion() const override
{ return 4; }
147 // PS4 toolchain uses legacy thin LTO API, which is not
148 // capable of unit splitting.
149 bool canSplitThinLTOUnit() const override
{ return false; }
151 const char *getLinkerBaseName() const override
{ return "ld"; }
152 std::string
qualifyPSCmdName(StringRef CmdName
) const override
{
153 return Twine("orbis-", CmdName
).str();
155 void addSanitizerArgs(const llvm::opt::ArgList
&Args
,
156 llvm::opt::ArgStringList
&CmdArgs
, const char *Prefix
,
157 const char *Suffix
) const override
;
158 const char *getProfileRTLibName() const override
{
159 return "libclang_rt.profile-x86_64.a";
163 Tool
*buildAssembler() const override
;
164 Tool
*buildLinker() const override
;
167 // PS5-specific Toolchain class.
168 class LLVM_LIBRARY_VISIBILITY PS5CPU
: public PS4PS5Base
{
170 PS5CPU(const Driver
&D
, const llvm::Triple
&Triple
,
171 const llvm::opt::ArgList
&Args
);
173 unsigned GetDefaultDwarfVersion() const override
{ return 5; }
175 SanitizerMask
getSupportedSanitizers() const override
;
177 const char *getLinkerBaseName() const override
{ return "lld"; }
178 std::string
qualifyPSCmdName(StringRef CmdName
) const override
{
179 return Twine("prospero-", CmdName
).str();
181 void addSanitizerArgs(const llvm::opt::ArgList
&Args
,
182 llvm::opt::ArgStringList
&CmdArgs
, const char *Prefix
,
183 const char *Suffix
) const override
;
184 const char *getProfileRTLibName() const override
{
185 return "libclang_rt.profile_nosubmission.a";
189 Tool
*buildAssembler() const override
;
190 Tool
*buildLinker() const override
;
193 } // end namespace toolchains
194 } // end namespace driver
195 } // end namespace clang
197 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H