| 1 |
// RUN: %clang_cc1 -triple spir -cl-std=CL2.0 %s -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc -o %t.bc -no-opaque-pointers |
| 2 |
// RUN: llvm-spirv %t.bc -opaque-pointers=0 -spirv-text -o %t.txt |
| 3 |
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV |
| 4 |
// RUN: llvm-spirv --spirv-max-version=1.3 %t.bc -opaque-pointers=0 -o %t.spv |
| 5 |
// RUN: spirv-val %t.spv |
| 6 |
// RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 7 |
// RUN: llvm-dis -opaque-pointers=0 < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 8 |
// RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc |
| 9 |
// RUN: llvm-dis -opaque-pointers=0 < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR |
| 10 |
// RUN: llvm-spirv %t.rev.bc -opaque-pointers=0 -spirv-text -o %t.rev.spt |
| 11 |
// RUN: FileCheck < %t.rev.spt %s --check-prefix=CHECK-SPIRV |
| 12 |
|
| 13 |
constant sampler_t constSampl = CLK_FILTER_LINEAR; |
| 14 |
|
| 15 |
__kernel |
| 16 |
void sample_kernel_float(image2d_t input, float2 coords, global float4 *results, sampler_t argSampl) { |
| 17 |
*results = read_imagef(input, constSampl, coords); |
| 18 |
*results = read_imagef(input, argSampl, coords); |
| 19 |
*results = read_imagef(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords); |
| 20 |
} |
| 21 |
|
| 22 |
__kernel |
| 23 |
void sample_kernel_int(image2d_t input, float2 coords, global int4 *results, sampler_t argSampl) { |
| 24 |
*results = read_imagei(input, constSampl, coords); |
| 25 |
*results = read_imagei(input, argSampl, coords); |
| 26 |
*results = read_imagei(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords); |
| 27 |
} |
| 28 |
|
| 29 |
// CHECK-SPIRV: Capability LiteralSampler |
| 30 |
// CHECK-SPIRV: Name [[sample_kernel_float:[0-9]+]] "sample_kernel_float" |
| 31 |
// CHECK-SPIRV: Name [[sample_kernel_int:[0-9]+]] "sample_kernel_int" |
| 32 |
|
| 33 |
// CHECK-SPIRV: TypeSampler [[TypeSampler:[0-9]+]] |
| 34 |
// CHECK-SPIRV: TypeSampledImage [[SampledImageTy:[0-9]+]] |
| 35 |
// CHECK-SPIRV: ConstantSampler [[TypeSampler]] [[ConstSampler1:[0-9]+]] 0 0 1 |
| 36 |
// CHECK-SPIRV: ConstantSampler [[TypeSampler]] [[ConstSampler2:[0-9]+]] 3 0 0 |
| 37 |
// CHECK-SPIRV: ConstantSampler [[TypeSampler]] [[ConstSampler3:[0-9]+]] 0 0 1 |
| 38 |
// CHECK-SPIRV: ConstantSampler [[TypeSampler]] [[ConstSampler4:[0-9]+]] 3 0 0 |
| 39 |
|
| 40 |
// CHECK-SPIRV: Function {{.*}} [[sample_kernel_float]] |
| 41 |
// CHECK-SPIRV: FunctionParameter {{.*}} [[InputImage:[0-9]+]] |
| 42 |
// CHECK-SPIRV: FunctionParameter [[TypeSampler]] [[argSampl:[0-9]+]] |
| 43 |
// CHECK-LLVM: define spir_kernel void @sample_kernel_float(%opencl.image2d_ro_t addrspace(1)* %input, <2 x float> %coords, <4 x float> addrspace(1)* nocapture align 16 %results, %opencl.sampler_t addrspace(2)* %argSampl) |
| 44 |
|
| 45 |
// CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage1:[0-9]+]] [[InputImage]] [[ConstSampler1]] |
| 46 |
// CHECK-SPIRV: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[SampledImage1]] |
| 47 |
// CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %0, <2 x float> %coords) |
| 48 |
// CHECK-SPV-IR: call spir_func %spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* @_Z20__spirv_SampledImagePU3AS133__spirv_Image__void_1_0_0_0_0_0_0PU3AS215__spirv_Sampler(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %input, %spirv.Sampler addrspace(2)* %0) |
| 49 |
// CHECK-SPV-IR: call spir_func <4 x float> @_Z38__spirv_ImageSampleExplicitLod_Rfloat4PU3AS140__spirv_SampledImage__void_1_0_0_0_0_0_0Dv2_fif(%spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* %TempSampledImage, <2 x float> %coords, i32 2, float 0.000000e+00) |
| 50 |
|
| 51 |
// CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage2:[0-9]+]] [[InputImage]] [[argSampl]] |
| 52 |
// CHECK-SPIRV: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[SampledImage2]] |
| 53 |
// CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %argSampl, <2 x float> %coords) |
| 54 |
// CHECK-SPV-IR: call spir_func %spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* @_Z20__spirv_SampledImagePU3AS133__spirv_Image__void_1_0_0_0_0_0_0PU3AS215__spirv_Sampler(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %input, %spirv.Sampler addrspace(2)* %argSampl) |
| 55 |
// CHECK-SPV-IR: call spir_func <4 x float> @_Z38__spirv_ImageSampleExplicitLod_Rfloat4PU3AS140__spirv_SampledImage__void_1_0_0_0_0_0_0Dv2_fif(%spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* %TempSampledImage4, <2 x float> %coords, i32 2, float 0.000000e+00) |
| 56 |
|
| 57 |
// CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage3:[0-9]+]] [[InputImage]] [[ConstSampler2]] |
| 58 |
// CHECK-SPIRV: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[SampledImage3]] |
| 59 |
// CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %{{[0-9]+}}, <2 x float> %coords) |
| 60 |
// CHECK-SPV-IR: call spir_func %spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* @_Z20__spirv_SampledImagePU3AS133__spirv_Image__void_1_0_0_0_0_0_0PU3AS215__spirv_Sampler(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %input, %spirv.Sampler addrspace(2)* %1) |
| 61 |
// CHECK-SPV-IR: call spir_func <4 x float> @_Z38__spirv_ImageSampleExplicitLod_Rfloat4PU3AS140__spirv_SampledImage__void_1_0_0_0_0_0_0Dv2_fif(%spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* %TempSampledImage6, <2 x float> %coords, i32 2, float 0.000000e+00) |
| 62 |
|
| 63 |
// CHECK-SPIRV: Function {{.*}} [[sample_kernel_int]] |
| 64 |
// CHECK-SPIRV: FunctionParameter {{.*}} [[InputImage:[0-9]+]] |
| 65 |
// CHECK-SPIRV: FunctionParameter [[TypeSampler]] [[argSampl:[0-9]+]] |
| 66 |
// CHECK-LLVM: define spir_kernel void @sample_kernel_int(%opencl.image2d_ro_t addrspace(1)* %input, <2 x float> %coords, <4 x i32> addrspace(1)* nocapture align 16 %results, %opencl.sampler_t addrspace(2)* %argSampl) |
| 67 |
|
| 68 |
// CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage4:[0-9]+]] [[InputImage]] [[ConstSampler3]] |
| 69 |
// CHECK-SPIRV: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[SampledImage4]] |
| 70 |
// CHECK-LLVM: call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %0, <2 x float> %coords) |
| 71 |
// CHECK-SPV-IR: call spir_func %spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* @_Z20__spirv_SampledImagePU3AS133__spirv_Image__void_1_0_0_0_0_0_0PU3AS215__spirv_Sampler(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %input, %spirv.Sampler addrspace(2)* %0) |
| 72 |
// CHECK-SPV-IR: call spir_func <4 x i32> @_Z36__spirv_ImageSampleExplicitLod_Rint4PU3AS140__spirv_SampledImage__void_1_0_0_0_0_0_0Dv2_fif(%spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* %TempSampledImage, <2 x float> %coords, i32 2, float 0.000000e+00) |
| 73 |
|
| 74 |
// CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage5:[0-9]+]] [[InputImage]] [[argSampl]] |
| 75 |
// CHECK-SPIRV: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[SampledImage5]] |
| 76 |
// CHECK-LLVM: call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %argSampl, <2 x float> %coords) |
| 77 |
// CHECK-SPV-IR: call spir_func %spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* @_Z20__spirv_SampledImagePU3AS133__spirv_Image__void_1_0_0_0_0_0_0PU3AS215__spirv_Sampler(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %input, %spirv.Sampler addrspace(2)* %argSampl) |
| 78 |
// CHECK-SPV-IR: call spir_func <4 x i32> @_Z36__spirv_ImageSampleExplicitLod_Rint4PU3AS140__spirv_SampledImage__void_1_0_0_0_0_0_0Dv2_fif(%spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* %TempSampledImage4, <2 x float> %coords, i32 2, float 0.000000e+00) |
| 79 |
|
| 80 |
// CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage6:[0-9]+]] [[InputImage]] [[ConstSampler4]] |
| 81 |
// CHECK-SPIRV: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[SampledImage6]] |
| 82 |
// CHECK-LLVM: call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(%opencl.image2d_ro_t addrspace(1)* %input, %opencl.sampler_t addrspace(2)* %1, <2 x float> %coords) |
| 83 |
// CHECK-SPV-IR: call spir_func %spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* @_Z20__spirv_SampledImagePU3AS133__spirv_Image__void_1_0_0_0_0_0_0PU3AS215__spirv_Sampler(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %input, %spirv.Sampler addrspace(2)* %1) |
| 84 |
// CHECK-SPV-IR: call spir_func <4 x i32> @_Z36__spirv_ImageSampleExplicitLod_Rint4PU3AS140__spirv_SampledImage__void_1_0_0_0_0_0_0Dv2_fif(%spirv.SampledImage._void_1_0_0_0_0_0_0 addrspace(1)* %TempSampledImage6, <2 x float> %coords, i32 2, float 0.000000e+00) |