2007-05-30 H.J. Lu <hongjiu.lu@intel.com>
[official-gcc.git] / gcc / config / rs6000 / 8540.md
blob91781af7f5717add8e699852e125752ee2ae7535
1 ;; Pipeline description for Motorola PowerPC 8540 processor.
2 ;;   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
6 ;; GCC is free software; you can redistribute it and/or modify it
7 ;; under the terms of the GNU General Public License as published
8 ;; by the Free Software Foundation; either version 2, or (at your
9 ;; option) any later version.
11 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
12 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14 ;; License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING.  If not, write to the
18 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19 ;; MA 02110-1301, USA.
21 (define_automaton "ppc8540_most,ppc8540_long,ppc8540_retire")
22 (define_cpu_unit "ppc8540_decode_0,ppc8540_decode_1" "ppc8540_most")
24 ;; We don't simulate general issue queue (GIC).  If we have SU insn
25 ;; and then SU1 insn, they cannot be issued on the same cycle
26 ;; (although SU1 insn and then SU insn can be issued) because the SU
27 ;; insn will go to SU1 from GIC0 entry.  Fortunately, the first cycle
28 ;; multipass insn scheduling will find the situation and issue the SU1
29 ;; insn and then the SU insn.
30 (define_cpu_unit "ppc8540_issue_0,ppc8540_issue_1"   "ppc8540_most")
32 ;; We could describe completion buffers slots in combination with the
33 ;; retirement units and the order of completion but the result
34 ;; automaton would behave in the same way because we cannot describe
35 ;; real latency time with taking in order completion into account.
36 ;; Actually we could define the real latency time by querying reserved
37 ;; automaton units but the current scheduler uses latency time before
38 ;; issuing insns and making any reservations.
40 ;; So our description is aimed to achieve a insn schedule in which the
41 ;; insns would not wait in the completion buffer.
42 (define_cpu_unit "ppc8540_retire_0,ppc8540_retire_1" "ppc8540_retire")
44 ;; Branch unit:
45 (define_cpu_unit "ppc8540_bu" "ppc8540_most")
47 ;; SU:
48 (define_cpu_unit "ppc8540_su0_stage0,ppc8540_su1_stage0" "ppc8540_most")
50 ;; We could describe here MU subunits for float multiply, float add
51 ;; etc.  But the result automaton would behave the same way as the
52 ;; described one pipeline below because MU can start only one insn
53 ;; per cycle.  Actually we could simplify the automaton more not
54 ;; describing stages 1-3, the result automata would be the same.
55 (define_cpu_unit "ppc8540_mu_stage0,ppc8540_mu_stage1" "ppc8540_most")
56 (define_cpu_unit "ppc8540_mu_stage2,ppc8540_mu_stage3" "ppc8540_most")
58 ;; The following unit is used to describe non-pipelined division.
59 (define_cpu_unit "ppc8540_mu_div" "ppc8540_long")
61 ;; Here we simplified LSU unit description not describing the stages.
62 (define_cpu_unit "ppc8540_lsu" "ppc8540_most")
64 ;; The following units are used to make automata deterministic
65 (define_cpu_unit "present_ppc8540_decode_0" "ppc8540_most")
66 (define_cpu_unit "present_ppc8540_issue_0" "ppc8540_most")
67 (define_cpu_unit "present_ppc8540_retire_0" "ppc8540_retire")
68 (define_cpu_unit "present_ppc8540_su0_stage0" "ppc8540_most")
70 ;; The following sets to make automata deterministic when option ndfa is used.
71 (presence_set "present_ppc8540_decode_0" "ppc8540_decode_0")
72 (presence_set "present_ppc8540_issue_0" "ppc8540_issue_0")
73 (presence_set "present_ppc8540_retire_0" "ppc8540_retire_0")
74 (presence_set "present_ppc8540_su0_stage0" "ppc8540_su0_stage0")
76 ;; Some useful abbreviations.
77 (define_reservation "ppc8540_decode"
78     "ppc8540_decode_0|ppc8540_decode_1+present_ppc8540_decode_0")
79 (define_reservation "ppc8540_issue"
80     "ppc8540_issue_0|ppc8540_issue_1+present_ppc8540_issue_0")
81 (define_reservation "ppc8540_retire"
82    "ppc8540_retire_0|ppc8540_retire_1+present_ppc8540_retire_0")
83 (define_reservation "ppc8540_su_stage0"
84    "ppc8540_su0_stage0|ppc8540_su1_stage0+present_ppc8540_su0_stage0")
86 ;; Simple SU insns
87 (define_insn_reservation "ppc8540_su" 1
88   (and (eq_attr "type" "integer,insert_word,insert_dword,cmp,compare,\
89                         delayed_compare,var_delayed_compare,fast_compare,\
90                         shift,trap,var_shift_rotate,cntlz,exts")
91        (eq_attr "cpu" "ppc8540"))
92   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
94 (define_insn_reservation "ppc8540_two" 1
95   (and (eq_attr "type" "two")
96        (eq_attr "cpu" "ppc8540"))
97   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire,\
98    ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
100 (define_insn_reservation "ppc8540_three" 1
101   (and (eq_attr "type" "three")
102        (eq_attr "cpu" "ppc8540"))
103   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire,\
104    ppc8540_issue+ppc8540_su_stage0+ppc8540_retire,\
105    ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
107 ;; Branch.  Actually this latency time is not used by the scheduler.
108 (define_insn_reservation "ppc8540_branch" 1
109   (and (eq_attr "type" "jmpreg,branch,isync")
110        (eq_attr "cpu" "ppc8540"))
111   "ppc8540_decode,ppc8540_bu,ppc8540_retire")
113 ;; Multiply
114 (define_insn_reservation "ppc8540_multiply" 4
115   (and (eq_attr "type" "imul,imul2,imul3,imul_compare")
116        (eq_attr "cpu" "ppc8540"))
117   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0,ppc8540_mu_stage1,\
118    ppc8540_mu_stage2,ppc8540_mu_stage3+ppc8540_retire")
120 ;; Divide.  We use the average latency time here.  We omit reserving a
121 ;; retire unit because of the result automata will be huge.  We ignore
122 ;; reservation of miu_stage3 here because we use the average latency
123 ;; time.
124 (define_insn_reservation "ppc8540_divide" 14
125   (and (eq_attr "type" "idiv")
126        (eq_attr "cpu" "ppc8540"))
127   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0+ppc8540_mu_div,\
128    ppc8540_mu_div*13")
130 ;; CR logical
131 (define_insn_reservation "ppc8540_cr_logical" 1
132   (and (eq_attr "type" "cr_logical,delayed_cr")
133        (eq_attr "cpu" "ppc8540"))
134   "ppc8540_decode,ppc8540_bu,ppc8540_retire")
136 ;; Mfcr
137 (define_insn_reservation "ppc8540_mfcr" 1
138   (and (eq_attr "type" "mfcr")
139        (eq_attr "cpu" "ppc8540"))
140   "ppc8540_decode,ppc8540_issue+ppc8540_su1_stage0+ppc8540_retire")
142 ;; Mtcrf
143 (define_insn_reservation "ppc8540_mtcrf" 1
144   (and (eq_attr "type" "mtcr")
145        (eq_attr "cpu" "ppc8540"))
146   "ppc8540_decode,ppc8540_issue+ppc8540_su1_stage0+ppc8540_retire")
148 ;; Mtjmpr
149 (define_insn_reservation "ppc8540_mtjmpr" 1
150   (and (eq_attr "type" "mtjmpr,mfjmpr")
151        (eq_attr "cpu" "ppc8540"))
152   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
154 ;; Loads
155 (define_insn_reservation "ppc8540_load" 3
156   (and (eq_attr "type" "load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,\
157                         load_l,sync")
158        (eq_attr "cpu" "ppc8540"))
159   "ppc8540_decode,ppc8540_issue+ppc8540_lsu,nothing,ppc8540_retire")
161 ;; Stores.
162 (define_insn_reservation "ppc8540_store" 3
163   (and (eq_attr "type" "store,store_ux,store_u,store_c")
164        (eq_attr "cpu" "ppc8540"))
165   "ppc8540_decode,ppc8540_issue+ppc8540_lsu,nothing,ppc8540_retire")
167 ;; Simple FP
168 (define_insn_reservation "ppc8540_simple_float" 1
169   (and (eq_attr "type" "fpsimple")
170        (eq_attr "cpu" "ppc8540"))
171   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
173 ;; FP
174 (define_insn_reservation "ppc8540_float" 4
175   (and (eq_attr "type" "fp")
176        (eq_attr "cpu" "ppc8540"))
177   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0,ppc8540_mu_stage1,\
178    ppc8540_mu_stage2,ppc8540_mu_stage3+ppc8540_retire")
180 ;; float divides.  We omit reserving a retire unit and miu_stage3
181 ;; because of the result automata will be huge.
182 (define_insn_reservation "ppc8540_float_vector_divide" 29
183   (and (eq_attr "type" "vecfdiv")
184        (eq_attr "cpu" "ppc8540"))
185   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0+ppc8540_mu_div,\
186    ppc8540_mu_div*28")
188 ;; Brinc
189 (define_insn_reservation "ppc8540_brinc" 1
190   (and (eq_attr "type" "brinc")
191        (eq_attr "cpu" "ppc8540"))
192   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
194 ;; Simple vector
195 (define_insn_reservation "ppc8540_simple_vector" 1
196   (and (eq_attr "type" "vecsimple")
197        (eq_attr "cpu" "ppc8540"))
198   "ppc8540_decode,ppc8540_issue+ppc8540_su1_stage0+ppc8540_retire")
200 ;; Simple vector compare
201 (define_insn_reservation "ppc8540_simple_vector_compare" 1
202   (and (eq_attr "type" "veccmpsimple")
203        (eq_attr "cpu" "ppc8540"))
204   "ppc8540_decode,ppc8540_issue+ppc8540_su_stage0+ppc8540_retire")
206 ;; Vector compare
207 (define_insn_reservation "ppc8540_vector_compare" 1
208   (and (eq_attr "type" "veccmp")
209        (eq_attr "cpu" "ppc8540"))
210   "ppc8540_decode,ppc8540_issue+ppc8540_su1_stage0+ppc8540_retire")
212 ;; evsplatfi evsplati
213 (define_insn_reservation "ppc8540_vector_perm" 1
214   (and (eq_attr "type" "vecperm")
215        (eq_attr "cpu" "ppc8540"))
216   "ppc8540_decode,ppc8540_issue+ppc8540_su1_stage0+ppc8540_retire")
218 ;; Vector float
219 (define_insn_reservation "ppc8540_float_vector" 4
220   (and (eq_attr "type" "vecfloat")
221        (eq_attr "cpu" "ppc8540"))
222   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0,ppc8540_mu_stage1,\
223    ppc8540_mu_stage2,ppc8540_mu_stage3+ppc8540_retire")
225 ;; Vector divides: Use the average.  We omit reserving a retire unit
226 ;; because of the result automata will be huge.  We ignore reservation
227 ;; of miu_stage3 here because we use the average latency time.
228 (define_insn_reservation "ppc8540_vector_divide" 14
229   (and (eq_attr "type" "vecdiv")
230        (eq_attr "cpu" "ppc8540"))
231   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0+ppc8540_mu_div,\
232    ppc8540_mu_div*13")
234 ;; Complex vector.
235 (define_insn_reservation "ppc8540_complex_vector" 4
236   (and (eq_attr "type" "veccomplex")
237        (eq_attr "cpu" "ppc8540"))
238   "ppc8540_decode,ppc8540_issue+ppc8540_mu_stage0,ppc8540_mu_stage1,\
239    ppc8540_mu_stage2,ppc8540_mu_stage3+ppc8540_retire")
241 ;; Vector load
242 (define_insn_reservation "ppc8540_vector_load" 3
243   (and (eq_attr "type" "vecload")
244        (eq_attr "cpu" "ppc8540"))
245   "ppc8540_decode,ppc8540_issue+ppc8540_lsu,nothing,ppc8540_retire")
247 ;; Vector store
248 (define_insn_reservation "ppc8540_vector_store" 3
249   (and (eq_attr "type" "vecstore")
250        (eq_attr "cpu" "ppc8540"))
251   "ppc8540_decode,ppc8540_issue+ppc8540_lsu,nothing,ppc8540_retire")