Debian Codegraph @

llvm/test/CodeGen/SPIRV/pointers/store-struct.ll

raw
1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}
3
4 ; CHECK-DAG: %[[#uint:]] = OpTypeInt 32 0
5 ; CHECK-DAG: %[[#float:]] = OpTypeFloat 32
6 ; CHECK-DAG: %[[#float_fp:]] = OpTypePointer Function %[[#float]]
7 ; CHECK-DAG: %[[#float_pp:]] = OpTypePointer Private %[[#float]]
8 ; CHECK-DAG: %[[#uint_fp:]] = OpTypePointer Function %[[#uint]]
9 ; CHECK-DAG: %[[#uint_0:]] = OpConstant %[[#uint]] 0
10 ; CHECK-DAG: %[[#uint_4:]] = OpConstant %[[#uint]] 4
11 ; CHECK-DAG: %[[#float_0:]] = OpConstant %[[#float]] 0
12 ; CHECK-DAG: %[[#sf:]] = OpTypeStruct %[[#float]]
13 ; CHECK-DAG: %[[#su:]] = OpTypeStruct %[[#uint]]
14 ; CHECK-DAG: %[[#ssu:]] = OpTypeStruct %[[#su]]
15 ; CHECK-DAG: %[[#sfuf:]] = OpTypeStruct %[[#float]] %[[#uint]] %[[#float]]
16 ; CHECK-DAG: %[[#uint4:]] = OpTypeVector %[[#uint]] 4
17 ; CHECK-DAG: %[[#sv:]] = OpTypeStruct %[[#uint4]]
18 ; CHECK-DAG: %[[#ssv:]] = OpTypeStruct %[[#sv]]
19 ; CHECK-DAG: %[[#assv:]] = OpTypeArray %[[#ssv]] %[[#uint_4]]
20 ; CHECK-DAG: %[[#sassv:]] = OpTypeStruct %[[#assv]]
21 ; CHECK-DAG: %[[#ssassv:]] = OpTypeStruct %[[#sassv]]
22 ; CHECK-DAG: %[[#sf_fp:]] = OpTypePointer Function %[[#sf]]
23 ; CHECK-DAG: %[[#su_fp:]] = OpTypePointer Function %[[#su]]
24 ; CHECK-DAG: %[[#ssu_fp:]] = OpTypePointer Function %[[#ssu]]
25 ; CHECK-DAG: %[[#ssv_fp:]] = OpTypePointer Function %[[#ssv]]
26 ; CHECK-DAG: %[[#ssassv_fp:]] = OpTypePointer Function %[[#ssassv]]
27 ; CHECK-DAG: %[[#sfuf_fp:]] = OpTypePointer Function %[[#sfuf]]
28 ; CHECK-DAG: %[[#sfuf_pp:]] = OpTypePointer Private %[[#sfuf]]
29
30 %struct.SF = type { float }
31 %struct.SU = type { i32 }
32 %struct.SFUF = type { float, i32, float }
33 %struct.SSU = type { %struct.SU }
34 %struct.SV = type { <4 x i32> }
35 %struct.SSV = type { %struct.SV }
36 %struct.SASSV = type { [4 x %struct.SSV] }
37 %struct.SSASSV = type { %struct.SASSV }
38
39 @gsfuf = external addrspace(10) global %struct.SFUF
40 ; CHECK-DAG: %[[#gsfuf:]] = OpVariable %[[#sfuf_pp]] Private
41
42 define internal spir_func void @foo() {
43 %1 = alloca %struct.SF, align 4
44 ; CHECK: %[[#var:]] = OpVariable %[[#sf_fp]] Function
45
46 store float 0.0, ptr %1, align 4
47 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#float_fp]] %[[#var]] %[[#uint_0]]
48 ; CHECK: OpStore %[[#tmp]] %[[#float_0]] Aligned 4
49
50 ret void
51 }
52
53 define internal spir_func void @bar() {
54 %1 = alloca %struct.SU, align 4
55 ; CHECK: %[[#var:]] = OpVariable %[[#su_fp]] Function
56
57 store i32 0, ptr %1, align 4
58 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#uint_fp]] %[[#var]] %[[#uint_0]]
59 ; CHECK: OpStore %[[#tmp]] %[[#uint_0]] Aligned 4
60
61 ret void
62 }
63
64 define internal spir_func void @baz() {
65 %1 = alloca %struct.SFUF, align 4
66 ; CHECK: %[[#var:]] = OpVariable %[[#sfuf_fp]] Function
67
68 store float 0.0, ptr %1, align 4
69 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#float_fp]] %[[#var]] %[[#uint_0]]
70 ; CHECK: OpStore %[[#tmp]] %[[#float_0]] Aligned 4
71
72 ret void
73 }
74
75 define internal spir_func void @biz() {
76 store float 0.0, ptr addrspace(10) @gsfuf, align 4
77 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#float_pp]] %[[#gsfuf]] %[[#uint_0]]
78 ; CHECK: OpStore %[[#tmp]] %[[#float_0]] Aligned 4
79
80 ret void
81 }
82
83 define internal spir_func void @nested_store() {
84 %1 = alloca %struct.SSU, align 4
85 ; CHECK: %[[#var:]] = OpVariable %[[#ssu_fp]] Function
86
87 store i32 0, ptr %1, align 4
88 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#uint_fp]] %[[#var]] %[[#uint_0]] %[[#uint_0]]
89 ; CHECK: OpStore %[[#tmp]] %[[#uint_0]] Aligned 4
90
91 ret void
92 }
93
94 define internal spir_func void @nested_store_vector() {
95 %1 = alloca %struct.SSV, align 4
96 ; CHECK: %[[#var:]] = OpVariable %[[#ssv_fp]] Function
97
98 store i32 0, ptr %1, align 4
99 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#uint_fp]] %[[#var]] %[[#uint_0]] %[[#uint_0]] %[[#uint_0]]
100 ; CHECK: OpStore %[[#tmp]] %[[#uint_0]] Aligned 4
101
102 ret void
103 }
104
105 define internal spir_func void @nested_array_vector() {
106 %1 = alloca %struct.SSASSV, align 4
107 ; CHECK: %[[#var:]] = OpVariable %[[#ssassv_fp]] Function
108
109 store i32 0, ptr %1, align 4
110 ; CHECK: %[[#tmp:]] = OpInBoundsAccessChain %[[#uint_fp]] %[[#var]] %[[#uint_0]] %[[#uint_0]] %[[#uint_0]] %[[#uint_0]] %[[#uint_0]] %[[#uint_0]]
111 ; CHECK: OpStore %[[#tmp]] %[[#uint_0]] Aligned 4
112
113 ret void
114 }