OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [sh/] [sh4.md] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
;; DFA scheduling description for SH4.
2
;; Copyright (C) 2004, 2007 Free Software Foundation, Inc.
3
 
4
;; This file is part of GCC.
5
 
6
;; GCC is free software; you can redistribute it and/or modify
7
;; it under the terms of the GNU General Public License as published by
8
;; the Free Software Foundation; either version 3, or (at your option)
9
;; any later version.
10
 
11
;; GCC is distributed in the hope that it will be useful,
12
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
;; GNU General Public License for more details.
15
 
16
;; You should have received a copy of the GNU General Public License
17
;; along with GCC; see the file COPYING3.  If not see
18
;; .
19
 
20
;; Load and store instructions save a cycle if they are aligned on a
21
;; four byte boundary.  Using a function unit for stores encourages
22
;; gcc to separate load and store instructions by one instruction,
23
;; which makes it more likely that the linker will be able to word
24
;; align them when relaxing.
25
 
26
;; The following description models the SH4 pipeline using the DFA based
27
;; scheduler.  The DFA based description is better way to model a
28
;; superscalar pipeline as compared to function unit reservation model.
29
;; 1. The function unit based model is oriented to describe at most one
30
;;    unit reservation by each insn. It is difficult to model unit reservations
31
;;    in multiple pipeline units by same insn.  This can be done using DFA
32
;;    based description.
33
;; 2. The execution performance of DFA based scheduler does not depend on
34
;;    processor complexity.
35
;; 3. Writing all unit reservations for an instruction class is a more natural
36
;;    description of the pipeline and makes the interface to the hazard
37
;;    recognizer simpler than the old function unit based model.
38
;; 4. The DFA model is richer and is a part of greater overall framework
39
;;    of RCSP.
40
 
41
 
42
;; Two automata are defined to reduce number of states
43
;; which a single large automaton will have. (Factoring)
44
 
45
(define_automaton "inst_pipeline,fpu_pipe")
46
 
47
;; This unit is basically the decode unit of the processor.
48
;; Since SH4 is a dual issue machine,it is as if there are two
49
;; units so that any insn can be processed by either one
50
;; of the decoding unit.
51
 
52
(define_cpu_unit "pipe_01,pipe_02" "inst_pipeline")
53
 
54
 
55
;; The fixed point arithmetic calculator(?? EX Unit).
56
 
57
(define_cpu_unit  "int" "inst_pipeline")
58
 
59
;; f1_1 and f1_2 are floating point units.Actually there is
60
;; a f1 unit which can overlap with other f1 unit but
61
;; not another F1 unit.It is as though there were two
62
;; f1 units.
63
 
64
(define_cpu_unit "f1_1,f1_2" "fpu_pipe")
65
 
66
;; The floating point units (except FS - F2 always precedes it.)
67
 
68
(define_cpu_unit "F0,F1,F2,F3" "fpu_pipe")
69
 
70
;; This is basically the MA unit of SH4
71
;; used in LOAD/STORE pipeline.
72
 
73
(define_cpu_unit "memory" "inst_pipeline")
74
 
75
;; However, there are LS group insns that don't use it, even ones that
76
;; complete in 0 cycles.  So we use an extra unit for the issue of LS insns.
77
(define_cpu_unit "load_store" "inst_pipeline")
78
 
79
;; The address calculator used for branch instructions.
80
;; This will be reserved after "issue" of branch instructions
81
;; and this is to make sure that no two branch instructions
82
;; can be issued in parallel.
83
 
84
(define_cpu_unit "pcr_addrcalc" "inst_pipeline")
85
 
86
;; ----------------------------------------------------
87
;; This reservation is to simplify the dual issue description.
88
 
89
(define_reservation  "issue"  "pipe_01|pipe_02")
90
 
91
;; This is to express the locking of D stage.
92
;; Note that the issue of a CO group insn also effectively locks the D stage.
93
 
94
(define_reservation  "d_lock" "pipe_01+pipe_02")
95
 
96
;; Every FE instruction but fipr / ftrv starts with issue and this.
97
(define_reservation "F01" "F0+F1")
98
 
