blob: 51c81db3126a155e1d15d96e06e5bbc7231f64b0 [file] [log] [blame]
Yaxun Liu26f75662016-08-19 05:17:25 +00001// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir-unknown-unknown -o - | FileCheck --check-prefix=SZ32 %s
2// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir64-unknown-unknown -o - | FileCheck --check-prefix=SZ64 --check-prefix=SZ64ONLY %s
Yaxun Liuf5f45e52018-02-02 16:08:24 +00003// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple amdgcn -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDGCN %s
4// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple amdgcn---opencl -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDGCN %s
Yaxun Liu26f75662016-08-19 05:17:25 +00005
6//SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x)
7//SZ32: ptrtoint i8* %{{.*}} to i32
Yaxun Liuf5f45e52018-02-02 16:08:24 +00008//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_private(i8* %x)
9//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
10//AMDGCN: define{{.*}} i64 @test_ptrtoint_private(i8 addrspace(5)* %x)
11//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
Yaxun Liu26f75662016-08-19 05:17:25 +000012size_t test_ptrtoint_private(private char* x) {
13 return (size_t)x;
14}
15
16//SZ32: define{{.*}} i32 @test_ptrtoint_global(i8 addrspace(1)* %x)
17//SZ32: ptrtoint i8 addrspace(1)* %{{.*}} to i32
18//SZ64: define{{.*}} i64 @test_ptrtoint_global(i8 addrspace(1)* %x)
19//SZ64: ptrtoint i8 addrspace(1)* %{{.*}} to i64
20intptr_t test_ptrtoint_global(global char* x) {
21 return (intptr_t)x;
22}
23
24//SZ32: define{{.*}} i32 @test_ptrtoint_constant(i8 addrspace(2)* %x)
25//SZ32: ptrtoint i8 addrspace(2)* %{{.*}} to i32
26//SZ64: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(2)* %x)
27//SZ64: ptrtoint i8 addrspace(2)* %{{.*}} to i64
28uintptr_t test_ptrtoint_constant(constant char* x) {
29 return (uintptr_t)x;
30}
31
32//SZ32: define{{.*}} i32 @test_ptrtoint_local(i8 addrspace(3)* %x)
33//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
34//SZ64: define{{.*}} i64 @test_ptrtoint_local(i8 addrspace(3)* %x)
35//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
36size_t test_ptrtoint_local(local char* x) {
37 return (size_t)x;
38}
39
40//SZ32: define{{.*}} i32 @test_ptrtoint_generic(i8 addrspace(4)* %x)
41//SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
Yaxun Liuf5f45e52018-02-02 16:08:24 +000042//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_generic(i8 addrspace(4)* %x)
43//SZ64ONLY: ptrtoint i8 addrspace(4)* %{{.*}} to i64
44//AMDGCN: define{{.*}} i64 @test_ptrtoint_generic(i8* %x)
45//AMDGCN: ptrtoint i8* %{{.*}} to i64
Yaxun Liu26f75662016-08-19 05:17:25 +000046size_t test_ptrtoint_generic(generic char* x) {
47 return (size_t)x;
48}
49
50//SZ32: define{{.*}} i8* @test_inttoptr_private(i32 %x)
51//SZ32: inttoptr i32 %{{.*}} to i8*
Yaxun Liuf5f45e52018-02-02 16:08:24 +000052//SZ64ONLY: define{{.*}} i8* @test_inttoptr_private(i64 %x)
Yaxun Liu26f75662016-08-19 05:17:25 +000053//SZ64ONLY: inttoptr i64 %{{.*}} to i8*
Yaxun Liuf5f45e52018-02-02 16:08:24 +000054//AMDGCN: define{{.*}} i8 addrspace(5)* @test_inttoptr_private(i64 %x)
55//AMDGCN: trunc i64 %{{.*}} to i32
56//AMDGCN: inttoptr i32 %{{.*}} to i8 addrspace(5)*
Yaxun Liu26f75662016-08-19 05:17:25 +000057private char* test_inttoptr_private(size_t x) {
58 return (private char*)x;
59}
60
61//SZ32: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i32 %x)
62//SZ32: inttoptr i32 %{{.*}} to i8 addrspace(1)*
63//SZ64: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i64 %x)
64//SZ64: inttoptr i64 %{{.*}} to i8 addrspace(1)*
65global char* test_inttoptr_global(size_t x) {
66 return (global char*)x;
67}
68
69//SZ32: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i32 %y)
70//SZ32: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
71//SZ64: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i64 %y)
Yaxun Liuf5f45e52018-02-02 16:08:24 +000072//AMDGCN: trunc i64 %{{.*}} to i32
73//AMDGCN: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
Yaxun Liu26f75662016-08-19 05:17:25 +000074//SZ64ONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i64
75local char* test_add_local(local char* x, ptrdiff_t y) {
76 return x + y;
77}
78
79//SZ32: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i32 %y)
80//SZ32: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i32
81//SZ64: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i64 %y)
82//SZ64: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i64
83global char* test_add_global(global char* x, ptrdiff_t y) {
84 return x + y;
85}
86
87//SZ32: define{{.*}} i32 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
88//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
89//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
90//SZ64: define{{.*}} i64 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
91//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
92//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
93ptrdiff_t test_sub_local(local char* x, local char *y) {
94 return x - y;
95}
96
97//SZ32: define{{.*}} i32 @test_sub_private(i8* %x, i8* %y)
98//SZ32: ptrtoint i8* %{{.*}} to i32
99//SZ32: ptrtoint i8* %{{.*}} to i32
Yaxun Liuf5f45e52018-02-02 16:08:24 +0000100//SZ64ONLY: define{{.*}} i64 @test_sub_private(i8* %x, i8* %y)
101//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
102//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
103//AMDGCN: define{{.*}} i64 @test_sub_private(i8 addrspace(5)* %x, i8 addrspace(5)* %y)
104//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
105//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
Yaxun Liu26f75662016-08-19 05:17:25 +0000106ptrdiff_t test_sub_private(private char* x, private char *y) {
107 return x - y;
108}
109
110//SZ32: define{{.*}} i32 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
111//SZ32: ptrtoint i8* %{{.*}} to i32
112//SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
Yaxun Liuf5f45e52018-02-02 16:08:24 +0000113//SZ64ONLY: define{{.*}} i64 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
114//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
115//SZ64ONLY: ptrtoint i8 addrspace(4)* %{{.*}} to i64
116//AMDGCN: define{{.*}} i64 @test_sub_mix(i8 addrspace(5)* %x, i8* %y)
117//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
118//AMDGCN: ptrtoint i8* %{{.*}} to i64
Yaxun Liu26f75662016-08-19 05:17:25 +0000119ptrdiff_t test_sub_mix(private char* x, generic char *y) {
120 return x - y;
121}
122