1// RUN: llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s | FileCheck %s
2
3//---------------------------------------------------------------------------//
4// VOP1/VOP3 F16
5//---------------------------------------------------------------------------//
6
7v_ceil_f16 v0, -1
8// CHECK: [0xc1,0x8a,0x00,0x7e]
9
10v_ceil_f16 v0, -2
11// CHECK: [0xc2,0x8a,0x00,0x7e]
12
13v_ceil_f16 v0, -16
14// CHECK: [0xd0,0x8a,0x00,0x7e]
15
16v_ceil_f16 v0, -0.5
17// CHECK: [0xf1,0x8a,0x00,0x7e]
18
19v_ceil_f16 v0, -1.0
20// CHECK: [0xf3,0x8a,0x00,0x7e]
21
22v_ceil_f16 v0, -2.0
23// CHECK: [0xf5,0x8a,0x00,0x7e]
24
25v_ceil_f16 v0, -4.0
26// CHECK: [0xf7,0x8a,0x00,0x7e]
27
28// Arbitrary f16 literal in hex
29v_ceil_f16 v0, 0xabcd
30// CHECK: [0xff,0x8a,0x00,0x7e,0xcd,0xab,0x00,0x00]
31
32// '-' is a part of hex literal (not a 'neg' modifier)
33v_ceil_f16 v0, -0x5433
34// CHECK: [0xff,0x8a,0x00,0x7e,0xcd,0xab,0x00,0x00]
35
36v_ceil_f16 v0, abs(0xabcd)
37// CHECK: [0xff,0x8a,0x00,0x7e,0xcd,0x2b,0x00,0x00]
38
39v_ceil_f16 v0, neg(0xabcd)
40// CHECK: [0xff,0x8a,0x00,0x7e,0xcd,0x2b,0x00,0x00]
41
42v_ceil_f16 v0, neg(abs(0xabcd))
43// CHECK: [0xff,0x8a,0x00,0x7e,0xcd,0xab,0x00,0x00]
44
45v_ceil_f16 v0, -abs(0xabcd)
46// CHECK: [0xff,0x8a,0x00,0x7e,0xcd,0xab,0x00,0x00]
47
48// 1/(2*pi) encoded as inline constant in VOP1
49v_ceil_f16 v0, 0x3118
50// CHECK: [0xf8,0x8a,0x00,0x7e]
51
52// 1/(2*pi) encoded as inline constant in VOP3
53v_ceil_f16_e64 v0, 0x3118
54// CHECK: [0x00,0x00,0x85,0xd1,0xf8,0x00,0x00,0x00]
55
56// neg(-1/(2*pi)) = 1/(2*pi)
57v_ceil_f16 v0, neg(0xb118)
58// CHECK: [0xf8,0x8a,0x00,0x7e]
59
60// -1/(2*pi) cannot be encoded as inline constant in VOP1
61v_ceil_f16 v0, 0xb118
62// CHECK: [0xff,0x8a,0x00,0x7e,0x18,0xb1,0x00,0x00]
63
64// -1/(2*pi) cannot be encoded as inline constant in VOP1
65v_ceil_f16 v0, neg(0x3118)
66// CHECK: [0xff,0x8a,0x00,0x7e,0x18,0xb1,0x00,0x00]
67
68// -1/(2*pi) can be encoded as inline constant w/ modifiers in VOP3
69v_ceil_f16_e64 v0, neg(0x3118)
70// CHECK: [0x00,0x00,0x85,0xd1,0xf8,0x00,0x00,0x20]
71
72v_ceil_f16_e64 v0, abs(0x3118)
73// CHECK: 0x00,0x01,0x85,0xd1,0xf8,0x00,0x00,0x00]
74
75v_ceil_f16_e64 v0, neg(abs(0x3118))
76// CHECK: [0x00,0x01,0x85,0xd1,0xf8,0x00,0x00,0x20]
77
78v_ceil_f16_e64 v0, neg(|v1|)
79// CHECK: [0x00,0x01,0x85,0xd1,0x01,0x01,0x00,0x20]
80
81v_ceil_f16_e64 v0, -|v1|
82// CHECK: [0x00,0x01,0x85,0xd1,0x01,0x01,0x00,0x20]
83
84//---------------------------------------------------------------------------//
85// VOP1/VOP3 F64
86//---------------------------------------------------------------------------//
87
88// Encoded as inline constant 1 with 'neg' modifier
89v_ceil_f64 v[0:1], neg(1)
90// CHECK: [0x00,0x00,0x58,0xd1,0x81,0x00,0x00,0x20]
91
92// Encoded as inline constant -1 with 'neg' modifier
93v_ceil_f64 v[0:1], neg(-1)
94// CHECK: [0x00,0x00,0x58,0xd1,0xc1,0x00,0x00,0x20]
95
96v_ceil_f64_e32 v[0:1], 1.0
97// CHECK: [0xf2,0x30,0x00,0x7e]
98
99// abs(1.0) = 1.0
100v_ceil_f64_e32 v[0:1], abs(1.0)
101// CHECK: [0xf2,0x30,0x00,0x7e]
102
103// neg(1.0) = -1.0
104v_ceil_f64_e32 v[0:1], neg(1.0)
105// CHECK: [0xf3,0x30,0x00,0x7e]
106
107// 1/(2*pi) encoded as inline constant in VOP1
108v_ceil_f64 v[0:1], 0x3fc45f306dc9c882
109// CHECK: [0xf8,0x30,0x00,0x7e]
110
111// 1/(2*pi) encoded as inline constant in VOP3
112v_ceil_f64_e64 v[0:1], 0x3fc45f306dc9c882
113// CHECK: [0x00,0x00,0x58,0xd1,0xf8,0x00,0x00,0x00]
114
115// -1/(2*pi) cannot be encoded as inline constant in VOP1.
116// It cannot be encoded as literal either due to int literal rules.
117// So it is encoded as VOP3
118v_ceil_f64 v[0:1], abs(0x3fc45f306dc9c882)
119// CHECK: [0x00,0x01,0x58,0xd1,0xf8,0x00,0x00,0x00]
120
121v_ceil_f64 v[0:1], neg(abs(0x3fc45f306dc9c882))
122// CHECK: [0x00,0x01,0x58,0xd1,0xf8,0x00,0x00,0x20]
123
124
125//---------------------------------------------------------------------------//
126// VOP2/VOP3 F32
127//---------------------------------------------------------------------------//
128
129v_add_f32 v5, -1, v2
130// CHECK: [0xc1,0x04,0x0a,0x02]
131
132v_add_f32 v5, -16, v2
133// CHECK: [0xd0,0x04,0x0a,0x02]
134
135v_add_f32 v5, 0x3e22f983, v2
136// CHECK: [0xf8,0x04,0x0a,0x02]
137
138// abs(1/(2*pi)) = 1/(2*pi)
139v_add_f32 v5, abs(0x3e22f983), v2
140// CHECK: [0xf8,0x04,0x0a,0x02]
141
142// neg(-1/(2*pi)) = 1/(2*pi)
143v_add_f32 v5, neg(0xbe22f983), v2
144// CHECK: [0xf8,0x04,0x0a,0x02]
145
146// -1/(2*pi) cannot be encoded as inline constant in VOP1
147v_add_f32 v5, neg(0x3e22f983), v2
148// CHECK: [0xff,0x04,0x0a,0x02,0x83,0xf9,0x22,0xbe]
149
150
151v_add_f32_e64 v0, -2, s0
152// CHECK: [0x00,0x00,0x01,0xd1,0xc2,0x00,0x00,0x00]
153
154v_add_f32_e64 v0, -16, s0
155// CHECK: [0x00,0x00,0x01,0xd1,0xd0,0x00,0x00,0x00]
156
157v_add_f32_e64 v0, -0.5, s0
158// CHECK: [0x00,0x00,0x01,0xd1,0xf1,0x00,0x00,0x00]
159
160v_add_f32_e64 v0, -1.0, s0
161// CHECK: [0x00,0x00,0x01,0xd1,0xf3,0x00,0x00,0x00]
162
163v_add_f32_e64 v0, -2.0, s0
164// CHECK: [0x00,0x00,0x01,0xd1,0xf5,0x00,0x00,0x00]
165
166v_add_f32_e64 v0, -4.0, s0
167// CHECK: [0x00,0x00,0x01,0xd1,0xf7,0x00,0x00,0x00]
168
169v_add_f32_e64 v0, 0x3e22f983, s0
170// CHECK: [0x00,0x00,0x01,0xd1,0xf8,0x00,0x00,0x00]
171
172v_add_f32_e64 v0, neg(0x3e22f983), s0
173// CHECK: [0x00,0x00,0x01,0xd1,0xf8,0x00,0x00,0x20]
174
175//---------------------------------------------------------------------------//
176// VOPC/VOP3
177//---------------------------------------------------------------------------//
178
179v_cmp_eq_f16 vcc, -1, v0
180// CHECK: [0xc1,0x00,0x44,0x7c]
181
182v_cmp_eq_f16_e64 s[0:1], s0, -1
183// CHECK: [0x00,0x00,0x22,0xd0,0x00,0x82,0x01,0x00]
184
185v_cmp_eq_f16_e64 s[0:1], s0, 0x3118
186// CHECK: [0x00,0x00,0x22,0xd0,0x00,0xf0,0x01,0x00]
187
188v_cmp_eq_f16_e64 s[0:1], s0, neg(0x3118)
189// CHECK: [0x00,0x00,0x22,0xd0,0x00,0xf0,0x01,0x40]
190
191v_cmp_eq_f32 vcc, -4.0, v0
192// CHECK: [0xf7,0x00,0x84,0x7c]
193
194// 1/(2*pi) can be encoded as inline constant
195v_cmp_eq_f32 vcc, 0x3e22f983, v0
196// CHECK: [0xf8,0x00,0x84,0x7c]
197
198// -1/(2*pi) cannot be encoded as inline constant in VOPC
199v_cmp_eq_f32 vcc, neg(0x3e22f983), v0
200// CHECK: [0xff,0x00,0x84,0x7c,0x83,0xf9,0x22,0xbe]
201
202// abs(1/(2*pi)) = 1/(2*pi)
203v_cmp_eq_f32 vcc, abs(0x3e22f983), v0
204// CHECK: [0xf8,0x00,0x84,0x7c]
205
206// -1/(2*pi) can be encoded as inline constant w/ modifiers in VOP3
207v_cmp_eq_f32_e64 vcc, neg(0x3e22f983), v0
208// CHECK: [0x6a,0x00,0x42,0xd0,0xf8,0x00,0x02,0x20]
209
210v_cmp_eq_f32_e64 vcc, v0, abs(0x3e22f983)
211// CHECK: [0x6a,0x02,0x42,0xd0,0x00,0xf1,0x01,0x00]
212
213v_cmp_eq_f32_e64 vcc, v0, -abs(0x3e22f983)
214// CHECK: [0x6a,0x02,0x42,0xd0,0x00,0xf1,0x01,0x40]
215
216//---------------------------------------------------------------------------//
217// VOP3
218//---------------------------------------------------------------------------//
219
220v_add_f64 v[0:1], s[0:1], -1
221// CHECK: [0x00,0x00,0x80,0xd2,0x00,0x82,0x01,0x00]
222
223v_add_f64 v[0:1], s[0:1], -16
224// CHECK: [0x00,0x00,0x80,0xd2,0x00,0xa0,0x01,0x00]
225
226v_add_f64 v[0:1], s[0:1], -0.5
227// CHECK: [0x00,0x00,0x80,0xd2,0x00,0xe2,0x01,0x00]
228
229v_add_f64 v[0:1], s[0:1], -1.0
230// CHECK: [0x00,0x00,0x80,0xd2,0x00,0xe6,0x01,0x00]
231
232v_add_f64 v[0:1], s[0:1], -2.0
233// CHECK: [0x00,0x00,0x80,0xd2,0x00,0xea,0x01,0x00]
234
235v_add_f64 v[0:1], s[0:1], -4.0
236// CHECK: [0x00,0x00,0x80,0xd2,0x00,0xee,0x01,0x00]
237
238v_add_f64 v[4:5], s[0:1], 0x3fc45f306dc9c882
239// CHECK: [0x04,0x00,0x80,0xd2,0x00,0xf0,0x01,0x00]
240
241v_add_f64 v[4:5], s[0:1], neg(0x3fc45f306dc9c882)
242// CHECK: [0x04,0x00,0x80,0xd2,0x00,0xf0,0x01,0x40]
243
244
245v_cubeid_f32 v0, s0, s0, -1
246// CHECK: [0x00,0x00,0xc4,0xd1,0x00,0x00,0x04,0x03]
247
248v_cubeid_f32 v0, s0, s0, -4.0
249// CHECK: [0x00,0x00,0xc4,0xd1,0x00,0x00,0xdc,0x03]
250
251v_cubeid_f32 v0, s0, s0, 0x3e22f983
252// CHECK: [0x00,0x00,0xc4,0xd1,0x00,0x00,0xe0,0x03]
253
254v_cubeid_f32 v0, s0, s0, neg(0x3e22f983)
255// CHECK: [0x00,0x00,0xc4,0xd1,0x00,0x00,0xe0,0x83]
256
257v_cubeid_f32 v0, s0, s0, abs(0x3e22f983)
258// CHECK: [0x00,0x04,0xc4,0xd1,0x00,0x00,0xe0,0x03]
259
260
261//---------------------------------------------------------------------------//
262// VOP3 Instructions without Input Modifiers but with Output Modifiers
263//---------------------------------------------------------------------------//
264
265v_cvt_f64_i32_e64 v[5:6], s1 clamp
266// CHECK: [0x05,0x80,0x44,0xd1,0x01,0x00,0x00,0x00]
267
268v_cvt_f64_i32_e64 v[5:6], s1 mul:2
269// CHECK: [0x05,0x00,0x44,0xd1,0x01,0x00,0x00,0x08]
270
271v_cvt_f64_i32_e64 v[5:6], s1 mul:4
272// CHECK: [0x05,0x00,0x44,0xd1,0x01,0x00,0x00,0x10]
273
274v_cvt_f64_i32_e64 v[5:6], s1 div:2
275// CHECK: [0x05,0x00,0x44,0xd1,0x01,0x00,0x00,0x18]
276
277
278v_cvt_f64_u32_e64 v[5:6], s1 clamp
279// CHECK: [0x05,0x80,0x56,0xd1,0x01,0x00,0x00,0x00]
280
281v_cvt_f64_u32_e64 v[5:6], s1 mul:2
282// CHECK: [0x05,0x00,0x56,0xd1,0x01,0x00,0x00,0x08]
283
284v_cvt_f64_u32_e64 v[5:6], s1 mul:4
285// CHECK: [0x05,0x00,0x56,0xd1,0x01,0x00,0x00,0x10]
286
287v_cvt_f64_u32_e64 v[5:6], s1 div:2
288// CHECK: [0x05,0x00,0x56,0xd1,0x01,0x00,0x00,0x18]
289
290
291v_cvt_f32_i32_e64 v5, s1 clamp
292// CHECK: [0x05,0x80,0x45,0xd1,0x01,0x00,0x00,0x00]
293
294v_cvt_f32_i32_e64 v5, s1 mul:2
295// CHECK: [0x05,0x00,0x45,0xd1,0x01,0x00,0x00,0x08]
296
297v_cvt_f32_i32_e64 v5, s1 mul:4
298// CHECK: [0x05,0x00,0x45,0xd1,0x01,0x00,0x00,0x10]
299
300v_cvt_f32_i32_e64 v5, s1 div:2
301// CHECK: [0x05,0x00,0x45,0xd1,0x01,0x00,0x00,0x18]
302
303
304v_cvt_f32_u32_e64 v5, s1 clamp
305// CHECK: [0x05,0x80,0x46,0xd1,0x01,0x00,0x00,0x00]
306
307v_cvt_f32_u32_e64 v5, s1 mul:2
308// CHECK: [0x05,0x00,0x46,0xd1,0x01,0x00,0x00,0x08]
309
310v_cvt_f32_u32_e64 v5, s1 mul:4
311// CHECK: [0x05,0x00,0x46,0xd1,0x01,0x00,0x00,0x10]
312
313v_cvt_f32_u32_e64 v5, s1 div:2
314// CHECK: [0x05,0x00,0x46,0xd1,0x01,0x00,0x00,0x18]
315
316
317v_cvt_off_f32_i4_e64 v5, s1 clamp
318// CHECK: [0x05,0x80,0x4e,0xd1,0x01,0x00,0x00,0x00]
319
320v_cvt_off_f32_i4_e64 v5, s1 mul:2
321// CHECK: [0x05,0x00,0x4e,0xd1,0x01,0x00,0x00,0x08]
322
323v_cvt_off_f32_i4_e64 v5, s1 mul:4
324// CHECK: [0x05,0x00,0x4e,0xd1,0x01,0x00,0x00,0x10]
325
326v_cvt_off_f32_i4_e64 v5, s1 div:2
327// CHECK: [0x05,0x00,0x4e,0xd1,0x01,0x00,0x00,0x18]
328
329
330v_cvt_f32_ubyte0_e64 v5, s1 clamp
331// CHECK: [0x05,0x80,0x51,0xd1,0x01,0x00,0x00,0x00]
332
333v_cvt_f32_ubyte0_e64 v5, s1 mul:2
334// CHECK: [0x05,0x00,0x51,0xd1,0x01,0x00,0x00,0x08]
335
336v_cvt_f32_ubyte0_e64 v5, s1 mul:4
337// CHECK: [0x05,0x00,0x51,0xd1,0x01,0x00,0x00,0x10]
338
339v_cvt_f32_ubyte0_e64 v5, s1 div:2
340// CHECK: [0x05,0x00,0x51,0xd1,0x01,0x00,0x00,0x18]
341
342
343v_cvt_f32_ubyte1_e64 v5, s1 clamp
344// CHECK: [0x05,0x80,0x52,0xd1,0x01,0x00,0x00,0x00]
345
346v_cvt_f32_ubyte1_e64 v5, s1 mul:2
347// CHECK: [0x05,0x00,0x52,0xd1,0x01,0x00,0x00,0x08]
348
349v_cvt_f32_ubyte1_e64 v5, s1 mul:4
350// CHECK: [0x05,0x00,0x52,0xd1,0x01,0x00,0x00,0x10]
351
352v_cvt_f32_ubyte1_e64 v5, s1 div:2
353// CHECK: [0x05,0x00,0x52,0xd1,0x01,0x00,0x00,0x18]
354
355
356v_cvt_f32_ubyte2_e64 v5, s1 clamp
357// CHECK: [0x05,0x80,0x53,0xd1,0x01,0x00,0x00,0x00]
358
359v_cvt_f32_ubyte2_e64 v5, s1 mul:2
360// CHECK: [0x05,0x00,0x53,0xd1,0x01,0x00,0x00,0x08]
361
362v_cvt_f32_ubyte2_e64 v5, s1 mul:4
363// CHECK: [0x05,0x00,0x53,0xd1,0x01,0x00,0x00,0x10]
364
365v_cvt_f32_ubyte2_e64 v5, s1 div:2
366// CHECK: [0x05,0x00,0x53,0xd1,0x01,0x00,0x00,0x18]
367
368
369v_cvt_f32_ubyte3_e64 v5, s1 clamp
370// CHECK: [0x05,0x80,0x54,0xd1,0x01,0x00,0x00,0x00]
371
372v_cvt_f32_ubyte3_e64 v5, s1 mul:2
373// CHECK: [0x05,0x00,0x54,0xd1,0x01,0x00,0x00,0x08]
374
375v_cvt_f32_ubyte3_e64 v5, s1 mul:4
376// CHECK: [0x05,0x00,0x54,0xd1,0x01,0x00,0x00,0x10]
377
378v_cvt_f32_ubyte3_e64 v5, s1 div:2
379// CHECK: [0x05,0x00,0x54,0xd1,0x01,0x00,0x00,0x18]
380
381
382// NB: output modifiers are not supported for f16
383v_cvt_f16_i16_e64 v5, s1 clamp
384// CHECK: [0x05,0x80,0x7a,0xd1,0x01,0x00,0x00,0x00]
385
386// NB: output modifiers are not supported for f16
387v_cvt_f16_u16_e64 v5, s1 clamp
388// CHECK: [0x05,0x80,0x79,0xd1,0x01,0x00,0x00,0x00]
389