Skip to content

Commit

Permalink
[SYCL] Add SYCL kernel attribute to clang.
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Lazarev <vladimir.lazarev@intel.com>
  • Loading branch information
vladimirlaz committed Jan 22, 2019
1 parent e802518 commit f1d20ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,13 @@ def SYCLDevice : InheritableAttr {
let Documentation = [Undocumented];
}

def SYCLKernel : InheritableAttr {
let Spellings = [GNU<"sycl_kernel">];
let Subjects = SubjectList<[Function]>;
let LangOpts = [SYCL];
let Documentation = [Undocumented];
}

def C11NoReturn : InheritableAttr {
let Spellings = [Keyword<"_Noreturn">];
let Subjects = SubjectList<[Function], ErrorDiag>;
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6280,6 +6280,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case ParsedAttr::AT_Flatten:
handleSimpleAttribute<FlattenAttr>(S, D, AL);
break;
case ParsedAttr::AT_SYCLKernel:
handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
break;
case ParsedAttr::AT_Format:
handleFormatAttr(S, D, AL);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
// CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
// CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
// CHECK-NEXT: SYCLDevice (SubjectMatchRule_function, SubjectMatchRule_variable)
// CHECK-NEXT: SYCLKernel (SubjectMatchRule_function)
// CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
// CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
// CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Expand Down
5 changes: 5 additions & 0 deletions clang/test/SemaSYCL/kernel-attribute.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -fcxx-exceptions -verify -pedantic -std=c++11 %s
// expected-no-diagnostics

__attribute((sycl_kernel)) void foo() {
}

0 comments on commit f1d20ee

Please sign in to comment.