1 | // 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 |
3 | // 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 |
5 | |
6 | //SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x) |
7 | //SZ32: ptrtoint i8* %{{.*}} to i32 |
8 | //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 |
12 | size_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 |
20 | intptr_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 | //SZ64ONLY: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(2)* %x) |
27 | //SZ64ONLY: ptrtoint i8 addrspace(2)* %{{.*}} to i64 |
28 | //AMDGCN: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(4)* %x) |
29 | //AMDGCN: ptrtoint i8 addrspace(4)* %{{.*}} to i64 |
30 | uintptr_t test_ptrtoint_constant(constant char* x) { |
31 | return (uintptr_t)x; |
32 | } |
33 | |
34 | //SZ32: define{{.*}} i32 @test_ptrtoint_local(i8 addrspace(3)* %x) |
35 | //SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32 |
36 | //SZ64: define{{.*}} i64 @test_ptrtoint_local(i8 addrspace(3)* %x) |
37 | //SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64 |
38 | size_t test_ptrtoint_local(local char* x) { |
39 | return (size_t)x; |
40 | } |
41 | |
42 | //SZ32: define{{.*}} i32 @test_ptrtoint_generic(i8 addrspace(4)* %x) |
43 | //SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32 |
44 | //SZ64ONLY: define{{.*}} i64 @test_ptrtoint_generic(i8 addrspace(4)* %x) |
45 | //SZ64ONLY: ptrtoint i8 addrspace(4)* %{{.*}} to i64 |
46 | //AMDGCN: define{{.*}} i64 @test_ptrtoint_generic(i8* %x) |
47 | //AMDGCN: ptrtoint i8* %{{.*}} to i64 |
48 | size_t test_ptrtoint_generic(generic char* x) { |
49 | return (size_t)x; |
50 | } |
51 | |
52 | //SZ32: define{{.*}} i8* @test_inttoptr_private(i32 %x) |
53 | //SZ32: inttoptr i32 %{{.*}} to i8* |
54 | //SZ64ONLY: define{{.*}} i8* @test_inttoptr_private(i64 %x) |
55 | //SZ64ONLY: inttoptr i64 %{{.*}} to i8* |
56 | //AMDGCN: define{{.*}} i8 addrspace(5)* @test_inttoptr_private(i64 %x) |
57 | //AMDGCN: trunc i64 %{{.*}} to i32 |
58 | //AMDGCN: inttoptr i32 %{{.*}} to i8 addrspace(5)* |
59 | private char* test_inttoptr_private(size_t x) { |
60 | return (private char*)x; |
61 | } |
62 | |
63 | //SZ32: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i32 %x) |
64 | //SZ32: inttoptr i32 %{{.*}} to i8 addrspace(1)* |
65 | //SZ64: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i64 %x) |
66 | //SZ64: inttoptr i64 %{{.*}} to i8 addrspace(1)* |
67 | global char* test_inttoptr_global(size_t x) { |
68 | return (global char*)x; |
69 | } |
70 | |
71 | //SZ32: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i32 %y) |
72 | //SZ32: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32 |
73 | //SZ64: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i64 %y) |
74 | //AMDGCN: trunc i64 %{{.*}} to i32 |
75 | //AMDGCN: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32 |
76 | //SZ64ONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i64 |
77 | local char* test_add_local(local char* x, ptrdiff_t y) { |
78 | return x + y; |
79 | } |
80 | |
81 | //SZ32: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i32 %y) |
82 | //SZ32: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i32 |
83 | //SZ64: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i64 %y) |
84 | //SZ64: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i64 |
85 | global char* test_add_global(global char* x, ptrdiff_t y) { |
86 | return x + y; |
87 | } |
88 | |
89 | //SZ32: define{{.*}} i32 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y) |
90 | //SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32 |
91 | //SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32 |
92 | //SZ64: define{{.*}} i64 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y) |
93 | //SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64 |
94 | //SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64 |
95 | ptrdiff_t test_sub_local(local char* x, local char *y) { |
96 | return x - y; |
97 | } |
98 | |
99 | //SZ32: define{{.*}} i32 @test_sub_private(i8* %x, i8* %y) |
100 | //SZ32: ptrtoint i8* %{{.*}} to i32 |
101 | //SZ32: ptrtoint i8* %{{.*}} to i32 |
102 | //SZ64ONLY: define{{.*}} i64 @test_sub_private(i8* %x, i8* %y) |
103 | //SZ64ONLY: ptrtoint i8* %{{.*}} to i64 |
104 | //SZ64ONLY: ptrtoint i8* %{{.*}} to i64 |
105 | //AMDGCN: define{{.*}} i64 @test_sub_private(i8 addrspace(5)* %x, i8 addrspace(5)* %y) |
106 | //AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64 |
107 | //AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64 |
108 | ptrdiff_t test_sub_private(private char* x, private char *y) { |
109 | return x - y; |
110 | } |
111 | |
112 | //SZ32: define{{.*}} i32 @test_sub_mix(i8* %x, i8 addrspace(4)* %y) |
113 | //SZ32: ptrtoint i8* %{{.*}} to i32 |
114 | //SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32 |
115 | //SZ64ONLY: define{{.*}} i64 @test_sub_mix(i8* %x, i8 addrspace(4)* %y) |
116 | //SZ64ONLY: ptrtoint i8* %{{.*}} to i64 |
117 | //SZ64ONLY: ptrtoint i8 addrspace(4)* %{{.*}} to i64 |
118 | //AMDGCN: define{{.*}} i64 @test_sub_mix(i8 addrspace(5)* %x, i8* %y) |
119 | //AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64 |
120 | //AMDGCN: ptrtoint i8* %{{.*}} to i64 |
121 | ptrdiff_t test_sub_mix(private char* x, generic char *y) { |
122 | return x - y; |
123 | } |
124 | |
125 | |