Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / config / rs6000 / titan.md
blob744d7770f280e1445b7e13cf47d672cedf456d69
1 ;; Pipeline description for the AppliedMicro Titan core.
2 ;;   Copyright (C) 2010 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 (automata_option "progress")
25 (define_automaton "titan_core,titan_fpu,titan_fxu,titan_bpu,titan_lsu")
26 (define_cpu_unit "titan_issue_0,titan_issue_1" "titan_core")
28 ;; Some useful abbreviations.
29 (define_reservation "titan_issue" "titan_issue_0|titan_issue_1")
31 ;; === FXU scheduling ===
33 (define_cpu_unit "titan_fxu_sh,titan_fxu_wb" "titan_fxu")
35 ;; The 1-cycle adder executes add, addi, subf, neg, compare and trap
36 ;; instructions. It provides its own, dedicated result-bus, so we
37 ;; don't need the titan_fxu_wb reservation to complete.
38 (define_insn_reservation "titan_fxu_adder" 1
39   (and (eq_attr "type" "cmp,fast_compare,trap")
40        (eq_attr "cpu" "titan"))
41   "titan_issue,titan_fxu_sh")
43 ;; Keep the titan_imul and titan_mulhw (half-word) rules in order, to
44 ;; ensure the proper match: the half-word instructions are tagged as
45 ;; imul3 only, whereas regular multiplys will always carry a imul tag.
47 (define_insn_reservation "titan_imul" 5
48   (and (eq_attr "type" "imul,imul2,imul_compare")
49        (eq_attr "cpu" "titan"))       
50   "titan_issue,titan_fxu_sh,nothing*5,titan_fxu_wb")  
52 (define_insn_reservation "titan_mulhw" 4
53   (and (eq_attr "type" "imul3")
54        (eq_attr "cpu" "titan"))
55   "titan_issue,titan_fxu_sh,nothing*4,titan_fxu_wb")
57 (define_bypass 2 "titan_mulhw" "titan_mulhw")
59 (define_insn_reservation "titan_fxu_shift_and_rotate" 2
60   (and (eq_attr "type" "insert_word,shift,var_shift_rotate,cntlz")
61        (eq_attr "cpu" "titan"))
62   "titan_issue,titan_fxu_sh,nothing*2,titan_fxu_wb")
64 ;; We model the divider for the worst-case (i.e. a full 32-bit
65 ;; divide).  To model the bypass for byte-wise completion, a
66 ;; define_bypass with a guard-function could be used... however, this
67 ;; would be an optimization of doubtful value, as a large number of
68 ;; divides will operate on 32-bit variables.
70 ;; To avoid an unmanagably large automata (generating the automata
71 ;; would require well over 2GB in memory), we don't model the shared
72 ;; result bus on this one. The divider-pipeline is thus modeled
73 ;; through its latency and initial disptach bottlenecks (i.e. issue
74 ;; slots and fxu scheduler availability)
75 (define_insn_reservation "titan_fxu_div" 34
76   (and (eq_attr "type" "idiv")
77        (eq_attr "cpu" "titan"))
78   "titan_issue,titan_fxu_sh")
80 (define_insn_reservation "titan_fxu_alu" 1
81   (and (eq_attr "type" "integer,exts")
82        (eq_attr "cpu" "titan"))
83   "titan_issue,titan_fxu_sh,nothing,titan_fxu_wb")
85 ;; === BPU scheduling ===
87 (define_cpu_unit "titan_bpu_sh" "titan_bpu")
89 (define_insn_reservation "titan_bpu" 2
90   (and (eq_attr "type" "branch,jmpreg,cr_logical,delayed_cr")
91        (eq_attr "cpu" "titan"))
92   "titan_issue,titan_bpu_sh")
94 ;; === LSU scheduling ===
96 (define_cpu_unit "titan_lsu_sh" "titan_lsu")
98 ;; Loads.
99 (define_insn_reservation "titan_lsu_load" 3
100   (and (eq_attr "type" "load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,\
101                         load_l,sync")
102        (eq_attr "cpu" "titan"))
103   "titan_issue,titan_lsu_sh")
105 (define_insn_reservation "titan_lsu_fpload" 12
106   (and (eq_attr "type" "fpload,fpload_ux,fpload_u")
107        (eq_attr "cpu" "titan"))
108   "titan_issue,titan_lsu_sh")
110 ;; Note that the isync is not clearly placed within any execution
111 ;; unit. We've made the assumption that it will be running out of the
112 ;; LSU, as msync is also executed within the LSU.
113 (define_insn_reservation "titan_lsu_sync" 20
114   (and (eq_attr "type" "sync")
115        (eq_attr "cpu" "titan"))
116   "titan_issue,titan_lsu_sh*20")
118 ;; Stores.
119 (define_insn_reservation "titan_lsu_store" 12
120   (and (eq_attr "type" "store,store_ux,store_u,store_c")
121        (eq_attr "cpu" "titan"))
122   "titan_issue,titan_lsu_sh")
124 (define_insn_reservation "titan_lsu_fpstore" 12
125   (and (eq_attr "type" "fpstore,fpstore_ux,fpstore_u")
126        (eq_attr "cpu" "titan"))
127   "titan_issue,titan_lsu_sh")
129 ;; === FPU scheduling ===
131 ;; In order to keep the automaton for the Titan FPU efficient and
132 ;; maintainable, we've kept in as concise as possible and created a
133 ;; mapping for the main "choke points" only instead of modelling the
134 ;; overall flow of instructions through the FP-pipeline(s).
136 ;; The key elements modelled are:
137 ;;  * each FP-instruction takes up one of the two issue slots 
138 ;;  * the FPU runs at half the core frequency
139 ;;  * divides are not pipelined (but execute in a separate unit)
140 ;;  * the FPU has a shared result bus for all its units
142 (define_cpu_unit "titan_fp0,titan_fpdiv,titan_fpwb" "titan_fpu")
144 (define_insn_reservation "titan_fp_div_double" 72
145   (and (eq_attr "type" "ddiv")
146        (eq_attr "cpu" "titan"))
147   "titan_issue,titan_fpdiv*72,titan_fpwb")
149 (define_insn_reservation "titan_fp_div_single" 46
150   (and (eq_attr "type" "sdiv")
151        (eq_attr "cpu" "titan"))
152   "titan_issue,titan_fpdiv*46,titan_fpwb")
154 (define_insn_reservation "titan_fp_single" 12
155   (and (eq_attr "fp_type" "fp_addsub_s,fp_mul_s,fp_maddsub_s")       
156        (eq_attr "cpu" "titan"))
157   "titan_issue,titan_fp0*2,nothing*10,titan_fpwb")
159 ;; Make sure the "titan_fp" rule stays last, as it's a catch all for
160 ;; double-precision and unclassified (e.g. fsel) FP-instructions
161 (define_insn_reservation "titan_fp" 10
162   (and (eq_attr "type" "fpcompare,fp,dmul")
163        (eq_attr "cpu" "titan"))
164   "titan_issue,titan_fp0*2,nothing*8,titan_fpwb")
166 ;; Please note, that the non-pipelined FP-instructions "mcrfs",
167 ;; "mtfsb0[.]", "mtfsb1[.]", "mtfsf[.]", "mtfsfi[.]" are not
168 ;; accessible from regular language constructs (i.e. they are not used
169 ;; by the code generator, except for special purpose sequences defined
170 ;; in rs6000.md), no special provisions are made for these.