summaryrefslogtreecommitdiff
path: root/gcc/config/arm/cortex-a53.md
blob: c1eeedb72dde271cf03817c525e9e0eaa943c4f6 (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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
;; ARM Cortex-A53 pipeline description
;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
;;
;; Contributed by ARM Ltd.
;;
;; This file is part of GCC.
;;
;; GCC 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.
;;
;; GCC 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 GCC; see the file COPYING3.  If not see
;; <http://www.gnu.org/licenses/>.

(define_automaton "cortex_a53")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General-purpose functional units.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; We use slot0 and slot1 to model constraints on which instructions may
;; dual-issue.

(define_cpu_unit "cortex_a53_slot0" "cortex_a53")
(define_cpu_unit "cortex_a53_slot1" "cortex_a53")

(define_reservation "cortex_a53_slot_any"
		    "cortex_a53_slot0\
		     |cortex_a53_slot1")

(define_reservation "cortex_a53_single_issue"
		    "cortex_a53_slot0\
		     +cortex_a53_slot1")

;; Used to model load and store pipelines.  Load/store instructions
;; can dual-issue with other instructions, but two load/stores cannot
;; simultaneously issue.

(define_cpu_unit "cortex_a53_store" "cortex_a53")
(define_cpu_unit "cortex_a53_load" "cortex_a53")
(define_cpu_unit "cortex_a53_ls_agen" "cortex_a53")

;; Used to model a branch pipeline.  Branches can dual-issue with other
;; instructions (except when those instructions take multiple cycles
;; to issue).

(define_cpu_unit "cortex_a53_branch" "cortex_a53")

;; Used to model an integer divide pipeline.

(define_cpu_unit "cortex_a53_idiv" "cortex_a53")

;; Used to model an integer multiply/multiply-accumulate pipeline.

(define_cpu_unit "cortex_a53_imul" "cortex_a53")

;; Model general structural hazards, for wherever we need them.

(define_cpu_unit "cortex_a53_hazard" "cortex_a53")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ALU instructions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_insn_reservation "cortex_a53_shift" 2
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "adr,shift_imm,shift_reg,mov_imm,mvn_imm"))
  "cortex_a53_slot_any")

(define_insn_reservation "cortex_a53_alu_rotate_imm" 2
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "rotate_imm"))
  "(cortex_a53_slot1)
   | (cortex_a53_single_issue)")

(define_insn_reservation "cortex_a53_alu" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "alu_imm,alus_imm,logic_imm,logics_imm,
			alu_sreg,alus_sreg,logic_reg,logics_reg,
			adc_imm,adcs_imm,adc_reg,adcs_reg,
			bfm,csel,clz,rbit,rev,alu_dsp_reg,
			mov_reg,mvn_reg,
			mrs,multiple,no_insn"))
  "cortex_a53_slot_any")

(define_insn_reservation "cortex_a53_alu_shift" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "alu_shift_imm,alus_shift_imm,
			crc,logic_shift_imm,logics_shift_imm,
			alu_ext,alus_ext,
			extend,mov_shift,mvn_shift"))
  "cortex_a53_slot_any")

(define_insn_reservation "cortex_a53_alu_shift_reg" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "alu_shift_reg,alus_shift_reg,
			logic_shift_reg,logics_shift_reg,
			mov_shift_reg,mvn_shift_reg"))
  "cortex_a53_slot_any+cortex_a53_hazard")

(define_insn_reservation "cortex_a53_mul" 3
  (and (eq_attr "tune" "cortexa53")
       (ior (eq_attr "mul32" "yes")
	    (eq_attr "mul64" "yes")))
  "cortex_a53_slot_any+cortex_a53_imul")

;; From the perspective of the GCC scheduling state machine, if we wish to
;; model an instruction as serialising other instructions, we are best to do
;; so by modelling it as taking very few cycles.  Scheduling many other
;; instructions underneath it at the cost of freedom to pick from the
;; ready list is likely to hurt us more than it helps.  However, we do
;; want to model some resource and latency cost for divide instructions in
;; order to avoid divides ending up too lumpy.

