Skip to content

Commit e90a3b7

Browse files
committed
Add frontend tests
1 parent 5510208 commit e90a3b7

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,24 @@ const stream& operator<<(const stream &S, T&&) {
649649
return S;
650650
}
651651

652+
// Dummy implementation of work_group_memory for use in CodeGenSYCL tests.
653+
template <typename DataT>
654+
class __attribute__((sycl_special_class))
655+
__SYCL_TYPE(work_group_memory) work_group_memory {
656+
public:
657+
work_group_memory(handler &CGH) {}
658+
#ifdef __SYCL_DEVICE_ONLY__
659+
// Default constructor for objects later initialized with __init member.
660+
work_group_memory() = default;
661+
#endif
662+
663+
void __init(__attribute((opencl_local)) DataT *Ptr) { this->Ptr = Ptr; }
664+
__attribute((opencl_local)) DataT *operator&() const { return Ptr; }
665+
666+
private:
667+
__attribute((opencl_local)) DataT *Ptr;
668+
};
669+
652670
template <typename T, int dimensions = 1,
653671
typename AllocatorT = int /*fake type as AllocatorT is not used*/>
654672
class buffer {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o %t.ll
2+
// RUN: FileCheck < %t.ll %s --check-prefix CHECK-IR
3+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -fsycl-int-header=%t.h %s
4+
// RUN: FileCheck < %t.h %s --check-prefix CHECK-INT-HEADER
5+
//
6+
// CHECK-IR: define dso_local spir_kernel void @
7+
// CHECK-IR-SAME: ptr addrspace(3) noundef align 4 [[PTR:%[a-zA-Z0-9_]+]]
8+
//
9+
// CHECK-IR: [[PTR]].addr = alloca ptr addrspace(3), align 8
10+
// CHECK-IR: [[PTR]].addr.ascast = addrspacecast ptr %_arg_mem.addr to ptr addrspace(4)
11+
// CHECK-IR: store ptr addrspace(3) [[PTR]], ptr addrspace(4) [[PTR]].addr.ascast, align 8
12+
// CHECK-IR: [[PTR_LOAD:%[a-zA-Z0-9_]+]] = load ptr addrspace(3), ptr addrspace(4) [[PTR]].addr.ascast, align 8
13+
//
14+
// CHECK-IR: call spir_func void @{{.*}}__init{{.*}}(ptr addrspace(4) noundef align 8 dereferenceable_or_null(8) %{{[a-zA-Z0-9_]+}}, ptr addrspace(3) noundef [[PTR_LOAD]])
15+
//
16+
// CHECK-INT-HEADER: const kernel_param_desc_t kernel_signatures[] = {
17+
// CHECK-INT-HEADER-NEXT: //{{.*}}
18+
// CHECK-INT-HEADER-NEXT: { kernel_param_kind_t::kind_work_group_memory, 8, 0 },
19+
20+
#include "Inputs/sycl.hpp"
21+
22+
int main() {
23+
sycl::queue Q;
24+
Q.submit([&](sycl::handler &CGH) {
25+
sycl::work_group_memory<int> mem;
26+
sycl::range<1> ndr;
27+
CGH.parallel_for(ndr, [=](sycl::item<1> it) { int *ptr = &mem; });
28+
});
29+
return 0;
30+
}

0 commit comments

Comments
 (0)