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