OSDN Git Service

* config/fp-bit.c: Follow spelling conventions.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / pentium.md
1 ;; Pentium Scheduling
2 ;; Copyright (C) 2002 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GNU CC.
5 ;;
6 ;; GNU CC 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 2, or (at your option)
9 ;; any later version.
10 ;;
11 ;; GNU CC 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 GNU CC; see the file COPYING.  If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.  */
20 ;;
21 ;; The Pentium is an in-order core with two integer pipelines.
22
23 ;; True for insns that behave like prefixed insns on the Pentium.
24 (define_attr "pent_prefix" "false,true"
25   (if_then_else (ior (eq_attr "prefix_0f" "1")
26                      (ior (eq_attr "prefix_data16" "1")
27                           (eq_attr "prefix_rep" "1")))
28     (const_string "true")
29     (const_string "false")))
30
31 ;; Categorize how an instruction slots.
32
33 ;; The non-MMX Pentium slots an instruction with prefixes on U pipe only,
34 ;; while MMX Pentium can slot it on either U or V.  Model non-MMX Pentium
35 ;; rules, because it results in noticeably better code on non-MMX Pentium
36 ;; and doesn't hurt much on MMX.  (Prefixed instructions are not very
37 ;; common, so the scheduler usualy has a non-prefixed insn to pair).
38
39 (define_attr "pent_pair" "uv,pu,pv,np"
40   (cond [(eq_attr "imm_disp" "true")
41            (const_string "np")
42          (ior (eq_attr "type" "alu1,alu,imov,icmp,test,lea,incdec")
43               (and (eq_attr "type" "pop,push")
44                    (eq_attr "memory" "!both")))
45            (if_then_else (eq_attr "pent_prefix" "true")
46              (const_string "pu")
47              (const_string "uv"))
48          (eq_attr "type" "ibr")
49            (const_string "pv")
50          (and (eq_attr "type" "ishift")
51               (match_operand 2 "const_int_operand" ""))
52            (const_string "pu")
53          (and (eq_attr "type" "rotate")
54               (match_operand 2 "const_int_1_operand" ""))
55            (const_string "pu")
56          (and (eq_attr "type" "call")
57               (match_operand 0 "constant_call_address_operand" ""))
58            (const_string "pv")
59          (and (eq_attr "type" "callv")
60               (match_operand 1 "constant_call_address_operand" ""))
61            (const_string "pv")
62         ]
63         (const_string "np")))
64
65 (define_automaton "pentium,pentium_fpu")
66
67 ;; Pentium do have U and V pipes.  Instruction to both pipes
68 ;; are alwyas issued together, much like on VLIW.
69 ;;
70 ;;                    predecode
71 ;;                   /         \
72 ;;               decodeu     decodev
73 ;;             /    |           |
74 ;;           fpu executeu    executev
75 ;;            |     |           |
76 ;;           fpu  retire     retire
77 ;;            |
78 ;;           fpu
79 ;; We add dummy "port" pipes allocated only first cycle of
80 ;; instruction to specify this behavior.
81
82 (define_cpu_unit "pentium-portu,pentium-portv" "pentium")
83 (define_cpu_unit "pentium-u,pentium-v" "pentium")
84 (absence_set "pentium-portu" "pentium-u,pentium-v")
85 (presence_set "pentium-portv" "pentium-portu")
86
87 ;; Floating point instructions can overlap with new issue of integer
88 ;; instructions.  We model only first cycle of FP pipeline, as it is
89 ;; fully pipelined.
90 (define_cpu_unit "pentium-fp" "pentium_fpu")
91
92 ;; There is non-pipelined multiplier unit used for complex operations.
93 (define_cpu_unit "pentium-fmul" "pentium_fpu")
94
95 ;; Pentium preserves memory ordering, so when load-execute-store
96 ;; instruction is executed together with other instruction loading
97 ;; data, the execution of the other instruction is delayed to very
98 ;; last cycle of first instruction, when data are bypassed.
99 ;; We model this by allocating "memory" unit when store is pending
100 ;; and using conflicting load units together.
101
102 (define_cpu_unit "pentium-memory" "pentium")
103 (define_cpu_unit "pentium-load0" "pentium")
104 (define_cpu_unit "pentium-load1" "pentium")
105 (absence_set "pentium-load0,pentium-load1" "pentium-memory")
106
107 (define_reservation "pentium-load" "(pentium-load0 | pentium-load1)")
108 (define_reservation "pentium-np" "(pentium-u + pentium-v)")
109 (define_reservation "pentium-uv" "(pentium-u | pentium-v)")
110 (define_reservation "pentium-portuv" "(pentium-portu | pentium-portv)")
111 (define_reservation "pentium-firstu" "(pentium-u + pentium-portu)")
112 (define_reservation "pentium-firstv" "(pentium-v + pentium-portuv)")
113 (define_reservation "pentium-firstuv" "(pentium-uv + pentium-portuv)")
114 (define_reservation "pentium-firstuload" "(pentium-load + pentium-firstu)")
115 (define_reservation "pentium-firstvload" "(pentium-load + pentium-firstv)")
116 (define_reservation "pentium-firstuvload" "(pentium-load + pentium-firstuv)
117                                            | (pentium-firstv,pentium-v,
118                                               (pentium-load+pentium-firstv))")
119 (define_reservation "pentium-firstuboth" "(pentium-load + pentium-firstu
120                                            + pentium-memory)")
121 (define_reservation "pentium-firstvboth" "(pentium-load + pentium-firstv
122                                            + pentium-memory)")
123 (define_reservation "pentium-firstuvboth" "(pentium-load + pentium-firstuv
124                                             + pentium-memory)
125                                            | (pentium-firstv,pentium-v,
126                                               (pentium-load+pentium-firstv))")
127
128 ;; Few common long latency instructions
129 (define_insn_reservation "pent_mul" 11
130   (and (eq_attr "cpu" "pentium")
131        (eq_attr "type" "imul"))
132   "pentium-np*11")
133
134 (define_insn_reservation "pent_str" 12
135   (and (eq_attr "cpu" "pentium")
136        (eq_attr "type" "str"))
137   "pentium-np*12")
138
139 ;; Integer division and some other long latency instruction block all
140 ;; units, including the FP pipe.  There is no value in modeling the
141 ;; latency of these instructions and not modeling the latency
142 ;; decreases the size of the DFA.
143 (define_insn_reservation "pent_block" 1
144   (and (eq_attr "cpu" "pentium")
145        (eq_attr "type" "idiv"))
146   "pentium-np+pentium-fp")
147
148 (define_insn_reservation "pent_cld" 2
149   (and (eq_attr "cpu" "pentium")
150        (eq_attr "type" "cld"))
151   "pentium-np*2")
152
153 ;;  Moves usually have one cycle penalty, but there are exceptions.
154 (define_insn_reservation "pent_fmov" 1
155   (and (eq_attr "cpu" "pentium")
156        (and (eq_attr "type" "fmov")
157             (eq_attr "memory" "none,load")))
158   "(pentium-fp+pentium-np)")
159
160 (define_insn_reservation "pent_fpmovxf" 3
161   (and (eq_attr "cpu" "pentium")
162        (and (eq_attr "type" "fmov")
163             (and (eq_attr "memory" "load,store")
164                  (eq_attr "mode" "XF"))))
165   "(pentium-fp+pentium-np)*3")
166
167 (define_insn_reservation "pent_fpstore" 2
168   (and (eq_attr "cpu" "pentium")
169        (and (eq_attr "type" "fmov")
170             (ior (match_operand 1 "immediate_operand" "")
171                  (eq_attr "memory" "store"))))
172   "(pentium-fp+pentium-np)*2")
173
174 (define_insn_reservation "pent_imov" 1
175   (and (eq_attr "cpu" "pentium")
176        (eq_attr "type" "imov"))
177   "pentium-firstuv")
178
179 ;; Push and pop instructions have 1 cycle latency and special
180 ;; hardware bypass allows them to be paired with other push,pop
181 ;; and call instructions.
182 (define_bypass 0 "pent_push,pent_pop" "pent_push,pent_pop,pent_call")
183 (define_insn_reservation "pent_push" 1
184   (and (eq_attr "cpu" "pentium")
185        (and (eq_attr "type" "push")
186             (eq_attr "memory" "store")))
187   "pentium-firstuv")
188
189 (define_insn_reservation "pent_pop" 1
190   (and (eq_attr "cpu" "pentium")
191        (eq_attr "type" "pop"))
192   "pentium-firstuv")
193
194 ;; Call and branch instruction can execute in either pipe, but
195 ;; they are only pairable when in the v pipe.
196 (define_insn_reservation "pent_call" 10
197   (and (eq_attr "cpu" "pentium")
198        (eq_attr "type" "call,callv"))
199   "pentium-firstv,pentium-v*9")
200
201 (define_insn_reservation "pent_branch" 1
202   (and (eq_attr "cpu" "pentium")
203        (eq_attr "type" "ibr"))
204   "pentium-firstv")
205
206 ;; Floating point instruction dispatch in U pipe, but continue
207 ;; in FP pipeline allowing other isntructions to be executed.
208 (define_insn_reservation "pent_fp" 3
209   (and (eq_attr "cpu" "pentium")
210        (eq_attr "type" "fop,fistp"))
211   "(pentium-firstu+pentium-fp),nothing,nothing")
212
213 ;; First two cycles of fmul are not pipelined.
214 (define_insn_reservation "pent_fmul" 3
215   (and (eq_attr "cpu" "pentium")
216        (eq_attr "type" "fmul"))
217   "(pentium-firstuv+pentium-fp+pentium-fmul),pentium-fmul,nothing")
218
219 ;; Long latency FP instructions overlap with integer instructions,
220 ;; but only last 2 cycles with FP ones.
221 (define_insn_reservation "pent_fdiv" 39
222   (and (eq_attr "cpu" "pentium")
223        (eq_attr "type" "fdiv"))
224   "(pentium-np+pentium-fp+pentium-fmul),
225    (pentium-fp+pentium-fmul)*36,pentium-fmul*2")
226
227 (define_insn_reservation "pent_fpspc" 70
228   (and (eq_attr "cpu" "pentium")
229        (eq_attr "type" "fpspc"))
230   "(pentium-np+pentium-fp+pentium-fmul),
231    (pentium-fp+pentium-fmul)*67,pentium-fmul*2")
232
233 ;; Integer instructions.  Load/execute/store takes 3 cycles,
234 ;; load/execute 2 cycles and execute only one cycle.
235 (define_insn_reservation "pent_uv_both" 3
236   (and (eq_attr "cpu" "pentium")
237        (and (eq_attr "pent_pair" "uv")
238             (eq_attr "memory" "both")))
239   "pentium-firstuvboth,pentium-uv+pentium-memory,pentium-uv")
240
241 (define_insn_reservation "pent_u_both" 3
242   (and (eq_attr "cpu" "pentium")
243        (and (eq_attr "pent_pair" "pu")
244             (eq_attr "memory" "both")))
245   "pentium-firstuboth,pentium-u+pentium-memory,pentium-u")
246
247 (define_insn_reservation "pent_v_both" 3
248   (and (eq_attr "cpu" "pentium")
249        (and (eq_attr "pent_pair" "pv")
250             (eq_attr "memory" "both")))
251   "pentium-firstvboth,pentium-v+pentium-memory,pentium-v")
252
253 (define_insn_reservation "pent_np_both" 3
254   (and (eq_attr "cpu" "pentium")
255        (and (eq_attr "pent_pair" "np")
256             (eq_attr "memory" "both")))
257   "pentium-np,pentium-np,pentium-np")
258
259 (define_insn_reservation "pent_uv_load" 2
260   (and (eq_attr "cpu" "pentium")
261        (and (eq_attr "pent_pair" "uv")
262             (eq_attr "memory" "load")))
263   "pentium-firstuvload,pentium-uv")
264
265 (define_insn_reservation "pent_u_load" 2
266   (and (eq_attr "cpu" "pentium")
267        (and (eq_attr "pent_pair" "pu")
268             (eq_attr "memory" "load")))
269   "pentium-firstuload,pentium-u")
270
271 (define_insn_reservation "pent_v_load" 2
272   (and (eq_attr "cpu" "pentium")
273        (and (eq_attr "pent_pair" "pv")
274             (eq_attr "memory" "load")))
275   "pentium-firstvload,pentium-v")
276
277 (define_insn_reservation "pent_np_load" 2
278   (and (eq_attr "cpu" "pentium")
279        (and (eq_attr "pent_pair" "np")
280             (eq_attr "memory" "load")))
281   "pentium-np,pentium-np")
282
283 (define_insn_reservation "pent_uv" 1
284   (and (eq_attr "cpu" "pentium")
285        (and (eq_attr "pent_pair" "uv")
286             (eq_attr "memory" "none")))
287   "pentium-firstuv")
288
289 (define_insn_reservation "pent_u" 1
290   (and (eq_attr "cpu" "pentium")
291        (and (eq_attr "pent_pair" "pu")
292             (eq_attr "memory" "none")))
293   "pentium-firstu")
294
295 (define_insn_reservation "pent_v" 1
296   (and (eq_attr "cpu" "pentium")
297        (and (eq_attr "pent_pair" "pv")
298             (eq_attr "memory" "none")))
299   "pentium-firstv")
300
301 (define_insn_reservation "pent_np" 1
302   (and (eq_attr "cpu" "pentium")
303        (and (eq_attr "pent_pair" "np")
304             (eq_attr "memory" "none")))
305   "pentium-np")
306