1 ;; ARM 1136J[F]-S Pipeline Description
2 ;; Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 ;; Written by CodeSourcery, LLC.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; GCC is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>. */
21 ;; These descriptions are based on the information contained in the
22 ;; ARM1136JF-S Technical Reference Manual, Copyright (c) 2003 ARM
26 ;; This automaton provides a pipeline description for the ARM
27 ;; 1136J-S and 1136JF-S cores.
29 ;; The model given here assumes that the condition for all conditional
30 ;; instructions is "true", i.e., that all of the instructions are
33 (define_automaton "arm1136jfs")
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 ;; There are three distinct pipelines (page 1-26 and following):
41 ;; - A 4-stage decode pipeline, shared by all three. It has fetch (1),
42 ;; fetch (2), decode, and issue stages. Since this is always involved,
43 ;; we do not model it in the scheduler.
45 ;; - A 4-stage ALU pipeline. It has shifter, ALU (main integer operations),
46 ;; and saturation stages. The fourth stage is writeback; see below.
48 ;; - A 4-stage multiply-accumulate pipeline. It has three stages, called
49 ;; MAC1 through MAC3, and a fourth writeback stage.
51 ;; The 4th-stage writeback is shared between the ALU and MAC pipelines,
52 ;; which operate in lockstep. Results from either pipeline will be
53 ;; moved into the writeback stage. Because the two pipelines operate
54 ;; in lockstep, we schedule them as a single "execute" pipeline.
56 ;; - A 4-stage LSU pipeline. It has address generation, data cache (1),
57 ;; data cache (2), and writeback stages. (Note that this pipeline,
58 ;; including the writeback stage, is independent from the ALU & LSU pipes.)
60 (define_cpu_unit "e_1,e_2,e_3,e_wb" "arm1136jfs") ; ALU and MAC
61 ; e_1 = Sh/Mac1, e_2 = ALU/Mac2, e_3 = SAT/Mac3
62 (define_cpu_unit "l_a,l_dc1,l_dc2,l_wb" "arm1136jfs") ; Load/Store
64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
66 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
68 ;; ALU instructions require eight cycles to execute, and use the ALU
69 ;; pipeline in each of the eight stages. The results are available
70 ;; after the alu stage has finished.
72 ;; If the destination register is the PC, the pipelines are stalled
73 ;; for several cycles. That case is not modelled here.
75 ;; ALU operations with no shifted operand
76 (define_insn_reservation "11_alu_op" 2
77 (and (eq_attr "tune" "arm1136js,arm1136jfs")
78 (eq_attr "type" "alu_reg,simple_alu_imm"))
81 ;; ALU operations with a shift-by-constant operand
82 (define_insn_reservation "11_alu_shift_op" 2
83 (and (eq_attr "tune" "arm1136js,arm1136jfs")
84 (eq_attr "type" "simple_alu_shift,alu_shift"))
87 ;; ALU operations with a shift-by-register operand
88 ;; These really stall in the decoder, in order to read
89 ;; the shift value in a second cycle. Pretend we take two cycles in
91 (define_insn_reservation "11_alu_shift_reg_op" 3
92 (and (eq_attr "tune" "arm1136js,arm1136jfs")
93 (eq_attr "type" "alu_shift_reg"))
96 ;; alu_ops can start sooner, if there is no shifter dependency
97 (define_bypass 1 "11_alu_op,11_alu_shift_op"
99 (define_bypass 1 "11_alu_op,11_alu_shift_op"
101 "arm_no_early_alu_shift_value_dep")
102 (define_bypass 1 "11_alu_op,11_alu_shift_op"
103 "11_alu_shift_reg_op"
104 "arm_no_early_alu_shift_dep")
105 (define_bypass 2 "11_alu_shift_reg_op"
107 (define_bypass 2 "11_alu_shift_reg_op"
109 "arm_no_early_alu_shift_value_dep")
110 (define_bypass 2 "11_alu_shift_reg_op"
111 "11_alu_shift_reg_op"
112 "arm_no_early_alu_shift_dep")
114 (define_bypass 1 "11_alu_op,11_alu_shift_op"
115 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
116 "arm_no_early_mul_dep")
117 (define_bypass 2 "11_alu_shift_reg_op"
118 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
119 "arm_no_early_mul_dep")
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
122 ;; Multiplication Instructions
123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
125 ;; Multiplication instructions loop in the first two execute stages until
126 ;; the instruction has been passed through the multiplier array enough
129 ;; Multiply and multiply-accumulate results are available after four stages.
130 (define_insn_reservation "11_mult1" 4
131 (and (eq_attr "tune" "arm1136js,arm1136jfs")
132 (eq_attr "type" "mul,mla"))
133 "e_1*2,e_2,e_3,e_wb")
135 ;; The *S variants set the condition flags, which requires three more cycles.
136 (define_insn_reservation "11_mult2" 4
137 (and (eq_attr "tune" "arm1136js,arm1136jfs")
138 (eq_attr "type" "muls,mlas"))
139 "e_1*2,e_2,e_3,e_wb")
141 (define_bypass 3 "11_mult1,11_mult2"
142 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
143 "arm_no_early_mul_dep")
144 (define_bypass 3 "11_mult1,11_mult2"
146 (define_bypass 3 "11_mult1,11_mult2"
148 "arm_no_early_alu_shift_value_dep")
149 (define_bypass 3 "11_mult1,11_mult2"
150 "11_alu_shift_reg_op"
151 "arm_no_early_alu_shift_dep")
152 (define_bypass 3 "11_mult1,11_mult2"
154 "arm_no_early_store_addr_dep")
156 ;; Signed and unsigned multiply long results are available across two cycles;
157 ;; the less significant word is available one cycle before the more significant
158 ;; word. Here we conservatively wait until both are available, which is
159 ;; after three iterations and the memory cycle. The same is also true of
160 ;; the two multiply-accumulate instructions.
161 (define_insn_reservation "11_mult3" 5
162 (and (eq_attr "tune" "arm1136js,arm1136jfs")
163 (eq_attr "type" "smull,umull,smlal,umlal"))
164 "e_1*3,e_2,e_3,e_wb*2")
166 ;; The *S variants set the condition flags, which requires three more cycles.
167 (define_insn_reservation "11_mult4" 5
168 (and (eq_attr "tune" "arm1136js,arm1136jfs")
169 (eq_attr "type" "smulls,umulls,smlals,umlals"))
170 "e_1*3,e_2,e_3,e_wb*2")
172 (define_bypass 4 "11_mult3,11_mult4"
173 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
174 "arm_no_early_mul_dep")
175 (define_bypass 4 "11_mult3,11_mult4"
177 (define_bypass 4 "11_mult3,11_mult4"
179 "arm_no_early_alu_shift_value_dep")
180 (define_bypass 4 "11_mult3,11_mult4"
181 "11_alu_shift_reg_op"
182 "arm_no_early_alu_shift_dep")
183 (define_bypass 4 "11_mult3,11_mult4"
185 "arm_no_early_store_addr_dep")
187 ;; Various 16x16->32 multiplies and multiply-accumulates, using combinations
188 ;; of high and low halves of the argument registers. They take a single
189 ;; pass through the pipeline and make the result available after three
191 (define_insn_reservation "11_mult5" 3
192 (and (eq_attr "tune" "arm1136js,arm1136jfs")
193 (eq_attr "type" "smulxy,smlaxy,smulwy,smlawy,smuad,smuadx,smlad,smladx,\
194 smusd,smusdx,smlsd,smlsdx"))
197 (define_bypass 2 "11_mult5"
198 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
199 "arm_no_early_mul_dep")
200 (define_bypass 2 "11_mult5"
202 (define_bypass 2 "11_mult5"
204 "arm_no_early_alu_shift_value_dep")
205 (define_bypass 2 "11_mult5"
206 "11_alu_shift_reg_op"
207 "arm_no_early_alu_shift_dep")
208 (define_bypass 2 "11_mult5"
210 "arm_no_early_store_addr_dep")
212 ;; The same idea, then the 32-bit result is added to a 64-bit quantity.
213 (define_insn_reservation "11_mult6" 4
214 (and (eq_attr "tune" "arm1136js,arm1136jfs")
215 (eq_attr "type" "smlalxy"))
216 "e_1*2,e_2,e_3,e_wb*2")
218 ;; Signed 32x32 multiply, then the most significant 32 bits are extracted
219 ;; and are available after the memory stage.
220 (define_insn_reservation "11_mult7" 4
221 (and (eq_attr "tune" "arm1136js,arm1136jfs")
222 (eq_attr "type" "smmul,smmulr"))
223 "e_1*2,e_2,e_3,e_wb")
225 (define_bypass 3 "11_mult6,11_mult7"
226 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
227 "arm_no_early_mul_dep")
228 (define_bypass 3 "11_mult6,11_mult7"
230 (define_bypass 3 "11_mult6,11_mult7"
232 "arm_no_early_alu_shift_value_dep")
233 (define_bypass 3 "11_mult6,11_mult7"
234 "11_alu_shift_reg_op"
235 "arm_no_early_alu_shift_dep")
236 (define_bypass 3 "11_mult6,11_mult7"
238 "arm_no_early_store_addr_dep")
240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
241 ;; Branch Instructions
242 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
244 ;; These vary greatly depending on their arguments and the results of
245 ;; stat prediction. Cycle count ranges from zero (unconditional branch,
246 ;; folded dynamic prediction) to seven (incorrect predictions, etc). We
247 ;; assume an optimal case for now, because the cost of a cache miss
248 ;; overwhelms the cost of everything else anyhow.
250 (define_insn_reservation "11_branches" 0
251 (and (eq_attr "tune" "arm1136js,arm1136jfs")
252 (eq_attr "type" "branch"))
255 ;; Call latencies are not predictable. A semi-arbitrary very large
256 ;; number is used as "positive infinity" so that everything should be
257 ;; finished by the time of return.
258 (define_insn_reservation "11_call" 32
259 (and (eq_attr "tune" "arm1136js,arm1136jfs")
260 (eq_attr "type" "call"))
263 ;; Branches are predicted. A correctly predicted branch will be no
264 ;; cost, but we're conservative here, and use the timings a
265 ;; late-register would give us.
266 (define_bypass 1 "11_alu_op,11_alu_shift_op"
268 (define_bypass 2 "11_alu_shift_reg_op"
270 (define_bypass 2 "11_load1,11_load2"
272 (define_bypass 3 "11_load34"
275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
276 ;; Load/Store Instructions
277 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
279 ;; The models for load/store instructions do not accurately describe
280 ;; the difference between operations with a base register writeback.
281 ;; These models assume that all memory references hit in dcache. Also,
282 ;; if the PC is one of the registers involved, there are additional stalls
283 ;; not modelled here. Addressing modes are also not modelled.
285 (define_insn_reservation "11_load1" 3
286 (and (eq_attr "tune" "arm1136js,arm1136jfs")
287 (eq_attr "type" "load1"))
288 "l_a+e_1,l_dc1,l_dc2,l_wb")
290 ;; Load byte results are not available until the writeback stage, where
291 ;; the correct byte is extracted.
293 (define_insn_reservation "11_loadb" 4
294 (and (eq_attr "tune" "arm1136js,arm1136jfs")
295 (eq_attr "type" "load_byte"))
296 "l_a+e_1,l_dc1,l_dc2,l_wb")
298 (define_insn_reservation "11_store1" 0
299 (and (eq_attr "tune" "arm1136js,arm1136jfs")
300 (eq_attr "type" "store1"))
301 "l_a+e_1,l_dc1,l_dc2,l_wb")
303 ;; Load/store double words into adjacent registers. The timing and
304 ;; latencies are different depending on whether the address is 64-bit
305 ;; aligned. This model assumes that it is.
306 (define_insn_reservation "11_load2" 3
307 (and (eq_attr "tune" "arm1136js,arm1136jfs")
308 (eq_attr "type" "load2"))
309 "l_a+e_1,l_dc1,l_dc2,l_wb")
311 (define_insn_reservation "11_store2" 0
312 (and (eq_attr "tune" "arm1136js,arm1136jfs")
313 (eq_attr "type" "store2"))
314 "l_a+e_1,l_dc1,l_dc2,l_wb")
316 ;; Load/store multiple registers. Two registers are stored per cycle.
317 ;; Actual timing depends on how many registers are affected, so we
318 ;; optimistically schedule a low latency.
319 (define_insn_reservation "11_load34" 4
320 (and (eq_attr "tune" "arm1136js,arm1136jfs")
321 (eq_attr "type" "load3,load4"))
322 "l_a+e_1,l_dc1*2,l_dc2,l_wb")
324 (define_insn_reservation "11_store34" 0
325 (and (eq_attr "tune" "arm1136js,arm1136jfs")
326 (eq_attr "type" "store3,store4"))
327 "l_a+e_1,l_dc1*2,l_dc2,l_wb")
329 ;; A store can start immediately after an alu op, if that alu op does
330 ;; not provide part of the address to access.
331 (define_bypass 1 "11_alu_op,11_alu_shift_op"
333 "arm_no_early_store_addr_dep")
334 (define_bypass 2 "11_alu_shift_reg_op"
336 "arm_no_early_store_addr_dep")
338 ;; An alu op can start sooner after a load, if that alu op does not
339 ;; have an early register dependency on the load
340 (define_bypass 2 "11_load1"
342 (define_bypass 2 "11_load1"
344 "arm_no_early_alu_shift_value_dep")
345 (define_bypass 2 "11_load1"
346 "11_alu_shift_reg_op"
347 "arm_no_early_alu_shift_dep")
349 (define_bypass 3 "11_loadb"
351 (define_bypass 3 "11_loadb"
353 "arm_no_early_alu_shift_value_dep")
354 (define_bypass 3 "11_loadb"
355 "11_alu_shift_reg_op"
356 "arm_no_early_alu_shift_dep")
358 ;; A mul op can start sooner after a load, if that mul op does not
359 ;; have an early multiply dependency
360 (define_bypass 2 "11_load1"
361 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
362 "arm_no_early_mul_dep")
363 (define_bypass 3 "11_load34"
364 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
365 "arm_no_early_mul_dep")
366 (define_bypass 3 "11_loadb"
367 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
368 "arm_no_early_mul_dep")
370 ;; A store can start sooner after a load, if that load does not
371 ;; produce part of the address to access
372 (define_bypass 2 "11_load1"
374 "arm_no_early_store_addr_dep")
375 (define_bypass 3 "11_loadb"
377 "arm_no_early_store_addr_dep")