(define_insn_reservation "cortex_a53_div" 4
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "udiv,sdiv"))
  "cortex_a53_slot0,cortex_a53_idiv*2")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load/store instructions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; TODO: load<n> is not prescriptive about how much data is to be loaded.
;; This is most obvious for LDRD from AArch32 and LDP (X register) from
;; AArch64, both are tagged load2 but LDP will load 128-bits compared to
;; LDRD which is 64-bits.
;;
;; For the below, we assume AArch64 X-registers for load2, and AArch32
;; registers for load3/load4.

(define_insn_reservation "cortex_a53_load1" 4
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "load_byte,load1,load_acq"))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_load")

(define_insn_reservation "cortex_a53_store1" 2
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "store1,store_rel"))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_store")

;; Model AArch64-sized LDP Xm, Xn, [Xa]

(define_insn_reservation "cortex_a53_load2" 4
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "load2"))
  "cortex_a53_single_issue+cortex_a53_ls_agen,
   cortex_a53_load+cortex_a53_slot0,
   cortex_a53_load")

(define_insn_reservation "cortex_a53_store2" 2
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "store2"))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_store")

;; Model AArch32-sized LDM Ra, {Rm, Rn, Ro}

(define_insn_reservation "cortex_a53_load3plus" 6
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "load3,load4"))
  "cortex_a53_single_issue+cortex_a53_ls_agen,
   cortex_a53_load+cortex_a53_slot0,
   cortex_a53_load")

(define_insn_reservation "cortex_a53_store3plus" 2
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "store3,store4"))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_store+cortex_a53_slot0,
   cortex_a53_store")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Branches.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Model all branches as dual-issuable from either execution, which
;; is not strictly true for all cases (indirect branches).

(define_insn_reservation "cortex_a53_branch" 0
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "branch,call"))
  "cortex_a53_slot_any,cortex_a53_branch")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General-purpose register bypasses
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Model bypasses for unshifted operands to ALU instructions.

(define_bypass 1 "cortex_a53_shift"
		 "cortex_a53_shift")

(define_bypass 1 "cortex_a53_alu,
		  cortex_a53_alu_shift*,
		  cortex_a53_alu_rotate_imm,
		  cortex_a53_shift"
		 "cortex_a53_alu")

(define_bypass 2 "cortex_a53_alu,
		  cortex_a53_alu_shift*"
		 "cortex_a53_alu_shift*"
		 "aarch_forward_to_shift_is_not_shifted_reg")

;; In our model, we allow any general-purpose register operation to
;; bypass to the accumulator operand of an integer MADD-like operation.

(define_bypass 1 "cortex_a53_alu*,
		  cortex_a53_load*,
		  cortex_a53_mul"
		 "cortex_a53_mul"
		 "aarch_accumulator_forwarding")

;; Model a bypass from MLA/MUL to many ALU instructions.

