-
Notifications
You must be signed in to change notification settings - Fork 808
[sycl] [clang] Add sycl global var attribute #3746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
682277f
2c6f8fa
4184aa4
3f7887f
63c4f17
8b721d9
08d0c67
5c0f8af
a1ac1c5
a046f39
6bb98b9
47ce16a
a349032
79d4ed7
e9b7b2a
7219bff
3373830
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1197,6 +1197,14 @@ def SYCLDevice : InheritableAttr { | |
| let Documentation = [SYCLDeviceDocs]; | ||
| } | ||
|
|
||
| def SYCLGlobalVar : InheritableAttr { | ||
| let Spellings = [GNU<"sycl_global_var">]; | ||
| let Subjects = SubjectList<[GlobalVar]>; | ||
| let LangOpts = [SYCLIsDevice]; | ||
AaronBallman marked this conversation as resolved.
Show resolved
Hide resolved
AaronBallman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let Documentation = [SYCLGlobalVarDocs]; | ||
|
||
| let SimpleHandler = 1; | ||
AaronBallman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| def SYCLKernel : InheritableAttr { | ||
| let Spellings = [Clang<"sycl_kernel">]; | ||
| let Subjects = SubjectList<[FunctionTmpl]>; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only %s | ||
|
|
||
| #include "Inputs/sycl.hpp" | ||
|
|
||
| __attribute__((sycl_global_var)) int GlobalWithAttribute; | ||
|
|
||
| __attribute__((sycl_global_var)) extern int ExternGlobalWithAttribute; | ||
|
|
||
| namespace NS { | ||
| __attribute__((sycl_global_var)) int NSGlobalWithAttribute; | ||
| } | ||
|
|
||
| union U { | ||
| int InstanceMember; | ||
| }; | ||
|
|
||
| __attribute__((sycl_global_var)) U GlobalUnion; | ||
AaronBallman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| struct S { | ||
| __attribute__((sycl_global_var)) static int StaticMember; | ||
|
|
||
| // expected-warning@+1 {{attribute only applies to global variables}} | ||
| __attribute__((sycl_global_var)) int InstanceMember; | ||
| }; | ||
| int S::StaticMember = 0; | ||
|
|
||
| __attribute__((sycl_global_var)) S GlobalStruct; | ||
|
|
||
| __attribute__((sycl_global_var)) static S StaticGlobal; | ||
|
|
||
| // expected-error@+1 {{attribute takes no arguments}} | ||
| __attribute__((sycl_global_var(42))) int GlobalWithAttributeArg; | ||
|
|
||
| int GlobalNoAttribute; | ||
|
|
||
| // expected-warning@+1 {{attribute only applies to global variables}} | ||
| __attribute__((sycl_global_var)) void F() { | ||
| __attribute__((sycl_global_var)) static int StaticLocalVar; | ||
|
||
|
|
||
| // expected-warning@+1 {{attribute only applies to global variables}} | ||
| __attribute__((sycl_global_var)) int Local; | ||
|
|
||
| cl::sycl::kernel_single_task<class kernel_name>([=] () { | ||
| (void)GlobalWithAttribute; | ||
| (void)ExternGlobalWithAttribute; | ||
| (void)NS::NSGlobalWithAttribute; | ||
| (void)GlobalUnion.InstanceMember; | ||
| (void)S::StaticMember; | ||
| (void)GlobalStruct.InstanceMember; | ||
| (void)StaticGlobal.InstanceMember; // expected-error {{SYCL kernel cannot use a non-const static data variable}} | ||
| (void)StaticLocalVar; // expected-error {{SYCL kernel cannot use a non-const static data variable}} | ||
| (void)GlobalNoAttribute; // expected-error {{SYCL kernel cannot use a non-const global variable}} expected-note@Inputs/sycl.hpp:* {{called by}} | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.