99
;; This is to simplify description where F1,F2,FS
100
;; are used simultaneously.
101
 
102
(define_reservation "fpu" "F1+F2")
103
 
104
;; This is to highlight the fact that f1
105
;; cannot overlap with F1.
106
 
107
(exclusion_set  "f1_1,f1_2" "F1")
108
 
109
(define_insn_reservation "nil" 0 (eq_attr "type" "nil") "nothing")
110
 
111
;; Although reg moves have a latency of zero
112
;; we need to highlight that they use D stage
113
;; for one cycle.
114
 
115
;; Group:       MT
116
 
117
(define_insn_reservation "reg_mov" 0
118
  (and (eq_attr "pipe_model" "sh4")
119
       (eq_attr "type" "move"))
120
  "issue")
121
 
122
;; Group:       LS
123
 
124
(define_insn_reservation "freg_mov" 0
125
  (and (eq_attr "pipe_model" "sh4")
126
       (eq_attr "type" "fmove"))
127
  "issue+load_store")
128
 
129
;; We don't model all pipeline stages; we model the issue ('D') stage
130
;; inasmuch as we allow only two instructions to issue simultaneously,
131
;; and CO instructions prevent any simultaneous issue of another instruction.
132
;; (This uses pipe_01 and pipe_02).
133
;; Double issue of EX insns is prevented by using the int unit in the EX stage.
134
;; Double issue of EX / BR insns is prevented by using the int unit /
135
;; pcr_addrcalc unit in the EX stage.
136
;; Double issue of BR / LS instructions is prevented by using the
137
;; pcr_addrcalc / load_store unit in the issue cycle.
138
;; Double issue of FE instructions is prevented by using F0 in the first
139
;; pipeline stage after the first D stage.
140
;; There is no need to describe the [ES]X / [MN]A / S stages after a D stage
141
;; (except in the cases outlined above), nor to describe the FS stage after
142
;; the F2 stage.
143
 
144
;; Other MT  group instructions(1 step operations)
145
;; Group:       MT
146
;; Latency:     1
147
;; Issue Rate:  1
148
 
149
(define_insn_reservation "mt" 1
150
  (and (eq_attr "pipe_model" "sh4")
151
       (eq_attr "type" "mt_group"))
152
  "issue")
153
 
154
;; Fixed Point Arithmetic Instructions(1 step operations)
155
;; Group:       EX
156
;; Latency:     1
157
;; Issue Rate:  1
158
 
159
(define_insn_reservation "sh4_simple_arith" 1
160
  (and (eq_attr "pipe_model" "sh4")
161
       (eq_attr "insn_class" "ex_group"))
162
  "issue,int")
163
 
164
;; Load and store instructions have no alignment peculiarities for the SH4,
165
;; but they use the load-store unit, which they share with the fmove type
166
;; insns (fldi[01]; fmov frn,frm; flds; fsts; fabs; fneg) .
167
;; Loads have a latency of two.
168
;; However, call insns can only paired with a preceding insn, and have
169
;; a delay slot, so that we want two more insns to be scheduled between the
170
;; load of the function address and the call.  This is equivalent to a
171
;; latency of three.
172
;; ADJUST_COST can only properly handle reductions of the cost, so we
173
;; use a latency of three here, which gets multiplied by 10 to yield 30.
174
;; We only do this for SImode loads of general registers, to make the work
175
;; for ADJUST_COST easier.
176
 