(define_bypass 2 "cortex_a53_mul"
		 "cortex_a53_alu,
		  cortex_a53_alu_shift*")

;; We get neater schedules by allowing an MLA/MUL to feed an
;; early load address dependency to a load.

(define_bypass 2 "cortex_a53_mul"
		 "cortex_a53_load*"
		 "arm_early_load_addr_dep")

;; Model bypasses for loads which are to be consumed by the ALU.

(define_bypass 2 "cortex_a53_load1"
		 "cortex_a53_alu")

(define_bypass 3 "cortex_a53_load1"
		 "cortex_a53_alu_shift*")

;; Model a bypass for ALU instructions feeding stores.

(define_bypass 1 "cortex_a53_alu*"
		 "cortex_a53_store1,
		  cortex_a53_store2,
		  cortex_a53_store3plus"
		 "arm_no_early_store_addr_dep")

;; Model a bypass for load and multiply instructions feeding stores.

(define_bypass 2 "cortex_a53_mul,
		  cortex_a53_load1,
		  cortex_a53_load2,
		  cortex_a53_load3plus"
		 "cortex_a53_store1,
		  cortex_a53_store2,
		  cortex_a53_store3plus"
		 "arm_no_early_store_addr_dep")

;; Model a GP->FP register move as similar to stores.

(define_bypass 1 "cortex_a53_alu*"
		 "cortex_a53_r2f")

(define_bypass 2 "cortex_a53_mul,
		  cortex_a53_load1,
		  cortex_a53_load2,
		  cortex_a53_load3plus"
		 "cortex_a53_r2f")

;; Shifts feeding Load/Store addresses may not be ready in time.

(define_bypass 3 "cortex_a53_shift"
		 "cortex_a53_load*"
		 "arm_early_load_addr_dep")

(define_bypass 3 "cortex_a53_shift"
		 "cortex_a53_store*"
		 "arm_early_store_addr_dep")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point/Advanced SIMD.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_automaton "cortex_a53_advsimd")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Broad Advanced SIMD type categorisation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_attr "cortex_a53_advsimd_type"
  "advsimd_alu, advsimd_alu_q,
   advsimd_mul, advsimd_mul_q,
   advsimd_div_s, advsimd_div_s_q,
   advsimd_div_d, advsimd_div_d_q,
   advsimd_load_64, advsimd_store_64,
   advsimd_load_128, advsimd_store_128,
   advsimd_load_lots, advsimd_store_lots,
   unknown"
  (cond [
    (eq_attr "type" "neon_add, neon_qadd, neon_add_halve, neon_sub, neon_qsub,\
		     neon_sub_halve, neon_abs, neon_neg, neon_qneg,\
		     neon_qabs, neon_abd, neon_minmax, neon_compare,\
		     neon_compare_zero, neon_arith_acc, neon_reduc_add,\
		     neon_reduc_add_acc, neon_reduc_minmax,\
		     neon_logic, neon_tst, neon_shift_imm,\
		     neon_shift_reg, neon_shift_acc, neon_sat_shift_imm,\
		     neon_sat_shift_reg, neon_ins, neon_move,\
		     neon_permute, neon_zip, neon_tbl1,\
		     neon_tbl2, neon_tbl3, neon_tbl4, neon_bsl,\
		     neon_cls, neon_cnt, neon_dup,\
		     neon_ext, neon_rbit, neon_rev,\
		     neon_fp_abd_s, neon_fp_abd_d,\
		     neon_fp_abs_s, neon_fp_abs_d,\
		     neon_fp_addsub_s, neon_fp_addsub_d, neon_fp_compare_s,\
		     neon_fp_compare_d, neon_fp_minmax_s,\
		     neon_fp_minmax_d, neon_fp_neg_s, neon_fp_neg_d,\
		     neon_fp_reduc_add_s, neon_fp_reduc_add_d,\
		     neon_fp_reduc_minmax_s, neon_fp_reduc_minmax_d,\
		     neon_fp_cvt_widen_h, neon_fp_to_int_s,neon_fp_to_int_d,\
		     neon_int_to_fp_s, neon_int_to_fp_d, neon_fp_round_s,\
		     neon_fp_recpe_s, neon_fp_recpe_d, neon_fp_recps_s,\
		     neon_fp_recps_d, neon_fp_recpx_s, neon_fp_recpx_d,\
		     neon_fp_rsqrte_s, neon_fp_rsqrte_d, neon_fp_rsqrts_s,\
		     neon_fp_rsqrts_d")
      (const_string "advsimd_alu")
    (eq_attr "type" "neon_add_q, neon_add_widen, neon_add_long,\
		     neon_qadd_q, neon_add_halve_q, neon_add_halve_narrow_q,\
		     neon_sub_q, neon_sub_widen, neon_sub_long,\
		     neon_qsub_q, neon_sub_halve_q, neon_sub_halve_narrow_q,\
		     neon_abs_q, neon_neg_q, neon_qneg_q, neon_qabs_q,\
		     neon_abd_q, neon_abd_long, neon_minmax_q,\
		     neon_compare_q, neon_compare_zero_q,\
		     neon_arith_acc_q, neon_reduc_add_q,\
		     neon_reduc_add_long, neon_reduc_add_acc_q,\
		     neon_reduc_minmax_q, neon_logic_q, neon_tst_q,\
		     neon_shift_imm_q, neon_shift_imm_narrow_q,\
		     neon_shift_imm_long, neon_shift_reg_q,\
		     neon_shift_acc_q, neon_sat_shift_imm_q,\
		     neon_sat_shift_imm_narrow_q, neon_sat_shift_reg_q,\
		     neon_ins_q, neon_move_q, neon_move_narrow_q,\
		     neon_permute_q, neon_zip_q,\
		     neon_tbl1_q, neon_tbl2_q, neon_tbl3_q,\
		     neon_tbl4_q, neon_bsl_q, neon_cls_q, neon_cnt_q,\
		     neon_dup_q, neon_ext_q, neon_rbit_q,\
		     neon_rev_q, neon_fp_abd_s_q, neon_fp_abd_d_q,\
		     neon_fp_abs_s_q, neon_fp_abs_d_q,\
		     neon_fp_addsub_s_q, neon_fp_addsub_d_q,\
		     neon_fp_compare_s_q, neon_fp_compare_d_q,\
		     neon_fp_minmax_s_q, neon_fp_minmax_d_q,\
		     neon_fp_cvt_widen_s, neon_fp_neg_s_q, neon_fp_neg_d_q,\
		     neon_fp_reduc_add_s_q, neon_fp_reduc_add_d_q,\
		     neon_fp_reduc_minmax_s_q, neon_fp_reduc_minmax_d_q,\
		     neon_fp_cvt_narrow_s_q, neon_fp_cvt_narrow_d_q,\
		     neon_fp_to_int_s_q, neon_fp_to_int_d_q,\
		     neon_int_to_fp_s_q, neon_int_to_fp_d_q,\
		     neon_fp_round_s_q,\
		     neon_fp_recpe_s_q, neon_fp_recpe_d_q,\
		     neon_fp_recps_s_q, neon_fp_recps_d_q,\
		     neon_fp_recpx_s_q, neon_fp_recpx_d_q,\
		     neon_fp_rsqrte_s_q, neon_fp_rsqrte_d_q,\
		     neon_fp_rsqrts_s_q, neon_fp_rsqrts_d_q")
      (const_string "advsimd_alu_q")
    (eq_attr "type" "neon_mul_b, neon_mul_h, neon_mul_s,\
		     neon_mul_h_scalar, neon_mul_s_scalar,\
		     neon_sat_mul_b, neon_sat_mul_h, neon_sat_mul_s,\
		     neon_sat_mul_h_scalar, neon_sat_mul_s_scalar,\
		     neon_mla_b, neon_mla_h, neon_mla_s,\
		     neon_mla_h_scalar, neon_mla_s_scalar,\
		     neon_fp_mul_s, neon_fp_mul_s_scalar,\
		     neon_fp_mul_d, neon_fp_mla_s,\
		     neon_fp_mla_s_scalar, neon_fp_mla_d")
      (const_string "advsimd_mul")
    (eq_attr "type" "neon_mul_b_q, neon_mul_h_q, neon_mul_s_q,\
		     neon_mul_b_long, neon_mul_h_long, neon_mul_s_long,\
		     neon_mul_d_long, neon_mul_h_scalar_q,\
		     neon_mul_s_scalar_q, neon_mul_h_scalar_long,\
		     neon_mul_s_scalar_long, neon_sat_mul_b_q,\
		     neon_sat_mul_h_q, neon_sat_mul_s_q,\
		     neon_sat_mul_b_long, neon_sat_mul_h_long,\
		     neon_sat_mul_s_long, neon_sat_mul_h_scalar_q,\
		     neon_sat_mul_s_scalar_q, neon_sat_mul_h_scalar_long,\
		     neon_sat_mul_s_scalar_long, neon_mla_b_q,\
		     neon_mla_h_q, neon_mla_s_q, neon_mla_b_long,\
		     neon_mla_h_long, neon_mla_s_long,\
		     neon_mla_h_scalar_q, neon_mla_s_scalar_q,\
		     neon_mla_h_scalar_long, neon_mla_s_scalar_long,\
		     neon_sat_mla_b_long, neon_sat_mla_h_long,\
		     neon_sat_mla_s_long, neon_sat_mla_h_scalar_long,\
		     neon_sat_mla_s_scalar_long,\
		     neon_fp_mul_s_q, neon_fp_mul_s_scalar_q,\
		     neon_fp_mul_d_q, neon_fp_mul_d_scalar_q,\
		     neon_fp_mla_s_q, neon_fp_mla_s_scalar_q,\
		     neon_fp_mla_d_q, neon_fp_mla_d_scalar_q")
      (const_string "advsimd_mul_q")
    (eq_attr "type" "neon_fp_sqrt_s, neon_fp_div_s")
      (const_string "advsimd_div_s")
    (eq_attr "type" "neon_fp_sqrt_s_q, neon_fp_div_s_q")
      (const_string "advsimd_div_s_q")
    (eq_attr "type" "neon_fp_sqrt_d, neon_fp_div_d")
      (const_string "advsimd_div_d")
    (eq_attr "type" "neon_fp_sqrt_d_q, neon_fp_div_d_q")
      (const_string "advsimd_div_d_q")
    (eq_attr "type" "neon_ldr, neon_load1_1reg,\
		     neon_load1_all_lanes, neon_load1_all_lanes_q,\
		     neon_load1_one_lane, neon_load1_one_lane_q")
      (const_string "advsimd_load_64")
    (eq_attr "type" "neon_str, neon_store1_1reg,\
		     neon_store1_one_lane,neon_store1_one_lane_q")
      (const_string "advsimd_store_64")
    (eq_attr "type" "neon_load1_1reg_q, neon_load1_2reg,\
		     neon_load2_2reg,\
		     neon_load2_all_lanes, neon_load2_all_lanes_q,\
		     neon_load2_one_lane, neon_load2_one_lane_q")
      (const_string "advsimd_load_128")
    (eq_attr "type" "neon_store1_1reg_q, neon_store1_2reg,\
		     neon_store2_2reg,\
		     neon_store2_one_lane, neon_store2_one_lane_q")
      (const_string "advsimd_store_128")
    (eq_attr "type" "neon_load1_2reg_q, neon_load1_3reg, neon_load1_3reg_q,\
		     neon_load1_4reg, neon_load1_4reg_q, \
		     neon_load2_2reg_q, neon_load2_4reg,\
		     neon_load2_4reg_q, neon_load3_3reg,\
		     neon_load3_3reg_q, neon_load3_all_lanes,\
		     neon_load3_all_lanes_q, neon_load3_one_lane,\
		     neon_load3_one_lane_q, neon_load4_4reg,\
		     neon_load4_4reg_q, neon_load4_all_lanes,\
		     neon_load4_all_lanes_q, neon_load4_one_lane,\
		     neon_load4_one_lane_q, neon_ldp, neon_ldp_q")
      (const_string "advsimd_load_lots")
    (eq_attr "type" "neon_store1_2reg_q, neon_store1_3reg,\
		     neon_store1_3reg_q, neon_store1_4reg,\
		     neon_store1_4reg_q, neon_store2_2reg_q,\
		     neon_store2_4reg, neon_store2_4reg_q,\
		     neon_store3_3reg, neon_store3_3reg_q,\
		     neon_store3_one_lane, neon_store3_one_lane_q,\
		     neon_store4_4reg, neon_store4_4reg_q,\
		     neon_store4_one_lane, neon_store4_one_lane_q,\
		     neon_stp, neon_stp_q")
      (const_string "advsimd_store_lots")]
      (const_string "unknown")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point/Advanced SIMD functional units.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; We model the Advanced SIMD unit as two 64-bit units, each with three
;; pipes, FP_ALU, FP_MUL, FP_DIV.  We also give convenient reservations
;; for 128-bit Advanced SIMD instructions, which use both units.

;; The floating-point/Advanced SIMD ALU pipelines.

(define_cpu_unit "cortex_a53_fp_alu_lo,\
		  cortex_a53_fp_alu_hi"
		 "cortex_a53_advsimd")

(define_reservation "cortex_a53_fp_alu"
		    "cortex_a53_fp_alu_lo\
		     |cortex_a53_fp_alu_hi")

(define_reservation "cortex_a53_fp_alu_q"
		    "cortex_a53_fp_alu_lo\
		     +cortex_a53_fp_alu_hi")

;; The floating-point/Advanced SIMD multiply/multiply-accumulate
;; pipelines.

(define_cpu_unit "cortex_a53_fp_mul_lo,\
		  cortex_a53_fp_mul_hi"
		 "cortex_a53_advsimd")

(define_reservation "cortex_a53_fp_mul"
		    "cortex_a53_fp_mul_lo\
		     |cortex_a53_fp_mul_hi")

(define_reservation "cortex_a53_fp_mul_q"
		    "cortex_a53_fp_mul_lo\
		     +cortex_a53_fp_mul_hi")

;; Floating-point/Advanced SIMD divide/square root.

(define_cpu_unit "cortex_a53_fp_div_lo,\
		  cortex_a53_fp_div_hi"
		 "cortex_a53_advsimd")

;; Once we choose a pipe, stick with it for three simulated cycles.

(define_reservation "cortex_a53_fp_div"
		    "(cortex_a53_fp_div_lo*3)\
		     |(cortex_a53_fp_div_hi*3)")

(define_reservation "cortex_a53_fp_div_q"
		    "(cortex_a53_fp_div_lo*3)\
		     +(cortex_a53_fp_div_hi*3)")

;; Cryptographic extensions

(define_cpu_unit "cortex_a53_crypto"
		 "cortex_a53_advsimd")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point arithmetic.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_insn_reservation "cortex_a53_fpalu" 5
  (and (eq_attr "tune" "cortexa53")
	(eq_attr "type" "ffariths, fadds, ffarithd, faddd, fmov,
			f_cvt, fcmps, fcmpd, fcsel, f_rints, f_rintd,
			f_minmaxs, f_minmaxd"))
  "cortex_a53_slot_any,cortex_a53_fp_alu")

(define_insn_reservation "cortex_a53_fconst" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "fconsts,fconstd"))
  "cortex_a53_slot_any,cortex_a53_fp_alu")

