Skip to content

[SYCL] Fix builtins address space type #4275

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

Merged
merged 5 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions clang/include/clang/Basic/AddressSpaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,40 @@ inline bool isPtrSizeAddressSpace(LangAS AS) {
AS == LangAS::ptr64);
}

inline LangAS asSYCLLangAS(LangAS AS) {
switch (AS) {
case LangAS::opencl_global:
return LangAS::sycl_global;
case LangAS::opencl_global_device:
return LangAS::sycl_global_device;
case LangAS::opencl_global_host:
return LangAS::sycl_global_host;
case LangAS::opencl_local:
return LangAS::sycl_local;
case LangAS::opencl_private:
return LangAS::sycl_private;
default:
return AS;
}
}

inline LangAS asOpenCLLangAS(LangAS AS) {
switch (AS) {
case LangAS::sycl_global:
return LangAS::opencl_global;
case LangAS::sycl_global_device:
return LangAS::opencl_global_device;
case LangAS::sycl_global_host:
return LangAS::opencl_global_host;
case LangAS::sycl_local:
return LangAS::opencl_local;
case LangAS::sycl_private:
return LangAS::opencl_private;
default:
return AS;
}
}

} // namespace clang

#endif // LLVM_CLANG_BASIC_ADDRESSSPACES_H
4 changes: 3 additions & 1 deletion clang/utils/TableGen/ClangProgModelBuiltinEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,9 @@ static QualType getOpenCLTypedefType(Sema &S, llvm::StringRef Name);
// [const|volatile] pointers, so this is ok to do it as a last step.
if (Ty.IsPointer != 0) {
for (unsigned Index = 0; Index < QT.size(); Index++) {
QT[Index] = Context.getAddrSpaceQualType(QT[Index], Ty.AS);
QT[Index] = Context.getAddrSpaceQualType(
QT[Index], S.getLangOpts().SYCLIsDevice ? asSYCLLangAS(Ty.AS)
: asOpenCLLangAS(Ty.AS));
QT[Index] = Context.getPointerType(QT[Index]);
}
}
Expand Down