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
131private:
132 // We compute the SDK root dir in the ctor, and use it later.
133 std::string SDKRootDir;
134};
135
136// PS4-specific Toolchain class.
137class LLVM_LIBRARY_VISIBILITY PS4CPU : public PS4PS5Base {
138public:
139 PS4CPU(const Driver &D, const llvm::Triple &Triple,
140 const llvm::opt::ArgList &Args);
141
142 unsigned GetDefaultDwarfVersion() const override { return 4; }
143
144 // PS4 toolchain uses legacy thin LTO API, which is not
145 // capable of unit splitting.
146 bool canSplitThinLTOUnit() const override { return false; }
147
148 const char *getLinkerBaseName() const override { return "ld"; }
149 std::string qualifyPSCmdName(StringRef CmdName) const override {
150 return Twine("orbis-", CmdName).str();
151 }
152 void addSanitizerArgs(const llvm::opt::ArgList &Args,
153 llvm::opt::ArgStringList &CmdArgs, const char *Prefix,
154 const char *Suffix) const override;
155 const char *getProfileRTLibName() const override {
156 return "libclang_rt.profile-x86_64.a";
157 }
158
159protected:
160 Tool *buildAssembler() const override;
161 Tool *buildLinker() const override;
162};
163
164// PS5-specific Toolchain class.
165class LLVM_LIBRARY_VISIBILITY PS5CPU : public PS4PS5Base {
166public:
167 PS5CPU(const Driver &D, const llvm::Triple &Triple,
168 const llvm::opt::ArgList &Args);
169
170 unsigned GetDefaultDwarfVersion() const override { return 5; }
171
172 SanitizerMask getSupportedSanitizers() const override;
173
174 const char *getLinkerBaseName() const override { return "lld"; }
175 std::string qualifyPSCmdName(StringRef CmdName) const override {
176 return Twine("prospero-", CmdName).str();
177 }
178 void addSanitizerArgs(const llvm::opt::ArgList &Args,
179 llvm::opt::ArgStringList &CmdArgs, const char *Prefix,
180 const char *Suffix) const override;
181 const char *getProfileRTLibName() const override {
182 return "libclang_rt.profile_nosubmission.a";
183 }
184
185protected:
186 Tool *buildAssembler() const override;
187 Tool *buildLinker() const override;
188};
189
190} // end namespace toolchains
191} // end namespace driver
192} // end namespace clang
193
194#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:155
std::string qualifyPSCmdName(StringRef CmdName) const override
Definition: PS4CPU.h:149
const char * getLinkerBaseName() const override
Definition: PS4CPU.h:148
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:146
unsigned GetDefaultDwarfVersion() const override
Definition: PS4CPU.h:142
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
const char * getLinkerBaseName() const override
Definition: PS4CPU.h:174
const char * getProfileRTLibName() const override
Definition: PS4CPU.h:181
std::string qualifyPSCmdName(StringRef CmdName) const override
Definition: PS4CPU.h:175
unsigned GetDefaultDwarfVersion() const override
Definition: PS4CPU.h:170
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.