1 # RUN: llvm-mc -triple=amdgcn -mcpu=tonga -disassemble -show-encoding < %s | FileCheck %s -check-prefix=VI -check-prefix=GFX80
2 # RUN: llvm-mc -triple=amdgcn -mcpu=gfx810 -disassemble -show-encoding < %s | FileCheck %s -check-prefix=VI -check-prefix=GFX81
4 #===------------------------------------------------------------------------===#
6 #===------------------------------------------------------------------------===#
8 # VI: image_load v[0:3], v4, s[8:15] dmask:0xf unorm ; encoding: [0x00,0x1f,0x00,0xf0,0x04,0x00,0x02,0x00]
9 0x00 0x1f 0x00 0xf0 0x04 0x00 0x02 0x00
11 # VI: image_load v[0:2], v4, s[8:15] dmask:0xe unorm ; encoding: [0x00,0x1e,0x00,0xf0,0x04,0x00,0x02,0x00]
12 0x00 0x1e 0x00 0xf0 0x04 0x00 0x02 0x00
14 # VI: image_load v[0:1], v0, s[0:7] dmask:0x3 unorm ; encoding: [0x00,0x13,0x00,0xf0,0x00,0x00,0x00,0x00]
15 0x00 0x13 0x00 0xf0 0x00 0x00 0x00 0x00
17 # VI: image_load v0, v0, s[0:7] dmask:0x1 unorm ; encoding: [0x00,0x11,0x00,0xf0,0x00,0x00,0x00,0x00]
18 0x00 0x11 0x00 0xf0 0x00 0x00 0x00 0x00
20 # VI: image_store v[0:3], v4, s[0:7] dmask:0xf unorm ; encoding: [0x00,0x1f,0x20,0xf0,0x04,0x00,0x00,0x00]
21 0x00 0x1f 0x20 0xf0 0x04 0x00 0x00 0x00
23 # VI: image_store v[0:2], v4, s[0:7] dmask:0xe unorm ; encoding: [0x00,0x1e,0x20,0xf0,0x04,0x00,0x00,0x00]
24 0x00 0x1e 0x20 0xf0 0x04 0x00 0x00 0x00
26 # VI: image_store v[0:1], v2, s[0:7] dmask:0x3 unorm ; encoding: [0x00,0x13,0x20,0xf0,0x02,0x00,0x00,0x00]
27 0x00 0x13 0x20 0xf0 0x02 0x00 0x00 0x00
29 # VI: image_store v0, v1, s[0:7] dmask:0x1 unorm ; encoding: [0x00,0x11,0x20,0xf0,0x01,0x00,0x00,0x00]
30 0x00 0x11 0x20 0xf0 0x01 0x00 0x00 0x00
33 # FIXME: This test is incorrect because r128 assumes a 128-bit SRSRC.
34 # VI: image_load v[5:6], v1, s[8:15] dmask:0x1 unorm glc slc r128 tfe lwe da d16 ; encoding: [0x00,0xf1,0x03,0xf2,0x01,0x05,0x02,0x80]
35 0x00,0xf1,0x03,0xf2,0x01,0x05,0x02,0x80
38 # VI: image_load v0, v4, s[8:15] unorm ; encoding: [0x00,0x10,0x00,0xf0,0x04,0x00,0x02,0x00]
39 0x00 0x10 0x00 0xf0 0x04 0x00 0x02 0x00
41 # Test out of bounds register width
42 # VI: image_load v254, v0, s[0:7] dmask:0x7 unorm ; encoding: [0x00,0x17,0x00,0xf0,0x00,0xfe,0x00,0x00]
43 0x00 0x17 0x00 0xf0 0x00 0xfe 0x00 0x00
45 # VI: image_load v255, v0, s[0:7] dmask:0x1 unorm ; encoding: [0x00,0x11,0x00,0xf0,0x00,0xff,0x00,0x00]
46 0x00 0x11 0x00 0xf0 0x00 0xff 0x00 0x00
48 # VI: image_load v255, v0, s[0:7] dmask:0x3 unorm ; encoding: [0x00,0x13,0x00,0xf0,0x00,0xff,0x00,0x00]
49 0x00 0x13 0x00 0xf0 0x00 0xff 0x00 0x00
51 #===------------------------------------------------------------------------===#
52 # Image load/store: packed/unpacked d16
53 #===------------------------------------------------------------------------===#
55 # GFX80: image_load v[0:1], v4, s[8:15] dmask:0x3 d16 ; encoding: [0x00,0x03,0x00,0xf0,0x04,0x00,0x02,0x80]
56 # GFX81: image_load v0, v4, s[8:15] dmask:0x3 d16 ; encoding: [0x00,0x03,0x00,0xf0,0x04,0x00,0x02,0x80]
57 0x00,0x03,0x00,0xf0,0x04,0x00,0x02,0x80
59 # GFX80: image_load v[0:2], v4, s[8:15] dmask:0x7 d16 ; encoding: [0x00,0x07,0x00,0xf0,0x04,0x00,0x02,0x80]
60 # GFX81: image_load v[0:1], v4, s[8:15] dmask:0x7 d16 ; encoding: [0x00,0x07,0x00,0xf0,0x04,0x00,0x02,0x80]
61 0x00,0x07,0x00,0xf0,0x04,0x00,0x02,0x80
63 # GFX80: image_load v[0:3], v4, s[8:15] dmask:0xf d16 ; encoding: [0x00,0x0f,0x00,0xf0,0x04,0x00,0x02,0x80]
64 # GFX81: image_load v[0:1], v4, s[8:15] dmask:0xf d16 ; encoding: [0x00,0x0f,0x00,0xf0,0x04,0x00,0x02,0x80]
65 0x00,0x0f,0x00,0xf0,0x04,0x00,0x02,0x80
67 # GFX80: image_store v[0:1], v4, s[8:15] dmask:0x3 d16 ; encoding: [0x00,0x03,0x20,0xf0,0x04,0x00,0x02,0x80]
68 # GFX81: image_store v0, v4, s[8:15] dmask:0x3 d16 ; encoding: [0x00,0x03,0x20,0xf0,0x04,0x00,0x02,0x80]
69 0x00,0x03,0x20,0xf0,0x04,0x00,0x02,0x80
71 # GFX80: image_store v[0:2], v4, s[8:15] dmask:0x7 d16 ; encoding: [0x00,0x07,0x20,0xf0,0x04,0x00,0x02,0x80]
72 # GFX81: image_store v[0:1], v4, s[8:15] dmask:0x7 d16 ; encoding: [0x00,0x07,0x20,0xf0,0x04,0x00,0x02,0x80]
73 0x00,0x07,0x20,0xf0,0x04,0x00,0x02,0x80
75 # GFX80: image_store v[0:3], v4, s[8:15] dmask:0xf d16 ; encoding: [0x00,0x0f,0x20,0xf0,0x04,0x00,0x02,0x80]
76 # GFX81: image_store v[0:1], v4, s[8:15] dmask:0xf d16 ; encoding: [0x00,0x0f,0x20,0xf0,0x04,0x00,0x02,0x80]
77 0x00,0x0f,0x20,0xf0,0x04,0x00,0x02,0x80
79 # GFX80: image_load v[0:2], v4, s[8:15] dmask:0x3 tfe d16 ; encoding: [0x00,0x03,0x01,0xf0,0x04,0x00,0x02,0x80]
80 # GFX81: image_load v[0:1], v4, s[8:15] dmask:0x3 tfe d16 ; encoding: [0x00,0x03,0x01,0xf0,0x04,0x00,0x02,0x80]
81 0x00,0x03,0x01,0xf0,0x04,0x00,0x02,0x80
83 # GFX80: image_load v[0:3], v4, s[8:15] dmask:0x7 tfe d16 ; encoding: [0x00,0x07,0x01,0xf0,0x04,0x00,0x02,0x80]
84 # GFX81: image_load v[0:2], v4, s[8:15] dmask:0x7 tfe d16 ; encoding: [0x00,0x07,0x01,0xf0,0x04,0x00,0x02,0x80]
85 0x00,0x07,0x01,0xf0,0x04,0x00,0x02,0x80
87 # GFX80: image_load v[0:4], v4, s[8:15] dmask:0xf tfe d16 ; encoding: [0x00,0x0f,0x01,0xf0,0x04,0x00,0x02,0x80]
88 # GFX81: image_load v[0:2], v4, s[8:15] dmask:0xf tfe d16 ; encoding: [0x00,0x0f,0x01,0xf0,0x04,0x00,0x02,0x80]
89 0x00,0x0f,0x01,0xf0,0x04,0x00,0x02,0x80
91 # GFX80: image_store v[0:2], v4, s[8:15] dmask:0x3 tfe d16 ; encoding: [0x00,0x03,0x21,0xf0,0x04,0x00,0x02,0x80]
92 # GFX81: image_store v[0:1], v4, s[8:15] dmask:0x3 tfe d16 ; encoding: [0x00,0x03,0x21,0xf0,0x04,0x00,0x02,0x80]
93 0x00,0x03,0x21,0xf0,0x04,0x00,0x02,0x80
95 # GFX80: image_store v[0:3], v4, s[8:15] dmask:0x7 tfe d16 ; encoding: [0x00,0x07,0x21,0xf0,0x04,0x00,0x02,0x80]
96 # GFX81: image_store v[0:2], v4, s[8:15] dmask:0x7 tfe d16 ; encoding: [0x00,0x07,0x21,0xf0,0x04,0x00,0x02,0x80]
97 0x00,0x07,0x21,0xf0,0x04,0x00,0x02,0x80
99 # GFX80: image_store v[0:4], v4, s[8:15] dmask:0xf tfe d16 ; encoding: [0x00,0x0f,0x21,0xf0,0x04,0x00,0x02,0x80]
100 # GFX81: image_store v[0:2], v4, s[8:15] dmask:0xf tfe d16 ; encoding: [0x00,0x0f,0x21,0xf0,0x04,0x00,0x02,0x80]
101 0x00,0x0f,0x21,0xf0,0x04,0x00,0x02,0x80
103 #===------------------------------------------------------------------------===#
104 # Image load/store: PCK variants
105 #===------------------------------------------------------------------------===#
107 # VI: image_load_mip_pck v5, v1, s[8:15] dmask:0x1 ; encoding: [0x00,0x01,0x10,0xf0,0x01,0x05,0x02,0x00]
108 0x00,0x01,0x10,0xf0,0x01,0x05,0x02,0x00
110 # VI: image_load_mip_pck v[5:6], v1, s[8:15] dmask:0x3 ; encoding: [0x00,0x03,0x10,0xf0,0x01,0x05,0x02,0x00]
111 0x00,0x03,0x10,0xf0,0x01,0x05,0x02,0x00
113 # VI: image_load_mip_pck_sgn v[5:6], v1, s[8:15] dmask:0x5 ; encoding: [0x00,0x05,0x14,0xf0,0x01,0x05,0x02,0x00]
114 0x00,0x05,0x14,0xf0,0x01,0x05,0x02,0x00
116 # VI: image_load_pck v5, v1, s[8:15] dmask:0x1 glc ; encoding: [0x00,0x21,0x08,0xf0,0x01,0x05,0x02,0x00]
117 0x00,0x21,0x08,0xf0,0x01,0x05,0x02,0x00
119 # VI: image_load_pck_sgn v5, v1, s[8:15] dmask:0x1 lwe ; encoding: [0x00,0x01,0x0e,0xf0,0x01,0x05,0x02,0x00]
120 0x00,0x01,0x0e,0xf0,0x01,0x05,0x02,0x00
122 # VI: image_store_mip_pck v252, v2, s[12:19] dmask:0x1 unorm ; encoding: [0x00,0x11,0x2c,0xf0,0x02,0xfc,0x03,0x00]
123 0x00,0x11,0x2c,0xf0,0x02,0xfc,0x03,0x00
125 # VI: image_store_mip_pck v1, v2, s[12:19] dmask:0x1 unorm glc slc lwe da ; encoding: [0x00,0x71,0x2e,0xf2,0x02,0x01,0x03,0x00]
126 0x00,0x71,0x2e,0xf2,0x02,0x01,0x03,0x00
128 # VI: image_store_pck v1, v2, s[12:19] dmask:0x1 unorm da ; encoding: [0x00,0x51,0x28,0xf0,0x02,0x01,0x03,0x00]
129 0x00,0x51,0x28,0xf0,0x02,0x01,0x03,0x00
131 #===------------------------------------------------------------------------===#
133 #===------------------------------------------------------------------------===#
135 # VI: image_sample v[193:195], v237, s[28:35], s[4:7] dmask:0x7 unorm ; encoding: [0x00,0x17,0x80,0xf0,0xed,0xc1,0x27,0x00]
136 0x00,0x17,0x80,0xf0,0xed,0xc1,0x27,0x00
138 # GFX80: image_sample v[193:194], v237, s[28:35], s[4:7] dmask:0x3 d16 ; encoding: [0x00,0x03,0x80,0xf0,0xed,0xc1,0x27,0x80]
139 # GFX81: image_sample v193, v237, s[28:35], s[4:7] dmask:0x3 d16 ; encoding: [0x00,0x03,0x80,0xf0,0xed,0xc1,0x27,0x80]
140 0x00,0x03,0x80,0xf0,0xed,0xc1,0x27,0x80
142 # GFX80: image_sample v[193:195], v237, s[28:35], s[4:7] dmask:0x7 d16 ; encoding: [0x00,0x07,0x80,0xf0,0xed,0xc1,0x27,0x80]
143 # GFX81: image_sample v[193:194], v237, s[28:35], s[4:7] dmask:0x7 d16 ; encoding: [0x00,0x07,0x80,0xf0,0xed,0xc1,0x27,0x80]
144 0x00,0x07,0x80,0xf0,0xed,0xc1,0x27,0x80
146 # GFX80: image_sample v[193:196], v237, s[28:35], s[4:7] dmask:0xf d16 ; encoding: [0x00,0x0f,0x80,0xf0,0xed,0xc1,0x27,0x80]
147 # GFX81: image_sample v[193:194], v237, s[28:35], s[4:7] dmask:0xf d16 ; encoding: [0x00,0x0f,0x80,0xf0,0xed,0xc1,0x27,0x80]
148 0x00,0x0f,0x80,0xf0,0xed,0xc1,0x27,0x80
150 #===------------------------------------------------------------------------===#
152 #===------------------------------------------------------------------------===#
154 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x1 unorm ; encoding: [0x00,0x11,0x48,0xf0,0x01,0x05,0x02,0x00]
155 0x00,0x11,0x48,0xf0,0x01,0x05,0x02,0x00
157 # VI: image_atomic_add v252, v1, s[8:15] dmask:0x1 unorm ; encoding: [0x00,0x11,0x48,0xf0,0x01,0xfc,0x02,0x00]
158 0x00,0x11,0x48,0xf0,0x01,0xfc,0x02,0x00
160 # VI: image_atomic_add v5, v255, s[8:15] dmask:0x1 unorm ; encoding: [0x00,0x11,0x48,0xf0,0xff,0x05,0x02,0x00]
161 0x00,0x11,0x48,0xf0,0xff,0x05,0x02,0x00
163 # VI: image_atomic_add v5, v1, s[92:99] dmask:0x1 unorm ; encoding: [0x00,0x11,0x48,0xf0,0x01,0x05,0x17,0x00]
164 0x00,0x11,0x48,0xf0,0x01,0x05,0x17,0x00
166 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x1 unorm glc ; encoding: [0x00,0x31,0x48,0xf0,0x01,0x05,0x02,0x00]
167 0x00,0x31,0x48,0xf0,0x01,0x05,0x02,0x00
169 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x1 unorm slc ; encoding: [0x00,0x11,0x48,0xf2,0x01,0x05,0x02,0x00]
170 0x00,0x11,0x48,0xf2,0x01,0x05,0x02,0x00
172 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x1 unorm lwe ; encoding: [0x00,0x11,0x4a,0xf0,0x01,0x05,0x02,0x00]
173 0x00,0x11,0x4a,0xf0,0x01,0x05,0x02,0x00
175 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x1 unorm da ; encoding: [0x00,0x51,0x48,0xf0,0x01,0x05,0x02,0x00]
176 0x00,0x51,0x48,0xf0,0x01,0x05,0x02,0x00
178 # VI: image_atomic_add v[5:6], v1, s[8:15] dmask:0x3 unorm ; encoding: [0x00,0x13,0x48,0xf0,0x01,0x05,0x02,0x00]
179 0x00,0x13,0x48,0xf0,0x01,0x05,0x02,0x00
181 # VI: image_atomic_cmpswap v[5:6], v1, s[8:15] dmask:0x3 unorm ; encoding: [0x00,0x13,0x44,0xf0,0x01,0x05,0x02,0x00]
182 0x00,0x13,0x44,0xf0,0x01,0x05,0x02,0x00
184 # VI: image_atomic_cmpswap v[5:8], v1, s[8:15] dmask:0xf unorm ; encoding: [0x00,0x1f,0x44,0xf0,0x01,0x05,0x02,0x00]
185 0x00,0x1f,0x44,0xf0,0x01,0x05,0x02,0x00
187 #===------------------------------------------------------------------------===#
188 # Invalid image atomics (incorrect dmask value).
189 # Disassembler may produce a partially incorrect instruction but should not fail.
190 #===------------------------------------------------------------------------===#
192 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x2 unorm ; encoding: [0x00,0x12,0x48,0xf0,0x01,0x05,0x02,0x00]
193 0x00,0x12,0x48,0xf0,0x01,0x05,0x02,0x00
195 # VI: image_atomic_add v5, v1, s[8:15] dmask:0x7 unorm ; encoding: [0x00,0x17,0x48,0xf0,0x01,0x05,0x02,0x00]
196 0x00,0x17,0x48,0xf0,0x01,0x05,0x02,0x00
198 # VI: image_atomic_add v5, v1, s[8:15] dmask:0xf unorm ; encoding: [0x00,0x1f,0x48,0xf0,0x01,0x05,0x02,0x00]
199 0x00,0x1f,0x48,0xf0,0x01,0x05,0x02,0x00
201 # VI: image_atomic_cmpswap v[5:6], v1, s[8:15] unorm ; encoding: [0x00,0x10,0x44,0xf0,0x01,0x05,0x02,0x00]
202 0x00,0x10,0x44,0xf0,0x01,0x05,0x02,0x00
204 # VI: image_atomic_cmpswap v[5:6], v1, s[8:15] dmask:0x1 unorm ; encoding: [0x00,0x11,0x44,0xf0,0x01,0x05,0x02,0x00]
205 0x00,0x11,0x44,0xf0,0x01,0x05,0x02,0x00
207 # VI: image_atomic_cmpswap v[5:6], v1, s[8:15] dmask:0xe unorm ; encoding: [0x00,0x1e,0x44,0xf0,0x01,0x05,0x02,0x00]
208 0x00,0x1e,0x44,0xf0,0x01,0x05,0x02,0x00
210 #===------------------------------------------------------------------------===#
212 #===------------------------------------------------------------------------===#
214 # VI: image_gather4 v[252:255], v1, s[8:15], s[12:15] dmask:0x1 ; encoding: [0x00,0x01,0x00,0xf1,0x01,0xfc,0x62,0x00]
215 0x00,0x01,0x00,0xf1,0x01,0xfc,0x62,0x00
217 # VI: image_gather4 v[5:8], v1, s[8:15], s[12:15] dmask:0x2 ; encoding: [0x00,0x02,0x00,0xf1,0x01,0x05,0x62,0x00]
218 0x00,0x02,0x00,0xf1,0x01,0x05,0x62,0x00
220 # VI: image_gather4 v[5:8], v1, s[8:15], s[12:15] dmask:0x4 ; encoding: [0x00,0x04,0x00,0xf1,0x01,0x05,0x62,0x00]
221 0x00,0x04,0x00,0xf1,0x01,0x05,0x62,0x00
223 # VI: image_gather4 v[5:8], v1, s[8:15], s[12:15] dmask:0x8 ; encoding: [0x00,0x08,0x00,0xf1,0x01,0x05,0x62,0x00]
224 0x00,0x08,0x00,0xf1,0x01,0x05,0x62,0x00
226 # GFX80: image_gather4 v[252:255], v1, s[8:15], s[12:15] dmask:0x1 unorm glc slc lwe da d16 ; encoding: [0x00,0x71,0x02,0xf3,0x01,0xfc,0x62,0x80]
227 # GFX81: image_gather4 v[252:253], v1, s[8:15], s[12:15] dmask:0x1 unorm glc slc lwe da d16 ; encoding: [0x00,0x71,0x02,0xf3,0x01,0xfc,0x62,0x80]
228 0x00,0x71,0x02,0xf3,0x01,0xfc,0x62,0x80
230 #===------------------------------------------------------------------------===#
231 # Invalid image gather (incorrect dmask value or tfe).
232 # Disassembler may produce a partially incorrect instruction but should not fail.
233 #===------------------------------------------------------------------------===#
235 # VI: image_gather4 v[252:255], v1, s[8:15], s[12:15] dmask:0x3 ; encoding: [0x00,0x03,0x00,0xf1,0x01,0xfc,0x62,0x00]
236 0x00,0x03,0x00,0xf1,0x01,0xfc,0x62,0x00
238 # VI: image_gather4 v[252:255], v1, s[8:15], s[12:15] dmask:0x1 unorm glc slc tfe lwe da ; encoding: [0x00,0x71,0x03,0xf3,0x01,0xfc,0x62,0x00]
239 0x00,0x71,0x03,0xf3,0x01,0xfc,0x62,0x00