|
1 | 1 | ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-vulkan-library %s -o - | FileCheck %s |
2 | 2 | ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-vulkan-library %s -o - -filetype=obj | spirv-val %} |
3 | 3 |
|
4 | | -; CHECK-DAG: OpDecorate [[BufferVar:%[0-9]+]] DescriptorSet 16 |
5 | | -; CHECK-DAG: OpDecorate [[BufferVar]] Binding 7 |
| 4 | +; CHECK-DAG: OpDecorate [[IntBufferVar:%[0-9]+]] DescriptorSet 16 |
| 5 | +; CHECK-DAG: OpDecorate [[IntBufferVar]] Binding 7 |
| 6 | +; CHECK-DAG: OpDecorate [[FloatBufferVar:%[0-9]+]] DescriptorSet 16 |
| 7 | +; CHECK-DAG: OpDecorate [[FloatBufferVar]] Binding 7 |
6 | 8 |
|
7 | | -; CHECK: [[float:%[0-9]+]] = OpTypeFloat 32 |
8 | | -; CHECK: [[RWBufferType:%[0-9]+]] = OpTypeImage [[float]] Buffer 2 0 0 2 R32i {{$}} |
9 | | -; CHECK: [[BufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[RWBufferType]] |
10 | | -; CHECK: [[BufferVar]] = OpVariable [[BufferPtrType]] UniformConstant |
| 9 | +; CHECK-DAG: [[float:%[0-9]+]] = OpTypeFloat 32 |
| 10 | +; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0 |
| 11 | +; CHECK-DAG: [[RWBufferTypeInt:%[0-9]+]] = OpTypeImage [[int]] Buffer 2 0 0 2 R32i {{$}} |
| 12 | +; CHECK-DAG: [[RWBufferTypeFloat:%[0-9]+]] = OpTypeImage [[float]] Buffer 2 0 0 2 R32f {{$}} |
| 13 | +; CHECK-DAG: [[IntBufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[RWBufferTypeInt]] |
| 14 | +; CHECK-DAG: [[FloatBufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[RWBufferTypeFloat]] |
| 15 | +; CHECK-DAG: [[IntBufferVar]] = OpVariable [[IntBufferPtrType]] UniformConstant |
| 16 | +; CHECK-DAG: [[FloatBufferVar]] = OpVariable [[FloatBufferPtrType]] UniformConstant |
11 | 17 |
|
12 | 18 | ; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} |
13 | 19 | ; CHECK-NEXT: OpLabel |
14 | 20 | define void @RWBufferLoad() #0 { |
15 | | -; CHECK-NEXT: [[buffer:%[0-9]+]] = OpLoad [[RWBufferType]] [[BufferVar]] |
16 | | - %buffer0 = call target("spirv.Image", float, 5, 2, 0, 0, 2, 24) |
| 21 | +; CHECK-NEXT: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeInt]] [[IntBufferVar]] |
| 22 | + %buffer0 = call target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) |
17 | 23 | @llvm.spv.handle.fromBinding.tspirv.Image_f32_5_2_0_0_2_24( |
18 | 24 | i32 16, i32 7, i32 1, i32 0, i1 false) |
19 | 25 |
|
20 | 26 | ; Make sure we use the same variable with multiple loads. |
21 | | -; CHECK-NEXT: [[buffer:%[0-9]+]] = OpLoad [[RWBufferType]] [[BufferVar]] |
22 | | - %buffer1 = call target("spirv.Image", float, 5, 2, 0, 0, 2, 24) |
| 27 | +; CHECK-NEXT: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeInt]] [[IntBufferVar]] |
| 28 | + %buffer1 = call target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) |
| 29 | + @llvm.spv.handle.fromBinding.tspirv.Image_f32_5_2_0_0_2_24( |
| 30 | + i32 16, i32 7, i32 1, i32 0, i1 false) |
| 31 | + ret void |
| 32 | +} |
| 33 | + |
| 34 | +; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} |
| 35 | +; CHECK-NEXT: OpLabel |
| 36 | +define void @UseDifferentGlobalVar() #0 { |
| 37 | +; Make sure we use a different variable from the first function. They have |
| 38 | +; different types. |
| 39 | +; CHECK-NEXT: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeFloat]] [[FloatBufferVar]] |
| 40 | + %buffer0 = call target("spirv.Image", float, 5, 2, 0, 0, 2, 3) |
| 41 | + @llvm.spv.handle.fromBinding.tspirv.Image_f32_5_2_0_0_2_3( |
| 42 | + i32 16, i32 7, i32 1, i32 0, i1 false) |
| 43 | + ret void |
| 44 | +} |
| 45 | + |
| 46 | +; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}} |
| 47 | +; CHECK-NEXT: OpLabel |
| 48 | +define void @ReuseGlobalVarFromFirstFunction() #0 { |
| 49 | +; Make sure we use the same variable as the first function. They should be the |
| 50 | +; same in case one function calls the other. |
| 51 | +; CHECK-NEXT: [[buffer:%[0-9]+]] = OpLoad [[RWBufferTypeInt]] [[IntBufferVar]] |
| 52 | + %buffer1 = call target("spirv.Image", i32, 5, 2, 0, 0, 2, 24) |
23 | 53 | @llvm.spv.handle.fromBinding.tspirv.Image_f32_5_2_0_0_2_24( |
24 | 54 | i32 16, i32 7, i32 1, i32 0, i1 false) |
25 | 55 | ret void |
|
0 commit comments