@@ -3612,6 +3612,9 @@ class OffloadingActionBuilder final {
3612
3612
// / List of objects to extract FPGA dependency info from
3613
3613
ActionList FPGAObjectInputs;
3614
3614
3615
+ // / List of static archives to extract FPGA dependency info from
3616
+ ActionList FPGAArchiveInputs;
3617
+
3615
3618
// / List of CUDA architectures to use in this compilation with NVPTX targets.
3616
3619
SmallVector<CudaArch, 8 > GpuArchList;
3617
3620
@@ -4060,15 +4063,19 @@ class OffloadingActionBuilder final {
4060
4063
// triple calls for it (provided a valid subarch).
4061
4064
ActionList BEInputs;
4062
4065
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) {
4066
4067
ActionList AL;
4067
4068
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 );
4070
4071
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);
4072
4079
for (const auto &A : DeviceLibObjects)
4073
4080
BEInputs.push_back (A);
4074
4081
BuildCodeAction =
@@ -4193,6 +4200,7 @@ class OffloadingActionBuilder final {
4193
4200
Arg *SYCLAddTargets = Args.getLastArg (options::OPT_fsycl_add_targets_EQ);
4194
4201
bool HasValidSYCLRuntime = C.getInputArgs ().hasFlag (options::OPT_fsycl,
4195
4202
options::OPT_fno_sycl, false );
4203
+ bool SYCLfpgaTriple = false ;
4196
4204
if (SYCLTargets || SYCLAddTargets) {
4197
4205
if (SYCLTargets) {
4198
4206
llvm::StringMap<StringRef> FoundNormalizedTriples;
@@ -4210,6 +4218,8 @@ class OffloadingActionBuilder final {
4210
4218
FoundNormalizedTriples[NormalizedName] = Val;
4211
4219
4212
4220
SYCLTripleList.push_back (TT);
4221
+ if (TT.getSubArch () == llvm::Triple::SPIRSubArch_fpga)
4222
+ SYCLfpgaTriple = true ;
4213
4223
}
4214
4224
}
4215
4225
if (SYCLAddTargets) {
@@ -4233,13 +4243,30 @@ class OffloadingActionBuilder final {
4233
4243
const char *SYCLTargetArch = SYCLfpga ? " spir64_fpga" : " spir64" ;
4234
4244
SYCLTripleList.push_back (
4235
4245
C.getDriver ().MakeSYCLDeviceTriple (SYCLTargetArch));
4246
+ if (SYCLfpga)
4247
+ SYCLfpgaTriple = true ;
4236
4248
}
4237
4249
4238
4250
// Set the FPGA output type based on command line (-fsycl-link).
4239
4251
if (auto * A = C.getInputArgs ().getLastArg (options::OPT_fsycl_link_EQ))
4240
4252
FPGAOutType = (A->getValue () == StringRef (" early" ))
4241
4253
? types::TY_FPGA_AOCR : types::TY_FPGA_AOCX;
4242
4254
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
+
4243
4270
DeviceLinkerInputs.resize (ToolChains.size ());
4244
4271
return initializeGpuArchMap ();
4245
4272
}
@@ -5975,12 +6002,14 @@ InputInfo Driver::BuildJobsForActionNoCache(
5975
6002
// Do a check for a dependency file unbundle for FPGA. This is out of line
5976
6003
// from a regular unbundle, so just create and return the name of the
5977
6004
// 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 ()));
5979
6008
std::string TmpFileName =
5980
- C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), " d " );
6009
+ C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), Ext );
5981
6010
const char *TmpFile =
5982
6011
C.addTempFile (C.getArgs ().MakeArgString (TmpFileName));
5983
- Result = InputInfo (types::TY_FPGA_Dependencies , TmpFile, TmpFile);
6012
+ Result = InputInfo (JA-> getType () , TmpFile, TmpFile);
5984
6013
UnbundlingResults.push_back (Result);
5985
6014
} else {
5986
6015
// Now that we have all the results generated, select the one that should
0 commit comments