@@ -3612,6 +3612,9 @@ class OffloadingActionBuilder final {
36123612 // / List of objects to extract FPGA dependency info from
36133613 ActionList FPGAObjectInputs;
36143614
3615+ // / List of static archives to extract FPGA dependency info from
3616+ ActionList FPGAArchiveInputs;
3617+
36153618 // / List of CUDA architectures to use in this compilation with NVPTX targets.
36163619 SmallVector<CudaArch, 8 > GpuArchList;
36173620
@@ -4060,15 +4063,19 @@ class OffloadingActionBuilder final {
40604063 // triple calls for it (provided a valid subarch).
40614064 ActionList BEInputs;
40624065 BEInputs.push_back (BuildCodeAction);
4063- for (Action *A : FPGAObjectInputs) {
4064- // Send any known objects through the unbundler to grab the
4065- // dependency file associated.
4066+ auto unbundleAdd = [&](Action *A, types::ID T) {
40664067 ActionList AL;
40674068 AL.push_back (A);
4068- Action *UnbundleAction = C. MakeAction <OffloadUnbundlingJobAction>(
4069- AL, types::TY_FPGA_Dependencies );
4069+ Action *UnbundleAction =
4070+ C. MakeAction <OffloadUnbundlingJobAction>( AL, T );
40704071 BEInputs.push_back (UnbundleAction);
4071- }
4072+ };
4073+ // Send any known objects/archives through the unbundler to grab the
4074+ // dependency file associated.
4075+ for (Action *A : FPGAObjectInputs)
4076+ unbundleAdd (A, types::TY_FPGA_Dependencies);
4077+ for (Action *A : FPGAArchiveInputs)
4078+ unbundleAdd (A, types::TY_FPGA_Dependencies_List);
40724079 for (const auto &A : DeviceLibObjects)
40734080 BEInputs.push_back (A);
40744081 BuildCodeAction =
@@ -4193,6 +4200,7 @@ class OffloadingActionBuilder final {
41934200 Arg *SYCLAddTargets = Args.getLastArg (options::OPT_fsycl_add_targets_EQ);
41944201 bool HasValidSYCLRuntime = C.getInputArgs ().hasFlag (options::OPT_fsycl,
41954202 options::OPT_fno_sycl, false );
4203+ bool SYCLfpgaTriple = false ;
41964204 if (SYCLTargets || SYCLAddTargets) {
41974205 if (SYCLTargets) {
41984206 llvm::StringMap<StringRef> FoundNormalizedTriples;
@@ -4210,6 +4218,8 @@ class OffloadingActionBuilder final {
42104218 FoundNormalizedTriples[NormalizedName] = Val;
42114219
42124220 SYCLTripleList.push_back (TT);
4221+ if (TT.getSubArch () == llvm::Triple::SPIRSubArch_fpga)
4222+ SYCLfpgaTriple = true ;
42134223 }
42144224 }
42154225 if (SYCLAddTargets) {
@@ -4233,13 +4243,30 @@ class OffloadingActionBuilder final {
42334243 const char *SYCLTargetArch = SYCLfpga ? " spir64_fpga" : " spir64" ;
42344244 SYCLTripleList.push_back (
42354245 C.getDriver ().MakeSYCLDeviceTriple (SYCLTargetArch));
4246+ if (SYCLfpga)
4247+ SYCLfpgaTriple = true ;
42364248 }
42374249
42384250 // Set the FPGA output type based on command line (-fsycl-link).
42394251 if (auto * A = C.getInputArgs ().getLastArg (options::OPT_fsycl_link_EQ))
42404252 FPGAOutType = (A->getValue () == StringRef (" early" ))
42414253 ? types::TY_FPGA_AOCR : types::TY_FPGA_AOCX;
42424254
4255+ // Populate FPGA static archives that could contain dep files to be
4256+ // incorporated into the aoc compilation
4257+ if (SYCLfpgaTriple) {
4258+ SmallVector<const char *, 16 > LinkArgs (getLinkerArgs (C, Args));
4259+ for (const StringRef &LA : LinkArgs) {
4260+ if (isStaticArchiveFile (LA) && hasOffloadSections (C, LA, Args)) {
4261+ const llvm::opt::OptTable &Opts = C.getDriver ().getOpts ();
4262+ Arg *InputArg = MakeInputArg (Args, Opts, Args.MakeArgString (LA));
4263+ Action *Current =
4264+ C.MakeAction <InputAction>(*InputArg, types::TY_Archive);
4265+ FPGAArchiveInputs.push_back (Current);
4266+ }
4267+ }
4268+ }
4269+
42434270 DeviceLinkerInputs.resize (ToolChains.size ());
42444271 return initializeGpuArchMap ();
42454272 }
@@ -5975,12 +6002,14 @@ InputInfo Driver::BuildJobsForActionNoCache(
59756002 // Do a check for a dependency file unbundle for FPGA. This is out of line
59766003 // from a regular unbundle, so just create and return the name of the
59776004 // unbundled file.
5978- if (JA->getType () == types::TY_FPGA_Dependencies) {
6005+ if (JA->getType () == types::TY_FPGA_Dependencies ||
6006+ JA->getType () == types::TY_FPGA_Dependencies_List) {
6007+ std::string Ext (types::getTypeTempSuffix (JA->getType ()));
59796008 std::string TmpFileName =
5980- C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), " d " );
6009+ C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), Ext );
59816010 const char *TmpFile =
59826011 C.addTempFile (C.getArgs ().MakeArgString (TmpFileName));
5983- Result = InputInfo (types::TY_FPGA_Dependencies , TmpFile, TmpFile);
6012+ Result = InputInfo (JA-> getType () , TmpFile, TmpFile);
59846013 UnbundlingResults.push_back (Result);
59856014 } else {
59866015 // Now that we have all the results generated, select the one that should
0 commit comments