| 1 |
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-vulkan-library %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-library %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
@.str.int_buf = private unnamed_addr constant [7 x i8] c"IntBuf\00", align 1 |
| 5 |
@.str.float_buf = private unnamed_addr constant [9 x i8] c"FloatBuf\00", align 1 |
| 6 |
|
| 7 |
; CHECK-DAG: OpDecorate [[IntBufferVar:%[0-9]+]] DescriptorSet 16 |
| 8 |
; CHECK-DAG: OpDecorate [[IntBufferVar]] Binding 7 |
| 9 |
; CHECK-DAG: OpDecorate [[FloatBufferVar:%[0-9]+]] DescriptorSet 16 |
| 10 |
; CHECK-DAG: OpDecorate [[FloatBufferVar]] Binding 7 |
| 11 |
|
| 12 |
; CHECK-DAG: [[float:%[0-9]+]] = OpTypeFloat 32 |
| 13 |
; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0 |
| 14 |
; CHECK-DAG: [[RWBufferTypeInt:%[0-9]+]] = OpTypeImage [[int]] Buffer 2 0 0 2 R32i {{$}} |
| 15 |
; CHECK-DAG: [[RWBufferTypeFloat:%[0-9]+]] = OpTypeImage [[float]] Buffer 2 0 0 2 R32f {{$}} |
| 16 |
; CHECK-DAG: [[IntBufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[RWBufferTypeInt]] |
| 17 |
; CHECK-DAG: [[FloatBufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[RWBufferTypeFloat]] |
| 18 |
; CHECK-DAG: [[IntBufferVar]] = OpVariable [[IntBufferPtrType]] UniformConstant |
| 19 |
; CHECK-DAG: [[FloatBufferVar]] = OpVariable [[FloatBufferPtrType]] UniformConstant |
| 20 |
|
| 21 |
; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} |
| 22 |
; CHECK-NEXT: OpLabel |
| 23 |
define void @RWBufferLoad() #0 { |
| 24 |
; CHECK: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeInt]] [[IntBufferVar]] |
| 25 |
%buffer0 = call target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) |
| 26 |
@llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_24( |
| 27 |
i32 16, i32 7, i32 1, i32 0, ptr nonnull @.str.int_buf) |
| 28 |
%ptr0 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) %buffer0, i32 0) |
| 29 |
store i32 0, ptr %ptr0, align 4 |
| 30 |
|
| 31 |
; Make sure we use the same variable with multiple loads. |
| 32 |
; CHECK: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeInt]] [[IntBufferVar]] |
| 33 |
%buffer1 = call target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) |
| 34 |
@llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_24( |
| 35 |
i32 16, i32 7, i32 1, i32 0, ptr nonnull @.str.int_buf) |
| 36 |
%ptr1 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) %buffer1, i32 0) |
| 37 |
store i32 0, ptr %ptr1, align 4 |
| 38 |
ret void |
| 39 |
} |
| 40 |
|
| 41 |
; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} |
| 42 |
; CHECK-NEXT: OpLabel |
| 43 |
define void @UseDifferentGlobalVar() #0 { |
| 44 |
; Make sure we use a different variable from the first function. They have |
| 45 |
; different types. |
| 46 |
; CHECK: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeFloat]] [[FloatBufferVar]] |
| 47 |
%buffer0 = call target("spirv.Image", float, 5, 2, 0, 0, 2, 3) |
| 48 |
@llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_3( |
| 49 |
i32 16, i32 7, i32 1, i32 0, ptr nonnull @.str.float_buf ) |
| 50 |
%ptr0 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", float, 5, 2, 0, 0, 2, 3) %buffer0, i32 0) |
| 51 |
store float 0.0, ptr %ptr0, align 4 |
| 52 |
ret void |
| 53 |
} |
| 54 |
|
| 55 |
; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} |
| 56 |
; CHECK-NEXT: OpLabel |
| 57 |
define void @ReuseGlobalVarFromFirstFunction() #0 { |
| 58 |
; Make sure we use the same variable as the first function. They should be the |
| 59 |
; same in case one function calls the other. |
| 60 |
; CHECK: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeInt]] [[IntBufferVar]] |
| 61 |
%buffer1 = call target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) |
| 62 |
@llvm.spv.resource.handlefrombinding.tspirv.Image_f32_5_2_0_0_2_24( |
| 63 |
i32 16, i32 7, i32 1, i32 0, ptr nonnull @.str.int_buf) |
| 64 |
%ptr1 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.spv.resource.getpointer.p0.tspirv.Image_f32_5_2_0_0_2_0t(target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) %buffer1, i32 0) |
| 65 |
store i32 0, ptr %ptr1, align 4 |
| 66 |
ret void |
| 67 |
} |
| 68 |
|
| 69 |
attributes #0 = { convergent noinline norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |