Skip to content

Commit 2e70ea9

Browse files
Alexander Batashevbader
authored andcommitted
[SYCL] Disable double underscore AS keywords
__global is used in libc++ preventing usage of this library with SYCL apps. This patch disables double underscore AS keywords recognition in SYCL. Signed-off-by: Alexander Batashev <alexander.batashev@intel.com>
1 parent 609999c commit 2e70ea9

File tree

6 files changed

+20
-28
lines changed

6 files changed

+20
-28
lines changed

clang/include/clang/Basic/TokenKinds.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ KEYWORD(__unaligned , KEYMS)
541541
KEYWORD(__super , KEYMS)
542542

543543
// OpenCL address space qualifiers
544-
KEYWORD(__global , KEYOPENCLC | KEYOPENCLCXX | KEYSYCL)
545-
KEYWORD(__local , KEYOPENCLC | KEYOPENCLCXX | KEYSYCL)
546-
KEYWORD(__constant , KEYOPENCLC | KEYOPENCLCXX | KEYSYCL)
547-
KEYWORD(__private , KEYOPENCLC | KEYOPENCLCXX | KEYSYCL)
544+
KEYWORD(__global , KEYOPENCLC | KEYOPENCLCXX)
545+
KEYWORD(__local , KEYOPENCLC | KEYOPENCLCXX)
546+
KEYWORD(__constant , KEYOPENCLC | KEYOPENCLCXX)
547+
KEYWORD(__private , KEYOPENCLC | KEYOPENCLCXX)
548548
KEYWORD(__generic , KEYOPENCLC | KEYOPENCLCXX)
549549
ALIAS("global", __global , KEYOPENCLC | KEYOPENCLCXX)
550550
ALIAS("local", __local , KEYOPENCLC | KEYOPENCLCXX)

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#pragma once
22

3-
#ifndef __SYCL_DEVICE_ONLY__
4-
#define __global
5-
#endif
6-
73
#define ATTR_SYCL_KERNEL __attribute__((sycl_kernel))
84

