
This patch is part of the upstreaming effort for supporting SYCL language front end. It makes the following changes: 1. Adds sycl_external attribute for functions with external linkage, which is intended for use to implement the SYCL_EXTERNAL macro as specified by the SYCL 2020 specification 2. Adds checks to avoid emitting device code when sycl_external and sycl_kernel_entry_point attributes are not enabled 3. Fixes test failures caused by the above changes This patch is missing diagnostics for the following diagnostics listed in the SYCL 2020 specification's section 5.10.1, which will be addressed in a subsequent PR: Functions that are declared using SYCL_EXTERNAL have the following additional restrictions beyond those imposed on other device functions: 1. If the SYCL backend does not support the generic address space then the function cannot use raw pointers as parameter or return types. Explicit pointer classes must be used instead; 2. The function cannot call group::parallel_for_work_item; 3. The function cannot be called from a parallel_for_work_group scope. In addition to that, the subsequent PR will also implement diagnostics for inline functions including virtual functions defined as inline. --------- Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
26 lines
1.5 KiB
C++
26 lines
1.5 KiB
C++
// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple spirv64 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=SPV
|
|
// RUN: %clang_cc1 -Wno-unused-value -O0 -internal-isystem %S/../../lib/Headers -include __clang_spirv_builtins.h -triple nvptx64 -emit-llvm %s -fsycl-is-device -o - | FileCheck %s -check-prefixes=NV
|
|
|
|
|
|
// SPV: void @_Z9test_castPi
|
|
// SPV: call noundef ptr addrspace(1) @llvm.spv.generic.cast.to.ptr.explicit.p1
|
|
// SPV: call noundef ptr addrspace(3) @llvm.spv.generic.cast.to.ptr.explicit.p3
|
|
// SPV: call noundef ptr @llvm.spv.generic.cast.to.ptr.explicit.p0
|
|
// SPV: addrspacecast ptr addrspace(4) %{{.*}} to ptr addrspace(1)
|
|
// SPV: addrspacecast ptr addrspace(4) %{{.*}} to ptr addrspace(3)
|
|
// SPV: addrspacecast ptr addrspace(4) %{{.*}} to ptr
|
|
// NV: void @_Z9test_castPi
|
|
// NV: call noundef ptr addrspace(1) @_Z41__spirv_GenericCastToPtrExplicit_ToGlobalPvi
|
|
// NV: call noundef ptr addrspace(3) @_Z40__spirv_GenericCastToPtrExplicit_ToLocalPvi
|
|
// NV: call noundef ptr @_Z42__spirv_GenericCastToPtrExplicit_ToPrivatePvi
|
|
// NV: addrspacecast ptr %{{.*}} to ptr addrspace(1)
|
|
// NV: addrspacecast ptr %{{.*}} to ptr addrspace(3)
|
|
[[clang::sycl_external]] void test_cast(int* p) {
|
|
__spirv_GenericCastToPtrExplicit_ToGlobal(p, 5);
|
|
__spirv_GenericCastToPtrExplicit_ToLocal(p, 4);
|
|
__spirv_GenericCastToPtrExplicit_ToPrivate(p, 7);
|
|
__spirv_GenericCastToPtr_ToGlobal(p, 5);
|
|
__spirv_GenericCastToPtr_ToLocal(p, 4);
|
|
__spirv_GenericCastToPtr_ToPrivate(p, 7);
|
|
}
|