Skip to content

Commit e50ae05

Browse files
[SYCL][ABI-break] Remove old spec constants extension and implementation (#9874)
`sycl_ext_oneapi_spec_constants` extension was deprecated a year ago in b185269 and since it is dependent on `program` class, which was removed from SYCL 2020 and was removed from our implementation about 1.5 years ago in e7cc7b0, there is no reason anymore to keep related implementation bits. This is technically an ABI break, because our compiler loses ability to process device code compiled by older versions of the compiler.
1 parent aba998f commit e50ae05

32 files changed

+137
-2140
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,12 +1354,12 @@ def SYCLType: InheritableAttr {
13541354
let Subjects = SubjectList<[CXXRecord, Enum], ErrorDiag>;
13551355
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
13561356
let Args = [EnumArgument<"Type", "SYCLType",
1357-
["accessor", "local_accessor", "spec_constant",
1357+
["accessor", "local_accessor",
13581358
"specialization_id", "kernel_handler", "buffer_location",
13591359
"no_alias", "accessor_property_list", "group",
13601360
"private_memory", "aspect", "annotated_ptr", "annotated_arg",
13611361
"stream", "sampler", "host_pipe"],
1362-
["accessor", "local_accessor", "spec_constant",
1362+
["accessor", "local_accessor",
13631363
"specialization_id", "kernel_handler", "buffer_location",
13641364
"no_alias", "accessor_property_list", "group",
13651365
"private_memory", "aspect", "annotated_ptr", "annotated_arg",

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,6 @@ class KernelObjVisitor {
12571257
QualType FieldTy, HandlerTys &... Handlers) {
12581258
if (isSyclSpecialType(FieldTy, SemaRef))
12591259
KF_FOR_EACH(handleSyclSpecialType, Field, FieldTy);
1260-
else if (isSyclType(FieldTy, SYCLTypeAttr::spec_constant))
1261-
KF_FOR_EACH(handleSyclSpecConstantType, Field, FieldTy);
12621260
else if (FieldTy->isStructureOrClassType()) {
12631261
if (KF_FOR_EACH(handleStructType, Field, FieldTy)) {
12641262
CXXRecordDecl *RD = FieldTy->getAsCXXRecordDecl();
@@ -1327,10 +1325,6 @@ class SyclKernelFieldHandlerBase {
13271325
}
13281326
virtual bool handleSyclSpecialType(FieldDecl *, QualType) { return true; }
13291327

1330-
virtual bool handleSyclSpecConstantType(FieldDecl *, QualType) {
1331-
return true;
1332-
}
1333-
13341328
virtual bool handleStructType(FieldDecl *, QualType) { return true; }
13351329
virtual bool handleUnionType(FieldDecl *, QualType) { return true; }
13361330
virtual bool handleReferenceType(FieldDecl *, QualType) { return true; }
@@ -1826,11 +1820,6 @@ class SyclKernelDecompMarker : public SyclKernelFieldHandler {
18261820
return true;
18271821
}
18281822

1829-
bool handleSyclSpecConstantType(FieldDecl *, QualType) final {
1830-
CollectionStack.back() = true;
1831-
return true;
1832-
}
1833-
18341823
bool handlePointerType(FieldDecl *, QualType) final {
18351824
PointerStack.back() = true;
18361825
return true;
@@ -3448,10 +3437,6 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
34483437
return handleSpecialType(BS, Ty);
34493438
}
34503439

3451-
bool handleSyclSpecConstantType(FieldDecl *FD, QualType Ty) final {
3452-
return handleSpecialType(FD, Ty);
3453-
}
3454-
34553440
bool handlePointerType(FieldDecl *FD, QualType FieldTy) final {
34563441
Expr *PointerRef =
34573442
createPointerParamReferenceExpr(FieldTy, StructDepth != 0);
@@ -3717,21 +3702,6 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
37173702
return true;
37183703
}
37193704

3720-
bool handleSyclSpecConstantType(FieldDecl *FD, QualType FieldTy) final {
3721-
const TemplateArgumentList &TemplateArgs =
3722-
cast<ClassTemplateSpecializationDecl>(FieldTy->getAsRecordDecl())
3723-
->getTemplateInstantiationArgs();
3724-
assert(TemplateArgs.size() == 2 &&
3725-
"Incorrect template args for spec constant type");
3726-
// Get specialization constant ID type, which is the second template
3727-
// argument.
3728-
QualType SpecConstIDTy = TemplateArgs.get(1).getAsType().getCanonicalType();
3729-
const std::string SpecConstName = SYCLUniqueStableNameExpr::ComputeName(
3730-
SemaRef.getASTContext(), SpecConstIDTy);
3731-
Header.addSpecConstant(SpecConstName, SpecConstIDTy);
3732-
return true;
3733-
}
3734-
37353705
bool handlePointerType(FieldDecl *FD, QualType FieldTy) final {
37363706
addParam(FD, FieldTy,
37373707
((StructDepth) ? SYCLIntegrationHeader::kind_std_layout

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,6 @@ struct get_kernel_name_t<auto_name, Type> {
370370
namespace ext {
371371
namespace oneapi {
372372
namespace experimental {
373-
template <typename T, typename ID = T>
374-
class __SYCL_TYPE(spec_constant) spec_constant {
375-
public:
376-
spec_constant() {}
377-
spec_constant(T Cst) {}
378-
379-
T get() const { // explicit access.
380-
return T(); // Dummy implementaion.
381-
}
382-
operator T() const { // implicit conversion.
383-
return get();
384-
}
385-
};
386-
387373
#ifdef __SYCL_DEVICE_ONLY__
388374
#define __SYCL_CONSTANT_AS __attribute__((opencl_constant))
389375
#else

clang/test/CodeGenSYCL/int_header_spec_const.cpp

Lines changed: 0 additions & 90 deletions
This file was deleted.

clang/test/Frontend/Inputs/sycl.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,6 @@ struct get_kernel_name_t<auto_name, Type> {
344344
namespace ext {
345345
namespace oneapi {
346346
namespace experimental {
347-
template <typename T, typename ID = T>
348-
class __SYCL_TYPE(spec_constant) spec_constant {
349-
public:
350-
spec_constant() {}
351-
spec_constant(T Cst) {}
352-
353-
T get() const { // explicit access.
354-
return T(); // Dummy implementaion.
355-
}
356-
operator T() const { // implicit conversion.
357-
return get();
358-
}
359-
};
360-
361347
#ifdef __SYCL_DEVICE_ONLY__
362348
#define __SYCL_CONSTANT_AS __attribute__((opencl_constant))
363349
#else

clang/test/SemaSYCL/Inputs/sycl.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,6 @@ template <typename T, access::address_space AS> class multi_ptr {
395395
namespace ext {
396396
namespace oneapi {
397397
namespace experimental {
398-
template <typename T, typename ID = T>
399-
class __SYCL_TYPE(spec_constant) spec_constant {
400-
public:
401-
spec_constant() {}
402-
explicit constexpr spec_constant(T defaultVal) : DefaultValue(defaultVal) {}
403-
404-
private:
405-
T DefaultValue;
406-
};
407-
408398
template <typename T, typename... Props>
409399
class __attribute__((sycl_special_class)) __SYCL_TYPE(annotated_arg) annotated_arg {
410400
T obj;

clang/test/SemaSYCL/decomposition.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ struct StructWithSampler {
2121
sycl::sampler sampl;
2222
};
2323

24-
struct StructWithSpecConst {
25-
sycl::ext::oneapi::experimental::spec_constant<int, class f1> SC;
26-
};
27-
2824
sycl::handler H;
2925

3026
struct StructWithStream {
@@ -136,20 +132,6 @@ int main() {
136132
// CHECK: FunctionDecl {{.*}}Sampl2{{.*}} 'void (sampler_t, StructNonDecomposed, int)'
137133
}
138134

139-
{
140-
StructWithArray<StructWithSpecConst> t1;
141-
myQueue.submit([&](sycl::handler &h) {
142-
h.single_task<class SpecConst1>([=]() { return t1.i; });
143-
});
144-
// CHECK: FunctionDecl {{.*}}SpecConst{{.*}} 'void (StructNonDecomposed, int)'
145-
146-
DerivedStruct<StructWithSpecConst> t2;
147-
myQueue.submit([&](sycl::handler &h) {
148-
h.single_task<class SpecConst2>([=]() { return t2.i; });
149-
});
150-
// CHECK: FunctionDecl {{.*}}SpecConst2{{.*}} 'void (StructNonDecomposed, int)'
151-
}
152-
153135
{
154136
StructWithArray<StructWithStream> t1;
155137
myQueue.submit([&](sycl::handler &h) {

clang/test/SemaSYCL/spec-const-kernel-arg.cpp

Lines changed: 0 additions & 33 deletions
This file was deleted.

clang/test/SemaSYCL/spec-const-value-dependent-crash.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

clang/test/SemaSYCL/spec_const_and_accesor_crash.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

clang/test/SemaSYCL/sycl-type-attr-ast.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ class [[__sycl_detail__::sycl_type(local_accessor)]] local_accessor {};
2020
// CHECK: CXXRecordDecl {{.*}} class local_accessor definition
2121
// CHECK: SYCLTypeAttr {{.*}} local_accessor
2222

23-
class [[__sycl_detail__::sycl_type(spec_constant)]]
24-
[[__sycl_detail__::sycl_type(spec_constant)]] spec_constant;
25-
// CHECK: CXXRecordDecl {{.*}} spec_constant
26-
// CHECK: SYCLTypeAttr {{.*}} spec_constant
27-
// CHECK-NOT: SYCLTypeAttr {{.*}} spec_constant
28-
2923
template <>
3024
class [[__sycl_detail__::sycl_type(local_accessor)]] local_accessor <int> {};
3125
// CHECK: ClassTemplateSpecializationDecl {{.*}} class local_accessor definition

clang/test/SemaSYCL/sycl-type-attr.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ class [[__sycl_detail__::sycl_type()]] B {};
1717
// expected-error@+1{{'sycl_type' attribute argument 'NotValidType' is not supported}}
1818
class [[__sycl_detail__::sycl_type(NotValidType)]] C {};
1919

20-
// expected-note@+1{{previous attribute is here}}
21-
class [[__sycl_detail__::sycl_type(spec_constant)]] spec_constant;
22-
// expected-error@+1{{attribute 'sycl_type' is already applied with different arguments}}
23-
class [[__sycl_detail__::sycl_type(accessor)]] spec_constant {};
24-
2520
// expected-error@+2{{attribute 'sycl_type' is already applied with different arguments}}
2621
// expected-note@+1{{previous attribute is here}}
2722
class [[__sycl_detail__::sycl_type(group)]] [[__sycl_detail__::sycl_type(accessor)]] group {};

0 commit comments

Comments
 (0)