12 #include "clang/Config/config.h"
18 #include "llvm/Option/ArgList.h"
19 #include "llvm/Support/Error.h"
20 #include "llvm/Support/Host.h"
21 #include "llvm/Support/LineIterator.h"
22 #include "llvm/Support/Path.h"
23 #include "llvm/Support/Process.h"
24 #include "llvm/Support/VirtualFileSystem.h"
26 #include <system_error>
31 using namespace clang;
41 RocmInstallationDetector::findSPACKPackage(
const Candidate &Cand,
42 StringRef PackageName) {
46 std::string Prefix = Twine(PackageName +
"-" + Cand.SPACKReleaseStr).str();
48 for (llvm::vfs::directory_iterator File = D.getVFS().dir_begin(Cand.Path, EC),
50 File != FileEnd && !EC;
File.increment(EC)) {
51 llvm::StringRef FileName = llvm::sys::path::filename(
File->path());
52 if (FileName.startswith(Prefix)) {
53 SubDirs.push_back(FileName);
54 if (SubDirs.size() > 1)
58 if (SubDirs.size() == 1) {
59 auto PackagePath = Cand.Path;
60 llvm::sys::path::append(PackagePath, SubDirs[0]);
63 if (SubDirs.size() == 0 && Verbose) {
64 llvm::errs() <<
"SPACK package " << Prefix <<
" not found at " << Cand.Path
69 if (SubDirs.size() > 1 && Verbose) {
70 llvm::errs() <<
"Cannot use SPACK package " << Prefix <<
" at " << Cand.Path
71 <<
" due to multiple installations for the same version\n";
76 void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) {
77 assert(!Path.empty());
79 const StringRef Suffix(
".bc");
80 const StringRef Suffix2(
".amdgcn.bc");
83 for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Path, EC),
LE;
84 !EC && LI !=
LE; LI = LI.increment(EC)) {
85 StringRef FilePath = LI->path();
86 StringRef FileName = llvm::sys::path::filename(FilePath);
87 if (!FileName.endswith(Suffix))
91 if (FileName.endswith(Suffix2))
92 BaseName = FileName.drop_back(Suffix2.size());
93 else if (FileName.endswith(Suffix))
94 BaseName = FileName.drop_back(Suffix.size());
96 const StringRef ABIVersionPrefix =
"oclc_abi_version_";
97 if (BaseName ==
"ocml") {
99 }
else if (BaseName ==
"ockl") {
101 }
else if (BaseName ==
"opencl") {
103 }
else if (BaseName ==
"hip") {
105 }
else if (BaseName ==
"asanrtl") {
107 }
else if (BaseName ==
"oclc_finite_only_off") {
108 FiniteOnly.Off = FilePath;
109 }
else if (BaseName ==
"oclc_finite_only_on") {
110 FiniteOnly.On = FilePath;
111 }
else if (BaseName ==
"oclc_daz_opt_on") {
112 DenormalsAreZero.On = FilePath;
113 }
else if (BaseName ==
"oclc_daz_opt_off") {
114 DenormalsAreZero.Off = FilePath;
115 }
else if (BaseName ==
"oclc_correctly_rounded_sqrt_on") {
116 CorrectlyRoundedSqrt.On = FilePath;
117 }
else if (BaseName ==
"oclc_correctly_rounded_sqrt_off") {
118 CorrectlyRoundedSqrt.Off = FilePath;
119 }
else if (BaseName ==
"oclc_unsafe_math_on") {
120 UnsafeMath.On = FilePath;
121 }
else if (BaseName ==
"oclc_unsafe_math_off") {
122 UnsafeMath.Off = FilePath;
123 }
else if (BaseName ==
"oclc_wavefrontsize64_on") {
124 WavefrontSize64.On = FilePath;
125 }
else if (BaseName ==
"oclc_wavefrontsize64_off") {
126 WavefrontSize64.Off = FilePath;
127 }
else if (BaseName.startswith(ABIVersionPrefix)) {
128 unsigned ABIVersionNumber;
129 if (BaseName.drop_front(ABIVersionPrefix.size())
130 .getAsInteger(0, ABIVersionNumber))
132 ABIVersionMap[ABIVersionNumber] = FilePath.str();
136 const StringRef DeviceLibPrefix =
"oclc_isa_version_";
137 if (!BaseName.startswith(DeviceLibPrefix))
140 StringRef IsaVersionNumber =
141 BaseName.drop_front(DeviceLibPrefix.size());
143 llvm::Twine GfxName = Twine(
"gfx") + IsaVersionNumber;
146 std::make_pair(GfxName.toStringRef(Tmp), FilePath.str()));
153 bool RocmInstallationDetector::parseHIPVersionFile(llvm::StringRef
V) {
155 V.split(VersionParts,
'\n');
156 unsigned Major = ~0
U;
157 unsigned Minor = ~0
U;
158 for (
auto Part : VersionParts) {
159 auto Splits = Part.rtrim().split(
'=');
160 if (Splits.first ==
"HIP_VERSION_MAJOR") {
161 if (Splits.second.getAsInteger(0, Major))
163 }
else if (Splits.first ==
"HIP_VERSION_MINOR") {
164 if (Splits.second.getAsInteger(0, Minor))
166 }
else if (Splits.first ==
"HIP_VERSION_PATCH")
167 VersionPatch = Splits.second.str();
169 if (Major == ~0
U || Minor == ~0
U)
171 VersionMajorMinor = llvm::VersionTuple(Major, Minor);
173 (Twine(Major) +
"." + Twine(Minor) +
"." + VersionPatch).str();
180 RocmInstallationDetector::getInstallationPathCandidates() {
183 if (!ROCmSearchDirs.empty())
184 return ROCmSearchDirs;
186 auto DoPrintROCmSearchDirs = [&]() {
187 if (PrintROCmSearchDirs)
188 for (
auto Cand : ROCmSearchDirs) {
189 llvm::errs() <<
"ROCm installation search path";
191 llvm::errs() <<
" (Spack " << Cand.SPACKReleaseStr <<
")";
192 llvm::errs() <<
": " << Cand.Path <<
'\n';
198 if (!RocmPathArg.empty()) {
199 ROCmSearchDirs.emplace_back(RocmPathArg.str());
200 DoPrintROCmSearchDirs();
201 return ROCmSearchDirs;
202 }
else if (std::optional<std::string> RocmPathEnv =
203 llvm::sys::Process::GetEnv(
"ROCM_PATH")) {
204 if (!RocmPathEnv->empty()) {
205 ROCmSearchDirs.emplace_back(std::move(*RocmPathEnv));
206 DoPrintROCmSearchDirs();
207 return ROCmSearchDirs;
212 const char *InstallDir = D.getInstalledDir();
217 auto DeduceROCmPath = [](StringRef ClangPath) {
219 StringRef ParentDir = llvm::sys::path::parent_path(ClangPath);
220 StringRef ParentName = llvm::sys::path::filename(ParentDir);
223 if (ParentName ==
"bin") {
224 ParentDir = llvm::sys::path::parent_path(ParentDir);
225 ParentName = llvm::sys::path::filename(ParentDir);
233 if (ParentName.startswith(
"llvm-amdgpu-")) {
235 ParentName.drop_front(strlen(
"llvm-amdgpu-")).split(
'-');
236 auto SPACKReleaseStr = SPACKPostfix.first;
237 if (!SPACKReleaseStr.empty()) {
238 ParentDir = llvm::sys::path::parent_path(ParentDir);
239 return Candidate(ParentDir.str(),
true,
246 if (ParentName ==
"llvm" || ParentName.startswith(
"aomp"))
247 ParentDir = llvm::sys::path::parent_path(ParentDir);
249 return Candidate(ParentDir.str(),
true);
254 ROCmSearchDirs.emplace_back(DeduceROCmPath(InstallDir));
259 llvm::sys::fs::real_path(D.getClangProgramPath(), RealClangPath);
260 auto ParentPath = llvm::sys::path::parent_path(RealClangPath);
261 if (ParentPath != InstallDir)
262 ROCmSearchDirs.emplace_back(DeduceROCmPath(ParentPath));
265 auto ClangRoot = llvm::sys::path::parent_path(InstallDir);
266 auto RealClangRoot = llvm::sys::path::parent_path(ParentPath);
267 ROCmSearchDirs.emplace_back(ClangRoot.str(),
true);
268 if (RealClangRoot != ClangRoot)
269 ROCmSearchDirs.emplace_back(RealClangRoot.str(),
true);
270 ROCmSearchDirs.emplace_back(D.ResourceDir,
273 ROCmSearchDirs.emplace_back(D.SysRoot +
"/opt/rocm",
279 llvm::VersionTuple LatestVer;
281 auto GetROCmVersion = [](StringRef DirName) {
282 llvm::VersionTuple
V;
283 std::string VerStr = DirName.drop_front(strlen(
"rocm-")).str();
286 std::replace(VerStr.begin(), VerStr.end(),
'-',
'.');
290 for (llvm::vfs::directory_iterator
291 File = D.getVFS().dir_begin(D.SysRoot +
"/opt", EC),
293 File != FileEnd && !EC;
File.increment(EC)) {
294 llvm::StringRef FileName = llvm::sys::path::filename(
File->path());
295 if (!FileName.startswith(
"rocm-"))
297 if (LatestROCm.empty()) {
298 LatestROCm = FileName.str();
299 LatestVer = GetROCmVersion(LatestROCm);
302 auto Ver = GetROCmVersion(FileName);
303 if (LatestVer < Ver) {
304 LatestROCm = FileName.str();
308 if (!LatestROCm.empty())
309 ROCmSearchDirs.emplace_back(D.SysRoot +
"/opt/" + LatestROCm,
312 Distro Dist(D.getVFS(), llvm::Triple(llvm::sys::getProcessTriple()));
313 if (Dist.IsDebian() || Dist.IsRedhat()) {
314 ROCmSearchDirs.emplace_back(D.SysRoot +
"/usr/local",
316 ROCmSearchDirs.emplace_back(D.SysRoot +
"/usr",
320 DoPrintROCmSearchDirs();
321 return ROCmSearchDirs;
325 const Driver &D,
const llvm::Triple &HostTriple,
326 const llvm::opt::ArgList &Args,
bool DetectHIPRuntime,
bool DetectDeviceLib)
328 Verbose = Args.hasArg(options::OPT_v);
329 RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ);
330 PrintROCmSearchDirs =
331 Args.hasArg(clang::driver::options::OPT_print_rocm_search_dirs);
332 RocmDeviceLibPathArg =
333 Args.getAllArgValues(clang::driver::options::OPT_rocm_device_lib_path_EQ);
334 HIPPathArg = Args.getLastArgValue(clang::driver::options::OPT_hip_path_EQ);
335 if (
auto *A = Args.getLastArg(clang::driver::options::OPT_hip_version_EQ)) {
336 HIPVersionArg = A->getValue();
337 unsigned Major = ~0
U;
338 unsigned Minor = ~0
U;
340 HIPVersionArg.split(Parts,
'.');
342 Parts[0].getAsInteger(0, Major);
343 if (Parts.size() > 1)
344 Parts[1].getAsInteger(0, Minor);
345 if (Parts.size() > 2)
346 VersionPatch = Parts[2].str();
347 if (VersionPatch.empty())
349 if (Major != ~0
U && Minor == ~0
U)
351 if (Major == ~0
U || Minor == ~0
U)
352 D.
Diag(diag::err_drv_invalid_value)
353 << A->getAsString(Args) << HIPVersionArg;
355 VersionMajorMinor = llvm::VersionTuple(Major, Minor);
357 (Twine(Major) +
"." + Twine(Minor) +
"." + VersionPatch).str();
359 VersionPatch = DefaultVersionPatch;
361 llvm::VersionTuple(DefaultVersionMajor, DefaultVersionMinor);
362 DetectedVersion = (Twine(DefaultVersionMajor) +
"." +
363 Twine(DefaultVersionMinor) +
"." + VersionPatch)
367 if (DetectHIPRuntime)
374 assert(LibDevicePath.empty());
376 if (!RocmDeviceLibPathArg.empty())
377 LibDevicePath = RocmDeviceLibPathArg[RocmDeviceLibPathArg.size() - 1];
378 else if (std::optional<std::string> LibPathEnv =
379 llvm::sys::Process::GetEnv(
"HIP_DEVICE_LIB_PATH"))
380 LibDevicePath = std::move(*LibPathEnv);
383 if (!LibDevicePath.empty()) {
387 if (!FS.exists(LibDevicePath))
390 scanLibDevicePath(LibDevicePath);
391 HasDeviceLibrary = allGenericLibsValid() && !LibDeviceMap.empty();
396 auto CheckDeviceLib = [&](StringRef Path,
bool StrictChecking) {
397 bool CheckLibDevice = (!NoBuiltinLibs || StrictChecking);
398 if (CheckLibDevice && !FS.exists(Path))
401 scanLibDevicePath(Path);
403 if (!NoBuiltinLibs) {
405 if (!allGenericLibsValid())
410 if (LibDeviceMap.empty())
418 llvm::sys::path::append(LibDevicePath, CLANG_INSTALL_LIBDIR_BASENAME,
419 "amdgcn",
"bitcode");
420 HasDeviceLibrary = CheckDeviceLib(LibDevicePath,
true);
421 if (HasDeviceLibrary)
426 auto &ROCmDirs = getInstallationPathCandidates();
427 for (
const auto &Candidate : ROCmDirs) {
428 LibDevicePath = Candidate.Path;
429 llvm::sys::path::append(LibDevicePath,
"amdgcn",
"bitcode");
430 HasDeviceLibrary = CheckDeviceLib(LibDevicePath, Candidate.StrictChecking);
431 if (HasDeviceLibrary)
438 if (!HIPPathArg.empty())
439 HIPSearchDirs.emplace_back(HIPPathArg.str(),
true);
441 HIPSearchDirs.append(getInstallationPathCandidates());
444 for (
const auto &Candidate : HIPSearchDirs) {
445 InstallPath = Candidate.Path;
446 if (InstallPath.empty() || !FS.exists(InstallPath))
450 auto SPACKPath = findSPACKPackage(Candidate,
"hip");
451 InstallPath = SPACKPath.empty() ? InstallPath : SPACKPath;
453 BinPath = InstallPath;
454 llvm::sys::path::append(BinPath,
"bin");
455 IncludePath = InstallPath;
456 llvm::sys::path::append(IncludePath,
"include");
457 LibPath = InstallPath;
458 llvm::sys::path::append(LibPath,
"lib");
459 SharePath = InstallPath;
460 llvm::sys::path::append(SharePath,
"share");
463 for (
const auto &VersionFilePath :
466 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
467 FS.getBufferForFile(VersionFilePath);
470 if (HIPVersionArg.empty() && VersionFile)
471 if (parseHIPVersionFile((*VersionFile)->getBuffer()))
474 HasHIPRuntime =
true;
479 if (!Candidate.StrictChecking) {
480 HasHIPRuntime =
true;
484 HasHIPRuntime =
false;
489 OS <<
"Found HIP installation: " << InstallPath <<
", version "
490 << DetectedVersion <<
'\n';
494 ArgStringList &CC1Args)
const {
495 bool UsesRuntimeWrapper = VersionMajorMinor > llvm::VersionTuple(3, 5) &&
496 !DriverArgs.hasArg(options::OPT_nohipwrapperinc);
498 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
513 if (UsesRuntimeWrapper)
514 llvm::sys::path::append(
P,
"include",
"cuda_wrappers");
515 CC1Args.push_back(
"-internal-isystem");
516 CC1Args.push_back(DriverArgs.MakeArgString(
P));
519 if (DriverArgs.hasArg(options::OPT_nogpuinc))
523 D.
Diag(diag::err_drv_no_hip_runtime);
527 CC1Args.push_back(
"-idirafter");
529 if (UsesRuntimeWrapper)
530 CC1Args.append({
"-include",
"__clang_hip_runtime_wrapper.h"});
537 const char *LinkingOutput)
const {
540 ArgStringList CmdArgs;
543 CmdArgs.push_back(
"-shared");
544 CmdArgs.push_back(
"-o");
546 C.addCommand(std::make_unique<Command>(
548 CmdArgs, Inputs, Output));
552 const llvm::Triple &Triple,
553 const llvm::opt::ArgList &Args,
554 std::vector<StringRef> &Features) {
557 StringRef TargetID = Args.getLastArgValue(options::OPT_mcpu_EQ);
558 if (!TargetID.empty()) {
559 llvm::StringMap<bool> FeatureMap;
560 auto OptionalGpuArch =
parseTargetID(Triple, TargetID, &FeatureMap);
561 if (OptionalGpuArch) {
562 StringRef GpuArch = *OptionalGpuArch;
568 auto Pos = FeatureMap.find(Feature);
569 if (Pos == FeatureMap.end())
571 Features.push_back(Args.MakeArgStringRef(
572 (Twine(Pos->second ?
"+" :
"-") + Feature).str()));
577 if (Args.hasFlag(options::OPT_mwavefrontsize64,
578 options::OPT_mno_wavefrontsize64,
false))
579 Features.push_back(
"+wavefrontsize64");
582 Args, Features, options::OPT_m_amdgpu_Features_Group);
586 AMDGPUToolChain::AMDGPUToolChain(
const Driver &D,
const llvm::Triple &Triple,
590 {{options::OPT_O,
"3"}, {options::OPT_cl_std_EQ,
"CL1.2"}}) {
606 DerivedArgList *DAL =
612 DAL =
new DerivedArgList(Args.getBaseArgs());
614 for (Arg *A : Args) {
621 if (!Args.getLastArgValue(options::OPT_x).equals(
"cl"))
625 if (Args.hasArg(options::OPT_c) && Args.hasArg(options::OPT_emit_llvm)) {
626 DAL->AddFlagArg(
nullptr, Opts.getOption(
getTriple().isArch64Bit()
628 : options::OPT_m32));
632 if (!Args.hasArg(options::OPT_O, options::OPT_O0, options::OPT_O4,
634 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_O),
642 llvm::AMDGPU::GPUKind
Kind) {
645 if (
Kind == llvm::AMDGPU::GK_NONE)
648 const unsigned ArchAttr = llvm::AMDGPU::getArchAttrAMDGCN(
Kind);
652 const bool BothDenormAndFMAFast =
653 (ArchAttr & llvm::AMDGPU::FEATURE_FAST_FMA_F32) &&
654 (ArchAttr & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32);
655 return !BothDenormAndFMAFast;
659 const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
660 const llvm::fltSemantics *FPType)
const {
662 if (!FPType || FPType != &llvm::APFloat::IEEEsingle())
663 return llvm::DenormalMode::getIEEE();
668 auto Kind = llvm::AMDGPU::parseArchAMDGCN(Arch);
669 if (FPType && FPType == &llvm::APFloat::IEEEsingle() &&
670 DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
671 options::OPT_fno_gpu_flush_denormals_to_zero,
673 return llvm::DenormalMode::getPreserveSign();
675 return llvm::DenormalMode::getIEEE();
678 const StringRef GpuArch =
getGPUArch(DriverArgs);
679 auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
683 bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
688 return DAZ ? llvm::DenormalMode::getPreserveSign() :
689 llvm::DenormalMode::getIEEE();
693 llvm::AMDGPU::GPUKind
Kind) {
694 const unsigned ArchAttr = llvm::AMDGPU::getArchAttrAMDGCN(
Kind);
695 bool HasWave32 = (ArchAttr & llvm::AMDGPU::FEATURE_WAVE32);
697 return !HasWave32 || DriverArgs.hasFlag(
698 options::OPT_mwavefrontsize64, options::OPT_mno_wavefrontsize64,
false);
710 const llvm::opt::ArgList &DriverArgs,
711 llvm::opt::ArgStringList &CC1Args,
715 if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
716 options::OPT_fvisibility_ms_compat)) {
717 CC1Args.push_back(
"-fvisibility=hidden");
718 CC1Args.push_back(
"-fapply-global-visibility-to-externs");
725 getTriple(), DriverArgs.getLastArgValue(options::OPT_mcpu_EQ));
730 StringRef TargetID = DriverArgs.getLastArgValue(options::OPT_mcpu_EQ);
731 if (TargetID.empty())
732 return {std::nullopt, std::nullopt, std::nullopt};
734 llvm::StringMap<bool> FeatureMap;
736 if (!OptionalGpuArch)
737 return {TargetID.str(), std::nullopt, std::nullopt};
739 return {TargetID.str(), OptionalGpuArch->str(), FeatureMap};
743 const llvm::opt::ArgList &DriverArgs)
const {
745 if (PTID.OptionalTargetID && !PTID.OptionalGPUArch) {
747 << *PTID.OptionalTargetID;
755 if (Arg *A = Args.getLastArg(options::OPT_amdgpu_arch_tool_EQ))
756 Program = A->getValue();
762 return StdoutOrErr.takeError();
765 for (StringRef Arch : llvm::split((*StdoutOrErr)->getBuffer(),
"\n"))
767 GPUArchs.push_back(Arch.str());
769 if (GPUArchs.empty())
770 return llvm::createStringError(std::error_code(),
771 "No AMD GPU detected in the system");
773 return std::move(GPUArchs);
777 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
780 DeviceOffloadingKind);
785 DriverArgs.hasArg(options::OPT_nostdlib))
788 if (DriverArgs.hasArg(options::OPT_nogpulib))
792 const StringRef GpuArch =
getGPUArch(DriverArgs);
793 auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
794 const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(
Kind);
806 bool DAZ = DriverArgs.hasArg(options::OPT_cl_denorms_are_zero) ||
808 bool FiniteOnly = DriverArgs.hasArg(options::OPT_cl_finite_math_only);
811 DriverArgs.hasArg(options::OPT_cl_unsafe_math_optimizations);
812 bool FastRelaxedMath = DriverArgs.hasArg(options::OPT_cl_fast_relaxed_math);
814 DriverArgs.hasArg(options::OPT_cl_fp32_correctly_rounded_divide_sqrt);
822 DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
823 FastRelaxedMath, CorrectSqrt, ABIVer,
false));
825 for (StringRef BCFile : BCLibs) {
826 CC1Args.push_back(
"-mlink-builtin-bitcode");
827 CC1Args.push_back(DriverArgs.MakeArgString(BCFile));
832 StringRef GPUArch, StringRef LibDeviceFile,
834 if (!hasDeviceLibrary()) {
835 D.Diag(diag::err_drv_no_rocm_device_lib) << 0;
838 if (LibDeviceFile.empty()) {
839 D.Diag(diag::err_drv_no_rocm_device_lib) << 1 << GPUArch;
843 D.Diag(diag::err_drv_no_rocm_device_lib) << 2 << ABIVer.
toString();
851 const llvm::opt::ArgList &DriverArgs, StringRef LibDeviceFile,
bool Wave64,
852 bool DAZ,
bool FiniteOnly,
bool UnsafeMathOpt,
bool FastRelaxedMath,
856 auto AddBCLib = [&](StringRef BCFile) { BCLibs.push_back(BCFile.str()); };
858 AddBCLib(getOCMLPath());
859 AddBCLib(getOCKLPath());
860 AddBCLib(getDenormalsAreZeroPath(DAZ));
861 AddBCLib(getUnsafeMathPath(UnsafeMathOpt || FastRelaxedMath));
862 AddBCLib(getFiniteOnlyPath(FiniteOnly || FastRelaxedMath));
863 AddBCLib(getCorrectlyRoundedSqrtPath(CorrectSqrt));
864 AddBCLib(getWavefrontSize64Path(Wave64));
865 AddBCLib(LibDeviceFile);
866 auto ABIVerPath = getABIVersionPath(ABIVer);
867 if (!ABIVerPath.empty())
868 AddBCLib(ABIVerPath);
874 Option O = A->getOption();
875 if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie))
883 bool isOpenMP)
const {
884 auto Kind = llvm::AMDGPU::parseArchAMDGCN(GPUArch);
885 const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(
Kind);
897 bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
898 options::OPT_fno_gpu_flush_denormals_to_zero,
900 bool FiniteOnly = DriverArgs.hasFlag(
901 options::OPT_ffinite_math_only, options::OPT_fno_finite_math_only,
false);
903 DriverArgs.hasFlag(options::OPT_funsafe_math_optimizations,
904 options::OPT_fno_unsafe_math_optimizations,
false);
905 bool FastRelaxedMath = DriverArgs.hasFlag(options::OPT_ffast_math,
906 options::OPT_fno_fast_math,
false);
907 bool CorrectSqrt = DriverArgs.hasFlag(
908 options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
909 options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt,
true);
913 DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
914 FastRelaxedMath, CorrectSqrt, ABIVer, isOpenMP);