aboutsummaryrefslogtreecommitdiff
path: root/opcodes/aarch64-asm-2.c
blob: bbe6edaa4c634721b2fee11c08ac5259e95a8ecf (plain)
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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
/* This file is automatically generated by aarch64-gen.  Do not edit!  */
/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
   Contributed by ARM Ltd.

   This file is part of the GNU opcodes library.

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   It is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING3. If not,
   see <http://www.gnu.org/licenses/>.  */

#include "sysdep.h"
#include "aarch64-asm.h"


const aarch64_opcode *
aarch64_find_real_opcode (const aarch64_opcode *opcode)
{
  /* Use the index as the key to locate the real opcode.  */
  int key = opcode - aarch64_opcode_table;
  int value;
  switch (key)
    {
    case 3:	/* ngc */
    case 2:	/* sbc */
      value = 2;	/* --> sbc.  */
      break;
    case 5:	/* ngcs */
    case 4:	/* sbcs */
      value = 4;	/* --> sbcs.  */
      break;
    case 8:	/* cmn */
    case 7:	/* adds */
      value = 7;	/* --> adds.  */
      break;
    case 11:	/* cmp */
    case 10:	/* subs */
      value = 10;	/* --> subs.  */
      break;
    case 13:	/* mov */
    case 12:	/* add */
      value = 12;	/* --> add.  */
      break;
    case 15:	/* cmn */
    case 14:	/* adds */
      value = 14;	/* --> adds.  */
      break;
    case 18:	/* cmp */
    case 17:	/* subs */
      value = 17;	/* --> subs.  */
      break;
    case 21:	/* cmn */
    case 20:	/* adds */
      value = 20;	/* --> adds.  */
      break;
    case 23:	/* neg */
    case 22:	/* sub */
      value = 22;	/* --> sub.  */
      break;
    case 26:	/* negs */
    case 25:	/* cmp */
    case 24:	/* subs */
      value = 24;	/* --> subs.  */
      break;
    case 141:	/* mov */
    case 140:	/* umov */
      value = 140;	/* --> umov.  */
      break;
    case 143:	/* mov */
    case 142:	/* ins */
      value = 142;	/* --> ins.  */
      break;
    case 145:	/* mov */
    case 144:	/* ins */
      value = 144;	/* --> ins.  */
      break;
    case 227:	/* mvn */
    case 226:	/* not */
      value = 226;	/* --> not.  */
      break;
    case 302:	/* mov */
    case 301:	/* orr */
      value = 301;	/* --> orr.  */
      break;
    case 371:	/* sxtl */
    case 370:	/* sshll */
      value = 370;	/* --> sshll.  */
      break;
    case 373:	/* sxtl2 */
    case 372:	/* sshll2 */
      value = 372;	/* --> sshll2.  */
      break;
    case 393:	/* uxtl */
    case 392:	/* ushll */
      value = 392;	/* --> ushll.  */
      break;
    case 395:	/* uxtl2 */
    case 394:	/* ushll2 */
      value = 394;	/* --> ushll2.  */
      break;
    case 510:	/* mov */
    case 509:	/* dup */
      value = 509;	/* --> dup.  */
      break;
    case 588:	/* sxtw */
    case 587:	/* sxth */
    case 586:	/* sxtb */
    case 589:	/* asr */
    case 585:	/* sbfx */
    case 584:	/* sbfiz */
    case 583:	/* sbfm */
      value = 583;	/* --> sbfm.  */
      break;
    case 592:	/* bfc */
    case 593:	/* bfxil */
    case 591:	/* bfi */
    case 590:	/* bfm */
      value = 590;	/* --> bfm.  */
      break;
    case 598:	/* uxth */
    case 597:	/* uxtb */
    case 600:	/* lsr */
    case 599:	/* lsl */
    case 596:	/* ubfx */
    case 595:	/* ubfiz */
    case 594:	/* ubfm */
      value = 594;	/* --> ubfm.  */
      break;
    case 618:	/* cset */
    case 617:	/* cinc */
    case 616:	/* csinc */
      value = 616;	/* --> csinc.  */
      break;
    case 621:	/* csetm */
    case 620:	/* cinv */
    case 619:	/* csinv */
      value = 619;	/* --> csinv.  */
      break;
    case 623:	/* cneg */
    case 622:	/* csneg */
      value = 622;	/* --> csneg.  */
      break;
    case 641:	/* rev */
    case 642:	/* rev64 */
      value = 641;	/* --> rev.  */
      break;
    case 649:	/* lsl */
    case 648:	/* lslv */
      value = 648;	/* --> lslv.  */
      break;
    case 651:	/* lsr */
    case 650:	/* lsrv */
      value = 650;	/* --> lsrv.  */
      break;
    case 653:	/* asr */
    case 652:	/* asrv */
      value = 652;	/* --> asrv.  */
      break;
    case 655:	/* ror */
    case 654:	/* rorv */
      value = 654;	/* --> rorv.  */
      break;
    case 665:	/* mul */
    case 664:	/* madd */
      value = 664;	/* --> madd.  */
      break;
    case 667:	/* mneg */
    case 666:	/* msub */
      value = 666;	/* --> msub.  */
      break;
    case 669:	/* smull */
    case 668:	/* smaddl */
      value = 668;	/* --> smaddl.  */
      break;
    case 671:	/* smnegl */
    case 670:	/* smsubl */
      value = 670;	/* --> smsubl.  */
      break;
    case 674:	/* umull */
    case 673:	/* umaddl */
      value = 673;	/* --> umaddl.  */
      break;
    case 676:	/* umnegl */
    case 675:	/* umsubl */
      value = 675;	/* --> umsubl.  */
      break;
    case 687:	/* ror */
    case 686:	/* extr */
      value = 686;	/* --> extr.  */
      break;
    case 894:	/* bic */
    case 893:	/* and */
      value = 893;	/* --> and.  */
      break;
    case 896:	/* mov */
    case 895:	/* orr */
      value = 895;	/* --> orr.  */
      break;
    case 899:	/* tst */
    case 898:	/* ands */
      value = 898;	/* --> ands.  */
      break;
    case 904:	/* uxtw */
    case 903:	/* mov */
    case 902:	/* orr */
      value = 902;	/* --> orr.  */
      break;
    case 906:	/* mvn */
    case 905:	/* orn */
      value = 905;	/* --> orn.  */
      break;
    case 910:	/* tst */
    case 909:	/* ands */
      value = 909;	/* --> ands.  */
      break;
    case 1036:	/* staddb */
    case 940:	/* ldaddb */
      value = 940;	/* --> ldaddb.  */
      break;
    case 1037:	/* staddh */
    case 941:	/* ldaddh */
      value = 941;	/* --> ldaddh.  */
      break;
    case 1038:	/* stadd */
    case 942:	/* ldadd */
      value = 942;	/* --> ldadd.  */
      break;
    case 1039:	/* staddlb */
    case 944:	/* ldaddlb */
      value = 944;	/* --> ldaddlb.  */
      break;
    case 1040:	/* staddlh */
    case 947:	/* ldaddlh */
      value = 947;	/* --> ldaddlh.  */
      break;
    case 1041:	/* staddl */
    case 950:	/* ldaddl */
      value = 950;	/* --> ldaddl.  */
      break;
    case 1042:	/* stclrb */
    case 952:	/* ldclrb */
      value = 952;	/* --> ldclrb.  */
      break;
    case 1043:	/* stclrh */
    case 953:	/* ldclrh */
      value = 953;	/* --> ldclrh.  */
      break;
    case 1044:	/* stclr */
    case 954:	/* ldclr */
      value = 954;	/* --> ldclr.  */
      break;
    case 1045:	/* stclrlb */
    case 956:	/* ldclrlb */
      value = 956;	/* --> ldclrlb.  */
      break;
    case 1046:	/* stclrlh */
    case 959:	/* ldclrlh */
      value = 959;	/* --> ldclrlh.  */
      break;
    case 1047:	/* stclrl */
    case 962:	/* ldclrl */
      value = 962;	/* --> ldclrl.  */
      break;
    case 1048:	/* steorb */
    case 964:	/* ldeorb */
      value = 964;	/* --> ldeorb.  */
      break;
    case 1049:	/* steorh */
    case 965:	/* ldeorh */
      value = 965;	/* --> ldeorh.  */
      break;
    case 1050:	/* steor */
    case 966:	/* ldeor */
      value = 966;	/* --> ldeor.  */
      break;
    case 1051:	/* steorlb */
    case 968:	/* ldeorlb */
      value = 968;	/* --> ldeorlb.  */
      break;
    case 1052:	/* steorlh */
    case 971:	/* ldeorlh */
      value = 971;	/* --> ldeorlh.  */
      break;
    case 1053:	/* steorl */
    case 974:	/* ldeorl */
      value = 974;	/* --> ldeorl.  */
      break;
    case 1054:	/* stsetb */
    case 976:	/* ldsetb */
      value = 976;	/* --> ldsetb.  */
      break;
    case 1055:	/* stseth */
    case 977:	/* ldseth */
      value = 977;	/* --> ldseth.  */
      break;
    case 1056:	/* stset */
    case 978:	/* ldset */
      value = 978;	/* --> ldset.  */
      break;
    case 1057:	/* stsetlb */
    case 980:	/* ldsetlb */
      value = 980;	/* --> ldsetlb.  */
      break;
    case 1058:	/* stsetlh */
    case 983:	/* ldsetlh */
      value = 983;	/* --> ldsetlh.  */
      break;
    case 1059:	/* stsetl */
    case 986:	/* ldsetl */
      value = 986;	/* --> ldsetl.  */
      break;
    case 1060:	/* stsmaxb */
    case 988:	/* ldsmaxb */
      value = 988;	/* --> ldsmaxb.  */
      break;
    case 1061:	/* stsmaxh */
    case 989:	/* ldsmaxh */
      value = 989;	/* --> ldsmaxh.  */
      break;
    case 1062:	/* stsmax */
    case 990:	/* ldsmax */
      value = 990;	/* --> ldsmax.  */
      break;
    case 1063:	/* stsmaxlb */
    case 992:	/* ldsmaxlb */
      value = 992;	/* --> ldsmaxlb.  */
      break;
    case 1064:	/* stsmaxlh */
    case 995:	/* ldsmaxlh */
      value = 995;	/* --> ldsmaxlh.  */
      break;
    case 1065:	/* stsmaxl */
    case 998:	/* ldsmaxl */
      value = 998;	/* --> ldsmaxl.  */
      break;
    case 1066:	/* stsminb */
    case 1000:	/* ldsminb */
      value = 1000;	/* --> ldsminb.  */
      break;
    case 1067:	/* stsminh */
    case 1001:	/* ldsminh */
      value = 1001;	/* --> ldsminh.  */
      break;
    case 1068:	/* stsmin */
    case 1002:	/* ldsmin */
      value = 1002;	/* --> ldsmin.  */
      break;
    case 1069:	/* stsminlb */
    case 1004:	/* ldsminlb */
      value = 1004;	/* --> ldsminlb.  */
      break;
    case 1070:	/* stsminlh */
    case 1007:	/* ldsminlh */
      value = 1007;	/* --> ldsminlh.  */
      break;
    case 1071:	/* stsminl */
    case 1010:	/* ldsminl */
      value = 1010;	/* --> ldsminl.  */
      break;
    case 1072:	/* stumaxb */
    case 1012:	/* ldumaxb */
      value = 1012;	/* --> ldumaxb.  */
      break;
    case 1073:	/* stumaxh */
    case 1013:	/* ldumaxh */
      value = 1013;	/* --> ldumaxh.  */
      break;
    case 1074:	/* stumax */
    case 1014:	/* ldumax */
      value = 1014;	/* --> ldumax.  */
      break;
    case 1075:	/* stumaxlb */
    case 1016:	/* ldumaxlb */
      value = 1016;	/* --> ldumaxlb.  */
      break;
    case 1076:	/* stumaxlh */
    case 1019:	/* ldumaxlh */
      value = 1019;	/* --> ldumaxlh.  */
      break;
    case 1077:	/* stumaxl */
    case 1022:	/* ldumaxl */
      value = 1022;	/* --> ldumaxl.  */
      break;
    case 1078:	/* stuminb */
    case 1024:	/* lduminb */
      value = 1024;	/* --> lduminb.  */
      break;
    case 1079:	/* stuminh */
    case 1025:	/* lduminh */
      value = 1025;	/* --> lduminh.  */
      break;
    case 1080:	/* stumin */
    case 1026:	/* ldumin */
      value = 1026;	/* --> ldumin.  */
      break;
    case 1081:	/* stuminlb */
    case 1028:	/* lduminlb */
      value = 1028;	/* --> lduminlb.  */
      break;
    case 1082:	/* stuminlh */
    case 1031:	/* lduminlh */
      value = 1031;	/* --> lduminlh.  */
      break;
    case 1083:	/* stuminl */
    case 1034:	/* lduminl */
      value = 1034;	/* --> lduminl.  */
      break;
    case 1085:	/* mov */
    case 1084:	/* movn */
      value = 1084;	/* --> movn.  */
      break;
    case 1087:	/* mov */
    case 1086:	/* movz */
      value = 1086;	/* --> movz.  */
      break;
    case 1100:	/* psb */
    case 1099:	/* esb */
    case 1098:	/* sevl */
    case 1097:	/* sev */
    case 1096:	/* wfi */
    case 1095:	/* wfe */
    case 1094:	/* yield */
    case 1093:	/* nop */
    case 1092:	/* hint */
      value = 1092;	/* --> hint.  */
      break;
    case 1109:	/* tlbi */
    case 1108:	/* ic */
    case 1107:	/* dc */
    case 1106:	/* at */
    case 1105:	/* sys */
      value = 1105;	/* --> sys.  */
      break;
    default: return NULL;
    }

  return aarch64_opcode_table + value;
}

