Skip to content

Commit d7c124c

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into glyons/offset
2 parents 3538c2d + 998c97f commit d7c124c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2377
-1431
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11036,9 +11036,10 @@ def err_sycl_compiletime_property_duplication : Error<
1103611036
def err_sycl_invalid_property_list_param_number : Error<
1103711037
"%0 must have exactly one template parameter">;
1103811038
def err_sycl_invalid_accessor_property_template_param : Error<
11039-
"Fifth template parameter of the accessor must be of a property_list type">;
11040-
def err_sycl_invalid_property_list_template_param : Error<
11041-
"%select{property_list|property_list pack argument|buffer_location}0 "
11039+
"sixth template parameter of the accessor must be of accessor_property_list "
11040+
"type">;
11041+
def err_sycl_invalid_accessor_property_list_template_param : Error<
11042+
"%select{accessor_property_list|accessor_property_list pack argument|buffer_location}0 "
1104211043
"template parameter must be a "
1104311044
"%select{parameter pack|type|non-negative integer}1">;
1104411045
def warn_sycl_pass_by_value_deprecated

clang/include/clang/Driver/Types.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@ TYPE("fpga_aocx", FPGA_AOCX, INVALID, "aocx", phases
111111
TYPE("fpga_aocr", FPGA_AOCR, INVALID, "aocr", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
112112
TYPE("fpga_aoco", FPGA_AOCO, INVALID, "aoco", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
113113
TYPE("fpga_dependencies", FPGA_Dependencies, INVALID, "d", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
114+
TYPE("fpga_dependencies_list", FPGA_Dependencies_List, INVALID, "txt", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
114115
TYPE("none", Nothing, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)

clang/lib/Driver/Compilation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ bool Compilation::CleanupFileList(const TempFileList &Files,
150150
// Temporary file lists contain files that need to be cleaned. The
151151
// file containing the information is also removed
152152
if (File.second == types::TY_Tempfilelist ||
153-
File.second == types::TY_Tempfiletable) {
153+
File.second == types::TY_Tempfiletable ||
154+
File.second == types::TY_FPGA_Dependencies_List) {
154155
// These are temporary files and need to be removed.
155156
bool IsTable = File.second == types::TY_Tempfiletable;
156157

clang/lib/Driver/Driver.cpp

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,6 +3613,9 @@ class OffloadingActionBuilder final {
36133613
/// List of objects to extract FPGA dependency info from
36143614
ActionList FPGAObjectInputs;
36153615

3616+
/// List of static archives to extract FPGA dependency info from
3617+
ActionList FPGAArchiveInputs;
3618+
36163619
/// List of CUDA architectures to use in this compilation with NVPTX targets.
36173620
SmallVector<CudaArch, 8> GpuArchList;
36183621

@@ -4061,15 +4064,19 @@ class OffloadingActionBuilder final {
40614064
// triple calls for it (provided a valid subarch).
40624065
ActionList BEInputs;
40634066
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) {
40674068
ActionList AL;
40684069
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);
40714072
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);
40734080
for (const auto &A : DeviceLibObjects)
40744081
BEInputs.push_back(A);
40754082
BuildCodeAction =
@@ -4194,6 +4201,7 @@ class OffloadingActionBuilder final {
41944201
Arg *SYCLAddTargets = Args.getLastArg(options::OPT_fsycl_add_targets_EQ);
41954202
bool HasValidSYCLRuntime = C.getInputArgs().hasFlag(options::OPT_fsycl,
41964203
options::OPT_fno_sycl, false);
4204+
bool SYCLfpgaTriple = false;
41974205
if (SYCLTargets || SYCLAddTargets) {
41984206
if (SYCLTargets) {
41994207
llvm::StringMap<StringRef> FoundNormalizedTriples;
@@ -4211,6 +4219,8 @@ class OffloadingActionBuilder final {
42114219
FoundNormalizedTriples[NormalizedName] = Val;
42124220

42134221
SYCLTripleList.push_back(TT);
4222+
if (TT.getSubArch() == llvm::Triple::SPIRSubArch_fpga)
4223+
SYCLfpgaTriple = true;
42144224
}
42154225
}
42164226
if (SYCLAddTargets) {
@@ -4234,13 +4244,30 @@ class OffloadingActionBuilder final {
42344244
const char *SYCLTargetArch = SYCLfpga ? "spir64_fpga" : "spir64";
42354245
SYCLTripleList.push_back(
42364246
C.getDriver().MakeSYCLDeviceTriple(SYCLTargetArch));
4247+
if (SYCLfpga)
4248+
SYCLfpgaTriple = true;
42374249
}
42384250

42394251
// Set the FPGA output type based on command line (-fsycl-link).
42404252
if (auto * A = C.getInputArgs().getLastArg(options::OPT_fsycl_link_EQ))
42414253
FPGAOutType = (A->getValue() == StringRef("early"))
42424254
? types::TY_FPGA_AOCR : types::TY_FPGA_AOCX;
42434255

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+
42444271
DeviceLinkerInputs.resize(ToolChains.size());
42454272
return initializeGpuArchMap();
42464273
}
@@ -5976,12 +6003,14 @@ InputInfo Driver::BuildJobsForActionNoCache(
59766003
// Do a check for a dependency file unbundle for FPGA. This is out of line
59776004
// from a regular unbundle, so just create and return the name of the
59786005
// 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()));
59806009
std::string TmpFileName =
5981-
C.getDriver().GetTemporaryPath(llvm::sys::path::stem(BaseInput), "d");
6010+
C.getDriver().GetTemporaryPath(llvm::sys::path::stem(BaseInput), Ext);
59826011
const char *TmpFile =
59836012
C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
5984-
Result = InputInfo(types::TY_FPGA_Dependencies, TmpFile, TmpFile);
6013+
Result = InputInfo(JA->getType(), TmpFile, TmpFile);
59856014
UnbundlingResults.push_back(Result);
59866015
} else {
59876016
// Now that we have all the results generated, select the one that should

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,7 +4155,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
41554155
CmdArgs.push_back("-fenable-sycl-dae");
41564156

41574157
// Pass the triple of host when doing SYCL
4158-
auto AuxT = llvm::Triple(llvm::sys::getProcessTriple());
4158+
llvm::Triple AuxT = C.getDefaultToolChain().getTriple();
4159+
if (Args.hasFlag(options::OPT_fsycl_device_only, OptSpecifier(), false))
4160+
AuxT = llvm::Triple(llvm::sys::getProcessTriple());
41594161
std::string NormalizedTriple = AuxT.normalize();
41604162
CmdArgs.push_back("-aux-triple");
41614163
CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
@@ -7399,7 +7401,8 @@ void OffloadBundler::ConstructJobMultipleOutputs(
73997401
bool IsMSVCEnv =
74007402
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
74017403
types::ID InputType(Input.getType());
7402-
bool IsFPGADepUnbundle = (JA.getType() == types::TY_FPGA_Dependencies);
7404+
bool IsFPGADepUnbundle = JA.getType() == types::TY_FPGA_Dependencies;
7405+
bool IsFPGADepLibUnbundle = JA.getType() == types::TY_FPGA_Dependencies_List;
74037406
bool IsArchiveUnbundle =
74047407
(!IsMSVCEnv && C.getDriver().getOffloadStaticLibSeen() &&
74057408
(types::isArchive(InputType) || InputType == types::TY_Object));
@@ -7415,7 +7418,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
74157418
else
74167419
TypeArg = "aoo";
74177420
}
7418-
if (InputType == types::TY_FPGA_AOCO ||
7421+
if (InputType == types::TY_FPGA_AOCO || IsFPGADepLibUnbundle ||
74197422
(IsMSVCEnv && types::isArchive(InputType)))
74207423
TypeArg = "aoo";
74217424
if (IsFPGADepUnbundle)
@@ -7474,7 +7477,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
74747477
Triples += Dep.DependentBoundArch;
74757478
}
74767479
}
7477-
if (IsFPGADepUnbundle) {
7480+
if (IsFPGADepUnbundle || IsFPGADepLibUnbundle) {
74787481
// TODO - We are currently using the target triple inputs to slot a location
74797482
// of the dependency information into the bundle. It would be good to
74807483
// separate this out to an explicit option in the bundler for the dependency
@@ -7495,7 +7498,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
74957498
// When dealing with -fintelfpga, there is an additional unbundle step
74967499
// that occurs for the dependency file. In that case, do not use the
74977500
// dependent information, but just the output file.
7498-
if (IsFPGADepUnbundle)
7501+
if (IsFPGADepUnbundle || IsFPGADepLibUnbundle)
74997502
UB += Outputs[0].getFilename();
75007503
else {
75017504
for (unsigned I = 0; I < Outputs.size(); ++I) {

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
233233
// Add any FPGA library lists. These come in as special tempfile lists.
234234
CmdArgs.push_back(Args.MakeArgString(Twine("-library-list=") +
235235
Filename));
236-
else if (II.getType() == types::TY_FPGA_Dependencies)
236+
else if (II.getType() == types::TY_FPGA_Dependencies ||
237+
II.getType() == types::TY_FPGA_Dependencies_List)
237238
FPGADepFiles.push_back(II);
238239
else
239240
CmdArgs.push_back(C.getArgs().MakeArgString(Filename));
@@ -287,6 +288,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
287288
for (unsigned I = 0; I < FPGADepFiles.size(); ++I) {
288289
if (I)
289290
DepOpt += ',';
291+
if (FPGADepFiles[I].getType() == types::TY_FPGA_Dependencies_List)
292+
DepOpt += "@";
290293
DepOpt += FPGADepFiles[I].getFilename();
291294
}
292295
CmdArgs.push_back(C.getArgs().MakeArgString(DepOpt));

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class Util {
8282
static bool isSyclHalfType(const QualType &Ty);
8383

8484
/// Checks whether given clang type is a full specialization of the SYCL
85-
/// property_list class.
86-
static bool isPropertyListType(const QualType &Ty);
85+
/// accessor_property_list class.
86+
static bool isAccessorPropertyListType(const QualType &Ty);
8787

8888
/// Checks whether given clang type is a full specialization of the SYCL
8989
/// buffer_location class.
@@ -1194,29 +1194,31 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
11941194
return;
11951195
}
11961196
QualType PropListTy = PropList.getAsType();
1197-
if (!Util::isPropertyListType(PropListTy)) {
1197+
if (!Util::isAccessorPropertyListType(PropListTy)) {
11981198
SemaRef.Diag(Loc,
11991199
diag::err_sycl_invalid_accessor_property_template_param);
12001200
return;
12011201
}
1202-
const auto *PropListDecl =
1202+
const auto *AccPropListDecl =
12031203
cast<ClassTemplateSpecializationDecl>(PropListTy->getAsRecordDecl());
1204-
if (PropListDecl->getTemplateArgs().size() != 1) {
1204+
if (AccPropListDecl->getTemplateArgs().size() != 1) {
12051205
SemaRef.Diag(Loc, diag::err_sycl_invalid_property_list_param_number)
1206-
<< "property_list";
1206+
<< "accessor_property_list";
12071207
return;
12081208
}
1209-
const auto TemplArg = PropListDecl->getTemplateArgs()[0];
1209+
const auto TemplArg = AccPropListDecl->getTemplateArgs()[0];
12101210
if (TemplArg.getKind() != TemplateArgument::ArgKind::Pack) {
1211-
SemaRef.Diag(Loc, diag::err_sycl_invalid_property_list_template_param)
1212-
<< /*property_list*/ 0 << /*parameter pack*/ 0;
1211+
SemaRef.Diag(Loc,
1212+
diag::err_sycl_invalid_accessor_property_list_template_param)
1213+
<< /*accessor_property_list*/ 0 << /*parameter pack*/ 0;
12131214
return;
12141215
}
12151216
for (TemplateArgument::pack_iterator Prop = TemplArg.pack_begin();
12161217
Prop != TemplArg.pack_end(); ++Prop) {
12171218
if (Prop->getKind() != TemplateArgument::ArgKind::Type) {
1218-
SemaRef.Diag(Loc, diag::err_sycl_invalid_property_list_template_param)
1219-
<< /*property_list pack argument*/ 1 << /*type*/ 1;
1219+
SemaRef.Diag(
1220+
Loc, diag::err_sycl_invalid_accessor_property_list_template_param)
1221+
<< /*accessor_property_list pack argument*/ 1 << /*type*/ 1;
12201222
return;
12211223
}
12221224
QualType PropTy = Prop->getAsType();
@@ -1235,13 +1237,15 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
12351237
}
12361238
const auto BufferLoc = PropDecl->getTemplateArgs()[0];
12371239
if (BufferLoc.getKind() != TemplateArgument::ArgKind::Integral) {
1238-
SemaRef.Diag(Loc, diag::err_sycl_invalid_property_list_template_param)
1240+
SemaRef.Diag(Loc,
1241+
diag::err_sycl_invalid_accessor_property_list_template_param)
12391242
<< /*buffer_location*/ 2 << /*non-negative integer*/ 2;
12401243
return;
12411244
}
12421245
int LocationID = static_cast<int>(BufferLoc.getAsIntegral().getExtValue());
12431246
if (LocationID < 0) {
1244-
SemaRef.Diag(Loc, diag::err_sycl_invalid_property_list_template_param)
1247+
SemaRef.Diag(Loc,
1248+
diag::err_sycl_invalid_accessor_property_list_template_param)
12451249
<< /*buffer_location*/ 2 << /*non-negative integer*/ 2;
12461250
return;
12471251
}
@@ -1298,6 +1302,18 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
12981302
return isValid();
12991303
}
13001304

1305+
bool handlePointerType(FieldDecl *FD, QualType FieldTy) final {
1306+
while (FieldTy->isAnyPointerType()) {
1307+
FieldTy = QualType{FieldTy->getPointeeOrArrayElementType(), 0};
1308+
if (FieldTy->isVariableArrayType()) {
1309+
Diag.Report(FD->getLocation(), diag::err_vla_unsupported);
1310+
IsInvalid = true;
1311+
break;
1312+
}
1313+
}
1314+
return isValid();
1315+
}
1316+
13011317
bool handleOtherType(FieldDecl *FD, QualType FieldTy) final {
13021318
Diag.Report(FD->getLocation(), diag::err_bad_kernel_param_type) << FieldTy;
13031319
IsInvalid = true;
@@ -1402,19 +1418,18 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
14021418
}
14031419

14041420
// Handle accessor properties. If any properties were found in
1405-
// the property_list - add the appropriate attributes to ParmVarDecl.
1421+
// the accessor_property_list - add the appropriate attributes to ParmVarDecl.
14061422
void handleAccessorPropertyList(ParmVarDecl *Param,
14071423
const CXXRecordDecl *RecordDecl,
14081424
SourceLocation Loc) {
14091425
const auto *AccTy = cast<ClassTemplateSpecializationDecl>(RecordDecl);
1410-
// TODO: when SYCL headers' part is ready - replace this 'if' with an error
14111426
if (AccTy->getTemplateArgs().size() < 6)
14121427
return;
14131428
const auto PropList = cast<TemplateArgument>(AccTy->getTemplateArgs()[5]);
14141429
QualType PropListTy = PropList.getAsType();
1415-
const auto *PropListDecl =
1430+
const auto *AccPropListDecl =
14161431
cast<ClassTemplateSpecializationDecl>(PropListTy->getAsRecordDecl());
1417-
const auto TemplArg = PropListDecl->getTemplateArgs()[0];
1432+
const auto TemplArg = AccPropListDecl->getTemplateArgs()[0];
14181433
// Move through TemplateArgs list of a property list and search for
14191434
// properties. If found - apply the appropriate attribute to ParmVarDecl.
14201435
for (TemplateArgument::pack_iterator Prop = TemplArg.pack_begin();
@@ -3443,20 +3458,17 @@ bool Util::isSyclSpecConstantType(const QualType &Ty) {
34433458
return matchQualifiedTypeName(Ty, Scopes);
34443459
}
34453460

3446-
bool Util::isPropertyListType(const QualType &Ty) {
3447-
return isSyclType(Ty, "property_list", true /*Tmpl*/);
3448-
}
3449-
34503461
bool Util::isSyclBufferLocationType(const QualType &Ty) {
3451-
const StringRef &Name = "buffer_location";
3452-
std::array<DeclContextDesc, 4> Scopes = {
3453-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
3454-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
3455-
// TODO: this doesn't belong to property namespace, instead it shall be
3456-
// in its own namespace. Change it, when the actual implementation in SYCL
3457-
// headers is ready
3458-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "property"},
3459-
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, Name}};
3462+
const StringRef &PropertyName = "buffer_location";
3463+
const StringRef &InstanceName = "instance";
3464+
std::array<DeclContextDesc, 6> Scopes = {
3465+
Util::DeclContextDesc{Decl::Kind::Namespace, "cl"},
3466+
Util::DeclContextDesc{Decl::Kind::Namespace, "sycl"},
3467+
Util::DeclContextDesc{Decl::Kind::Namespace, "INTEL"},
3468+
Util::DeclContextDesc{Decl::Kind::Namespace, "property"},
3469+
Util::DeclContextDesc{Decl::Kind::CXXRecord, PropertyName},
3470+
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization,
3471+
InstanceName}};
34603472
return matchQualifiedTypeName(Ty, Scopes);
34613473
}
34623474

@@ -3470,6 +3482,16 @@ bool Util::isSyclType(const QualType &Ty, StringRef Name, bool Tmpl) {
34703482
return matchQualifiedTypeName(Ty, Scopes);
34713483
}
34723484

3485+
bool Util::isAccessorPropertyListType(const QualType &Ty) {
3486+
const StringRef &Name = "accessor_property_list";
3487+
std::array<DeclContextDesc, 4> Scopes = {
3488+
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
3489+
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
3490+
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "ONEAPI"},
3491+
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, Name}};
3492+
return matchQualifiedTypeName(Ty, Scopes);
3493+
}
3494+
34733495
bool Util::matchQualifiedTypeName(const QualType &Ty,
34743496
ArrayRef<Util::DeclContextDesc> Scopes) {
34753497
// The idea: check the declaration context chain starting from the type

0 commit comments

Comments
 (0)