Skip to content

Commit d375f2a

Browse files
author
Alexander Batashev
committed
Align with the latest revision and temporarily allow old accessors
1 parent 1884bd4 commit d375f2a

File tree

8 files changed

+45
-59
lines changed

8 files changed

+45
-59
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,20 +1270,8 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
12701270
llvm::DenseSet<QualType> Visited;
12711271
checkSYCLType(SemaRef, TemplateArgTy, Loc, Visited);
12721272

1273-
if (TAL.size() < 6) {
1274-
// Not enough arguments for this parameter pack.
1275-
SemaRef.Diag(Loc.getBegin(),
1276-
diag::err_template_arg_list_different_arity)
1277-
<< /*not enough args*/ 0
1278-
<< (int)SemaRef.getTemplateNameKindForDiagnostics(
1279-
TemplateName(CTSD->getSpecializedTemplate()))
1280-
<< CTSD;
1281-
SemaRef.Diag(CTSD->getLocation(), diag::note_template_decl_here)
1282-
<< CTSD->getSourceRange();
1283-
return;
1284-
}
1285-
1286-
checkPropertyListType(TAL.get(5), Loc.getBegin());
1273+
if (TAL.size() > 5)
1274+
checkPropertyListType(TAL.get(5), Loc.getBegin());
12871275
}
12881276
}
12891277

@@ -3472,14 +3460,15 @@ bool Util::isPropertyListType(const QualType &Ty) {
34723460
}
34733461

34743462
bool Util::isSyclBufferLocationType(const QualType &Ty) {
3475-
const StringRef &Name = "buffer_location";
3463+
const StringRef &PropertyName = "buffer_location";
3464+
const StringRef &InstanceName = "instance";
34763465
std::array<DeclContextDesc, 6> Scopes = {
3477-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
3478-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
3479-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "ext"},
3480-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "INTEL"},
3481-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "property"},
3482-
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, Name}};
3466+
Util::DeclContextDesc{Decl::Kind::Namespace, "cl"},
3467+
Util::DeclContextDesc{Decl::Kind::Namespace, "sycl"},
3468+
Util::DeclContextDesc{Decl::Kind::Namespace, "INTEL"},
3469+
Util::DeclContextDesc{Decl::Kind::Namespace, "property"},
3470+
Util::DeclContextDesc{Decl::Kind::CXXRecord, PropertyName},
3471+
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, InstanceName}};
34833472
return matchQualifiedTypeName(Ty, Scopes);
34843473
}
34853474

@@ -3495,10 +3484,9 @@ bool Util::isSyclType(const QualType &Ty, StringRef Name, bool Tmpl) {
34953484

34963485
bool Util::isAccessorPropertyListType(const QualType &Ty) {
34973486
const StringRef &Name = "accessor_property_list";
3498-
std::array<DeclContextDesc, 5> Scopes = {
3487+
std::array<DeclContextDesc, 4> Scopes = {
34993488
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
35003489
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
3501-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "ext"},
35023490
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "ONEAPI"},
35033491
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, Name}};
35043492
return matchQualifiedTypeName(Ty, Scopes);

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,19 @@ class property_list {
9494
bool operator!=(const property_list &rhs) const { return false; }
9595
};
9696

97-
namespace ext {
9897
namespace INTEL {
9998
namespace property {
10099
// Compile time known accessor property
101-
template <int>
102-
class buffer_location {};
100+
struct buffer_location {
101+
template <int> class instance {};
102+
};
103103
} // namespace property
104104
} // namespace INTEL
105105

106106
namespace ONEAPI {
107107
template <typename... properties>
108108
class accessor_property_list {};
109109
} // namespace ONEAPI
110-
} // namespace ext
111110

