clang  13.0.0git
HIP.cpp
Go to the documentation of this file.
1 //===--- HIP.cpp - HIP Tool and 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 #include "HIP.h"
10 #include "AMDGPU.h"
11 #include "CommonArgs.h"
12 #include "InputInfo.h"
13 #include "clang/Basic/Cuda.h"
14 #include "clang/Basic/TargetID.h"
16 #include "clang/Driver/Driver.h"
18 #include "clang/Driver/Options.h"
19 #include "llvm/Support/Alignment.h"
20 #include "llvm/Support/FileSystem.h"
21 #include "llvm/Support/Path.h"
22 #include "llvm/Support/TargetParser.h"
23 
24 using namespace clang::driver;
25 using namespace clang::driver::toolchains;
26 using namespace clang::driver::tools;
27 using namespace clang;
28 using namespace llvm::opt;
29 
30 #if defined(_WIN32) || defined(_WIN64)
31 #define NULL_FILE "nul"
32 #else
33 #define NULL_FILE "/dev/null"
34 #endif
35 
36 namespace {
37 const unsigned HIPCodeObjectAlign = 4096;
38 } // namespace
39 
40 void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
41  const InputInfoList &Inputs,
42  const InputInfo &Output,
43  const llvm::opt::ArgList &Args) const {
44  // Construct lld command.
45  // The output from ld.lld is an HSA code object file.
46  ArgStringList LldArgs{"-flavor", "gnu", "--no-undefined", "-shared",
47  "-plugin-opt=-amdgpu-internalize-symbols"};
48 
49  auto &TC = getToolChain();
50  auto &D = TC.getDriver();
51  assert(!Inputs.empty() && "Must have at least one input.");
52  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0],
53  D.getLTOMode() == LTOK_Thin);
54 
55  // Extract all the -m options
56  std::vector<llvm::StringRef> Features;
57  amdgpu::getAMDGPUTargetFeatures(D, TC.getTriple(), Args, Features);
58 
59  // Add features to mattr such as cumode
60  std::string MAttrString = "-plugin-opt=-mattr=";
61  for (auto OneFeature : unifyTargetFeatures(Features)) {
62  MAttrString.append(Args.MakeArgString(OneFeature));
63  if (OneFeature != Features.back())
64  MAttrString.append(",");
65  }
66  if (!Features.empty())
67  LldArgs.push_back(Args.MakeArgString(MAttrString));
68 
69  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
70  LldArgs.push_back(
71  Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
72  }
73 
74  if (C.getDriver().isSaveTempsEnabled())
75  LldArgs.push_back("-save-temps");
76 
77  addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
78 
79  LldArgs.append({"-o", Output.getFilename()});
80  for (auto Input : Inputs)
81  LldArgs.push_back(Input.getFilename());
82 
83  if (Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
84  false))
85  llvm::for_each(TC.getHIPDeviceLibs(Args), [&](StringRef BCFile) {
86  LldArgs.push_back(Args.MakeArgString(BCFile));
87  });
88 
89  const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
90  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
91  Lld, LldArgs, Inputs, Output));
92 }
93 
94 // Construct a clang-offload-bundler command to bundle code objects for
95 // different GPU's into a HIP fat binary.
97  StringRef OutputFileName, const InputInfoList &Inputs,
98  const llvm::opt::ArgList &Args, const Tool& T) {
99  // Construct clang-offload-bundler command to bundle object files for
100  // for different GPU archs.
101  ArgStringList BundlerArgs;
102  BundlerArgs.push_back(Args.MakeArgString("-type=o"));
103  BundlerArgs.push_back(
104  Args.MakeArgString("-bundle-align=" + Twine(HIPCodeObjectAlign)));
105 
106  // ToDo: Remove the dummy host binary entry which is required by
107  // clang-offload-bundler.
108  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
109  std::string BundlerInputArg = "-inputs=" NULL_FILE;
110 
111  // For code object version 2 and 3, the offload kind in bundle ID is 'hip'
112  // for backward compatibility. For code object version 4 and greater, the
113  // offload kind in bundle ID is 'hipv4'.
114  std::string OffloadKind = "hip";
115  if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
116  OffloadKind = OffloadKind + "v4";
117  for (const auto &II : Inputs) {
118  const auto* A = II.getAction();
119  BundlerTargetArg = BundlerTargetArg + "," + OffloadKind +
120  "-amdgcn-amd-amdhsa--" +
121  StringRef(A->getOffloadingArch()).str();
122  BundlerInputArg = BundlerInputArg + "," + II.getFilename();
123  }
124  BundlerArgs.push_back(Args.MakeArgString(BundlerTargetArg));
125  BundlerArgs.push_back(Args.MakeArgString(BundlerInputArg));
126 
127  std::string Output = std::string(OutputFileName);
128  auto BundlerOutputArg =
129  Args.MakeArgString(std::string("-outputs=").append(Output));
130  BundlerArgs.push_back(BundlerOutputArg);
131 
132  const char *Bundler = Args.MakeArgString(
133  T.getToolChain().GetProgramPath("clang-offload-bundler"));
134  C.addCommand(std::make_unique<Command>(
135  JA, T, ResponseFileSupport::None(), Bundler, BundlerArgs, Inputs,
136  InputInfo(&JA, Args.MakeArgString(Output))));
137 }
138 
139 /// Add Generated HIP Object File which has device images embedded into the
140 /// host to the argument list for linking. Using MC directives, embed the
141 /// device code and also define symbols required by the code generation so that
142 /// the image can be retrieved at runtime.
143 void AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary(
144  Compilation &C, const InputInfo &Output,
145  const InputInfoList &Inputs, const ArgList &Args,
146  const JobAction &JA) const {
147  const ToolChain &TC = getToolChain();
148  std::string Name =
149  std::string(llvm::sys::path::stem(Output.getFilename()));
150 
151  // Create Temp Object File Generator,
152  // Offload Bundled file and Bundled Object file.
153  // Keep them if save-temps is enabled.
154  const char *McinFile;
155  const char *BundleFile;
156  if (C.getDriver().isSaveTempsEnabled()) {
157  McinFile = C.getArgs().MakeArgString(Name + ".mcin");
158  BundleFile = C.getArgs().MakeArgString(Name + ".hipfb");
159  } else {
160  auto TmpNameMcin = C.getDriver().GetTemporaryPath(Name, "mcin");
161  McinFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameMcin));
162  auto TmpNameFb = C.getDriver().GetTemporaryPath(Name, "hipfb");
163  BundleFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameFb));
164  }
165  constructHIPFatbinCommand(C, JA, BundleFile, Inputs, Args, *this);
166 
167  // Create a buffer to write the contents of the temp obj generator.
168  std::string ObjBuffer;
169  llvm::raw_string_ostream ObjStream(ObjBuffer);
170 
171  // Add MC directives to embed target binaries. We ensure that each
172  // section and image is 16-byte aligned. This is not mandatory, but
173  // increases the likelihood of data to be aligned with a cache block
174  // in several main host machines.
175  ObjStream << "# HIP Object Generator\n";
176  ObjStream << "# *** Automatically generated by Clang ***\n";
177  ObjStream << " .type __hip_fatbin,@object\n";
178  ObjStream << " .section .hip_fatbin,\"a\",@progbits\n";
179  ObjStream << " .globl __hip_fatbin\n";
180  ObjStream << " .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign))
181  << "\n";
182  ObjStream << "__hip_fatbin:\n";
183  ObjStream << " .incbin \"" << BundleFile << "\"\n";
184  ObjStream.flush();
185 
186  // Dump the contents of the temp object file gen if the user requested that.
187  // We support this option to enable testing of behavior with -###.
188  if (C.getArgs().hasArg(options::OPT_fhip_dump_offload_linker_script))
189  llvm::errs() << ObjBuffer;
190 
191  // Open script file and write the contents.
192  std::error_code EC;
193  llvm::raw_fd_ostream Objf(McinFile, EC, llvm::sys::fs::OF_None);
194 
195  if (EC) {
196  C.getDriver().Diag(clang::diag::err_unable_to_make_temp) << EC.message();
197  return;
198  }
199 
200  Objf << ObjBuffer;
201 
202  ArgStringList McArgs{"-o", Output.getFilename(),
203  McinFile, "--filetype=obj"};
204  const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
205  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
206  Mc, McArgs, Inputs, Output));
207 }
208 
209 // For amdgcn the inputs of the linker job are device bitcode and output is
210 // object file. It calls llvm-link, opt, llc, then lld steps.
211 void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA,
212  const InputInfo &Output,
213  const InputInfoList &Inputs,
214  const ArgList &Args,
215  const char *LinkingOutput) const {
216  if (Inputs.size() > 0 &&
217  Inputs[0].getType() == types::TY_Image &&
218  JA.getType() == types::TY_Object)
219  return constructGenerateObjFileFromHIPFatBinary(C, Output, Inputs, Args, JA);
220 
221  if (JA.getType() == types::TY_HIP_FATBIN)
222  return constructHIPFatbinCommand(C, JA, Output.getFilename(), Inputs, Args, *this);
223 
224  return constructLldCommand(C, JA, Inputs, Output, Args);
225 }
226 
227 HIPToolChain::HIPToolChain(const Driver &D, const llvm::Triple &Triple,
228  const ToolChain &HostTC, const ArgList &Args)
229  : ROCMToolChain(D, Triple, Args), HostTC(HostTC) {
230  // Lookup binaries into the driver directory, this is used to
231  // discover the clang-offload-bundler executable.
232  getProgramPaths().push_back(getDriver().Dir);
233 }
234 
236  const llvm::opt::ArgList &DriverArgs,
237  llvm::opt::ArgStringList &CC1Args,
238  Action::OffloadKind DeviceOffloadingKind) const {
239  HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);
240 
241  assert(DeviceOffloadingKind == Action::OFK_HIP &&
242  "Only HIP offloading kinds are supported for GPUs.");
243 
244  CC1Args.push_back("-fcuda-is-device");
245 
246  if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
247  options::OPT_fno_cuda_approx_transcendentals, false))
248  CC1Args.push_back("-fcuda-approx-transcendentals");
249 
250  if (!DriverArgs.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
251  false))
252  CC1Args.append({"-mllvm", "-amdgpu-internalize-symbols"});
253 
254  StringRef MaxThreadsPerBlock =
255  DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
256  if (!MaxThreadsPerBlock.empty()) {
257  std::string ArgStr =
258  std::string("--gpu-max-threads-per-block=") + MaxThreadsPerBlock.str();
259  CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
260  }
261 
262  CC1Args.push_back("-fcuda-allow-variadic-functions");
263 
264  // Default to "hidden" visibility, as object level linking will not be
265  // supported for the foreseeable future.
266  if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
267  options::OPT_fvisibility_ms_compat)) {
268  CC1Args.append({"-fvisibility", "hidden"});
269  CC1Args.push_back("-fapply-global-visibility-to-externs");
270  }
271 
272  llvm::for_each(getHIPDeviceLibs(DriverArgs), [&](StringRef BCFile) {
273  CC1Args.push_back("-mlink-builtin-bitcode");
274  CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
275  });
276 }
277 
278 llvm::opt::DerivedArgList *
279 HIPToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
280  StringRef BoundArch,
281  Action::OffloadKind DeviceOffloadKind) const {
282  DerivedArgList *DAL =
283  HostTC.TranslateArgs(Args, BoundArch, DeviceOffloadKind);
284  if (!DAL)
285  DAL = new DerivedArgList(Args.getBaseArgs());
286 
287  const OptTable &Opts = getDriver().getOpts();
288 
289  for (Arg *A : Args) {
290  if (!shouldSkipArgument(A))
291  DAL->append(A);
292  }
293 
294  if (!BoundArch.empty()) {
295  DAL->eraseArg(options::OPT_mcpu_EQ);
296  DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_mcpu_EQ), BoundArch);
297  checkTargetID(*DAL);
298  }
299 
300  return DAL;
301 }
302 
304  assert(getTriple().getArch() == llvm::Triple::amdgcn);
305  return new tools::AMDGCN::Linker(*this);
306 }
307 
308 void HIPToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {
310 }
311 
313 HIPToolChain::GetCXXStdlibType(const ArgList &Args) const {
314  return HostTC.GetCXXStdlibType(Args);
315 }
316 
317 void HIPToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
318  ArgStringList &CC1Args) const {
319  HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
320 }
321 
323  ArgStringList &CC1Args) const {
324  HostTC.AddClangCXXStdlibIncludeArgs(Args, CC1Args);
325 }
326 
327 void HIPToolChain::AddIAMCUIncludeArgs(const ArgList &Args,
328  ArgStringList &CC1Args) const {
329  HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
330 }
331 
332 void HIPToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
333  ArgStringList &CC1Args) const {
334  RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
335 }
336 
338  // The HIPToolChain only supports sanitizers in the sense that it allows
339  // sanitizer arguments on the command line if they are supported by the host
340  // toolchain. The HIPToolChain will actually ignore any command line
341  // arguments for any of these "supported" sanitizers. That means that no
342  // sanitization of device code is actually supported at this time.
343  //
344  // This behavior is necessary because the host and device toolchains
345  // invocations often share the command line, so the device toolchain must
346  // tolerate flags meant only for the host toolchain.
348 }
349 
351  const ArgList &Args) const {
352  return HostTC.computeMSVCVersion(D, Args);
353 }
354 
356 HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
358  if (DriverArgs.hasArg(options::OPT_nogpulib))
359  return {};
360  ArgStringList LibraryPaths;
361 
362  // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
363  for (auto Path : RocmInstallation.getRocmDeviceLibPathArg())
364  LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
365 
366  addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
367 
368  // Maintain compatability with --hip-device-lib.
369  auto BCLibArgs = DriverArgs.getAllArgValues(options::OPT_hip_device_lib_EQ);
370  if (!BCLibArgs.empty()) {
371  llvm::for_each(BCLibArgs, [&](StringRef BCName) {
372  StringRef FullName;
373  for (std::string LibraryPath : LibraryPaths) {
374  SmallString<128> Path(LibraryPath);
375  llvm::sys::path::append(Path, BCName);
376  FullName = Path;
377  if (llvm::sys::fs::exists(FullName)) {
378  BCLibs.push_back(FullName.str());
379  return;
380  }
381  }
382  getDriver().Diag(diag::err_drv_no_such_file) << BCName;
383  });
384  } else {
386  getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
387  return {};
388  }
389  StringRef GpuArch = getGPUArch(DriverArgs);
390  assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
391  (void)GpuArch;
392  auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
393  const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
394 
395  std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
396  if (LibDeviceFile.empty()) {
397  getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GpuArch;
398  return {};
399  }
400 
401  // If --hip-device-lib is not set, add the default bitcode libraries.
402  // TODO: There are way too many flags that change this. Do we need to check
403  // them all?
404  bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
405  options::OPT_fno_gpu_flush_denormals_to_zero,
407  // TODO: Check standard C++ flags?
408  bool FiniteOnly = false;
409  bool UnsafeMathOpt = false;
410  bool FastRelaxedMath = false;
411  bool CorrectSqrt = true;
412  bool Wave64 = isWave64(DriverArgs, Kind);
413 
414  if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
415  options::OPT_fno_gpu_sanitize, false)) {
416  auto AsanRTL = RocmInstallation.getAsanRTLPath();
417  if (AsanRTL.empty()) {
418  unsigned DiagID = getDriver().getDiags().getCustomDiagID(
420  "AMDGPU address sanitizer runtime library (asanrtl) is not found. "
421  "Please install ROCm device library which supports address "
422  "sanitizer");
423  getDriver().Diag(DiagID);
424  return {};
425  } else
426  BCLibs.push_back(AsanRTL.str());
427  }
428 
429  // Add the HIP specific bitcode library.
430  BCLibs.push_back(RocmInstallation.getHIPPath().str());
431 
432  // Add the generic set of libraries.
434  DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
435  FastRelaxedMath, CorrectSqrt));
436 
437  // Add instrument lib.
438  auto InstLib =
439  DriverArgs.getLastArgValue(options::OPT_gpu_instrument_lib_EQ);
440  if (InstLib.empty())
441  return BCLibs;
442  if (llvm::sys::fs::exists(InstLib))
443  BCLibs.push_back(InstLib.str());
444  else
445  getDriver().Diag(diag::err_drv_no_such_file) << InstLib;
446  }
447 
448  return BCLibs;
449 }
clang::driver::toolchains
Definition: AIX.h:55
clang::driver::toolchains::AMDGPUToolChain::getGPUArch
StringRef getGPUArch(const llvm::opt::ArgList &DriverArgs) const
Get GPU arch from -mcpu without checking.
Definition: AMDGPU.cpp:700
clang::driver::toolchains::AMDGPUToolChain::shouldSkipArgument
bool shouldSkipArgument(const llvm::opt::Arg *Arg) const
Should skip argument.
Definition: AMDGPU.cpp:799
clang::driver::RocmInstallationDetector::AddHIPIncludeArgs
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition: AMDGPU.cpp:470
clang::driver::toolchains::HIPToolChain::buildLinker
Tool * buildLinker() const override
Definition: HIP.cpp:303
clang::driver::RocmInstallationDetector::getAsanRTLPath
StringRef getAsanRTLPath() const
Returns empty string of Asan runtime library is not available.
Definition: ROCm.h:194
clang::driver::ToolChain::getProgramPaths
path_list & getProgramPaths()
Definition: ToolChain.h:255
Driver.h
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::ToolChain::computeMSVCVersion
virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const
On Windows, returns the MSVC compatibility version.
Definition: ToolChain.cpp:1068
clang::driver::tools::AMDGCN::constructHIPFatbinCommand
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
Definition: HIP.cpp:96
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::tools::getOrCheckAMDGPUCodeObjectVersion
unsigned getOrCheckAMDGPUCodeObjectVersion(const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose=false)
Definition: CommonArgs.cpp:1576
clang::driver::ToolChain::GetProgramPath
std::string GetProgramPath(const char *Name) const
Definition: ToolChain.cpp:561
HIP.h
clang::driver::ToolChain::AddClangCXXStdlibIncludeArgs
virtual void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: ToolChain.cpp:924
clang::driver::tools
Definition: AIX.h:17
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:52
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:214
clang::driver::Action::OFK_HIP
@ OFK_HIP
Definition: Action.h:94
clang::driver::toolchains::HIPToolChain::AddIAMCUIncludeArgs
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use MCU GCC toolchain includes.
Definition: HIP.cpp:327
clang::driver::ToolChain::addClangWarningOptions
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const
Add warning options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:764
NULL_FILE
#define NULL_FILE
Definition: HIP.cpp:33
clang::driver::Driver::getOpts
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:322
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::Driver::getDiags
DiagnosticsEngine & getDiags() const
Definition: Driver.h:324
InputInfo.h
clang::driver::toolchains::HIPToolChain::computeMSVCVersion
VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const override
On Windows, returns the MSVC compatibility version.
Definition: HIP.cpp:350
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:109
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
Options.h
clang::driver::Action::getType
types::ID getType() const
Definition: Action.h:143
clang::driver::LTOK_Thin
@ LTOK_Thin
Definition: Driver.h:53
clang::driver::toolchains::HIPToolChain::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: HIP.cpp:337
llvm::opt
Definition: DiagnosticOptions.h:19
DriverDiagnostic.h
clang::driver::toolchains::HIPToolChain::TranslateArgs
llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind) const override
TranslateArgs - Create a new derived argument list for any argument translations this ToolChain may w...
Definition: HIP.cpp:279
clang::DiagnosticsEngine::Error
@ Error
Definition: Diagnostic.h:199
clang::driver::ToolChain::AddClangSystemIncludeArgs
virtual void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add the clang cc1 arguments for system include paths.
Definition: ToolChain.cpp:755
clang::driver::toolchains::HIPToolChain::addClangTargetOptions
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition: HIP.cpp:235
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
clang::driver::toolchains::AMDGPUToolChain::isWave64
static bool isWave64(const llvm::opt::ArgList &DriverArgs, llvm::AMDGPU::GPUKind Kind)
Definition: AMDGPU.cpp:668
llvm::SmallString< 128 >
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:216
TargetID.h
AMDGPU.h
clang::driver::RocmInstallationDetector::hasDeviceLibrary
bool hasDeviceLibrary() const
Check whether we detected a valid ROCm device library.
Definition: ROCm.h:150
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:230
clang::driver::toolchains::HIPToolChain::AddClangSystemIncludeArgs
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition: HIP.cpp:317
clang::driver::RocmInstallationDetector::getHIPPath
StringRef getHIPPath() const
Definition: ROCm.h:188
clang::driver::tools::addLTOOptions
void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, const InputInfo &Input, bool IsThinLTO)
clang::driver::toolchains::Generic_GCC::RocmInstallation
RocmInstallationDetector RocmInstallation
Definition: Gnu.h:290
clang::driver::toolchains::HIPToolChain::HIPToolChain
HIPToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const llvm::opt::ArgList &Args)
Definition: HIP.cpp:227
clang::driver::tools::unifyTargetFeatures
std::vector< StringRef > unifyTargetFeatures(const std::vector< StringRef > &Features)
If there are multiple +xxx or -xxx features, keep the last one.
Definition: CommonArgs.cpp:146
clang::driver::ToolChain::getSupportedSanitizers
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1015
Compilation.h
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::toolchains::HIPToolChain::AddClangCXXStdlibIncludeArgs
void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1Args) const override
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: HIP.cpp:322
clang::driver::RocmInstallationDetector::getCommonBitcodeLibs
llvm::SmallVector< std::string, 12 > getCommonBitcodeLibs(const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile, bool Wave64, bool DAZ, bool FiniteOnly, bool UnsafeMathOpt, bool FastRelaxedMath, bool CorrectSqrt) const
Get file paths of default bitcode libraries common to AMDGPU based toolchains.
Definition: AMDGPU.cpp:778
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::toolchains::HIPToolChain::GetCXXStdlibType
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: HIP.cpp:313
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::driver::ToolChain::GetCXXStdlibType
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:836
clang::driver::Tool::getToolChain
const ToolChain & getToolChain() const
Definition: Tool.h:52
clang::driver::ToolChain::AddIAMCUIncludeArgs
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use MCU GCC toolchain includes.
Definition: ToolChain.cpp:1051
clang::driver::tools::amdgpu::getAMDGPUTargetFeatures
void getAMDGPUTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, std::vector< StringRef > &Features)
Definition: AMDGPU.cpp:527
Cuda.h
clang::driver::InputInfo::getFilename
const char * getFilename() const
Definition: InputInfo.h:83
clang::DiagnosticsEngine::getCustomDiagID
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:863
clang::driver::toolchains::HIPToolChain::addClangWarningOptions
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override
Add warning options that need to be passed to cc1 for this target.
Definition: HIP.cpp:308
clang::driver::RocmInstallationDetector::getLibDeviceFile
std::string getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
Definition: ROCm.h:217
CommonArgs.h
clang
Dataflow Directional Tag Classes.
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:59
clang::driver::toolchains::HIPToolChain::HostTC
const ToolChain & HostTC
Definition: HIP.h:97
clang::driver::toolchains::AMDGPUToolChain::checkTargetID
void checkTargetID(const llvm::opt::ArgList &DriverArgs) const
Check and diagnose invalid target ID specified by -mcpu.
Definition: AMDGPU.cpp:705
clang::driver::ToolChain::TranslateArgs
virtual llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind) const
TranslateArgs - Create a new derived argument list for any argument translations this ToolChain may w...
Definition: ToolChain.h:299
clang::driver::toolchains::ROCMToolChain
Definition: AMDGPU.h:111
clang::driver::toolchains::HIPToolChain::AddHIPIncludeArgs
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition: HIP.cpp:332
clang::driver::tools::addDirectoryList
void addDirectoryList(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const char *ArgName, const char *EnvVar)
EnvVar is split by system delimiter for environment variables.
clang::driver::RocmInstallationDetector::getRocmDeviceLibPathArg
std::vector< std::string > getRocmDeviceLibPathArg() const
Get the values for –rocm-device-lib-path arguments.
Definition: ROCm.h:228
clang::driver::ToolChain::addClangTargetOptions
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const
Add options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:760
clang::driver::tools::addLinkerCompressDebugSectionsOption
void addLinkerCompressDebugSectionsOption(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
Definition: CommonArgs.cpp:275
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:85
clang::driver
Definition: Action.h:31
clang::driver::ResponseFileSupport::None
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
Definition: Job.h:77
clang::driver::toolchains::HIPToolChain::getHIPDeviceLibs
llvm::SmallVector< std::string, 12 > getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override
Get paths of HIP device libraries.
Definition: HIP.cpp:356
clang::driver::JobAction
Definition: Action.h:380
clang::driver::tools::AMDGCN::Linker
Definition: HIP.h:29
clang::SanitizerMask
Definition: Sanitizers.h:30
clang::driver::toolchains::AMDGPUToolChain::getDefaultDenormsAreZeroForTarget
static bool getDefaultDenormsAreZeroForTarget(llvm::AMDGPU::GPUKind GPUKind)
Return whether denormals should be flushed, and treated as 0 by default for the subtarget.
Definition: AMDGPU.cpp:617