| 1 |
// RUN: %clang_cc1 %s -triple spir -O0 -emit-llvm-bc -o %t.bc -no-opaque-pointers |
| 2 |
// RUN: llvm-spirv %t.bc -opaque-pointers=0 -o %t.spv |
| 3 |
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s |
| 4 |
// RUN: spirv-val %t.spv |
| 5 |
|
| 6 |
// CHECK: TypeImage [[TypeImage:[0-9]+]] |
| 7 |
// CHECK: TypeSampler [[TypeSampler:[0-9]+]] |
| 8 |
// CHECK: TypePointer [[TypeImagePtr:[0-9]+]] {{[0-9]+}} [[TypeImage]] |
| 9 |
// CHECK: TypePointer [[TypeSamplerPtr:[0-9]+]] {{[0-9]+}} [[TypeSampler]] |
| 10 |
|
| 11 |
// CHECK: FunctionParameter [[TypeImage]] [[srcimg:[0-9]+]] |
| 12 |
// CHECK: FunctionParameter [[TypeSampler]] [[sampler:[0-9]+]] |
| 13 |
|
| 14 |
// CHECK: Variable [[TypeImagePtr]] [[srcimg_addr:[0-9]+]] |
| 15 |
// CHECK: Variable [[TypeSamplerPtr]] [[sampler_addr:[0-9]+]] |
| 16 |
|
| 17 |
// CHECK: Store [[srcimg_addr]] [[srcimg]] |
| 18 |
// CHECK: Store [[sampler_addr]] [[sampler]] |
| 19 |
|
| 20 |
// CHECK: Load {{[0-9]+}} [[srcimg_val:[0-9]+]] [[srcimg_addr]] |
| 21 |
// CHECK: Load {{[0-9]+}} [[sampler_val:[0-9]+]] [[sampler_addr]] |
| 22 |
|
| 23 |
// CHECK: SampledImage {{[0-9]+}} {{[0-9]+}} [[srcimg_val]] [[sampler_val]] |
| 24 |
// CHECK-NEXT: ImageSampleExplicitLod |
| 25 |
|
| 26 |
// CHECK: Load {{[0-9]+}} [[srcimg_val:[0-9]+]] [[srcimg_addr]] |
| 27 |
// CHECK: ImageQuerySizeLod {{[0-9]+}} {{[0-9]+}} [[srcimg_val]] |
| 28 |
|
| 29 |
// Excerpt from opencl-c-base.h |
| 30 |
typedef float float4 __attribute__((ext_vector_type(4))); |
| 31 |
typedef int int2 __attribute__((ext_vector_type(2))); |
| 32 |
typedef __SIZE_TYPE__ size_t; |
| 33 |
|
| 34 |
// Excerpt from opencl-c.h to speed up compilation. |
| 35 |
#define __ovld __attribute__((overloadable)) |
| 36 |
#define __purefn __attribute__((pure)) |
| 37 |
#define __cnfn __attribute__((const)) |
| 38 |
size_t __ovld __cnfn get_global_id(unsigned int dimindx); |
| 39 |
int __ovld __cnfn get_image_width(read_only image2d_t image); |
| 40 |
float4 __purefn __ovld read_imagef(read_only image2d_t image, sampler_t sampler, int2 coord); |
| 41 |
|
| 42 |
|
| 43 |
__kernel void test_fn(image2d_t srcimg, sampler_t sampler, global float4 *results) { |
| 44 |
int tid_x = get_global_id(0); |
| 45 |
int tid_y = get_global_id(1); |
| 46 |
results[tid_x + tid_y * get_image_width(srcimg)] = read_imagef(srcimg, sampler, (int2){tid_x, tid_y}); |
| 47 |
} |