arm64-arithmetic.txt
12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# RUN: llvm-mc -triple arm64-apple-darwin --disassemble < %s | FileCheck %s
#==---------------------------------------------------------------------------==
# Add/Subtract with carry/borrow
#==---------------------------------------------------------------------------==
0x41 0x00 0x03 0x1a
0x41 0x00 0x03 0x9a
0x85 0x00 0x03 0x3a
0x85 0x00 0x03 0xba
# CHECK: adc w1, w2, w3
# CHECK: adc x1, x2, x3
# CHECK: adcs w5, w4, w3
# CHECK: adcs x5, x4, x3
0x41 0x00 0x03 0x5a
0x41 0x00 0x03 0xda
0x41 0x00 0x03 0x7a
0x41 0x00 0x03 0xfa
# CHECK: sbc w1, w2, w3
# CHECK: sbc x1, x2, x3
# CHECK: sbcs w1, w2, w3
# CHECK: sbcs x1, x2, x3
#==---------------------------------------------------------------------------==
# Add/Subtract with (optionally shifted) immediate
#==---------------------------------------------------------------------------==
0x83 0x00 0x10 0x11
0x83 0x00 0x10 0x91
# CHECK: add w3, w4, #1024
# CHECK: add x3, x4, #1024
0x83 0x00 0x50 0x11
0x83 0x00 0x40 0x11
0x83 0x00 0x50 0x91
0x83 0x00 0x40 0x91
0xff 0x83 0x00 0x91
# CHECK: add w3, w4, #1024, lsl #12
# CHECK: add x3, x4, #1024, lsl #12
# CHECK: add x3, x4, #0, lsl #12
# CHECK: add sp, sp, #32
0x83 0x00 0x10 0x31
0x83 0x00 0x50 0x31
0x83 0x00 0x10 0xb1
0x83 0x00 0x50 0xb1
0xff 0x83 0x00 0xb1
# CHECK: adds w3, w4, #1024
# CHECK: adds w3, w4, #1024, lsl #12
# CHECK: adds x3, x4, #1024
# CHECK: adds x3, x4, #1024, lsl #12
# CHECK: cmn sp, #32
0x83 0x00 0x10 0x51
0x83 0x00 0x50 0x51
0x83 0x00 0x10 0xd1
0x83 0x00 0x50 0xd1
0xff 0x83 0x00 0xd1
# CHECK: sub w3, w4, #1024
# CHECK: sub w3, w4, #1024, lsl #12
# CHECK: sub x3, x4, #1024
# CHECK: sub x3, x4, #1024, lsl #12
# CHECK: sub sp, sp, #32
0x83 0x00 0x10 0x71
0x83 0x00 0x50 0x71
0x83 0x00 0x10 0xf1
0x83 0x00 0x50 0xf1
0xff 0x83 0x00 0xf1
# CHECK: subs w3, w4, #1024
# CHECK: subs w3, w4, #1024, lsl #12
# CHECK: subs x3, x4, #1024
# CHECK: subs x3, x4, #1024, lsl #12
# CHECK: cmp sp, #32
#==---------------------------------------------------------------------------==
# Add/Subtract register with (optional) shift
#==---------------------------------------------------------------------------==
0xac 0x01 0x0e 0x0b
0xac 0x01 0x0e 0x8b
0xac 0x31 0x0e 0x0b
0xac 0x31 0x0e 0x8b
0xac 0x29 0x4e 0x0b
0xac 0x29 0x4e 0x8b
0xac 0x1d 0x8e 0x0b
0xac 0x9d 0x8e 0x8b
# CHECK: add w12, w13, w14
# CHECK: add x12, x13, x14
# CHECK: add w12, w13, w14, lsl #12
# CHECK: add x12, x13, x14, lsl #12
# CHECK: add w12, w13, w14, lsr #10
# CHECK: add x12, x13, x14, lsr #10
# CHECK: add w12, w13, w14, asr #7
# CHECK: add x12, x13, x14, asr #39
0xac 0x01 0x0e 0x4b
0xac 0x01 0x0e 0xcb
0xac 0x31 0x0e 0x4b
0xac 0x31 0x0e 0xcb
0xac 0x29 0x4e 0x4b
0xac 0x29 0x4e 0xcb
0xac 0x1d 0x8e 0x4b
0xac 0x9d 0x8e 0xcb
# CHECK: sub w12, w13, w14
# CHECK: sub x12, x13, x14
# CHECK: sub w12, w13, w14, lsl #12
# CHECK: sub x12, x13, x14, lsl #12
# CHECK: sub w12, w13, w14, lsr #10
# CHECK: sub x12, x13, x14, lsr #10
# CHECK: sub w12, w13, w14, asr #7
# CHECK: sub x12, x13, x14, asr #39
0xac 0x01 0x0e 0x2b
0xac 0x01 0x0e 0xab
0xac 0x31 0x0e 0x2b
0xac 0x31 0x0e 0xab
0xac 0x29 0x4e 0x2b
0xac 0x29 0x4e 0xab
0xac 0x1d 0x8e 0x2b
0xac 0x9d 0x8e 0xab
# CHECK: adds w12, w13, w14
# CHECK: adds x12, x13, x14
# CHECK: adds w12, w13, w14, lsl #12
# CHECK: adds x12, x13, x14, lsl #12
# CHECK: adds w12, w13, w14, lsr #10
# CHECK: adds x12, x13, x14, lsr #10
# CHECK: adds w12, w13, w14, asr #7
# CHECK: adds x12, x13, x14, asr #39
0xac 0x01 0x0e 0x6b
0xac 0x01 0x0e 0xeb
0xac 0x31 0x0e 0x6b
0xac 0x31 0x0e 0xeb
0xac 0x29 0x4e 0x6b
0xac 0x29 0x4e 0xeb
0xac 0x1d 0x8e 0x6b
0xac 0x9d 0x8e 0xeb
# CHECK: subs w12, w13, w14
# CHECK: subs x12, x13, x14
# CHECK: subs w12, w13, w14, lsl #12
# CHECK: subs x12, x13, x14, lsl #12
# CHECK: subs w12, w13, w14, lsr #10
# CHECK: subs x12, x13, x14, lsr #10
# CHECK: subs w12, w13, w14, asr #7
# CHECK: subs x12, x13, x14, asr #39
#==---------------------------------------------------------------------------==
# Add/Subtract with (optional) extend
#==---------------------------------------------------------------------------==
0x41 0x00 0x23 0x0b
0x41 0x20 0x23 0x0b
0x41 0x40 0x23 0x0b
0x41 0x60 0x23 0x0b
0x41 0x80 0x23 0x0b
0x41 0xa0 0x23 0x0b
0x41 0xc0 0x23 0x0b
0x41 0xe0 0x23 0x0b
# CHECK: add w1, w2, w3, uxtb
# CHECK: add w1, w2, w3, uxth
# CHECK: add w1, w2, w3
# CHECK: add w1, w2, w3, uxtx
# CHECK: add w1, w2, w3, sxtb
# CHECK: add w1, w2, w3, sxth
# CHECK: add w1, w2, w3, sxtw
# CHECK: add w1, w2, w3, sxtx
0x41 0x00 0x23 0x8b
0x41 0x20 0x23 0x8b
0x41 0x40 0x23 0x8b
0x41 0x80 0x23 0x8b
0x41 0xa0 0x23 0x8b
0x41 0xc0 0x23 0x8b
# CHECK: add x1, x2, w3, uxtb
# CHECK: add x1, x2, w3, uxth
# CHECK: add x1, x2, w3, uxtw
# CHECK: add x1, x2, w3, sxtb
# CHECK: add x1, x2, w3, sxth
# CHECK: add x1, x2, w3, sxtw
0xe1 0x43 0x23 0x0b
0xe1 0x43 0x23 0x0b
0x5f 0x60 0x23 0x8b
0x5f 0x60 0x23 0x8b
# CHECK: add w1, wsp, w3
# CHECK: add w1, wsp, w3
# CHECK: add sp, x2, x3
# CHECK: add sp, x2, x3
0x41 0x00 0x23 0x4b
0x41 0x20 0x23 0x4b
0x41 0x40 0x23 0x4b
0x41 0x60 0x23 0x4b
0x41 0x80 0x23 0x4b
0x41 0xa0 0x23 0x4b
0x41 0xc0 0x23 0x4b
0x41 0xe0 0x23 0x4b
# CHECK: sub w1, w2, w3, uxtb
# CHECK: sub w1, w2, w3, uxth
# CHECK: sub w1, w2, w3
# CHECK: sub w1, w2, w3, uxtx
# CHECK: sub w1, w2, w3, sxtb
# CHECK: sub w1, w2, w3, sxth
# CHECK: sub w1, w2, w3, sxtw
# CHECK: sub w1, w2, w3, sxtx
0x41 0x00 0x23 0xcb
0x41 0x20 0x23 0xcb
0x41 0x40 0x23 0xcb
0x41 0x80 0x23 0xcb
0x41 0xa0 0x23 0xcb
0x41 0xc0 0x23 0xcb
# CHECK: sub x1, x2, w3, uxtb
# CHECK: sub x1, x2, w3, uxth
# CHECK: sub x1, x2, w3, uxtw
# CHECK: sub x1, x2, w3, sxtb
# CHECK: sub x1, x2, w3, sxth
# CHECK: sub x1, x2, w3, sxtw
0xe1 0x43 0x23 0x4b
0xe1 0x43 0x23 0x4b
0x5f 0x60 0x23 0xcb
0x5f 0x60 0x23 0xcb
# CHECK: sub w1, wsp, w3
# CHECK: sub w1, wsp, w3
# CHECK: sub sp, x2, x3
# CHECK: sub sp, x2, x3
0x41 0x00 0x23 0x2b
0x41 0x20 0x23 0x2b
0x41 0x40 0x23 0x2b
0x41 0x60 0x23 0x2b
0x41 0x80 0x23 0x2b
0x41 0xa0 0x23 0x2b
0x41 0xc0 0x23 0x2b
0x41 0xe0 0x23 0x2b
# CHECK: adds w1, w2, w3, uxtb
# CHECK: adds w1, w2, w3, uxth
# CHECK: adds w1, w2, w3
# CHECK: adds w1, w2, w3, uxtx
# CHECK: adds w1, w2, w3, sxtb
# CHECK: adds w1, w2, w3, sxth
# CHECK: adds w1, w2, w3, sxtw
# CHECK: adds w1, w2, w3, sxtx
0x41 0x00 0x23 0xab
0x41 0x20 0x23 0xab
0x41 0x40 0x23 0xab
0x41 0x80 0x23 0xab
0x41 0xa0 0x23 0xab
0x41 0xc0 0x23 0xab
# CHECK: adds x1, x2, w3, uxtb
# CHECK: adds x1, x2, w3, uxth
# CHECK: adds x1, x2, w3, uxtw
# CHECK: adds x1, x2, w3, sxtb
# CHECK: adds x1, x2, w3, sxth
# CHECK: adds x1, x2, w3, sxtw
0xe1 0x43 0x23 0x2b
0xe1 0x43 0x23 0x2b
# CHECK: adds w1, wsp, w3
# CHECK: adds w1, wsp, w3
0x41 0x00 0x23 0x6b
0x41 0x20 0x23 0x6b
0x41 0x40 0x23 0x6b
0x41 0x60 0x23 0x6b
0x41 0x80 0x23 0x6b
0x41 0xa0 0x23 0x6b
0x41 0xc0 0x23 0x6b
0x41 0xe0 0x23 0x6b
# CHECK: subs w1, w2, w3, uxtb
# CHECK: subs w1, w2, w3, uxth
# CHECK: subs w1, w2, w3
# CHECK: subs w1, w2, w3, uxtx
# CHECK: subs w1, w2, w3, sxtb
# CHECK: subs w1, w2, w3, sxth
# CHECK: subs w1, w2, w3, sxtw
# CHECK: subs w1, w2, w3, sxtx
0x41 0x00 0x23 0xeb
0x41 0x20 0x23 0xeb
0x41 0x40 0x23 0xeb
0x41 0x80 0x23 0xeb
0x41 0xa0 0x23 0xeb
0x41 0xc0 0x23 0xeb
# CHECK: subs x1, x2, w3, uxtb
# CHECK: subs x1, x2, w3, uxth
# CHECK: subs x1, x2, w3, uxtw
# CHECK: subs x1, x2, w3, sxtb
# CHECK: subs x1, x2, w3, sxth
# CHECK: subs x1, x2, w3, sxtw
0xe1 0x43 0x23 0x6b
0xe1 0x43 0x23 0x6b
# CHECK: subs w1, wsp, w3
# CHECK: subs w1, wsp, w3
0x1f 0x41 0x28 0xeb
0x3f 0x41 0x28 0x6b
0xff 0x43 0x28 0x6b
0xff 0x43 0x28 0xeb
# CHECK: cmp x8, w8, uxtw
# CHECK: cmp w9, w8, uxtw
# CHECK: cmp wsp, w8
# CHECK: cmp sp, w8
0x3f 0x41 0x28 0x4b
0xe1 0x43 0x28 0x4b
0xff 0x43 0x28 0x4b
0x3f 0x41 0x28 0xcb
0xe1 0x43 0x28 0xcb
0xff 0x43 0x28 0xcb
0xe1 0x43 0x28 0x6b
0xe1 0x43 0x28 0xeb
# CHECK: sub wsp, w9, w8
# CHECK: sub w1, wsp, w8
# CHECK: sub wsp, wsp, w8
# CHECK: sub sp, x9, w8
# CHECK: sub x1, sp, w8
# CHECK: sub sp, sp, w8
# CHECK: subs w1, wsp, w8
# CHECK: subs x1, sp, w8
#==---------------------------------------------------------------------------==
# Signed/Unsigned divide
#==---------------------------------------------------------------------------==
0x41 0x0c 0xc3 0x1a
0x41 0x0c 0xc3 0x9a
0x41 0x08 0xc3 0x1a
0x41 0x08 0xc3 0x9a
# CHECK: sdiv w1, w2, w3
# CHECK: sdiv x1, x2, x3
# CHECK: udiv w1, w2, w3
# CHECK: udiv x1, x2, x3
#==---------------------------------------------------------------------------==
# Variable shifts
#==---------------------------------------------------------------------------==
0x41 0x28 0xc3 0x1a
# CHECK: asr w1, w2, w3
0x41 0x28 0xc3 0x9a
# CHECK: asr x1, x2, x3
0x41 0x20 0xc3 0x1a
# CHECK: lsl w1, w2, w3
0x41 0x20 0xc3 0x9a
# CHECK: lsl x1, x2, x3
0x41 0x24 0xc3 0x1a
# CHECK: lsr w1, w2, w3
0x41 0x24 0xc3 0x9a
# CHECK: lsr x1, x2, x3
0x41 0x2c 0xc3 0x1a
# CHECK: ror w1, w2, w3
0x41 0x2c 0xc3 0x9a
# CHECK: ror x1, x2, x3
#==---------------------------------------------------------------------------==
# One operand instructions
#==---------------------------------------------------------------------------==
0x41 0x14 0xc0 0x5a
# CHECK: cls w1, w2
0x41 0x14 0xc0 0xda
# CHECK: cls x1, x2
0x41 0x10 0xc0 0x5a
# CHECK: clz w1, w2
0x41 0x10 0xc0 0xda
# CHECK: clz x1, x2
0x41 0x00 0xc0 0x5a
# CHECK: rbit w1, w2
0x41 0x00 0xc0 0xda
# CHECK: rbit x1, x2
0x41 0x08 0xc0 0x5a
# CHECK: rev w1, w2
0x41 0x0c 0xc0 0xda
# CHECK: rev x1, x2
0x41 0x04 0xc0 0x5a
# CHECK: rev16 w1, w2
0x41 0x04 0xc0 0xda
# CHECK: rev16 x1, x2
0x41 0x08 0xc0 0xda
# CHECK: rev32 x1, x2
#==---------------------------------------------------------------------------==
# 6.6.1 Multiply-add instructions
#==---------------------------------------------------------------------------==
0x41 0x10 0x03 0x1b
0x41 0x10 0x03 0x9b
0x41 0x90 0x03 0x1b
0x41 0x90 0x03 0x9b
0x41 0x10 0x23 0x9b
0x41 0x90 0x23 0x9b
0x41 0x10 0xa3 0x9b
0x41 0x90 0xa3 0x9b
# CHECK: madd w1, w2, w3, w4
# CHECK: madd x1, x2, x3, x4
# CHECK: msub w1, w2, w3, w4
# CHECK: msub x1, x2, x3, x4
# CHECK: smaddl x1, w2, w3, x4
# CHECK: smsubl x1, w2, w3, x4
# CHECK: umaddl x1, w2, w3, x4
# CHECK: umsubl x1, w2, w3, x4
#==---------------------------------------------------------------------------==
# Multiply-high instructions
#==---------------------------------------------------------------------------==
0x41 0x7c 0x43 0x9b
0x41 0x7c 0xc3 0x9b
# CHECK: smulh x1, x2, x3
# CHECK: umulh x1, x2, x3
#==---------------------------------------------------------------------------==
# Move immediate instructions
#==---------------------------------------------------------------------------==
0x20 0x00 0x80 0x52
0x20 0x00 0x80 0xd2
0x20 0x00 0xa0 0x52
0x20 0x00 0xa0 0xd2
# CHECK: mov w0, #1
# CHECK: mov x0, #1
# CHECK: mov w0, #65536
# CHECK: mov x0, #65536
0x40 0x00 0x80 0x12
0x40 0x00 0x80 0x92
0x40 0x00 0xa0 0x12
0x40 0x00 0xa0 0x92
# CHECK: mov w0, #-3
# CHECK: mov x0, #-3
# CHECK: mov w0, #-131073
# CHECK: mov x0, #-131073
0x20 0x00 0x80 0x72
0x20 0x00 0x80 0xf2
0x20 0x00 0xa0 0x72
0x20 0x00 0xa0 0xf2
# CHECK: movk w0, #1
# CHECK: movk x0, #1
# CHECK: movk w0, #1, lsl #16
# CHECK: movk x0, #1, lsl #16
#==---------------------------------------------------------------------------==
# Conditionally set flags instructions
#==---------------------------------------------------------------------------==
0x1f 0x00 0x00 0x31
# CHECK: cmn w0, #0
0x1f 0xfc 0x03 0xb1
# CHECK: x0, #255
0x23 0x08 0x42 0x3a
# CHECK: ccmn w1, #2, #3, eq
0x23 0x08 0x42 0xba
# CHECK: ccmn x1, #2, #3, eq
0x23 0x08 0x42 0x7a
# CHECK: ccmp w1, #2, #3, eq
0x23 0x08 0x42 0xfa
# CHECK: ccmp x1, #2, #3, eq
0x23 0x00 0x42 0x3a
# CHECK: ccmn w1, w2, #3, eq
0x23 0x00 0x42 0xba
# CHECK: ccmn x1, x2, #3, eq
0x23 0x00 0x42 0x7a
# CHECK: ccmp w1, w2, #3, eq
0x23 0x00 0x42 0xfa
# CHECK: ccmp x1, x2, #3, eq
#==---------------------------------------------------------------------------==
# Conditional select instructions
#==---------------------------------------------------------------------------==
0x41 0x00 0x83 0x1a
# CHECK: csel w1, w2, w3, eq
0x41 0x00 0x83 0x9a
# CHECK: csel x1, x2, x3, eq
0x41 0x04 0x83 0x1a
# CHECK: csinc w1, w2, w3, eq
0x41 0x04 0x83 0x9a
# CHECK: csinc x1, x2, x3, eq
0x41 0x00 0x83 0x5a
# CHECK: csinv w1, w2, w3, eq
0x41 0x00 0x83 0xda
# CHECK: csinv x1, x2, x3, eq
0x41 0x04 0x83 0x5a
# CHECK: csneg w1, w2, w3, eq
0x41 0x04 0x83 0xda
# CHECK: csneg x1, x2, x3, eq