(define_insn_reservation "cortex_a53_fpmul" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "fmuls,fmuld"))
  "cortex_a53_slot_any,cortex_a53_fp_mul")

;; For multiply-accumulate, model the add (accumulate) as being issued
;; after the multiply completes.

(define_insn_reservation "cortex_a53_fpmac" 8
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "fmacs,fmacd,ffmas,ffmad"))
  "cortex_a53_slot_any,cortex_a53_fp_mul,
   nothing*3, cortex_a53_fp_alu")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point to/from core transfers.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_insn_reservation "cortex_a53_r2f" 6
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "f_mcr,f_mcrr,f_cvti2f,
			neon_from_gp, neon_from_gp_q"))
  "cortex_a53_slot_any,cortex_a53_store,
   nothing,cortex_a53_fp_alu")

(define_insn_reservation "cortex_a53_f2r" 6
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "f_mrc,f_mrrc,f_cvtf2i,
			neon_to_gp, neon_to_gp_q"))
  "cortex_a53_slot_any,cortex_a53_fp_alu,
   nothing,cortex_a53_store")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point flag transfer.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_insn_reservation "cortex_a53_f_flags" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "f_flag"))
  "cortex_a53_slot_any")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point load/store.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define_insn_reservation "cortex_a53_f_load_64" 4
  (and (eq_attr "tune" "cortexa53")
       (ior (eq_attr "type" "f_loads,f_loadd")
	    (eq_attr "cortex_a53_advsimd_type"
		     "advsimd_load_64")))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_load")

