1 ;; ARM Cortex-A7 pipeline description
2 ;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 ;; Contributed by ARM Ltd.
5 ;; Based on cortex-a5.md which was originally contributed by CodeSourcery.
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; GCC is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
23 (define_automaton "cortex_a7")
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29 ;; The Cortex-A7 pipeline integer and vfp pipeline.
30 ;; The decode is the same for all instructions, so do not model it.
31 ;; We only model the first execution stage because
32 ;; instructions always advance one stage per cycle in order.
33 ;; We model all of the LS, Branch, ALU, MAC and FPU pipelines together.
35 (define_cpu_unit "cortex_a7_ex1, cortex_a7_ex2" "cortex_a7")
37 (define_reservation "cortex_a7_both" "cortex_a7_ex1+cortex_a7_ex2")
39 (define_cpu_unit "cortex_a7_branch" "cortex_a7")
41 ;; Cortex-A7 is in order and can dual-issue under limited circumstances.
42 ;; ex2 can be reserved only after ex1 is reserved.
44 (final_presence_set "cortex_a7_ex2" "cortex_a7_ex1")
46 ;; Pseudo-unit for blocking the multiply pipeline when a double-precision
47 ;; multiply is in progress.
49 (define_cpu_unit "cortex_a7_fpmul_pipe" "cortex_a7")
51 ;; The floating-point add pipeline (ex1/f1 stage), used to model the usage
52 ;; of the add pipeline by fmac instructions, etc.
54 (define_cpu_unit "cortex_a7_fpadd_pipe" "cortex_a7")
56 ;; Floating-point div/sqrt (long latency, out-of-order completion).
58 (define_cpu_unit "cortex_a7_fp_div_sqrt" "cortex_a7")
60 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64 ;; A direct branch can dual issue either as younger or older instruction,
65 ;; but branches cannot dual issue with branches.
66 ;; No latency as there is no result.
68 (define_insn_reservation "cortex_a7_branch" 0
69 (and (eq_attr "tune" "cortexa7")
70 (and (eq_attr "type" "branch")
71 (eq_attr "neon_type" "none")))
72 "(cortex_a7_ex2|cortex_a7_ex1)+cortex_a7_branch")
74 ;; Call cannot dual-issue as an older instruction. It can dual-issue
75 ;; as a younger instruction, or single-issue. Call cannot dual-issue
76 ;; with another branch instruction. The result is available the next
78 (define_insn_reservation "cortex_a7_call" 1
79 (and (eq_attr "tune" "cortexa7")
80 (and (eq_attr "type" "call")
81 (eq_attr "neon_type" "none")))
82 "(cortex_a7_ex2|cortex_a7_both)+cortex_a7_branch")
84 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
86 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
88 ;; ALU instruction with an immediate operand can dual-issue.
89 (define_insn_reservation "cortex_a7_alu_imm" 2
90 (and (eq_attr "tune" "cortexa7")
91 (and (ior (eq_attr "type" "simple_alu_imm")
92 (ior (eq_attr "type" "simple_alu_shift")
93 (and (eq_attr "insn" "mov")
94 (not (eq_attr "length" "8")))))
95 (eq_attr "neon_type" "none")))
96 "cortex_a7_ex2|cortex_a7_ex1")
98 ;; ALU instruction with register operands can dual-issue
99 ;; with a younger immediate-based instruction.
100 (define_insn_reservation "cortex_a7_alu_reg" 2
101 (and (eq_attr "tune" "cortexa7")
102 (and (eq_attr "type" "alu_reg")
103 (eq_attr "neon_type" "none")))
106 (define_insn_reservation "cortex_a7_alu_shift" 2
107 (and (eq_attr "tune" "cortexa7")
108 (and (eq_attr "type" "alu_shift,alu_shift_reg")
109 (eq_attr "neon_type" "none")))
112 ;; Forwarding path for unshifted operands.
113 (define_bypass 1 "cortex_a7_alu_imm,cortex_a7_alu_reg,cortex_a7_alu_shift"
114 "cortex_a7_alu_imm,cortex_a7_alu_reg,cortex_a7_mul")
116 (define_bypass 1 "cortex_a7_alu_imm,cortex_a7_alu_reg,cortex_a7_alu_shift"
118 "arm_no_early_store_addr_dep")
120 (define_bypass 1 "cortex_a7_alu_imm,cortex_a7_alu_reg,cortex_a7_alu_shift"
121 "cortex_a7_alu_shift"
122 "arm_no_early_alu_shift_dep")
124 ;; The multiplier pipeline can forward results from wr stage only so
125 ;; there's no need to specify bypasses.
126 ;; Multiply instructions cannot dual-issue.
128 (define_insn_reservation "cortex_a7_mul" 2
129 (and (eq_attr "tune" "cortexa7")
130 (and (eq_attr "type" "mult")
131 (eq_attr "neon_type" "none")))
134 ;; Forward the result of a multiply operation to the accumulator
135 ;; of the following multiply and accumulate instruction.
136 (define_bypass 1 "cortex_a7_mul"
138 "arm_mac_accumulator_is_result")
140 ;; The latency depends on the operands, so we use an estimate here.
141 (define_insn_reservation "cortex_a7_idiv" 5
142 (and (eq_attr "tune" "cortexa7")
143 (eq_attr "insn" "udiv,sdiv"))
146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147 ;; Load/store instructions.
148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
150 ;; Address-generation happens in the issue stage.
151 ;; Double-word accesses can be issued in a single cycle,
152 ;; and occupy only one pipeline stage.
154 (define_insn_reservation "cortex_a7_load1" 2
155 (and (eq_attr "tune" "cortexa7")
156 (and (eq_attr "type" "load_byte,load1")
157 (eq_attr "neon_type" "none")))
160 (define_insn_reservation "cortex_a7_store1" 0
161 (and (eq_attr "tune" "cortexa7")
162 (and (eq_attr "type" "store1")
163 (eq_attr "neon_type" "none")))
166 (define_insn_reservation "cortex_a7_load2" 2
167 (and (eq_attr "tune" "cortexa7")
168 (and (eq_attr "type" "load2")
169 (eq_attr "neon_type" "none")))
172 (define_insn_reservation "cortex_a7_store2" 0
173 (and (eq_attr "tune" "cortexa7")
174 (and (eq_attr "type" "store2")
175 (eq_attr "neon_type" "none")))
178 (define_insn_reservation "cortex_a7_load3" 3
179 (and (eq_attr "tune" "cortexa7")
180 (and (eq_attr "type" "load3")
181 (eq_attr "neon_type" "none")))
182 "cortex_a7_both, cortex_a7_ex1")
184 (define_insn_reservation "cortex_a7_store3" 0
185 (and (eq_attr "tune" "cortexa7")
186 (and (eq_attr "type" "store4")
187 (eq_attr "neon_type" "none")))
188 "cortex_a7_both, cortex_a7_ex1")
190 (define_insn_reservation "cortex_a7_load4" 3
191 (and (eq_attr "tune" "cortexa7")
192 (and (eq_attr "type" "load4")
193 (eq_attr "neon_type" "none")))
194 "cortex_a7_both, cortex_a7_both")
196 (define_insn_reservation "cortex_a7_store4" 0
197 (and (eq_attr "tune" "cortexa7")
198 (and (eq_attr "type" "store3")
199 (eq_attr "neon_type" "none")))
200 "cortex_a7_both, cortex_a7_both")
202 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
203 ;; Floating-point arithmetic.
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
205 ;; Neon integer, neon floating point, and single-precision floating
206 ;; point instructions of the same type have the same timing
207 ;; characteristics, but neon instructions cannot dual-issue.
209 (define_insn_reservation "cortex_a7_fpalu" 4
210 (and (eq_attr "tune" "cortexa7")
211 (and (eq_attr "type" "ffariths, fadds, ffarithd, faddd, fcpys,\
212 f_cvt, fcmps, fcmpd")
213 (eq_attr "neon_type" "none")))
214 "cortex_a7_ex1+cortex_a7_fpadd_pipe")
216 ;; For fconsts and fconstd, 8-bit immediate data is passed directly from
217 ;; f1 to f3 (which I think reduces the latency by one cycle).
219 (define_insn_reservation "cortex_a7_fconst" 3
220 (and (eq_attr "tune" "cortexa7")
221 (and (eq_attr "type" "fconsts,fconstd")
222 (eq_attr "neon_type" "none")))
223 "cortex_a7_ex1+cortex_a7_fpadd_pipe")
225 ;; We should try not to attempt to issue a single-precision multiplication in
226 ;; the middle of a double-precision multiplication operation (the usage of
227 ;; cortex_a7_fpmul_pipe).
229 (define_insn_reservation "cortex_a7_fpmuls" 4
230 (and (eq_attr "tune" "cortexa7")
231 (and (eq_attr "type" "fmuls")
232 (eq_attr "neon_type" "none")))
233 "cortex_a7_ex1+cortex_a7_fpmul_pipe")
235 (define_insn_reservation "cortex_a7_neon_mul" 4
236 (and (eq_attr "tune" "cortexa7")
238 "neon_mul_ddd_8_16_qdd_16_8_long_32_16_long,\
239 neon_mul_qqq_8_16_32_ddd_32,\
240 neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar,\
241 neon_mul_ddd_16_scalar_32_16_long_scalar,\
242 neon_mul_qqd_32_scalar,\
245 "(cortex_a7_both+cortex_a7_fpmul_pipe)*2")
247 (define_insn_reservation "cortex_a7_fpmacs" 8
248 (and (eq_attr "tune" "cortexa7")
249 (and (eq_attr "type" "fmacs,ffmas")
250 (eq_attr "neon_type" "none")))
251 "cortex_a7_ex1+cortex_a7_fpmul_pipe")
253 (define_insn_reservation "cortex_a7_neon_mla" 8
254 (and (eq_attr "tune" "cortexa7")
256 "neon_mla_ddd_8_16_qdd_16_8_long_32_16_long,\
258 neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long,\
259 neon_mla_qqq_32_qqd_32_scalar,\
260 neon_mla_ddd_16_scalar_qdd_32_16_long_scalar,\
263 neon_fp_vmla_ddd_scalar,\
264 neon_fp_vmla_qqq_scalar"))
265 "cortex_a7_both+cortex_a7_fpmul_pipe")
267 (define_bypass 4 "cortex_a7_fpmacs,cortex_a7_neon_mla"
268 "cortex_a7_fpmacs,cortex_a7_neon_mla"
269 "arm_mac_accumulator_is_result")
271 ;; Non-multiply instructions can issue between two cycles of a
272 ;; double-precision multiply.
274 (define_insn_reservation "cortex_a7_fpmuld" 7
275 (and (eq_attr "tune" "cortexa7")
276 (and (eq_attr "type" "fmuld")
277 (eq_attr "neon_type" "none")))
278 "cortex_a7_ex1+cortex_a7_fpmul_pipe, cortex_a7_fpmul_pipe*3")
280 (define_insn_reservation "cortex_a7_fpmacd" 11
281 (and (eq_attr "tune" "cortexa7")
282 (and (eq_attr "type" "fmacd")
283 (eq_attr "neon_type" "none")))
284 "cortex_a7_ex1+cortex_a7_fpmul_pipe, cortex_a7_fpmul_pipe*3")
286 (define_insn_reservation "cortex_a7_fpfmad" 8
287 (and (eq_attr "tune" "cortexa7")
288 (and (eq_attr "type" "ffmad")
289 (eq_attr "neon_type" "none")))
290 "cortex_a7_ex1+cortex_a7_fpmul_pipe, cortex_a7_fpmul_pipe*4")
292 (define_bypass 7 "cortex_a7_fpmacd"
293 "cortex_a7_fpmacd,cortex_a7_fpfmad"
294 "arm_mac_accumulator_is_result")
296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
297 ;; Floating-point divide/square root instructions.
298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
300 (define_insn_reservation "cortex_a7_fdivs" 16
301 (and (eq_attr "tune" "cortexa7")
302 (and (eq_attr "type" "fdivs")
303 (eq_attr "neon_type" "none")))
304 "cortex_a7_ex1+cortex_a7_fp_div_sqrt, cortex_a7_fp_div_sqrt * 13")
306 (define_insn_reservation "cortex_a7_fdivd" 31
307 (and (eq_attr "tune" "cortexa7")
308 (and (eq_attr "type" "fdivd")
309 (eq_attr "neon_type" "none")))
310 "cortex_a7_ex1+cortex_a7_fp_div_sqrt, cortex_a7_fp_div_sqrt * 28")
312 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
313 ;; VFP to/from core transfers.
314 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
316 ;; Core-to-VFP transfers.
318 (define_insn_reservation "cortex_a7_r2f" 4
319 (and (eq_attr "tune" "cortexa7")
320 (and (eq_attr "type" "r_2_f")
321 (eq_attr "neon_type" "none")))
324 (define_insn_reservation "cortex_a7_f2r" 2
325 (and (eq_attr "tune" "cortexa7")
326 (and (eq_attr "type" "f_2_r")
327 (eq_attr "neon_type" "none")))
330 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
331 ;; VFP flag transfer.
332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
334 ;; Fuxne: The flag forwarding from fmstat to the second instruction is
335 ;; not modeled at present.
337 (define_insn_reservation "cortex_a7_f_flags" 4
338 (and (eq_attr "tune" "cortexa7")
339 (and (eq_attr "type" "f_flag")
340 (eq_attr "neon_type" "none")))
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
345 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
347 (define_insn_reservation "cortex_a7_f_loads" 4
348 (and (eq_attr "tune" "cortexa7")
349 (and (eq_attr "type" "f_loads")
350 (eq_attr "neon_type" "none")))
353 (define_insn_reservation "cortex_a7_f_loadd" 4
354 (and (eq_attr "tune" "cortexa7")
355 (and (eq_attr "type" "f_loadd")
356 (eq_attr "neon_type" "none")))
359 (define_insn_reservation "cortex_a7_f_stores" 0
360 (and (eq_attr "tune" "cortexa7")
361 (and (eq_attr "type" "f_stores")
362 (eq_attr "neon_type" "none")))
365 (define_insn_reservation "cortex_a7_f_stored" 0
366 (and (eq_attr "tune" "cortexa7")
367 (and (eq_attr "type" "f_stored")
368 (eq_attr "neon_type" "none")))
371 ;; Load-to-use for floating-point values has a penalty of one cycle,
372 ;; i.e. a latency of two.
374 (define_bypass 2 "cortex_a7_f_loads, cortex_a7_f_loadd"
376 cortex_a7_fpmuls,cortex_a7_fpmacs,\
377 cortex_a7_fpmuld,cortex_a7_fpmacd, cortex_a7_fpfmad,\
378 cortex_a7_fdivs, cortex_a7_fdivd,\
381 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
383 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
385 ;; Simple modeling for all neon instructions not covered earlier.
387 (define_insn_reservation "cortex_a7_neon" 4
388 (and (eq_attr "tune" "cortexa7")
391 neon_mul_ddd_8_16_qdd_16_8_long_32_16_long,\
392 neon_mul_qqq_8_16_32_ddd_32,\
393 neon_mul_qdd_64_32_long_qqd_16_ddd_32_scalar_64_32_long_scalar,\
394 neon_mla_ddd_8_16_qdd_16_8_long_32_16_long,\
396 neon_mla_ddd_32_qqd_16_ddd_32_scalar_qdd_64_32_long_scalar_qdd_64_32_long,\
397 neon_mla_qqq_32_qqd_32_scalar,\
398 neon_mul_ddd_16_scalar_32_16_long_scalar,\
399 neon_mul_qqd_32_scalar,\
400 neon_mla_ddd_16_scalar_qdd_32_16_long_scalar,\
405 neon_fp_vmla_ddd_scalar,\
406 neon_fp_vmla_qqq_scalar"))