125 lines · plain
1// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -fdeclare-opencl-builtins -emit-llvm -O0 -triple spir-unknown-unknown -o - | FileCheck --check-prefix=SZ32 %s2// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -fdeclare-opencl-builtins -emit-llvm -O0 -triple spir64-unknown-unknown -o - | FileCheck --check-prefix=SZ64 --check-prefix=SZ64ONLY %s3// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -fdeclare-opencl-builtins -emit-llvm -O0 -triple amdgcn -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDGCN %s4// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -fdeclare-opencl-builtins -emit-llvm -O0 -triple amdgcn---opencl -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDGCN %s5 6//SZ32: define{{.*}} i32 @test_ptrtoint_private(ptr noundef %x)7//SZ32: ptrtoint ptr %{{.*}} to i328//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_private(ptr noundef %x)9//SZ64ONLY: ptrtoint ptr %{{.*}} to i6410//AMDGCN: define{{.*}} i64 @test_ptrtoint_private(ptr addrspace(5) noundef %x)11//AMDGCN: ptrtoint ptr addrspace(5) %{{.*}} to i6412size_t test_ptrtoint_private(private char* x) {13 return (size_t)x;14}15 16//SZ32: define{{.*}} i32 @test_ptrtoint_global(ptr addrspace(1) noundef %x)17//SZ32: ptrtoint ptr addrspace(1) %{{.*}} to i3218//SZ64: define{{.*}} i64 @test_ptrtoint_global(ptr addrspace(1) noundef %x)19//SZ64: ptrtoint ptr addrspace(1) %{{.*}} to i6420intptr_t test_ptrtoint_global(global char* x) {21 return (intptr_t)x;22}23 24//SZ32: define{{.*}} i32 @test_ptrtoint_constant(ptr addrspace(2) noundef %x)25//SZ32: ptrtoint ptr addrspace(2) %{{.*}} to i3226//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_constant(ptr addrspace(2) noundef %x)27//SZ64ONLY: ptrtoint ptr addrspace(2) %{{.*}} to i6428//AMDGCN: define{{.*}} i64 @test_ptrtoint_constant(ptr addrspace(4) noundef %x)29//AMDGCN: ptrtoint ptr addrspace(4) %{{.*}} to i6430uintptr_t test_ptrtoint_constant(constant char* x) {31 return (uintptr_t)x;32}33 34//SZ32: define{{.*}} i32 @test_ptrtoint_local(ptr addrspace(3) noundef %x)35//SZ32: ptrtoint ptr addrspace(3) %{{.*}} to i3236//SZ64: define{{.*}} i64 @test_ptrtoint_local(ptr addrspace(3) noundef %x)37//SZ64: ptrtoint ptr addrspace(3) %{{.*}} to i6438size_t test_ptrtoint_local(local char* x) {39 return (size_t)x;40}41 42//SZ32: define{{.*}} i32 @test_ptrtoint_generic(ptr addrspace(4) noundef %x)43//SZ32: ptrtoint ptr addrspace(4) %{{.*}} to i3244//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_generic(ptr addrspace(4) noundef %x)45//SZ64ONLY: ptrtoint ptr addrspace(4) %{{.*}} to i6446//AMDGCN: define{{.*}} i64 @test_ptrtoint_generic(ptr noundef %x)47//AMDGCN: ptrtoint ptr %{{.*}} to i6448size_t test_ptrtoint_generic(generic char* x) {49 return (size_t)x;50}51 52//SZ32: define{{.*}} ptr @test_inttoptr_private(i32 noundef %x)53//SZ32: inttoptr i32 %{{.*}} to ptr54//SZ64ONLY: define{{.*}} ptr @test_inttoptr_private(i64 noundef %x)55//SZ64ONLY: inttoptr i64 %{{.*}} to ptr56//AMDGCN: define{{.*}} ptr addrspace(5) @test_inttoptr_private(i64 noundef %x)57//AMDGCN: trunc i64 %{{.*}} to i3258//AMDGCN: inttoptr i32 %{{.*}} to ptr addrspace(5)59private char* test_inttoptr_private(size_t x) {60 return (private char*)x;61}62 63//SZ32: define{{.*}} ptr addrspace(1) @test_inttoptr_global(i32 noundef %x)64//SZ32: inttoptr i32 %{{.*}} to ptr addrspace(1)65//SZ64: define{{.*}} ptr addrspace(1) @test_inttoptr_global(i64 noundef %x)66//SZ64: inttoptr i64 %{{.*}} to ptr addrspace(1)67global char* test_inttoptr_global(size_t x) {68 return (global char*)x;69}70 71//SZ32: define{{.*}} ptr addrspace(3) @test_add_local(ptr addrspace(3) noundef %x, i32 noundef %y)72//SZ32: getelementptr inbounds i8, ptr addrspace(3) %{{.*}}, i3273//SZ64: define{{.*}} ptr addrspace(3) @test_add_local(ptr addrspace(3) noundef %x, i64 noundef %y)74//AMDGCN: trunc i64 %{{.*}} to i3275//AMDGCN: getelementptr inbounds i8, ptr addrspace(3) %{{.*}}, i3276//SZ64ONLY: getelementptr inbounds i8, ptr addrspace(3) %{{.*}}, i6477local char* test_add_local(local char* x, ptrdiff_t y) {78 return x + y;79}80 81//SZ32: define{{.*}} ptr addrspace(1) @test_add_global(ptr addrspace(1) noundef %x, i32 noundef %y)82//SZ32: getelementptr inbounds i8, ptr addrspace(1) %{{.*}}, i3283//SZ64: define{{.*}} ptr addrspace(1) @test_add_global(ptr addrspace(1) noundef %x, i64 noundef %y)84//SZ64: getelementptr inbounds i8, ptr addrspace(1) %{{.*}}, i6485global char* test_add_global(global char* x, ptrdiff_t y) {86 return x + y;87}88 89//SZ32: define{{.*}} i32 @test_sub_local(ptr addrspace(3) noundef %x, ptr addrspace(3) noundef %y)90//SZ32: ptrtoint ptr addrspace(3) %{{.*}} to i3291//SZ32: ptrtoint ptr addrspace(3) %{{.*}} to i3292//SZ64: define{{.*}} i64 @test_sub_local(ptr addrspace(3) noundef %x, ptr addrspace(3) noundef %y)93//SZ64: ptrtoint ptr addrspace(3) %{{.*}} to i6494//SZ64: ptrtoint ptr addrspace(3) %{{.*}} to i6495ptrdiff_t test_sub_local(local char* x, local char *y) {96 return x - y;97}98 99//SZ32: define{{.*}} i32 @test_sub_private(ptr noundef %x, ptr noundef %y)100//SZ32: ptrtoint ptr %{{.*}} to i32101//SZ32: ptrtoint ptr %{{.*}} to i32102//SZ64ONLY: define{{.*}} i64 @test_sub_private(ptr noundef %x, ptr noundef %y)103//SZ64ONLY: ptrtoint ptr %{{.*}} to i64104//SZ64ONLY: ptrtoint ptr %{{.*}} to i64105//AMDGCN: define{{.*}} i64 @test_sub_private(ptr addrspace(5) noundef %x, ptr addrspace(5) noundef %y)106//AMDGCN: ptrtoint ptr addrspace(5) %{{.*}} to i64107//AMDGCN: ptrtoint ptr addrspace(5) %{{.*}} to i64108ptrdiff_t test_sub_private(private char* x, private char *y) {109 return x - y;110}111 112//SZ32: define{{.*}} i32 @test_sub_mix(ptr noundef %x, ptr addrspace(4) noundef %y)113//SZ32: ptrtoint ptr %{{.*}} to i32114//SZ32: ptrtoint ptr addrspace(4) %{{.*}} to i32115//SZ64ONLY: define{{.*}} i64 @test_sub_mix(ptr noundef %x, ptr addrspace(4) noundef %y)116//SZ64ONLY: ptrtoint ptr %{{.*}} to i64117//SZ64ONLY: ptrtoint ptr addrspace(4) %{{.*}} to i64118//AMDGCN: define{{.*}} i64 @test_sub_mix(ptr addrspace(5) noundef %x, ptr noundef %y)119//AMDGCN: ptrtoint ptr addrspace(5) %{{.*}} to i64120//AMDGCN: ptrtoint ptr %{{.*}} to i64121ptrdiff_t test_sub_mix(private char* x, generic char *y) {122 return x - y;123}124 125