Skip to content

Commit f1d20ee

Browse files
committed
[SYCL] Add SYCL kernel attribute to clang.
Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent e802518 commit f1d20ee

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,13 @@ def SYCLDevice : InheritableAttr {
991991
let Documentation = [Undocumented];
992992
}
993993

994+
def SYCLKernel : InheritableAttr {
995+
let Spellings = [GNU<"sycl_kernel">];
996+
let Subjects = SubjectList<[Function]>;
997+
let LangOpts = [SYCL];
998+
let Documentation = [Undocumented];
999+
}
1000+
9941001
def C11NoReturn : InheritableAttr {
9951002
let Spellings = [Keyword<"_Noreturn">];
9961003
let Subjects = SubjectList<[Function], ErrorDiag>;

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6280,6 +6280,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
62806280
case ParsedAttr::AT_Flatten:
62816281
handleSimpleAttribute<FlattenAttr>(S, D, AL);
62826282
break;
6283+
case ParsedAttr::AT_SYCLKernel:
6284+
handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
6285+
break;
62836286
case ParsedAttr::AT_Format:
62846287
handleFormatAttr(S, D, AL);
62856288
break;

clang/test/Misc/pragma-attribute-supported-attributes-list.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
// CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
118118
// CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
119119
// CHECK-NEXT: SYCLDevice (SubjectMatchRule_function, SubjectMatchRule_variable)
120+
// CHECK-NEXT: SYCLKernel (SubjectMatchRule_function)
120121
// CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
121122
// CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
122123
// CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -fcxx-exceptions -verify -pedantic -std=c++11 %s
2+
// expected-no-diagnostics
3+
4+
__attribute((sycl_kernel)) void foo() {
5+
}

0 commit comments

Comments
 (0)