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
: 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
;
42 class LLVM_LIBRARY_VISIBILITY Linker
: public Tool
{
44 Linker(const ToolChain
&TC
) : Tool("PScpu::Linker", "linker", TC
) {}
46 bool hasIntegratedCPP() const override
{ return false; }
47 bool isLinkJob() const override
{ return true; }
49 void ConstructJob(Compilation
&C
, const JobAction
&JA
,
50 const InputInfo
&Output
, const InputInfoList
&Inputs
,
51 const llvm::opt::ArgList
&TCArgs
,
52 const char *LinkingOutput
) const override
;
57 namespace toolchains
{
59 // Common Toolchain base class for PS4 and PS5.
60 class LLVM_LIBRARY_VISIBILITY PS4PS5Base
: public Generic_ELF
{
62 PS4PS5Base(const Driver
&D
, const llvm::Triple
&Triple
,
63 const llvm::opt::ArgList
&Args
, StringRef Platform
,
66 // No support for finding a C++ standard library yet.
67 void addLibCxxIncludePaths(const llvm::opt::ArgList
&DriverArgs
,
68 llvm::opt::ArgStringList
&CC1Args
) const override
{
71 addLibStdCxxIncludePaths(const llvm::opt::ArgList
&DriverArgs
,
72 llvm::opt::ArgStringList
&CC1Args
) const override
{}
74 bool IsMathErrnoDefault() const override
{ return false; }
75 bool IsObjCNonFragileABIDefault() const override
{ return true; }
76 bool HasNativeLLVMSupport() const override
{ return true; }
77 bool isPICDefault() const override
{ return true; }
79 LangOptions::StackProtectorMode
80 GetDefaultStackProtectorLevel(bool KernelOrKext
) const override
{
81 return LangOptions::SSPStrong
;
84 llvm::DebuggerKind
getDefaultDebuggerTuning() const override
{
85 return llvm::DebuggerKind::SCE
;
88 SanitizerMask
getSupportedSanitizers() const override
;
90 void addClangTargetOptions(
91 const llvm::opt::ArgList
&DriverArgs
, llvm::opt::ArgStringList
&CC1Args
,
92 Action::OffloadKind DeviceOffloadingKind
) const override
;
94 llvm::DenormalMode
getDefaultDenormalModeForType(
95 const llvm::opt::ArgList
&DriverArgs
, const JobAction
&JA
,
96 const llvm::fltSemantics
*FPType
) const override
{
97 // DAZ and FTZ are on by default.
98 return llvm::DenormalMode::getPreserveSign();
101 bool useRelaxRelocations() const override
{ return true; }
103 // Helper methods for PS4/PS5.
104 virtual const char *getLinkerBaseName() const = 0;
105 virtual std::string
qualifyPSCmdName(StringRef CmdName
) const = 0;
106 virtual void addSanitizerArgs(const llvm::opt::ArgList
&Args
,
107 llvm::opt::ArgStringList
&CmdArgs
,
109 const char *Suffix
) const = 0;
110 virtual const char *getProfileRTLibName() const = 0;
113 Tool
*buildLinker() const override
;
116 // PS4-specific Toolchain class.
117 class LLVM_LIBRARY_VISIBILITY PS4CPU
: public PS4PS5Base
{
119 PS4CPU(const Driver
&D
, const llvm::Triple
&Triple
,
120 const llvm::opt::ArgList
&Args
);
122 unsigned GetDefaultDwarfVersion() const override
{ return 4; }
124 // PS4 toolchain uses legacy thin LTO API, which is not
125 // capable of unit splitting.
126 bool canSplitThinLTOUnit() const override
{ return false; }
128 const char *getLinkerBaseName() const override
{ return "ld"; }
129 std::string
qualifyPSCmdName(StringRef CmdName
) const override
{
130 return Twine("orbis-", CmdName
).str();
132 void addSanitizerArgs(const llvm::opt::ArgList
&Args
,
133 llvm::opt::ArgStringList
&CmdArgs
, const char *Prefix
,
134 const char *Suffix
) const override
;
135 const char *getProfileRTLibName() const override
{
136 return "libclang_rt.profile-x86_64.a";
140 Tool
*buildAssembler() const override
;
143 // PS5-specific Toolchain class.
144 class LLVM_LIBRARY_VISIBILITY PS5CPU
: public PS4PS5Base
{
146 PS5CPU(const Driver
&D
, const llvm::Triple
&Triple
,
147 const llvm::opt::ArgList
&Args
);
149 unsigned GetDefaultDwarfVersion() const override
{ return 5; }
151 SanitizerMask
getSupportedSanitizers() const override
;
153 const char *getLinkerBaseName() const override
{ return "lld"; }
154 std::string
qualifyPSCmdName(StringRef CmdName
) const override
{
155 return Twine("prospero-", CmdName
).str();
157 void addSanitizerArgs(const llvm::opt::ArgList
&Args
,
158 llvm::opt::ArgStringList
&CmdArgs
, const char *Prefix
,
159 const char *Suffix
) const override
;
160 const char *getProfileRTLibName() const override
{
161 return "libclang_rt.profile-x86_64_nosubmission.a";
165 Tool
*buildAssembler() const override
;
168 } // end namespace toolchains
169 } // end namespace driver
170 } // end namespace clang
172 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H