clang 20.0.0git
HIPAMD.cpp
Go to the documentation of this file.
1//===--- HIPAMD.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 "HIPAMD.h"
10#include "AMDGPU.h"
11#include "CommonArgs.h"
12#include "HIPUtility.h"
13#include "SPIRV.h"
14#include "clang/Basic/Cuda.h"
17#include "clang/Driver/Driver.h"
22#include "llvm/Support/Alignment.h"
23#include "llvm/Support/FileSystem.h"
24#include "llvm/Support/Path.h"
25#include "llvm/TargetParser/TargetParser.h"
26
27using namespace clang::driver;
28using namespace clang::driver::toolchains;
29using namespace clang::driver::tools;
30using namespace clang;
31using namespace llvm::opt;
32
33#if defined(_WIN32) || defined(_WIN64)
34#define NULL_FILE "nul"
35#else
36#define NULL_FILE "/dev/null"
37#endif
38
39static bool shouldSkipSanitizeOption(const ToolChain &TC,
40 const llvm::opt::ArgList &DriverArgs,
41 StringRef TargetID,
42 const llvm::opt::Arg *A) {
43 // For actions without targetID, do nothing.
44 if (TargetID.empty())
45 return false;
46 Option O = A->getOption();
47 if (!O.matches(options::OPT_fsanitize_EQ))
48 return false;
49
50 if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
51 options::OPT_fno_gpu_sanitize, true))
52 return true;
53
54 auto &Diags = TC.getDriver().getDiags();
55
56 // For simplicity, we only allow -fsanitize=address
57 SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
58 if (K != SanitizerKind::Address)
59 return true;
60
61 llvm::StringMap<bool> FeatureMap;
62 auto OptionalGpuArch = parseTargetID(TC.getTriple(), TargetID, &FeatureMap);
63
64 assert(OptionalGpuArch && "Invalid Target ID");
65 (void)OptionalGpuArch;
66 auto Loc = FeatureMap.find("xnack");
67 if (Loc == FeatureMap.end() || !Loc->second) {
68 Diags.Report(
69 clang::diag::warn_drv_unsupported_option_for_offload_arch_req_feature)
70 << A->getAsString(DriverArgs) << TargetID << "xnack+";
71 return true;
72 }
73 return false;
74}
75
76void AMDGCN::Linker::constructLlvmLinkCommand(Compilation &C,
77 const JobAction &JA,
78 const InputInfoList &Inputs,
79 const InputInfo &Output,
80 const llvm::opt::ArgList &Args) const {
81 // Construct llvm-link command.
82 // The output from llvm-link is a bitcode file.
83 ArgStringList LlvmLinkArgs;
84
85 assert(!Inputs.empty() && "Must have at least one input.");
86
87 LlvmLinkArgs.append({"-o", Output.getFilename()});
88 for (auto Input : Inputs)
89 LlvmLinkArgs.push_back(Input.getFilename());
90
91 // Look for archive of bundled bitcode in arguments, and add temporary files
92 // for the extracted archive of bitcode to inputs.
93 auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
94 AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LlvmLinkArgs, "amdgcn",
95 TargetID, /*IsBitCodeSDL=*/true);
96
97 const char *LlvmLink =
98 Args.MakeArgString(getToolChain().GetProgramPath("llvm-link"));
99 C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
100 LlvmLink, LlvmLinkArgs, Inputs,
101 Output));
102}
103
104void AMDGCN::Linker::constructLldCommand(Compilation &C, const JobAction &JA,
105 const InputInfoList &Inputs,
106 const InputInfo &Output,
107 const llvm::opt::ArgList &Args) const {
108 // Construct lld command.
109 // The output from ld.lld is an HSA code object file.
110 ArgStringList LldArgs{"-flavor",
111 "gnu",
112 "-m",
113 "elf64_amdgpu",
114 "--no-undefined",
115 "-shared",
116 "-plugin-opt=-amdgpu-internalize-symbols"};
117 if (Args.hasArg(options::OPT_hipstdpar))
118 LldArgs.push_back("-plugin-opt=-amdgpu-enable-hipstdpar");
119
120 auto &TC = getToolChain();
121 auto &D = TC.getDriver();
122 assert(!Inputs.empty() && "Must have at least one input.");
123 bool IsThinLTO = D.getOffloadLTOMode() == LTOK_Thin;
124 addLTOOptions(TC, Args, LldArgs, Output, Inputs[0], IsThinLTO);
125
126 // Extract all the -m options
127 std::vector<llvm::StringRef> Features;
128 amdgpu::getAMDGPUTargetFeatures(D, TC.getTriple(), Args, Features);
129
130 // Add features to mattr such as cumode
131 std::string MAttrString = "-plugin-opt=-mattr=";
132 for (auto OneFeature : unifyTargetFeatures(Features)) {
133 MAttrString.append(Args.MakeArgString(OneFeature));
134 if (OneFeature != Features.back())
135 MAttrString.append(",");
136 }
137 if (!Features.empty())
138 LldArgs.push_back(Args.MakeArgString(MAttrString));
139
140 // ToDo: Remove this option after AMDGPU backend supports ISA-level linking.
141 // Since AMDGPU backend currently does not support ISA-level linking, all
142 // called functions need to be imported.
143 if (IsThinLTO)
144 LldArgs.push_back(Args.MakeArgString("-plugin-opt=-force-import-all"));
145
146 for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
147 LldArgs.push_back(
148 Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0)));
149 }
150
151 if (C.getDriver().isSaveTempsEnabled())
152 LldArgs.push_back("-save-temps");
153
154 addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
155
156 // Given that host and device linking happen in separate processes, the device
157 // linker doesn't always have the visibility as to which device symbols are
158 // needed by a program, especially for the device symbol dependencies that are
159 // introduced through the host symbol resolution.
160 // For example: host_A() (A.obj) --> host_B(B.obj) --> device_kernel_B()
161 // (B.obj) In this case, the device linker doesn't know that A.obj actually
162 // depends on the kernel functions in B.obj. When linking to static device
163 // library, the device linker may drop some of the device global symbols if
164 // they aren't referenced. As a workaround, we are adding to the
165 // --whole-archive flag such that all global symbols would be linked in.
166 LldArgs.push_back("--whole-archive");
167
168 for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker)) {
169 StringRef ArgVal = Arg->getValue(1);
170 auto SplitArg = ArgVal.split("-mllvm=");
171 if (!SplitArg.second.empty()) {
172 LldArgs.push_back(
173 Args.MakeArgString(Twine("-plugin-opt=") + SplitArg.second));
174 } else {
175 LldArgs.push_back(Args.MakeArgString(ArgVal));
176 }
177 Arg->claim();
178 }
179
180 LldArgs.append({"-o", Output.getFilename()});
181 for (auto Input : Inputs)
182 LldArgs.push_back(Input.getFilename());
183
184 // Look for archive of bundled bitcode in arguments, and add temporary files
185 // for the extracted archive of bitcode to inputs.
186 auto TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
187 AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, LldArgs, "amdgcn",
188 TargetID, /*IsBitCodeSDL=*/true);
189
190 LldArgs.push_back("--no-whole-archive");
191
192 const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
193 C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
194 Lld, LldArgs, Inputs, Output));
195}
196
197// For SPIR-V the inputs for the job are device AMDGCN SPIR-V flavoured bitcode
198// and the output is either a compiled SPIR-V binary or bitcode (-emit-llvm). It
199// calls llvm-link and then the llvm-spirv translator. Once the SPIR-V BE will
200// be promoted from experimental, we will switch to using that. TODO: consider
201// if we want to run any targeted optimisations over IR here, over generic
202// SPIR-V.
203void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
204 Compilation &C, const JobAction &JA, const InputInfoList &Inputs,
205 const InputInfo &Output, const llvm::opt::ArgList &Args) const {
206 assert(!Inputs.empty() && "Must have at least one input.");
207
208 constructLlvmLinkCommand(C, JA, Inputs, Output, Args);
209
210 // Linked BC is now in Output
211
212 // Emit SPIR-V binary.
213 llvm::opt::ArgStringList TrArgs{
214 "--spirv-max-version=1.6",
215 "--spirv-ext=+all",
216 "--spirv-allow-extra-diexpressions",
217 "--spirv-allow-unknown-intrinsics",
218 "--spirv-lower-const-expr",
219 "--spirv-preserve-auxdata",
220 "--spirv-debug-info-version=nonsemantic-shader-200"};
221 SPIRV::constructTranslateCommand(C, *this, JA, Output, Output, TrArgs);
222}
223
224// For amdgcn the inputs of the linker job are device bitcode and output is
225// either an object file or bitcode (-emit-llvm). It calls llvm-link, opt,
226// llc, then lld steps.
228 const InputInfo &Output,
229 const InputInfoList &Inputs,
230 const ArgList &Args,
231 const char *LinkingOutput) const {
232 if (Inputs.size() > 0 &&
233 Inputs[0].getType() == types::TY_Image &&
234 JA.getType() == types::TY_Object)
236 Args, JA, *this);
237
238 if (JA.getType() == types::TY_HIP_FATBIN)
239 return HIP::constructHIPFatbinCommand(C, JA, Output.getFilename(), Inputs,
240 Args, *this);
241
242 if (JA.getType() == types::TY_LLVM_BC)
243 return constructLlvmLinkCommand(C, JA, Inputs, Output, Args);
244
245 if (getToolChain().getTriple().isSPIRV())
246 return constructLinkAndEmitSpirvCommand(C, JA, Inputs, Output, Args);
247
248 return constructLldCommand(C, JA, Inputs, Output, Args);
249}
250
251HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
252 const ToolChain &HostTC, const ArgList &Args)
253 : ROCMToolChain(D, Triple, Args), HostTC(HostTC) {
254 // Lookup binaries into the driver directory, this is used to
255 // discover the clang-offload-bundler executable.
256 getProgramPaths().push_back(getDriver().Dir);
257
258 // Diagnose unsupported sanitizer options only once.
259 if (!Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
260 true))
261 return;
262 for (auto *A : Args.filtered(options::OPT_fsanitize_EQ)) {
263 SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
264 if (K != SanitizerKind::Address)
265 D.getDiags().Report(clang::diag::warn_drv_unsupported_option_for_target)
266 << A->getAsString(Args) << getTriple().str();
267 }
268}
269
271 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
272 Action::OffloadKind DeviceOffloadingKind) const {
273 HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);
274
275 assert(DeviceOffloadingKind == Action::OFK_HIP &&
276 "Only HIP offloading kinds are supported for GPUs.");
277
278 CC1Args.push_back("-fcuda-is-device");
279
280 if (!DriverArgs.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
281 false))
282 CC1Args.append({"-mllvm", "-amdgpu-internalize-symbols"});
283 if (DriverArgs.hasArgNoClaim(options::OPT_hipstdpar))
284 CC1Args.append({"-mllvm", "-amdgpu-enable-hipstdpar"});
285
286 StringRef MaxThreadsPerBlock =
287 DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);
288 if (!MaxThreadsPerBlock.empty()) {
289 std::string ArgStr =
290 (Twine("--gpu-max-threads-per-block=") + MaxThreadsPerBlock).str();
291 CC1Args.push_back(DriverArgs.MakeArgStringRef(ArgStr));
292 }
293
294 CC1Args.push_back("-fcuda-allow-variadic-functions");
295
296 // Default to "hidden" visibility, as object level linking will not be
297 // supported for the foreseeable future.
298 if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
299 options::OPT_fvisibility_ms_compat)) {
300 CC1Args.append({"-fvisibility=hidden"});
301 CC1Args.push_back("-fapply-global-visibility-to-externs");
302 }
303
304 // For SPIR-V we embed the command-line into the generated binary, in order to
305 // retrieve it at JIT time and be able to do target specific compilation with
306 // options that match the user-supplied ones.
307 if (getTriple().isSPIRV() &&
308 !DriverArgs.hasArg(options::OPT_fembed_bitcode_marker))
309 CC1Args.push_back("-fembed-bitcode=marker");
310
311 for (auto BCFile : getDeviceLibs(DriverArgs)) {
312 CC1Args.push_back(BCFile.ShouldInternalize ? "-mlink-builtin-bitcode"
313 : "-mlink-bitcode-file");
314 CC1Args.push_back(DriverArgs.MakeArgString(BCFile.Path));
315 }
316}
317
318llvm::opt::DerivedArgList *
319HIPAMDToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
320 StringRef BoundArch,
321 Action::OffloadKind DeviceOffloadKind) const {
322 DerivedArgList *DAL =
323 HostTC.TranslateArgs(Args, BoundArch, DeviceOffloadKind);
324 if (!DAL)
325 DAL = new DerivedArgList(Args.getBaseArgs());
326
327 const OptTable &Opts = getDriver().getOpts();
328
329 for (Arg *A : Args) {
330 if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
331 DAL->append(A);
332 }
333
334 if (!BoundArch.empty()) {
335 DAL->eraseArg(options::OPT_mcpu_EQ);
336 DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_mcpu_EQ), BoundArch);
337 checkTargetID(*DAL);
338 }
339
340 return DAL;
341}
342
344 assert(getTriple().getArch() == llvm::Triple::amdgcn ||
345 getTriple().getArch() == llvm::Triple::spirv64);
346 return new tools::AMDGCN::Linker(*this);
347}
348
349void HIPAMDToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {
352}
353
355HIPAMDToolChain::GetCXXStdlibType(const ArgList &Args) const {
356 return HostTC.GetCXXStdlibType(Args);
357}
358
359void HIPAMDToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
360 ArgStringList &CC1Args) const {
361 HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
362}
363
365 const ArgList &Args, ArgStringList &CC1Args) const {
367}
368
370 ArgStringList &CC1Args) const {
371 HostTC.AddIAMCUIncludeArgs(Args, CC1Args);
372}
373
374void HIPAMDToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
375 ArgStringList &CC1Args) const {
376 RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
377}
378
380 // The HIPAMDToolChain only supports sanitizers in the sense that it allows
381 // sanitizer arguments on the command line if they are supported by the host
382 // toolchain. The HIPAMDToolChain will actually ignore any command line
383 // arguments for any of these "supported" sanitizers. That means that no
384 // sanitization of device code is actually supported at this time.
385 //
386 // This behavior is necessary because the host and device toolchains
387 // invocations often share the command line, so the device toolchain must
388 // tolerate flags meant only for the host toolchain.
390}
391
393 const ArgList &Args) const {
394 return HostTC.computeMSVCVersion(D, Args);
395}
396
398HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
400 if (DriverArgs.hasArg(options::OPT_nogpulib) ||
401 (getTriple().getArch() == llvm::Triple::spirv64 &&
402 getTriple().getVendor() == llvm::Triple::AMD))
403 return {};
404 ArgStringList LibraryPaths;
405
406 // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
407 for (StringRef Path : RocmInstallation->getRocmDeviceLibPathArg())
408 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
409
410 addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
411
412 // Maintain compatability with --hip-device-lib.
413 auto BCLibArgs = DriverArgs.getAllArgValues(options::OPT_hip_device_lib_EQ);
414 if (!BCLibArgs.empty()) {
415 llvm::for_each(BCLibArgs, [&](StringRef BCName) {
416 StringRef FullName;
417 for (StringRef LibraryPath : LibraryPaths) {
418 SmallString<128> Path(LibraryPath);
419 llvm::sys::path::append(Path, BCName);
420 FullName = Path;
421 if (llvm::sys::fs::exists(FullName)) {
422 BCLibs.push_back(FullName);
423 return;
424 }
425 }
426 getDriver().Diag(diag::err_drv_no_such_file) << BCName;
427 });
428 } else {
429 if (!RocmInstallation->hasDeviceLibrary()) {
430 getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;
431 return {};
432 }
433 StringRef GpuArch = getGPUArch(DriverArgs);
434 assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
435
436 // If --hip-device-lib is not set, add the default bitcode libraries.
437 if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
438 options::OPT_fno_gpu_sanitize, true) &&
439 getSanitizerArgs(DriverArgs).needsAsanRt()) {
440 auto AsanRTL = RocmInstallation->getAsanRTLPath();
441 if (AsanRTL.empty()) {
442 unsigned DiagID = getDriver().getDiags().getCustomDiagID(
444 "AMDGPU address sanitizer runtime library (asanrtl) is not found. "
445 "Please install ROCm device library which supports address "
446 "sanitizer");
447 getDriver().Diag(DiagID);
448 return {};
449 } else
450 BCLibs.emplace_back(AsanRTL, /*ShouldInternalize=*/false);
451 }
452
453 // Add the HIP specific bitcode library.
454 BCLibs.push_back(RocmInstallation->getHIPPath());
455
456 // Add common device libraries like ocml etc.
457 for (StringRef N : getCommonDeviceLibNames(DriverArgs, GpuArch.str()))
458 BCLibs.emplace_back(N);
459
460 // Add instrument lib.
461 auto InstLib =
462 DriverArgs.getLastArgValue(options::OPT_gpu_instrument_lib_EQ);
463 if (InstLib.empty())
464 return BCLibs;
465 if (llvm::sys::fs::exists(InstLib))
466 BCLibs.push_back(InstLib);
467 else
468 getDriver().Diag(diag::err_drv_no_such_file) << InstLib;
469 }
470
471 return BCLibs;
472}
473
475 const llvm::opt::ArgList &DriverArgs) const {
476 auto PTID = getParsedTargetID(DriverArgs);
477 if (PTID.OptionalTargetID && !PTID.OptionalGPUArch) {
478 getDriver().Diag(clang::diag::err_drv_bad_target_id)
479 << *PTID.OptionalTargetID;
480 }
481}
const Decl * D
IndirectLocalPath & Path
static bool shouldSkipSanitizeOption(const ToolChain &TC, const llvm::opt::ArgList &DriverArgs, StringRef TargetID, const llvm::opt::Arg *A)
Definition: HIPAMD.cpp:39
int32_t FullName
Definition: SemaARM.cpp:1145
SourceLocation Loc
Definition: SemaObjC.cpp:759
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:873
types::ID getType() const
Definition: Action.h:148
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
DiagnosticsEngine & getDiags() const
Definition: Driver.h:401
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:144
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:399
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
const char * getFilename() const
Definition: InputInfo.h:83
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const
Add warning options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:1111
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:268
const Driver & getDriver() const
Definition: ToolChain.h:252
path_list & getProgramPaths()
Definition: ToolChain.h:297
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:358
const llvm::Triple & getTriple() const
Definition: ToolChain.h:254
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:1279
virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const
On Windows, returns the MSVC compatibility version.
Definition: ToolChain.cpp:1454
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use MCU GCC toolchain includes.
Definition: ToolChain.cpp:1437
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const
Definition: ToolChain.cpp:333
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1183
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:1104
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:1099
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1400
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
const ToolChain & getToolChain() const
Definition: Tool.h:52
StringRef getGPUArch(const llvm::opt::ArgList &DriverArgs) const
Get GPU arch from -mcpu without checking.
Definition: AMDGPU.cpp:865
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override
Common warning options shared by AMDGPU HIP, OpenCL and OpenMP toolchains.
Definition: AMDGPU.cpp:858
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:871
LazyDetector< RocmInstallationDetector > RocmInstallation
Definition: Gnu.h:290
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: HIPAMD.cpp:379
Tool * buildLinker() const override
Definition: HIPAMD.cpp:343
HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple, const ToolChain &HostTC, const llvm::opt::ArgList &Args)
Definition: HIPAMD.cpp:251
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: HIPAMD.cpp:319
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: HIPAMD.cpp:270
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition: HIPAMD.cpp:359
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use MCU GCC toolchain includes.
Definition: HIPAMD.cpp:369
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: HIPAMD.cpp:364
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition: HIPAMD.cpp:374
void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override
Check and diagnose invalid target ID specified by -mcpu.
Definition: HIPAMD.cpp:474
VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const override
On Windows, returns the MSVC compatibility version.
Definition: HIPAMD.cpp:392
void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override
Common warning options shared by AMDGPU HIP, OpenCL and OpenMP toolchains.
Definition: HIPAMD.cpp:349
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: HIPAMD.cpp:355
llvm::SmallVector< BitCodeLibraryInfo, 12 > getDeviceLibs(const llvm::opt::ArgList &Args) const override
Get paths for device libraries.
Definition: HIPAMD.cpp:398
llvm::SmallVector< std::string, 12 > getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs, const std::string &GPUArch, bool isOpenMP=false) const
Definition: AMDGPU.cpp:1022
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
Definition: HIPAMD.cpp:227
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA, StringRef OutputFileName, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const Tool &T)
void constructGenerateObjFileFromHIPFatBinary(Compilation &C, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, const JobAction &JA, const Tool &T)
void constructTranslateCommand(Compilation &C, const Tool &T, const JobAction &JA, const InputInfo &Output, const InputInfo &Input, const llvm::opt::ArgStringList &Args)
Definition: SPIRV.cpp:21
void getAMDGPUTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, std::vector< StringRef > &Features)
Definition: AMDGPU.cpp:660
SmallVector< StringRef > unifyTargetFeatures(ArrayRef< StringRef > Features)
If there are multiple +xxx or -xxx features, keep the last one.
Definition: CommonArgs.cpp:379
void AddStaticDeviceLibsLinking(Compilation &C, const Tool &T, const JobAction &JA, const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CmdArgs, StringRef Arch, StringRef Target, bool isBitCodeSDL)
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.
void addLinkerCompressDebugSectionsOption(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
Definition: CommonArgs.cpp:495
void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, const InputInfo &Input, bool IsThinLTO)
The JSON file list parser is used to communicate input to InstallAPI.
std::optional< llvm::StringRef > parseTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch, llvm::StringMap< bool > *FeatureMap)
Parse a target ID to get processor and feature map.
Definition: TargetID.cpp:105
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
Definition: Sanitizers.cpp:29
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
Definition: Job.h:78