Skip to content

Commit 7a2c8df

Browse files
committed
[SYCL] Re-use OpenCL address space attributes for SYCL
Today we re-use OpenCL parsed attributes, but have separate SYCL address space semantic attributes as current implementation of OpenCL semantics breaks valid C++. This patch enables re-use of OpenCL semantic attributes by allowing conversions between types qualified with OpenCL address spaces and type w/o address space qualifiers. Clang compiler (almost) always adds address space qualifiers in OpenCL mode, so it should not affect OpenCL mode. NOTE: this change also disables implicit conversion between the unqualified types and types qualified with `__attribute__((address_space(N)))`, enabled by one of the previous SYCL patches. Signed-off-by: Alexey Bader <[email protected]>
1 parent 54dddb4 commit 7a2c8df

File tree

17 files changed

+50
-200
lines changed

17 files changed

+50
-200
lines changed

clang/include/clang/AST/Type.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,12 @@ class Qualifiers {
486486
/// Returns true if the address space in these qualifiers is equal to or
487487
/// a superset of the address space in the argument qualifiers.
488488
bool isAddressSpaceSupersetOf(Qualifiers other) const {
489-
490-
return
491-
isAddressSpaceSupersetOf(getAddressSpace(), other.getAddressSpace()) ||
492-
(!hasAddressSpace() &&
493-
(other.getAddressSpace() == LangAS::sycl_private ||
494-
other.getAddressSpace() == LangAS::sycl_local ||
495-
other.getAddressSpace() == LangAS::sycl_global ||
496-
other.getAddressSpace() == LangAS::sycl_constant ||
497-
other.getAddressSpace() == LangAS::sycl_generic));
489+
return isAddressSpaceSupersetOf(getAddressSpace(),
490+
other.getAddressSpace()) ||
491+
(!hasAddressSpace() &&
492+
(other.getAddressSpace() == LangAS::opencl_private ||
493+
other.getAddressSpace() == LangAS::opencl_local ||
494+
other.getAddressSpace() == LangAS::opencl_global));
498495
}
499496

500497
/// Determines if these qualifiers compatibly include another set.

clang/include/clang/Basic/AddressSpaces.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ enum class LangAS : unsigned {
4242
cuda_constant,
4343
cuda_shared,
4444

45-
sycl_global,
46-
sycl_local,
47-
sycl_constant,
48-
sycl_private,
49-
// Likely never used, but useful in the future to reserve the spot in the
50-
// enum.
51-
sycl_generic,
52-
5345
// Pointer size and extension address spaces.
5446
ptr32_sptr,
5547
ptr32_uptr,

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10292,8 +10292,6 @@ def err_builtin_launder_invalid_arg : Error<
1029210292
"'__builtin_launder' is not allowed">;
1029310293

1029410294
// SYCL-specific diagnostics
10295-
def err_sycl_attribute_address_space_invalid : Error<
10296-
"address space is outside the valid range of values">;
1029710295
def err_sycl_kernel_name_class_not_top_level : Error<
1029810296
"kernel name class and its template argument classes' declarations can only "
1029910297
"nest in a namespace: %0">;

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -534,24 +534,6 @@ class ParsedAttr final
534534
}
535535
}
536536

537-
/// If this is an OpenCL addr space attribute returns its SYCL representation
538-
/// in LangAS, otherwise returns default addr space.
539-
LangAS asSYCLLangAS() const {
540-
switch (getKind()) {
541-
case ParsedAttr::AT_OpenCLConstantAddressSpace:
542-
return LangAS::sycl_constant;
543-
case ParsedAttr::AT_OpenCLGlobalAddressSpace:
544-
return LangAS::sycl_global;
545-
case ParsedAttr::AT_OpenCLLocalAddressSpace:
546-
return LangAS::sycl_local;
547-
case ParsedAttr::AT_OpenCLPrivateAddressSpace:
548-
return LangAS::sycl_private;
549-
case ParsedAttr::AT_OpenCLGenericAddressSpace:
550-
default:
551-
return LangAS::Default;
552-
}
553-
}
554-
555537
AttributeCommonInfo::Kind getKind() const { return getParsedKind(); }
556538
};
557539

