@@ -3682,10 +3682,6 @@ class OffloadingActionBuilder final {
3682
3682
// / construction. Does not track AOT binary inputs triples.
3683
3683
SmallVector<llvm::Triple, 4 > SYCLTripleList;
3684
3684
3685
- // / Running count of FPGA device binaries.
3686
- unsigned FPGAxCount = 0 ;
3687
- unsigned FPGArCount = 0 ;
3688
-
3689
3685
// / Type of output file for FPGA device compilation.
3690
3686
types::ID FPGAOutType = types::TY_FPGA_AOCX;
3691
3687
@@ -3916,20 +3912,6 @@ class OffloadingActionBuilder final {
3916
3912
.isWindowsMSVCEnvironment ()))
3917
3913
FPGAObjectInputs.push_back (IA);
3918
3914
}
3919
- // When creating FPGA device fat objects, all host objects are
3920
- // partially linked. Gather that list here.
3921
- if (IA->getType () == types::TY_Object ||
3922
- IA->getType () == types::TY_FPGA_AOCX ||
3923
- IA->getType () == types::TY_FPGA_AOCR) {
3924
- // Keep track of the number of FPGA devices encountered
3925
- // Only one of these is allowed at a single time.
3926
- if (IA->getType () == types::TY_FPGA_AOCX)
3927
- FPGAxCount++;
3928
- if (IA->getType () == types::TY_FPGA_AOCR)
3929
- FPGArCount++;
3930
- if ((FPGAxCount && FPGArCount) || FPGAxCount > 1 || FPGArCount > 1 )
3931
- C.getDriver ().Diag (clang::diag::err_drv_bad_fpga_device_count);
3932
- }
3933
3915
}
3934
3916
for (unsigned I = 0 ; I < ToolChains.size (); ++I) {
3935
3917
SYCLDeviceActions.push_back (UA);
@@ -4089,59 +4071,6 @@ class OffloadingActionBuilder final {
4089
4071
// Current list is empty, nothing to process.
4090
4072
continue ;
4091
4073
4092
- // Perform a check for device kernels. This is done for FPGA when an
4093
- // aocx or aocr based file is found.
4094
- if (FPGAxCount || FPGArCount) {
4095
- ActionList DeviceObjects;
4096
- for (const auto &I : LI) {
4097
- if (I->getType () == types::TY_Object) {
4098
- // Perform a check for SPIR kernel.
4099
- auto *DeviceCheckAction =
4100
- C.MakeAction <SPIRCheckJobAction>(I, types::TY_Object);
4101
- DeviceObjects.push_back (DeviceCheckAction);
4102
- continue ;
4103
- }
4104
- // We want to move the AOCX/AOCR binary to the front of the objects
4105
- // allowing it to be picked up instead of the other device objects
4106
- // at runtime.
4107
- // TODO: In the presense of existing FPGA Device binaries (AOCX)
4108
- // we do not need to perform/add the SPIR-V generated device
4109
- // binaries from sources or objects.
4110
- if (types::isFPGA (I->getType ())) {
4111
- // Do not perform a device link and only pass the aocr
4112
- // file to the offline compilation before wrapping. Just
4113
- // wrap an aocx file.
4114
- Action *DeviceWrappingAction;
4115
- if (I->getType () == types::TY_FPGA_AOCR) {
4116
- auto *DeviceBECompileAction =
4117
- C.MakeAction <BackendCompileJobAction>(I, FPGAOutType);
4118
- DeviceWrappingAction = C.MakeAction <OffloadWrapperJobAction>(
4119
- DeviceBECompileAction, types::TY_Object);
4120
- } else
4121
- DeviceWrappingAction =
4122
- C.MakeAction <OffloadWrapperJobAction>(I, types::TY_Object);
4123
- DA.add (*DeviceWrappingAction, **TC, /* BoundArch=*/ nullptr ,
4124
- Action::OFK_SYCL);
4125
- continue ;
4126
- }
4127
- DeviceObjects.push_back (I);
4128
- }
4129
- if (!DeviceObjects.empty ()) {
4130
- // When aocx or aocr is found, there is an expectation that none of
4131
- // the other objects processed have any kernel. So, there
4132
- // is no need in device code split and backend compile here. Just
4133
- // link and wrap the device binary.
4134
- auto *DeviceLinkAction =
4135
- C.MakeAction <LinkJobAction>(DeviceObjects, types::TY_LLVM_BC);
4136
- auto *SPIRVTranslateAction = C.MakeAction <SPIRVTranslatorJobAction>(
4137
- DeviceLinkAction, types::TY_SPIRV);
4138
- auto *DeviceWrappingAction = C.MakeAction <OffloadWrapperJobAction>(
4139
- SPIRVTranslateAction, types::TY_Object);
4140
- DA.add (*DeviceWrappingAction, **TC, /* BoundArch=*/ nullptr ,
4141
- Action::OFK_SYCL);
4142
- }
4143
- continue ;
4144
- }
4145
4074
ActionList DeviceLibObjects;
4146
4075
ActionList LinkObjects;
4147
4076
auto TT = SYCLTripleList[I];
@@ -4153,9 +4082,33 @@ class OffloadingActionBuilder final {
4153
4082
// FPGA aoco does not go through the link, everything else does.
4154
4083
if (Input->getType () == types::TY_FPGA_AOCO)
4155
4084
DeviceLibObjects.push_back (Input);
4156
- else
4085
+ // FPGA aocr/aocx does not go through the link and is passed
4086
+ // directly to the backend compilation step (aocr) or wrapper (aocx)
4087
+ else if (types::isFPGA (Input->getType ())) {
4088
+ Action *FPGAAOTAction;
4089
+ constexpr char COL_CODE[] = " Code" ;
4090
+ constexpr char COL_ZERO[] = " 0" ;
4091
+ if (Input->getType () == types::TY_FPGA_AOCR)
4092
+ // Generate AOCX/AOCR
4093
+ FPGAAOTAction =
4094
+ C.MakeAction <BackendCompileJobAction>(Input, FPGAOutType);
4095
+ else if (Input->getType () == types::TY_FPGA_AOCX)
4096
+ FPGAAOTAction = Input;
4097
+ else
4098
+ llvm_unreachable (" Unexpected FPGA input type." );
4099
+ auto *RenameAction = C.MakeAction <FileTableTformJobAction>(
4100
+ FPGAAOTAction, types::TY_Tempfilelist);
4101
+ RenameAction->addRenameColumnTform (COL_ZERO, COL_CODE);
4102
+ auto *DeviceWrappingAction = C.MakeAction <OffloadWrapperJobAction>(
4103
+ RenameAction, types::TY_Object);
4104
+ DA.add (*DeviceWrappingAction, **TC, /* BoundArch=*/ nullptr ,
4105
+ Action::OFK_SYCL);
4106
+ } else
4157
4107
LinkObjects.push_back (Input);
4158
4108
}
4109
+ if (LinkObjects.empty ())
4110
+ continue ;
4111
+
4159
4112
// The linkage actions subgraph leading to the offload wrapper.
4160
4113
// [cond] Means incoming/outgoing dependence is created only when cond
4161
4114
// is true. A function of:
@@ -5145,9 +5098,10 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
5145
5098
// archive unbundling for Windows.
5146
5099
if (!isStaticArchiveFile (LA))
5147
5100
continue ;
5148
- // FPGA AOCX files are archives, but we do not want to unbundle them here
5149
- // as they have already been unbundled and processed for linking.
5150
- if (hasFPGABinary (C, LA.str (), types::TY_FPGA_AOCX))
5101
+ // FPGA AOCX/AOCR files are archives, but we do not want to unbundle them
5102
+ // here as they have already been unbundled and processed for linking.
5103
+ if (hasFPGABinary (C, LA.str (), types::TY_FPGA_AOCX) ||
5104
+ hasFPGABinary (C, LA.str (), types::TY_FPGA_AOCR))
5151
5105
continue ;
5152
5106
// For offload-static-libs we add an unbundling action for each static
5153
5107
// archive which produces list files with extracted objects. Device lists
@@ -6151,6 +6105,9 @@ InputInfo Driver::BuildJobsForActionNoCache(
6151
6105
TI = types::TY_TempAOCOfilelist;
6152
6106
Ext = " txt" ;
6153
6107
}
6108
+ if (JA->getType () == types::TY_FPGA_AOCR)
6109
+ // AOCR files are always unbundled into a list file.
6110
+ TI = types::TY_Tempfilelist;
6154
6111
} else if (EffectiveTriple.getSubArch () !=
6155
6112
llvm::Triple::SPIRSubArch_fpga) {
6156
6113
if (UI.DependentOffloadKind == Action::OFK_SYCL) {
0 commit comments