Home | History | Annotate | Download | only in CodeGenOpenCL
      1 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
      2 
      3 // CHECK: %[[A:.*]] = type { float, float, float }
      4 typedef struct {
      5   float x,y,z;
      6 } A;
      7 typedef private A *PA;
      8 typedef global A *GA;
      9 
     10 void test(void) {
     11   global int *glob;
     12   local int *loc;
     13   private int *priv;
     14   generic int *gen;
     15 
     16   //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
     17   //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
     18   //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
     19   glob = to_global(glob);
     20   
     21   //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
     22   //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
     23   //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
     24   glob = to_global(loc);
     25  
     26   //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
     27   //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
     28   //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
     29   glob = to_global(priv);
     30  
     31   //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)*
     32   //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
     33   //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
     34   glob = to_global(gen);
     35   
     36   //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
     37   //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
     38   //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
     39   loc = to_local(glob);
     40 
     41   //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
     42   //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
     43   //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
     44   loc = to_local(loc);
     45 
     46   //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
     47   //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
     48   //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
     49   loc = to_local(priv);
     50 
     51   //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)*
     52   //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
     53   //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
     54   loc = to_local(gen);
     55 
     56   //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
     57   //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]])
     58   //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
     59   priv = to_private(glob);
     60 
     61   //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
     62   //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]])
     63   //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
     64   priv = to_private(loc);
     65 
     66   //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
     67   //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]])
     68   //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
     69   priv = to_private(priv);
     70 
     71   //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)*
     72   //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]])
     73   //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
     74   priv = to_private(gen);
     75 
     76   //CHECK: %[[ARG:.*]] = addrspacecast %[[A]]* %{{.*}} to i8 addrspace(4)*
     77   //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
     78   //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to %[[A]] addrspace(1)*
     79   PA pA;
     80   GA gA = to_global(pA);
     81 
     82   //CHECK-NOT: addrspacecast
     83   //CHECK-NOT: bitcast
     84   //CHECK: call i8 addrspace(1)* @to_global(i8 addrspace(4)* %{{.*}})
     85   //CHECK-NOT: addrspacecast
     86   //CHECK-NOT: bitcast
     87   generic void *gen_v;
     88   global void *glob_v = to_global(gen_v);
     89 }
     90