clang  14.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 "clang/Basic/Cuda.h"
13 #include "clang/Basic/TargetID.h"
15 #include "clang/Driver/Driver.h"
17 #include "clang/Driver/InputInfo.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  bool IsThinLTO = D.getLTOMode(/*IsOffload=*/true) == LTOK_Thin;
53  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0], IsThinLTO);
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  // ToDo: Remove this option after AMDGPU backend supports ISA-level linking.
70  // Since AMDGPU backend currently does not support ISA-level linking, all
71  // called functions need to be imported.
72  if (IsThinLTO)
73  LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all"));
74 
75  for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
76  LldArgs.push_back(
77  Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
78  }
79 
80  if (C.getDriver().isSaveTempsEnabled())
81  LldArgs.push_back("-save-temps");
82 
83  addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
84 
85  LldArgs.append({"-o", Output.getFilename()});
86  for (auto Input : Inputs)
87  LldArgs.push_back(Input.getFilename());
88 
89  if (Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
90  false))
91  llvm::for_each(TC.getHIPDeviceLibs(Args), [&](auto BCFile) {
92  LldArgs.push_back(Args.MakeArgString(BCFile.Path));
93  });
94 
95  const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
96  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
97  Lld, LldArgs, Inputs, Output));
98 }
99 
100 // Construct a clang-offload-bundler command to bundle code objects for
101 // different GPU's into a HIP fat binary.
103  StringRef OutputFileName, const InputInfoList &Inputs,
104  const llvm::opt::ArgList &Args, const Tool& T) {
105  // Construct clang-offload-bundler command to bundle object files for
106  // for different GPU archs.
107  ArgStringList BundlerArgs;
108  BundlerArgs.push_back(Args.MakeArgString("-type=o"));
109  BundlerArgs.push_back(
110  Args.MakeArgString("-bundle-align=" + Twine(HIPCodeObjectAlign)));
111 
112  // ToDo: Remove the dummy host binary entry which is required by
113  // clang-offload-bundler.
114  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
115  std::string BundlerInputArg = "-inputs=" NULL_FILE;
116 
117  // For code object version 2 and 3, the offload kind in bundle ID is 'hip'
118  // for backward compatibility. For code object version 4 and greater, the
119  // offload kind in bundle ID is 'hipv4'.
120  std::string OffloadKind = "hip";
121  if (getAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
122  OffloadKind = OffloadKind + "v4";
123  for (const auto &II : Inputs) {
124  const auto* A = II.getAction();
125  BundlerTargetArg = BundlerTargetArg + "," + OffloadKind +
126  "-amdgcn-amd-amdhsa--" +
127  StringRef(A->getOffloadingArch()).str();
128  BundlerInputArg = BundlerInputArg + "," + II.getFilename();
129  }
130  BundlerArgs.push_back(Args.MakeArgString(BundlerTargetArg));
131  BundlerArgs.push_back(Args.MakeArgString(BundlerInputArg));
132 
133  std::string Output = std::string(OutputFileName);
134  auto BundlerOutputArg =
135  Args.MakeArgString(std::string("-outputs=").append(Output));
136  BundlerArgs.push_back(BundlerOutputArg);
137 
138  const char *Bundler = Args.MakeArgString(
139  T.getToolChain().GetProgramPath("clang-offload-bundler"));
140  C.addCommand(std::make_unique<Command>(
141  JA, T, ResponseFileSupport::None(), Bundler, BundlerArgs, Inputs,
142  InputInfo(&JA, Args.MakeArgString(Output))));
143 }
144 
145 /// Add Generated HIP Object File which has device images embedded into the
146 /// host to the argument list for linking. Using MC directives, embed the
147 /// device code and also define symbols required by the code generation so that
148 /// the image can be retrieved at runtime.
149 void AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary(
150  Compilation &C, const InputInfo &Output,
151  const InputInfoList &Inputs, const ArgList &Args,
152  const JobAction &JA) const {
153  const ToolChain &TC = getToolChain();
154  std::string Name =
155  std::string(llvm::sys::path::stem(Output.getFilename()));
156 
157  // Create Temp Object File Generator,
158  // Offload Bundled file and Bundled Object file.
159  // Keep them if save-temps is enabled.
160  const char *McinFile;
161  const char *BundleFile;
162  if (C.getDriver().isSaveTempsEnabled()) {
163  McinFile = C.getArgs().MakeArgString(Name + ".mcin");
164  BundleFile = C.getArgs().MakeArgString(Name + ".hipfb");
165  } else {
166  auto TmpNameMcin = C.getDriver().GetTemporaryPath(Name, "mcin");
167  McinFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameMcin));
168  auto TmpNameFb = C.getDriver().GetTemporaryPath(Name, "hipfb");
169  BundleFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameFb));
170  }
171  constructHIPFatbinCommand(C, JA, BundleFile, Inputs, Args, *this);
172 
173  // Create a buffer to write the contents of the temp obj generator.
174  std::string ObjBuffer;
175  llvm::raw_string_ostream ObjStream(ObjBuffer);
176 
177  // Add MC directives to embed target binaries. We ensure that each
178  // section and image is 16-byte aligned. This is not mandatory, but
179  // increases the likelihood of data to be aligned with a cache block
180  // in several main host machines.
181  ObjStream << "# HIP Object Generator\n";
182  ObjStream << "# *** Automatically generated by Clang ***\n";
183  ObjStream << " .protected __hip_fatbin\n";
184  ObjStream << " .type __hip_fatbin,@object\n";
185  ObjStream << " .section .hip_fatbin,\"a\",@progbits\n";
186  ObjStream << " .globl __hip_fatbin\n";
187  ObjStream << " .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign))
188  << "\n";
189  ObjStream << "__hip_fatbin:\n";
190  ObjStream << " .incbin \"" << BundleFile << "\"\n";
191  ObjStream.flush();
192 
193  // Dump the contents of the temp object file gen if the user requested that.
194  // We support this option to enable testing of behavior with -###.
195  if (C.getArgs().hasArg(options::OPT_fhip_dump_offload_linker_script))
196  llvm::errs() << ObjBuffer;
197 
198  // Open script file and write the contents.
199  std::error_code EC;
200  llvm::raw_fd_ostream Objf(McinFile, EC, llvm::sys::fs::OF_None);
201 
202  if (EC) {
203  C.getDriver().Diag(clang::diag::err_unable_to_make_temp) << EC.message();
204  return;
205  }
206 
207  Objf << ObjBuffer;
208 
209  ArgStringList McArgs{"-o", Output.getFilename(),
210  McinFile, "--filetype=obj"};
211  const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
212  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
213  Mc, McArgs, Inputs, Output));
214 }
215 
216 // For amdgcn the inputs of the linker job are device bitcode and output is
217 // object file. It calls llvm-link, opt, llc, then lld steps.
218 void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA,
219  const InputInfo &Output,
220  const InputInfoList &Inputs,
221  const ArgList &Args,
222  const char *LinkingOutput) const {
223  if (Inputs.size() > 0 &&
224  Inputs[0].getType() == types::TY_Image &&
225  JA.getType() == types::TY_Object)
226  return constructGenerateObjFileFromHIPFatBinary(C, Output, Inputs, Args, JA);
227 
228  if (JA.getType() == types::TY_HIP_FATBIN)
229  return constructHIPFatbinCommand(C, JA, Output.getFilename(), Inputs, Args, *this);
230 
231  return constructLldCommand(C, JA, Inputs, Output, Args);
232 }
233 
234 HIPToolChain::HIPToolChain(const Driver &D, const llvm::Triple &Triple,
235  const ToolChain &HostTC, const ArgList &Args)
236  : ROCMToolChain(D, Triple, Args), HostTC(HostTC) {
237  // Lookup binaries into the driver directory, this is used to
238  // discover the clang-offload-bundler executable.
239  getProgramPaths().push_back(getDriver().Dir);
240 }
241 
243  const llvm::opt::ArgList &DriverArgs,
244  llvm::opt::ArgStringList &CC1Args,
245  Action::OffloadKind DeviceOffloadingKind) const {
246  HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);
247 
248  assert(DeviceOffloadingKind == Action::OFK_HIP &&
249  "Only HIP offloading kinds are supported for GPUs.");
250 
251  CC1Args.push_back("-fcuda-is-device");
252 
253  if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
254  options::OPT_fno_cuda_approx_transcendentals, false))
255  CC1Args.push_back("-fcuda-approx-transcendentals");
256 
257  if (!DriverArgs.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
258  false))
259  CC1Args.append({"-mllvm", "-amdgpu-internalize-symbols"});
260 
261  StringRef MaxThreadsPerBlock =
262  DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
263  if (!MaxThreadsPerBlock.empty()) {
264  std::string ArgStr =
265  std::string("--gpu-max-threads-per-block=") + MaxThreadsPerBlock.str();
266  CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
267  }
268 
269  CC1Args.push_back("-fcuda-allow-variadic-functions");
270 
271  // Default to "hidden" visibility, as object level linking will not be
272  // supported for the foreseeable future.
273  if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
274  options::OPT_fvisibility_ms_compat)) {
275  CC1Args.append({"-fvisibility", "hidden"});
276  CC1Args.push_back("-fapply-global-visibility-to-externs");
277  }
278 
279  llvm::for_each(getHIPDeviceLibs(DriverArgs), [&](auto BCFile) {
280  CC1Args.push_back(BCFile.ShouldInternalize ? "-mlink-builtin-bitcode"
281  : "-mlink-bitcode-file");
282  CC1Args.push_back(DriverArgs.MakeArgString(BCFile.Path));
283  });
284 }
285 
286 llvm::opt::DerivedArgList *
287 HIPToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
288  StringRef BoundArch,
289  Action::OffloadKind DeviceOffloadKind) const {
290  DerivedArgList *DAL =
291  HostTC.TranslateArgs(Args, BoundArch, DeviceOffloadKind);
292  if (!DAL)
293  DAL = new DerivedArgList(Args.getBaseArgs());
294 
295  const OptTable &Opts = getDriver().getOpts();
296 
297  for (Arg *A : Args) {
298  if (!shouldSkipArgument(A))
299  DAL->append(A);
300  }
301 
302  if (!BoundArch.empty()) {
303  DAL->eraseArg(options::OPT_mcpu_EQ);
304  DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_mcpu_EQ), BoundArch);
305  checkTargetID(*DAL);
306  }
307 
308  return DAL;
309 }
310 
312  assert(getTriple().getArch() == llvm::Triple::amdgcn);
313  return new tools::AMDGCN::Linker(*this);
314 }
315 
316 void HIPToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {
318 }
319 
321 HIPToolChain::GetCXXStdlibType(const ArgList &Args) const {
322  return HostTC.GetCXXStdlibType(Args);
323 }
324 
325 void HIPToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
326  ArgStringList &CC1Args) const {
327  HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
328 }
329 
331  ArgStringList &CC1Args) const {
332  HostTC.AddClangCXXStdlibIncludeArgs(Args, CC1Args);
333 }
334 
335 void HIPToolChain::AddIAMCUIncludeArgs(const ArgList &Args,
336  ArgStringList &CC1Args) const {
337  HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
338 }
339 
340 void HIPToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
341  ArgStringList &CC1Args) const {
342  RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
343 }
344 
346  // The HIPToolChain only supports sanitizers in the sense that it allows
347  // sanitizer arguments on the command line if they are supported by the host
348  // toolchain. The HIPToolChain will actually ignore any command line
349  // arguments for any of these "supported" sanitizers. That means that no
350  // sanitization of device code is actually supported at this time.
351  //
352  // This behavior is necessary because the host and device toolchains
353  // invocations often share the command line, so the device toolchain must
354  // tolerate flags meant only for the host toolchain.
356 }
357 
359  const ArgList &Args) const {
360  return HostTC.computeMSVCVersion(D, Args);
361 }
362 
364 HIPToolChain::getHIPDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
366  if (DriverArgs.hasArg(options::OPT_nogpulib))
367  return {};
368  ArgStringList LibraryPaths;
369 
370  // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
371  for (auto Path : RocmInstallation.getRocmDeviceLibPathArg())
372  LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
373 
374  addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
375 
376  // Maintain compatability with --hip-device-lib.
377  auto BCLibArgs = DriverArgs.getAllArgValues(options::OPT_hip_device_lib_EQ);
378  if (!BCLibArgs.empty()) {
379  llvm::for_each(BCLibArgs, [&](StringRef BCName) {
380  StringRef FullName;
381  for (std::string LibraryPath : LibraryPaths) {
382  SmallString<128> Path(LibraryPath);
383  llvm::sys::path::append(Path, BCName);
384  FullName = Path;
385  if (llvm::sys::fs::exists(FullName)) {
386  BCLibs.push_back(FullName);
387  return;
388  }
389  }
390  getDriver().Diag(diag::err_drv_no_such_file) << BCName;
391  });
392  } else {
394  getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
395  return {};
396  }
397  StringRef GpuArch = getGPUArch(DriverArgs);
398  assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
399 
400  // If --hip-device-lib is not set, add the default bitcode libraries.
401  if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
402  options::OPT_fno_gpu_sanitize, false)) {
403  auto AsanRTL = RocmInstallation.getAsanRTLPath();
404  if (AsanRTL.empty()) {
405  unsigned DiagID = getDriver().getDiags().getCustomDiagID(
407  "AMDGPU address sanitizer runtime library (asanrtl) is not found. "
408  "Please install ROCm device library which supports address "
409  "sanitizer");
410  getDriver().Diag(DiagID);
411  return {};
412  } else
413  BCLibs.push_back({AsanRTL.str(), /*ShouldInternalize=*/false});
414  }
415 
416  // Add the HIP specific bitcode library.
417  BCLibs.push_back(RocmInstallation.getHIPPath());
418 
419  // Add common device libraries like ocml etc.
420  for (auto N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
421  BCLibs.push_back(StringRef(N));
422 
423  // Add instrument lib.
424  auto InstLib =
425  DriverArgs.getLastArgValue(options::OPT_gpu_instrument_lib_EQ);
426  if (InstLib.empty())
427  return BCLibs;
428  if (llvm::sys::fs::exists(InstLib))
429  BCLibs.push_back(InstLib);
430  else
431  getDriver().Diag(diag::err_drv_no_such_file) << InstLib;
432  }
433 
434  return BCLibs;
435 }
436 
437 void HIPToolChain::checkTargetID(const llvm::opt::ArgList &DriverArgs) const {
438  auto PTID = getParsedTargetID(DriverArgs);
439  if (PTID.OptionalTargetID && !PTID.OptionalGPUArch) {
440  getDriver().Diag(clang::diag::err_drv_bad_target_id)
441  << PTID.OptionalTargetID.getValue();
442  return;
443  }
444 
445  assert(PTID.OptionalFeatures && "Invalid return from getParsedTargetID");
446  auto &FeatureMap = PTID.OptionalFeatures.getValue();
447  // Sanitizer is not supported with xnack-.
448  if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
449  options::OPT_fno_gpu_sanitize, false)) {
450  auto Loc = FeatureMap.find("xnack");
451  if (Loc != FeatureMap.end() && !Loc->second) {
452  auto &Diags = getDriver().getDiags();
453  auto DiagID = Diags.getCustomDiagID(
455  "'-fgpu-sanitize' is not compatible with offload arch '%0'. "
456  "Use an offload arch without 'xnack-' instead");
457  Diags.Report(DiagID) << PTID.OptionalTargetID.getValue();
458  }
459  }
460 }
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:709
clang::driver::toolchains::AMDGPUToolChain::getParsedTargetID
ParsedTargetIDType getParsedTargetID(const llvm::opt::ArgList &DriverArgs) const
Get target ID, GPU arch, and target ID features if the target ID is specified and valid.
Definition: AMDGPU.cpp:715
clang::driver::toolchains::AMDGPUToolChain::shouldSkipArgument
bool shouldSkipArgument(const llvm::opt::Arg *Arg) const
Should skip argument.
Definition: AMDGPU.cpp:890
clang::driver::RocmInstallationDetector::AddHIPIncludeArgs
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition: AMDGPU.cpp:479
clang::driver::toolchains::HIPToolChain::buildLinker
Tool * buildLinker() const override
Definition: HIP.cpp:311
clang::driver::RocmInstallationDetector::getAsanRTLPath
StringRef getAsanRTLPath() const
Returns empty string of Asan runtime library is not available.
Definition: ROCm.h:195
clang::driver::ToolChain::getProgramPaths
path_list & getProgramPaths()
Definition: ToolChain.h:262
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:1051
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:102
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::ToolChain::GetProgramPath
std::string GetProgramPath(const char *Name) const
Definition: ToolChain.cpp:542
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:907
clang::driver::tools
Definition: AIX.h:17
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:221
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:335
clang::driver::toolchains::HIPToolChain::checkTargetID
void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override
Check and diagnose invalid target ID specified by -mcpu.
Definition: HIP.cpp:437
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:747
NULL_FILE
#define NULL_FILE
Definition: HIP.cpp:33
clang::driver::Driver::getOpts
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:325
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:327
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:358
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:112
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::getHIPDeviceLibs
llvm::SmallVector< BitCodeLibraryInfo, 12 > getHIPDeviceLibs(const llvm::opt::ArgList &Args) const override
Get paths of HIP device libraries.
Definition: HIP.cpp:364
clang::driver::toolchains::HIPToolChain::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: HIP.cpp:345
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:287
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:738
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:242
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
llvm::SmallString< 128 >
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:223
TargetID.h
AMDGPU.h
clang::driver::tools::getAMDGPUCodeObjectVersion
unsigned getAMDGPUCodeObjectVersion(const Driver &D, const llvm::opt::ArgList &Args)
Definition: CommonArgs.cpp:1913
clang::driver::RocmInstallationDetector::hasDeviceLibrary
bool hasDeviceLibrary() const
Check whether we detected a valid ROCm device library.
Definition: ROCm.h:151
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:237
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:325
clang::driver::RocmInstallationDetector::getHIPPath
StringRef getHIPPath() const
Definition: ROCm.h:189
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:234
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:147
clang::driver::toolchains::ROCMToolChain::getCommonDeviceLibNames
llvm::SmallVector< std::string, 12 > getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs, const std::string &GPUArch) const
Definition: AMDGPU.cpp:898
clang::driver::ToolChain::getSupportedSanitizers
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:998
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:330
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:321
clang::driver::ToolChain::GetCXXStdlibType
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:819
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:1034
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:536
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:866
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:316
CommonArgs.h
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:59
clang::driver::toolchains::HIPToolChain::HostTC
const ToolChain & HostTC
Definition: HIP.h:97
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:306
clang::driver::toolchains::ROCMToolChain
Definition: AMDGPU.h:131
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:340
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:229
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:743
clang::driver::tools::addLinkerCompressDebugSectionsOption
void addLinkerCompressDebugSectionsOption(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
Definition: CommonArgs.cpp:285
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:78
clang::driver::JobAction
Definition: Action.h:380
clang::driver::tools::AMDGCN::Linker
Definition: HIP.h:29
clang::SanitizerMask
Definition: Sanitizers.h:30