clang 20.0.0git
PS4CPU.h
Go to the documentation of this file.
1//===--- PS4CPU.h - PS4CPU ToolChain Implementations ------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H
11
12#include "Gnu.h"
14#include "clang/Driver/Tool.h"
16
17namespace clang {
18namespace driver {
19namespace tools {
20
21namespace PScpu {
22// Functions/classes in this namespace support both PS4 and PS5.
23
24void addProfileRTArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
25 llvm::opt::ArgStringList &CmdArgs);
26
27void addSanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
28 llvm::opt::ArgStringList &CmdArgs);
29
30class LLVM_LIBRARY_VISIBILITY Assembler final : public Tool {
31public:
32 Assembler(const ToolChain &TC) : Tool("PScpu::Assembler", "assembler", TC) {}
33
34 bool hasIntegratedCPP() const override { return false; }
35
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;
40};
41} // namespace PScpu
42
43namespace PS4cpu {
44class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
45public:
46 Linker(const ToolChain &TC) : Tool("PS4cpu::Linker", "linker", TC) {}
47
48 bool hasIntegratedCPP() const override { return false; }
49 bool isLinkJob() const override { return true; }
50
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;
55};
56} // namespace PS4cpu
57
58namespace PS5cpu {
59class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
60public:
61 Linker(const ToolChain &TC) : Tool("PS5cpu::Linker", "linker", TC) {}
62
63 bool hasIntegratedCPP() const override { return false; }
64 bool isLinkJob() const override { return true; }
65
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;
70};
71} // namespace PS5cpu
72
73} // namespace tools
74
75namespace toolchains {
76
77// Common Toolchain base class for PS4 and PS5.
78class LLVM_LIBRARY_VISIBILITY PS4PS5Base : public Generic_ELF {
79public:
80 PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
81 const llvm::opt::ArgList &Args, StringRef Platform,
82 const char *EnvVar);
83
84 void
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 {
90 }
91 void
92 addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
93 llvm::opt::ArgStringList &CC1Args) const override {}
94
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; }
99
101 GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
102 return LangOptions::SSPStrong;
103 }
104
105 llvm::DebuggerKind getDefaultDebuggerTuning() const override {
106 return llvm::DebuggerKind::SCE;
107 }
108
109 SanitizerMask getSupportedSanitizers() const override;
110
111 void addClangTargetOptions(
112 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
113 Action::OffloadKind DeviceOffloadingKind) const override;
114
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();
120 }
121
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,
127 const char *Prefix,
128 const char *Suffix) const = 0;
129 virtual const char *getProfileRTLibName() const = 0;
130
131 StringRef getSDKLibraryRootDir() const { return SDKLibraryRootDir; }
132
133private:
134 // We compute the SDK locations in the ctor, and use them later.
135 std::string SDKHeaderRootDir;
136 std::string SDKLibraryRootDir;
137};
138
139// PS4-specific Toolchain class.
140class LLVM_LIBRARY_VISIBILITY PS4CPU : public PS4PS5Base {
141public:
142 PS4CPU(const Driver &D, const llvm::Triple &Triple,
143 const llvm::opt::ArgList &Args);
144
145 unsigned GetDefaultDwarfVersion() const override { return 4; }
146
147 // PS4 toolchain uses legacy thin LTO API, which is not
148 // capable of unit splitting.
149 bool canSplitThinLTOUnit() const override { return false; }
150
151 const char *getLinkerBaseName() const override { return "ld"; }
152 std::string qualifyPSCmdName(StringRef CmdName) const override {
153 return Twine("orbis-", CmdName).str();
154 }
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";
160 }
161
162protected:
163 Tool *buildAssembler() const override;
164 Tool *buildLinker() const override;
165};
166
167// PS5-specific Toolchain class.
168class LLVM_LIBRARY_VISIBILITY PS5CPU : public PS4PS5Base {
169public:
170 PS5CPU(const Driver &D, const llvm::Triple &Triple,
171 const llvm::opt::ArgList &Args);
172
173 unsigned GetDefaultDwarfVersion() const override { return 5; }
174
175 SanitizerMask getSupportedSanitizers() const override;
176
177 const char *getLinkerBaseName() const override { return "lld"; }
178 std::string qualifyPSCmdName(StringRef CmdName) const override {
179 return Twine("prospero-", CmdName).str();
180 }
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";
186 }
187
188protected:
189 Tool *buildAssembler() const override;
190 Tool *buildLinker() const override;
191};
192
193} // end namespace toolchains
194} // end namespace driver
195} // end namespace clang
196
197#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H
const Decl * D
Defines the clang::LangOptions interface.
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
const char * getProfileRTLibName() const override
Definition: PS4CPU.h:158
std::string qualifyPSCmdName(StringRef CmdName) const override
Definition: PS4CPU.h:152
const char * getLinkerBaseName() const override
Definition: PS4CPU.h:151
bool canSplitThinLTOUnit() const override
Returns true when it's possible to split LTO unit to use whole program devirtualization and CFI santi...
Definition: PS4CPU.h:149
unsigned GetDefaultDwarfVersion() const override
Definition: PS4CPU.h:145
LangOptions::StackProtectorMode GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain.
Definition: PS4CPU.h:101
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: PS4CPU.h:95
llvm::DebuggerKind getDefaultDebuggerTuning() const override
Definition: PS4CPU.h:105
virtual void addSanitizerArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const char *Prefix, const char *Suffix) const =0
void addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition: PS4CPU.h:92
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: PS4CPU.h:96
llvm::DenormalMode getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs, const JobAction &JA, const llvm::fltSemantics *FPType) const override
Returns the output denormal handling type in the default floating point environment for the given FPT...
Definition: PS4CPU.h:115
virtual const char * getProfileRTLibName() const =0
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: PS4CPU.h:98
virtual const char * getLinkerBaseName() const =0
virtual std::string qualifyPSCmdName(StringRef CmdName) const =0
void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition: PS4CPU.h:88
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: PS4CPU.h:97
StringRef getSDKLibraryRootDir() const
Definition: PS4CPU.h:131
const char * getLinkerBaseName() const override
Definition: PS4CPU.h:177
const char * getProfileRTLibName() const override
Definition: PS4CPU.h:184
std::string qualifyPSCmdName(StringRef CmdName) const override
Definition: PS4CPU.h:178
unsigned GetDefaultDwarfVersion() const override
Definition: PS4CPU.h:173
bool hasIntegratedCPP() const override
Definition: PS4CPU.h:48
bool isLinkJob() const override
Definition: PS4CPU.h:49
Linker(const ToolChain &TC)
Definition: PS4CPU.h:46
Linker(const ToolChain &TC)
Definition: PS4CPU.h:61
bool isLinkJob() const override
Definition: PS4CPU.h:64
bool hasIntegratedCPP() const override
Definition: PS4CPU.h:63
Assembler(const ToolChain &TC)
Definition: PS4CPU.h:32
bool hasIntegratedCPP() const override
Definition: PS4CPU.h:34
void addSanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
void addProfileRTArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
The JSON file list parser is used to communicate input to InstallAPI.