@@ -2810,10 +2810,8 @@ bool Driver::checkForOffloadStaticLib(Compilation &C,
2810
2810
if (isStaticArchiveFile (OLArg) && hasOffloadSections (C, OLArg, Args)) {
2811
2811
// FPGA binaries with AOCX or AOCR sections are not considered fat
2812
2812
// static archives.
2813
- if (Args.hasArg (options::OPT_fintelfpga))
2814
- return !(hasFPGABinary (C, OLArg.str (), types::TY_FPGA_AOCR) ||
2815
- hasFPGABinary (C, OLArg.str (), types::TY_FPGA_AOCX));
2816
- return true ;
2813
+ return !(hasFPGABinary (C, OLArg.str (), types::TY_FPGA_AOCR) ||
2814
+ hasFPGABinary (C, OLArg.str (), types::TY_FPGA_AOCX));
2817
2815
}
2818
2816
return false ;
2819
2817
}
@@ -3877,11 +3875,12 @@ class OffloadingActionBuilder final {
3877
3875
ActionList FullSYCLLinkBinaryList;
3878
3876
bool SYCLDeviceLibLinked = false ;
3879
3877
FullSYCLLinkBinaryList.push_back (DeviceLinkAction);
3880
- // If used without -fintelfpga, -fsycl-link is used to wrap device
3881
- // objects for future host link. Device libraries should be linked
3882
- // by default to resolve any undefined reference.
3883
- if (!Args.hasArg (options::OPT_fintelfpga)) {
3884
- const auto *TC = ToolChains.front ();
3878
+ // If used without the FPGA target, -fsycl-link is used to wrap
3879
+ // device objects for future host link. Device libraries should
3880
+ // be linked by default to resolve any undefined reference.
3881
+ const auto *TC = ToolChains.front ();
3882
+ if (TC->getTriple ().getSubArch () !=
3883
+ llvm::Triple::SPIRSubArch_fpga) {
3885
3884
SYCLDeviceLibLinked =
3886
3885
addSYCLDeviceLibs (TC, FullSYCLLinkBinaryList, true ,
3887
3886
C.getDefaultToolChain ()
@@ -3984,8 +3983,9 @@ class OffloadingActionBuilder final {
3984
3983
return ABRT_Inactive;
3985
3984
// For SYCL device libraries, don't need to add them to
3986
3985
// FPGAObjectInputs as there is no FPGA dep files inside.
3987
-
3988
- if (Args.hasArg (options::OPT_fintelfpga) &&
3986
+ const auto *TC = ToolChains.front ();
3987
+ if (TC->getTriple ().getSubArch () ==
3988
+ llvm::Triple::SPIRSubArch_fpga &&
3989
3989
!IsSYCLDeviceLibObj (FileName, C.getDefaultToolChain ()
3990
3990
.getTriple ()
3991
3991
.isWindowsMSVCEnvironment ()))
@@ -4332,7 +4332,7 @@ class OffloadingActionBuilder final {
4332
4332
BEInputs.push_back (UnbundleAction);
4333
4333
};
4334
4334
// Send any known objects/archives through the unbundler to grab the
4335
- // dependency file associated.
4335
+ // dependency file associated. This is only done for -fintelfpga.
4336
4336
for (Action *A : FPGAObjectInputs)
4337
4337
unbundleAdd (A, types::TY_FPGA_Dependencies);
4338
4338
for (Action *A : FPGAArchiveInputs)
@@ -4460,11 +4460,6 @@ class OffloadingActionBuilder final {
4460
4460
// -fsycl-device-code-split=per_source
4461
4461
DeviceCodeSplit = DeviceCodeSplitArg &&
4462
4462
DeviceCodeSplitArg->getValue () != StringRef (" off" );
4463
- // Device only compilation for -fsycl-link (no FPGA) and
4464
- // -fsycl-link-targets
4465
- CompileDeviceOnly =
4466
- (SYCLLinkTargets ||
4467
- (WrapDeviceOnlyBinary && !Args.hasArg (options::OPT_fintelfpga)));
4468
4463
// Gather information about the SYCL Ahead of Time targets. The targets
4469
4464
// are determined on the SubArch values passed along in the triple.
4470
4465
Arg *SYCLTargets =
@@ -4519,14 +4514,19 @@ class OffloadingActionBuilder final {
4519
4514
SYCLfpgaTriple = true ;
4520
4515
}
4521
4516
4517
+ // Device only compilation for -fsycl-link (no FPGA) and
4518
+ // -fsycl-link-targets
4519
+ CompileDeviceOnly =
4520
+ (SYCLLinkTargets || (WrapDeviceOnlyBinary && !SYCLfpgaTriple));
4521
+
4522
4522
// Set the FPGA output type based on command line (-fsycl-link).
4523
4523
if (auto * A = C.getInputArgs ().getLastArg (options::OPT_fsycl_link_EQ))
4524
4524
FPGAOutType = (A->getValue () == StringRef (" early" ))
4525
4525
? types::TY_FPGA_AOCR : types::TY_FPGA_AOCX;
4526
4526
4527
4527
// Populate FPGA static archives that could contain dep files to be
4528
4528
// incorporated into the aoc compilation
4529
- if (SYCLfpgaTriple) {
4529
+ if (SYCLfpgaTriple && Args. hasArg (options::OPT_fintelfpga) ) {
4530
4530
SmallVector<const char *, 16 > LinkArgs (getLinkerArgs (C, Args));
4531
4531
for (StringRef LA : LinkArgs) {
4532
4532
if (isStaticArchiveFile (LA) && hasOffloadSections (C, LA, Args)) {
@@ -4685,6 +4685,7 @@ class OffloadingActionBuilder final {
4685
4685
// is a bundle or not and if the input is not a bundle it assumes it is a
4686
4686
// host file. Therefore it is safe to create an unbundling action even if
4687
4687
// the input is not a bundle.
4688
+ bool HasFPGATarget = false ;
4688
4689
if (CanUseBundler && isa<InputAction>(HostAction) &&
4689
4690
InputArg->getOption ().getKind () == llvm::opt::Option::InputClass &&
4690
4691
!InputArg->getOption ().hasFlag (options::LinkerInput) &&
@@ -4694,9 +4695,12 @@ class OffloadingActionBuilder final {
4694
4695
ActionList HostActionList;
4695
4696
Action *A (HostAction);
4696
4697
// Only check for FPGA device information when using fpga SubArch.
4697
- if (Args.hasArg (options::OPT_fintelfpga) &&
4698
- !(HostAction->getType () == types::TY_Object &&
4699
- isObjectFile (InputName))) {
4698
+ auto SYCLTCRange = C.getOffloadToolChains <Action::OFK_SYCL>();
4699
+ for (auto TI = SYCLTCRange.first , TE = SYCLTCRange.second ; TI != TE; ++TI)
4700
+ HasFPGATarget |= TI->second ->getTriple ().getSubArch () ==
4701
+ llvm::Triple::SPIRSubArch_fpga;
4702
+ if (HasFPGATarget && !(HostAction->getType () == types::TY_Object &&
4703
+ isObjectFile (InputName))) {
4700
4704
// Type FPGA aoco is a special case for -foffload-static-lib.
4701
4705
if (HostAction->getType () == types::TY_FPGA_AOCO) {
4702
4706
if (!hasFPGABinary (C, InputName, types::TY_FPGA_AOCO))
@@ -4741,10 +4745,9 @@ class OffloadingActionBuilder final {
4741
4745
// For unbundling of an FPGA AOCX binary, we want to link with the original
4742
4746
// FPGA device archive.
4743
4747
if ((OffloadKind == Action::OFK_None && CanUseBundler) ||
4744
- (Args.hasArg (options::OPT_fintelfpga) &&
4745
- ((Args.hasArg (options::OPT_fsycl_link_EQ) &&
4746
- HostAction->getType () == types::TY_Object) ||
4747
- HostAction->getType () == types::TY_FPGA_AOCX)))
4748
+ (HasFPGATarget && ((Args.hasArg (options::OPT_fsycl_link_EQ) &&
4749
+ HostAction->getType () == types::TY_Object) ||
4750
+ HostAction->getType () == types::TY_FPGA_AOCX)))
4748
4751
if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction))
4749
4752
HostAction = UA->getInputs ().back ();
4750
4753
@@ -5187,13 +5190,13 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
5187
5190
// are then added to the appropriate device link actions and host list is
5188
5191
// ignored since we are adding offload-static-libs as normal libraries to
5189
5192
// the host link command.
5190
- if (hasOffloadSections (C, LA, Args))
5193
+ if (hasOffloadSections (C, LA, Args)) {
5191
5194
unbundleStaticLib (types::TY_Archive, LA);
5192
- // Pass along the static libraries to check if we need to add them for
5193
- // unbundling for FPGA AOT static lib usage. Uses FPGA aoco type to
5194
- // differentiate if aoco unbundling is needed.
5195
- if (Args.hasArg (options::OPT_fintelfpga))
5195
+ // Pass along the static libraries to check if we need to add them for
5196
+ // unbundling for FPGA AOT static lib usage. Uses FPGA aoco type to
5197
+ // differentiate if aoco unbundling is needed.
5196
5198
unbundleStaticLib (types::TY_FPGA_AOCO, LA);
5199
+ }
5197
5200
}
5198
5201
5199
5202
// For an FPGA archive, we add the unbundling step above to take care of
@@ -6152,16 +6155,17 @@ InputInfo Driver::BuildJobsForActionNoCache(
6152
6155
// unbundling action does not change the type of the output which can
6153
6156
// cause a overwrite.
6154
6157
InputInfo CurI;
6155
- bool IsFPGAObjLink = (JA->getType () == types::TY_Object &&
6156
- C.getInputArgs ().hasArg (options::OPT_fintelfpga) &&
6157
- C.getInputArgs ().hasArg (options::OPT_fsycl_link_EQ));
6158
+ bool IsFPGAObjLink =
6159
+ (JA->getType () == types::TY_Object &&
6160
+ EffectiveTriple.getSubArch () == llvm::Triple::SPIRSubArch_fpga &&
6161
+ C.getInputArgs ().hasArg (options::OPT_fsycl_link_EQ));
6158
6162
if (C.getDriver ().getOffloadStaticLibSeen () &&
6159
6163
JA->getType () == types::TY_Archive) {
6160
6164
// Host part of the unbundled static archive is not used.
6161
6165
if (UI.DependentOffloadKind == Action::OFK_Host)
6162
6166
continue ;
6163
- // Host part of the unbundled object when -fintelfpga -fsycl-link is
6164
- // enabled is not used
6167
+ // Host part of the unbundled object is not used when using the
6168
+ // FPGA target and -fsycl-link is enabled.
6165
6169
if (UI.DependentOffloadKind == Action::OFK_Host && IsFPGAObjLink)
6166
6170
continue ;
6167
6171
std::string TmpFileName = C.getDriver ().GetTemporaryPath (
@@ -6203,8 +6207,8 @@ InputInfo Driver::BuildJobsForActionNoCache(
6203
6207
C.addTempFile (C.getArgs ().MakeArgString (TmpFileName));
6204
6208
CurI = InputInfo (TI, TmpFile, TmpFile);
6205
6209
} else {
6206
- // Host part of the unbundled object is not used when -fintelfpga
6207
- // -fsycl-link is enabled
6210
+ // Host part of the unbundled object is not used when -fsycl-link is
6211
+ // enabled with FPGA target
6208
6212
if (UI.DependentOffloadKind == Action::OFK_Host && IsFPGAObjLink)
6209
6213
continue ;
6210
6214
std::string OffloadingPrefix = Action::GetOffloadingFileNamePrefix (
0 commit comments