177
;; Load Store instructions. (MOV.[BWL]@(d,GBR)
178
;; Group:       LS
179
;; Latency:     2
180
;; Issue Rate:  1
181
 
182
(define_insn_reservation "sh4_load" 2
183
  (and (eq_attr "pipe_model" "sh4")
184
       (eq_attr "type" "load,pcload"))
185
  "issue+load_store,nothing,memory")
186
 
187
;; calls / sfuncs need an extra instruction for their delay slot.
188
;; Moreover, estimating the latency for SImode loads as 3 will also allow
189
;; adjust_cost to meaningfully bump it back up to 3 if they load the shift
190
;; count of a dynamic shift.
191
(define_insn_reservation "sh4_load_si" 3
192
  (and (eq_attr "pipe_model" "sh4")
193
       (eq_attr "type" "load_si,pcload_si"))
194
  "issue+load_store,nothing,memory")
195
 
196
;; (define_bypass 2 "sh4_load_si" "!sh4_call")
197
 
198
;; The load latency is upped to three higher if the dependent insn does
199
;; double precision computation.  We want the 'default' latency to reflect
200
;; that increased latency because otherwise the insn priorities won't
201
;; allow proper scheduling.
202
(define_insn_reservation "sh4_fload" 3
203
  (and (eq_attr "pipe_model" "sh4")
204
       (eq_attr "type" "fload,pcfload"))
205
  "issue+load_store,nothing,memory")
206
 
207
;; (define_bypass 2 "sh4_fload" "!")
208
 
209
(define_insn_reservation "sh4_store" 1
210
  (and (eq_attr "pipe_model" "sh4")
211
       (eq_attr "type" "store"))
212
  "issue+load_store,nothing,memory")
213
 
214
;; Load Store instructions.
215
;; Group:       LS
216
;; Latency:     1
217
;; Issue Rate:  1
218
 
219
(define_insn_reservation "sh4_gp_fpul" 1
220
  (and (eq_attr "pipe_model" "sh4")
221
       (eq_attr "type" "gp_fpul"))
222
  "issue+load_store")
223
 
224
;; Load Store instructions.
225
;; Group:       LS
226
;; Latency:     3
227
;; Issue Rate:  1
228
 
229
(define_insn_reservation "sh4_fpul_gp" 3
230
  (and (eq_attr "pipe_model" "sh4")
231
       (eq_attr "type" "fpul_gp"))
232
  "issue+load_store")
233
 
234
;; Branch (BF,BF/S,BT,BT/S,BRA)
235
;; Group:       BR
236
;; Latency when taken:  2 (or 1)
237
;; Issue Rate:  1
238
;; The latency is 1 when displacement is 0.
239
;; We can't really do much with the latency, even if we could express it,
240
;; but the pairing restrictions are useful to take into account.
241
;; ??? If the branch is likely, we might want to fill the delay slot;
242
;; if the branch is likely, but not very likely, should we pretend to use
243
;; a resource that CO instructions use, to get a pairable delay slot insn?
244
 
245
(define_insn_reservation "sh4_branch"  1
246
  (and (eq_attr "pipe_model" "sh4")
247
       (eq_attr "type" "cbranch,jump"))
248
  "issue+pcr_addrcalc")
249
 
250
;; Branch Far (JMP,RTS,BRAF)
251
;; Group:       CO
252
;; Latency:     3
253
;; Issue Rate:  2
254
;; ??? Scheduling happens before branch shortening, and hence jmp and braf
255
;; can't be distinguished from bra for the "jump" pattern.
256
 
257
(define_insn_reservation "sh4_return" 3
258
  (and (eq_attr "pipe_model" "sh4")
259
       (eq_attr "type" "return,jump_ind"))
260
         "d_lock*2")
261
 
262
;; RTE
263
;; Group:       CO
264
;; Latency:     5
265
;; Issue Rate:  5
266
;; this instruction can be executed in any of the pipelines
267
;; and blocks the pipeline for next 4 stages.
268
 
269
(define_insn_reservation "sh4_return_from_exp" 5
270
  (and (eq_attr "pipe_model" "sh4")
271
       (eq_attr "type" "rte"))
272
  "d_lock*5")
273
 
274
;; OCBP, OCBWB
275
;; Group:       CO
276
;; Latency:     1-5
277
;; Issue Rate:  1
278
 
279
;; cwb is used for the sequence ocbwb @%0; extu.w %0,%2; or %1,%2; mov.l %0,@%2
280
;; ocbwb on its own would be "d_lock,nothing,memory*5"
281
(define_insn_reservation "ocbwb"  6
282
  (and (eq_attr "pipe_model" "sh4")
283
       (eq_attr "type" "cwb"))
284
  "d_lock*2,(d_lock+memory)*3,issue+load_store+memory,memory*2")
285
 
286
;; LDS to PR,JSR
287
;; Group:       CO
288
;; Latency:     3
289
;; Issue Rate:  2
290
;; The SX stage is blocked for last 2 cycles.
291
;; OTOH, the only time that has an effect for insns generated by the compiler
292
;; is when lds to PR is followed by sts from PR - and that is highly unlikely -
293
;; or when we are doing a function call - and we don't do inter-function
294
;; scheduling.  For the function call case, it's really best that we end with
295
;; something that models an rts.
296
 
297
(define_insn_reservation "sh4_lds_to_pr" 3
298
  (and (eq_attr "pipe_model" "sh4")
299
       (eq_attr "type" "prset") )
300
  "d_lock*2")
301
 
302
;; calls introduce a longisch delay that is likely to flush the pipelines
303
;; of the caller's instructions.  Ordinary functions tend to end with a
304
;; load to restore a register (in the delay slot of rts), while sfuncs
305
;; tend to end with an EX or MT insn.  But that is not actually relevant,
306
;; since there are no instructions that contend for memory access early.
307
;; We could, of course, provide exact scheduling information for specific
308
;; sfuncs, if that should prove useful.
309
 
310
(define_insn_reservation "sh4_call" 16
311
  (and (eq_attr "pipe_model" "sh4")
312
       (eq_attr "type" "call,sfunc"))
313
  "d_lock*16")
314
 
315
;; LDS.L to PR
316
;; Group:       CO
317
;; Latency:     3
318
;; Issue Rate:  2
319
;; The SX unit is blocked for last 2 cycles.
320
 
321
(define_insn_reservation "ldsmem_to_pr"  3
322
  (and (eq_attr "pipe_model" "sh4")
323
       (eq_attr "type" "pload"))
324
  "d_lock*2")
325
 
326
;; STS from PR
327
;; Group:       CO
328
;; Latency:     2
329
;; Issue Rate:  2
330
;; The SX unit in second and third cycles.
331
 
332
(define_insn_reservation "sts_from_pr" 2
333
  (and (eq_attr "pipe_model" "sh4")
334
       (eq_attr "type" "prget"))
335
  "d_lock*2")
336
 
337
;; STS.L from PR
338
;; Group:       CO
339
;; Latency:     2
340
;; Issue Rate:  2
341
 
342
(define_insn_reservation "sh4_prstore_mem" 2
343
  (and (eq_attr "pipe_model" "sh4")
344
       (eq_attr "type" "pstore"))
345
  "d_lock*2,nothing,memory")
346
 
347
;; LDS to FPSCR
348
;; Group:       CO
349
;; Latency:     4
350
;; Issue Rate:  1
351
;; F1 is blocked for last three cycles.
352
 
353
(define_insn_reservation "fpscr_load" 4
354
  (and (eq_attr "pipe_model" "sh4")
355
       (eq_attr "type" "gp_fpscr"))
356
  "d_lock,nothing,F1*3")
357
 
358
;; LDS.L to FPSCR
359
;; Group:       CO
360
;; Latency:     1 / 4
361
;; Latency to update Rn is 1 and latency to update FPSCR is 4
362
;; Issue Rate:  1
363
;; F1 is blocked for last three cycles.
364
 
365
(define_insn_reservation "fpscr_load_mem" 4
366
  (and (eq_attr "pipe_model" "sh4")
367
       (eq_attr "type"  "mem_fpscr"))
368
  "d_lock,nothing,(F1+memory),F1*2")
369
 
370
 
371
;; Fixed point multiplication (DMULS.L DMULU.L MUL.L MULS.W,MULU.W)
372
;; Group:       CO
373
;; Latency:     4 / 4
374
;; Issue Rate:  1
375
 
376
(define_insn_reservation "multi" 4
377
  (and (eq_attr "pipe_model" "sh4")
378
       (eq_attr "type" "smpy,dmpy"))
379
  "d_lock,(d_lock+f1_1),(f1_1|f1_2)*3,F2")
380
 
381
;; Fixed STS from MACL / MACH
382
;; Group:       CO
383
;; Latency:     3
384
;; Issue Rate:  1
385
 
386
(define_insn_reservation "sh4_mac_gp" 3
387
  (and (eq_attr "pipe_model" "sh4")
388
       (eq_attr "type" "mac_gp"))
389
  "d_lock")
390
 
391
 
392
;; Single precision floating point computation FCMP/EQ,
393
;; FCMP/GT, FADD, FLOAT, FMAC, FMUL, FSUB, FTRC, FRVHG, FSCHG
394
;; Group:       FE
395
;; Latency:     3/4
396
;; Issue Rate:  1
397
 
398
(define_insn_reservation "fp_arith"  3
399
  (and (eq_attr "pipe_model" "sh4")
400
       (eq_attr "type" "fp"))
401
  "issue,F01,F2")
402
 
403
(define_insn_reservation "fp_arith_ftrc"  3
404
  (and (eq_attr "pipe_model" "sh4")
405
       (eq_attr "type" "ftrc_s"))
406
  "issue,F01,F2")
407
 
408
(define_bypass 1 "fp_arith_ftrc" "sh4_fpul_gp")
409
 
410
;; Single Precision FDIV/SQRT
411
;; Group:       FE
412
;; Latency:     12/13 (FDIV); 11/12 (FSQRT)
413
;; Issue Rate:  1
414
;; We describe fdiv here; fsqrt is actually one cycle faster.
415
 
416
(define_insn_reservation "fp_div" 12
417
  (and (eq_attr "pipe_model" "sh4")
418
       (eq_attr "type" "fdiv"))
419
  "issue,F01+F3,F2+F3,F3*7,F1+F3,F2")
420
 
421
;; Double Precision floating point computation
422
;; (FCNVDS, FCNVSD, FLOAT, FTRC)
423
;; Group:       FE
424
;; Latency:     (3,4)/5
425
;; Issue Rate:  1
426
 
427
(define_insn_reservation "dp_float" 4
428
  (and (eq_attr "pipe_model" "sh4")
429
       (eq_attr "type" "dfp_conv"))
430
  "issue,F01,F1+F2,F2")
431
 
432
;; Double-precision floating-point (FADD,FMUL,FSUB)
433
;; Group:       FE
434
;; Latency:     (7,8)/9
435
;; Issue Rate:  1
436
 
437
(define_insn_reservation "fp_double_arith" 8
438
  (and (eq_attr "pipe_model" "sh4")
439
       (eq_attr "type" "dfp_arith"))
440
  "issue,F01,F1+F2,fpu*4,F2")
441
 
442
;; Double-precision FCMP (FCMP/EQ,FCMP/GT)
443
;; Group:       CO
444
;; Latency:     3/5
445
;; Issue Rate:  2
446
 
447
(define_insn_reservation "fp_double_cmp" 3
448
  (and (eq_attr "pipe_model" "sh4")
449
       (eq_attr "type" "dfp_cmp"))
450
  "d_lock,(d_lock+F01),F1+F2,F2")
451
 
452
;; Double precision FDIV/SQRT
453
;; Group:       FE
454
;; Latency:     (24,25)/26
455
;; Issue Rate:  1
456
 
457
(define_insn_reservation "dp_div" 25
458
  (and (eq_attr "pipe_model" "sh4")
459
       (eq_attr "type" "dfdiv"))
460
  "issue,F01+F3,F1+F2+F3,F2+F3,F3*16,F1+F3,(fpu+F3)*2,F2")
461
 
462
 
463
;; Use the branch-not-taken case to model arith3 insns.  For the branch taken
464
;; case, we'd get a d_lock instead of issue at the end.
465
(define_insn_reservation "arith3" 3
466
  (and (eq_attr "pipe_model" "sh4")
467
       (eq_attr "type" "arith3"))
468
  "issue,d_lock+pcr_addrcalc,issue")
469
 
470
;; arith3b insns schedule the same no matter if the branch is taken or not.
471
(define_insn_reservation "arith3b" 2
472
  (and (eq_attr "pipe_model" "sh4")
473
       (eq_attr "type" "arith3"))
474
  "issue,d_lock+pcr_addrcalc")

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.