1; Copyright 2011 Free Software Foundation, Inc.
2;
3; Contributed by Red Hat Inc;
4;
5; This file is part of the GNU Binutils.
6;
7; This program is free software; you can redistribute it and/or modify
8; it under the terms of the GNU General Public License as published by
9; the Free Software Foundation; either version 3 of the License, or
10; (at your option) any later version.
11;
12; This program is distributed in the hope that it will be useful,
13; but WITHOUT ANY WARRANTY; without even the implied warranty of
14; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15; GNU General Public License for more details.
16;
17; You should have received a copy of the GNU General Public License
18; along with this program; if not, write to the Free Software
19; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20; MA 02110-1301, USA.
21
22; Insns introduced for the MeP-c5 core
23;
24
25(dnf f-c5n4     "extended field"     (all-mep-core-isas)   16  4)
26(dnf f-c5n5     "extended field"     (all-mep-core-isas)   20  4)
27(dnf f-c5n6     "extended field"     (all-mep-core-isas)   24  4)
28(dnf f-c5n7     "extended field"     (all-mep-core-isas)   28  4)
29(dnf f-rl5      "register l c5"      (all-mep-core-isas)   20  4)
30(df  f-12s20    "extended field"     (all-mep-core-isas)   20  12  INT #f #f)
31
32(dnop rl5       "register Rl c5"     (all-mep-core-isas) h-gpr   f-rl5)
33(dnop cdisp12   "copro addend (12 bits)" (all-mep-core-isas) h-sint  f-12s20)
34
35(dnci stcb_r "store in control bus space" (VOLATILE (MACH c5))
36     "stcb $rn,($rma)"
37     (+ MAJ_7 rn rma (f-sub4 12))
38     (c-call VOID "do_stcb" rn (and rma #xffff))
39     ((mep (unit u-use-gpr (in usereg rn))
40	   (unit u-use-gpr (in usereg rma))
41	   (unit u-exec)
42	   (unit u-stcb))))
43
44(dnci ldcb_r "load from control bus space" (VOLATILE (MACH c5) (LATENCY 3))
45     "ldcb $rn,($rma)"
46     (+ MAJ_7 rn rma (f-sub4 13))
47     (set rn (c-call SI "do_ldcb" (and rma #xffff)))
48      ((mep (unit u-use-gpr (in usereg rma))
49	    (unit u-ldcb)
50	    (unit u-exec)
51	    (unit u-ldcb-gpr (out loadreg rn)))))
52
53(dnci pref "cache prefetch" ((MACH c5) VOLATILE)
54     "pref $cimm4,($rma)"
55     (+ MAJ_7 cimm4 rma (f-sub4 5))
56     (sequence ()
57	       (c-call VOID "check_option_dcache" pc)
58	       (c-call VOID "do_cache_prefetch" cimm4 rma pc))
59     ((mep (unit u-use-gpr (in usereg rma))
60	   (unit u-exec))))
61
62(dnci prefd "cache prefetch" ((MACH c5) VOLATILE)
63     "pref $cimm4,$sdisp16($rma)"
64     (+ MAJ_15 cimm4 rma (f-sub4 3) sdisp16)
65     (sequence ()
66	       (c-call VOID "check_option_dcache" pc)
67	       (c-call VOID "do_cache_prefetch" cimm4 (add INT rma (ext SI sdisp16)) pc))
68     ((mep (unit u-use-gpr (in usereg rma))
69	   (unit u-exec))))
70
71(dnci casb3 "compare and swap byte 3" ((MACH c5) VOLATILE OPTIONAL_BIT_INSN)
72      "casb3 $rl5,$rn,($rm)"
73      (+ MAJ_15 rn rm (f-sub4 #x1) (f-c5n4 #x2) rl5 (f-c5n6 #x0) (f-c5n7 #x0))
74      (sequence ()
75		(c-call VOID "do_casb3" (index-of rl5) rn rm pc)
76		(set rl5 rl5)
77		)
78      ((mep (unit u-use-gpr (in usereg rl5))
79	    (unit u-load-gpr (out loadreg rl5))
80	    (unit u-exec))))
81
82(dnci cash3 "compare and swap halfword 3" ((MACH c5) VOLATILE OPTIONAL_BIT_INSN)
83      "cash3 $rl5,$rn,($rm)"
84      (+ MAJ_15 rn rm (f-sub4 #x1) (f-c5n4 #x2) rl5 (f-c5n6 #x0) (f-c5n7 #x1))
85      (sequence ()
86		(c-call VOID "do_cash3" (index-of rl5) rn rm pc)
87		(set rl5 rl5)
88		)
89      ((mep (unit u-use-gpr (in usereg rl5))
90	    (unit u-load-gpr (out loadreg rl5))
91	    (unit u-exec))))
92
93(dnci casw3 "compare and swap word 3" ((MACH c5) VOLATILE OPTIONAL_BIT_INSN)
94      "casw3 $rl5,$rn,($rm)"
95      (+ MAJ_15 rn rm (f-sub4 #x1) (f-c5n4 #x2) rl5 (f-c5n6 #x0) (f-c5n7 #x2))
96      (sequence ()
97		(c-call VOID "do_casw3" (index-of rl5) rn rm pc)
98		(set rl5 rl5)
99		)
100      ((mep (unit u-use-gpr (in usereg rl5))
101	    (unit u-load-gpr (out loadreg rl5))
102	    (unit u-exec))))
103
104
105
106(dnci sbcp "store byte coprocessor" (OPTIONAL_CP_INSN (STALL STORE) (MACH c5))
107     "sbcp $crn,$cdisp12($rma)"
108     (+ MAJ_15 crn rma (f-sub4 6) (f-ext4 0) cdisp12)
109     (sequence ()
110	       (c-call "check_option_cp" pc)
111	       (c-call VOID "check_write_to_text" (add rma (ext SI cdisp12)))
112	       (set (mem QI (add rma (ext SI cdisp12))) (and crn #xff)))
113     ((mep (unit u-use-gpr (in usereg rma))
114	   (unit u-exec))))
115
116(dnci lbcp "load byte coprocessor" (OPTIONAL_CP_INSN (STALL STORE) (MACH c5))
117     "lbcp $crn,$cdisp12($rma)"
118     (+ MAJ_15 crn rma (f-sub4 6) (f-ext4 4) cdisp12)
119     (sequence ()
120	       (c-call "check_option_cp" pc)
121	       (set crn (ext SI (mem QI (add rma (ext SI cdisp12))))))
122     ((mep (unit u-use-gpr (in usereg rma))
123	   (unit u-exec))))
124
125(dnci lbucp "load byte coprocessor" (OPTIONAL_CP_INSN (STALL STORE) (MACH c5))
126     "lbucp $crn,$cdisp12($rma)"
127     (+ MAJ_15 crn rma (f-sub4 6) (f-ext4 12) cdisp12)
128     (sequence ()
129	       (c-call "check_option_cp" pc)
130	       (set crn (zext SI (mem QI (add rma (ext SI cdisp12))))))
131     ((mep (unit u-use-gpr (in usereg rma))
132	   (unit u-exec))))
133
134
135(dnci shcp "store half-word coprocessor" (OPTIONAL_CP_INSN (STALL STORE) (MACH c5))
136     "shcp $crn,$cdisp12($rma)"
137     (+ MAJ_15 crn rma (f-sub4 6) (f-ext4 1) cdisp12)
138     (sequence ()
139	       (c-call "check_option_cp" pc)
140	       (c-call VOID "check_write_to_text" (add rma (ext SI cdisp12)))
141	       (set (mem HI (add rma (ext SI cdisp12))) (and crn #xffff)))
142     ((mep (unit u-use-gpr (in usereg rma))
143	   (unit u-exec))))
144
145(dnci lhcp "load half-word coprocessor" (OPTIONAL_CP_INSN (STALL STORE) (MACH c5))
146     "lhcp $crn,$cdisp12($rma)"
147     (+ MAJ_15 crn rma (f-sub4 6) (f-ext4 5) cdisp12)
148     (sequence ()
149	       (c-call "check_option_cp" pc)
150	       (set crn (ext SI (mem HI (add rma (ext SI cdisp12))))))
151     ((mep (unit u-use-gpr (in usereg rma))
152	   (unit u-exec))))
153
154(dnci lhucp "load half-word coprocessor" (OPTIONAL_CP_INSN (STALL STORE) (MACH c5))
155     "lhucp $crn,$cdisp12($rma)"
156     (+ MAJ_15 crn rma (f-sub4 6) (f-ext4 13) cdisp12)
157     (sequence ()
158	       (c-call "check_option_cp" pc)
159	       (set crn (zext SI (mem HI (add rma (ext SI cdisp12))))))
160     ((mep (unit u-use-gpr (in usereg rma))
161	   (unit u-exec))))
162
163
164(dnci lbucpa "load byte coprocessor" (OPTIONAL_CP_INSN (STALL LOAD) (MACH c5))
165     "lbucpa $crn,($rma+),$cdisp10"
166     (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #xC) (f-ext62 #x0) cdisp10)
167     (sequence ()
168	       (c-call "check_option_cp" pc)
169	       (set crn (zext SI (mem QI rma)))
170	       (set rma (add rma cdisp10)))
171     ((mep (unit u-use-gpr (in usereg rma))
172	   (unit u-exec))))
173
174(dnci lhucpa "load half-word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD) (MACH c5))
175     "lhucpa $crn,($rma+),$cdisp10a2"
176     (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #xD) (f-ext62 #x0) cdisp10a2)
177     (sequence ()
178	       (c-call "check_option_cp" pc)
179	       (set crn (zext SI (mem HI (and rma (inv SI 1)))))
180	       (set rma (add rma (ext SI cdisp10a2))))
181     ((mep (unit u-use-gpr (in usereg rma))
182	   (unit u-exec))))
183
184(dnci lbucpm0 "lbucpm0" (OPTIONAL_CP_INSN (MACH c5))
185     "lbucpm0 $crn,($rma+),$cdisp10"
186     (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #xc) (f-ext62 #x2) cdisp10)
187     (sequence ()
188	       (c-call "check_option_cp" pc)
189	       (set crn (zext SI (mem QI rma)))
190	       (set rma (mod0 cdisp10)))
191     ((mep (unit u-use-gpr (in usereg rma))
192	   (unit u-exec))))
193
194(dnci lhucpm0 "lhucpm0" (OPTIONAL_CP_INSN (MACH c5))
195     "lhucpm0 $crn,($rma+),$cdisp10a2"
196     (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #xd) (f-ext62 #x2) cdisp10a2)
197     (sequence ()
198	       (c-call "check_option_cp" pc)
199	       (set crn (zext SI (mem HI (and rma (inv SI 1)))))
200	       (set rma (mod0 cdisp10a2)))
201     ((mep (unit u-use-gpr (in usereg rma))
202	   (unit u-exec))))
203
204(dnci lbucpm1 "lbucpm1" (OPTIONAL_CP_INSN (MACH c5))
205     "lbucpm1 $crn,($rma+),$cdisp10"
206     (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #xc) (f-ext62 #x3) cdisp10)
207     (sequence ()
208	       (c-call "check_option_cp" pc)
209	       (set crn (zext SI (mem QI rma)))
210	       (set rma (mod1 cdisp10)))
211     ((mep (unit u-use-gpr (in usereg rma))
212	   (unit u-exec))))
213
214(dnci lhucpm1 "lhucpm1" (OPTIONAL_CP_INSN (MACH c5))
215     "lhucpm1 $crn,($rma+),$cdisp10a2"
216     (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #xd) (f-ext62 #x3) cdisp10a2)
217     (sequence ()
218	       (c-call "check_option_cp" pc)
219	       (set crn (zext SI (mem HI (and rma (inv SI 1)))))
220	       (set rma (mod1 cdisp10a2)))
221     ((mep (unit u-use-gpr (in usereg rma))
222	   (unit u-exec))))
223
224(dnci uci "uci" ((MACH c5) VOLATILE)
225     "uci $rn,$rm,$uimm16"
226     (+ MAJ_15 rn rm (f-sub4 2) simm16)
227     (set rn (c-call SI "do_UCI" rn rm (zext SI uimm16) pc))
228     ((mep (unit u-use-gpr (in usereg rm))
229	   (unit u-use-gpr (in usereg rn))
230	   (unit u-exec))))
231
232(dnf f-c5-rnm     "register n/m"              (all-mep-isas)    4  8)
233(dnf f-c5-rm      "register m"              (all-mep-isas)    8  4)
234(df  f-c5-16u16  "general 16-bit u-val"    (all-mep-isas) 16 16 UINT #f #f)
235
236(dnmf f-c5-rmuimm20 "20-bit immediate in Rm/Imm16" (all-mep-isas) UINT
237      (f-c5-rm f-c5-16u16)
238      (sequence () ; insert
239		(set (ifield f-c5-rm)    (srl (ifield f-c5-rmuimm20) 16))
240		(set (ifield f-c5-16u16) (and (ifield f-c5-rmuimm20) #xffff))
241		)
242      (sequence () ; extract
243		(set (ifield f-c5-rmuimm20) (or (ifield f-c5-16u16)
244						(sll (ifield f-c5-rm) 16)))
245		)
246      )
247(dnop c5rmuimm20 "20-bit immediate in rm and imm16" (all-mep-core-isas) h-uint f-c5-rmuimm20)
248
249(dnmf f-c5-rnmuimm24 "24-bit immediate in Rm/Imm16" (all-mep-isas) UINT
250      (f-c5-rnm f-c5-16u16)
251      (sequence () ; insert
252		(set (ifield f-c5-rnm)    (srl (ifield f-c5-rnmuimm24) 16))
253		(set (ifield f-c5-16u16) (and (ifield f-c5-rnmuimm24) #xffff))
254		)
255      (sequence () ; extract
256		(set (ifield f-c5-rnmuimm24) (or (ifield f-c5-16u16)
257						(sll (ifield f-c5-rnm) 16)))
258		)
259      )
260(dnop c5rnmuimm24 "24-bit immediate in rn, rm, and imm16" (all-mep-core-isas) h-uint f-c5-rnmuimm24)
261
262(dnci dsp "dsp" ((MACH c5) VOLATILE)
263     "dsp $rn,$rm,$uimm16"
264     (+ MAJ_15 rn rm (f-sub4 0) uimm16)
265     (set rn (c-call SI "do_DSP" rn rm (zext SI uimm16) pc))
266     ((mep (unit u-use-gpr (in usereg rm))
267	   (unit u-use-gpr (in usereg rn))
268	   (unit u-exec))))
269
270(dnci dsp0 "dsp0" ((MACH c5) VOLATILE NO-DIS ALIAS)
271     "dsp0 $c5rnmuimm24"
272     (+ MAJ_15 c5rnmuimm24 (f-sub4 0))
273     (c-call VOID "do_DSP" (zext SI c5rnmuimm24) pc)
274     ((mep (unit u-exec))))
275
276(dnci dsp1 "dsp1" ((MACH c5) VOLATILE NO-DIS ALIAS)
277     "dsp1 $rn,$c5rmuimm20"
278     (+ MAJ_15 rn (f-sub4 0) c5rmuimm20)
279     (set rn (c-call SI "do_DSP" rn (zext SI c5rmuimm20) pc))
280     ((mep (unit u-use-gpr (in usereg rn))
281	   (unit u-exec))))
282