Skip to content

Commit 7db9ce8

Browse files
Fznamznonbader
authored andcommitted
[SYCL] Add aliases to OpenCL event and sampler types for SYCL
event_t and sampler_t type names are replaced with __ocl_event_t and __ocl_sampler_t to avoid potential collisions with user types. This change allows to re-use OpenCL event and sampler types for SYCL and replace OpTypeEvent and OpTypeSampler with __ocl_event_t and __ocl_sampler_t in SYCL headers. OpenCL diagnostics is not enabled. Signed-off-by: Mariya Podchishchaeva <[email protected]>
1 parent cd9de48 commit 7db9ce8

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
12851285
InitBuiltinType(ObjCBuiltinClassTy, BuiltinType::ObjCClass);
12861286
InitBuiltinType(ObjCBuiltinSelTy, BuiltinType::ObjCSel);
12871287

1288-
if (LangOpts.OpenCL) {
1288+
if (LangOpts.OpenCL || LangOpts.SYCLIsDevice) {
12891289
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
12901290
InitBuiltinType(SingletonId, BuiltinType::Id);
12911291
#include "clang/Basic/OpenCLImageTypes.def"

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO,
129129

130130
if (LangOpts.ObjC)
131131
createObjCRuntime();
132-
if (LangOpts.OpenCL)
132+
if (LangOpts.OpenCL || LangOpts.SYCLIsDevice)
133133
createOpenCLRuntime();
134134
if (LangOpts.OpenMP)
135135
createOpenMPRuntime();

clang/lib/Sema/Sema.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ void Sema::Initialize() {
264264

265265
addImplicitTypedef("size_t", Context.getSizeType());
266266
}
267+
if (getLangOpts().SYCLIsDevice) {
268+
addImplicitTypedef("__ocl_event_t", Context.OCLEventTy);
269+
addImplicitTypedef("__ocl_sampler_t", Context.OCLSamplerTy);
270+
}
267271

268272
// Initialize predefined OpenCL types and supported extensions and (optional)
269273
// core features.

0 commit comments

Comments
 (0)