(define_insn_reservation "cortex_a53_f_load_many" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type"
		"advsimd_load_128,advsimd_load_lots"))
  "cortex_a53_single_issue+cortex_a53_ls_agen,
   cortex_a53_load+cortex_a53_slot0,
   cortex_a53_load")

(define_insn_reservation "cortex_a53_f_store_64" 0
  (and (eq_attr "tune" "cortexa53")
       (ior (eq_attr "type" "f_stores,f_stored")
	    (eq_attr "cortex_a53_advsimd_type"
		     "advsimd_store_64")))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_store")

(define_insn_reservation "cortex_a53_f_store_many" 0
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type"
		"advsimd_store_128,advsimd_store_lots"))
  "cortex_a53_slot_any+cortex_a53_ls_agen,
   cortex_a53_store+cortex_a53_slot0,
   cortex_a53_store")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Advanced SIMD.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Either we want to model use of the ALU pipe, the multiply pipe or the
;; divide/sqrt pipe.  In all cases we need to check if we are a 64-bit
;; operation (in which case we model dual-issue without penalty)
;; or a 128-bit operation in which case we require in our model that we
;; issue from slot 0.

(define_insn_reservation "cortex_a53_advsimd_alu" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_alu"))
  "cortex_a53_slot_any,cortex_a53_fp_alu")