95
// Dummy runtime classes to model SYCL API.
@@ -137,7 +133,7 @@ class accessor {
137133
_ImplT<dimensions> impl;
138134

139135
private:
140-
void __init(__global dataT *Ptr, range<dimensions> AccessRange,
136+
void __init(__attribute__((ocl_global)) dataT *Ptr, range<dimensions> AccessRange,
141137
range<dimensions> MemRange, id<dimensions> Offset) {}
142138
};
143139

clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void bar(int & Data) {}
66
void bar2(int & Data) {}
77
// CHECK-OLD-DAG: define spir_func void @[[RAW_REF2:[a-zA-Z0-9_]+]](i32* dereferenceable(4) %
88
// CHECK-NEW-DAG: define spir_func void @[[RAW_REF2:[a-zA-Z0-9_]+]](i32 addrspace(4)* dereferenceable(4) %
9-
void bar(__local int &Data) {}
9+
void bar(__attribute__((ocl_local)) int &Data) {}
1010
// CHECK-DAG: define spir_func void [[LOC_REF:@[a-zA-Z0-9_]+]](i32 addrspace(3)* dereferenceable(4) %
1111
void foo(int * Data) {}
1212
// CHECK-OLD-DAG: define spir_func void @[[RAW_PTR:[a-zA-Z0-9_]+]](i32* %
@@ -25,13 +25,13 @@ void usages() {
2525
// CHECK-DAG: [[GLOB:%[a-zA-Z0-9]+]] = alloca i32 addrspace(1)*
2626
__attribute__((address_space(1))) int *GLOB;
2727
// CHECK-DAG: [[LOC:%[a-zA-Z0-9]+]] = alloca i32 addrspace(3)*
28-
__local int *LOC;
28+
__attribute__((ocl_local)) int *LOC;
2929
// CHECK-OLD-DAG: [[NoAS:%[a-zA-Z0-9]+]] = alloca i32*
3030
// CHECK-NEW-DAG: [[NoAS:%[a-zA-Z0-9]+]] = alloca i32 addrspace(4)*
3131
int *NoAS;
3232

3333
// CHECK-DAG: [[PRIV:%[a-zA-Z0-9]+]] = alloca i32*
34-
__private int *PRIV;
34+
__attribute__((ocl_private)) int *PRIV;
3535

3636
bar(*GLOB);
3737
// CHECK-DAG: [[GLOB_LOAD:%[a-zA-Z0-9]+]] = load i32 addrspace(1)*, i32 addrspace(1)** [[GLOB]]
@@ -121,19 +121,19 @@ void usages2() {
121121
// CHECK-DAG: [[PRIV_NUM:%[a-zA-Z0-9_]+]] = alloca i32*
122122
__attribute__((address_space(0))) int *PRIV_NUM2;
123123
// CHECK-DAG: [[PRIV_NUM2:%[a-zA-Z0-9_]+]] = alloca i32*
124-
__private int *PRIV;
124+
__attribute__((ocl_private)) int *PRIV;
125125
// CHECK-DAG: [[PRIV:%[a-zA-Z0-9_]+]] = alloca i32*
126126
__attribute__((address_space(1))) int *GLOB_NUM;
127127
// CHECK-DAG: [[GLOB_NUM:%[a-zA-Z0-9_]+]] = alloca i32 addrspace(1)*
128-
__global int *GLOB;
128+
__attribute__((ocl_global)) int *GLOB;
129129
// CHECK-DAG: [[GLOB:%[a-zA-Z0-9_]+]] = alloca i32 addrspace(1)*
130130
__attribute__((address_space(2))) int *CONST_NUM;
131131
// CHECK-DAG: [[CONST_NUM:%[a-zA-Z0-9_]+]] = alloca i32 addrspace(2)*
132-
__constant int *CONST;
132+
__attribute__((ocl_constant)) int *CONST;
133133
// CHECK-DAG: [[CONST:%[a-zA-Z0-9_]+]] = alloca i32 addrspace(2)*
134134
__attribute__((address_space(3))) int *LOCAL_NUM;
135135
// CHECK-DAG: [[LOCAL_NUM:%[a-zA-Z0-9_]+]] = alloca i32 addrspace(3)*
136-
__local int *LOCAL;
136+
__attribute__((ocl_local)) int *LOCAL;
137137
// CHECK-DAG: [[LOCAL:%[a-zA-Z0-9_]+]] = alloca i32 addrspace(3)*
138138

139139
bar(*PRIV_NUM);

clang/test/SemaSYCL/Inputs/sycl.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
// Shared code for SYCL tests
55

6-
#ifndef __SYCL_DEVICE_ONLY__
7-
#define __global
8-
#endif
9-
106
namespace cl {
117
namespace sycl {
128
namespace access {
@@ -61,17 +57,17 @@ struct DeviceValueType;
6157

6258
template <typename dataT>
6359
struct DeviceValueType<dataT, access::target::global_buffer> {
64-
using type = __global dataT;
60+
using type = __attribute__((ocl_global)) dataT;
6561
};
6662

6763
template <typename dataT>
6864
struct DeviceValueType<dataT, access::target::constant_buffer> {
69-
using type = __constant dataT;
65+
using type = __attribute__((ocl_constant)) dataT;
7066
};
7167

7268
template <typename dataT>
7369
struct DeviceValueType<dataT, access::target::local> {
74-
using type = __local dataT;
70+
using type = __attribute__((ocl_local)) dataT;
7571
};
7672

7773
template <typename dataT, int dimensions, access::mode accessmode,

clang/test/SemaSYCL/address-space-parameter-conversions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
void bar(int & Data) {}
44
void bar2(int & Data) {}
5-
void bar(__private int & Data) {}
5+
void bar(__attribute__((ocl_private)) int & Data) {}
66
void foo(int * Data) {}
77
void foo2(int * Data) {}
8-
void foo(__private int * Data) {}
8+
void foo(__attribute__((ocl_private)) int * Data) {}
99

1010
template<typename T>
1111
void tmpl(T *t){}
1212

1313
void usages() {
14-
__global int *GLOB;
15-
__private int *PRIV;
14+
__attribute__((ocl_global)) int *GLOB;
15+
__attribute__((ocl_private)) int *PRIV;
1616
__attribute__((address_space(3))) int *LOC;
1717
int *NoAS;
1818

clang/test/SemaSYCL/intel-fpga-local.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ void foo1()
406406

407407
//expected-error@+1{{attribute only applies to local non-const variables and non-static data members}}
408408
[[intelfpga::max_private_copies(8)]]
409-
__constant unsigned int ext_two[64] = { 1, 2, 3 };
409+
__attribute__((ocl_constant)) unsigned int ext_two[64] = { 1, 2, 3 };
410410

411411
void other2()
412412
{

0 commit comments

Comments
 (0)