[gcc]
[official-gcc.git] / gcc / config / rs6000 / titan.md
blobc0c3155e4a90eacc38fab3f1b61743fb86f821e0
1 ;; Pipeline description for the AppliedMicro Titan core.
2 ;;   Copyright (C) 2010-2014 Free Software Foundation, Inc.
3 ;;   Contributed by Theobroma Systems Design und Consulting GmbH
4 ;;
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15 ;; License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3.  If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;; AppliedMicro Titan core complex
23 (define_automaton "titan_core,titan_fpu,titan_fxu,titan_bpu,titan_lsu")
24 (define_cpu_unit "titan_issue_0,titan_issue_1" "titan_core")
26 ;; Some useful abbreviations.
27 (define_reservation "titan_issue" "titan_issue_0|titan_issue_1")
29 ;; === FXU scheduling ===
31 (define_cpu_unit "titan_fxu_sh,titan_fxu_wb" "titan_fxu")
33 ;; The 1-cycle adder executes add, addi, subf, neg, compare and trap
34 ;; instructions. It provides its own, dedicated result-bus, so we
35 ;; don't need the titan_fxu_wb reservation to complete.
36 (define_insn_reservation "titan_fxu_adder" 1
37   (and (eq_attr "type" "cmp,fast_compare,trap")
38        (eq_attr "cpu" "titan"))
39   "titan_issue,titan_fxu_sh")
41 ;; Keep the titan_imul and titan_mulhw (half-word) rules in order, to
42 ;; ensure the proper match: the half-word instructions are tagged as
43 ;; imul3 only, whereas regular multiplys will always carry a imul tag.
45 (define_insn_reservation "titan_imul" 5
46   (and (eq_attr "type" "imul,imul2,imul_compare")
47        (eq_attr "cpu" "titan"))       
48   "titan_issue,titan_fxu_sh,nothing*5,titan_fxu_wb")  
50 (define_insn_reservation "titan_mulhw" 4
51   (and (eq_attr "type" "imul3")
52        (eq_attr "cpu" "titan"))
53   "titan_issue,titan_fxu_sh,nothing*4,titan_fxu_wb")
55 (define_bypass 2 "titan_mulhw" "titan_mulhw")
57 (define_insn_reservation "titan_fxu_shift_and_rotate" 2
58   (and (eq_attr "type" "insert_word,shift,var_shift_rotate,cntlz")
59        (eq_attr "cpu" "titan"))
60   "titan_issue,titan_fxu_sh,nothing*2,titan_fxu_wb")
62 ;; We model the divider for the worst-case (i.e. a full 32-bit
63 ;; divide).  To model the bypass for byte-wise completion, a
64 ;; define_bypass with a guard-function could be used... however, this
65 ;; would be an optimization of doubtful value, as a large number of
66 ;; divides will operate on 32-bit variables.
68 ;; To avoid an unmanagably large automata (generating the automata
69 ;; would require well over 2GB in memory), we don't model the shared
70 ;; result bus on this one. The divider-pipeline is thus modeled
71 ;; through its latency and initial disptach bottlenecks (i.e. issue
72 ;; slots and fxu scheduler availability)
73 (define_insn_reservation "titan_fxu_div" 34
74   (and (eq_attr "type" "idiv")
75        (eq_attr "cpu" "titan"))
76   "titan_issue,titan_fxu_sh")
78 (define_insn_reservation "titan_fxu_alu" 1
79   (and (eq_attr "type" "integer,exts")
80        (eq_attr "cpu" "titan"))
81   "titan_issue,titan_fxu_sh,nothing,titan_fxu_wb")
83 ;; === BPU scheduling ===
85 (define_cpu_unit "titan_bpu_sh" "titan_bpu")
87 (define_insn_reservation "titan_bpu" 2
88   (and (eq_attr "type" "branch,jmpreg,cr_logical,delayed_cr")
89        (eq_attr "cpu" "titan"))
90   "titan_issue,titan_bpu_sh")
92 ;; === LSU scheduling ===
94 (define_cpu_unit "titan_lsu_sh" "titan_lsu")
96 ;; Loads.
97 (define_insn_reservation "titan_lsu_load" 3
98   (and (eq_attr "type" "load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,\
99                         load_l,sync")
100        (eq_attr "cpu" "titan"))
101   "titan_issue,titan_lsu_sh")
103 (define_insn_reservation "titan_lsu_fpload" 12
104   (and (eq_attr "type" "fpload,fpload_ux,fpload_u")
105        (eq_attr "cpu" "titan"))
106   "titan_issue,titan_lsu_sh")
108 ;; Note that the isync is not clearly placed within any execution
109 ;; unit. We've made the assumption that it will be running out of the
110 ;; LSU, as msync is also executed within the LSU.
111 (define_insn_reservation "titan_lsu_sync" 20
112   (and (eq_attr "type" "sync")
113        (eq_attr "cpu" "titan"))
114   "titan_issue,titan_lsu_sh*20")
116 ;; Stores.
117 (define_insn_reservation "titan_lsu_store" 12
118   (and (eq_attr "type" "store,store_ux,store_u,store_c")
119        (eq_attr "cpu" "titan"))
120   "titan_issue,titan_lsu_sh")
122 (define_insn_reservation "titan_lsu_fpstore" 12
123   (and (eq_attr "type" "fpstore,fpstore_ux,fpstore_u")
124        (eq_attr "cpu" "titan"))
125   "titan_issue,titan_lsu_sh")
127 ;; === FPU scheduling ===
129 ;; In order to keep the automaton for the Titan FPU efficient and
130 ;; maintainable, we've kept in as concise as possible and created a
131 ;; mapping for the main "choke points" only instead of modelling the
132 ;; overall flow of instructions through the FP-pipeline(s).
134 ;; The key elements modelled are:
135 ;;  * each FP-instruction takes up one of the two issue slots 
136 ;;  * the FPU runs at half the core frequency
137 ;;  * divides are not pipelined (but execute in a separate unit)
138 ;;  * the FPU has a shared result bus for all its units
140 (define_cpu_unit "titan_fp0,titan_fpdiv,titan_fpwb" "titan_fpu")
142 (define_insn_reservation "titan_fp_div_double" 72
143   (and (eq_attr "type" "ddiv")
144        (eq_attr "cpu" "titan"))
145   "titan_issue,titan_fpdiv*72,titan_fpwb")
147 (define_insn_reservation "titan_fp_div_single" 46
148   (and (eq_attr "type" "sdiv")
149        (eq_attr "cpu" "titan"))
150   "titan_issue,titan_fpdiv*46,titan_fpwb")
152 (define_insn_reservation "titan_fp_single" 12
153   (and (eq_attr "fp_type" "fp_addsub_s,fp_mul_s,fp_maddsub_s")       
154        (eq_attr "cpu" "titan"))
155   "titan_issue,titan_fp0*2,nothing*10,titan_fpwb")
157 ;; Make sure the "titan_fp" rule stays last, as it's a catch all for
158 ;; double-precision and unclassified (e.g. fsel) FP-instructions
159 (define_insn_reservation "titan_fp" 10
160   (and (eq_attr "type" "fpcompare,fp,dmul")
161        (eq_attr "cpu" "titan"))
162   "titan_issue,titan_fp0*2,nothing*8,titan_fpwb")
164 ;; Please note, that the non-pipelined FP-instructions "mcrfs",
165 ;; "mtfsb0[.]", "mtfsb1[.]", "mtfsf[.]", "mtfsfi[.]" are not
166 ;; accessible from regular language constructs (i.e. they are not used
167 ;; by the code generator, except for special purpose sequences defined
168 ;; in rs6000.md), no special provisions are made for these.