clang  16.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"
15 #include "clang/Driver/ToolChain.h"
16 
17 namespace clang {
18 namespace driver {
19 namespace tools {
20 
21 namespace PScpu {
22 // Functions/classes in this namespace support both PS4 and PS5.
23 
24 void addProfileRTArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
25  llvm::opt::ArgStringList &CmdArgs);
26 
27 void addSanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
28  llvm::opt::ArgStringList &CmdArgs);
29 
30 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
31 public:
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 
42 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
43 public:
44  Linker(const ToolChain &TC) : Tool("PScpu::Linker", "linker", TC) {}
45 
46  bool hasIntegratedCPP() const override { return false; }
47  bool isLinkJob() const override { return true; }
48 
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;
53 };
54 } // namespace PScpu
55 } // namespace tools
56 
57 namespace toolchains {
58 
59 // Common Toolchain base class for PS4 and PS5.
60 class LLVM_LIBRARY_VISIBILITY PS4PS5Base : public Generic_ELF {
61 public:
62  PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
63  const llvm::opt::ArgList &Args, StringRef Platform,
64  const char *EnvVar);
65 
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 {
69  }
70  void
71  addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
72  llvm::opt::ArgStringList &CC1Args) const override {}
73 
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; }
78 
80  GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
82  }
83 
84  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
85  return llvm::DebuggerKind::SCE;
86  }
87 
88  SanitizerMask getSupportedSanitizers() const override;
89 
90  void addClangTargetOptions(
91  const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
92  Action::OffloadKind DeviceOffloadingKind) const override;
93 
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();
99  }
100 
101  bool useRelaxRelocations() const override { return true; }
102 
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,
108  const char *Prefix,
109  const char *Suffix) const = 0;
110  virtual const char *getProfileRTLibName() const = 0;
111 
112 protected:
113  Tool *buildLinker() const override;
114 };
115 
116 // PS4-specific Toolchain class.
117 class LLVM_LIBRARY_VISIBILITY PS4CPU : public PS4PS5Base {
118 public:
119  PS4CPU(const Driver &D, const llvm::Triple &Triple,
120  const llvm::opt::ArgList &Args);
121 
122  unsigned GetDefaultDwarfVersion() const override { return 4; }
123 
124  // PS4 toolchain uses legacy thin LTO API, which is not
125  // capable of unit splitting.
126  bool canSplitThinLTOUnit() const override { return false; }
127 
128  const char *getLinkerBaseName() const override { return "ld"; }
129  std::string qualifyPSCmdName(StringRef CmdName) const override {
130  return Twine("orbis-", CmdName).str();
131  }
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";
137  }
138 
139 protected:
140  Tool *buildAssembler() const override;
141 };
142 
143 // PS5-specific Toolchain class.
144 class LLVM_LIBRARY_VISIBILITY PS5CPU : public PS4PS5Base {
145 public:
146  PS5CPU(const Driver &D, const llvm::Triple &Triple,
147  const llvm::opt::ArgList &Args);
148 
149  unsigned GetDefaultDwarfVersion() const override { return 5; }
150 
151  SanitizerMask getSupportedSanitizers() const override;
152 
153  const char *getLinkerBaseName() const override { return "lld"; }
154  std::string qualifyPSCmdName(StringRef CmdName) const override {
155  return Twine("prospero-", CmdName).str();
156  }
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";
162  }
163 
164 protected:
165  Tool *buildAssembler() const override;
166 };
167 
168 } // end namespace toolchains
169 } // end namespace driver
170 } // end namespace clang
171 
172 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_PS4CPU_H
clang::driver::toolchains::PS4PS5Base::getDefaultDebuggerTuning
llvm::DebuggerKind getDefaultDebuggerTuning() const override
Definition: PS4CPU.h:84
clang::driver::toolchains::PS4PS5Base::getDefaultDenormalModeForType
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:94
clang::driver::toolchains::PS5CPU::qualifyPSCmdName
std::string qualifyPSCmdName(StringRef CmdName) const override
Definition: PS4CPU.h:154
clang::LangOptions::StackProtectorMode
StackProtectorMode
Definition: LangOptions.h:87
clang::driver::tools::PScpu::Linker::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: PS4CPU.h:46
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::toolchains::PS4PS5Base::useRelaxRelocations
bool useRelaxRelocations() const override
Check whether to enable x86 relax relocations by default.
Definition: PS4CPU.h:101
clang::LangOptions::SSPStrong
@ SSPStrong
Definition: LangOptions.h:87
clang::driver::tools::PScpu::Assembler::Assembler
Assembler(const ToolChain &TC)
Definition: PS4CPU.h:32
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::toolchains::PS4PS5Base::IsObjCNonFragileABIDefault
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: PS4CPU.h:75
clang::driver::tools::PScpu::Linker
Definition: PS4CPU.h:42
clang::driver::tools::PScpu::Linker::Linker
Linker(const ToolChain &TC)
Definition: PS4CPU.h:44
clang::driver::toolchains::PS4PS5Base::addLibCxxIncludePaths
void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition: PS4CPU.h:67
clang::driver::toolchains::PS4CPU::getLinkerBaseName
const char * getLinkerBaseName() const override
Definition: PS4CPU.h:128
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::toolchains::PS4PS5Base
Definition: PS4CPU.h:60
clang::driver::toolchains::PS4CPU::canSplitThinLTOUnit
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:126
clang::driver::tools::PScpu::Assembler::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: PS4CPU.h:34
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::toolchains::Generic_ELF
Definition: Gnu.h:363
clang::driver::toolchains::PS5CPU::getLinkerBaseName
const char * getLinkerBaseName() const override
Definition: PS4CPU.h:153
clang::driver::toolchains::PS4CPU::qualifyPSCmdName
std::string qualifyPSCmdName(StringRef CmdName) const override
Definition: PS4CPU.h:129
LangOptions.h
Tool.h
clang::driver::toolchains::PS4PS5Base::IsMathErrnoDefault
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: PS4CPU.h:74
clang::driver::tools::PScpu::Assembler
Definition: PS4CPU.h:30
clang::driver::tools::PScpu::addProfileRTArgs
void addProfileRTArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
ToolChain.h
clang::driver::toolchains::PS4PS5Base::GetDefaultStackProtectorLevel
LangOptions::StackProtectorMode GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain.
Definition: PS4CPU.h:80
clang::driver::toolchains::PS4PS5Base::addLibStdCxxIncludePaths
void addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition: PS4CPU.h:71
Gnu.h
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::toolchains::PS4CPU::GetDefaultDwarfVersion
unsigned GetDefaultDwarfVersion() const override
Definition: PS4CPU.h:122
clang::driver::toolchains::PS4CPU::getProfileRTLibName
const char * getProfileRTLibName() const override
Definition: PS4CPU.h:135
clang::driver::tools::PScpu::addSanitizerArgs
void addSanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
clang::driver::toolchains::PS4PS5Base::HasNativeLLVMSupport
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: PS4CPU.h:76
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::toolchains::PS4CPU
Definition: PS4CPU.h:117
clang::driver::tools::PScpu::Linker::isLinkJob
bool isLinkJob() const override
Definition: PS4CPU.h:47
clang::driver::toolchains::PS5CPU
Definition: PS4CPU.h:144
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:75
clang::driver::toolchains::PS4PS5Base::isPICDefault
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: PS4CPU.h:77
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:86
clang::driver::JobAction
Definition: Action.h:398
clang::SanitizerMask
Definition: Sanitizers.h:30
clang::driver::toolchains::PS5CPU::getProfileRTLibName
const char * getProfileRTLibName() const override
Definition: PS4CPU.h:160
clang::driver::toolchains::PS5CPU::GetDefaultDwarfVersion
unsigned GetDefaultDwarfVersion() const override
Definition: PS4CPU.h:149