1 |
282 |
jeremybenn |
;; Pipeline model for ST Microelectronics Loongson-2E/2F cores.
|
2 |
|
|
|
3 |
|
|
;; Copyright (C) 2008 Free Software Foundation, Inc.
|
4 |
|
|
;; Contributed by CodeSourcery.
|
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 |
|
|
;; Automaton for integer instructions.
|
21 |
|
|
(define_automaton "ls2_alu")
|
22 |
|
|
|
23 |
|
|
;; ALU1 and ALU2.
|
24 |
|
|
;; We need to query these units to adjust round-robin counter.
|
25 |
|
|
(define_query_cpu_unit "ls2_alu1_core,ls2_alu2_core" "ls2_alu")
|
26 |
|
|
|
27 |
|
|
;; Pseudo units to help modeling of ALU1/2 round-robin dispatch strategy.
|
28 |
|
|
(define_cpu_unit "ls2_alu1_turn,ls2_alu2_turn" "ls2_alu")
|
29 |
|
|
|
30 |
|
|
;; Pseudo units to enable/disable ls2_alu[12]_turn units.
|
31 |
|
|
;; ls2_alu[12]_turn unit can be subscribed only after ls2_alu[12]_turn_enabled
|
32 |
|
|
;; unit is subscribed.
|
33 |
|
|
(define_cpu_unit "ls2_alu1_turn_enabled,ls2_alu2_turn_enabled" "ls2_alu")
|
34 |
|
|
(presence_set "ls2_alu1_turn" "ls2_alu1_turn_enabled")
|
35 |
|
|
(presence_set "ls2_alu2_turn" "ls2_alu2_turn_enabled")
|
36 |
|
|
|
37 |
|
|
;; Reservations for ALU1 (ALU2) instructions.
|
38 |
|
|
;; Instruction goes to ALU1 (ALU2) and makes next ALU1/2 instruction to
|
39 |
|
|
;; be dispatched to ALU2 (ALU1).
|
40 |
|
|
(define_reservation "ls2_alu1"
|
41 |
|
|
"(ls2_alu1_core+ls2_alu2_turn_enabled)|ls2_alu1_core")
|
42 |
|
|
(define_reservation "ls2_alu2"
|
43 |
|
|
"(ls2_alu2_core+ls2_alu1_turn_enabled)|ls2_alu2_core")
|
44 |
|
|
|
45 |
|
|
;; Reservation for ALU1/2 instructions.
|
46 |
|
|
;; Instruction will go to ALU1 iff ls2_alu1_turn_enabled is subscribed and
|
47 |
|
|
;; switch the turn to ALU2 by subscribing ls2_alu2_turn_enabled.
|
48 |
|
|
;; Or to ALU2 otherwise.
|
49 |
|
|
(define_reservation "ls2_alu"
|
50 |
|
|
"(ls2_alu1_core+ls2_alu1_turn+ls2_alu2_turn_enabled)
|
51 |
|
|
|(ls2_alu1_core+ls2_alu1_turn)
|
52 |
|
|
|(ls2_alu2_core+ls2_alu2_turn+ls2_alu1_turn_enabled)
|
53 |
|
|
|(ls2_alu2_core+ls2_alu2_turn)")
|
54 |
|
|
|
55 |
|
|
;; Automaton for floating-point instructions.
|
56 |
|
|
(define_automaton "ls2_falu")
|
57 |
|
|
|
58 |
|
|
;; FALU1 and FALU2.
|
59 |
|
|
;; We need to query these units to adjust round-robin counter.
|
60 |
|
|
(define_query_cpu_unit "ls2_falu1_core,ls2_falu2_core" "ls2_falu")
|
61 |
|
|
|
62 |
|
|
;; Pseudo units to help modeling of FALU1/2 round-robin dispatch strategy.
|
63 |
|
|
(define_cpu_unit "ls2_falu1_turn,ls2_falu2_turn" "ls2_falu")
|
64 |
|
|
|
65 |
|
|
;; Pseudo units to enable/disable ls2_falu[12]_turn units.
|
66 |
|
|
;; ls2_falu[12]_turn unit can be subscribed only after
|
67 |
|
|
;; ls2_falu[12]_turn_enabled unit is subscribed.
|
68 |
|
|
(define_cpu_unit "ls2_falu1_turn_enabled,ls2_falu2_turn_enabled" "ls2_falu")
|
69 |
|
|
(presence_set "ls2_falu1_turn" "ls2_falu1_turn_enabled")
|
70 |
|
|
(presence_set "ls2_falu2_turn" "ls2_falu2_turn_enabled")
|
71 |
|
|
|
72 |
|
|
;; Reservations for FALU1 (FALU2) instructions.
|
73 |
|
|
;; Instruction goes to FALU1 (FALU2) and makes next FALU1/2 instruction to
|
74 |
|
|
;; be dispatched to FALU2 (FALU1).
|
75 |
|
|
(define_reservation "ls2_falu1"
|
76 |
|
|
"(ls2_falu1_core+ls2_falu2_turn_enabled)|ls2_falu1_core")
|
77 |
|
|
(define_reservation "ls2_falu2"
|
78 |
|
|
"(ls2_falu2_core+ls2_falu1_turn_enabled)|ls2_falu2_core")
|
79 |
|
|
|
80 |
|
|
;; Reservation for FALU1/2 instructions.
|
81 |
|
|
;; Instruction will go to FALU1 iff ls2_falu1_turn_enabled is subscribed and
|
82 |
|
|
;; switch the turn to FALU2 by subscribing ls2_falu2_turn_enabled.
|
83 |
|
|
;; Or to FALU2 otherwise.
|
84 |
|
|
(define_reservation "ls2_falu"
|
85 |
|
|
"(ls2_falu1+ls2_falu1_turn+ls2_falu2_turn_enabled)
|
86 |
|
|
|(ls2_falu1+ls2_falu1_turn)
|
87 |
|
|
|(ls2_falu2+ls2_falu2_turn+ls2_falu1_turn_enabled)
|
88 |
|
|
|(ls2_falu2+ls2_falu2_turn)")
|
89 |
|
|
|
90 |
|
|
;; The following 4 instructions each subscribe one of
|
91 |
|
|
;; ls2_[f]alu{1,2}_turn_enabled units according to this attribute.
|
92 |
|
|
;; These instructions are used in mips.c: sched_ls2_dfa_post_advance_cycle.
|
93 |
|
|
|
94 |
|
|
(define_attr "ls2_turn_type" "alu1,alu2,falu1,falu2,unknown"
|
95 |
|
|
(const_string "unknown"))
|
96 |
|
|
|
97 |
|
|
;; Subscribe ls2_alu1_turn_enabled.
|
98 |
|
|
(define_insn "ls2_alu1_turn_enabled_insn"
|
99 |
|
|
[(unspec [(const_int 0)] UNSPEC_LOONGSON_ALU1_TURN_ENABLED_INSN)]
|
100 |
|
|
"TUNE_LOONGSON_2EF"
|
101 |
|
|
{ gcc_unreachable (); }
|
102 |
|
|
[(set_attr "ls2_turn_type" "alu1")])
|
103 |
|
|
|
104 |
|
|
(define_insn_reservation "ls2_alu1_turn_enabled" 0
|
105 |
|
|
(eq_attr "ls2_turn_type" "alu1")
|
106 |
|
|
"ls2_alu1_turn_enabled")
|
107 |
|
|
|
108 |
|
|
;; Subscribe ls2_alu2_turn_enabled.
|
109 |
|
|
(define_insn "ls2_alu2_turn_enabled_insn"
|
110 |
|
|
[(unspec [(const_int 0)] UNSPEC_LOONGSON_ALU2_TURN_ENABLED_INSN)]
|
111 |
|
|
"TUNE_LOONGSON_2EF"
|
112 |
|
|
{ gcc_unreachable (); }
|
113 |
|
|
[(set_attr "ls2_turn_type" "alu2")])
|
114 |
|
|
|
115 |
|
|
(define_insn_reservation "ls2_alu2_turn_enabled" 0
|
116 |
|
|
(eq_attr "ls2_turn_type" "alu2")
|
117 |
|
|
"ls2_alu2_turn_enabled")
|
118 |
|
|
|
119 |
|
|
;; Subscribe ls2_falu1_turn_enabled.
|
120 |
|
|
(define_insn "ls2_falu1_turn_enabled_insn"
|
121 |
|
|
[(unspec [(const_int 0)] UNSPEC_LOONGSON_FALU1_TURN_ENABLED_INSN)]
|
122 |
|
|
"TUNE_LOONGSON_2EF"
|
123 |
|
|
{ gcc_unreachable (); }
|
124 |
|
|
[(set_attr "ls2_turn_type" "falu1")])
|
125 |
|
|
|
126 |
|
|
(define_insn_reservation "ls2_falu1_turn_enabled" 0
|
127 |
|
|
(eq_attr "ls2_turn_type" "falu1")
|
128 |
|
|
"ls2_falu1_turn_enabled")
|
129 |
|
|
|
130 |
|
|
;; Subscribe ls2_falu2_turn_enabled.
|
131 |
|
|
(define_insn "ls2_falu2_turn_enabled_insn"
|
132 |
|
|
[(unspec [(const_int 0)] UNSPEC_LOONGSON_FALU2_TURN_ENABLED_INSN)]
|
133 |
|
|
"TUNE_LOONGSON_2EF"
|
134 |
|
|
{ gcc_unreachable (); }
|
135 |
|
|
[(set_attr "ls2_turn_type" "falu2")])
|
136 |
|
|
|
137 |
|
|
(define_insn_reservation "ls2_falu2_turn_enabled" 0
|
138 |
|
|
(eq_attr "ls2_turn_type" "falu2")
|
139 |
|
|
"ls2_falu2_turn_enabled")
|
140 |
|
|
|
141 |
|
|
;; Automaton for memory operations.
|
142 |
|
|
(define_automaton "ls2_mem")
|
143 |
|
|
|
144 |
|
|
;; Memory unit.
|
145 |
|
|
(define_query_cpu_unit "ls2_mem" "ls2_mem")
|
146 |
|
|
|
147 |
|
|
;; Reservation for integer instructions.
|
148 |
|
|
(define_insn_reservation "ls2_alu" 2
|
149 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
150 |
|
|
(eq_attr "type" "arith,condmove,const,logical,mfhilo,move,
|
151 |
|
|
mthilo,nop,shift,signext,slt"))
|
152 |
|
|
"ls2_alu")
|
153 |
|
|
|
154 |
|
|
;; Reservation for branch instructions.
|
155 |
|
|
(define_insn_reservation "ls2_branch" 2
|
156 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
157 |
|
|
(eq_attr "type" "branch,jump,call,trap"))
|
158 |
|
|
"ls2_alu1")
|
159 |
|
|
|
160 |
|
|
;; Reservation for integer multiplication instructions.
|
161 |
|
|
(define_insn_reservation "ls2_imult" 5
|
162 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
163 |
|
|
(eq_attr "type" "imul,imul3nc"))
|
164 |
|
|
"ls2_alu2,ls2_alu2_core")
|
165 |
|
|
|
166 |
|
|
;; Reservation for integer division / remainder instructions.
|
167 |
|
|
;; These instructions use the SRT algorithm and hence take 2-38 cycles.
|
168 |
|
|
(define_insn_reservation "ls2_idiv" 20
|
169 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
170 |
|
|
(eq_attr "type" "idiv,idiv3"))
|
171 |
|
|
"ls2_alu2,ls2_alu2_core*18")
|
172 |
|
|
|
173 |
|
|
;; Reservation for memory load instructions.
|
174 |
|
|
(define_insn_reservation "ls2_load" 5
|
175 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
176 |
|
|
(eq_attr "type" "load,fpload,mfc,mtc"))
|
177 |
|
|
"ls2_mem")
|
178 |
|
|
|
179 |
|
|
(define_insn_reservation "ls2_prefetch" 0
|
180 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
181 |
|
|
(eq_attr "type" "prefetch,prefetchx"))
|
182 |
|
|
"ls2_mem")
|
183 |
|
|
|
184 |
|
|
;; Reservation for memory store instructions.
|
185 |
|
|
;; With stores we assume they don't alias with dependent loads.
|
186 |
|
|
;; Therefore we set the latency to zero.
|
187 |
|
|
(define_insn_reservation "ls2_store" 0
|
188 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
189 |
|
|
(eq_attr "type" "store,fpstore"))
|
190 |
|
|
"ls2_mem")
|
191 |
|
|
|
192 |
|
|
;; Reservation for floating-point instructions of latency 3.
|
193 |
|
|
(define_insn_reservation "ls2_fp3" 3
|
194 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
195 |
|
|
(eq_attr "type" "fabs,fneg,fcmp,fmove"))
|
196 |
|
|
"ls2_falu1")
|
197 |
|
|
|
198 |
|
|
;; Reservation for floating-point instructions of latency 5.
|
199 |
|
|
(define_insn_reservation "ls2_fp5" 5
|
200 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
201 |
|
|
(eq_attr "type" "fcvt"))
|
202 |
|
|
"ls2_falu1")
|
203 |
|
|
|
204 |
|
|
;; Reservation for floating-point instructions that can go
|
205 |
|
|
;; to either of FALU1/2 units.
|
206 |
|
|
(define_insn_reservation "ls2_falu" 7
|
207 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
208 |
|
|
(eq_attr "type" "fadd,fmul,fmadd"))
|
209 |
|
|
"ls2_falu")
|
210 |
|
|
|
211 |
|
|
;; Reservation for floating-point division / remainder instructions.
|
212 |
|
|
;; These instructions use the SRT algorithm and hence take a variable amount
|
213 |
|
|
;; of cycles:
|
214 |
|
|
;; div.s takes 5-11 cycles
|
215 |
|
|
;; div.d takes 5-18 cycles
|
216 |
|
|
(define_insn_reservation "ls2_fdiv" 9
|
217 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
218 |
|
|
(eq_attr "type" "fdiv"))
|
219 |
|
|
"ls2_falu2,ls2_falu2_core*7")
|
220 |
|
|
|
221 |
|
|
;; Reservation for floating-point sqrt instructions.
|
222 |
|
|
;; These instructions use the SRT algorithm and hence take a variable amount
|
223 |
|
|
;; of cycles:
|
224 |
|
|
;; sqrt.s takes 5-17 cycles
|
225 |
|
|
;; sqrt.d takes 5-32 cycles
|
226 |
|
|
(define_insn_reservation "ls2_fsqrt" 15
|
227 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
228 |
|
|
(eq_attr "type" "fsqrt"))
|
229 |
|
|
"ls2_falu2,ls2_falu2_core*13")
|
230 |
|
|
|
231 |
|
|
;; Two consecutive ALU instructions.
|
232 |
|
|
(define_insn_reservation "ls2_multi" 4
|
233 |
|
|
(and (eq_attr "cpu" "loongson_2e,loongson_2f")
|
234 |
|
|
(eq_attr "type" "multi"))
|
235 |
|
|
"(ls2_alu1,ls2_alu2_core)|(ls2_alu2,ls2_alu1_core)")
|
236 |
|
|
|
237 |
|
|
;; Reservation for everything else. Normally, this reservation
|
238 |
|
|
;; will only be used to handle cases like compiling for non-loongson
|
239 |
|
|
;; CPUs with -mtune=loongson2?.
|
240 |
|
|
;;
|
241 |
|
|
;; This reservation depends upon the fact that DFA will check
|
242 |
|
|
;; reservations in the same order as they appear in the file.
|
243 |
|
|
(define_insn_reservation "ls2_unknown" 1
|
244 |
|
|
(eq_attr "cpu" "loongson_2e,loongson_2f")
|
245 |
|
|
"ls2_alu1_core+ls2_alu2_core+ls2_falu1_core+ls2_falu2_core+ls2_mem")
|