1;; Marvell WMMX2 pipeline description
2;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
3;; Written by Marvell, Inc.
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.
11
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.
16
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/>.
20
21
22(define_automaton "marvell_f_iwmmxt")
23
24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25;; Pipelines
26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27
28;; This is a 7-stage pipelines:
29;;
30;;    MD | MI | ME1 | ME2 | ME3 | ME4 | MW
31;;
32;; There are various bypasses modelled to a greater or lesser extent.
33;;
34;; Latencies in this file correspond to the number of cycles after
35;; the issue stage that it takes for the result of the instruction to
36;; be computed, or for its side-effects to occur.
37
38(define_cpu_unit "mf_iwmmxt_MD" "marvell_f_iwmmxt")
39(define_cpu_unit "mf_iwmmxt_MI" "marvell_f_iwmmxt")
40(define_cpu_unit "mf_iwmmxt_ME1" "marvell_f_iwmmxt")
41(define_cpu_unit "mf_iwmmxt_ME2" "marvell_f_iwmmxt")
42(define_cpu_unit "mf_iwmmxt_ME3" "marvell_f_iwmmxt")
43(define_cpu_unit "mf_iwmmxt_ME4" "marvell_f_iwmmxt")
44(define_cpu_unit "mf_iwmmxt_MW" "marvell_f_iwmmxt")
45
46(define_reservation "mf_iwmmxt_ME"
47      "mf_iwmmxt_ME1,mf_iwmmxt_ME2,mf_iwmmxt_ME3,mf_iwmmxt_ME4"
48)
49
50(define_reservation "mf_iwmmxt_pipeline"
51      "mf_iwmmxt_MD, mf_iwmmxt_MI, mf_iwmmxt_ME, mf_iwmmxt_MW"
52)
53
54;; An attribute to indicate whether our reservations are applicable.
55(define_attr "marvell_f_iwmmxt" "yes,no"
56  (const (if_then_else (symbol_ref "arm_arch_iwmmxt")
57                       (const_string "yes") (const_string "no"))))
58
59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60;; instruction classes
61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62
63;; An attribute appended to instructions for classification
64
65(define_attr "wmmxt_shift" "yes,no"
66  (if_then_else (eq_attr "type" "wmmx_wror, wmmx_wsll, wmmx_wsra, wmmx_wsrl")
67		(const_string "yes") (const_string "no"))
68)
69
70(define_attr "wmmxt_pack" "yes,no"
71  (if_then_else (eq_attr "type" "wmmx_waligni, wmmx_walignr, wmmx_wmerge,\
72                                 wmmx_wpack, wmmx_wshufh, wmmx_wunpckeh,\
73                                 wmmx_wunpckih, wmmx_wunpckel, wmmx_wunpckil")
74		(const_string "yes") (const_string "no"))
75)
76
77(define_attr "wmmxt_mult_c1" "yes,no"
78  (if_then_else (eq_attr "type" "wmmx_wmac, wmmx_wmadd, wmmx_wmiaxy,\
79                                 wmmx_wmiawxy, wmmx_wmulw, wmmx_wqmiaxy,\
80                                 wmmx_wqmulwm")
81		(const_string "yes") (const_string "no"))
82)
83
84(define_attr "wmmxt_mult_c2" "yes,no"
85  (if_then_else (eq_attr "type" "wmmx_wmul, wmmx_wqmulm")
86		(const_string "yes") (const_string "no"))
87)
88
89(define_attr "wmmxt_alu_c1" "yes,no"
90  (if_then_else (eq_attr "type" "wmmx_wabs, wmmx_wabsdiff, wmmx_wand,\
91                                 wmmx_wandn, wmmx_wmov, wmmx_wor, wmmx_wxor")
92	        (const_string "yes") (const_string "no"))
93)
94
95(define_attr "wmmxt_alu_c2" "yes,no"
96  (if_then_else (eq_attr "type" "wmmx_wacc, wmmx_wadd, wmmx_waddsubhx,\
97                                 wmmx_wavg2, wmmx_wavg4, wmmx_wcmpeq,\
98                                 wmmx_wcmpgt, wmmx_wmax, wmmx_wmin,\
99                                 wmmx_wsub, wmmx_waddbhus, wmmx_wsubaddhx")
100		(const_string "yes") (const_string "no"))
101)
102
103(define_attr "wmmxt_alu_c3" "yes,no"
104  (if_then_else (eq_attr "type" "wmmx_wsad")
105	        (const_string "yes") (const_string "no"))
106)
107
108(define_attr "wmmxt_transfer_c1" "yes,no"
109  (if_then_else (eq_attr "type" "wmmx_tbcst, wmmx_tinsr,\
110                                 wmmx_tmcr, wmmx_tmcrr")
111                (const_string "yes") (const_string "no"))
112)
113
114(define_attr "wmmxt_transfer_c2" "yes,no"
115  (if_then_else (eq_attr "type" "wmmx_textrm, wmmx_tmovmsk,\
116                                 wmmx_tmrc, wmmx_tmrrc")
117	        (const_string "yes") (const_string "no"))
118)
119
120(define_attr "wmmxt_transfer_c3" "yes,no"
121  (if_then_else (eq_attr "type" "wmmx_tmia, wmmx_tmiaph, wmmx_tmiaxy")
122	        (const_string "yes") (const_string "no"))
123)
124
125;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126;; Main description
127;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
128
129(define_insn_reservation "marvell_f_iwmmxt_alu_c1" 1
130  (and (eq_attr "marvell_f_iwmmxt" "yes")
131       (eq_attr "wmmxt_alu_c1" "yes"))
132  "mf_iwmmxt_pipeline")
133
134(define_insn_reservation "marvell_f_iwmmxt_pack" 1
135  (and (eq_attr "marvell_f_iwmmxt" "yes")
136       (eq_attr "wmmxt_pack" "yes"))
137  "mf_iwmmxt_pipeline")
138
139(define_insn_reservation "marvell_f_iwmmxt_shift" 1
140  (and (eq_attr "marvell_f_iwmmxt" "yes")
141       (eq_attr "wmmxt_shift" "yes"))
142  "mf_iwmmxt_pipeline")
143
144(define_insn_reservation "marvell_f_iwmmxt_transfer_c1" 1
145  (and (eq_attr "marvell_f_iwmmxt" "yes")
146       (eq_attr "wmmxt_transfer_c1" "yes"))
147  "mf_iwmmxt_pipeline")
148
149(define_insn_reservation "marvell_f_iwmmxt_transfer_c2" 5
150  (and (eq_attr "marvell_f_iwmmxt" "yes")
151       (eq_attr "wmmxt_transfer_c2" "yes"))
152  "mf_iwmmxt_pipeline")
153
154(define_insn_reservation "marvell_f_iwmmxt_alu_c2" 2
155  (and (eq_attr "marvell_f_iwmmxt" "yes")
156       (eq_attr "wmmxt_alu_c2" "yes"))
157  "mf_iwmmxt_pipeline")
158
159(define_insn_reservation "marvell_f_iwmmxt_alu_c3" 3
160  (and (eq_attr "marvell_f_iwmmxt" "yes")
161       (eq_attr "wmmxt_alu_c3" "yes"))
162  "mf_iwmmxt_pipeline")
163
164(define_insn_reservation "marvell_f_iwmmxt_transfer_c3" 4
165  (and (eq_attr "marvell_f_iwmmxt" "yes")
166       (eq_attr "wmmxt_transfer_c3" "yes"))
167  "mf_iwmmxt_pipeline")
168
169(define_insn_reservation "marvell_f_iwmmxt_mult_c1" 4
170  (and (eq_attr "marvell_f_iwmmxt" "yes")
171       (eq_attr "wmmxt_mult_c1" "yes"))
172  "mf_iwmmxt_pipeline")
173
174;There is a forwarding path from ME3 stage
175(define_insn_reservation "marvell_f_iwmmxt_mult_c2" 3
176  (and (eq_attr "marvell_f_iwmmxt" "yes")
177       (eq_attr "wmmxt_mult_c2" "yes"))
178  "mf_iwmmxt_pipeline")
179
180(define_insn_reservation "marvell_f_iwmmxt_wstr" 0
181  (and (eq_attr "marvell_f_iwmmxt" "yes")
182       (eq_attr "type" "wmmx_wstr"))
183  "mf_iwmmxt_pipeline")
184
185;There is a forwarding path from MW stage
186(define_insn_reservation "marvell_f_iwmmxt_wldr" 5
187  (and (eq_attr "marvell_f_iwmmxt" "yes")
188       (eq_attr "type" "wmmx_wldr"))
189  "mf_iwmmxt_pipeline")
190