(define_insn_reservation "cortex_a53_advsimd_alu_q" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_alu_q"))
  "cortex_a53_slot0,cortex_a53_fp_alu_q")

(define_insn_reservation "cortex_a53_advsimd_mul" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_mul"))
  "cortex_a53_slot_any,cortex_a53_fp_mul")

(define_insn_reservation "cortex_a53_advsimd_mul_q" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_mul_q"))
  "cortex_a53_slot0,cortex_a53_fp_mul_q")

;; SIMD Dividers.

(define_insn_reservation "cortex_a53_advsimd_div_s" 14
  (and (eq_attr "tune" "cortexa53")
       (ior (eq_attr "type" "fdivs,fsqrts")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_div_s")))
  "cortex_a53_slot0,cortex_a53_fp_mul,
   cortex_a53_fp_div")

(define_insn_reservation "cortex_a53_advsimd_div_d" 29
  (and (eq_attr "tune" "cortexa53")
       (ior (eq_attr "type" "fdivd,fsqrtd")
	    (eq_attr "cortex_a53_advsimd_type" "advsimd_div_d")))
  "cortex_a53_slot0,cortex_a53_fp_mul,
   cortex_a53_fp_div")

(define_insn_reservation "cortex_a53_advsimd_div_s_q" 14
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_div_s_q"))
  "cortex_a53_single_issue,cortex_a53_fp_mul_q,
   cortex_a53_fp_div_q")

(define_insn_reservation "cortex_a53_advsimd_divd_q" 29
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "cortex_a53_advsimd_type" "advsimd_div_d_q"))
  "cortex_a53_single_issue,cortex_a53_fp_mul_q,
   cortex_a53_fp_div_q")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ARMv8-A Cryptographic extensions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; We want AESE and AESMC to end up consecutive to one another.

(define_insn_reservation "cortex_a53_crypto_aese" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "crypto_aese"))
  "cortex_a53_slot0")

(define_insn_reservation "cortex_a53_crypto_aesmc" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "crypto_aesmc"))
  "cortex_a53_slot_any")