clang/lib/AST/ASTContext.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,6 @@ static const LangASMap *getAddressSpaceMap(const TargetInfo &T,
836836
5, // cuda_device
837837
6, // cuda_constant
838838
7, // cuda_shared
839-
1, // sycl_global
840-
3, // sycl_local
841-
2, // sycl_constant
842-
0, // sycl_private
843-
4, // sycl_generic
844839
8, // ptr32_sptr
845840
9, // ptr32_uptr
846841
10 // ptr64

clang/lib/AST/TypePrinter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,16 +1792,12 @@ std::string Qualifiers::getAddrSpaceAsString(LangAS AS) {
17921792
case LangAS::Default:
17931793
return "";
17941794
case LangAS::opencl_global:
1795-
case LangAS::sycl_global:
17961795
return "__global";
17971796
case LangAS::opencl_local:
1798-
case LangAS::sycl_local:
17991797
return "__local";
18001798
case LangAS::opencl_private:
1801-
case LangAS::sycl_private:
18021799
return "__private";
18031800
case LangAS::opencl_constant:
1804-
case LangAS::sycl_constant:
18051801
return "__constant";
18061802
case LangAS::opencl_generic:
18071803
return "__generic";

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
4848
Global, // cuda_device
4949
Constant, // cuda_constant
5050
Local, // cuda_shared
51-
Global, // sycl_global
52-
Local, // sycl_local
53-
Constant, // sycl_constant
54-
Private, // sycl_private
55-
Generic, // sycl_generic
5651
Generic, // ptr32_sptr
5752
Generic, // ptr32_uptr
5853
Generic // ptr64
@@ -68,11 +63,6 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = {
6863
Global, // cuda_device
6964
Constant, // cuda_constant
7065
Local, // cuda_shared
71-
Global, // sycl_global
72-
Local, // sycl_local
73-
Constant, // sycl_constant
74-
Private, // sycl_private
75-
Generic, // sycl_generic
7666
Generic, // ptr32_sptr
7767
Generic, // ptr32_uptr
7868
Generic // ptr64

clang/lib/Basic/Targets/NVPTX.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ static const unsigned NVPTXAddrSpaceMap[] = {
3333
1, // cuda_device
3434
4, // cuda_constant
3535
3, // cuda_shared
36-
1, // sycl_global
37-
3, // sycl_local
38-
4, // sycl_constant
39-
0, // sycl_private
40-
// FIXME: generic has to be added to the target
41-
0, // sycl_generic
4236
0, // ptr32_sptr
4337
0, // ptr32_uptr
4438
0 // ptr64

clang/lib/Basic/Targets/SPIR.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ static const unsigned SPIRAddrSpaceMap[] = {
3333
0, // cuda_device
3434
0, // cuda_constant
3535
0, // cuda_shared
36-
1, // sycl_global
37-
3, // sycl_local
38-
2, // sycl_constant
39-
0, // sycl_private
40-
4, // sycl_generic
4136
0, // ptr32_sptr
4237
0, // ptr32_uptr
4338
0 // ptr64
@@ -53,11 +48,6 @@ static const unsigned SYCLAddrSpaceMap[] = {
5348
0, // cuda_device
5449
0, // cuda_constant
5550
0, // cuda_shared
56-
1, // sycl_global
57-
3, // sycl_local
58-
2, // sycl_constant
59-
0, // sycl_private
60-
4, // sycl_generic
6151
0, // ptr32_sptr
6252
0, // ptr32_uptr
6353
0 // ptr64
@@ -70,11 +60,9 @@ class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
7060
TLSSupported = false;
7161
VLASupported = false;
7262
LongWidth = LongAlign = 64;
73-
if (Triple.getEnvironment() == llvm::Triple::SYCLDevice) {
74-
AddrSpaceMap = &SYCLAddrSpaceMap;
75-
} else {
76-
AddrSpaceMap = &SPIRAddrSpaceMap;
77-
}
63+
AddrSpaceMap = (Triple.getEnvironment() == llvm::Triple::SYCLDevice)
64+
? &SYCLAddrSpaceMap
65+
: &SPIRAddrSpaceMap;
7866
UseAddrSpaceMapMangling = true;
7967
HasLegalHalfType = true;
8068
HasFloat16 = true;

clang/lib/Basic/Targets/TCE.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ static const unsigned TCEOpenCLAddrSpaceMap[] = {
4040
0, // cuda_device
4141
0, // cuda_constant
4242
0, // cuda_shared
43-
3, // sycl_global
44-
4, // sycl_local
45-
5, // sycl_constant
46-
0, // sycl_private
47-
// FIXME: generic has to be added to the target
48-
0, // sycl_generic
4943
0, // ptr32_sptr
5044
0, // ptr32_uptr
5145
0, // ptr64

0 commit comments

Comments
 (0)