| 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 %s |
| 2 |
// 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 %s |
| 3 |
// 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 %s |
| 4 |
// 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 %s |
| 5 |
|
| 6 |
//SZ32: define{{.*}} i32 @test_ptrtoint_private(ptr noundef %x) |
| 7 |
//SZ32: ptrtoint ptr %{{.*}} to i32 |
| 8 |
//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_private(ptr noundef %x) |
| 9 |
//SZ64ONLY: ptrtoint ptr %{{.*}} to i64 |
| 10 |
//AMDGCN: define{{.*}} i64 @test_ptrtoint_private(ptr addrspace(5) noundef %x) |
| 11 |
//AMDGCN: ptrtoint ptr 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(ptr addrspace(1) noundef %x) |
| 17 |
//SZ32: ptrtoint ptr addrspace(1) %{{.*}} to i32 |
| 18 |
//SZ64: define{{.*}} i64 @test_ptrtoint_global(ptr addrspace(1) noundef %x) |
| 19 |
//SZ64: ptrtoint ptr 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(ptr addrspace(2) noundef %x) |
| 25 |
//SZ32: ptrtoint ptr addrspace(2) %{{.*}} to i32 |
| 26 |
//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_constant(ptr addrspace(2) noundef %x) |
| 27 |
//SZ64ONLY: ptrtoint ptr addrspace(2) %{{.*}} to i64 |
| 28 |
//AMDGCN: define{{.*}} i64 @test_ptrtoint_constant(ptr addrspace(4) noundef %x) |
| 29 |
//AMDGCN: ptrtoint ptr 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(ptr addrspace(3) noundef %x) |
| 35 |
//SZ32: ptrtoint ptr addrspace(3) %{{.*}} to i32 |
| 36 |
//SZ64: define{{.*}} i64 @test_ptrtoint_local(ptr addrspace(3) noundef %x) |
| 37 |
//SZ64: ptrtoint ptr 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(ptr addrspace(4) noundef %x) |
| 43 |
//SZ32: ptrtoint ptr addrspace(4) %{{.*}} to i32 |
| 44 |
//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_generic(ptr addrspace(4) noundef %x) |
| 45 |
//SZ64ONLY: ptrtoint ptr addrspace(4) %{{.*}} to i64 |
| 46 |
//AMDGCN: define{{.*}} i64 @test_ptrtoint_generic(ptr noundef %x) |
| 47 |
//AMDGCN: ptrtoint ptr %{{.*}} to i64 |
| 48 |
size_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 ptr |
| 54 |
//SZ64ONLY: define{{.*}} ptr @test_inttoptr_private(i64 noundef %x) |
| 55 |
//SZ64ONLY: inttoptr i64 %{{.*}} to ptr |
| 56 |
//AMDGCN: define{{.*}} ptr addrspace(5) @test_inttoptr_private(i64 noundef %x) |
| 57 |
//AMDGCN: trunc i64 %{{.*}} to i32 |
| 58 |
//AMDGCN: inttoptr i32 %{{.*}} to ptr addrspace(5) |
| 59 |
private 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) |
| 67 |
global 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) %{{.*}}, i32 |
| 73 |
//SZ64: define{{.*}} ptr addrspace(3) @test_add_local(ptr addrspace(3) noundef %x, i64 noundef %y) |
| 74 |
//AMDGCN: trunc i64 %{{.*}} to i32 |
| 75 |
//AMDGCN: getelementptr inbounds i8, ptr addrspace(3) %{{.*}}, i32 |
| 76 |
//SZ64ONLY: getelementptr inbounds i8, ptr addrspace(3) %{{.*}}, i64 |
| 77 |
local 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) %{{.*}}, i32 |
| 83 |
//SZ64: define{{.*}} ptr addrspace(1) @test_add_global(ptr addrspace(1) noundef %x, i64 noundef %y) |
| 84 |
//SZ64: getelementptr inbounds i8, ptr 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(ptr addrspace(3) noundef %x, ptr addrspace(3) noundef %y) |
| 90 |
//SZ32: ptrtoint ptr addrspace(3) %{{.*}} to i32 |
| 91 |
//SZ32: ptrtoint ptr addrspace(3) %{{.*}} to i32 |
| 92 |
//SZ64: define{{.*}} i64 @test_sub_local(ptr addrspace(3) noundef %x, ptr addrspace(3) noundef %y) |
| 93 |
//SZ64: ptrtoint ptr addrspace(3) %{{.*}} to i64 |
| 94 |
//SZ64: ptrtoint ptr 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(ptr noundef %x, ptr noundef %y) |
| 100 |
//SZ32: ptrtoint ptr %{{.*}} to i32 |
| 101 |
//SZ32: ptrtoint ptr %{{.*}} to i32 |
| 102 |
//SZ64ONLY: define{{.*}} i64 @test_sub_private(ptr noundef %x, ptr noundef %y) |
| 103 |
//SZ64ONLY: ptrtoint ptr %{{.*}} to i64 |
| 104 |
//SZ64ONLY: ptrtoint ptr %{{.*}} to i64 |
| 105 |
//AMDGCN: define{{.*}} i64 @test_sub_private(ptr addrspace(5) noundef %x, ptr addrspace(5) noundef %y) |
| 106 |
//AMDGCN: ptrtoint ptr addrspace(5) %{{.*}} to i64 |
| 107 |
//AMDGCN: ptrtoint ptr 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(ptr noundef %x, ptr addrspace(4) noundef %y) |
| 113 |
//SZ32: ptrtoint ptr %{{.*}} to i32 |
| 114 |
//SZ32: ptrtoint ptr addrspace(4) %{{.*}} to i32 |
| 115 |
//SZ64ONLY: define{{.*}} i64 @test_sub_mix(ptr noundef %x, ptr addrspace(4) noundef %y) |
| 116 |
//SZ64ONLY: ptrtoint ptr %{{.*}} to i64 |
| 117 |
//SZ64ONLY: ptrtoint ptr addrspace(4) %{{.*}} to i64 |
| 118 |
//AMDGCN: define{{.*}} i64 @test_sub_mix(ptr addrspace(5) noundef %x, ptr noundef %y) |
| 119 |
//AMDGCN: ptrtoint ptr addrspace(5) %{{.*}} to i64 |
| 120 |
//AMDGCN: ptrtoint ptr %{{.*}} to i64 |
| 121 |
ptrdiff_t test_sub_mix(private char* x, generic char *y) { |
| 122 |
return x - y; |
| 123 |
} |
| 124 |
|