Skip to content

Commit 7613f5a

Browse files
committed
[Driver][SYCL][NFC] Update interface to access SYCL header additions
Move the ability to add the SYCL headers into the SYCLInstallation class to better conform to existing usage for other toolchains. Also improve the toolchain access for adding the headers using a virtual function.
1 parent a9aa8cb commit 7613f5a

File tree

15 files changed

+72
-38
lines changed

15 files changed

+72
-38
lines changed

clang/include/clang/Driver/ToolChain.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,10 @@ class ToolChain {
782782
virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
783783
llvm::opt::ArgStringList &CC1Args) const;
784784

785+
/// Add arguments to use SYCL specific includes.
786+
virtual void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
787+
llvm::opt::ArgStringList &CC1Args) const;
788+
785789
/// Add arguments to use MCU GCC toolchain includes.
786790
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
787791
llvm::opt::ArgStringList &CC1Args) const;

clang/lib/Driver/ToolChain.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,9 @@ void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
14771477
void ToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
14781478
ArgStringList &CC1Args) const {}
14791479

1480+
void ToolChain::AddSYCLIncludeArgs(const ArgList &DriverArgs,
1481+
ArgStringList &CC1Args) const {}
1482+
14801483
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
14811484
ToolChain::getDeviceLibs(
14821485
const ArgList &DriverArgs,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
11601160
getToolChain().AddHIPIncludeArgs(Args, CmdArgs);
11611161

11621162
if (JA.isOffloading(Action::OFK_SYCL)) {
1163-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(D, Args, CmdArgs);
1163+
getToolChain().AddSYCLIncludeArgs(Args, CmdArgs);
11641164
if (Inputs[0].getType() == types::TY_CUDA) {
11651165
// Include __clang_cuda_runtime_wrapper.h in .cu SYCL compilation.
11661166
getToolChain().AddCudaIncludeArgs(Args, CmdArgs);

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
924924
const ToolChain &HostTC, const ArgList &Args,
925925
const Action::OffloadKind OK)
926926
: NVPTXToolChain(D, Triple, HostTC.getTriple(), Args), HostTC(HostTC),
927-
OK(OK) {}
927+
SYCLInstallation(D), OK(OK) {}
928928

929929
void CudaToolChain::addClangTargetOptions(
930930
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
@@ -956,8 +956,7 @@ void CudaToolChain::addClangTargetOptions(
956956
}
957957

958958
if (DeviceOffloadingKind == Action::OFK_SYCL) {
959-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs,
960-
CC1Args);
959+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
961960

962961
if (DriverArgs.hasArg(options::OPT_fsycl_fp32_prec_sqrt)) {
963962
CC1Args.push_back("-fcuda-prec-sqrt");
@@ -1190,8 +1189,7 @@ CudaToolChain::GetCXXStdlibType(const ArgList &Args) const {
11901189
void CudaToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
11911190
ArgStringList &CC1Args) const {
11921191
if (DriverArgs.hasArg(options::OPT_fsycl)) {
1193-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs,
1194-
CC1Args);
1192+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
11951193
}
11961194
HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
11971195

clang/lib/Driver/ToolChains/Cuda.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ class LLVM_LIBRARY_VISIBILITY CudaToolChain : public NVPTXToolChain {
260260
Tool *SelectTool(const JobAction &JA) const override;
261261
const ToolChain &HostTC;
262262

263+
SYCLInstallationDetector SYCLInstallation;
264+
263265
protected:
264266
Tool *buildAssembler() const override; // ptxas
265267
Tool *buildLinker() const override; // fatbinary (ok, not really a linker)

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3190,7 +3190,8 @@ bool Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig(
31903190
Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple &Triple,
31913191
const ArgList &Args)
31923192
: ToolChain(D, Triple, Args), GCCInstallation(D),
3193-
CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args) {
3193+
CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args),
3194+
SYCLInstallation(D) {
31943195
getProgramPaths().push_back(getDriver().Dir);
31953196
}
31963197

clang/lib/Driver/ToolChains/Gnu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
294294
GCCInstallationDetector GCCInstallation;
295295
LazyDetector<CudaInstallationDetector> CudaInstallation;
296296
LazyDetector<RocmInstallationDetector> RocmInstallation;
297+
SYCLInstallationDetector SYCLInstallation;
297298

298299
public:
299300
Generic_GCC(const Driver &D, const llvm::Triple &Triple,

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA,
253253
HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
254254
const ToolChain &HostTC, const ArgList &Args,
255255
const Action::OffloadKind OK)
256-
: ROCMToolChain(D, Triple, Args), HostTC(HostTC), OK(OK) {
256+
: ROCMToolChain(D, Triple, Args), HostTC(HostTC), SYCLInstallation(D),
257+
OK(OK) {
257258
// Lookup binaries into the driver directory, this is used to
258259
// discover the clang-offload-bundler executable.
259260
getProgramPaths().push_back(getDriver().Dir);
@@ -318,8 +319,7 @@ void HIPAMDToolChain::addClangTargetOptions(
318319
CC1Args.push_back("-fembed-bitcode=marker");
319320

320321
if (DeviceOffloadingKind == Action::OFK_SYCL) {
321-
toolchains::SYCLToolChain::AddSYCLIncludeArgs(getDriver(), DriverArgs,
322-
CC1Args);
322+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
323323
}
324324

325325
auto NoLibSpirv = DriverArgs.hasArg(options::OPT_fno_sycl_libspirv) ||

clang/lib/Driver/ToolChains/HIPAMD.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class LLVM_LIBRARY_VISIBILITY HIPAMDToolChain final : public ROCMToolChain {
110110
void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
111111
Tool *SelectTool(const JobAction &JA) const override;
112112

113+
SYCLInstallationDetector SYCLInstallation;
114+
113115
protected:
114116
Tool *buildLinker() const override;
115117

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,11 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
768768
}
769769
}
770770

771+
void Linux::AddSYCLIncludeArgs(const ArgList &DriverArgs,
772+
ArgStringList &CC1Args) const {
773+
SYCLInstallation.AddSYCLIncludeArgs(DriverArgs, CC1Args);
774+
}
775+
771776
bool Linux::isPIEDefault(const llvm::opt::ArgList &Args) const {
772777
return CLANG_DEFAULT_PIE_ON_LINUX || getTriple().isAndroid() ||
773778
getTriple().isMusl() || getSanitizerArgs(Args).requiresPIE();

0 commit comments

Comments
 (0)