112111
template <int dim>
113112
struct id {

clang/test/CodeGenSYCL/buffer_location.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ struct Base {
1010
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read,
1111
cl::sycl::access::target::global_buffer,
1212
cl::sycl::access::placeholder::false_t,
13-
cl::sycl::ext::ONEAPI::accessor_property_list<
14-
cl::sycl::ext::INTEL::property::buffer_location<2>>>
13+
cl::sycl::ONEAPI::accessor_property_list<
14+
cl::sycl::INTEL::property::buffer_location::instance<2>>>
1515
AccField;
1616
};
1717

1818
struct Captured : Base,
1919
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read,
2020
cl::sycl::access::target::global_buffer,
2121
cl::sycl::access::placeholder::false_t,
22-
cl::sycl::ext::ONEAPI::accessor_property_list<
23-
cl::sycl::ext::INTEL::property::buffer_location<2>>> {
22+
cl::sycl::ONEAPI::accessor_property_list<
23+
cl::sycl::INTEL::property::buffer_location::instance<2>>> {
2424
int C;
2525
};
2626

@@ -29,8 +29,8 @@ int main() {
2929
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
3030
cl::sycl::access::target::global_buffer,
3131
cl::sycl::access::placeholder::false_t,
32-
cl::sycl::ext::ONEAPI::accessor_property_list<
33-
cl::sycl::ext::INTEL::property::buffer_location<3>>>
32+
cl::sycl::ONEAPI::accessor_property_list<
33+
cl::sycl::INTEL::property::buffer_location::instance<3>>>
3434
accessorA;
3535
cl::sycl::kernel_single_task<class kernel_function>(
3636
[=]() {

clang/test/SemaSYCL/Inputs/sycl.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@ enum class address_space : int {
3939

4040
class property_list {};
4141

42-
namespace ext {
4342
namespace INTEL {
4443
namespace property {
45-
template <int>
46-
class buffer_location {};
44+
struct buffer_location {
45+
template <int> class instance {};
46+
};
4747
} // namespace property
4848
} // namespace INTEL
4949

5050
namespace ONEAPI {
5151
template <typename... properties>
5252
class accessor_property_list {};
5353
} // namespace ONEAPI
54-
} // namespace ext
5554

5655
namespace detail {
5756
namespace half_impl {
@@ -103,7 +102,7 @@ struct DeviceValueType<dataT, access::target::local> {
103102
template <typename dataT, int dimensions, access::mode accessmode,
104103
access::target accessTarget = access::target::global_buffer,
105104
access::placeholder isPlaceholder = access::placeholder::false_t,
106-
typename propertyListT = property_list>
105+
typename propertyListT = ONEAPI::accessor_property_list<>>
107106
class accessor {
108107

109108
public:

clang/test/SemaSYCL/accessor_inheritance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ int main() {
4242
// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} '_arg_A' 'int'
4343
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
4444
// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} '_arg_B' 'int'
45-
// CHECK-NEXT: CXXConstructExpr {{.*}} 'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read>':'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>' 'void () noexcept'
46-
// CHECK-NEXT: CXXConstructExpr {{.*}} 'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read>':'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>' 'void () noexcept'
45+
// CHECK-NEXT: CXXConstructExpr {{.*}} 'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read>':'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>' 'void () noexcept'
46+
// CHECK-NEXT: CXXConstructExpr {{.*}} 'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read>':'cl::sycl::accessor<char, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>' 'void () noexcept'
4747
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <LValueToRValue>
4848
// CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} '_arg_C' 'int'
4949

clang/test/SemaSYCL/basic-kernel-wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main() {
4343

4444
// CHECK: CXXMemberCallExpr {{.*}} 'void'
4545
// CHECK-NEXT: MemberExpr {{.*}} 'void ({{.*}}PtrType, range<1>, range<1>, id<1>)' lvalue .__init
46-
// CHECK-NEXT: MemberExpr {{.*}} 'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write>':'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>' lvalue .
46+
// CHECK-NEXT: MemberExpr {{.*}} 'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write>':'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>' lvalue .
4747
// CHECK-NEXT: DeclRefExpr {{.*}} '(lambda at {{.*}}basic-kernel-wrapper.cpp{{.*}})' lvalue Var
4848

4949
// CHECK-NEXT: ImplicitCastExpr {{.*}} <LValueToRValue>

clang/test/SemaSYCL/buffer_location.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ struct Base {
1414
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read,
1515
cl::sycl::access::target::global_buffer,
1616
cl::sycl::access::placeholder::false_t,
17-
cl::sycl::ext::ONEAPI::accessor_property_list<
18-
cl::sycl::ext::INTEL::property::buffer_location<1>>>
17+
cl::sycl::ONEAPI::accessor_property_list<
18+
cl::sycl::INTEL::property::buffer_location::instance<1>>>
1919
AccField;
2020
};
2121

2222
struct Captured : Base,
2323
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read,
2424
cl::sycl::access::target::global_buffer,
2525
cl::sycl::access::placeholder::false_t,
26-
cl::sycl::ext::ONEAPI::accessor_property_list<
27-
cl::sycl::ext::INTEL::property::buffer_location<1>>> {
26+
cl::sycl::ONEAPI::accessor_property_list<
27+
cl::sycl::INTEL::property::buffer_location::instance<1>>> {
2828
int C;
2929
};
3030

@@ -35,30 +35,30 @@ int main() {
3535
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
3636
cl::sycl::access::target::global_buffer,
3737
cl::sycl::access::placeholder::false_t,
38-
cl::sycl::ext::ONEAPI::accessor_property_list<
39-
cl::sycl::ext::INTEL::property::buffer_location<2>>>
38+
cl::sycl::ONEAPI::accessor_property_list<
39+
cl::sycl::INTEL::property::buffer_location::instance<2>>>
4040
// CHECK: SYCLIntelBufferLocationAttr {{.*}} Implicit 2
4141
accessorA;
4242
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
4343
cl::sycl::access::target::global_buffer,
4444
cl::sycl::access::placeholder::false_t,
45-
cl::sycl::ext::ONEAPI::accessor_property_list<
45+
cl::sycl::ONEAPI::accessor_property_list<
4646
another_property,
47-
cl::sycl::ext::INTEL::property::buffer_location<3>>>
47+
cl::sycl::INTEL::property::buffer_location::instance<3>>>
4848
// CHECK: SYCLIntelBufferLocationAttr {{.*}} Implicit 3
4949
accessorB;
5050
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
5151
cl::sycl::access::target::global_buffer,
5252
cl::sycl::access::placeholder::false_t,
53-
cl::sycl::ext::ONEAPI::accessor_property_list<
53+
cl::sycl::ONEAPI::accessor_property_list<
5454
another_property>>
5555
accessorC;
5656
#else
5757
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
5858
cl::sycl::access::target::global_buffer,
5959
cl::sycl::access::placeholder::false_t,
60-
cl::sycl::ext::ONEAPI::accessor_property_list<
61-
cl::sycl::ext::INTEL::property::buffer_location<-2>>>
60+
cl::sycl::ONEAPI::accessor_property_list<
61+
cl::sycl::INTEL::property::buffer_location::instance<-2>>>
6262
accessorD;
6363
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
6464
cl::sycl::access::target::global_buffer,
@@ -68,9 +68,9 @@ int main() {
6868
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
6969
cl::sycl::access::target::global_buffer,
7070
cl::sycl::access::placeholder::false_t,
71-
cl::sycl::ext::ONEAPI::accessor_property_list<
72-
cl::sycl::ext::INTEL::property::buffer_location<1>,
73-
cl::sycl::ext::INTEL::property::buffer_location<2>>>
71+
cl::sycl::ONEAPI::accessor_property_list<
72+
cl::sycl::INTEL::property::buffer_location::instance<1>,
73+
cl::sycl::INTEL::property::buffer_location::instance<2>>>
7474
accessorF;
7575
#endif
7676
cl::sycl::kernel_single_task<class kernel_function>(

clang/test/SemaSYCL/wrapped-accessor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ int main() {
3535
// argument
3636
// CHECK: VarDecl {{.*}}'(lambda at {{.*}}wrapped-accessor.cpp{{.*}})'
3737
// CHECK-NEXT: InitListExpr {{.*}}'(lambda at {{.*}}wrapped-accessor.cpp{{.*}})'
38-
// CHECK-NEXT: InitListExpr {{.*}}'AccWrapper<cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>>'
39-
// CHECK-NEXT: CXXConstructExpr {{.*}}'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>':'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>' 'void () noexcept'
38+
// CHECK-NEXT: InitListExpr {{.*}}'AccWrapper<cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>>'
39+
// CHECK-NEXT: CXXConstructExpr {{.*}}'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>':'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>' 'void () noexcept'
4040

4141
// Check that accessor field of the wrapper object is initialized using __init method
4242
// CHECK-NEXT: CXXMemberCallExpr {{.*}} 'void'
4343
// CHECK-NEXT: MemberExpr {{.*}} 'void ({{.*}}PtrType, range<1>, range<1>, id<1>)' lvalue .__init
44-
// CHECK-NEXT: MemberExpr {{.*}} 'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>':'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>' lvalue .accessor {{.*}}
45-
// CHECK-NEXT: MemberExpr {{.*}} 'AccWrapper<cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>>':'AccWrapper<cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::property_list>>' lvalue .
44+
// CHECK-NEXT: MemberExpr {{.*}} 'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>':'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>' lvalue .accessor {{.*}}
45+
// CHECK-NEXT: MemberExpr {{.*}} 'AccWrapper<cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>>':'AccWrapper<cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t, cl::sycl::ONEAPI::accessor_property_list<>>>' lvalue .
4646
// CHECK-NEXT: DeclRefExpr {{.*}} '(lambda at {{.*}}wrapped-accessor.cpp{{.*}})' lvalue Var {{.*}} '(lambda at {{.*}}wrapped-accessor.cpp{{.*}})'
4747

4848
// Parameters of the _init method

0 commit comments

Comments
 (0)