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=AMDONLY %s
5 //SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x)
6 //SZ32: ptrtoint i8* %{{.*}} to i32
7 //SZ64: define{{.*}} i64 @test_ptrtoint_private(i8* %x)
8 //SZ64: ptrtoint i8* %{{.*}} to i64
9 size_t test_ptrtoint_private(private char* x) {
13 //SZ32: define{{.*}} i32 @test_ptrtoint_global(i8 addrspace(1)* %x)
14 //SZ32: ptrtoint i8 addrspace(1)* %{{.*}} to i32
15 //SZ64: define{{.*}} i64 @test_ptrtoint_global(i8 addrspace(1)* %x)
16 //SZ64: ptrtoint i8 addrspace(1)* %{{.*}} to i64
17 intptr_t test_ptrtoint_global(global char* x) {
21 //SZ32: define{{.*}} i32 @test_ptrtoint_constant(i8 addrspace(2)* %x)
22 //SZ32: ptrtoint i8 addrspace(2)* %{{.*}} to i32
23 //SZ64: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(2)* %x)
24 //SZ64: ptrtoint i8 addrspace(2)* %{{.*}} to i64
25 uintptr_t test_ptrtoint_constant(constant char* x) {
29 //SZ32: define{{.*}} i32 @test_ptrtoint_local(i8 addrspace(3)* %x)
30 //SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
31 //SZ64: define{{.*}} i64 @test_ptrtoint_local(i8 addrspace(3)* %x)
32 //SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
33 size_t test_ptrtoint_local(local char* x) {
37 //SZ32: define{{.*}} i32 @test_ptrtoint_generic(i8 addrspace(4)* %x)
38 //SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
39 //SZ64: define{{.*}} i64 @test_ptrtoint_generic(i8 addrspace(4)* %x)
40 //SZ64: ptrtoint i8 addrspace(4)* %{{.*}} to i64
41 size_t test_ptrtoint_generic(generic char* x) {
45 //SZ32: define{{.*}} i8* @test_inttoptr_private(i32 %x)
46 //SZ32: inttoptr i32 %{{.*}} to i8*
47 //SZ64: define{{.*}} i8* @test_inttoptr_private(i64 %x)
48 //AMDONLY: trunc i64 %{{.*}} to i32
49 //AMDONLY: inttoptr i32 %{{.*}} to i8*
50 //SZ64ONLY: inttoptr i64 %{{.*}} to i8*
51 private char* test_inttoptr_private(size_t x) {
52 return (private char*)x;
55 //SZ32: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i32 %x)
56 //SZ32: inttoptr i32 %{{.*}} to i8 addrspace(1)*
57 //SZ64: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i64 %x)
58 //SZ64: inttoptr i64 %{{.*}} to i8 addrspace(1)*
59 global char* test_inttoptr_global(size_t x) {
60 return (global char*)x;
63 //SZ32: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i32 %y)
64 //SZ32: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
65 //SZ64: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i64 %y)
66 //AMDONLY: trunc i64 %{{.*}} to i32
67 //AMDONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
68 //SZ64ONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i64
69 local char* test_add_local(local char* x, ptrdiff_t y) {
73 //SZ32: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i32 %y)
74 //SZ32: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i32
75 //SZ64: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i64 %y)
76 //SZ64: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i64
77 global char* test_add_global(global char* x, ptrdiff_t y) {
81 //SZ32: define{{.*}} i32 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
82 //SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
83 //SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
84 //SZ64: define{{.*}} i64 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
85 //SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
86 //SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
87 ptrdiff_t test_sub_local(local char* x, local char *y) {
91 //SZ32: define{{.*}} i32 @test_sub_private(i8* %x, i8* %y)
92 //SZ32: ptrtoint i8* %{{.*}} to i32
93 //SZ32: ptrtoint i8* %{{.*}} to i32
94 //SZ64: define{{.*}} i64 @test_sub_private(i8* %x, i8* %y)
95 //SZ64: ptrtoint i8* %{{.*}} to i64
96 //SZ64: ptrtoint i8* %{{.*}} to i64
97 ptrdiff_t test_sub_private(private char* x, private char *y) {
101 //SZ32: define{{.*}} i32 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
102 //SZ32: ptrtoint i8* %{{.*}} to i32
103 //SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
104 //SZ64: define{{.*}} i64 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
105 //SZ64: ptrtoint i8* %{{.*}} to i64
106 //SZ64: ptrtoint i8 addrspace(4)* %{{.*}} to i64
107 ptrdiff_t test_sub_mix(private char* x, generic char *y) {