const char*
aarch64_insert_operand (const aarch64_operand *self,
			   const aarch64_opnd_info *info,
			   aarch64_insn *code, const aarch64_inst *inst)
{
  /* Use the index as the key.  */
  int key = self - aarch64_operands;
  switch (key)
    {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
    case 14:
    case 15:
    case 16:
    case 17:
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 24:
    case 25:
    case 26:
    case 27:
    case 35:
    case 36:
      return aarch64_ins_regno (self, info, code, inst);
    case 12:
      return aarch64_ins_reg_extended (self, info, code, inst);
    case 13:
      return aarch64_ins_reg_shifted (self, info, code, inst);
    case 18:
      return aarch64_ins_ft (self, info, code, inst);
    case 28:
    case 29:
    case 30:
      return aarch64_ins_reglane (self, info, code, inst);
    case 31:
      return aarch64_ins_reglist (self, info, code, inst);
    case 32:
      return aarch64_ins_ldst_reglist (self, info, code, inst);
    case 33:
      return aarch64_ins_ldst_reglist_r (self, info, code, inst);
    case 34:
      return aarch64_ins_ldst_elemlist (self, info, code, inst);
    case 37:
    case 46:
    case 47:
    case 48:
    case 49:
    case 50:
    case 51:
    case 52:
    case 53:
    case 54:
    case 55:
    case 56:
    case 57:
    case 58:
    case 67:
    case 68:
    case 69:
    case 70:
      return aarch64_ins_imm (self, info, code, inst);
    case 38:
    case 39:
      return aarch64_ins_advsimd_imm_shift (self, info, code, inst);
    case 40:
    case 41:
    case 42:
      return aarch64_ins_advsimd_imm_modified (self, info, code, inst);
    case 59:
      return aarch64_ins_limm (self, info, code, inst);
    case 60:
      return aarch64_ins_aimm (self, info, code, inst);
    case 61:
      return aarch64_ins_imm_half (self, info, code, inst);
    case 62:
      return aarch64_ins_fbits (self, info, code, inst);
    case 64:
    case 65:
      return aarch64_ins_cond (self, info, code, inst);
    case 71:
    case 77:
      return aarch64_ins_addr_simple (self, info, code, inst);
    case 72:
      return aarch64_ins_addr_regoff (self, info, code, inst);
    case 73:
    case 74:
    case 75:
      return aarch64_ins_addr_simm (self, info, code, inst);
    case 76:
      return aarch64_ins_addr_uimm12 (self, info, code, inst);
    case 78:
      return aarch64_ins_simd_addr_post (self, info, code, inst);
    case 79:
      return aarch64_ins_sysreg (self, info, code, inst);
    case 80:
      return aarch64_ins_pstatefield (self, info, code, inst);
    case 81:
    case 82:
    case 83:
    case 84:
      return aarch64_ins_sysins_op (self, info, code, inst);
    case 85:
    case 86:
      return aarch64_ins_barrier (self, info, code, inst);
    case 87:
      return aarch64_ins_prfop (self, info, code, inst);
    case 88:
      return aarch64_ins_hint (self, info, code, inst);
    default: assert (0); abort ();
    }
}