1 ;; DFA-based pipeline descriptions for MIPS Technologies 24K core.
2 ;; Contributed by Chao-ying Fu (fu@mips.com), Nigel Stephens (nigel@mips.com)
3 ;; and David Ung (davidu@mips.com)
5 ;; The 24kf2_1 is a single-issue processor with a half-clocked fpu.
6 ;; The 24kf1_1 is 24k with 1:1 clocked fpu.
9 ;; "MIPS32 24K Processor Core Family Software User's Manual, Rev 3.04."
11 ;; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
13 ;; This file is part of GCC.
15 ;; GCC is free software; you can redistribute it and/or modify it
16 ;; under the terms of the GNU General Public License as published
17 ;; by the Free Software Foundation; either version 3, or (at your
18 ;; option) any later version.
20 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
21 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
23 ;; License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GCC; see the file COPYING3. If not see
27 ;; <http://www.gnu.org/licenses/>.
29 (define_automaton "r24k_cpu, r24k_mdu, r24k_fpu")
31 ;; Integer execution unit.
32 (define_cpu_unit "r24k_iss" "r24k_cpu")
33 (define_cpu_unit "r24k_ixu_arith" "r24k_cpu")
34 (define_cpu_unit "r24k_mul3a" "r24k_mdu")
35 (define_cpu_unit "r24k_mul3b" "r24k_mdu")
36 (define_cpu_unit "r24k_mul3c" "r24k_mdu")
38 ;; --------------------------------------------------------------
40 ;; --------------------------------------------------------------
42 ;; 1. Loads: lb, lbu, lh, lhu, ll, lw, lwl, lwr, lwpc, lwxs
43 (define_insn_reservation "r24k_int_load" 2
44 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
45 (eq_attr "type" "load"))
46 "r24k_iss+r24k_ixu_arith")
49 ;; 2. Arithmetic: add, addi, addiu, addiupc, addu, and, andi, clo, clz,
50 ;; ext, ins, lui, movn, movz, nor, or, ori, rotr, rotrv, seb, seh, sll,
51 ;; sllv, slt, slti, sltiu, sltu, sra, srav, srl, srlv, sub, subu, wsbh,
53 ;; (movn/movz is not matched, we'll need to split condmov to
54 ;; differentiate between integer/float moves)
55 (define_insn_reservation "r24k_int_arith" 1
56 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
57 (eq_attr "type" "arith,const,logical,move,nop,shift,signext,slt"))
58 "r24k_iss+r24k_ixu_arith")
61 ;; 3. Links: bgezal, bgezall, bltzal, bltzall, jal, jalr, jalx
62 ;; 3a. jr/jalr consumer
63 (define_insn_reservation "r24k_int_jump" 1
64 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
65 (eq_attr "type" "call,jump"))
66 "r24k_iss+r24k_ixu_arith")
68 ;; 3b. branch consumer
69 (define_insn_reservation "r24k_int_branch" 1
70 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
71 (eq_attr "type" "branch"))
72 "r24k_iss+r24k_ixu_arith")
75 ;; 4. MDU: fully pipelined multiplier
76 ;; mult - delivers result to hi/lo in 1 cycle (pipelined)
77 (define_insn_reservation "r24k_int_mult" 1
78 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
79 (eq_attr "type" "imul"))
80 "r24k_iss+(r24k_mul3a|r24k_mul3b|r24k_mul3c)")
82 ;; madd, msub - delivers result to hi/lo in 1 cycle (pipelined)
83 (define_insn_reservation "r24k_int_madd" 1
84 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
85 (eq_attr "type" "imadd"))
86 "r24k_iss+(r24k_mul3a|r24k_mul3b|r24k_mul3c)")
88 ;; mul - delivers result to gpr in 5 cycles
89 (define_insn_reservation "r24k_int_mul3" 5
90 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
91 (eq_attr "type" "imul3"))
92 "r24k_iss+(r24k_mul3a|r24k_mul3b|r24k_mul3c)*5")
94 ;; mfhi, mflo, mflhxu - deliver result to gpr in 5 cycles
95 (define_insn_reservation "r24k_int_mfhilo" 5
96 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
97 (eq_attr "type" "mfhi,mflo"))
98 "r24k_iss+(r24k_mul3a|r24k_mul3b|r24k_mul3c)")
100 ;; mthi, mtlo, mtlhx - deliver result to hi/lo, thence madd, handled as bypass
101 (define_insn_reservation "r24k_int_mthilo" 1
102 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
103 (eq_attr "type" "mthi,mtlo"))
104 "r24k_iss+(r24k_mul3a|r24k_mul3b|r24k_mul3c)")
106 ;; div - default to 36 cycles for 32bit operands. Faster for 24bit, 16bit and
107 ;; 8bit, but is tricky to identify.
108 (define_insn_reservation "r24k_int_div" 36
109 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
110 (eq_attr "type" "idiv"))
111 "r24k_iss+(r24k_mul3a+r24k_mul3b+r24k_mul3c)*36")
114 ;; 5. Cop: cfc1, di, ei, mfc0, mtc0
115 ;; (Disabled until we add proper cop0 support)
116 ;;(define_insn_reservation "r24k_int_cop" 3
117 ;; (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
118 ;; (eq_attr "type" "cop0"))
119 ;; "r24k_iss+r24k_ixu_arith")
123 (define_insn_reservation "r24k_int_store" 1
124 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
125 (and (eq_attr "type" "store")
126 (eq_attr "mode" "!unknown")))
127 "r24k_iss+r24k_ixu_arith")
129 ;; 6.1 Special case - matches the cprestore pattern which don't set the mode
130 ;; attrib. This avoids being set as r24k_int_store and have it checked
131 ;; against store_data_bypass_p, which would then fail because cprestore
132 ;; does not have a normal SET pattern.
133 (define_insn_reservation "r24k_unknown_store" 1
134 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
135 (and (eq_attr "type" "store")
136 (eq_attr "mode" "unknown")))
137 "r24k_iss+r24k_ixu_arith")
140 ;; 7. Multiple instructions
141 (define_insn_reservation "r24k_int_multi" 1
142 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
143 (eq_attr "type" "multi"))
144 "r24k_iss+r24k_ixu_arith+r24k_fpu_arith+(r24k_mul3a+r24k_mul3b+r24k_mul3c)")
147 ;; 8. Unknowns - Currently these include blockage, consttable and alignment
148 ;; rtls. They do not really affect scheduling latency, (blockage affects
149 ;; scheduling via log links, but not used here).
150 (define_insn_reservation "r24k_int_unknown" 0
151 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
152 (eq_attr "type" "unknown,atomic,syncloop"))
157 (define_insn_reservation "r24k_int_prefetch" 1
158 (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
159 (eq_attr "type" "prefetch,prefetchx"))
160 "r24k_iss+r24k_ixu_arith")
163 ;; --------------------------------------------------------------
164 ;; Bypass to Consumer
165 ;; --------------------------------------------------------------
167 ;; load->next use : 2 cycles (Default)
168 ;; load->load base: 3 cycles
169 ;; load->store base: 3 cycles
170 ;; load->prefetch: 3 cycles
171 (define_bypass 3 "r24k_int_load" "r24k_int_load")
172 (define_bypass 3 "r24k_int_load" "r24k_int_store" "!store_data_bypass_p")
173 (define_bypass 3 "r24k_int_load" "r24k_int_prefetch")
175 ;; arith->next use : 1 cycles (Default)
176 ;; arith->load base: 2 cycles
177 ;; arith->store base: 2 cycles
178 ;; arith->prefetch: 2 cycles
179 (define_bypass 2 "r24k_int_arith" "r24k_int_load")
180 (define_bypass 2 "r24k_int_arith" "r24k_int_store" "!store_data_bypass_p")
181 (define_bypass 2 "r24k_int_arith" "r24k_int_prefetch")
183 ;; mul3->next use : 5 cycles (default)
184 ;; mul3->l/s base : 6 cycles
185 ;; mul3->prefetch : 6 cycles
186 (define_bypass 6 "r24k_int_mul3" "r24k_int_load")
187 (define_bypass 6 "r24k_int_mul3" "r24k_int_store" "!store_data_bypass_p")
188 (define_bypass 6 "r24k_int_mul3" "r24k_int_prefetch")
190 ;; mul3->madd/msub : 1 cycle
191 (define_bypass 1 "r24k_int_mul3" "r24k_int_madd" "mips_linked_madd_p")
193 ;; mfhilo->next use : 5 cycles (default)
194 ;; mfhilo->l/s base : 6 cycles
195 ;; mfhilo->prefetch : 6 cycles
196 ;; mthilo->madd/msub : 2 cycle (only for mthi/lo not mfhi/lo)
197 (define_bypass 6 "r24k_int_mfhilo" "r24k_int_load")
198 (define_bypass 6 "r24k_int_mfhilo" "r24k_int_store" "!store_data_bypass_p")
199 (define_bypass 6 "r24k_int_mfhilo" "r24k_int_prefetch")
200 (define_bypass 2 "r24k_int_mthilo" "r24k_int_madd")
202 ;; cop->next use : 3 cycles (Default)
203 ;; cop->l/s base : 4 cycles
204 ;; (define_bypass 4 "r24k_int_cop" "r24k_int_load")
205 ;; (define_bypass 4 "r24k_int_cop" "r24k_int_store" "!store_data_bypass_p")
207 ;; multi->next use : 1 cycles (Default)
208 ;; multi->l/s base : 2 cycles
209 ;; multi->prefetch : 2 cycles
210 (define_bypass 2 "r24k_int_multi" "r24k_int_load")
211 (define_bypass 2 "r24k_int_multi" "r24k_int_store" "!store_data_bypass_p")
212 (define_bypass 2 "r24k_int_multi" "r24k_int_prefetch")
215 ;; --------------------------------------------------------------
216 ;; Floating Point Instructions
217 ;; --------------------------------------------------------------
219 (define_cpu_unit "r24k_fpu_arith" "r24k_fpu")
221 ;; The 24k is a single issue cpu, and the fpu runs at half clock speed,
222 ;; so each fpu instruction ties up the shared instruction scheduler for
223 ;; 1 cycle, and the fpu scheduler for 2 cycles.
225 ;; These timings are therefore twice the values in the 24K manual,
226 ;; which are quoted in fpu clocks.
228 ;; The 24kf1_1 is a 24k configured with 1:1 cpu and fpu, so use
229 ;; the unscaled timings
231 (define_reservation "r24kf2_1_fpu_iss" "r24k_iss+(r24k_fpu_arith*2)")
234 (define_insn_reservation "r24kf2_1_fadd" 8
235 (and (eq_attr "cpu" "24kf2_1")
236 (eq_attr "type" "fadd,fabs,fneg"))
240 (define_insn_reservation "r24kf2_1_fmove" 8
241 (and (eq_attr "cpu" "24kf2_1")
242 (eq_attr "type" "fmove,condmove"))
246 (define_insn_reservation "r24kf2_1_fload" 6
247 (and (eq_attr "cpu" "24kf2_1")
248 (eq_attr "type" "fpload,fpidxload"))
252 (define_insn_reservation "r24kf2_1_fstore" 2
253 (and (eq_attr "cpu" "24kf2_1")
254 (eq_attr "type" "fpstore"))
258 (define_insn_reservation "r24kf2_1_fmul_sf" 8
259 (and (eq_attr "cpu" "24kf2_1")
260 (and (eq_attr "type" "fmul,fmadd")
261 (eq_attr "mode" "SF")))
264 (define_insn_reservation "r24kf2_1_fmul_df" 10
265 (and (eq_attr "cpu" "24kf2_1")
266 (and (eq_attr "type" "fmul,fmadd")
267 (eq_attr "mode" "DF")))
268 "r24kf2_1_fpu_iss,(r24k_fpu_arith*2)")
271 ;; fdiv, fsqrt, frsqrt
272 (define_insn_reservation "r24kf2_1_fdiv_sf" 34
273 (and (eq_attr "cpu" "24kf2_1")
274 (and (eq_attr "type" "fdiv,fsqrt,frsqrt")
275 (eq_attr "mode" "SF")))
276 "r24kf2_1_fpu_iss,(r24k_fpu_arith*26)")
278 (define_insn_reservation "r24kf2_1_fdiv_df" 64
279 (and (eq_attr "cpu" "24kf2_1")
280 (and (eq_attr "type" "fdiv,fsqrt")
281 (eq_attr "mode" "DF")))
282 "r24kf2_1_fpu_iss,(r24k_fpu_arith*56)")
285 (define_insn_reservation "r24kf2_1_frsqrt_df" 70
286 (and (eq_attr "cpu" "24kf2_1")
287 (and (eq_attr "type" "frsqrt")
288 (eq_attr "mode" "DF")))
289 "r24kf2_1_fpu_iss,(r24k_fpu_arith*60)")
292 (define_insn_reservation "r24kf2_1_fcmp" 4
293 (and (eq_attr "cpu" "24kf2_1")
294 (eq_attr "type" "fcmp"))
297 ;; fcmp -> movf.fmt & movt.fmt bypass (dependency must be on the condition)
298 (define_bypass 2 "r24kf2_1_fcmp" "r24kf2_1_fmove")
300 ;; fcvt (cvt.d.s, cvt.[sd].[wl])
301 (define_insn_reservation "r24kf2_1_fcvt_i2f_s2d" 8
302 (and (eq_attr "cpu" "24kf2_1")
303 (and (eq_attr "type" "fcvt")
304 (eq_attr "cnv_mode" "I2S,I2D,S2D")))
308 (define_insn_reservation "r24kf2_1_fcvt_s2d" 12
309 (and (eq_attr "cpu" "24kf2_1")
310 (and (eq_attr "type" "fcvt")
311 (eq_attr "cnv_mode" "D2S")))
314 ;; fcvt (cvt.[wl].[sd], etc)
315 (define_insn_reservation "r24kf2_1_fcvt_f2i" 10
316 (and (eq_attr "cpu" "24kf2_1")
317 (and (eq_attr "type" "fcvt")
318 (eq_attr "cnv_mode" "S2I,D2I")))
321 ;; fxfer (mfc1, mfhc1, mtc1, mthc1)
322 (define_insn_reservation "r24kf2_1_fxfer" 4
323 (and (eq_attr "cpu" "24kf2_1")
324 (eq_attr "type" "mfc,mtc"))
327 ;; --------------------------------------------------------------
328 ;; Bypass to Consumer
329 ;; --------------------------------------------------------------
330 ;; r24kf2_1_fcvt_f2i->l/s base : 11 cycles
331 ;; r24kf2_1_fcvt_f2i->prefetch : 11 cycles
332 (define_bypass 11 "r24kf2_1_fcvt_f2i" "r24k_int_load")
333 (define_bypass 11 "r24kf2_1_fcvt_f2i" "r24k_int_store" "!store_data_bypass_p")
334 (define_bypass 11 "r24kf2_1_fcvt_f2i" "r24k_int_prefetch")
336 ;; r24kf2_1_fxfer->l/s base : 5 cycles
337 ;; r24kf2_1_fxfer->prefetch : 5 cycles
338 (define_bypass 5 "r24kf2_1_fxfer" "r24k_int_load")
339 (define_bypass 5 "r24kf2_1_fxfer" "r24k_int_store" "!store_data_bypass_p")
340 (define_bypass 5 "r24kf2_1_fxfer" "r24k_int_prefetch")
342 ;; --------------------------------------------------------------
343 ;; The 24kf1_1 is a 24k configured with 1:1 cpu and fpu, so use
344 ;; the unscaled timings
345 ;; --------------------------------------------------------------
347 (define_reservation "r24kf1_1_fpu_iss" "r24k_iss+r24k_fpu_arith")
350 (define_insn_reservation "r24kf1_1_fadd" 4
351 (and (eq_attr "cpu" "24kf1_1")
352 (eq_attr "type" "fadd,fabs,fneg"))
356 (define_insn_reservation "r24kf1_1_fmove" 4
357 (and (eq_attr "cpu" "24kf1_1")
358 (eq_attr "type" "fmove,condmove"))
362 (define_insn_reservation "r24kf1_1_fload" 3
363 (and (eq_attr "cpu" "24kf1_1")
364 (eq_attr "type" "fpload,fpidxload"))
368 (define_insn_reservation "r24kf1_1_fstore" 1
369 (and (eq_attr "cpu" "24kf1_1")
370 (eq_attr "type" "fpstore"))
374 (define_insn_reservation "r24kf1_1_fmul_sf" 4
375 (and (eq_attr "cpu" "24kf1_1")
376 (and (eq_attr "type" "fmul,fmadd")
377 (eq_attr "mode" "SF")))
380 (define_insn_reservation "r24kf1_1_fmul_df" 5
381 (and (eq_attr "cpu" "24kf1_1")
382 (and (eq_attr "type" "fmul,fmadd")
383 (eq_attr "mode" "DF")))
384 "r24kf1_1_fpu_iss,r24k_fpu_arith")
387 ;; fdiv, fsqrt, frsqrt
388 (define_insn_reservation "r24kf1_1_fdiv_sf" 17
389 (and (eq_attr "cpu" "24kf1_1")
390 (and (eq_attr "type" "fdiv,fsqrt,frsqrt")
391 (eq_attr "mode" "SF")))
392 "r24kf1_1_fpu_iss,(r24k_fpu_arith*13)")
394 (define_insn_reservation "r24kf1_1_fdiv_df" 32
395 (and (eq_attr "cpu" "24kf1_1")
396 (and (eq_attr "type" "fdiv,fsqrt")
397 (eq_attr "mode" "DF")))
398 "r24kf1_1_fpu_iss,(r24k_fpu_arith*28)")
401 (define_insn_reservation "r24kf1_1_frsqrt_df" 35
402 (and (eq_attr "cpu" "24kf1_1")
403 (and (eq_attr "type" "frsqrt")
404 (eq_attr "mode" "DF")))
405 "r24kf1_1_fpu_iss,(r24k_fpu_arith*30)")
408 (define_insn_reservation "r24kf1_1_fcmp" 2
409 (and (eq_attr "cpu" "24kf1_1")
410 (eq_attr "type" "fcmp"))
413 ;; fcmp -> movf.fmt & movt.fmt bypass (dependency must be on the condition)
414 (define_bypass 1 "r24kf1_1_fcmp" "r24kf1_1_fmove")
416 ;; fcvt (cvt.d.s, cvt.[sd].[wl])
417 (define_insn_reservation "r24kf1_1_fcvt_i2f_s2d" 4
418 (and (eq_attr "cpu" "24kf1_1")
419 (and (eq_attr "type" "fcvt")
420 (eq_attr "cnv_mode" "I2S,I2D,S2D")))
424 (define_insn_reservation "r24kf1_1_fcvt_s2d" 6
425 (and (eq_attr "cpu" "24kf1_1")
426 (and (eq_attr "type" "fcvt")
427 (eq_attr "cnv_mode" "D2S")))
430 ;; fcvt (cvt.[wl].[sd], etc)
431 (define_insn_reservation "r24kf1_1_fcvt_f2i" 5
432 (and (eq_attr "cpu" "24kf1_1")
433 (and (eq_attr "type" "fcvt")
434 (eq_attr "cnv_mode" "S2I,D2I")))
437 ;; fxfer (mfc1, mfhc1, mtc1, mthc1)
438 (define_insn_reservation "r24kf1_1_fxfer" 2
439 (and (eq_attr "cpu" "24kf1_1")
440 (eq_attr "type" "mfc,mtc"))
443 ;; --------------------------------------------------------------
444 ;; Bypass to Consumer
445 ;; --------------------------------------------------------------
446 ;; r24kf1_1_fcvt_f2i->l/s base : 6 cycles
447 ;; r24kf1_1_fcvt_f2i->prefetch : 6 cycles
448 (define_bypass 6 "r24kf1_1_fcvt_f2i" "r24k_int_load")
449 (define_bypass 6 "r24kf1_1_fcvt_f2i" "r24k_int_store" "!store_data_bypass_p")
450 (define_bypass 6 "r24kf1_1_fcvt_f2i" "r24k_int_prefetch")
452 ;; r24kf1_1_fxfer->l/s base : 3 cycles
453 ;; r24kf1_1_fxfer->prefetch : 3 cycles
454 (define_bypass 3 "r24kf1_1_fxfer" "r24k_int_load")
455 (define_bypass 3 "r24kf1_1_fxfer" "r24k_int_store" "!store_data_bypass_p")
456 (define_bypass 3 "r24kf1_1_fxfer" "r24k_int_prefetch")