rs6000: Make all add instructions one type
[official-gcc.git] / gcc / config / rs6000 / power8.md
blobb2eeac4935ce8c8df0e53a80151d26a8d5bfc6df
1 ;; Scheduling description for IBM POWER8 processor.
2 ;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
3 ;;
4 ;; Contributed by Pat Haugen (pthaugen@us.ibm.com).
6 ;; This file is part of GCC.
7 ;;
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 3, or (at your
11 ;; option) any later version.
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16 ;; License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
22 (define_automaton "power8fxu,power8lsu,power8vsu,power8misc")
24 (define_cpu_unit "fxu0_power8,fxu1_power8" "power8fxu")
25 (define_cpu_unit "lu0_power8,lu1_power8" "power8lsu")
26 (define_cpu_unit "lsu0_power8,lsu1_power8" "power8lsu")
27 (define_cpu_unit "vsu0_power8,vsu1_power8" "power8vsu")
28 (define_cpu_unit "bpu_power8,cru_power8" "power8misc")
29 (define_cpu_unit "du0_power8,du1_power8,du2_power8,du3_power8,du4_power8,\
30                   du5_power8,du6_power8"  "power8misc")
33 ; Dispatch group reservations
34 (define_reservation "DU_any_power8"
35                     "du0_power8|du1_power8|du2_power8|du3_power8|du4_power8|\
36                      du5_power8")
38 ; 2-way Cracked instructions go in slots 0-1
39 ;   (can also have a second in slots 3-4 if insns are adjacent)
40 (define_reservation "DU_cracked_power8"
41                     "du0_power8+du1_power8")
43 ; Insns that are first in group
44 (define_reservation "DU_first_power8"
45                     "du0_power8")
47 ; Insns that are first and last in group
48 (define_reservation "DU_both_power8"
49                     "du0_power8+du1_power8+du2_power8+du3_power8+du4_power8+\
50                      du5_power8+du6_power8")
52 ; Dispatch slots are allocated in order conforming to program order.
53 (absence_set "du0_power8" "du1_power8,du2_power8,du3_power8,du4_power8,\
54               du5_power8,du6_power8")
55 (absence_set "du1_power8" "du2_power8,du3_power8,du4_power8,du5_power8,\
56               du6_power8")
57 (absence_set "du2_power8" "du3_power8,du4_power8,du5_power8,du6_power8")
58 (absence_set "du3_power8" "du4_power8,du5_power8,du6_power8")
59 (absence_set "du4_power8" "du5_power8,du6_power8")
60 (absence_set "du5_power8" "du6_power8")
63 ; Execution unit reservations
64 (define_reservation "FXU_power8"
65                     "fxu0_power8|fxu1_power8")
67 (define_reservation "LU_power8"
68                     "lu0_power8|lu1_power8")
70 (define_reservation "LSU_power8"
71                     "lsu0_power8|lsu1_power8")
73 (define_reservation "LU_or_LSU_power8"
74                     "lu0_power8|lu1_power8|lsu0_power8|lsu1_power8")
76 (define_reservation "VSU_power8"
77                     "vsu0_power8|vsu1_power8")
80 ; LS Unit
81 (define_insn_reservation "power8-load" 3
82   (and (eq_attr "type" "load")
83        (eq_attr "sign_extend" "no")
84        (eq_attr "update" "no")
85        (eq_attr "cpu" "power8"))
86   "DU_any_power8,LU_or_LSU_power8")
88 (define_insn_reservation "power8-load-update" 3
89   (and (eq_attr "type" "load")
90        (eq_attr "sign_extend" "no")
91        (eq_attr "update" "yes")
92        (eq_attr "cpu" "power8"))
93   "DU_cracked_power8,LU_or_LSU_power8+FXU_power8")
95 (define_insn_reservation "power8-load-ext" 3
96   (and (eq_attr "type" "load")
97        (eq_attr "sign_extend" "yes")
98        (eq_attr "update" "no")
99        (eq_attr "cpu" "power8"))
100   "DU_cracked_power8,LU_or_LSU_power8,FXU_power8")
102 (define_insn_reservation "power8-load-ext-update" 3
103   (and (eq_attr "type" "load")
104        (eq_attr "sign_extend" "yes")
105        (eq_attr "update" "yes")
106        (eq_attr "cpu" "power8"))
107   "DU_both_power8,LU_or_LSU_power8+FXU_power8,FXU_power8")
109 (define_insn_reservation "power8-fpload" 5
110   (and (ior (eq_attr "type" "vecload")
111             (and (eq_attr "type" "fpload")
112                  (eq_attr "update" "no")))
113        (eq_attr "cpu" "power8"))
114   "DU_any_power8,LU_power8")
116 (define_insn_reservation "power8-fpload-update" 5
117   (and (eq_attr "type" "fpload")
118        (eq_attr "update" "yes")
119        (eq_attr "cpu" "power8"))
120   "DU_cracked_power8,LU_power8+FXU_power8")
122 (define_insn_reservation "power8-store" 5 ; store-forwarding latency
123   (and (eq_attr "type" "store")
124        (not (and (eq_attr "update" "yes")
125                  (eq_attr "indexed" "yes")))
126        (eq_attr "cpu" "power8"))
127   "DU_any_power8,LSU_power8+LU_power8")
129 (define_insn_reservation "power8-store-update-indexed" 5
130   (and (eq_attr "type" "store")
131        (eq_attr "update" "yes")
132        (eq_attr "indexed" "yes")
133        (eq_attr "cpu" "power8"))
134   "DU_cracked_power8,LSU_power8+LU_power8")
136 (define_insn_reservation "power8-fpstore" 5
137   (and (eq_attr "type" "fpstore")
138        (eq_attr "update" "no")
139        (eq_attr "cpu" "power8"))
140   "DU_any_power8,LSU_power8+VSU_power8")
142 (define_insn_reservation "power8-fpstore-update" 5
143   (and (eq_attr "type" "fpstore")
144        (eq_attr "update" "yes")
145        (eq_attr "cpu" "power8"))
146   "DU_any_power8,LSU_power8+VSU_power8")
148 (define_insn_reservation "power8-vecstore" 5
149   (and (eq_attr "type" "vecstore")
150        (eq_attr "cpu" "power8"))
151   "DU_cracked_power8,LSU_power8+VSU_power8")
153 (define_insn_reservation "power8-larx" 3
154   (and (eq_attr "type" "load_l")
155        (eq_attr "cpu" "power8"))
156   "DU_both_power8,LU_or_LSU_power8")
158 (define_insn_reservation "power8-stcx" 10
159   (and (eq_attr "type" "store_c")
160        (eq_attr "cpu" "power8"))
161   "DU_both_power8,LSU_power8+LU_power8")
163 (define_insn_reservation "power8-sync" 1
164   (and (eq_attr "type" "sync,isync")
165        (eq_attr "cpu" "power8"))
166   "DU_both_power8,LSU_power8")
169 ; FX Unit
170 (define_insn_reservation "power8-1cyc" 1
171   (and (ior (eq_attr "type" "integer,insert,trap,exts,isel")
172             (and (eq_attr "type" "add,shift")
173                  (eq_attr "dot" "no")))
174        (eq_attr "cpu" "power8"))
175   "DU_any_power8,FXU_power8")
177 ; Extra cycle to LU/LSU
178 (define_bypass 2 "power8-1cyc"
179                  "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
180                   power8-vecstore,power8-larx,power8-stcx")
181 ;                "power8-load,power8-load-update,power8-load-ext,\
182 ;                 power8-load-ext-update,power8-fpload,power8-fpload-update,\
183 ;                 power8-store,power8-store-update,power8-store-update-indexed,\
184 ;                 power8-fpstore,power8-fpstore-update,power8-vecstore,\
185 ;                 power8-larx,power8-stcx")
187 (define_insn_reservation "power8-2cyc" 2
188   (and (eq_attr "type" "cntlz,popcnt")
189        (eq_attr "cpu" "power8"))
190   "DU_any_power8,FXU_power8")
192 (define_insn_reservation "power8-two" 2
193   (and (eq_attr "type" "two")
194        (eq_attr "cpu" "power8"))
195   "DU_any_power8+DU_any_power8,FXU_power8,FXU_power8")
197 (define_insn_reservation "power8-three" 3
198   (and (eq_attr "type" "three")
199        (eq_attr "cpu" "power8"))
200   "DU_any_power8+DU_any_power8+DU_any_power8,FXU_power8,FXU_power8,FXU_power8")
202 ; cmp - Normal compare insns
203 (define_insn_reservation "power8-cmp" 2
204   (and (eq_attr "type" "cmp")
205        (eq_attr "cpu" "power8"))
206   "DU_any_power8,FXU_power8")
208 ; fast_compare : add./and./nor./etc
209 (define_insn_reservation "power8-fast-compare" 2
210   (and (ior (eq_attr "type" "fast_compare")
211             (and (eq_attr "type" "add")
212                  (eq_attr "dot" "yes")))
213        (eq_attr "cpu" "power8"))
214   "DU_any_power8,FXU_power8")
216 ; compare : rldicl./exts./etc
217 ; shift with dot : rlwinm./slwi./rlwnm./slw./etc
218 (define_insn_reservation "power8-compare" 2
219   (and (ior (eq_attr "type" "compare")
220             (and (eq_attr "type" "shift")
221                  (eq_attr "dot" "yes")))
222        (eq_attr "cpu" "power8"))
223   "DU_cracked_power8,FXU_power8,FXU_power8")
225 ; Extra cycle to LU/LSU
226 (define_bypass 3 "power8-fast-compare,power8-compare"
227                  "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
228                   power8-vecstore,power8-larx,power8-stcx")
230 ; 5 cycle CR latency 
231 (define_bypass 5 "power8-fast-compare,power8-compare"
232                  "power8-crlogical,power8-mfcr,power8-mfcrf,power8-branch")
234 (define_insn_reservation "power8-mul" 4
235   (and (eq_attr "type" "mul")
236        (eq_attr "dot" "no")
237        (eq_attr "cpu" "power8"))
238   "DU_any_power8,FXU_power8")
240 (define_insn_reservation "power8-mul-compare" 4
241   (and (eq_attr "type" "mul")
242        (eq_attr "dot" "yes")
243        (eq_attr "cpu" "power8"))
244   "DU_cracked_power8,FXU_power8")
246 ; Extra cycle to LU/LSU
247 (define_bypass 5 "power8-mul,power8-mul-compare"
248                  "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
249                   power8-vecstore,power8-larx,power8-stcx")
251 ; 7 cycle CR latency 
252 (define_bypass 7 "power8-mul,power8-mul-compare"
253                  "power8-crlogical,power8-mfcr,power8-mfcrf,power8-branch")
255 ; FXU divides are not pipelined
256 (define_insn_reservation "power8-idiv" 37
257   (and (eq_attr "type" "div")
258        (eq_attr "size" "32")
259        (eq_attr "cpu" "power8"))
260   "DU_any_power8,fxu0_power8*37|fxu1_power8*37")
262 (define_insn_reservation "power8-ldiv" 68
263   (and (eq_attr "type" "div")
264        (eq_attr "size" "64")
265        (eq_attr "cpu" "power8"))
266   "DU_any_power8,fxu0_power8*68|fxu1_power8*68")
268 (define_insn_reservation "power8-mtjmpr" 5
269   (and (eq_attr "type" "mtjmpr")
270        (eq_attr "cpu" "power8"))
271   "DU_first_power8,FXU_power8")
273 ; Should differentiate between 1 cr field and > 1 since mtocrf is not microcode
274 (define_insn_reservation "power8-mtcr" 3
275   (and (eq_attr "type" "mtcr")
276        (eq_attr "cpu" "power8"))
277   "DU_both_power8,FXU_power8")
280 ; CR Unit
281 (define_insn_reservation "power8-mfjmpr" 5
282   (and (eq_attr "type" "mfjmpr")
283        (eq_attr "cpu" "power8"))
284   "DU_first_power8,cru_power8+FXU_power8")
286 (define_insn_reservation "power8-crlogical" 3
287   (and (eq_attr "type" "cr_logical,delayed_cr")
288        (eq_attr "cpu" "power8"))
289   "DU_first_power8,cru_power8")
291 (define_insn_reservation "power8-mfcr" 5
292   (and (eq_attr "type" "mfcr")
293        (eq_attr "cpu" "power8"))
294   "DU_both_power8,cru_power8")
296 (define_insn_reservation "power8-mfcrf" 3
297   (and (eq_attr "type" "mfcrf")
298        (eq_attr "cpu" "power8"))
299   "DU_first_power8,cru_power8")
302 ; BR Unit
303 ; Branches take dispatch slot 7, but reserve any remaining prior slots to
304 ; prevent other insns from grabbing them once this is assigned.
305 (define_insn_reservation "power8-branch" 3
306   (and (eq_attr "type" "jmpreg,branch")
307        (eq_attr "cpu" "power8"))
308   "(du6_power8\
309    |du5_power8+du6_power8\
310    |du4_power8+du5_power8+du6_power8\
311    |du3_power8+du4_power8+du5_power8+du6_power8\
312    |du2_power8+du3_power8+du4_power8+du5_power8+du6_power8\
313    |du1_power8+du2_power8+du3_power8+du4_power8+du5_power8+du6_power8\
314    |du0_power8+du1_power8+du2_power8+du3_power8+du4_power8+du5_power8+\
315     du6_power8),bpu_power8")
317 ; Branch updating LR/CTR feeding mf[lr|ctr]
318 (define_bypass 4 "power8-branch" "power8-mfjmpr")
321 ; VS Unit (includes FP/VSX/VMX/DFP/Crypto)
322 (define_insn_reservation "power8-fp" 6
323   (and (eq_attr "type" "fp,dmul")
324        (eq_attr "cpu" "power8"))
325   "DU_any_power8,VSU_power8")
327 ; Additional 3 cycles for any CR result
328 (define_bypass 9 "power8-fp" "power8-crlogical,power8-mfcr*,power8-branch")
330 (define_insn_reservation "power8-fpcompare" 8
331   (and (eq_attr "type" "fpcompare")
332        (eq_attr "cpu" "power8"))
333   "DU_any_power8,VSU_power8")
335 (define_insn_reservation "power8-sdiv" 27
336   (and (eq_attr "type" "sdiv")
337        (eq_attr "cpu" "power8"))
338   "DU_any_power8,VSU_power8")
340 (define_insn_reservation "power8-ddiv" 33
341   (and (eq_attr "type" "ddiv")
342        (eq_attr "cpu" "power8"))
343   "DU_any_power8,VSU_power8")
345 (define_insn_reservation "power8-sqrt" 32
346   (and (eq_attr "type" "ssqrt")
347        (eq_attr "cpu" "power8"))
348   "DU_any_power8,VSU_power8")
350 (define_insn_reservation "power8-dsqrt" 44
351   (and (eq_attr "type" "dsqrt")
352        (eq_attr "cpu" "power8"))
353   "DU_any_power8,VSU_power8")
355 (define_insn_reservation "power8-vecsimple" 2
356   (and (eq_attr "type" "vecperm,vecsimple,veccmp")
357        (eq_attr "cpu" "power8"))
358   "DU_any_power8,VSU_power8")
360 (define_insn_reservation "power8-vecnormal" 6
361   (and (eq_attr "type" "vecfloat,vecdouble")
362        (eq_attr "cpu" "power8"))
363   "DU_any_power8,VSU_power8")
365 (define_bypass 7 "power8-vecnormal"
366                  "power8-vecsimple,power8-veccomplex,power8-fpstore*,\
367                   power8-vecstore")
369 (define_insn_reservation "power8-veccomplex" 7
370   (and (eq_attr "type" "veccomplex")
371        (eq_attr "cpu" "power8"))
372   "DU_any_power8,VSU_power8")
374 (define_insn_reservation "power8-vecfdiv" 25
375   (and (eq_attr "type" "vecfdiv")
376        (eq_attr "cpu" "power8"))
377   "DU_any_power8,VSU_power8")
379 (define_insn_reservation "power8-vecdiv" 31
380   (and (eq_attr "type" "vecdiv")
381        (eq_attr "cpu" "power8"))
382   "DU_any_power8,VSU_power8")
384 (define_insn_reservation "power8-mffgpr" 5
385   (and (eq_attr "type" "mffgpr")
386        (eq_attr "cpu" "power8"))
387   "DU_any_power8,VSU_power8")
389 (define_insn_reservation "power8-mftgpr" 6
390   (and (eq_attr "type" "mftgpr")
391        (eq_attr "cpu" "power8"))
392   "DU_any_power8,VSU_power8")
394 (define_insn_reservation "power8-crypto" 7
395   (and (eq_attr "type" "crypto")
396        (eq_attr "cpu" "power8"))
397   "DU_any_power8,VSU_power8")