1# RUN: llvm-mc -triple arm64-apple-darwin --disassemble < %s | FileCheck %s
2
3#==---------------------------------------------------------------------------==
4# Add/Subtract with carry/borrow
5#==---------------------------------------------------------------------------==
6
70x41 0x00 0x03 0x1a
80x41 0x00 0x03 0x9a
90x85 0x00 0x03 0x3a
100x85 0x00 0x03 0xba
11
12# CHECK: adc  w1, w2, w3
13# CHECK: adc  x1, x2, x3
14# CHECK: adcs w5, w4, w3
15# CHECK: adcs x5, x4, x3
16
170x41 0x00 0x03 0x5a
180x41 0x00 0x03 0xda
190x41 0x00 0x03 0x7a
200x41 0x00 0x03 0xfa
21
22# CHECK: sbc  w1, w2, w3
23# CHECK: sbc  x1, x2, x3
24# CHECK: sbcs w1, w2, w3
25# CHECK: sbcs x1, x2, x3
26
27#==---------------------------------------------------------------------------==
28# Add/Subtract with (optionally shifted) immediate
29#==---------------------------------------------------------------------------==
30
310x83 0x00 0x10 0x11
320x83 0x00 0x10 0x91
33
34# CHECK: add w3, w4, #1024
35# CHECK: add x3, x4, #1024
36
370x83 0x00 0x50 0x11
380x83 0x00 0x40 0x11
390x83 0x00 0x50 0x91
400x83 0x00 0x40 0x91
410xff 0x83 0x00 0x91
42
43# CHECK: add w3, w4, #1024, lsl #12
44# CHECK: add x3, x4, #1024, lsl #12
45# CHECK: add x3, x4, #0, lsl #12
46# CHECK: add sp, sp, #32
47
480x83 0x00 0x10 0x31
490x83 0x00 0x50 0x31
500x83 0x00 0x10 0xb1
510x83 0x00 0x50 0xb1
520xff 0x83 0x00 0xb1
53
54# CHECK: adds w3, w4, #1024
55# CHECK: adds w3, w4, #1024, lsl #12
56# CHECK: adds x3, x4, #1024
57# CHECK: adds x3, x4, #1024, lsl #12
58# CHECK: cmn  sp, #32
59
600x83 0x00 0x10 0x51
610x83 0x00 0x50 0x51
620x83 0x00 0x10 0xd1
630x83 0x00 0x50 0xd1
640xff 0x83 0x00 0xd1
65
66# CHECK: sub w3, w4, #1024
67# CHECK: sub w3, w4, #1024, lsl #12
68# CHECK: sub x3, x4, #1024
69# CHECK: sub x3, x4, #1024, lsl #12
70# CHECK: sub sp, sp, #32
71
720x83 0x00 0x10 0x71
730x83 0x00 0x50 0x71
740x83 0x00 0x10 0xf1
750x83 0x00 0x50 0xf1
760xff 0x83 0x00 0xf1
77
78# CHECK: subs w3, w4, #1024
79# CHECK: subs w3, w4, #1024, lsl #12
80# CHECK: subs x3, x4, #1024
81# CHECK: subs x3, x4, #1024, lsl #12
82# CHECK: cmp  sp, #32
83
84#==---------------------------------------------------------------------------==
85# Add/Subtract register with (optional) shift
86#==---------------------------------------------------------------------------==
87
880xac 0x01 0x0e 0x0b
890xac 0x01 0x0e 0x8b
900xac 0x31 0x0e 0x0b
910xac 0x31 0x0e 0x8b
920xac 0x29 0x4e 0x0b
930xac 0x29 0x4e 0x8b
940xac 0x1d 0x8e 0x0b
950xac 0x9d 0x8e 0x8b
96
97# CHECK: add w12, w13, w14
98# CHECK: add x12, x13, x14
99# CHECK: add w12, w13, w14, lsl #12
100# CHECK: add x12, x13, x14, lsl #12
101# CHECK: add w12, w13, w14, lsr #10
102# CHECK: add x12, x13, x14, lsr #10
103# CHECK: add w12, w13, w14, asr #7
104# CHECK: add x12, x13, x14, asr #39
105
1060xac 0x01 0x0e 0x4b
1070xac 0x01 0x0e 0xcb
1080xac 0x31 0x0e 0x4b
1090xac 0x31 0x0e 0xcb
1100xac 0x29 0x4e 0x4b
1110xac 0x29 0x4e 0xcb
1120xac 0x1d 0x8e 0x4b
1130xac 0x9d 0x8e 0xcb
114
115# CHECK: sub w12, w13, w14
116# CHECK: sub x12, x13, x14
117# CHECK: sub w12, w13, w14, lsl #12
118# CHECK: sub x12, x13, x14, lsl #12
119# CHECK: sub w12, w13, w14, lsr #10
120# CHECK: sub x12, x13, x14, lsr #10
121# CHECK: sub w12, w13, w14, asr #7
122# CHECK: sub x12, x13, x14, asr #39
123
1240xac 0x01 0x0e 0x2b
1250xac 0x01 0x0e 0xab
1260xac 0x31 0x0e 0x2b
1270xac 0x31 0x0e 0xab
1280xac 0x29 0x4e 0x2b
1290xac 0x29 0x4e 0xab
1300xac 0x1d 0x8e 0x2b
1310xac 0x9d 0x8e 0xab
132
133# CHECK: adds w12, w13, w14
134# CHECK: adds x12, x13, x14
135# CHECK: adds w12, w13, w14, lsl #12
136# CHECK: adds x12, x13, x14, lsl #12
137# CHECK: adds w12, w13, w14, lsr #10
138# CHECK: adds x12, x13, x14, lsr #10
139# CHECK: adds w12, w13, w14, asr #7
140# CHECK: adds x12, x13, x14, asr #39
141
1420xac 0x01 0x0e 0x6b
1430xac 0x01 0x0e 0xeb
1440xac 0x31 0x0e 0x6b
1450xac 0x31 0x0e 0xeb
1460xac 0x29 0x4e 0x6b
1470xac 0x29 0x4e 0xeb
1480xac 0x1d 0x8e 0x6b
1490xac 0x9d 0x8e 0xeb
150
151# CHECK: subs w12, w13, w14
152# CHECK: subs x12, x13, x14
153# CHECK: subs w12, w13, w14, lsl #12
154# CHECK: subs x12, x13, x14, lsl #12
155# CHECK: subs w12, w13, w14, lsr #10
156# CHECK: subs x12, x13, x14, lsr #10
157# CHECK: subs w12, w13, w14, asr #7
158# CHECK: subs x12, x13, x14, asr #39
159
160#==---------------------------------------------------------------------------==
161# Add/Subtract with (optional) extend
162#==---------------------------------------------------------------------------==
163
1640x41 0x00 0x23 0x0b
1650x41 0x20 0x23 0x0b
1660x41 0x40 0x23 0x0b
1670x41 0x60 0x23 0x0b
1680x41 0x80 0x23 0x0b
1690x41 0xa0 0x23 0x0b
1700x41 0xc0 0x23 0x0b
1710x41 0xe0 0x23 0x0b
172
173# CHECK: add w1, w2, w3, uxtb
174# CHECK: add w1, w2, w3, uxth
175# CHECK: add w1, w2, w3
176# CHECK: add w1, w2, w3, uxtx
177# CHECK: add w1, w2, w3, sxtb
178# CHECK: add w1, w2, w3, sxth
179# CHECK: add w1, w2, w3, sxtw
180# CHECK: add w1, w2, w3, sxtx
181
1820x41 0x00 0x23 0x8b
1830x41 0x20 0x23 0x8b
1840x41 0x40 0x23 0x8b
1850x41 0x80 0x23 0x8b
1860x41 0xa0 0x23 0x8b
1870x41 0xc0 0x23 0x8b
188
189# CHECK: add x1, x2, w3, uxtb
190# CHECK: add x1, x2, w3, uxth
191# CHECK: add x1, x2, w3, uxtw
192# CHECK: add x1, x2, w3, sxtb
193# CHECK: add x1, x2, w3, sxth
194# CHECK: add x1, x2, w3, sxtw
195
1960xe1 0x43 0x23 0x0b
1970xe1 0x43 0x23 0x0b
1980x5f 0x60 0x23 0x8b
1990x5f 0x60 0x23 0x8b
200
201# CHECK: add w1, wsp, w3
202# CHECK: add w1, wsp, w3
203# CHECK: add sp, x2, x3
204# CHECK: add sp, x2, x3
205
2060x41 0x00 0x23 0x4b
2070x41 0x20 0x23 0x4b
2080x41 0x40 0x23 0x4b
2090x41 0x60 0x23 0x4b
2100x41 0x80 0x23 0x4b
2110x41 0xa0 0x23 0x4b
2120x41 0xc0 0x23 0x4b
2130x41 0xe0 0x23 0x4b
214
215# CHECK: sub w1, w2, w3, uxtb
216# CHECK: sub w1, w2, w3, uxth
217# CHECK: sub w1, w2, w3
218# CHECK: sub w1, w2, w3, uxtx
219# CHECK: sub w1, w2, w3, sxtb
220# CHECK: sub w1, w2, w3, sxth
221# CHECK: sub w1, w2, w3, sxtw
222# CHECK: sub w1, w2, w3, sxtx
223
2240x41 0x00 0x23 0xcb
2250x41 0x20 0x23 0xcb
2260x41 0x40 0x23 0xcb
2270x41 0x80 0x23 0xcb
2280x41 0xa0 0x23 0xcb
2290x41 0xc0 0x23 0xcb
230
231# CHECK: sub x1, x2, w3, uxtb
232# CHECK: sub x1, x2, w3, uxth
233# CHECK: sub x1, x2, w3, uxtw
234# CHECK: sub x1, x2, w3, sxtb
235# CHECK: sub x1, x2, w3, sxth
236# CHECK: sub x1, x2, w3, sxtw
237
2380xe1 0x43 0x23 0x4b
2390xe1 0x43 0x23 0x4b
2400x5f 0x60 0x23 0xcb
2410x5f 0x60 0x23 0xcb
242
243# CHECK: sub w1, wsp, w3
244# CHECK: sub w1, wsp, w3
245# CHECK: sub sp, x2, x3
246# CHECK: sub sp, x2, x3
247
2480x41 0x00 0x23 0x2b
2490x41 0x20 0x23 0x2b
2500x41 0x40 0x23 0x2b
2510x41 0x60 0x23 0x2b
2520x41 0x80 0x23 0x2b
2530x41 0xa0 0x23 0x2b
2540x41 0xc0 0x23 0x2b
2550x41 0xe0 0x23 0x2b
256
257# CHECK: adds w1, w2, w3, uxtb
258# CHECK: adds w1, w2, w3, uxth
259# CHECK: adds w1, w2, w3
260# CHECK: adds w1, w2, w3, uxtx
261# CHECK: adds w1, w2, w3, sxtb
262# CHECK: adds w1, w2, w3, sxth
263# CHECK: adds w1, w2, w3, sxtw
264# CHECK: adds w1, w2, w3, sxtx
265
2660x41 0x00 0x23 0xab
2670x41 0x20 0x23 0xab
2680x41 0x40 0x23 0xab
2690x41 0x80 0x23 0xab
2700x41 0xa0 0x23 0xab
2710x41 0xc0 0x23 0xab
272
273# CHECK: adds x1, x2, w3, uxtb
274# CHECK: adds x1, x2, w3, uxth
275# CHECK: adds x1, x2, w3, uxtw
276# CHECK: adds x1, x2, w3, sxtb
277# CHECK: adds x1, x2, w3, sxth
278# CHECK: adds x1, x2, w3, sxtw
279
2800xe1 0x43 0x23 0x2b
2810xe1 0x43 0x23 0x2b
282
283# CHECK: adds w1, wsp, w3
284# CHECK: adds w1, wsp, w3
285
2860x41 0x00 0x23 0x6b
2870x41 0x20 0x23 0x6b
2880x41 0x40 0x23 0x6b
2890x41 0x60 0x23 0x6b
2900x41 0x80 0x23 0x6b
2910x41 0xa0 0x23 0x6b
2920x41 0xc0 0x23 0x6b
2930x41 0xe0 0x23 0x6b
294
295# CHECK: subs w1, w2, w3, uxtb
296# CHECK: subs w1, w2, w3, uxth
297# CHECK: subs w1, w2, w3
298# CHECK: subs w1, w2, w3, uxtx
299# CHECK: subs w1, w2, w3, sxtb
300# CHECK: subs w1, w2, w3, sxth
301# CHECK: subs w1, w2, w3, sxtw
302# CHECK: subs w1, w2, w3, sxtx
303
3040x41 0x00 0x23 0xeb
3050x41 0x20 0x23 0xeb
3060x41 0x40 0x23 0xeb
3070x41 0x80 0x23 0xeb
3080x41 0xa0 0x23 0xeb
3090x41 0xc0 0x23 0xeb
310
311# CHECK: subs x1, x2, w3, uxtb
312# CHECK: subs x1, x2, w3, uxth
313# CHECK: subs x1, x2, w3, uxtw
314# CHECK: subs x1, x2, w3, sxtb
315# CHECK: subs x1, x2, w3, sxth
316# CHECK: subs x1, x2, w3, sxtw
317
3180xe1 0x43 0x23 0x6b
3190xe1 0x43 0x23 0x6b
320
321# CHECK: subs w1, wsp, w3
322# CHECK: subs w1, wsp, w3
323
3240x1f 0x41 0x28 0xeb
3250x3f 0x41 0x28 0x6b
3260xff 0x43 0x28 0x6b
3270xff 0x43 0x28 0xeb
328
329# CHECK: cmp x8, w8, uxtw
330# CHECK: cmp w9, w8, uxtw
331# CHECK: cmp wsp, w8
332# CHECK: cmp sp, w8
333
3340x3f 0x41 0x28 0x4b
3350xe1 0x43 0x28 0x4b
3360xff 0x43 0x28 0x4b
3370x3f 0x41 0x28 0xcb
3380xe1 0x43 0x28 0xcb
3390xff 0x43 0x28 0xcb
3400xe1 0x43 0x28 0x6b
3410xe1 0x43 0x28 0xeb
342
343# CHECK: sub wsp, w9, w8
344# CHECK: sub w1, wsp, w8
345# CHECK: sub wsp, wsp, w8
346# CHECK: sub sp, x9, w8
347# CHECK: sub x1, sp, w8
348# CHECK: sub sp, sp, w8
349# CHECK: subs w1, wsp, w8
350# CHECK: subs x1, sp, w8
351
352#==---------------------------------------------------------------------------==
353# Signed/Unsigned divide
354#==---------------------------------------------------------------------------==
355
3560x41 0x0c 0xc3 0x1a
3570x41 0x0c 0xc3 0x9a
3580x41 0x08 0xc3 0x1a
3590x41 0x08 0xc3 0x9a
360
361# CHECK: sdiv w1, w2, w3
362# CHECK: sdiv x1, x2, x3
363# CHECK: udiv w1, w2, w3
364# CHECK: udiv x1, x2, x3
365
366#==---------------------------------------------------------------------------==
367# Variable shifts
368#==---------------------------------------------------------------------------==
369
370  0x41 0x28 0xc3 0x1a
371# CHECK: asr w1, w2, w3
372  0x41 0x28 0xc3 0x9a
373# CHECK: asr x1, x2, x3
374  0x41 0x20 0xc3 0x1a
375# CHECK: lsl w1, w2, w3
376  0x41 0x20 0xc3 0x9a
377# CHECK: lsl x1, x2, x3
378  0x41 0x24 0xc3 0x1a
379# CHECK: lsr w1, w2, w3
380  0x41 0x24 0xc3 0x9a
381# CHECK: lsr x1, x2, x3
382  0x41 0x2c 0xc3 0x1a
383# CHECK: ror w1, w2, w3
384  0x41 0x2c 0xc3 0x9a
385# CHECK: ror x1, x2, x3
386
387#==---------------------------------------------------------------------------==
388# One operand instructions
389#==---------------------------------------------------------------------------==
390
391  0x41 0x14 0xc0 0x5a
392# CHECK: cls w1, w2
393  0x41 0x14 0xc0 0xda
394# CHECK: cls x1, x2
395  0x41 0x10 0xc0 0x5a
396# CHECK: clz w1, w2
397  0x41 0x10 0xc0 0xda
398# CHECK: clz x1, x2
399  0x41 0x00 0xc0 0x5a
400# CHECK: rbit w1, w2
401  0x41 0x00 0xc0 0xda
402# CHECK: rbit x1, x2
403  0x41 0x08 0xc0 0x5a
404# CHECK: rev w1, w2
405  0x41 0x0c 0xc0 0xda
406# CHECK: rev x1, x2
407  0x41 0x04 0xc0 0x5a
408# CHECK: rev16 w1, w2
409  0x41 0x04 0xc0 0xda
410# CHECK: rev16 x1, x2
411  0x41 0x08 0xc0 0xda
412# CHECK: rev32 x1, x2
413
414#==---------------------------------------------------------------------------==
415# 6.6.1 Multiply-add instructions
416#==---------------------------------------------------------------------------==
417
4180x41 0x10 0x03 0x1b
4190x41 0x10 0x03 0x9b
4200x41 0x90 0x03 0x1b
4210x41 0x90 0x03 0x9b
4220x41 0x10 0x23 0x9b
4230x41 0x90 0x23 0x9b
4240x41 0x10 0xa3 0x9b
4250x41 0x90 0xa3 0x9b
426
427# CHECK: madd   w1, w2, w3, w4
428# CHECK: madd   x1, x2, x3, x4
429# CHECK: msub   w1, w2, w3, w4
430# CHECK: msub   x1, x2, x3, x4
431# CHECK: smaddl x1, w2, w3, x4
432# CHECK: smsubl x1, w2, w3, x4
433# CHECK: umaddl x1, w2, w3, x4
434# CHECK: umsubl x1, w2, w3, x4
435
436#==---------------------------------------------------------------------------==
437# Multiply-high instructions
438#==---------------------------------------------------------------------------==
439
4400x41 0x7c 0x43 0x9b
4410x41 0x7c 0xc3 0x9b
442
443# CHECK: smulh x1, x2, x3
444# CHECK: umulh x1, x2, x3
445
446#==---------------------------------------------------------------------------==
447# Move immediate instructions
448#==---------------------------------------------------------------------------==
449
4500x20 0x00 0x80 0x52
4510x20 0x00 0x80 0xd2
4520x20 0x00 0xa0 0x52
4530x20 0x00 0xa0 0xd2
454
455# CHECK: movz w0, #0x1
456# CHECK: movz x0, #0x1
457# CHECK: movz w0, #0x1, lsl #16
458# CHECK: movz x0, #0x1, lsl #16
459
4600x40 0x00 0x80 0x12
4610x40 0x00 0x80 0x92
4620x40 0x00 0xa0 0x12
4630x40 0x00 0xa0 0x92
464
465# CHECK: movn w0, #0x2
466# CHECK: movn x0, #0x2
467# CHECK: movn w0, #0x2, lsl #16
468# CHECK: movn x0, #0x2, lsl #16
469
4700x20 0x00 0x80 0x72
4710x20 0x00 0x80 0xf2
4720x20 0x00 0xa0 0x72
4730x20 0x00 0xa0 0xf2
474
475# CHECK: movk w0, #0x1
476# CHECK: movk x0, #0x1
477# CHECK: movk w0, #0x1, lsl #16
478# CHECK: movk x0, #0x1, lsl #16
479
480#==---------------------------------------------------------------------------==
481# Conditionally set flags instructions
482#==---------------------------------------------------------------------------==
483
484  0x1f 0x00 0x00 0x31
485# CHECK: cmn w0, #0
486  0x1f 0xfc 0x03 0xb1
487# CHECK: x0, #255
488
489  0x23 0x08 0x42 0x3a
490# CHECK: ccmn w1, #2, #3, eq
491  0x23 0x08 0x42 0xba
492# CHECK: ccmn x1, #2, #3, eq
493  0x23 0x08 0x42 0x7a
494# CHECK: ccmp w1, #2, #3, eq
495  0x23 0x08 0x42 0xfa
496# CHECK: ccmp x1, #2, #3, eq
497
498  0x23 0x00 0x42 0x3a
499# CHECK: ccmn w1, w2, #3, eq
500  0x23 0x00 0x42 0xba
501# CHECK: ccmn x1, x2, #3, eq
502  0x23 0x00 0x42 0x7a
503# CHECK: ccmp w1, w2, #3, eq
504  0x23 0x00 0x42 0xfa
505# CHECK: ccmp x1, x2, #3, eq
506
507#==---------------------------------------------------------------------------==
508# Conditional select instructions
509#==---------------------------------------------------------------------------==
510
511  0x41 0x00 0x83 0x1a
512# CHECK: csel w1, w2, w3, eq
513  0x41 0x00 0x83 0x9a
514# CHECK: csel x1, x2, x3, eq
515  0x41 0x04 0x83 0x1a
516# CHECK: csinc w1, w2, w3, eq
517  0x41 0x04 0x83 0x9a
518# CHECK: csinc x1, x2, x3, eq
519  0x41 0x00 0x83 0x5a
520# CHECK: csinv w1, w2, w3, eq
521  0x41 0x00 0x83 0xda
522# CHECK: csinv x1, x2, x3, eq
523  0x41 0x04 0x83 0x5a
524# CHECK: csneg w1, w2, w3, eq
525  0x41 0x04 0x83 0xda
526# CHECK: csneg x1, x2, x3, eq
527