|
| 1 | +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s |
| 2 | +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 | + |
| 4 | +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 5 | +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 6 | + |
| 7 | +;CHECK: OpEntryPoint Kernel %[[#KernelId:]] |
| 8 | +;CHECK: %[[#image2d_t:]] = OpTypeImage |
| 9 | +;CHECK: %[[#sampler_t:]] = OpTypeSampler |
| 10 | +;CHECK: %[[#sampled_image_t:]] = OpTypeSampledImage |
| 11 | + |
| 12 | +define spir_func float @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp) { |
| 13 | +;CHECK-NOT: %[[#KernelId]] = OpFunction %[[#]] |
| 14 | +;CHECK: OpFunction |
| 15 | +;CHECK: %[[#image:]] = OpFunctionParameter %[[#image2d_t]] |
| 16 | +;CHECK: %[[#sampler:]] = OpFunctionParameter %[[#sampler_t]] |
| 17 | +entry: |
| 18 | + %call = call spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp, <2 x i32> zeroinitializer) |
| 19 | +;CHECK: %[[#sampled_image:]] = OpSampledImage %[[#sampled_image_t]] %[[#image]] %[[#sampler]] |
| 20 | +;CHECK: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#sampled_image]] %[[#]] Lod %[[#]] |
| 21 | + |
| 22 | + %0 = extractelement <4 x i32> %call, i32 0 |
| 23 | + %conv = sitofp i32 %0 to float |
| 24 | + ret float %conv |
| 25 | +} |
| 26 | + |
| 27 | +declare spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), i32, <2 x i32>) |
| 28 | + |
| 29 | +define spir_kernel void @test2(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp, ptr addrspace(1) %result) { |
| 30 | +;CHECK: %[[#KernelId]] = OpFunction %[[#]] |
| 31 | +entry: |
| 32 | + %call = call spir_func float @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp) |
| 33 | + %0 = load float, ptr addrspace(1) %result, align 4 |
| 34 | + %add = fadd float %0, %call |
| 35 | + store float %add, ptr addrspace(1) %result, align 4 |
| 36 | + ret void |
| 37 | +} |
0 commit comments