2017-04-12 01:24:23 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
|
2021-07-13 17:45:38 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -cl-std=CL3.0 -cl-ext=-__opencl_c_generic_address_space -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,SPIR
|
2017-04-12 01:24:23 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -DCL20 -cl-std=CL2.0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20SPIR
|
2018-02-16 03:12:41 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
|
2021-07-13 17:45:38 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
|
2018-02-16 03:12:41 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -triple amdgcn-amd-amdhsa -DCL20 -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s --check-prefixes=CL20,CL20AMDGCN
|
|
|
|
// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
|
2021-07-13 17:45:38 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -triple amdgcn-mesa-mesa3d -cl-std=CL3.0 -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
|
2018-02-16 03:12:41 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
|
2021-07-13 17:45:38 +08:00
|
|
|
// RUN: %clang_cc1 %s -O0 -triple r600-- -emit-llvm -cl-std=CL3.0 -o - | FileCheck --check-prefixes=CHECK,AMDGCN %s
|
2017-04-12 01:24:23 +08:00
|
|
|
|
2017-10-13 11:37:48 +08:00
|
|
|
// SPIR: %struct.S = type { i32, i32, i32* }
|
|
|
|
// CL20SPIR: %struct.S = type { i32, i32, i32 addrspace(4)* }
|
|
|
|
struct S {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int *z;
|
|
|
|
};
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// CL20-DAG: @g_extern_var = external {{(dso_local )?}}addrspace(1) global float
|
|
|
|
// CL20-DAG: @l_extern_var = external {{(dso_local )?}}addrspace(1) global float
|
2017-10-13 11:37:48 +08:00
|
|
|
// CL20-DAG: @test_static.l_static_var = internal addrspace(1) global float 0.000000e+00
|
|
|
|
// CL20-DAG: @g_static_var = internal addrspace(1) global float 0.000000e+00
|
|
|
|
|
|
|
|
#ifdef CL20
|
2019-01-09 03:10:43 +08:00
|
|
|
// CL20-DAG: @g_s = {{(common )?}}{{(dso_local )?}}addrspace(1) global %struct.S zeroinitializer
|
2017-10-13 11:37:48 +08:00
|
|
|
struct S g_s;
|
|
|
|
#endif
|
|
|
|
|
2017-04-12 01:24:23 +08:00
|
|
|
// SPIR: i32* %arg
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: i32 addrspace(5)* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void f__p(__private int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2015-11-23 19:14:44 +08:00
|
|
|
// CHECK: i32 addrspace(1)* %arg
|
|
|
|
void f__g(__global int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2016-12-24 00:11:25 +08:00
|
|
|
// CHECK: i32 addrspace(3)* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void f__l(__local int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2018-02-14 02:01:21 +08:00
|
|
|
// SPIR: i32 addrspace(2)* %arg
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: i32 addrspace(4)* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void f__c(__constant int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2017-04-12 01:24:23 +08:00
|
|
|
// SPIR: i32* %arg
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: i32 addrspace(5)* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void fp(private int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2015-11-23 19:14:44 +08:00
|
|
|
// CHECK: i32 addrspace(1)* %arg
|
|
|
|
void fg(global int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2016-12-24 00:11:25 +08:00
|
|
|
// CHECK: i32 addrspace(3)* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void fl(local int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2018-02-14 02:01:21 +08:00
|
|
|
// SPIR: i32 addrspace(2)* %arg
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: i32 addrspace(4)* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void fc(constant int *arg) {}
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2020-07-29 20:07:06 +08:00
|
|
|
// SPIR: i32 addrspace(5)* %arg
|
|
|
|
// AMDGCN: i32 addrspace(1)* %arg
|
|
|
|
void fd(__attribute__((opencl_global_device)) int *arg) {}
|
|
|
|
|
|
|
|
// SPIR: i32 addrspace(6)* %arg
|
|
|
|
// AMDGCN: i32 addrspace(1)* %arg
|
|
|
|
void fh(__attribute__((opencl_global_host)) int *arg) {}
|
|
|
|
|
2015-11-23 19:14:44 +08:00
|
|
|
#ifdef CL20
|
|
|
|
int i;
|
2020-03-10 03:25:24 +08:00
|
|
|
// CL20-DAG: @i = {{(dso_local )?}}addrspace(1) global i32 0
|
2015-11-23 19:14:44 +08:00
|
|
|
int *ptr;
|
2019-01-09 03:10:43 +08:00
|
|
|
// CL20SPIR-DAG: @ptr = {{(common )?}}{{(dso_local )?}}addrspace(1) global i32 addrspace(4)* null
|
2020-03-10 03:25:24 +08:00
|
|
|
// CL20AMDGCN-DAG: @ptr = {{(dso_local )?}}addrspace(1) global i32* null
|
2015-11-23 19:14:44 +08:00
|
|
|
#endif
|
2011-03-19 06:38:29 +08:00
|
|
|
|
2017-04-12 01:24:23 +08:00
|
|
|
// SPIR: i32* %arg
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: i32 addrspace(5)* %arg
|
2017-04-12 01:24:23 +08:00
|
|
|
// CL20SPIR-DAG: i32 addrspace(4)* %arg
|
2018-02-16 03:12:41 +08:00
|
|
|
// CL20AMDGCN-DAG: i32* %arg
|
2015-11-23 19:14:44 +08:00
|
|
|
void f(int *arg) {
|
|
|
|
|
|
|
|
int i;
|
2017-04-12 01:24:23 +08:00
|
|
|
// SPIR: %i = alloca i32,
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: %i = alloca i32{{.*}}addrspace(5)
|
2017-04-12 01:24:23 +08:00
|
|
|
// CL20SPIR-DAG: %i = alloca i32,
|
2018-02-16 03:12:41 +08:00
|
|
|
// CL20AMDGCN-DAG: %i = alloca i32{{.*}}addrspace(5)
|
2015-11-23 19:14:44 +08:00
|
|
|
|
|
|
|
#ifdef CL20
|
|
|
|
static int ii;
|
|
|
|
// CL20-DAG: @f.ii = internal addrspace(1) global i32 0
|
|
|
|
#endif
|
|
|
|
}
|
2017-10-13 11:37:48 +08:00
|
|
|
|
|
|
|
typedef int int_td;
|
|
|
|
typedef int *intp_td;
|
2018-02-24 03:30:48 +08:00
|
|
|
// SPIR: define {{(dso_local )?}}void @test_typedef(i32 addrspace(1)* %x, i32 addrspace(2)* %y, i32* %z)
|
2017-10-13 11:37:48 +08:00
|
|
|
void test_typedef(global int_td *x, constant int_td *y, intp_td z) {
|
|
|
|
*x = *y;
|
|
|
|
*z = 0;
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// SPIR: define {{(dso_local )?}}void @test_struct()
|
2017-10-13 11:37:48 +08:00
|
|
|
void test_struct() {
|
|
|
|
// SPIR: %ps = alloca %struct.S*
|
|
|
|
// CL20SPIR: %ps = alloca %struct.S addrspace(4)*
|
|
|
|
struct S *ps;
|
|
|
|
// SPIR: store i32 0, i32* %x
|
|
|
|
// CL20SPIR: store i32 0, i32 addrspace(4)* %x
|
|
|
|
ps->x = 0;
|
|
|
|
#ifdef CL20
|
|
|
|
// CL20SPIR: store i32 0, i32 addrspace(1)* getelementptr inbounds (%struct.S, %struct.S addrspace(1)* @g_s, i32 0, i32 0)
|
|
|
|
g_s.x = 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:30:48 +08:00
|
|
|
// SPIR-LABEL: define {{(dso_local )?}}void @test_void_par()
|
2017-10-13 11:37:48 +08:00
|
|
|
void test_void_par(void) {}
|
|
|
|
|
2017-10-13 21:53:06 +08:00
|
|
|
// On ppc64 returns signext i32.
|
|
|
|
// SPIR-LABEL: define{{.*}} i32 @test_func_return_type()
|
2017-10-13 11:37:48 +08:00
|
|
|
int test_func_return_type(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CL20
|
|
|
|
extern float g_extern_var;
|
|
|
|
|
|
|
|
// CL20-LABEL: define {{.*}}void @test_extern(
|
|
|
|
kernel void test_extern(global float *buf) {
|
|
|
|
extern float l_extern_var;
|
|
|
|
buf[0] += g_extern_var + l_extern_var;
|
|
|
|
}
|
|
|
|
|
|
|
|
static float g_static_var;
|
|
|
|
|
|
|
|
// CL20-LABEL: define {{.*}}void @test_static(
|
|
|
|
kernel void test_static(global float *buf) {
|
|
|
|
static float l_static_var;
|
|
|
|
buf[0] += g_static_var + l_static_var;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|