Skip to content

Commit e4ee3e0

Browse files
committed
Comments
1 parent cea8a75 commit e4ee3e0

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -702,33 +702,7 @@ class Qualifiers {
702702
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B,
703703
const ASTContext &Ctx) {
704704
// Address spaces must match exactly.
705-
return A == B ||
706-
// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
707-
// for __constant can be used as __generic.
708-
(A == LangAS::opencl_generic && B != LangAS::opencl_constant) ||
709-
// We also define global_device and global_host address spaces,
710-
// to distinguish global pointers allocated on host from pointers
711-
// allocated on device, which are a subset of __global.
712-
(A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
713-
B == LangAS::opencl_global_host)) ||
714-
(A == LangAS::sycl_global && (B == LangAS::sycl_global_device ||
715-
B == LangAS::sycl_global_host)) ||
716-
// Consider pointer size address spaces to be equivalent to default.
717-
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
718-
(isPtrSizeAddressSpace(B) || B == LangAS::Default)) ||
719-
// Default is a superset of SYCL address spaces.
720-
(A == LangAS::Default &&
721-
(B == LangAS::sycl_private || B == LangAS::sycl_local ||
722-
B == LangAS::sycl_global || B == LangAS::sycl_global_device ||
723-
B == LangAS::sycl_global_host)) ||
724-
// In HIP device compilation, any cuda address space is allowed
725-
// to implicitly cast into the default address space.
726-
(A == LangAS::Default &&
727-
(B == LangAS::cuda_constant || B == LangAS::cuda_device ||
728-
B == LangAS::cuda_shared)) ||
729-
// Conversions from target specific address spaces may be legal
730-
// depending on the target information.
731-
isTargetAddressSpaceSupersetOf(A, B, Ctx);
705+
return A == B || isTargetAddressSpaceSupersetOf(A, B, Ctx);
732706
}
733707

734708
static bool isTargetAddressSpaceSupersetOf(LangAS A, LangAS B,

clang/lib/AST/Type.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,32 @@ bool Qualifiers::isStrictSupersetOf(Qualifiers Other) const {
7575

7676
bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B,
7777
const ASTContext &Ctx) {
78-
return Ctx.getTargetInfo().isAddressSpaceSupersetOf(A, B);
78+
// In OpenCLC v2.0 s6.5.5: every address space except for __constant can be
79+
// used as __generic.
80+
return (A == LangAS::opencl_generic && B != LangAS::opencl_constant) ||
81+
// We also define global_device and global_host address spaces,
82+
// to distinguish global pointers allocated on host from pointers
83+
// allocated on device, which are a subset of __global.
84+
(A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
85+
B == LangAS::opencl_global_host)) ||
86+
(A == LangAS::sycl_global &&
87+
(B == LangAS::sycl_global_device || B == LangAS::sycl_global_host)) ||
88+
// Consider pointer size address spaces to be equivalent to default.
89+
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
90+
(isPtrSizeAddressSpace(B) || B == LangAS::Default)) ||
91+
// Default is a superset of SYCL address spaces.
92+
(A == LangAS::Default &&
93+
(B == LangAS::sycl_private || B == LangAS::sycl_local ||
94+
B == LangAS::sycl_global || B == LangAS::sycl_global_device ||
95+
B == LangAS::sycl_global_host)) ||
96+
// In HIP device compilation, any cuda address space is allowed
97+
// to implicitly cast into the default address space.
98+
(A == LangAS::Default &&
99+
(B == LangAS::cuda_constant || B == LangAS::cuda_device ||
100+
B == LangAS::cuda_shared)) ||
101+
// Conversions from target specific address spaces may be legal
102+
// depending on the target information.
103+
Ctx.getTargetInfo().isAddressSpaceSupersetOf(A, B);
79104
}
80105

81106
const IdentifierInfo* QualType::getBaseTypeIdentifier() const {

0 commit comments

Comments
 (0)