1 ;; ARM 1136J[F]-S Pipeline Description
2 ;; Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free
19 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 ;; 02110-1301, USA. */
22 ;; These descriptions are based on the information contained in the
23 ;; ARM1136JF-S Technical Reference Manual, Copyright (c) 2003 ARM
27 ;; This automaton provides a pipeline description for the ARM
28 ;; 1136J-S and 1136JF-S cores.
30 ;; The model given here assumes that the condition for all conditional
31 ;; instructions is "true", i.e., that all of the instructions are
34 (define_automaton "arm1136jfs")
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;; There are three distinct pipelines (page 1-26 and following):
42 ;; - A 4-stage decode pipeline, shared by all three. It has fetch (1),
43 ;; fetch (2), decode, and issue stages. Since this is always involved,
44 ;; we do not model it in the scheduler.
46 ;; - A 4-stage ALU pipeline. It has shifter, ALU (main integer operations),
47 ;; and saturation stages. The fourth stage is writeback; see below.
49 ;; - A 4-stage multiply-accumulate pipeline. It has three stages, called
50 ;; MAC1 through MAC3, and a fourth writeback stage.
52 ;; The 4th-stage writeback is shared between the ALU and MAC pipelines,
53 ;; which operate in lockstep. Results from either pipeline will be
54 ;; moved into the writeback stage. Because the two pipelines operate
55 ;; in lockstep, we schedule them as a single "execute" pipeline.
57 ;; - A 4-stage LSU pipeline. It has address generation, data cache (1),
58 ;; data cache (2), and writeback stages. (Note that this pipeline,
59 ;; including the writeback stage, is independent from the ALU & LSU pipes.)
61 (define_cpu_unit "e_1,e_2,e_3,e_wb" "arm1136jfs") ; ALU and MAC
62 ; e_1 = Sh/Mac1, e_2 = ALU/Mac2, e_3 = SAT/Mac3
63 (define_cpu_unit "l_a,l_dc1,l_dc2,l_wb" "arm1136jfs") ; Load/Store
65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
69 ;; ALU instructions require eight cycles to execute, and use the ALU
70 ;; pipeline in each of the eight stages. The results are available
71 ;; after the alu stage has finished.
73 ;; If the destination register is the PC, the pipelines are stalled
74 ;; for several cycles. That case is not modelled here.
76 ;; ALU operations with no shifted operand
77 (define_insn_reservation "11_alu_op" 2
78 (and (eq_attr "tune" "arm1136js,arm1136jfs")
79 (eq_attr "type" "alu"))
82 ;; ALU operations with a shift-by-constant operand
83 (define_insn_reservation "11_alu_shift_op" 2
84 (and (eq_attr "tune" "arm1136js,arm1136jfs")
85 (eq_attr "type" "alu_shift"))
88 ;; ALU operations with a shift-by-register operand
89 ;; These really stall in the decoder, in order to read
90 ;; the shift value in a second cycle. Pretend we take two cycles in
92 (define_insn_reservation "11_alu_shift_reg_op" 3
93 (and (eq_attr "tune" "arm1136js,arm1136jfs")
94 (eq_attr "type" "alu_shift_reg"))
97 ;; alu_ops can start sooner, if there is no shifter dependency
98 (define_bypass 1 "11_alu_op,11_alu_shift_op"
100 (define_bypass 1 "11_alu_op,11_alu_shift_op"
102 "arm_no_early_alu_shift_value_dep")
103 (define_bypass 1 "11_alu_op,11_alu_shift_op"
104 "11_alu_shift_reg_op"
105 "arm_no_early_alu_shift_dep")
106 (define_bypass 2 "11_alu_shift_reg_op"
108 (define_bypass 2 "11_alu_shift_reg_op"
110 "arm_no_early_alu_shift_value_dep")
111 (define_bypass 2 "11_alu_shift_reg_op"
112 "11_alu_shift_reg_op"
113 "arm_no_early_alu_shift_dep")
115 (define_bypass 1 "11_alu_op,11_alu_shift_op"
116 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
117 "arm_no_early_mul_dep")
118 (define_bypass 2 "11_alu_shift_reg_op"
119 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
120 "arm_no_early_mul_dep")
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 ;; Multiplication Instructions
124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126 ;; Multiplication instructions loop in the first two execute stages until
127 ;; the instruction has been passed through the multiplier array enough
130 ;; Multiply and multiply-accumulate results are available after four stages.
131 (define_insn_reservation "11_mult1" 4
132 (and (eq_attr "tune" "arm1136js,arm1136jfs")
133 (eq_attr "insn" "mul,mla"))
134 "e_1*2,e_2,e_3,e_wb")
136 ;; The *S variants set the condition flags, which requires three more cycles.
137 (define_insn_reservation "11_mult2" 4
138 (and (eq_attr "tune" "arm1136js,arm1136jfs")
139 (eq_attr "insn" "muls,mlas"))
140 "e_1*2,e_2,e_3,e_wb")
142 (define_bypass 3 "11_mult1,11_mult2"
143 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
144 "arm_no_early_mul_dep")
145 (define_bypass 3 "11_mult1,11_mult2"
147 (define_bypass 3 "11_mult1,11_mult2"
149 "arm_no_early_alu_shift_value_dep")
150 (define_bypass 3 "11_mult1,11_mult2"
151 "11_alu_shift_reg_op"
152 "arm_no_early_alu_shift_dep")
153 (define_bypass 3 "11_mult1,11_mult2"
155 "arm_no_early_store_addr_dep")
157 ;; Signed and unsigned multiply long results are available across two cycles;
158 ;; the less significant word is available one cycle before the more significant
159 ;; word. Here we conservatively wait until both are available, which is
160 ;; after three iterations and the memory cycle. The same is also true of
161 ;; the two multiply-accumulate instructions.
162 (define_insn_reservation "11_mult3" 5
163 (and (eq_attr "tune" "arm1136js,arm1136jfs")
164 (eq_attr "insn" "smull,umull,smlal,umlal"))
165 "e_1*3,e_2,e_3,e_wb*2")
167 ;; The *S variants set the condition flags, which requires three more cycles.
168 (define_insn_reservation "11_mult4" 5
169 (and (eq_attr "tune" "arm1136js,arm1136jfs")
170 (eq_attr "insn" "smulls,umulls,smlals,umlals"))
171 "e_1*3,e_2,e_3,e_wb*2")
173 (define_bypass 4 "11_mult3,11_mult4"
174 "11_mult1,11_mult2,11_mult3,11_mult4,11_mult5,11_mult6,11_mult7"
175 "arm_no_early_mul_dep")
176 (define_bypass 4 "11_mult3,11_mult4"
178 (define_bypass 4 "11_mult3,11_mult4"
180 "arm_no_early_alu_shift_value_dep")
181 (define_bypass 4 "11_mult3,11_mult4"
182 "11_alu_shift_reg_op"
183 "arm_no_early_alu_shift_dep")
184 (define_bypass 4 "11_mult3,11_mult4"
186 "arm_no_early_store_addr_dep")
188 ;; Various 16x16->32 multiplies and multiply-accumulates, using combinations
189 ;; of high and low halves of the argument registers. They take a single
190 ;; pass through the pipeline and make the result available after three
192 (define_insn_reservation "11_mult5" 3
193 (and (eq_attr "tune" "arm1136js,arm1136jfs")
194 (eq_attr "insn" "smulxy,smlaxy,smulwy,smlawy,smuad,smuadx,smlad,smladx,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 "insn" "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 "insn" "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")