PR target/56858
[official-gcc.git] / gcc / config / arm / cortex-a53.md
bloba629bd61daebf6263bff47523ef508ac894e4698
1 ;; ARM Cortex-A53 pipeline description
2 ;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
3 ;;
4 ;; Contributed by ARM Ltd.
5 ;;
6 ;; This file is part of GCC.
7 ;;
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
13 ;; GCC is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;; General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
22 (define_automaton "cortex_a53")
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;; Functional units.
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;; There are two main integer execution pipelines, described as
29 ;; slot 0 and issue slot 1.
31 (define_cpu_unit "cortex_a53_slot0" "cortex_a53")
32 (define_cpu_unit "cortex_a53_slot1" "cortex_a53")
34 (define_reservation "cortex_a53_slot_any" "cortex_a53_slot0|cortex_a53_slot1")
35 (define_reservation "cortex_a53_single_issue" "cortex_a53_slot0+cortex_a53_slot1")
37 ;; The load/store pipeline.  Load/store instructions can dual-issue from
38 ;; either pipeline, but two load/stores cannot simultaneously issue.
40 (define_cpu_unit "cortex_a53_ls" "cortex_a53")
42 ;; The store pipeline.  Shared between both execution pipelines.
44 (define_cpu_unit "cortex_a53_store" "cortex_a53")
46 ;; The branch pipeline.  Branches can dual-issue with other instructions
47 ;; (except when those instructions take multiple cycles to issue).
49 (define_cpu_unit "cortex_a53_branch" "cortex_a53")
51 ;; The integer divider.
53 (define_cpu_unit "cortex_a53_idiv" "cortex_a53")
55 ;; The floating-point add pipeline used to model the usage
56 ;; of the add pipeline by fmac instructions.
58 (define_cpu_unit "cortex_a53_fpadd_pipe" "cortex_a53")
60 ;; Floating-point div/sqrt (long latency, out-of-order completion).
62 (define_cpu_unit "cortex_a53_fp_div_sqrt" "cortex_a53")
64 ;; The Advanced SIMD pipelines.
66 (define_cpu_unit "cortex_a53_simd0" "cortex_a53")
67 (define_cpu_unit "cortex_a53_simd1" "cortex_a53")
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
70 ;; ALU instructions.
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73 (define_insn_reservation "cortex_a53_alu" 2
74   (and (eq_attr "tune" "cortexa53")
75        (eq_attr "type" "alu_imm,alus_imm,logic_imm,logics_imm,\
76                         alu_reg,alus_reg,logic_reg,logics_reg,\
77                         adc_imm,adcs_imm,adc_reg,adcs_reg,\
78                         adr,bfm,csel,rev,\
79                         shift_imm,shift_reg,\
80                         mov_imm,mov_reg,mvn_imm,mvn_reg,\
81                         mrs,multiple,no_insn"))
82   "cortex_a53_slot_any")
84 (define_insn_reservation "cortex_a53_alu_shift" 2
85   (and (eq_attr "tune" "cortexa53")
86        (eq_attr "type" "alu_shift_imm,alus_shift_imm,\
87                         logic_shift_imm,logics_shift_imm,\
88                         alu_shift_reg,alus_shift_reg,\
89                         logic_shift_reg,logics_shift_reg,\
90                         extend,mov_shift,mov_shift_reg,\
91                         mvn_shift,mvn_shift_reg"))
92   "cortex_a53_slot_any")
94 ;; Forwarding path for unshifted operands.
96 (define_bypass 1 "cortex_a53_alu,cortex_a53_alu_shift"
97   "cortex_a53_alu")
99 (define_bypass 1 "cortex_a53_alu,cortex_a53_alu_shift"
100   "cortex_a53_alu_shift"
101   "arm_no_early_alu_shift_dep")
103 ;; The multiplier pipeline can forward results so there's no need to specify
104 ;; bypasses. Multiplies can only single-issue currently.
106 (define_insn_reservation "cortex_a53_mul" 3
107   (and (eq_attr "tune" "cortexa53")
108        (ior (eq_attr "mul32" "yes")
109             (eq_attr "mul64" "yes")))
110   "cortex_a53_single_issue")
112 ;; A multiply with a single-register result or an MLA, followed by an
113 ;; MLA with an accumulator dependency, has its result forwarded so two
114 ;; such instructions can issue back-to-back.
116 (define_bypass 1 "cortex_a53_mul"
117                "cortex_a53_mul"
118                "arm_mac_accumulator_is_mul_result")
120 ;; Punt with a high enough latency for divides.
121 (define_insn_reservation "cortex_a53_udiv" 8
122   (and (eq_attr "tune" "cortexa53")
123        (eq_attr "type" "udiv"))
124   "(cortex_a53_slot0+cortex_a53_idiv),cortex_a53_idiv*7")
126 (define_insn_reservation "cortex_a53_sdiv" 9
127   (and (eq_attr "tune" "cortexa53")
128        (eq_attr "type" "sdiv"))
129   "(cortex_a53_slot0+cortex_a53_idiv),cortex_a53_idiv*8")
132 (define_bypass 2 "cortex_a53_mul,cortex_a53_udiv,cortex_a53_sdiv"
133                "cortex_a53_alu")
134 (define_bypass 2 "cortex_a53_mul,cortex_a53_udiv,cortex_a53_sdiv"
135                "cortex_a53_alu_shift"
136                "arm_no_early_alu_shift_dep")
138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
139 ;; Load/store instructions.
140 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
142 ;; Address-generation happens in the issue stage.
144 (define_insn_reservation "cortex_a53_load1" 3
145   (and (eq_attr "tune" "cortexa53")
146        (eq_attr "type" "load_byte,load1,load_acq"))
147   "cortex_a53_slot_any+cortex_a53_ls")
149 (define_insn_reservation "cortex_a53_store1" 2
150   (and (eq_attr "tune" "cortexa53")
151        (eq_attr "type" "store1,store_rel"))
152   "cortex_a53_slot_any+cortex_a53_ls+cortex_a53_store")
154 (define_insn_reservation "cortex_a53_load2" 3
155   (and (eq_attr "tune" "cortexa53")
156        (eq_attr "type" "load2"))
157   "cortex_a53_single_issue+cortex_a53_ls")
159 (define_insn_reservation "cortex_a53_store2" 2
160   (and (eq_attr "tune" "cortexa53")
161        (eq_attr "type" "store2"))
162   "cortex_a53_single_issue+cortex_a53_ls+cortex_a53_store")
164 (define_insn_reservation "cortex_a53_load3plus" 4
165   (and (eq_attr "tune" "cortexa53")
166        (eq_attr "type" "load3,load4"))
167   "(cortex_a53_single_issue+cortex_a53_ls)*2")
169 (define_insn_reservation "cortex_a53_store3plus" 3
170   (and (eq_attr "tune" "cortexa53")
171        (eq_attr "type" "store3,store4"))
172   "(cortex_a53_single_issue+cortex_a53_ls+cortex_a53_store)*2")
174 ;; Load/store addresses are required early in Issue.
175 (define_bypass 3 "cortex_a53_load1,cortex_a53_load2,cortex_a53_load3plus,cortex_a53_alu,cortex_a53_alu_shift"
176                  "cortex_a53_load*"
177                  "arm_early_load_addr_dep")
178 (define_bypass 3 "cortex_a53_load1,cortex_a53_load2,cortex_a53_load3plus,cortex_a53_alu,cortex_a53_alu_shift"
179                  "cortex_a53_store*"
180                  "arm_early_store_addr_dep")
182 ;; Load data can forward in the ALU pipeline
183 (define_bypass 2 "cortex_a53_load1,cortex_a53_load2"
184                "cortex_a53_alu")
185 (define_bypass 2 "cortex_a53_load1,cortex_a53_load2"
186                "cortex_a53_alu_shift"
187                "arm_no_early_alu_shift_dep")
189 ;; ALU ops can forward to stores.
190 (define_bypass 0 "cortex_a53_alu,cortex_a53_alu_shift"
191                  "cortex_a53_store1,cortex_a53_store2,cortex_a53_store3plus"
192                  "arm_no_early_store_addr_dep")
194 (define_bypass 1 "cortex_a53_mul,cortex_a53_udiv,cortex_a53_sdiv,cortex_a53_load1,cortex_a53_load2,cortex_a53_load3plus"
195                  "cortex_a53_store1,cortex_a53_store2,cortex_a53_store3plus"
196                  "arm_no_early_store_addr_dep")
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
199 ;; Branches.
200 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
202 ;; Currently models all branches as dual-issuable from either execution
203 ;; slot, which isn't true for all cases. We still need to model indirect
204 ;; branches.
206 (define_insn_reservation "cortex_a53_branch" 0
207   (and (eq_attr "tune" "cortexa53")
208        (eq_attr "type" "branch,call"))
209   "cortex_a53_slot_any+cortex_a53_branch")
211 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
212 ;; Floating-point arithmetic.
213 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
215 (define_insn_reservation "cortex_a53_fpalu" 4
216   (and (eq_attr "tune" "cortexa53")
217        (eq_attr "type" "ffariths, fadds, ffarithd, faddd, fmov, fmuls,\
218                         f_cvt,f_cvtf2i,f_cvti2f,\
219                         fcmps, fcmpd, fcsel"))
220   "cortex_a53_slot0+cortex_a53_fpadd_pipe")
222 (define_insn_reservation "cortex_a53_fconst" 2
223   (and (eq_attr "tune" "cortexa53")
224        (eq_attr "type" "fconsts,fconstd"))
225   "cortex_a53_slot0+cortex_a53_fpadd_pipe")
227 (define_insn_reservation "cortex_a53_fpmul" 4
228   (and (eq_attr "tune" "cortexa53")
229        (eq_attr "type" "fmuls,fmuld"))
230   "cortex_a53_slot0")
232 ;; For single-precision multiply-accumulate, the add (accumulate) is issued after
233 ;; the multiply completes. Model that accordingly.
235 (define_insn_reservation "cortex_a53_fpmac" 8
236   (and (eq_attr "tune" "cortexa53")
237        (eq_attr "type" "fmacs,fmacd,ffmas,ffmad"))
238   "cortex_a53_slot0, nothing*3, cortex_a53_fpadd_pipe")
240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
241 ;; Floating-point divide/square root instructions.
242 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
243 ;; fsqrt really takes one cycle less, but that is not modelled.
245 (define_insn_reservation "cortex_a53_fdivs" 14
246   (and (eq_attr "tune" "cortexa53")
247        (eq_attr "type" "fdivs, fsqrts"))
248   "cortex_a53_slot0, cortex_a53_fp_div_sqrt * 5")
250 (define_insn_reservation "cortex_a53_fdivd" 29
251   (and (eq_attr "tune" "cortexa53")
252        (eq_attr "type" "fdivd, fsqrtd"))
253   "cortex_a53_slot0, cortex_a53_fp_div_sqrt * 8")
255 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
256 ;; ARMv8-A Cryptographic extensions.
257 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
259 (define_insn_reservation "cortex_a53_crypto_aese" 2
260   (and (eq_attr "tune" "cortexa53")
261        (eq_attr "type" "crypto_aese"))
262   "cortex_a53_simd0")
264 (define_insn_reservation "cortex_a53_crypto_aesmc" 2
265   (and (eq_attr "tune" "cortexa53")
266        (eq_attr "type" "crypto_aesmc"))
267   "cortex_a53_simd0 | cortex_a53_simd1")
269 (define_insn_reservation "cortex_a53_crypto_sha1_fast" 2
270   (and (eq_attr "tune" "cortexa53")
271        (eq_attr "type" "crypto_sha1_fast, crypto_sha256_fast"))
272   "cortex_a53_simd0")
274 (define_insn_reservation "cortex_a53_crypto_sha1_xor" 3
275   (and (eq_attr "tune" "cortexa53")
276        (eq_attr "type" "crypto_sha1_xor"))
277   "cortex_a53_simd0")
279 (define_insn_reservation "cortex_a53_crypto_sha_slow" 5
280   (and (eq_attr "tune" "cortexa53")
281        (eq_attr "type" "crypto_sha1_slow, crypto_sha256_slow"))
282   "cortex_a53_simd0")
284 (define_bypass 0 "cortex_a53_crypto_aese"
285                  "cortex_a53_crypto_aesmc"
286                  "aarch_crypto_can_dual_issue")
288 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
289 ;; VFP to/from core transfers.
290 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
292 (define_insn_reservation "cortex_a53_r2f" 4
293   (and (eq_attr "tune" "cortexa53")
294        (eq_attr "type" "f_mcr,f_mcrr"))
295   "cortex_a53_slot0")
297 (define_insn_reservation "cortex_a53_f2r" 2
298   (and (eq_attr "tune" "cortexa53")
299        (eq_attr "type" "f_mrc,f_mrrc"))
300   "cortex_a53_slot0")
302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
303 ;; VFP flag transfer.
304 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
306 (define_insn_reservation "cortex_a53_f_flags" 4
307   (and (eq_attr "tune" "cortexa53")
308        (eq_attr "type" "f_flag"))
309   "cortex_a53_slot0")
311 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
312 ;; VFP load/store.
313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
315 (define_insn_reservation "cortex_a53_f_loads" 4
316   (and (eq_attr "tune" "cortexa53")
317        (eq_attr "type" "f_loads"))
318   "cortex_a53_slot0")
320 (define_insn_reservation "cortex_a53_f_loadd" 5
321   (and (eq_attr "tune" "cortexa53")
322        (eq_attr "type" "f_loadd"))
323   "cortex_a53_slot0")
325 (define_insn_reservation "cortex_a53_f_load_2reg" 5
326   (and (eq_attr "tune" "cortexa53")
327        (eq_attr "type" "neon_load2_2reg_q"))
328   "(cortex_a53_slot_any+cortex_a53_ls)*2")
330 (define_insn_reservation "cortex_a53_f_loadq" 5
331   (and (eq_attr "tune" "cortexa53")
332        (eq_attr "type" "neon_load1_1reg_q"))
333   "cortex_a53_slot_any+cortex_a53_ls")
335 (define_insn_reservation "cortex_a53_f_stores" 0
336   (and (eq_attr "tune" "cortexa53")
337        (eq_attr "type" "f_stores"))
338   "cortex_a53_slot0")
340 (define_insn_reservation "cortex_a53_f_stored" 0
341   (and (eq_attr "tune" "cortexa53")
342        (eq_attr "type" "f_stored"))
343   "cortex_a53_slot0")
345 ;; Load-to-use for floating-point values has a penalty of one cycle,
346 ;; i.e. a latency of two.
348 (define_bypass 2 "cortex_a53_f_loads"
349                  "cortex_a53_fpalu, cortex_a53_fpmac, cortex_a53_fpmul,\
350                   cortex_a53_fdivs, cortex_a53_fdivd,\
351                   cortex_a53_f2r")
353 (define_bypass 2 "cortex_a53_f_loadd"
354                  "cortex_a53_fpalu, cortex_a53_fpmac, cortex_a53_fpmul,\
355                   cortex_a53_fdivs, cortex_a53_fdivd,\
356                   cortex_a53_f2r")
358 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
359 ;; Crude Advanced SIMD approximation.
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362 (define_insn_reservation "cortex_53_advsimd" 4
363   (and (eq_attr "tune" "cortexa53")
364        (eq_attr "is_neon_type" "yes"))
365   "cortex_a53_simd0")