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;
80 bool HasHIPStdParLibrary =
false;
81 bool HasRocThrustLibrary =
false;
82 bool HasRocPrimLibrary =
false;
85 const unsigned DefaultVersionMajor = 3;
86 const unsigned DefaultVersionMinor = 5;
87 const char *DefaultVersionPatch =
"0";
90 std::string DetectedVersion;
92 llvm::VersionTuple VersionMajorMinor;
94 std::string VersionPatch;
97 StringRef RocmPathArg;
99 std::vector<std::string> RocmDeviceLibPathArg;
101 StringRef HIPPathArg;
104 StringRef HIPStdParPathArg;
106 StringRef HIPRocThrustPathArg;
108 StringRef HIPRocPrimPathArg;
110 StringRef HIPVersionArg;
112 bool NoBuiltinLibs =
false;
121 llvm::StringMap<std::string> LibDeviceMap;
135 ConditionalLibrary WavefrontSize64;
136 ConditionalLibrary FiniteOnly;
137 ConditionalLibrary UnsafeMath;
138 ConditionalLibrary DenormalsAreZero;
139 ConditionalLibrary CorrectlyRoundedSqrt;
143 std::map<unsigned, std::string> ABIVersionMap;
147 bool PrintROCmSearchDirs;
150 bool allGenericLibsValid()
const {
151 return !OCML.empty() && !OCKL.empty() && !
OpenCL.empty() && !
HIP.empty() &&
152 WavefrontSize64.isValid() && FiniteOnly.isValid() &&
153 UnsafeMath.isValid() && DenormalsAreZero.isValid() &&
154 CorrectlyRoundedSqrt.isValid();
157 void scanLibDevicePath(llvm::StringRef
Path);
158 bool parseHIPVersionFile(llvm::StringRef
V);
166 StringRef PackageName);
170 const llvm::opt::ArgList &Args,
171 bool DetectHIPRuntime =
true,
172 bool DetectDeviceLib =
false);
178 StringRef LibDeviceFile,
bool Wave64,
bool DAZ,
179 bool FiniteOnly,
bool UnsafeMathOpt,
180 bool FastRelaxedMath,
bool CorrectSqrt,
197 void print(raw_ostream &OS)
const;
218 assert(!OCML.empty());
223 assert(!OCKL.empty());
233 assert(!
HIP.empty());
241 return WavefrontSize64.get(Enabled);
245 return FiniteOnly.get(Enabled);
249 return UnsafeMath.get(Enabled);
253 return DenormalsAreZero.get(Enabled);
257 return CorrectlyRoundedSqrt.get(Enabled);
262 if (
Loc == ABIVersionMap.end())
269 auto Loc = LibDeviceMap.find(Gpu);
270 if (
Loc == LibDeviceMap.end())
276 llvm::opt::ArgStringList &CC1Args)
const;
283 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
bool hasHIPStdParLibrary() const
Check whether we detected a valid HIP STDPAR Acceleration library.
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.
The JSON file list parser is used to communicate input to InstallAPI.
ABI version of device library.
static DeviceLibABIVersion fromCodeObjectVersion(unsigned CodeObjectVersion)
DeviceLibABIVersion(unsigned V)
bool requiresLibrary()
Whether ABI version bc file is requested.