OSDN Git Service

PR bootstrap/45177
[pf3gnuchains/gcc-fork.git] / gcc / config / arm / cortex-a9.md
1 ;; ARM Cortex-A9 pipeline description
2 ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3 ;; Originally written by CodeSourcery for VFP.
4 ;;
5 ;; Rewritten by Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
6 ;; Integer Pipeline description contributed by ARM Ltd.
7 ;; VFP Pipeline description rewritten and contributed by ARM Ltd.
8
9 ;; This file is part of GCC.
10 ;;
11 ;; GCC is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15 ;;
16 ;; GCC is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20 ;;
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GCC; see the file COPYING3.  If not see
23 ;; <http://www.gnu.org/licenses/>.
24
25 (define_automaton "cortex_a9")
26
27 ;; The Cortex-A9 core is modelled as a dual issue pipeline that has
28 ;; the following components.
29 ;; 1. 1 Load Store Pipeline.
30 ;; 2. P0 / main pipeline for data processing instructions.
31 ;; 3. P1 / Dual pipeline for Data processing instructions.
32 ;; 4. MAC pipeline for multiply as well as multiply
33 ;;    and accumulate instructions.
34 ;; 5. 1 VFP and an optional Neon unit.
35 ;; The Load/Store, VFP and Neon issue pipeline are multiplexed.
36 ;; The P0 / main pipeline and M1 stage of the MAC pipeline are
37 ;;   multiplexed.
38 ;; The P1 / dual pipeline and M2 stage of the MAC pipeline are
39 ;;   multiplexed.
40 ;; There are only 4 integer register read ports and hence at any point of
41 ;; time we can't have issue down the E1 and the E2 ports unless
42 ;; of course there are bypass paths that get exercised.
43 ;; Both P0 and P1 have 2 stages E1 and E2.
44 ;; Data processing instructions issue to E1 or E2 depending on
45 ;; whether they have an early shift or not.
46
47 (define_cpu_unit "ca9_issue_vfp_neon, cortex_a9_ls" "cortex_a9")
48 (define_cpu_unit "cortex_a9_p0_e1, cortex_a9_p0_e2" "cortex_a9")
49 (define_cpu_unit "cortex_a9_p1_e1, cortex_a9_p1_e2" "cortex_a9")
50 (define_cpu_unit "cortex_a9_p0_wb, cortex_a9_p1_wb" "cortex_a9")
51 (define_cpu_unit "cortex_a9_mac_m1, cortex_a9_mac_m2" "cortex_a9")
52 (define_cpu_unit "cortex_a9_branch, cortex_a9_issue_branch" "cortex_a9")
53
54 (define_reservation "cortex_a9_p0_default" "cortex_a9_p0_e2, cortex_a9_p0_wb")
55 (define_reservation "cortex_a9_p1_default" "cortex_a9_p1_e2, cortex_a9_p1_wb")
56 (define_reservation "cortex_a9_p0_shift" "cortex_a9_p0_e1, cortex_a9_p0_default")
57 (define_reservation "cortex_a9_p1_shift" "cortex_a9_p1_e1, cortex_a9_p1_default")
58
59 (define_reservation "cortex_a9_multcycle1"
60   "cortex_a9_p0_e2 + cortex_a9_mac_m1 + cortex_a9_mac_m2 + \
61 cortex_a9_p1_e2 + cortex_a9_p0_e1 + cortex_a9_p1_e1")
62
63 (define_reservation "cortex_a9_mult16"
64   "cortex_a9_mac_m1, cortex_a9_mac_m2, cortex_a9_p0_wb")
65 (define_reservation "cortex_a9_mac16"
66   "cortex_a9_multcycle1, cortex_a9_mac_m2, cortex_a9_p0_wb")
67 (define_reservation "cortex_a9_mult"
68   "cortex_a9_mac_m1*2, cortex_a9_mac_m2, cortex_a9_p0_wb")
69 (define_reservation "cortex_a9_mac"
70   "cortex_a9_multcycle1*2 ,cortex_a9_mac_m2, cortex_a9_p0_wb")
71
72
73 ;; Issue at the same time along the load store pipeline and
74 ;; the VFP / Neon pipeline is not possible.
75 (exclusion_set "cortex_a9_ls" "ca9_issue_vfp_neon")
76
77 ;; Default data processing instruction without any shift
78 ;; The only exception to this is the mov instruction
79 ;; which can go down E2 without any problem.
80 (define_insn_reservation "cortex_a9_dp" 2
81   (and (eq_attr "tune" "cortexa9")
82        (ior (eq_attr "type" "alu")
83             (and (eq_attr "type" "alu_shift_reg, alu_shift")
84                  (eq_attr "insn" "mov"))))
85   "cortex_a9_p0_default|cortex_a9_p1_default")
86
87 ;; An instruction using the shifter will go down E1.
88 (define_insn_reservation "cortex_a9_dp_shift" 3
89    (and (eq_attr "tune" "cortexa9")
90         (and (eq_attr "type" "alu_shift_reg, alu_shift")
91              (not (eq_attr "insn" "mov"))))
92    "cortex_a9_p0_shift | cortex_a9_p1_shift")
93
94 ;; Loads have a latency of 4 cycles.
95 ;; We don't model autoincrement instructions. These
96 ;; instructions use the load store pipeline and 1 of
97 ;; the E2 units to write back the result of the increment.
98
99 (define_insn_reservation "cortex_a9_load1_2" 4
100   (and (eq_attr "tune" "cortexa9")
101        (eq_attr "type" "load1, load2, load_byte, f_loads, f_loadd"))
102   "cortex_a9_ls")
103
104 ;; Loads multiples and store multiples can't be issued for 2 cycles in a
105 ;; row. The description below assumes that addresses are 64 bit aligned.
106 ;; If not, there is an extra cycle latency which is not modelled.
107
108 (define_insn_reservation "cortex_a9_load3_4" 5
109   (and (eq_attr "tune" "cortexa9")
110        (eq_attr "type" "load3, load4"))
111   "cortex_a9_ls, cortex_a9_ls")
112
113 (define_insn_reservation "cortex_a9_store1_2" 0
114   (and (eq_attr "tune" "cortexa9")
115        (eq_attr "type" "store1, store2, f_stores, f_stored"))
116   "cortex_a9_ls")
117
118 ;; Almost all our store multiples use an auto-increment
119 ;; form. Don't issue back to back load and store multiples
120 ;; because the load store unit will stall.
121
122 (define_insn_reservation "cortex_a9_store3_4" 0
123   (and (eq_attr "tune" "cortexa9")
124        (eq_attr "type" "store3, store4"))
125   "cortex_a9_ls+(cortex_a9_p0_default | cortex_a9_p1_default), cortex_a9_ls")
126
127 ;; We get 16*16 multiply / mac results in 3 cycles.
128 (define_insn_reservation "cortex_a9_mult16" 3
129   (and (eq_attr "tune" "cortexa9")
130        (eq_attr "insn" "smulxy"))
131        "cortex_a9_mult16")
132
133 ;; The 16*16 mac is slightly different that it
134 ;; reserves M1 and M2 in the same cycle.
135 (define_insn_reservation "cortex_a9_mac16" 3
136   (and (eq_attr "tune" "cortexa9")
137        (eq_attr "insn" "smlaxy"))
138   "cortex_a9_mac16")
139
140
141 (define_insn_reservation "cortex_a9_multiply" 4
142   (and (eq_attr "tune" "cortexa9")
143        (eq_attr "insn" "mul"))
144        "cortex_a9_mult")
145
146 (define_insn_reservation "cortex_a9_mac" 4
147   (and (eq_attr "tune" "cortexa9")
148        (eq_attr "insn" "mla"))
149        "cortex_a9_mac")
150
151 ;; An instruction with a result in E2 can be forwarded
152 ;; to E2 or E1 or M1 or the load store unit in the next cycle.
153
154 (define_bypass 1 "cortex_a9_dp"
155                  "cortex_a9_dp_shift, cortex_a9_multiply,
156  cortex_a9_load1_2, cortex_a9_dp, cortex_a9_store1_2,
157  cortex_a9_mult16, cortex_a9_mac16, cortex_a9_mac, cortex_a9_store3_4, cortex_a9_load3_4")
158
159 (define_bypass 2 "cortex_a9_dp_shift"
160                  "cortex_a9_dp_shift, cortex_a9_multiply,
161  cortex_a9_load1_2, cortex_a9_dp, cortex_a9_store1_2,
162  cortex_a9_mult16, cortex_a9_mac16, cortex_a9_mac, cortex_a9_store3_4, cortex_a9_load3_4")
163
164 ;; An instruction in the load store pipeline can provide
165 ;; read access to a DP instruction in the P0 default pipeline
166 ;; before the writeback stage.
167
168 (define_bypass 3 "cortex_a9_load1_2" "cortex_a9_dp, cortex_a9_load1_2,
169 cortex_a9_store3_4, cortex_a9_store1_2")
170
171 (define_bypass 4 "cortex_a9_load3_4" "cortex_a9_dp, cortex_a9_load1_2,
172 cortex_a9_store3_4, cortex_a9_store1_2,  cortex_a9_load3_4")
173
174 ;; Calls and branches.
175
176 ;; Branch instructions
177
178 (define_insn_reservation "cortex_a9_branch" 0
179   (and (eq_attr "tune" "cortexa9")
180        (eq_attr "type" "branch"))
181   "cortex_a9_branch")
182
183 ;; Call latencies are essentially 0 but make sure
184 ;; dual issue doesn't happen i.e the next instruction
185 ;; starts at the next cycle.
186 (define_insn_reservation "cortex_a9_call"  0
187   (and (eq_attr "tune" "cortexa9")
188        (eq_attr "type" "call"))
189   "cortex_a9_issue_branch + cortex_a9_multcycle1 + cortex_a9_ls + ca9_issue_vfp_neon")
190
191
192 ;; Pipelining for VFP instructions.
193 ;; Issue happens either along load store unit or the VFP / Neon unit.
194 ;; Pipeline   Instruction Classification.
195 ;; FPS - fcpys, ffariths, ffarithd,r_2_f,f_2_r
196 ;; FP_ADD   - fadds, faddd, fcmps (1)
197 ;; FPMUL   - fmul{s,d}, fmac{s,d}
198 ;; FPDIV - fdiv{s,d}
199 (define_cpu_unit "ca9fps" "cortex_a9")
200 (define_cpu_unit "ca9fp_add1, ca9fp_add2, ca9fp_add3, ca9fp_add4" "cortex_a9")
201 (define_cpu_unit "ca9fp_mul1, ca9fp_mul2 , ca9fp_mul3, ca9fp_mul4" "cortex_a9")
202 (define_cpu_unit "ca9fp_ds1" "cortex_a9")
203
204
205 ;; fmrs, fmrrd, fmstat and fmrx - The data is available after 1 cycle.
206 (define_insn_reservation "cortex_a9_fps" 2
207  (and (eq_attr "tune" "cortexa9")
208       (eq_attr "type" "fcpys, fconsts, fconstd, ffariths, ffarithd, r_2_f, f_2_r, f_flag"))
209  "ca9_issue_vfp_neon + ca9fps")
210
211 (define_bypass 1
212   "cortex_a9_fps"
213   "cortex_a9_fadd, cortex_a9_fps, cortex_a9_fcmp, cortex_a9_dp, cortex_a9_dp_shift, cortex_a9_multiply")
214
215 ;; Scheduling on the FP_ADD pipeline.
216 (define_reservation "ca9fp_add" "ca9_issue_vfp_neon + ca9fp_add1, ca9fp_add2, ca9fp_add3, ca9fp_add4")
217
218 (define_insn_reservation "cortex_a9_fadd" 4
219   (and (eq_attr "tune" "cortexa9")
220        (eq_attr "type" "fadds, faddd, f_cvt"))
221   "ca9fp_add")
222
223 (define_insn_reservation "cortex_a9_fcmp" 1
224   (and (eq_attr "tune" "cortexa9")
225       (eq_attr "type" "fcmps, fcmpd"))
226  "ca9_issue_vfp_neon + ca9fp_add1")
227
228 ;; Scheduling for the Multiply and MAC instructions.
229 (define_reservation "ca9fmuls"
230   "ca9fp_mul1 + ca9_issue_vfp_neon, ca9fp_mul2, ca9fp_mul3, ca9fp_mul4")
231
232 (define_reservation "ca9fmuld"
233   "ca9fp_mul1 + ca9_issue_vfp_neon, (ca9fp_mul1 + ca9fp_mul2), ca9fp_mul2, ca9fp_mul3, ca9fp_mul4")
234
235 (define_insn_reservation "cortex_a9_fmuls" 4
236   (and (eq_attr "tune" "cortexa9")
237        (eq_attr "type" "fmuls"))
238   "ca9fmuls")
239
240 (define_insn_reservation "cortex_a9_fmuld" 5
241   (and (eq_attr "tune" "cortexa9")
242        (eq_attr "type" "fmuld"))
243   "ca9fmuld")
244
245 (define_insn_reservation "cortex_a9_fmacs" 8
246   (and (eq_attr "tune" "cortexa9")
247        (eq_attr "type" "fmacs"))
248   "ca9fmuls, ca9fp_add")
249
250 (define_insn_reservation "cortex_a9_fmacd" 9
251   (and (eq_attr "tune" "cortexa9")
252        (eq_attr "type" "fmacd"))
253   "ca9fmuld, ca9fp_add")
254
255 ;; Division pipeline description.
256 (define_insn_reservation "cortex_a9_fdivs" 15
257   (and (eq_attr "tune" "cortexa9")
258        (eq_attr "type" "fdivs"))
259   "ca9fp_ds1 + ca9_issue_vfp_neon, nothing*14")
260
261 (define_insn_reservation "cortex_a9_fdivd" 25
262   (and (eq_attr "tune" "cortexa9")
263        (eq_attr "type" "fdivd"))
264   "ca9fp_ds1 + ca9_issue_vfp_neon, nothing*24")