9#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ROCM_H
16#include "llvm/ADT/SmallString.h"
17#include "llvm/ADT/StringMap.h"
18#include "llvm/Option/ArgList.h"
19#include "llvm/Support/VersionTuple.h"
20#include "llvm/TargetParser/Triple.h"
30 if (CodeObjectVersion < 4)
31 CodeObjectVersion = 4;
40 assert(
ABIVersion % 100 == 0 &&
"Not supported");
49 struct ConditionalLibrary {
53 bool isValid()
const {
return !On.empty() && !Off.empty(); }
55 StringRef get(
bool Enabled)
const {
57 return Enabled ? On : Off;
68 std::string SPACKReleaseStr;
70 bool isSPACK()
const {
return !SPACKReleaseStr.empty(); }
71 Candidate(std::string Path,
bool StrictChecking =
false,
72 StringRef SPACKReleaseStr = {})
73 : Path(Path), StrictChecking(StrictChecking),
74 SPACKReleaseStr(SPACKReleaseStr.str()) {}
78 bool HasHIPRuntime =
false;
79 bool HasDeviceLibrary =
false;
82 const unsigned DefaultVersionMajor = 3;
83 const unsigned DefaultVersionMinor = 5;
84 const char *DefaultVersionPatch =
"0";
87 std::string DetectedVersion;
89 llvm::VersionTuple VersionMajorMinor;
91 std::string VersionPatch;
94 StringRef RocmPathArg;
96 std::vector<std::string> RocmDeviceLibPathArg;
100 StringRef HIPVersionArg;
102 bool NoBuiltinLibs =
false;
111 llvm::StringMap<std::string> LibDeviceMap;
125 ConditionalLibrary WavefrontSize64;
126 ConditionalLibrary FiniteOnly;
127 ConditionalLibrary UnsafeMath;
128 ConditionalLibrary DenormalsAreZero;
129 ConditionalLibrary CorrectlyRoundedSqrt;
133 std::map<unsigned, std::string> ABIVersionMap;
137 bool PrintROCmSearchDirs;
140 bool allGenericLibsValid()
const {
141 return !OCML.empty() && !OCKL.empty() && !
OpenCL.empty() && !
HIP.empty() &&
142 WavefrontSize64.isValid() && FiniteOnly.isValid() &&
143 UnsafeMath.isValid() && DenormalsAreZero.isValid() &&
144 CorrectlyRoundedSqrt.isValid();
147 void scanLibDevicePath(llvm::StringRef Path);
148 bool parseHIPVersionFile(llvm::StringRef
V);
156 StringRef PackageName);
160 const llvm::opt::ArgList &Args,
161 bool DetectHIPRuntime =
true,
162 bool DetectDeviceLib =
false);
168 StringRef LibDeviceFile,
bool Wave64,
bool DAZ,
169 bool FiniteOnly,
bool UnsafeMathOpt,
170 bool FastRelaxedMath,
bool CorrectSqrt,
184 void print(raw_ostream &OS)
const;
205 assert(!OCML.empty());
210 assert(!OCKL.empty());
220 assert(!
HIP.empty());
228 return WavefrontSize64.get(Enabled);
232 return FiniteOnly.get(Enabled);
236 return UnsafeMath.get(Enabled);
240 return DenormalsAreZero.get(Enabled);
244 return CorrectlyRoundedSqrt.get(Enabled);
248 auto Loc = ABIVersionMap.find(ABIVer.
ABIVersion);
249 if (Loc == ABIVersionMap.end())
256 auto Loc = LibDeviceMap.find(Gpu);
257 if (Loc == LibDeviceMap.end())
263 llvm::opt::ArgStringList &CC1Args)
const;
270 return RocmDeviceLibPathArg;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
A class to find a viable ROCM installation TODO: Generalize to handle libclc.
StringRef getCorrectlyRoundedSqrtPath(bool Enabled) const
StringRef getIncludePath() const
Get the detected path to Rocm's bin directory.
StringRef getHIPPath() const
StringRef getUnsafeMathPath(bool Enabled) const
StringRef getOCMLPath() const
StringRef getHIPVersion() const
StringRef getAsanRTLPath() const
Returns empty string of Asan runtime library is not available.
StringRef getOCKLPath() const
StringRef getFiniteOnlyPath(bool Enabled) const
bool hasDeviceLibrary() const
Check whether we detected a valid ROCm device library.
StringRef getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
ArrayRef< std::string > getRocmDeviceLibPathArg() const
Get the values for –rocm-device-lib-path arguments.
StringRef getRocmPathArg() const
Get the value for –rocm-path argument.
StringRef getInstallPath() const
Get the detected Rocm install's version.
StringRef getLibPath() const
Get the detected Rocm library path.
StringRef getDenormalsAreZeroPath(bool Enabled) const
StringRef getLibDevicePath() const
Get the detected Rocm device library path.
bool checkCommonBitcodeLibs(StringRef GPUArch, StringRef LibDeviceFile, DeviceLibABIVersion ABIVer) const
Check file paths of default bitcode libraries common to AMDGPU based toolchains.
StringRef getOpenCLPath() const
StringRef getHIPVersionArg() const
Get the value for –hip-version argument.
StringRef getABIVersionPath(DeviceLibABIVersion ABIVer) const
bool hasHIPRuntime() const
Check whether we detected a valid HIP runtime.
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, DeviceLibABIVersion ABIVer, bool isOpenMP) const
Get file paths of default bitcode libraries common to AMDGPU based toolchains.
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
void detectDeviceLibrary()
StringRef getWavefrontSize64Path(bool Enabled) const
void print(raw_ostream &OS) const
Print information about the detected ROCm installation.
ABI version of device library.
static DeviceLibABIVersion fromCodeObjectVersion(unsigned CodeObjectVersion)
DeviceLibABIVersion(unsigned V)
bool requiresLibrary()
Whether ABI version bc file is requested.