@@ -834,6 +834,7 @@ static bool isValidSYCLTriple(llvm::Triple T) {
834
834
}
835
835
836
836
static const char *getDefaultSYCLArch (Compilation &C) {
837
+ // If -fsycl is supplied we will assume SPIR-V
837
838
if (C.getDefaultToolChain ().getTriple ().getArch () == llvm::Triple::x86)
838
839
return " spir" ;
839
840
return " spir64" ;
@@ -847,7 +848,7 @@ static bool addSYCLDefaultTriple(Compilation &C,
847
848
if (C.getInputArgs ().hasArg (options::OPT_fsycl_force_target_EQ))
848
849
return false ;
849
850
llvm::Triple DefaultTriple =
850
- C.getDriver ().MakeSYCLDeviceTriple (getDefaultSYCLArch (C));
851
+ C.getDriver ().getSYCLDeviceTriple (getDefaultSYCLArch (C));
851
852
for (const auto &SYCLTriple : SYCLTriples) {
852
853
if (SYCLTriple == DefaultTriple)
853
854
return false ;
@@ -1079,22 +1080,21 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1079
1080
// We need to generate a SYCL toolchain if the user specified -fsycl.
1080
1081
// If -fsycl is supplied without any of these we will assume SPIR-V.
1081
1082
// Use of -fsycl-device-only overrides -fsycl.
1082
- bool HasValidSYCLRuntime =
1083
- C.getInputArgs ().hasFlag (options::OPT_fsycl, options::OPT_fno_sycl,
1084
- false ) ||
1085
- C.getInputArgs ().hasArg (options::OPT_fsycl_device_only);
1083
+ bool IsSYCL = C.getInputArgs ().hasFlag (options::OPT_fsycl,
1084
+ options::OPT_fno_sycl, false ) ||
1085
+ C.getInputArgs ().hasArg (options::OPT_fsycl_device_only);
1086
1086
1087
1087
Arg *SYCLfpga = C.getInputArgs ().getLastArg (options::OPT_fintelfpga);
1088
1088
1089
1089
// Make -fintelfpga flag imply -fsycl.
1090
- if (SYCLfpga && !HasValidSYCLRuntime )
1091
- HasValidSYCLRuntime = true ;
1090
+ if (SYCLfpga && !IsSYCL )
1091
+ IsSYCL = true ;
1092
1092
1093
1093
// A mechanism for retrieving SYCL-specific options, erroring out
1094
1094
// if SYCL offloading wasn't enabled prior to that
1095
1095
auto getArgRequiringSYCLRuntime = [&](OptSpecifier OptId) -> Arg * {
1096
1096
Arg *SYCLArg = C.getInputArgs ().getLastArg (OptId);
1097
- if (SYCLArg && !HasValidSYCLRuntime ) {
1097
+ if (SYCLArg && !IsSYCL ) {
1098
1098
Diag (clang::diag::err_drv_expecting_fsycl_with_sycl_opt)
1099
1099
// Dropping the '=' symbol, which would otherwise pollute
1100
1100
// the diagnostics for the most of options
@@ -1123,7 +1123,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1123
1123
<< " -fsycl-host-compiler" ;
1124
1124
1125
1125
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
1126
- if (!HasValidSYCLRuntime )
1126
+ if (!IsSYCL )
1127
1127
return ;
1128
1128
if (Arg *IncompatArg = C.getInputArgs ().getLastArg (OptId))
1129
1129
Diag (clang::diag::err_drv_argument_not_allowed_with)
@@ -1182,7 +1182,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1182
1182
getArgRequiringSYCLRuntime (options::OPT_fsycl_force_target_EQ);
1183
1183
if (SYCLForceTarget) {
1184
1184
StringRef Val (SYCLForceTarget->getValue ());
1185
- llvm::Triple TT (MakeSYCLDeviceTriple (Val));
1185
+ llvm::Triple TT (getSYCLDeviceTriple (Val));
1186
1186
if (!isValidSYCLTriple (TT))
1187
1187
Diag (clang::diag::err_drv_invalid_sycl_target) << Val;
1188
1188
}
@@ -1240,7 +1240,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1240
1240
continue ;
1241
1241
}
1242
1242
1243
- llvm::Triple DeviceTriple (MakeSYCLDeviceTriple (UserTargetName));
1243
+ llvm::Triple DeviceTriple (getSYCLDeviceTriple (UserTargetName));
1244
1244
if (!isValidSYCLTriple (DeviceTriple)) {
1245
1245
Diag (clang::diag::err_drv_invalid_sycl_target) << Val;
1246
1246
continue ;
@@ -1271,7 +1271,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1271
1271
}
1272
1272
1273
1273
// Make sure we don't have a duplicate triple.
1274
- std::string NormalizedName = MakeSYCLDeviceTriple (Val).normalize ();
1274
+ std::string NormalizedName = getSYCLDeviceTriple (Val).normalize ();
1275
1275
auto Duplicate = FoundNormalizedTriples.find (NormalizedName);
1276
1276
if (Duplicate != FoundNormalizedTriples.end ()) {
1277
1277
Diag (clang::diag::warn_drv_sycl_offload_target_duplicate)
@@ -1303,9 +1303,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1303
1303
// Create a toolchain for each valid triple.
1304
1304
// We do not support SYCL offloading if any of the inputs is a
1305
1305
// .cu (for CUDA type) or .hip (for HIP type) file.
1306
- else if (HasValidSYCLRuntime &&
1307
- C.getInputArgs ().hasArg (options::OPT_offload_arch_EQ) && !IsHIP &&
1308
- !IsCuda) {
1306
+ else if (IsSYCL && C.getInputArgs ().hasArg (options::OPT_offload_arch_EQ) &&
1307
+ !IsHIP && !IsCuda) {
1309
1308
// SYCL offloading to AOT Targets with '--offload-arch'
1310
1309
// is currently enabled only with '--offload-new-driver' option.
1311
1310
// Emit a diagnostic if '--offload-arch' is invoked without
@@ -1352,7 +1351,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1352
1351
getProcessorFromTargetID (*AMDTriple, Arch)))) {
1353
1352
DerivedArchs[AMDTriple->getTriple ()].insert (Arch);
1354
1353
} else if (IsSYCLSupportedIntelCPUArch (StringToOffloadArchSYCL (Arch))) {
1355
- DerivedArchs[MakeSYCLDeviceTriple (" spir64_x86_64" ).getTriple ()].insert (
1354
+ DerivedArchs[getSYCLDeviceTriple (" spir64_x86_64" ).getTriple ()].insert (
1356
1355
Arch);
1357
1356
} else if (IsSYCLSupportedIntelGPUArch (StringToOffloadArchSYCL (Arch))) {
1358
1357
StringRef IntelGPUArch;
@@ -1363,7 +1362,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1363
1362
// offloading to Intel GPUs and the corresponding '-device' value passed
1364
1363
// to OCLOC.
1365
1364
IntelGPUArch = mapIntelGPUArchName (Arch).data ();
1366
- DerivedArchs[MakeSYCLDeviceTriple (" spir64_gen" ).getTriple ()].insert (
1365
+ DerivedArchs[getSYCLDeviceTriple (" spir64_gen" ).getTriple ()].insert (
1367
1366
IntelGPUArch);
1368
1367
} else {
1369
1368
Diag (clang::diag::err_drv_invalid_sycl_target) << Arch;
@@ -1381,7 +1380,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1381
1380
SYCLTriples.insert (TripleAndArchs.first ());
1382
1381
1383
1382
for (const auto &Val : SYCLTriples) {
1384
- llvm::Triple SYCLTargetTriple (MakeSYCLDeviceTriple (Val.getKey ()));
1383
+ llvm::Triple SYCLTargetTriple (getSYCLDeviceTriple (Val.getKey ()));
1385
1384
std::string NormalizedName = SYCLTargetTriple.normalize ();
1386
1385
1387
1386
// Make sure we don't have a duplicate triple.
@@ -1403,12 +1402,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
1403
1402
} else {
1404
1403
// If -fsycl is supplied without -fsycl-targets we will assume SPIR-V.
1405
1404
// For -fsycl-device-only, we also setup the implied triple as needed.
1406
- if (HasValidSYCLRuntime ) {
1405
+ if (IsSYCL ) {
1407
1406
StringRef SYCLTargetArch = getDefaultSYCLArch (C);
1408
1407
if (SYCLfpga)
1409
1408
// Triple for -fintelfpga is spir64_fpga.
1410
1409
SYCLTargetArch = " spir64_fpga" ;
1411
- UniqueSYCLTriplesVec.push_back (MakeSYCLDeviceTriple (SYCLTargetArch));
1410
+ UniqueSYCLTriplesVec.push_back (getSYCLDeviceTriple (SYCLTargetArch));
1412
1411
addSYCLDefaultTriple (C, UniqueSYCLTriplesVec);
1413
1412
}
1414
1413
}
@@ -2529,7 +2528,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
2529
2528
VisibilityMask);
2530
2529
}
2531
2530
2532
- llvm::Triple Driver::MakeSYCLDeviceTriple (StringRef TargetArch) const {
2531
+ llvm::Triple Driver::getSYCLDeviceTriple (StringRef TargetArch) const {
2533
2532
SmallVector<StringRef, 5 > SYCLAlias = {
2534
2533
" spir" , " spir64" , " spir64_fpga" , " spir64_x86_64" ,
2535
2534
" spir64_gen" , " spirv32" , " spirv64" , " nvptx64" };
@@ -2557,13 +2556,13 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
2557
2556
StringRef AV (A->getValue ());
2558
2557
llvm::Triple T;
2559
2558
if (AV == " gen" || AV == " all" )
2560
- HelpArgs.push_back (std::make_tuple (MakeSYCLDeviceTriple (" spir64_gen" ),
2559
+ HelpArgs.push_back (std::make_tuple (getSYCLDeviceTriple (" spir64_gen" ),
2561
2560
" ocloc" , " --help" , " " ));
2562
2561
if (AV == " fpga" || AV == " all" )
2563
- HelpArgs.push_back (std::make_tuple (MakeSYCLDeviceTriple (" spir64_fpga" ),
2562
+ HelpArgs.push_back (std::make_tuple (getSYCLDeviceTriple (" spir64_fpga" ),
2564
2563
" aoc" , " -help" , " -sycl" ));
2565
2564
if (AV == " x86_64" || AV == " all" )
2566
- HelpArgs.push_back (std::make_tuple (MakeSYCLDeviceTriple (" spir64_x86_64" ),
2565
+ HelpArgs.push_back (std::make_tuple (getSYCLDeviceTriple (" spir64_x86_64" ),
2567
2566
" opencl-aot" , " --help" , " " ));
2568
2567
if (HelpArgs.empty ()) {
2569
2568
C.getDriver ().Diag (diag::err_drv_unsupported_option_argument)
@@ -3614,7 +3613,7 @@ static bool hasSYCLDefaultSection(Compilation &C, const StringRef &File) {
3614
3613
if (!(IsArchive || isObjectFile (File.str ())))
3615
3614
return false ;
3616
3615
3617
- llvm::Triple TT (C.getDriver ().MakeSYCLDeviceTriple (getDefaultSYCLArch (C)));
3616
+ llvm::Triple TT (C.getDriver ().getSYCLDeviceTriple (getDefaultSYCLArch (C)));
3618
3617
// Checking uses -check-section option with the input file, no output
3619
3618
// file and the target triple being looked for.
3620
3619
const char *Targets =
@@ -3821,7 +3820,7 @@ bool Driver::checkForSYCLDefaultDevice(Compilation &C,
3821
3820
// or if -fsycl-targets isn't passed (that implies default device)
3822
3821
if (const Arg *A = Args.getLastArg (options::OPT_fsycl_targets_EQ)) {
3823
3822
for (const char *Val : A->getValues ()) {
3824
- llvm::Triple TT (C.getDriver ().MakeSYCLDeviceTriple (Val));
3823
+ llvm::Triple TT (C.getDriver ().getSYCLDeviceTriple (Val));
3825
3824
if ((TT.isSPIROrSPIRV ()) && TT.getSubArch () == llvm::Triple::NoSubArch)
3826
3825
// Default triple found
3827
3826
return false ;
@@ -6303,7 +6302,7 @@ class OffloadingActionBuilder final {
6303
6302
// There are a few different variants for FPGA, if we see one, just
6304
6303
// use the default FPGA triple to reduce possible match confusion.
6305
6304
if (Arch.compare (0 , 4 , " fpga" ) == 0 )
6306
- Arch = C.getDriver ().MakeSYCLDeviceTriple (" spir64_fpga" ).str ();
6305
+ Arch = C.getDriver ().getSYCLDeviceTriple (" spir64_fpga" ).str ();
6307
6306
6308
6307
if (std::find (UniqueSections.begin (), UniqueSections.end (), Arch) ==
6309
6308
UniqueSections.end ())
@@ -6460,8 +6459,9 @@ class OffloadingActionBuilder final {
6460
6459
// Unrecognized, we have already diagnosed this earlier; skip.
6461
6460
continue ;
6462
6461
// Add the proper -device value to the list.
6463
- GpuArchList.emplace_back (C.getDriver ().MakeSYCLDeviceTriple (
6464
- " spir64_gen" ), ValidDevice->data ());
6462
+ GpuArchList.emplace_back (
6463
+ C.getDriver ().getSYCLDeviceTriple (" spir64_gen" ),
6464
+ ValidDevice->data ());
6465
6465
UserTargetName = " spir64_gen" ;
6466
6466
} else if (auto ValidDevice =
6467
6467
gen::isGPUTarget<gen::NvidiaGPU>(Val)) {
@@ -6470,7 +6470,7 @@ class OffloadingActionBuilder final {
6470
6470
continue ;
6471
6471
// Add the proper -device value to the list.
6472
6472
GpuArchList.emplace_back (
6473
- C.getDriver ().MakeSYCLDeviceTriple (" nvptx64-nvidia-cuda" ),
6473
+ C.getDriver ().getSYCLDeviceTriple (" nvptx64-nvidia-cuda" ),
6474
6474
ValidDevice->data ());
6475
6475
UserTargetName = " nvptx64-nvidia-cuda" ;
6476
6476
} else if (auto ValidDevice = gen::isGPUTarget<gen::AmdGPU>(Val)) {
@@ -6479,7 +6479,7 @@ class OffloadingActionBuilder final {
6479
6479
continue ;
6480
6480
// Add the proper -device value to the list.
6481
6481
GpuArchList.emplace_back (
6482
- C.getDriver ().MakeSYCLDeviceTriple (" amdgcn-amd-amdhsa" ),
6482
+ C.getDriver ().getSYCLDeviceTriple (" amdgcn-amd-amdhsa" ),
6483
6483
ValidDevice->data ());
6484
6484
UserTargetName = " amdgcn-amd-amdhsa" ;
6485
6485
} else if (Val == " native_cpu" ) {
@@ -6490,7 +6490,7 @@ class OffloadingActionBuilder final {
6490
6490
continue ;
6491
6491
}
6492
6492
6493
- llvm::Triple TT (C.getDriver ().MakeSYCLDeviceTriple (Val));
6493
+ llvm::Triple TT (C.getDriver ().getSYCLDeviceTriple (Val));
6494
6494
std::string NormalizedName = TT.normalize ();
6495
6495
6496
6496
// Make sure we don't have a duplicate triple.
@@ -6503,7 +6503,7 @@ class OffloadingActionBuilder final {
6503
6503
FoundNormalizedTriples[NormalizedName] = Val;
6504
6504
6505
6505
SYCLTripleList.push_back (
6506
- C.getDriver ().MakeSYCLDeviceTriple (UserTargetName));
6506
+ C.getDriver ().getSYCLDeviceTriple (UserTargetName));
6507
6507
if (TT.getSubArch () == llvm::Triple::SPIRSubArch_fpga)
6508
6508
SYCLfpgaTriple = true ;
6509
6509
// For user specified spir64_gen, add an empty device value as a
@@ -6567,7 +6567,7 @@ class OffloadingActionBuilder final {
6567
6567
// -fsycl -fintelfpga implies spir64_fpga
6568
6568
const char *SYCLTargetArch =
6569
6569
SYCLfpga ? " spir64_fpga" : getDefaultSYCLArch (C);
6570
- llvm::Triple TT = C.getDriver ().MakeSYCLDeviceTriple (SYCLTargetArch);
6570
+ llvm::Triple TT = C.getDriver ().getSYCLDeviceTriple (SYCLTargetArch);
6571
6571
auto TCIt = llvm::find_if (
6572
6572
ToolChains, [&](auto &TC) { return TT == TC->getTriple (); });
6573
6573
assert (TCIt != ToolChains.end () &&
@@ -8372,14 +8372,14 @@ Action *Driver::ConstructPhaseAction(
8372
8372
return C.MakeAction <BackendJobAction>(Input, Output);
8373
8373
}
8374
8374
if (Args.hasArg (options::OPT_emit_llvm) ||
8375
- (( TargetDeviceOffloadKind == Action::OFK_SYCL &&
8376
- C.getDriver ().getUseNewOffloadingDriver ()) ||
8377
- (((Input->getOffloadingToolChain () &&
8378
- Input->getOffloadingToolChain ()->getTriple ().isAMDGPU ()) ||
8379
- TargetDeviceOffloadKind == Action::OFK_HIP) &&
8380
- (Args.hasFlag (options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
8381
- false ) ||
8382
- TargetDeviceOffloadKind == Action::OFK_OpenMP) ))) {
8375
+ (TargetDeviceOffloadKind == Action::OFK_SYCL &&
8376
+ C.getDriver ().getUseNewOffloadingDriver ()) ||
8377
+ (((Input->getOffloadingToolChain () &&
8378
+ Input->getOffloadingToolChain ()->getTriple ().isAMDGPU ()) ||
8379
+ TargetDeviceOffloadKind == Action::OFK_HIP) &&
8380
+ (Args.hasFlag (options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
8381
+ false ) ||
8382
+ TargetDeviceOffloadKind == Action::OFK_OpenMP))) {
8383
8383
types::ID Output =
8384
8384
Args.hasArg (options::OPT_S) &&
8385
8385
(TargetDeviceOffloadKind == Action::OFK_None ||
0 commit comments