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