1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
;; DFA-based pipeline description for MIPS32 model 74k.
;; Contributed by MIPS Technologies and CodeSourcery.
;;
;; Reference:
;; "MIPS32 74K Microarchitecure Specification Rev. 01.02 Jun 15, 2006"
;; "MIPS32 74Kf Processor Core Datasheet Jun 2, 2006"
;;
;; Copyright (C) 2007 Free Software Foundation, Inc.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your
;; option) any later version.
;; GCC is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3. If not see
;; <http://www.gnu.org/licenses/>.
(define_automaton "r74k_mdu_pipe, r74k_alu_pipe, r74k_agen_pipe, r74k_fpu")
(define_cpu_unit "r74k_mul" "r74k_mdu_pipe")
(define_cpu_unit "r74k_alu" "r74k_alu_pipe")
(define_cpu_unit "r74k_agen" "r74k_agen_pipe")
(define_cpu_unit "r74k_fpu_arith" "r74k_fpu")
(define_cpu_unit "r74k_fpu_ldst" "r74k_fpu")
;; --------------------------------------------------------------
;; Producers
;; --------------------------------------------------------------
;; ALU: Logicals/Arithmetics
;; - Logicals, move (addu/addiu with rt = 0), Set less than,
;; sign extend - 1 cycle
(define_insn_reservation "r74k_int_logical" 1
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "logical,move,signext,slt"))
"r74k_alu")
;; - Arithmetics - 2 cycles
(define_insn_reservation "r74k_int_arith" 2
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "arith,const,shift,clz"))
"r74k_alu")
(define_insn_reservation "r74k_int_nop" 0
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "nop"))
"nothing")
(define_insn_reservation "r74k_int_cmove" 4
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "condmove"))
"r74k_agen*2")
;; MDU: fully pipelined multiplier
;; mult - delivers result to hi/lo in 4 cycle (pipelined)
(define_insn_reservation "r74k_int_mult" 4
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "imul"))
"r74k_alu+r74k_mul")
;; madd, msub - delivers result to hi/lo in 4 cycle (pipelined)
(define_insn_reservation "r74k_int_madd" 4
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "imadd"))
"r74k_alu+r74k_mul")
;; mul - delivers result to general register in 7 cycles
(define_insn_reservation "r74k_int_mul3" 7
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "imul3"))
"r74k_alu+r74k_mul")
;; mfhi, mflo, mflhxu - deliver result to gpr in 7 cycles
(define_insn_reservation "r74k_int_mfhilo" 7
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "mfhilo"))
"r74k_alu+r74k_mul")
;; mthi, mtlo, mtlhx - deliver result to hi/lo, thence madd, handled as bypass
(define_insn_reservation "r74k_int_mthilo" 7
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "mthilo"))
"r74k_alu+r74k_mul")
;; div - default to 50 cycles for 32bit operands. Faster for 8 bit,
;; but is tricky to identify.
(define_insn_reservation "r74k_int_div" 50
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "idiv"))
"r74k_alu+r74k_mul*50")
;; call
(define_insn_reservation "r74k_int_call" 1
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "call"))
"r74k_agen")
;; branch/jump
(define_insn_reservation "r74k_int_jump" 1
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "branch,jump"))
"r74k_agen")
;; loads: lb, lbu, lh, lhu, ll, lw, lwl, lwr, lwpc, lwxs
;; prefetch: prefetch, prefetchx
(define_insn_reservation "r74k_int_load" 3
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "load,prefetch,prefetchx"))
"r74k_agen")
;; stores
(define_insn_reservation "r74k_int_store" 1
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(and (eq_attr "type" "store")
(eq_attr "mode" "!unknown")))
"r74k_agen")
;; Unknowns - Currently these include blockage, consttable and alignment
;; rtls. They do not really affect scheduling latency, (blockage
;; affects scheduling via log links, but not used here).
;;
(define_insn_reservation "r74k_unknown" 1
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "unknown"))
"r74k_alu")
(define_insn_reservation "r74k_multi" 10
(and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
(eq_attr "type" "multi"))
"(r74k_alu+r74k_agen)*10")
;; --------------------------------------------------------------
;; Bypass to Consumer
;; --------------------------------------------------------------
;; load->next use : 3 cycles (Default)
;; load->load base: 4 cycles
;; load->store base: 4 cycles
(define_bypass 4 "r74k_int_load" "r74k_int_load")
(define_bypass 4 "r74k_int_load" "r74k_int_store" "!store_data_bypass_p")
;; logical/move/slt/signext->next use : 1 cycles (Default)
;; logical/move/slt/signext->load base: 2 cycles
;; logical/move/slt/signext->store base: 2 cycles
(define_bypass 2 "r74k_int_logical" "r74k_int_load")
(define_bypass 2 "r74k_int_logical" "r74k_int_store" "!store_data_bypass_p")
;; arith->next use : 2 cycles (Default)
;; arith->load base: 3 cycles
;; arith->store base: 3 cycles
(define_bypass 3 "r74k_int_arith" "r74k_int_load")
(define_bypass 3 "r74k_int_arith" "r74k_int_store" "!store_data_bypass_p")
;; cmove->next use : 4 cycles (Default)
;; cmove->load base: 5 cycles
;; cmove->store base: 5 cycles
(define_bypass 5 "r74k_int_cmove" "r74k_int_load")
(define_bypass 5 "r74k_int_cmove" "r74k_int_store" "!store_data_bypass_p")
;; mult/madd/msub->int_mfhilo : 4 cycles (default)
;; mult->madd/msub : 1 cycles
;; madd/msub->madd/msub : 1 cycles
(define_bypass 1 "r74k_int_mult,r74k_int_mul3" "r74k_int_madd"
"mips_linked_madd_p")
(define_bypass 1 "r74k_int_madd" "r74k_int_madd"
"mips_linked_madd_p")
;; --------------------------------------------------------------
;; Floating Point Instructions
;; --------------------------------------------------------------
;; 74Kf FPU runs at 1:1 or 2:1 core/FPU clock ratio.
;; fadd, fabs, fneg,
(define_insn_reservation "r74kf1_1_fadd" 4
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "fadd,fabs,fneg"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fadd" 8
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "fadd,fabs,fneg"))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fadd" 6
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "fadd,fabs,fneg"))
"r74k_fpu_arith")
;; fmove, fcmove
(define_insn_reservation "r74kf1_1_fmove" 4
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "fmove"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fmove" 8
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "fmove"))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fmove" 6
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "fmove"))
"r74k_fpu_arith")
;; fload
(define_insn_reservation "r74kf1_1_fload" 4
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "fpload,fpidxload"))
"r74k_agen+r74k_fpu_ldst")
(define_insn_reservation "r74kf2_1_fload" 8
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "fpload,fpidxload"))
"r74k_agen+(r74k_fpu_ldst*2)")
(define_insn_reservation "r74kf3_2_fload" 6
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "fpload,fpidxload"))
"r74k_agen+r74k_fpu_ldst")
;; fstore
(define_insn_reservation "r74kf1_1_fstore" 1
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "fpstore,fpidxstore"))
"r74k_agen+r74k_fpu_ldst")
(define_insn_reservation "r74kf2_1_fstore" 2
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "fpstore,fpidxstore"))
"r74k_agen+(r74k_fpu_ldst*2)")
(define_insn_reservation "r74kf3_2_fstore" 1
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "fpstore,fpidxstore"))
"r74k_agen+r74k_fpu_ldst")
;; fmul, fmadd
(define_insn_reservation "r74kf1_1_fmul_sf" 4
(and (eq_attr "cpu" "74kf1_1")
(and (eq_attr "type" "fmul,fmadd")
(eq_attr "mode" "SF")))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fmul_sf" 8
(and (eq_attr "cpu" "74kf2_1")
(and (eq_attr "type" "fmul,fmadd")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fmul_sf" 6
(and (eq_attr "cpu" "74kf3_2")
(and (eq_attr "type" "fmul,fmadd")
(eq_attr "mode" "SF")))
"r74k_fpu_arith")
(define_insn_reservation "r74kf1_1_fmul_df" 5
(and (eq_attr "cpu" "74kf1_1")
(and (eq_attr "type" "fmul,fmadd")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf2_1_fmul_df" 10
(and (eq_attr "cpu" "74kf2_1")
(and (eq_attr "type" "fmul,fmadd")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*4")
(define_insn_reservation "r74kf3_2_fmul_df" 7
(and (eq_attr "cpu" "74kf3_2")
(and (eq_attr "type" "fmul,fmadd")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*2")
;; fdiv, fsqrt
(define_insn_reservation "r74kf1_1_fdiv_sf" 17
(and (eq_attr "cpu" "74kf1_1")
(and (eq_attr "type" "fdiv,fsqrt")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*14")
(define_insn_reservation "r74kf2_1_fdiv_sf" 34
(and (eq_attr "cpu" "74kf2_1")
(and (eq_attr "type" "fdiv,fsqrt")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*28")
(define_insn_reservation "r74kf3_2_fdiv_sf" 25
(and (eq_attr "cpu" "74kf3_2")
(and (eq_attr "type" "fdiv,fsqrt")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*14")
(define_insn_reservation "r74kf1_1_fdiv_df" 32
(and (eq_attr "cpu" "74kf1_1")
(and (eq_attr "type" "fdiv,fsqrt")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*29")
(define_insn_reservation "r74kf2_1_fdiv_df" 64
(and (eq_attr "cpu" "74kf2_1")
(and (eq_attr "type" "fdiv,fsqrt")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*58")
(define_insn_reservation "r74kf3_2_fdiv_df" 48
(and (eq_attr "cpu" "74kf3_2")
(and (eq_attr "type" "fdiv,fsqrt")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*29")
;; frsqrt
(define_insn_reservation "r74kf1_1_frsqrt_sf" 17
(and (eq_attr "cpu" "74kf1_1")
(and (eq_attr "type" "frsqrt")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*14")
(define_insn_reservation "r74kf2_1_frsqrt_sf" 34
(and (eq_attr "cpu" "74kf2_1")
(and (eq_attr "type" "frsqrt")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*28")
(define_insn_reservation "r74kf3_2_frsqrt_sf" 25
(and (eq_attr "cpu" "74kf3_2")
(and (eq_attr "type" "frsqrt")
(eq_attr "mode" "SF")))
"r74k_fpu_arith*14")
(define_insn_reservation "r74kf1_1_frsqrt_df" 36
(and (eq_attr "cpu" "74kf1_1")
(and (eq_attr "type" "frsqrt")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*31")
(define_insn_reservation "r74kf2_1_frsqrt_df" 72
(and (eq_attr "cpu" "74kf2_1")
(and (eq_attr "type" "frsqrt")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*62")
(define_insn_reservation "r74kf3_2_frsqrt_df" 54
(and (eq_attr "cpu" "74kf3_2")
(and (eq_attr "type" "frsqrt")
(eq_attr "mode" "DF")))
"r74k_fpu_arith*31")
;; fcmp
(define_insn_reservation "r74kf1_1_fcmp" 4
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "fcmp"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fcmp" 8
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "fcmp"))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fcmp" 6
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "fcmp"))
"r74k_fpu_arith")
;; fcvt
(define_insn_reservation "r74kf1_1_fcvt" 4
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "fcvt"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fcvt" 8
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "fcvt"))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fcvt" 6
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "fcvt"))
"r74k_fpu_arith")
;; fxfer (MTC1, DMTC1: latency is 4) (MFC1, DMFC1: latency is 1)
(define_insn_reservation "r74kf1_1_fxfer_to_c1" 4
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "mtc"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fxfer_to_c1" 8
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "mtc"))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fxfer_to_c1" 6
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "mtc"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf1_1_fxfer_from_c1" 1
(and (eq_attr "cpu" "74kf1_1")
(eq_attr "type" "mfc"))
"r74k_fpu_arith")
(define_insn_reservation "r74kf2_1_fxfer_from_c1" 2
(and (eq_attr "cpu" "74kf2_1")
(eq_attr "type" "mfc"))
"r74k_fpu_arith*2")
(define_insn_reservation "r74kf3_2_fxfer_from_c1" 1
(and (eq_attr "cpu" "74kf3_2")
(eq_attr "type" "mfc"))
"r74k_fpu_arith")
|