;; SHA1H

(define_insn_reservation "cortex_a53_crypto_sha1_fast" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "crypto_sha1_fast"))
  "cortex_a53_slot_any,cortex_a53_crypto")

(define_insn_reservation "cortex_a53_crypto_sha256_fast" 3
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "crypto_sha256_fast"))
  "cortex_a53_slot0,cortex_a53_crypto")

(define_insn_reservation "cortex_a53_crypto_sha1_xor" 4
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "crypto_sha1_xor"))
  "cortex_a53_slot0,cortex_a53_crypto")

(define_insn_reservation "cortex_a53_crypto_sha_slow" 5
  (and (eq_attr "tune" "cortexa53")
       (eq_attr "type" "crypto_sha1_slow, crypto_sha256_slow"))
  "cortex_a53_slot0,cortex_a53_crypto")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Floating-point/Advanced SIMD register bypasses.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Model the late use of the accumulator operand for floating-point
;; multiply-accumulate operations as a bypass reducing the latency
;; of producing instructions to near zero.

(define_bypass 1 "cortex_a53_fp*,
		  cortex_a53_r2f,
		  cortex_a53_f_load*"
		 "cortex_a53_fpmac"
		 "aarch_accumulator_forwarding")

;; Model a bypass from the result of an FP operation to a use.

(define_bypass 4 "cortex_a53_fpalu,
		  cortex_a53_fpmul"
		 "cortex_a53_fpalu,
		  cortex_a53_fpmul,
		  cortex_a53_fpmac,
		  cortex_a53_advsimd_div*")

;; We want AESE and AESMC to end up consecutive to one another.

(define_bypass 0 "cortex_a53_crypto_aese"
		 "cortex_a53_crypto_aesmc"
		 "aarch_crypto_can_dual_issue")