1// REQUIRES: amdgpu-registered-target
2// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown -target-cpu hawaii -S -emit-llvm -o - %s | FileCheck %s
3// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown -target-cpu fiji -S -emit-llvm -o - %s | FileCheck %s
4// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown -target-cpu gfx906 -S -emit-llvm -o - %s | FileCheck %s
5// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S -emit-llvm -o - %s | FileCheck %s
6
7typedef unsigned int uint;
8typedef unsigned long ulong;
9
10// CHECK-LABEL: @test_s_dcache_inv_vol
11// CHECK: call void @llvm.amdgcn.s.dcache.inv.vol(
12void test_s_dcache_inv_vol()
13{
14  __builtin_amdgcn_s_dcache_inv_vol();
15}
16
17// CHECK-LABEL: @test_buffer_wbinvl1_vol
18// CHECK: call void @llvm.amdgcn.buffer.wbinvl1.vol()
19void test_buffer_wbinvl1_vol()
20{
21  __builtin_amdgcn_buffer_wbinvl1_vol();
22}
23
24// CHECK-LABEL: @test_gws_sema_release_all(
25// CHECK: call void @llvm.amdgcn.ds.gws.sema.release.all(i32 %{{[0-9]+}})
26void test_gws_sema_release_all(uint id)
27{
28  __builtin_amdgcn_ds_gws_sema_release_all(id);
29}
30
31// CHECK-LABEL: @test_s_memtime
32// CHECK: call i64 @llvm.amdgcn.s.memtime()
33void test_s_memtime(global ulong* out)
34{
35  *out = __builtin_amdgcn_s_memtime();
36}
37
38// CHECK-LABEL: @test_is_shared(
39// CHECK: [[CAST:%[0-9]+]] = bitcast i32* %{{[0-9]+}} to i8*
40// CHECK: call i1 @llvm.amdgcn.is.shared(i8* [[CAST]]
41int test_is_shared(const int* ptr) {
42  return __builtin_amdgcn_is_shared(ptr);
43}
44
45// CHECK-LABEL: @test_is_private(
46// CHECK: [[CAST:%[0-9]+]] = bitcast i32* %{{[0-9]+}} to i8*
47// CHECK: call i1 @llvm.amdgcn.is.private(i8* [[CAST]]
48int test_is_private(const int* ptr) {
49  return __builtin_amdgcn_is_private(ptr);
50}
51
52// CHECK-LABEL: @test_is_shared_global(
53// CHECK: [[CAST:%[0-9]+]] = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i8*
54// CHECK: call i1 @llvm.amdgcn.is.shared(i8* [[CAST]]
55int test_is_shared_global(const global int* ptr) {
56  return __builtin_amdgcn_is_shared(ptr);
57}
58
59// CHECK-LABEL: @test_is_private_global(
60// CHECK: [[CAST:%[0-9]+]] = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i8*
61// CHECK: call i1 @llvm.amdgcn.is.private(i8* [[CAST]]
62int test_is_private_global(const global int* ptr) {
63  return __builtin_amdgcn_is_private(ptr);
64}
65
66// CHECK-LABEL: @test_groupstaticsize
67// CHECK: call i32 @llvm.amdgcn.groupstaticsize()
68void test_groupstaticsize(global uint* out) {
69  *out = __builtin_amdgcn_groupstaticsize();
70}
71