reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir-unknown-unknown -o - | FileCheck --check-prefix=SZ32 %s
// 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
// 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
// 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

//SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x)
//SZ32: ptrtoint i8* %{{.*}} to i32
//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_private(i8* %x)
//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
//AMDGCN: define{{.*}} i64 @test_ptrtoint_private(i8 addrspace(5)* %x)
//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
size_t test_ptrtoint_private(private char* x) {
  return (size_t)x;
}

//SZ32: define{{.*}} i32 @test_ptrtoint_global(i8 addrspace(1)* %x)
//SZ32: ptrtoint i8 addrspace(1)* %{{.*}} to i32
//SZ64: define{{.*}} i64 @test_ptrtoint_global(i8 addrspace(1)* %x)
//SZ64: ptrtoint i8 addrspace(1)* %{{.*}} to i64
intptr_t test_ptrtoint_global(global char* x) {
  return (intptr_t)x;
}

//SZ32: define{{.*}} i32 @test_ptrtoint_constant(i8 addrspace(2)* %x)
//SZ32: ptrtoint i8 addrspace(2)* %{{.*}} to i32
//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(2)* %x)
//SZ64ONLY: ptrtoint i8 addrspace(2)* %{{.*}} to i64
//AMDGCN: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(4)* %x)
//AMDGCN: ptrtoint i8 addrspace(4)* %{{.*}} to i64
uintptr_t test_ptrtoint_constant(constant char* x) {
  return (uintptr_t)x;
}

//SZ32: define{{.*}} i32 @test_ptrtoint_local(i8 addrspace(3)* %x)
//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
//SZ64: define{{.*}} i64 @test_ptrtoint_local(i8 addrspace(3)* %x)
//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
size_t test_ptrtoint_local(local char* x) {
  return (size_t)x;
}

//SZ32: define{{.*}} i32 @test_ptrtoint_generic(i8 addrspace(4)* %x)
//SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
//SZ64ONLY: define{{.*}} i64 @test_ptrtoint_generic(i8 addrspace(4)* %x)
//SZ64ONLY: ptrtoint i8 addrspace(4)* %{{.*}} to i64
//AMDGCN: define{{.*}} i64 @test_ptrtoint_generic(i8* %x)
//AMDGCN: ptrtoint i8* %{{.*}} to i64
size_t test_ptrtoint_generic(generic char* x) {
  return (size_t)x;
}

//SZ32: define{{.*}} i8* @test_inttoptr_private(i32 %x)
//SZ32: inttoptr i32 %{{.*}} to i8*
//SZ64ONLY: define{{.*}} i8* @test_inttoptr_private(i64 %x)
//SZ64ONLY: inttoptr i64 %{{.*}} to i8*
//AMDGCN: define{{.*}} i8 addrspace(5)* @test_inttoptr_private(i64 %x)
//AMDGCN: trunc i64 %{{.*}} to i32
//AMDGCN: inttoptr i32 %{{.*}} to i8 addrspace(5)*
private char* test_inttoptr_private(size_t x) {
  return (private char*)x;
}

//SZ32: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i32 %x)
//SZ32: inttoptr i32 %{{.*}} to i8 addrspace(1)*
//SZ64: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i64 %x)
//SZ64: inttoptr i64 %{{.*}} to i8 addrspace(1)*
global char* test_inttoptr_global(size_t x) {
  return (global char*)x;
}

//SZ32: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i32 %y)
//SZ32: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
//SZ64: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i64 %y)
//AMDGCN: trunc i64 %{{.*}} to i32
//AMDGCN: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
//SZ64ONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i64
local char* test_add_local(local char* x, ptrdiff_t y) {
  return x + y;
}

//SZ32: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i32 %y)
//SZ32: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i32
//SZ64: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i64 %y)
//SZ64: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i64
global char* test_add_global(global char* x, ptrdiff_t y) {
  return x + y;
}

//SZ32: define{{.*}} i32 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
//SZ64: define{{.*}} i64 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
ptrdiff_t test_sub_local(local char* x, local char *y) {
  return x - y;
}

//SZ32: define{{.*}} i32 @test_sub_private(i8* %x, i8* %y)
//SZ32: ptrtoint i8* %{{.*}} to i32
//SZ32: ptrtoint i8* %{{.*}} to i32
//SZ64ONLY: define{{.*}} i64 @test_sub_private(i8* %x, i8* %y)
//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
//AMDGCN: define{{.*}} i64 @test_sub_private(i8 addrspace(5)* %x, i8 addrspace(5)* %y)
//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
ptrdiff_t test_sub_private(private char* x, private char *y) {
  return x - y;
}

//SZ32: define{{.*}} i32 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
//SZ32: ptrtoint i8* %{{.*}} to i32
//SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
//SZ64ONLY: define{{.*}} i64 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
//SZ64ONLY: ptrtoint i8* %{{.*}} to i64
//SZ64ONLY: ptrtoint i8 addrspace(4)* %{{.*}} to i64
//AMDGCN: define{{.*}} i64 @test_sub_mix(i8 addrspace(5)* %x, i8* %y)
//AMDGCN: ptrtoint i8 addrspace(5)* %{{.*}} to i64
//AMDGCN: ptrtoint i8* %{{.*}} to i64
ptrdiff_t test_sub_mix(private char* x, generic char *y) {
  return x - y;
}