@@ -3613,6 +3613,9 @@ class OffloadingActionBuilder final {
3613
3613
// / List of objects to extract FPGA dependency info from
3614
3614
ActionList FPGAObjectInputs;
3615
3615
3616
+ // / List of static archives to extract FPGA dependency info from
3617
+ ActionList FPGAArchiveInputs;
3618
+
3616
3619
// / List of CUDA architectures to use in this compilation with NVPTX targets.
3617
3620
SmallVector<CudaArch, 8 > GpuArchList;
3618
3621
@@ -4061,15 +4064,19 @@ class OffloadingActionBuilder final {
4061
4064
// triple calls for it (provided a valid subarch).
4062
4065
ActionList BEInputs;
4063
4066
BEInputs.push_back (BuildCodeAction);
4064
- for (Action *A : FPGAObjectInputs) {
4065
- // Send any known objects through the unbundler to grab the
4066
- // dependency file associated.
4067
+ auto unbundleAdd = [&](Action *A, types::ID T) {
4067
4068
ActionList AL;
4068
4069
AL.push_back (A);
4069
- Action *UnbundleAction = C. MakeAction <OffloadUnbundlingJobAction>(
4070
- AL, types::TY_FPGA_Dependencies );
4070
+ Action *UnbundleAction =
4071
+ C. MakeAction <OffloadUnbundlingJobAction>( AL, T );
4071
4072
BEInputs.push_back (UnbundleAction);
4072
- }
4073
+ };
4074
+ // Send any known objects/archives through the unbundler to grab the
4075
+ // dependency file associated.
4076
+ for (Action *A : FPGAObjectInputs)
4077
+ unbundleAdd (A, types::TY_FPGA_Dependencies);
4078
+ for (Action *A : FPGAArchiveInputs)
4079
+ unbundleAdd (A, types::TY_FPGA_Dependencies_List);
4073
4080
for (const auto &A : DeviceLibObjects)
4074
4081
BEInputs.push_back (A);
4075
4082
BuildCodeAction =
@@ -4194,6 +4201,7 @@ class OffloadingActionBuilder final {
4194
4201
Arg *SYCLAddTargets = Args.getLastArg (options::OPT_fsycl_add_targets_EQ);
4195
4202
bool HasValidSYCLRuntime = C.getInputArgs ().hasFlag (options::OPT_fsycl,
4196
4203
options::OPT_fno_sycl, false );
4204
+ bool SYCLfpgaTriple = false ;
4197
4205
if (SYCLTargets || SYCLAddTargets) {
4198
4206
if (SYCLTargets) {
4199
4207
llvm::StringMap<StringRef> FoundNormalizedTriples;
@@ -4211,6 +4219,8 @@ class OffloadingActionBuilder final {
4211
4219
FoundNormalizedTriples[NormalizedName] = Val;
4212
4220
4213
4221
SYCLTripleList.push_back (TT);
4222
+ if (TT.getSubArch () == llvm::Triple::SPIRSubArch_fpga)
4223
+ SYCLfpgaTriple = true ;
4214
4224
}
4215
4225
}
4216
4226
if (SYCLAddTargets) {
@@ -4234,13 +4244,30 @@ class OffloadingActionBuilder final {
4234
4244
const char *SYCLTargetArch = SYCLfpga ? " spir64_fpga" : " spir64" ;
4235
4245
SYCLTripleList.push_back (
4236
4246
C.getDriver ().MakeSYCLDeviceTriple (SYCLTargetArch));
4247
+ if (SYCLfpga)
4248
+ SYCLfpgaTriple = true ;
4237
4249
}
4238
4250
4239
4251
// Set the FPGA output type based on command line (-fsycl-link).
4240
4252
if (auto * A = C.getInputArgs ().getLastArg (options::OPT_fsycl_link_EQ))
4241
4253
FPGAOutType = (A->getValue () == StringRef (" early" ))
4242
4254
? types::TY_FPGA_AOCR : types::TY_FPGA_AOCX;
4243
4255
4256
+ // Populate FPGA static archives that could contain dep files to be
4257
+ // incorporated into the aoc compilation
4258
+ if (SYCLfpgaTriple) {
4259
+ SmallVector<const char *, 16 > LinkArgs (getLinkerArgs (C, Args));
4260
+ for (const StringRef &LA : LinkArgs) {
4261
+ if (isStaticArchiveFile (LA) && hasOffloadSections (C, LA, Args)) {
4262
+ const llvm::opt::OptTable &Opts = C.getDriver ().getOpts ();
4263
+ Arg *InputArg = MakeInputArg (Args, Opts, Args.MakeArgString (LA));
4264
+ Action *Current =
4265
+ C.MakeAction <InputAction>(*InputArg, types::TY_Archive);
4266
+ FPGAArchiveInputs.push_back (Current);
4267
+ }
4268
+ }
4269
+ }
4270
+
4244
4271
DeviceLinkerInputs.resize (ToolChains.size ());
4245
4272
return initializeGpuArchMap ();
4246
4273
}
@@ -5976,12 +6003,14 @@ InputInfo Driver::BuildJobsForActionNoCache(
5976
6003
// Do a check for a dependency file unbundle for FPGA. This is out of line
5977
6004
// from a regular unbundle, so just create and return the name of the
5978
6005
// unbundled file.
5979
- if (JA->getType () == types::TY_FPGA_Dependencies) {
6006
+ if (JA->getType () == types::TY_FPGA_Dependencies ||
6007
+ JA->getType () == types::TY_FPGA_Dependencies_List) {
6008
+ std::string Ext (types::getTypeTempSuffix (JA->getType ()));
5980
6009
std::string TmpFileName =
5981
- C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), " d " );
6010
+ C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), Ext );
5982
6011
const char *TmpFile =
5983
6012
C.addTempFile (C.getArgs ().MakeArgString (TmpFileName));
5984
- Result = InputInfo (types::TY_FPGA_Dependencies , TmpFile, TmpFile);
6013
+ Result = InputInfo (JA-> getType () , TmpFile, TmpFile);
5985
6014
UnbundlingResults.push_back (Result);
5986
6015
} else {
5987
6016
// Now that we have all the results generated, select the one that should
0 commit comments