xref: /netbsd-src/external/gpl3/binutils/dist/cpu/frv.cpu (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1; Fujitsu FRV opcode support, for GNU Binutils.  -*- Scheme -*-
2;
3; Copyright 2000, 2001, 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
4;
5; Contributed by Red Hat Inc; developed under contract from Fujitsu.
6;
7; This file is part of the GNU Binutils.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 3 of the License, or
12; (at your option) any later version.
13;
14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17; GNU General Public License for more details.
18;
19; You should have received a copy of the GNU General Public License
20; along with this program; if not, write to the Free Software
21; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22; MA 02110-1301, USA.
23
24(include "simplify.inc")
25
26; define-arch must appear first
27
28(define-arch
29  (name frv) ; name of cpu architecture
30  (comment "Fujitsu FRV")
31  (insn-lsb0? #t)
32  (machs frv fr550 fr500 fr450 fr400 tomcat simple)
33  (isas frv)
34)
35
36(define-isa
37  (name frv)
38  (base-insn-bitsize 32)
39  ; Initial bitnumbers to decode insns by.
40  (decode-assist (24 23 22 21 20 19 18))
41  (liw-insns 1)       ; The frv fetches  up to 1 insns at a time.
42  (parallel-insns 8)  ; The frv executes up to 8 insns at a time.
43)
44
45; Cpu family definitions.
46;
47(define-cpu
48  ; cpu names must be distinct from the architecture name and machine names.
49  ; The "b" suffix stands for "base" and is the convention.
50  ; The "f" suffix stands for "family" and is the convention.
51  (name frvbf)
52  (comment "Fujitsu FRV base family")
53  (endian big)
54  (word-bitsize 32)
55)
56
57; Generic FR-V machine. Supports the entire architecture
58(define-mach
59  (name frv)
60  (comment "Generic FRV cpu")
61  (cpu frvbf)
62)
63(define-model
64  (name frv) (comment "Generic FRV model") (attrs)
65  (mach frv)
66
67  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
68
69  ; `state' is a list of variables for recording model state
70  ; (state)
71
72  (unit u-exec "Execution Unit" ()
73	1 1 ; issue done
74	() ; state
75	() ; inputs
76	() ; outputs
77	() ; profile action (default)
78	)
79)
80
81; FR550 machine
82(define-mach
83  (name fr550)
84  (comment "FR550 cpu")
85  (cpu frvbf)
86)
87(define-model
88  (name fr550) (comment "FR550 model") (attrs)
89  (mach fr550)
90
91  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
92
93  ; `state' is a list of variables for recording model state
94  (state
95   ; State items
96   ; These are all masks with each bit representing one register.
97   (prev-fr-load      DI) ; Previous use of FR  register was target of a load
98   (prev-fr-complex-1 DI) ; Previous use of FR  register has variable latency
99   (prev-fr-complex-2 DI) ; Previous use of FR  register has variable latency
100   (prev-ccr-complex  DI) ; Previous use of CCR register has variable latency
101   (prev-acc-mmac     DI) ; Previous use of ACC register was a MMAC category
102   (cur-fr-load       DI) ; Current  use of FR  register was target of a load
103   (cur-fr-complex-1  DI) ; Current  use of FR  register has variable latency
104   (cur-fr-complex-2  DI) ; Current  use of FR  register has variable latency
105   (cur-ccr-complex   SI) ; Current  use of CCR register has variable latency
106   (cur-acc-mmac      DI) ; Current  use of ACC register was a MMAC category
107  )
108  ; Basic unit for instructions with no latency penalties
109  (unit u-exec "Execution Unit" ()
110	1 1 ; issue done
111	() ; state
112	() ; inputs
113	() ; outputs
114	() ; profile action (default)
115	)
116  ; Basic integer insn unit
117  (unit u-integer "Integer Unit" ()
118	1 1 ; issue done
119	() ; state
120	((GRi INT -1) (GRj INT -1)) ; inputs
121	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
122	() ; profile action (default)
123	)
124  ; Integer multiplication unit
125  (unit u-imul "Integer Multiplication Unit" ()
126	1 1 ; issue done
127	() ; state
128	((GRi INT -1) (GRj INT -1)) ; inputs
129	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
130	() ; profile action (default)
131	)
132  ; Integer division unit
133  (unit u-idiv "Integer Division Unit" ()
134	1 1 ; issue done
135	() ; state
136	((GRi INT -1) (GRj INT -1)) ; inputs
137	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
138	() ; profile action (default)
139	)
140  ; Branch unit
141  (unit u-branch "Branch Unit" ()
142	1 1 ; issue done
143	() ; state
144	((GRi INT -1) (GRj INT -1)
145	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
146	((pc)) ; outputs
147	() ; profile action (default)
148	)
149  ; Trap unit
150  (unit u-trap "Trap Unit" ()
151	1 1 ; issue done
152	() ; state
153	((GRi INT -1) (GRj INT -1)
154	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
155	() ; outputs
156	() ; profile action (default)
157	)
158  ; Condition code check unit
159  (unit u-check "Check Unit" ()
160	1 1 ; issue done
161	() ; state
162	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
163	() ; outputs
164	() ; profile action (default)
165	)
166  ; Float Arithmetic unit
167  (unit u-float-arith "Float Arithmetic unit" ()
168	1 1 ; issue done
169	() ; state
170	((FRi INT -1) (FRj INT -1) ; inputs
171	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
172	((FRk INT -1) (FRdoublek INT -1)) ; outputs
173	() ; profile action (default)
174	)
175  ; Float Dual Arithmetic unit
176  (unit u-float-dual-arith "Float Arithmetic unit" ()
177	; This unit has a 2 cycle penalty -- see table 14-14 in the fr550 LSI
178	1 3 ; issue done
179	() ; state
180	((FRi INT -1) (FRj INT -1) ; inputs
181	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
182	((FRk INT -1) (FRdoublek INT -1)) ; outputs
183	() ; profile action (default)
184	)
185  ; Float Div unit
186  (unit u-float-div "Float Div unit" ()
187	1 1 ; issue done
188	() ; state
189	((FRi INT -1) (FRj INT -1)) ; inputs
190	((FRk INT -1)) ; outputs
191	() ; profile action (default)
192	)
193  ; Float Square Root unit
194  (unit u-float-sqrt "Float Square Root unit" ()
195	1 1 ; issue done
196	() ; state
197	((FRj INT -1) (FRdoublej INT -1)) ; inputs
198	((FRk INT -1) (FRdoublek INT -1)) ; outputs
199	() ; profile action (default)
200	)
201  ; Float Compare unit
202  (unit u-float-compare "Float Compare unit" ()
203	1 1 ; issue done
204	() ; state
205	((FRi INT -1) (FRj INT -1)
206	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
207	((FCCi_2 INT -1)) ; outputs
208	() ; profile action (default)
209	)
210  ; Dual Float Compare unit
211  (unit u-float-dual-compare "Float Dual Compare unit" ()
212	; This unit has a 2 cycle penalty -- see table 14-14 in the fr550 LSI
213	1 3 ; issue done
214	() ; state
215	((FRi INT -1) (FRj INT -1)) ; inputs
216	((FCCi_2 INT -1)) ; outputs
217	() ; profile action (default)
218	)
219  ; FR Move to GR unit
220  (unit u-fr2gr "FR Move to GR Unit" ()
221	1 1 ; issue done
222	() ; state
223	((FRintk INT -1)) ; inputs
224	((GRj INT -1)) ; outputs
225	() ; profile action (default)
226	)
227  ; GR Move to FR unit
228  (unit u-gr2fr "GR Move to FR Unit" ()
229	1 1 ; issue done
230	() ; state
231	((GRj INT -1)) ; inputs
232	((FRintk INT -1)) ; outputs
233	() ; profile action (default)
234	)
235  ; SPR Move to GR unit
236  (unit u-spr2gr "SPR Move to GR Unit" ()
237	1 1 ; issue done
238	() ; state
239	((spr INT -1)) ; inputs
240	((GRj INT -1)) ; outputs
241	() ; profile action (default)
242	)
243  ; GR Move to SPR unit
244  (unit u-gr2spr "GR Move to SPR Unit" ()
245	1 1 ; issue done
246	() ; state
247	((GRj INT -1)) ; inputs
248	((spr INT -1)) ; outputs
249	() ; profile action (default)
250	)
251  ; GR set half unit
252  (unit u-set-hilo "GR Set Half" ()
253	1 1 ; issue done
254	() ; state
255	() ; inputs
256	((GRkhi INT -1) (GRklo INT -1)) ; outputs
257	() ; profile action (default)
258	)
259  ; GR load unit
260  (unit u-gr-load "GR Load Unit" ()
261	1 1 ; issue done
262	() ; state
263	((GRi INT -1) (GRj INT -1)) ; inputs
264	((GRk INT -1) (GRdoublek INT -1)) ; outputs
265	() ; profile action (default)
266	)
267  ; GR store unit
268  (unit u-gr-store "GR Store Unit" ()
269	1 1 ; issue done
270	() ; state
271	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
272	() ; outputs
273	() ; profile action (default)
274	)
275  ; FR load unit
276  (unit u-fr-load "FR Load Unit" ()
277	1 1 ; issue done
278	() ; state
279	((GRi INT -1) (GRj INT -1)) ; inputs
280	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
281	() ; profile action (default)
282	)
283  ; FR store unit
284  (unit u-fr-store "FR Store Unit" ()
285	1 1 ; issue done
286	() ; state
287	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
288	() ; outputs
289	() ; profile action (default)
290	)
291  ; Swap unit
292  (unit u-swap "Swap Unit" ()
293	1 1 ; issue done
294	() ; state
295	((GRi INT -1) (GRj INT -1)) ; inputs
296	((GRk INT -1)) ; outputs
297	() ; profile action (default)
298	)
299  ; FR Move to FR unit
300  (unit u-fr2fr "FR Move to FR Unit" ()
301	1 1 ; issue done
302	() ; state
303	((FRi INT -1)) ; inputs
304	((FRk INT -1)) ; outputs
305	() ; profile action (default)
306	)
307  ; Clrgr unit
308  (unit u-clrgr "Clrgr Unit" ()
309	1 1 ; issue done
310	() ; state
311	((GRk INT -1)) ; inputs
312	() ; outputs
313	() ; profile action (default)
314	)
315  ; Clrfr unit
316  (unit u-clrfr "Clrfr Unit" ()
317	1 1 ; issue done
318	() ; state
319	((FRk INT -1)) ; inputs
320	() ; outputs
321	() ; profile action (default)
322	)
323  ; Insn cache invalidate unit
324  (unit u-ici "Insn cache invalidate unit" ()
325	1 1 ; issue done
326	() ; state
327	((GRi INT -1) (GRj INT -1)) ; inputs
328	() ; outputs
329	() ; profile action (default)
330	)
331  ; Data cache invalidate unit
332  (unit u-dci "Data cache invalidate unit" ()
333	1 1 ; issue done
334	() ; state
335	((GRi INT -1) (GRj INT -1)) ; inputs
336	() ; outputs
337	() ; profile action (default)
338	)
339  ; Data cache flush unit
340  (unit u-dcf "Data cache flush unit" ()
341	1 1 ; issue done
342	() ; state
343	((GRi INT -1) (GRj INT -1)) ; inputs
344	() ; outputs
345	() ; profile action (default)
346	)
347  ; Insn cache preload unit
348  (unit u-icpl "Insn cache preload unit" ()
349	1 1 ; issue done
350	() ; state
351	((GRi INT -1) (GRj INT -1)) ; inputs
352	() ; outputs
353	() ; profile action (default)
354	)
355  ; Data cache preload unit
356  (unit u-dcpl "Data cache preload unit" ()
357	1 1 ; issue done
358	() ; state
359	((GRi INT -1) (GRj INT -1)) ; inputs
360	() ; outputs
361	() ; profile action (default)
362	)
363  ; Insn cache unlock unit
364  (unit u-icul "Insn cache unlock unit" ()
365	1 1 ; issue done
366	() ; state
367	((GRi INT -1) (GRj INT -1)) ; inputs
368	() ; outputs
369	() ; profile action (default)
370	)
371  ; Data cache unlock unit
372  (unit u-dcul "Data cache unlock unit" ()
373	1 1 ; issue done
374	() ; state
375	((GRi INT -1) (GRj INT -1)) ; inputs
376	() ; outputs
377	() ; profile action (default)
378	)
379  ; commit unit
380  (unit u-commit "Commit Unit" ()
381	1 1 ; issue done
382	() ; state
383	((GRk INT -1) (FRk INT -1)) ; inputs
384	() ; outputs
385	() ; profile action (default)
386	)
387  ; Float Conversion unit
388  (unit u-float-convert "Float Conversion unit" ()
389	1 1 ; issue done
390	() ; state
391	((FRj INT -1) (FRintj INT -1) (FRdoublej INT -1)) ; inputs
392	((FRk INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; outputs
393	() ; profile action (default)
394	)
395  ; Media units
396  (unit u-media "Media unit" ()
397	1 1 ; issue done
398	() ; state
399	((FRinti INT -1) (FRintj INT -1)) ; inputs
400	((FRintk INT -1)) ; outputs
401	() ; profile action (default)
402	)
403  (unit u-media-quad "Media-quad unit" ()
404	1 1 ; issue done
405	() ; state
406	((FRintieven INT -1) (FRintjeven INT -1)) ; inputs
407	((FRintkeven INT -1)) ; outputs
408	() ; profile action (default)
409	)
410  (unit u-media-dual-expand "Media Dual Expand unit" ()
411	1 1 ; issue done
412	() ; state
413	((FRinti INT -1)) ; inputs
414	((FRintkeven INT -1)) ; outputs
415	() ; profile action (default)
416	)
417  (unit u-media-3-dual "Media-3-dual unit" ()
418	1 1 ; issue done
419	() ; state
420	((FRinti INT -1)) ; inputs
421	((FRintk INT -1)) ; outputs
422	() ; profile action (default)
423	)
424  (unit u-media-3-acc "Media unit for M-3 using ACC" ()
425	1 1 ; issue done
426	() ; state
427	((FRintj INT -1) (ACC40Si INT -1)) ; inputs
428	((FRintk INT -1)) ; outputs
429	() ; profile action (default)
430	)
431  (unit u-media-3-acc-dual "Media-3-acc-dual unit" ()
432	1 1 ; issue done
433	() ; state
434	((ACC40Si INT -1)) ; inputs
435	((FRintkeven INT -1)) ; outputs
436	() ; profile action (default)
437	)
438  (unit u-media-3-wtacc "Media-3-wtacc unit" ()
439	1 1 ; issue done
440	() ; state
441	((FRinti INT -1) (ACC40Sk INT -1)) ; inputs
442	() ; outputs
443	() ; profile action (default)
444	)
445  (unit u-media-3-mclracc "Media-3-mclracc unit" ()
446	1 1 ; issue done
447	() ; state
448	() ; inputs
449	() ; outputs
450	() ; profile action (default)
451	)
452  (unit u-media-set "Media set" ()
453	1 1 ; issue done
454	() ; state
455	() ; inputs
456	((FRintk INT -1)) ; outputs
457	() ; profile action (default)
458	)
459  (unit u-media-4 "Media-4 unit" ()
460	1 1 ; issue done
461	() ; state
462	((FRinti INT -1) (FRintj INT -1)) ; inputs
463	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
464	() ; profile action (default)
465	)
466  (unit u-media-4-acc "Media-4-acc unit" ()
467	1 1 ; issue done
468	() ; state
469	((ACC40Si INT -1)) ; inputs
470	((ACC40Sk INT -1)) ; outputs
471	() ; profile action (default)
472	)
473  (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
474	1 1 ; issue done
475	() ; state
476	((ACC40Si INT -1)) ; inputs
477	((ACC40Sk INT -1)) ; outputs
478	() ; profile action (default)
479	)
480  (unit u-media-4-add-sub "Media-4-add-sub unit" ()
481	1 1 ; issue done
482	() ; state
483	((ACC40Si INT -1)) ; inputs
484	((ACC40Sk INT -1)) ; outputs
485	() ; profile action (default)
486	)
487  (unit u-media-4-add-sub-dual "Media-4-add-sub-dual unit" ()
488	1 1 ; issue done
489	() ; state
490	((ACC40Si INT -1)) ; inputs
491	((ACC40Sk INT -1)) ; outputs
492	() ; profile action (default)
493	)
494  (unit u-media-4-quad "Media-4-quad unit" ()
495	1 1 ; issue done
496	() ; state
497	((FRintieven INT -1) (FRintjeven INT -1)) ; inputs
498	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
499	() ; profile action (default)
500	)
501)
502
503; FR500 machine.
504(define-mach
505  (name fr500)
506  (comment "FR500 cpu")
507  (cpu frvbf)
508)
509(define-model
510  (name fr500) (comment "FR500 model") (attrs)
511  (mach fr500)
512
513  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
514
515  ; `state' is a list of variables for recording model state
516  (state
517   ; State items
518   ; These are all masks with each bit representing one register.
519   (prev-fpop       DI) ; Previous use of FR register was floating point insn
520   (prev-media      DI) ; Previous use of FR register was a media insn
521   (prev-cc-complex DI) ; Previous use of ICC register was not simple
522   (cur-fpop        DI) ; Current use of FR register was floating point insn
523   (cur-media       DI) ; Current use of FR register was a media insn
524   (cur-cc-complex  DI) ; Current use of ICC register was not simple
525  )
526  ; Basic unit for instructions with no latency penalties
527  (unit u-exec "Execution Unit" ()
528	1 1 ; issue done
529	() ; state
530	() ; inputs
531	() ; outputs
532	() ; profile action (default)
533	)
534  ; Basic integer insn unit
535  (unit u-integer "Integer Unit" ()
536	1 1 ; issue done
537	() ; state
538	((GRi INT -1) (GRj INT -1)) ; inputs
539	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
540	() ; profile action (default)
541	)
542  ; Integer multiplication unit
543  (unit u-imul "Integer Multiplication Unit" ()
544	1 1 ; issue done
545	() ; state
546	((GRi INT -1) (GRj INT -1)) ; inputs
547	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
548	() ; profile action (default)
549	)
550  ; Integer division unit
551  (unit u-idiv "Integer Division Unit" ()
552	1 1 ; issue done
553	() ; state
554	((GRi INT -1) (GRj INT -1)) ; inputs
555	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
556	() ; profile action (default)
557	)
558  ; Branch unit
559  (unit u-branch "Branch Unit" ()
560	1 1 ; issue done
561	() ; state
562	((GRi INT -1) (GRj INT -1)
563	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
564	((pc)) ; outputs
565	() ; profile action (default)
566	)
567  ; Trap unit
568  (unit u-trap "Trap Unit" ()
569	1 1 ; issue done
570	() ; state
571	((GRi INT -1) (GRj INT -1)
572	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
573	() ; outputs
574	() ; profile action (default)
575	)
576  ; Condition code check unit
577  (unit u-check "Check Unit" ()
578	1 1 ; issue done
579	() ; state
580	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
581	() ; outputs
582	() ; profile action (default)
583	)
584  ; Clrgr unit
585  (unit u-clrgr "Clrgr Unit" ()
586	1 1 ; issue done
587	() ; state
588	((GRk INT -1)) ; inputs
589	() ; outputs
590	() ; profile action (default)
591	)
592  ; Clrfr unit
593  (unit u-clrfr "Clrfr Unit" ()
594	1 1 ; issue done
595	() ; state
596	((FRk INT -1)) ; inputs
597	() ; outputs
598	() ; profile action (default)
599	)
600  ; GR set half unit
601  (unit u-set-hilo "GR Set Half" ()
602	1 1 ; issue done
603	() ; state
604	() ; inputs
605	((GRkhi INT -1) (GRklo INT -1)) ; outputs
606	() ; profile action (default)
607	)
608  ; GR load unit -- TODO doesn't handle quad
609  (unit u-gr-load "GR Load Unit" ()
610	1 1 ; issue done
611	() ; state
612	((GRi INT -1) (GRj INT -1)) ; inputs
613	((GRk INT -1) (GRdoublek INT -1)) ; outputs
614	() ; profile action (default)
615	)
616  ; GR store unit -- TODO doesn't handle quad
617  (unit u-gr-store "GR Store Unit" ()
618	1 1 ; issue done
619	() ; state
620	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
621	() ; outputs
622	() ; profile action (default)
623	)
624  ; GR recovering store unit -- TODO doesn't handle quad
625  (unit u-gr-r-store "GR Recovering Store Unit" ()
626	1 1 ; issue done
627	() ; state
628	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
629	() ; outputs
630	() ; profile action (default)
631	)
632  ; FR load unit -- TODO doesn't handle quad
633  (unit u-fr-load "FR Load Unit" ()
634	1 1 ; issue done
635	() ; state
636	((GRi INT -1) (GRj INT -1)) ; inputs
637	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
638	() ; profile action (default)
639	)
640  ; FR store unit -- TODO doesn't handle quad
641  (unit u-fr-store "FR Store Unit" ()
642	1 1 ; issue done
643	() ; state
644	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
645	() ; outputs
646	() ; profile action (default)
647	)
648  ; FR recovering store unit -- TODO doesn't handle quad
649  (unit u-fr-r-store "FR Recovering Store Unit" ()
650	1 1 ; issue done
651	() ; state
652	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
653	() ; outputs
654	() ; profile action (default)
655	)
656  ; Swap unit
657  (unit u-swap "Swap Unit" ()
658	1 1 ; issue done
659	() ; state
660	((GRi INT -1) (GRj INT -1)) ; inputs
661	((GRk INT -1)) ; outputs
662	() ; profile action (default)
663	)
664  ; FR Move to FR unit
665  (unit u-fr2fr "FR Move to FR Unit" ()
666	1 1 ; issue done
667	() ; state
668	((FRi INT -1)) ; inputs
669	((FRk INT -1)) ; outputs
670	() ; profile action (default)
671	)
672  ; FR Move to GR unit
673  (unit u-fr2gr "FR Move to GR Unit" ()
674	1 1 ; issue done
675	() ; state
676	((FRintk INT -1)) ; inputs
677	((GRj INT -1)) ; outputs
678	() ; profile action (default)
679	)
680  ; SPR Move to GR unit
681  (unit u-spr2gr "SPR Move to GR Unit" ()
682	1 1 ; issue done
683	() ; state
684	((spr INT -1)) ; inputs
685	((GRj INT -1)) ; outputs
686	() ; profile action (default)
687	)
688  ; GR Move to FR unit
689  (unit u-gr2fr "GR Move to FR Unit" ()
690	1 1 ; issue done
691	() ; state
692	((GRj INT -1)) ; inputs
693	((FRintk INT -1)) ; outputs
694	() ; profile action (default)
695	)
696  ; GR Move to SPR unit
697  (unit u-gr2spr "GR Move to SPR Unit" ()
698	1 1 ; issue done
699	() ; state
700	((GRj INT -1)) ; inputs
701	((spr INT -1)) ; outputs
702	() ; profile action (default)
703	)
704  ; Float Arithmetic unit
705  (unit u-float-arith "Float Arithmetic unit" ()
706	1 1 ; issue done
707	() ; state
708	((FRi INT -1) (FRj INT -1) ; inputs
709	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
710	((FRk INT -1) (FRdoublek INT -1)) ; outputs
711	() ; profile action (default)
712	)
713  ; Float Dual Arithmetic unit
714  (unit u-float-dual-arith "Float Arithmetic unit" ()
715	1 1 ; issue done
716	() ; state
717	((FRi INT -1) (FRj INT -1) ; inputs
718	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
719	((FRk INT -1) (FRdoublek INT -1)) ; outputs
720	() ; profile action (default)
721	)
722  ; Float Div unit
723  (unit u-float-div "Float Div unit" ()
724	1 1 ; issue done
725	() ; state
726	((FRi INT -1) (FRj INT -1)) ; inputs
727	((FRk INT -1)) ; outputs
728	() ; profile action (default)
729	)
730  ; Float Square Root unit
731  (unit u-float-sqrt "Float Square Root unit" ()
732	1 1 ; issue done
733	() ; state
734	((FRj INT -1) (FRdoublej INT -1)) ; inputs
735	((FRk INT -1) (FRdoublek INT -1)) ; outputs
736	() ; profile action (default)
737	)
738  ; Float Dual Square Root unit
739  (unit u-float-dual-sqrt "Float Dual Square Root unit" ()
740	1 1 ; issue done
741	() ; state
742	((FRj INT -1)) ; inputs
743	((FRk INT -1)) ; outputs
744	() ; profile action (default)
745	)
746  ; Float Compare unit
747  (unit u-float-compare "Float Compare unit" ()
748	1 1 ; issue done
749	() ; state
750	((FRi INT -1) (FRj INT -1)
751	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
752	((FCCi_2 INT -1)) ; outputs
753	() ; profile action (default)
754	)
755  ; Dual Float Compare unit
756  (unit u-float-dual-compare "Float Dual Compare unit" ()
757	1 1 ; issue done
758	() ; state
759	((FRi INT -1) (FRj INT -1)) ; inputs
760	((FCCi_2 INT -1)) ; outputs
761	() ; profile action (default)
762	)
763  ; Float Conversion unit
764  (unit u-float-convert "Float Conversion unit" ()
765	1 1 ; issue done
766	() ; state
767	((FRj INT -1) (FRintj INT -1) (FRdoublej INT -1)) ; inputs
768	((FRk INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; outputs
769	() ; profile action (default)
770	)
771  ; Dual Float Conversion unit
772  (unit u-float-dual-convert "Float Dual Conversion unit" ()
773	1 1 ; issue done
774	() ; state
775	((FRj INT -1) (FRintj INT -1)) ; inputs
776	((FRk INT -1) (FRintk INT -1)) ; outputs
777	() ; profile action (default)
778	)
779  ; Media unit
780  (unit u-media "Media unit" ()
781	1 1 ; issue done
782	() ; state
783	((FRinti INT -1) (FRintj INT -1) (ACC40Si INT -1) (ACCGi INT -1)) ; inputs
784	((FRintk INT -1) (ACC40Sk INT -1) (ACC40Uk INT -1) (ACCGk INT -1)) ; outputs
785	() ; profile action (default)
786	)
787  ; Media Quad Arithmetic unit
788  (unit u-media-quad-arith "Media Quad Arithmetic unit" ()
789	1 1 ; issue done
790	() ; state
791	((FRinti INT -1) (FRintj INT -1)) ; inputs
792	((FRintk INT -1)) ; outputs
793	() ; profile action (default)
794	)
795  ; Media Dual Multiplication unit
796  (unit u-media-dual-mul "Media Dual Multiplication unit" ()
797	1 1 ; issue done
798	() ; state
799	((FRinti INT -1) (FRintj INT -1)) ; inputs
800	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
801	() ; profile action (default)
802	)
803  ; Media Quad Multiplication unit
804  (unit u-media-quad-mul "Media Quad Multiplication unit" ()
805	1 1 ; issue done
806	() ; state
807	((FRinti INT -1) (FRintj INT -1)) ; inputs
808	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
809	() ; profile action (default)
810	)
811  ; Media Quad Complex unit
812  (unit u-media-quad-complex "Media Quad Complex unit" ()
813	1 1 ; issue done
814	() ; state
815	((FRinti INT -1) (FRintj INT -1)) ; inputs
816	((ACC40Sk INT -1)) ; outputs
817	() ; profile action (default)
818	)
819  ; Media Dual Expand unit
820  (unit u-media-dual-expand "Media Dual Expand unit" ()
821	1 1 ; issue done
822	() ; state
823	((FRinti INT -1)) ; inputs
824	((FRintk INT -1)) ; outputs
825	() ; profile action (default)
826	)
827  ; Media Dual Unpack unit
828  (unit u-media-dual-unpack "Media Dual Unpack unit" ()
829	1 1 ; issue done
830	() ; state
831	((FRinti INT -1)) ; inputs
832	((FRintk INT -1)) ; outputs
833	() ; profile action (default)
834	)
835  ; Media Dual byte to half unit
836  (unit u-media-dual-btoh "Media Byte to byte" ()
837	1 1 ; issue done
838	() ; state
839	((FRintj INT -1)) ; inputs
840	((FRintk INT -1)) ; outputs
841	() ; profile action (default)
842	)
843  ; Media Dual half to byte unit
844  (unit u-media-dual-htob "Media Half to byte" ()
845	1 1 ; issue done
846	() ; state
847	((FRintj INT -1)) ; inputs
848	((FRintk INT -1)) ; outputs
849	() ; profile action (default)
850	)
851  ; Media Dual byte to half unit extended
852  (unit u-media-dual-btohe "Media Byte to byte extended" ()
853	1 1 ; issue done
854	() ; state
855	((FRintj INT -1)) ; inputs
856	((FRintk INT -1)) ; outputs
857	() ; profile action (default)
858	)
859  ; Barrier unit
860  (unit u-barrier "Barrier unit" ()
861	1 1 ; issue done
862	() ; state
863	() ; inputs
864	() ; outputs
865	() ; profile action (default)
866	)
867  ; Memory Barrier unit
868  (unit u-membar "Memory Barrier unit" ()
869	1 1 ; issue done
870	() ; state
871	() ; inputs
872	() ; outputs
873	() ; profile action (default)
874	)
875  ; Insn cache invalidate unit
876  (unit u-ici "Insn cache invalidate unit" ()
877	1 1 ; issue done
878	() ; state
879	((GRi INT -1) (GRj INT -1)) ; inputs
880	() ; outputs
881	() ; profile action (default)
882	)
883  ; Data cache invalidate unit
884  (unit u-dci "Data cache invalidate unit" ()
885	1 1 ; issue done
886	() ; state
887	((GRi INT -1) (GRj INT -1)) ; inputs
888	() ; outputs
889	() ; profile action (default)
890	)
891  ; Data cache flush unit
892  (unit u-dcf "Data cache flush unit" ()
893	1 1 ; issue done
894	() ; state
895	((GRi INT -1) (GRj INT -1)) ; inputs
896	() ; outputs
897	() ; profile action (default)
898	)
899  ; Insn cache preload unit
900  (unit u-icpl "Insn cache preload unit" ()
901	1 1 ; issue done
902	() ; state
903	((GRi INT -1) (GRj INT -1)) ; inputs
904	() ; outputs
905	() ; profile action (default)
906	)
907  ; Data cache preload unit
908  (unit u-dcpl "Data cache preload unit" ()
909	1 1 ; issue done
910	() ; state
911	((GRi INT -1) (GRj INT -1)) ; inputs
912	() ; outputs
913	() ; profile action (default)
914	)
915  ; Insn cache unlock unit
916  (unit u-icul "Insn cache unlock unit" ()
917	1 1 ; issue done
918	() ; state
919	((GRi INT -1) (GRj INT -1)) ; inputs
920	() ; outputs
921	() ; profile action (default)
922	)
923  ; Data cache unlock unit
924  (unit u-dcul "Data cache unlock unit" ()
925	1 1 ; issue done
926	() ; state
927	((GRi INT -1) (GRj INT -1)) ; inputs
928	() ; outputs
929	() ; profile action (default)
930	)
931  ; commit unit
932  (unit u-commit "Commit Unit" ()
933	1 1 ; issue done
934	() ; state
935	((GRk INT -1) (FRk INT -1)) ; inputs
936	() ; outputs
937	() ; profile action (default)
938	)
939)
940
941; Tomcat machine. Early version of fr500 machine
942(define-mach
943  (name tomcat)
944  (comment "Tomcat -- early version of fr500")
945  (cpu frvbf)
946)
947(define-model
948  (name tomcat) (comment "Tomcat model") (attrs)
949  (mach tomcat)
950
951  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
952
953  ; `state' is a list of variables for recording model state
954  ; (state)
955
956  (unit u-exec "Execution Unit" ()
957	1 1 ; issue done
958	() ; state
959	() ; inputs
960	() ; outputs
961	() ; profile action (default)
962	)
963)
964
965; FR400 machine
966(define-mach
967  (name fr400)
968  (comment "FR400 cpu")
969  (cpu frvbf)
970)
971(define-model
972  (name fr400) (comment "FR400 model") (attrs)
973  (mach fr400)
974  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
975  ; `state' is a list of variables for recording model state
976  (state
977   ; State items
978   ; These are all masks with each bit representing one register.
979   (prev-fp-load    DI) ; Previous use of FR  register was floating point load
980   (prev-fr-p4      DI) ; Previous use of FR  register was media unit 4
981   (prev-fr-p6      DI) ; Previous use of FR  register was media unit 6
982   (prev-acc-p2     DI) ; Previous use of ACC register was media unit 2
983   (prev-acc-p4     DI) ; Previous use of ACC register was media unit 4
984   (cur-fp-load     DI) ; Current  use of FR  register is  floating point load
985   (cur-fr-p4       DI) ; Current  use of FR  register is  media unit 4
986   (cur-fr-p6       DI) ; Current  use of FR  register is  media unit 6
987   (cur-acc-p2      DI) ; Current  use of ACC register is  media unit 2
988   (cur-acc-p4      DI) ; Current  use of ACC register is  media unit 4
989  )
990  (unit u-exec "Execution Unit" ()
991	1 1 ; issue done
992	() ; state
993	() ; inputs
994	() ; outputs
995	() ; profile action (default)
996	)
997  ; Basic integer insn unit
998  (unit u-integer "Integer Unit" ()
999	1 1 ; issue done
1000	() ; state
1001	((GRi INT -1) (GRj INT -1)) ; inputs
1002	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
1003	() ; profile action (default)
1004	)
1005  ; Integer multiplication unit
1006  (unit u-imul "Integer Multiplication Unit" ()
1007	1 1 ; issue done
1008	() ; state
1009	((GRi INT -1) (GRj INT -1)) ; inputs
1010	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
1011	() ; profile action (default)
1012	)
1013  ; Integer division unit
1014  (unit u-idiv "Integer Division Unit" ()
1015	1 1 ; issue done
1016	() ; state
1017	((GRi INT -1) (GRj INT -1)) ; inputs
1018	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
1019	() ; profile action (default)
1020	)
1021  ; Branch unit
1022  (unit u-branch "Branch Unit" ()
1023	1 1 ; issue done
1024	() ; state
1025	((GRi INT -1) (GRj INT -1)
1026	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
1027	((pc)) ; outputs
1028	() ; profile action (default)
1029	)
1030  ; Trap unit
1031  (unit u-trap "Trap Unit" ()
1032	1 1 ; issue done
1033	() ; state
1034	((GRi INT -1) (GRj INT -1)
1035	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
1036	() ; outputs
1037	() ; profile action (default)
1038	)
1039  ; Condition code check unit
1040  (unit u-check "Check Unit" ()
1041	1 1 ; issue done
1042	() ; state
1043	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
1044	() ; outputs
1045	() ; profile action (default)
1046	)
1047  ; GR set half unit
1048  (unit u-set-hilo "GR Set Half" ()
1049	1 1 ; issue done
1050	() ; state
1051	() ; inputs
1052	((GRkhi INT -1) (GRklo INT -1)) ; outputs
1053	() ; profile action (default)
1054	)
1055  ; GR load unit -- TODO doesn't handle quad
1056  (unit u-gr-load "GR Load Unit" ()
1057	1 1 ; issue done
1058	() ; state
1059	((GRi INT -1) (GRj INT -1)) ; inputs
1060	((GRk INT -1) (GRdoublek INT -1)) ; outputs
1061	() ; profile action (default)
1062	)
1063  ; GR store unit -- TODO doesn't handle quad
1064  (unit u-gr-store "GR Store Unit" ()
1065	1 1 ; issue done
1066	() ; state
1067	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
1068	() ; outputs
1069	() ; profile action (default)
1070	)
1071  ; FR load unit -- TODO doesn't handle quad
1072  (unit u-fr-load "FR Load Unit" ()
1073	1 1 ; issue done
1074	() ; state
1075	((GRi INT -1) (GRj INT -1)) ; inputs
1076	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
1077	() ; profile action (default)
1078	)
1079  ; FR store unit -- TODO doesn't handle quad
1080  (unit u-fr-store "FR Store Unit" ()
1081	1 1 ; issue done
1082	() ; state
1083	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
1084	() ; outputs
1085	() ; profile action (default)
1086	)
1087  ; Swap unit
1088  (unit u-swap "Swap Unit" ()
1089	1 1 ; issue done
1090	() ; state
1091	((GRi INT -1) (GRj INT -1)) ; inputs
1092	((GRk INT -1)) ; outputs
1093	() ; profile action (default)
1094	)
1095  ; FR Move to GR unit
1096  (unit u-fr2gr "FR Move to GR Unit" ()
1097	1 1 ; issue done
1098	() ; state
1099	((FRintk INT -1)) ; inputs
1100	((GRj INT -1)) ; outputs
1101	() ; profile action (default)
1102	)
1103  ; SPR Move to GR unit
1104  (unit u-spr2gr "SPR Move to GR Unit" ()
1105	1 1 ; issue done
1106	() ; state
1107	((spr INT -1)) ; inputs
1108	((GRj INT -1)) ; outputs
1109	() ; profile action (default)
1110	)
1111  ; GR Move to FR unit
1112  (unit u-gr2fr "GR Move to FR Unit" ()
1113	1 1 ; issue done
1114	() ; state
1115	((GRj INT -1)) ; inputs
1116	((FRintk INT -1)) ; outputs
1117	() ; profile action (default)
1118	)
1119  ; GR Move to SPR unit
1120  (unit u-gr2spr "GR Move to SPR Unit" ()
1121	1 1 ; issue done
1122	() ; state
1123	((GRj INT -1)) ; inputs
1124	((spr INT -1)) ; outputs
1125	() ; profile action (default)
1126	)
1127  ; Media unit M1 -- see table 13-8 in the fr400 LSI
1128  (unit u-media-1 "Media-1 unit" ()
1129	1 1 ; issue done
1130	() ; state
1131	((FRinti INT -1) (FRintj INT -1)) ; inputs
1132	((FRintk INT -1)) ; outputs
1133	() ; profile action (default)
1134	)
1135  (unit u-media-1-quad "Media-1-quad unit" ()
1136	1 1 ; issue done
1137	() ; state
1138	((FRinti INT -1) (FRintj INT -1)) ; inputs
1139	((FRintk INT -1)) ; outputs
1140	() ; profile action (default)
1141	)
1142  (unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
1143	1 1 ; issue done
1144	() ; state
1145	() ; inputs
1146	((FRkhi INT -1) (FRklo INT -1)) ; outputs
1147	() ; profile action (default)
1148	)
1149  ; Media unit M2 -- see table 13-8 in the fr400 LSI
1150  (unit u-media-2 "Media-2 unit" ()
1151	1 1 ; issue done
1152	() ; state
1153	((FRinti INT -1) (FRintj INT -1)) ; inputs
1154	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
1155	() ; profile action (default)
1156	)
1157  (unit u-media-2-quad "Media-2-quad unit" ()
1158	1 1 ; issue done
1159	() ; state
1160	((FRinti INT -1) (FRintj INT -1)) ; inputs
1161	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
1162	() ; profile action (default)
1163	)
1164  (unit u-media-2-acc "Media-2-acc unit" ()
1165	1 1 ; issue done
1166	() ; state
1167	((ACC40Si INT -1)) ; inputs
1168	((ACC40Sk INT -1)) ; outputs
1169	() ; profile action (default)
1170	)
1171  (unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
1172	1 1 ; issue done
1173	() ; state
1174	((ACC40Si INT -1)) ; inputs
1175	((ACC40Sk INT -1)) ; outputs
1176	() ; profile action (default)
1177	)
1178  (unit u-media-2-add-sub "Media-2-add-sub unit" ()
1179	1 1 ; issue done
1180	() ; state
1181	((ACC40Si INT -1)) ; inputs
1182	((ACC40Sk INT -1)) ; outputs
1183	() ; profile action (default)
1184	)
1185  (unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
1186	1 1 ; issue done
1187	() ; state
1188	((ACC40Si INT -1)) ; inputs
1189	((ACC40Sk INT -1)) ; outputs
1190	() ; profile action (default)
1191	)
1192  ; Media unit M3 -- see table 13-8 in the fr400 LSI
1193  (unit u-media-3 "Media-3 unit" ()
1194	1 1 ; issue done
1195	() ; state
1196	((FRinti INT -1) (FRintj INT -1)) ; inputs
1197	((FRintk INT -1)) ; outputs
1198	() ; profile action (default)
1199	)
1200  (unit u-media-3-dual "Media-3-dual unit" ()
1201	1 1 ; issue done
1202	() ; state
1203	((FRinti INT -1)) ; inputs
1204	((FRintk INT -1)) ; outputs
1205	() ; profile action (default)
1206	)
1207  (unit u-media-3-quad "Media-3-quad unit" ()
1208	1 1 ; issue done
1209	() ; state
1210	((FRinti INT -1) (FRintj INT -1)) ; inputs
1211	((FRintk INT -1)) ; outputs
1212	() ; profile action (default)
1213	)
1214  ; Media unit M4 -- see table 13-8 in the fr400 LSI
1215  (unit u-media-4 "Media-4 unit" ()
1216	1 1 ; issue done
1217	() ; state
1218	((ACC40Si INT -1) (FRintj INT -1)) ; inputs
1219	((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
1220	() ; profile action (default)
1221	)
1222  (unit u-media-4-accg "Media-4-accg unit" ()
1223	1 1 ; issue done
1224	() ; state
1225	((ACCGi INT -1) (FRinti INT -1)) ; inputs
1226	((ACCGk INT -1) (FRintk INT -1)) ; outputs
1227	() ; profile action (default)
1228	)
1229  (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
1230	1 1 ; issue done
1231	() ; state
1232	((ACC40Si INT -1)) ; inputs
1233	((FRintk INT -1)) ; outputs
1234	() ; profile action (default)
1235	)
1236  ; Media unit M6 -- see table 13-8 in the fr400 LSI
1237  (unit u-media-6 "Media-6 unit" ()
1238	1 1 ; issue done
1239	() ; state
1240	((FRinti INT -1)) ; inputs
1241	((FRintk INT -1)) ; outputs
1242	() ; profile action (default)
1243	)
1244  ; Media unit M7 -- see table 13-8 in the fr400 LSI
1245  (unit u-media-7 "Media-1 unit" ()
1246	1 1 ; issue done
1247	() ; state
1248	((FRinti INT -1) (FRintj INT -1)) ; inputs
1249	((FCCk INT -1)) ; outputs
1250	() ; profile action (default)
1251	)
1252  ; Media Dual Expand unit
1253  (unit u-media-dual-expand "Media Dual Expand unit" ()
1254	1 1 ; issue done
1255	() ; state
1256	((FRinti INT -1)) ; inputs
1257	((FRintk INT -1)) ; outputs
1258	() ; profile action (default)
1259	)
1260  ; Media Dual half to byte unit
1261  (unit u-media-dual-htob "Media Half to byte" ()
1262	1 1 ; issue done
1263	() ; state
1264	((FRintj INT -1)) ; inputs
1265	((FRintk INT -1)) ; outputs
1266	() ; profile action (default)
1267	)
1268  ; Barrier unit
1269  (unit u-barrier "Barrier unit" ()
1270	1 1 ; issue done
1271	() ; state
1272	() ; inputs
1273	() ; outputs
1274	() ; profile action (default)
1275	)
1276  ; Memory Barrier unit
1277  (unit u-membar "Memory Barrier unit" ()
1278	1 1 ; issue done
1279	() ; state
1280	() ; inputs
1281	() ; outputs
1282	() ; profile action (default)
1283	)
1284  ; Insn cache invalidate unit
1285  (unit u-ici "Insn cache invalidate unit" ()
1286	1 1 ; issue done
1287	() ; state
1288	((GRi INT -1) (GRj INT -1)) ; inputs
1289	() ; outputs
1290	() ; profile action (default)
1291	)
1292  ; Data cache invalidate unit
1293  (unit u-dci "Data cache invalidate unit" ()
1294	1 1 ; issue done
1295	() ; state
1296	((GRi INT -1) (GRj INT -1)) ; inputs
1297	() ; outputs
1298	() ; profile action (default)
1299	)
1300  ; Data cache flush unit
1301  (unit u-dcf "Data cache flush unit" ()
1302	1 1 ; issue done
1303	() ; state
1304	((GRi INT -1) (GRj INT -1)) ; inputs
1305	() ; outputs
1306	() ; profile action (default)
1307	)
1308  ; Insn cache preload unit
1309  (unit u-icpl "Insn cache preload unit" ()
1310	1 1 ; issue done
1311	() ; state
1312	((GRi INT -1) (GRj INT -1)) ; inputs
1313	() ; outputs
1314	() ; profile action (default)
1315	)
1316  ; Data cache preload unit
1317  (unit u-dcpl "Data cache preload unit" ()
1318	1 1 ; issue done
1319	() ; state
1320	((GRi INT -1) (GRj INT -1)) ; inputs
1321	() ; outputs
1322	() ; profile action (default)
1323	)
1324  ; Insn cache unlock unit
1325  (unit u-icul "Insn cache unlock unit" ()
1326	1 1 ; issue done
1327	() ; state
1328	((GRi INT -1) (GRj INT -1)) ; inputs
1329	() ; outputs
1330	() ; profile action (default)
1331	)
1332  ; Data cache unlock unit
1333  (unit u-dcul "Data cache unlock unit" ()
1334	1 1 ; issue done
1335	() ; state
1336	((GRi INT -1) (GRj INT -1)) ; inputs
1337	() ; outputs
1338	() ; profile action (default)
1339	)
1340)
1341
1342; FR450 machine
1343(define-mach
1344  (name fr450)
1345  (comment "FR450 cpu")
1346  (cpu frvbf)
1347)
1348(define-model
1349  (name fr450) (comment "FR450 model") (attrs)
1350  (mach fr450)
1351  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
1352  ; `state' is a list of variables for recording model state
1353  (state
1354   ; State items
1355   ; These are all masks with each bit representing one register.
1356   (prev-fp-load    DI) ; Previous use of FR  register was floating point load
1357   (prev-fr-p4      DI) ; Previous use of FR  register was media unit 4
1358   (prev-fr-p6      DI) ; Previous use of FR  register was media unit 6
1359   (prev-acc-p2     DI) ; Previous use of ACC register was media unit 2
1360   (prev-acc-p4     DI) ; Previous use of ACC register was media unit 4
1361   (cur-fp-load     DI) ; Current  use of FR  register is  floating point load
1362   (cur-fr-p4       DI) ; Current  use of FR  register is  media unit 4
1363   (cur-fr-p6       DI) ; Current  use of FR  register is  media unit 6
1364   (cur-acc-p2      DI) ; Current  use of ACC register is  media unit 2
1365   (cur-acc-p4      DI) ; Current  use of ACC register is  media unit 4
1366  )
1367  (unit u-exec "Execution Unit" ()
1368	1 1 ; issue done
1369	() ; state
1370	() ; inputs
1371	() ; outputs
1372	() ; profile action (default)
1373	)
1374  ; Basic integer insn unit
1375  (unit u-integer "Integer Unit" ()
1376	1 1 ; issue done
1377	() ; state
1378	((GRi INT -1) (GRj INT -1)) ; inputs
1379	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
1380	() ; profile action (default)
1381	)
1382  ; Integer multiplication unit
1383  (unit u-imul "Integer Multiplication Unit" ()
1384	1 1 ; issue done
1385	() ; state
1386	((GRi INT -1) (GRj INT -1)) ; inputs
1387	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
1388	() ; profile action (default)
1389	)
1390  ; Integer division unit
1391  (unit u-idiv "Integer Division Unit" ()
1392	1 1 ; issue done
1393	() ; state
1394	((GRi INT -1) (GRj INT -1)) ; inputs
1395	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
1396	() ; profile action (default)
1397	)
1398  ; Branch unit
1399  (unit u-branch "Branch Unit" ()
1400	1 1 ; issue done
1401	() ; state
1402	((GRi INT -1) (GRj INT -1)
1403	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
1404	((pc)) ; outputs
1405	() ; profile action (default)
1406	)
1407  ; Trap unit
1408  (unit u-trap "Trap Unit" ()
1409	1 1 ; issue done
1410	() ; state
1411	((GRi INT -1) (GRj INT -1)
1412	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
1413	() ; outputs
1414	() ; profile action (default)
1415	)
1416  ; Condition code check unit
1417  (unit u-check "Check Unit" ()
1418	1 1 ; issue done
1419	() ; state
1420	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
1421	() ; outputs
1422	() ; profile action (default)
1423	)
1424  ; GR set half unit
1425  (unit u-set-hilo "GR Set Half" ()
1426	1 1 ; issue done
1427	() ; state
1428	() ; inputs
1429	((GRkhi INT -1) (GRklo INT -1)) ; outputs
1430	() ; profile action (default)
1431	)
1432  ; GR load unit -- TODO doesn't handle quad
1433  (unit u-gr-load "GR Load Unit" ()
1434	1 1 ; issue done
1435	() ; state
1436	((GRi INT -1) (GRj INT -1)) ; inputs
1437	((GRk INT -1) (GRdoublek INT -1)) ; outputs
1438	() ; profile action (default)
1439	)
1440  ; GR store unit -- TODO doesn't handle quad
1441  (unit u-gr-store "GR Store Unit" ()
1442	1 1 ; issue done
1443	() ; state
1444	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
1445	() ; outputs
1446	() ; profile action (default)
1447	)
1448  ; FR load unit -- TODO doesn't handle quad
1449  (unit u-fr-load "FR Load Unit" ()
1450	1 1 ; issue done
1451	() ; state
1452	((GRi INT -1) (GRj INT -1)) ; inputs
1453	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
1454	() ; profile action (default)
1455	)
1456  ; FR store unit -- TODO doesn't handle quad
1457  (unit u-fr-store "FR Store Unit" ()
1458	1 1 ; issue done
1459	() ; state
1460	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
1461	() ; outputs
1462	() ; profile action (default)
1463	)
1464  ; Swap unit
1465  (unit u-swap "Swap Unit" ()
1466	1 1 ; issue done
1467	() ; state
1468	((GRi INT -1) (GRj INT -1)) ; inputs
1469	((GRk INT -1)) ; outputs
1470	() ; profile action (default)
1471	)
1472  ; FR Move to GR unit
1473  (unit u-fr2gr "FR Move to GR Unit" ()
1474	1 1 ; issue done
1475	() ; state
1476	((FRintk INT -1)) ; inputs
1477	((GRj INT -1)) ; outputs
1478	() ; profile action (default)
1479	)
1480  ; SPR Move to GR unit
1481  (unit u-spr2gr "SPR Move to GR Unit" ()
1482	1 1 ; issue done
1483	() ; state
1484	((spr INT -1)) ; inputs
1485	((GRj INT -1)) ; outputs
1486	() ; profile action (default)
1487	)
1488  ; GR Move to FR unit
1489  (unit u-gr2fr "GR Move to FR Unit" ()
1490	1 1 ; issue done
1491	() ; state
1492	((GRj INT -1)) ; inputs
1493	((FRintk INT -1)) ; outputs
1494	() ; profile action (default)
1495	)
1496  ; GR Move to SPR unit
1497  (unit u-gr2spr "GR Move to SPR Unit" ()
1498	1 1 ; issue done
1499	() ; state
1500	((GRj INT -1)) ; inputs
1501	((spr INT -1)) ; outputs
1502	() ; profile action (default)
1503	)
1504  ; Media unit M1 -- see table 14-8 in the fr450 LSI
1505  (unit u-media-1 "Media-1 unit" ()
1506	1 1 ; issue done
1507	() ; state
1508	((FRinti INT -1) (FRintj INT -1)) ; inputs
1509	((FRintk INT -1)) ; outputs
1510	() ; profile action (default)
1511	)
1512  (unit u-media-1-quad "Media-1-quad unit" ()
1513	1 1 ; issue done
1514	() ; state
1515	((FRinti INT -1) (FRintj INT -1)) ; inputs
1516	((FRintk INT -1)) ; outputs
1517	() ; profile action (default)
1518	)
1519  (unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
1520	1 1 ; issue done
1521	() ; state
1522	() ; inputs
1523	((FRkhi INT -1) (FRklo INT -1)) ; outputs
1524	() ; profile action (default)
1525	)
1526  ; Media unit M2 -- see table 14-8 in the fr450 LSI
1527  (unit u-media-2 "Media-2 unit" ()
1528	1 1 ; issue done
1529	() ; state
1530	((FRinti INT -1) (FRintj INT -1)) ; inputs
1531	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
1532	() ; profile action (default)
1533	)
1534  (unit u-media-2-quad "Media-2-quad unit" ()
1535	1 1 ; issue done
1536	() ; state
1537	((FRinti INT -1) (FRintj INT -1)) ; inputs
1538	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
1539	() ; profile action (default)
1540	)
1541  (unit u-media-2-acc "Media-2-acc unit" ()
1542	1 1 ; issue done
1543	() ; state
1544	((ACC40Si INT -1)) ; inputs
1545	((ACC40Sk INT -1)) ; outputs
1546	() ; profile action (default)
1547	)
1548  (unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
1549	1 1 ; issue done
1550	() ; state
1551	((ACC40Si INT -1)) ; inputs
1552	((ACC40Sk INT -1)) ; outputs
1553	() ; profile action (default)
1554	)
1555  (unit u-media-2-add-sub "Media-2-add-sub unit" ()
1556	1 1 ; issue done
1557	() ; state
1558	((ACC40Si INT -1)) ; inputs
1559	((ACC40Sk INT -1)) ; outputs
1560	() ; profile action (default)
1561	)
1562  (unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
1563	1 1 ; issue done
1564	() ; state
1565	((ACC40Si INT -1)) ; inputs
1566	((ACC40Sk INT -1)) ; outputs
1567	() ; profile action (default)
1568	)
1569  ; Media unit M3 -- see table 14-8 in the fr450 LSI
1570  (unit u-media-3 "Media-3 unit" ()
1571	1 1 ; issue done
1572	() ; state
1573	((FRinti INT -1) (FRintj INT -1)) ; inputs
1574	((FRintk INT -1)) ; outputs
1575	() ; profile action (default)
1576	)
1577  (unit u-media-3-dual "Media-3-dual unit" ()
1578	1 1 ; issue done
1579	() ; state
1580	((FRinti INT -1)) ; inputs
1581	((FRintk INT -1)) ; outputs
1582	() ; profile action (default)
1583	)
1584  (unit u-media-3-quad "Media-3-quad unit" ()
1585	1 1 ; issue done
1586	() ; state
1587	((FRinti INT -1) (FRintj INT -1)) ; inputs
1588	((FRintk INT -1)) ; outputs
1589	() ; profile action (default)
1590	)
1591  ; Media unit M4 -- see table 14-8 in the fr450 LSI
1592  (unit u-media-4 "Media-4 unit" ()
1593	1 1 ; issue done
1594	() ; state
1595	((ACC40Si INT -1) (FRintj INT -1)) ; inputs
1596	((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
1597	() ; profile action (default)
1598	)
1599  (unit u-media-4-accg "Media-4-accg unit" ()
1600	1 1 ; issue done
1601	() ; state
1602	((ACCGi INT -1) (FRinti INT -1)) ; inputs
1603	((ACCGk INT -1) (FRintk INT -1)) ; outputs
1604	() ; profile action (default)
1605	)
1606  (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
1607	1 1 ; issue done
1608	() ; state
1609	((ACC40Si INT -1)) ; inputs
1610	((FRintk INT -1)) ; outputs
1611	() ; profile action (default)
1612	)
1613  (unit u-media-4-mclracca "Media-4 unit for MCLRACC with #A=1" ()
1614	1 1 ; issue done
1615	() ; state
1616	() ; inputs
1617	() ; outputs
1618	() ; profile action (default)
1619	)
1620  ; Media unit M6 -- see table 14-8 in the fr450 LSI
1621  (unit u-media-6 "Media-6 unit" ()
1622	1 1 ; issue done
1623	() ; state
1624	((FRinti INT -1)) ; inputs
1625	((FRintk INT -1)) ; outputs
1626	() ; profile action (default)
1627	)
1628  ; Media unit M7 -- see table 14-8 in the fr450 LSI
1629  (unit u-media-7 "Media-1 unit" ()
1630	1 1 ; issue done
1631	() ; state
1632	((FRinti INT -1) (FRintj INT -1)) ; inputs
1633	((FCCk INT -1)) ; outputs
1634	() ; profile action (default)
1635	)
1636  ; Media Dual Expand unit
1637  (unit u-media-dual-expand "Media Dual Expand unit" ()
1638	1 1 ; issue done
1639	() ; state
1640	((FRinti INT -1)) ; inputs
1641	((FRintk INT -1)) ; outputs
1642	() ; profile action (default)
1643	)
1644  ; Media Dual half to byte unit
1645  (unit u-media-dual-htob "Media Half to byte" ()
1646	1 1 ; issue done
1647	() ; state
1648	((FRintj INT -1)) ; inputs
1649	((FRintk INT -1)) ; outputs
1650	() ; profile action (default)
1651	)
1652  ; Barrier unit
1653  (unit u-barrier "Barrier unit" ()
1654	1 1 ; issue done
1655	() ; state
1656	() ; inputs
1657	() ; outputs
1658	() ; profile action (default)
1659	)
1660  ; Memory Barrier unit
1661  (unit u-membar "Memory Barrier unit" ()
1662	1 1 ; issue done
1663	() ; state
1664	() ; inputs
1665	() ; outputs
1666	() ; profile action (default)
1667	)
1668  ; Insn cache invalidate unit
1669  (unit u-ici "Insn cache invalidate unit" ()
1670	1 1 ; issue done
1671	() ; state
1672	((GRi INT -1) (GRj INT -1)) ; inputs
1673	() ; outputs
1674	() ; profile action (default)
1675	)
1676  ; Data cache invalidate unit
1677  (unit u-dci "Data cache invalidate unit" ()
1678	1 1 ; issue done
1679	() ; state
1680	((GRi INT -1) (GRj INT -1)) ; inputs
1681	() ; outputs
1682	() ; profile action (default)
1683	)
1684  ; Data cache flush unit
1685  (unit u-dcf "Data cache flush unit" ()
1686	1 1 ; issue done
1687	() ; state
1688	((GRi INT -1) (GRj INT -1)) ; inputs
1689	() ; outputs
1690	() ; profile action (default)
1691	)
1692  ; Insn cache preload unit
1693  (unit u-icpl "Insn cache preload unit" ()
1694	1 1 ; issue done
1695	() ; state
1696	((GRi INT -1) (GRj INT -1)) ; inputs
1697	() ; outputs
1698	() ; profile action (default)
1699	)
1700  ; Data cache preload unit
1701  (unit u-dcpl "Data cache preload unit" ()
1702	1 1 ; issue done
1703	() ; state
1704	((GRi INT -1) (GRj INT -1)) ; inputs
1705	() ; outputs
1706	() ; profile action (default)
1707	)
1708  ; Insn cache unlock unit
1709  (unit u-icul "Insn cache unlock unit" ()
1710	1 1 ; issue done
1711	() ; state
1712	((GRi INT -1) (GRj INT -1)) ; inputs
1713	() ; outputs
1714	() ; profile action (default)
1715	)
1716  ; Data cache unlock unit
1717  (unit u-dcul "Data cache unlock unit" ()
1718	1 1 ; issue done
1719	() ; state
1720	((GRi INT -1) (GRj INT -1)) ; inputs
1721	() ; outputs
1722	() ; profile action (default)
1723	)
1724)
1725
1726; Simple machine - single issue integer machine
1727(define-mach
1728  (name simple)
1729  (comment "Simple single issue integer cpu")
1730  (cpu frvbf)
1731)
1732(define-model
1733  (name simple) (comment "Simple model") (attrs)
1734  (mach simple)
1735  (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
1736  ; `state' is a list of variables for recording model state
1737  (state)
1738  (unit u-exec "Execution Unit" ()
1739	1 1 ; issue done
1740	() ; state
1741	() ; inputs
1742	() ; outputs
1743	() ; profile action (default)
1744	)
1745)
1746
1747; The instruction fetch/execute cycle.
1748;
1749; This is how to fetch and decode an instruction.
1750; Leave it out for now
1751
1752; (define-extract (const SI 0))
1753
1754; This is how to execute a decoded instruction.
1755; Leave it out for now
1756
1757; (define-execute (const SI 0))
1758
1759; An attribute to describe which unit an insn runs in.
1760(define-attr
1761  (for insn)
1762  (type enum)
1763  (name UNIT)
1764  (comment "parallel execution pipeline selection")
1765  ; The order of declaration is significant.
1766  ; See the *_unit_mapping tables in frv.opc
1767  ; Keep variations on the same unit together.
1768  ; Keep the '01' variant immediately after the '1' variant in each unit.
1769  ; Keep the 'ALL' variations immediately after the last numbered variant in each unit.
1770  (values NIL
1771	  I0 I1 I01 I2 I3 IALL
1772	  FM0 FM1 FM01 FM2 FM3 FMALL FMLOW
1773	  B0 B1 B01
1774	  C
1775	  MULT-DIV ; multiply/division slotted differently on different machines
1776	  IACC     ; iacc multiply     slotted differently on different machines
1777	  LOAD     ; loads             slotted differently on different machines
1778	  STORE    ; store             slotted differently on different machines
1779	  SCAN     ; scan, scani       slotted differently on different machines
1780	  DCPL     ; dcpl              slotted differently on different machines
1781	  MDUALACC ; media dual acc    slotted differently on different machines
1782	  MDCUTSSI ; mdcutssi insn     slotted differently on different machines
1783	  MCLRACC-1; mclracc A==1      slotted differently on different machines
1784	  NUM_UNITS
1785  )
1786)
1787; Attributes to describe major categories of insns
1788(define-attr
1789  (for insn)
1790  (type enum)
1791  (name FR400-MAJOR)
1792  (comment "fr400 major insn categories")
1793  ; The order of declaration is significant. Keep variations on the same major
1794  ; together.
1795  (values NONE
1796	  I-1 I-2 I-3 I-4 I-5
1797	  B-1 B-2 B-3 B-4 B-5 B-6
1798	  C-1 C-2
1799	  M-1 M-2
1800  )
1801)
1802(define-attr
1803  (for insn)
1804  (type enum)
1805  (name FR450-MAJOR)
1806  (comment "fr450 major insn categories")
1807  ; The order of declaration is significant. Keep variations on the same major
1808  ; together.
1809  (values NONE
1810	  I-1 I-2 I-3 I-4 I-5
1811	  B-1 B-2 B-3 B-4 B-5 B-6
1812	  C-1 C-2
1813	  M-1 M-2 M-3 M-4 M-5 M-6
1814  )
1815)
1816(define-attr
1817  (for insn)
1818  (type enum)
1819  (name FR500-MAJOR)
1820  (comment "fr500 major insn categories")
1821  ; The order of declaration is significant. Keep variations on the same major
1822  ; together.
1823  (values NONE
1824	  I-1 I-2 I-3 I-4 I-5 I-6
1825	  B-1 B-2 B-3 B-4 B-5 B-6
1826	  C-1 C-2
1827	  F-1 F-2 F-3 F-4 F-5 F-6 F-7 F-8
1828	  M-1 M-2 M-3 M-4 M-5 M-6 M-7 M-8
1829  )
1830)
1831(define-attr
1832  (for insn)
1833  (type enum)
1834  (name FR550-MAJOR)
1835  (comment "fr550 major insn categories")
1836  ; The order of declaration is significant. Keep variations on the same major
1837  ; together.
1838  (values NONE
1839	  I-1 I-2 I-3 I-4 I-5 I-6 I-7 I-8
1840	  B-1 B-2 B-3 B-4 B-5 B-6
1841	  C-1 C-2
1842	  F-1 F-2 F-3 F-4
1843	  M-1 M-2 M-3 M-4 M-5
1844  )
1845)
1846; Privileged insn
1847(define-attr
1848  (for insn)
1849  (type boolean)
1850  (name PRIVILEGED)
1851  (comment "insn only allowed in supervisor mode")
1852)
1853; Non-Excepting insn
1854(define-attr
1855  (for insn)
1856  (type boolean)
1857  (name NON-EXCEPTING)
1858  (comment "non-excepting insn")
1859)
1860; Conditional insn
1861(define-attr
1862  (for insn)
1863  (type boolean)
1864  (name CONDITIONAL)
1865  (comment "conditional insn")
1866)
1867; insn accesses FR registers
1868(define-attr
1869  (for insn)
1870  (type boolean)
1871  (name FR-ACCESS)
1872  (comment "insn accesses FR registers")
1873)
1874; insn preserves MSR.OVF
1875(define-attr
1876  (for insn)
1877  (type boolean)
1878  (name PRESERVE-OVF)
1879  (comment "Preserve value of MSR.OVF")
1880)
1881; "Audio" instruction provided by the fr405 but not the original fr400 core.
1882(define-attr
1883  (for insn)
1884  (type boolean)
1885  (name AUDIO)
1886  (comment "Audio instruction added with FR405")
1887)
1888; null attribute -- used as a place holder for where an attribue is required.
1889(define-attr
1890  (for insn)
1891  (type boolean)
1892  (name NA)
1893  (comment "placeholder attribute")
1894  (attrs META) ; do not define in any generated file for now
1895)
1896
1897; IDOC attribute for instruction documentation.
1898
1899(define-attr
1900  (for insn)
1901  (type enum)
1902  (name IDOC)
1903  (comment "insn kind for documentation")
1904  (attrs META)
1905  (values
1906   (MEM - () "Memory")
1907   (ALU - () "ALU")
1908   (FPU - () "FPU")
1909   (BR - () "Branch")
1910   (PRIV - () "Priviledged")
1911   (MISC - () "Miscellaneous")
1912  )
1913)
1914
1915; Instruction fields.
1916;
1917; Attributes:
1918; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
1919; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
1920; RESERVED: bits are not used to decode insn, must be all 0
1921(dnf f-pack      "packing bit"                  () 31  1)
1922(dnf f-op        "primary opcode"               () 24  7)
1923(dnf f-ope1      "extended opcode"              () 11  6)
1924(dnf f-ope2      "extended opcode"              ()  9  4)
1925(dnf f-ope3      "extended opcode"              () 15  3)
1926(dnf f-ope4      "extended opcode"              ()  7  2)
1927
1928(dnf f-GRi       "source register 1"            () 17  6)
1929(dnf f-GRj       "source register 2"            ()  5  6)
1930(dnf f-GRk       "destination register"         () 30  6)
1931
1932(dnf f-FRi       "source register 1"            () 17  6)
1933(dnf f-FRj       "source register 2"            ()  5  6)
1934(dnf f-FRk       "destination register"         () 30  6)
1935
1936(dnf f-CPRi      "source register 1"            () 17  6)
1937(dnf f-CPRj      "source register 2"            ()  5  6)
1938(dnf f-CPRk      "destination register"         () 30  6)
1939
1940(dnf f-ACCGi     "source register"              () 17  6)
1941(dnf f-ACCGk     "destination register"         () 30  6)
1942
1943(dnf f-ACC40Si   "40 bit signed accumulator"    () 17  6)
1944(dnf f-ACC40Ui   "40 bit unsigned accumulator"  () 17  6)
1945(dnf f-ACC40Sk   "40 bit accumulator"           () 30  6)
1946(dnf f-ACC40Uk   "40 bit accumulator"           () 30  6)
1947
1948(dnf f-CRi       "source      register"         () 14  3)
1949(dnf f-CRj       "source      register"         ()  2  3)
1950(dnf f-CRk       "destination register"         () 27  3)
1951(dnf f-CCi       "condition   register"         () 11  3)
1952
1953(df  f-CRj_int   "target cr for ck insns"       () 26  2 UINT
1954     ((value pc) (sub WI value 4))
1955     ((value pc) (add WI value 4))
1956)
1957(dnf f-CRj_float "target cr for fck insns"      () 26  2)
1958
1959(dnf f-ICCi_1    "condition register"           () 11  2)
1960(dnf f-ICCi_2    "condition register"           () 26  2)
1961(dnf f-ICCi_3    "condition register"           ()  1  2)
1962(dnf f-FCCi_1    "condition register"           () 11  2)
1963(dnf f-FCCi_2    "condition register"           () 26  2)
1964(dnf f-FCCi_3    "condition register"           ()  1  2)
1965(dnf f-FCCk      "condition register"           () 26  2)
1966(dnf f-eir       "exception insn register"      () 17  6)
1967
1968(df  f-s10       "10 bit sign extended"         ()  9 10  INT #f #f)
1969(df  f-s12       "12 bit sign extended"         () 11 12  INT #f #f)
1970(df  f-d12       "12 bit sign extended"         () 11 12  INT #f #f)
1971(df  f-u16       "16 bit unsigned"              () 15 16 UINT #f #f)
1972(df  f-s16       "16 bit sign extended"         () 15 16  INT #f #f)
1973(df  f-s6        "6  bit   signed"              ()  5  6  INT #f #f)
1974(df  f-s6_1      "6  bit   signed"              () 11  6  INT #f #f)
1975(df  f-u6        "6  bit unsigned"              ()  5  6 UINT #f #f)
1976(df  f-s5        "5  bit   signed"              ()  4  5  INT #f #f)
1977
1978(df  f-u12-h "upper 6 bits of u12"  () 17 6  INT #f #f)
1979(df  f-u12-l "lower 6 bits of u12"  ()  5 6 UINT #f #f)
1980(dnmf f-u12   "12 bit signed immediate" () INT
1981      (f-u12-h f-u12-l)
1982      (sequence () ; insert
1983		(set (ifield f-u12-h) (sra SI (ifield f-u12) 6))
1984		(set (ifield f-u12-l) (and (ifield f-u12) #x3f))
1985		)
1986      (sequence () ; extract
1987		(set (ifield f-u12) (or (mul (ifield f-u12-h) 64)
1988					(ifield f-u12-l)))
1989		)
1990)
1991
1992(dnf f-int-cc    "integer  branch conditions"   () 30  4)
1993(dnf f-flt-cc    "floating branch conditions"   () 30  4)
1994(df  f-cond      "conditional arithmetic"       ()  8  1 UINT #f #f)
1995(df  f-ccond     "lr branch condition"          () 12  1 UINT #f #f)
1996(df  f-hint      "2 bit branch prediction hint" () 17  2 UINT #f #f)
1997(df  f-LI        "link indicator"               () 25  1 UINT #f #f)
1998(df  f-lock      "cache lock indicator"         () 25  1 UINT #f #f)
1999(df  f-debug     "debug mode indicator"         () 25  1 UINT #f #f)
2000(df  f-A         "all accumulator bit"          () 17  1 UINT #f #f)
2001(df  f-ae        "cache all entries indicator"  () 25  1 UINT #f #f)
2002
2003(dnf  f-spr-h "upper 6 bits of spr"  () 30  6)
2004(dnf  f-spr-l "lower 6 bits of spr"  () 17  6)
2005(dnmf f-spr   "special purpose register" () UINT
2006      (f-spr-h f-spr-l)
2007      (sequence () ; insert
2008		(set (ifield f-spr-h) (srl (ifield f-spr) (const 6)))
2009		(set (ifield f-spr-l) (and (ifield f-spr) (const #x3f)))
2010		)
2011      (sequence () ; extract
2012		(set (ifield f-spr) (or (sll (ifield f-spr-h) (const 6))
2013					(ifield f-spr-l)))
2014		)
2015)
2016
2017(df  f-label16    "18 bit pc relative signed offset" (PCREL-ADDR) 15 16 INT
2018     ((value pc) (sra WI (sub WI value pc) (const 2)))
2019     ((value pc) (add WI (mul WI value (const 4)) pc))
2020)
2021
2022(df   f-labelH6   "upper 6  bits of label24"  () 30  6 INT #f #f)
2023(dnf  f-labelL18  "lower 18 bits of label24"  () 17 18)
2024(dnmf f-label24   "26 bit signed offset"     (PCREL-ADDR) INT
2025      (f-labelH6 f-labelL18)
2026      ; insert
2027      (sequence ()
2028		(set (ifield f-labelH6)
2029		     (sra WI (sub (ifield f-label24) pc) (const 20)))
2030		(set (ifield f-labelL18)
2031		     (and (srl (sub (ifield f-label24) pc) (const 2))
2032			  (const #x3ffff)))
2033		)
2034      ; extract
2035      (sequence ()
2036		(set (ifield f-label24)
2037		     (add (mul (or (mul (ifield f-labelH6) (sll 1 18))
2038				   (ifield f-labelL18))
2039			       (const 4))
2040			  pc)))
2041)
2042
2043(dnf f-LRAE "Load Real Address E flag" () 5 1)
2044(dnf f-LRAD "Load Real Address D flag" () 4 1)
2045(dnf f-LRAS "Load Real Address S flag" () 3 1)
2046
2047(dnf f-TLBPRopx "TLB Probe operation number" () 28 3)
2048(dnf f-TLBPRL   "TLB Probe L flag" () 25 1)
2049
2050(dnf f-ICCi_1-null  "null field" (RESERVED) 11  2)
2051(dnf f-ICCi_2-null  "null field" (RESERVED) 26  2)
2052(dnf f-ICCi_3-null  "null field" (RESERVED)  1  2)
2053(dnf f-FCCi_1-null  "null field" (RESERVED) 11  2)
2054(dnf f-FCCi_2-null  "null field" (RESERVED) 26  2)
2055(dnf f-FCCi_3-null  "null field" (RESERVED)  1  2)
2056(dnf f-rs-null      "null field" (RESERVED) 17  6)
2057(dnf f-GRi-null     "null field" (RESERVED) 17  6)
2058(dnf f-GRj-null     "null field" (RESERVED)  5  6)
2059(dnf f-GRk-null     "null field" (RESERVED) 30  6)
2060(dnf f-FRi-null     "null field" (RESERVED) 17  6)
2061(dnf f-FRj-null     "null field" (RESERVED)  5  6)
2062(dnf f-ACCj-null    "null field" (RESERVED)  5  6)
2063(dnf f-rd-null      "null field" (RESERVED) 30  6)
2064(dnf f-cond-null    "null field" (RESERVED) 30  4)
2065(dnf f-ccond-null   "null field" (RESERVED) 12  1)
2066(dnf f-s12-null     "null field" (RESERVED) 11 12)
2067(dnf f-label16-null "null field" (RESERVED) 15 16)
2068(dnf f-misc-null-1  "null field" (RESERVED) 30  5)
2069(dnf f-misc-null-2  "null field" (RESERVED) 11  6)
2070(dnf f-misc-null-3  "null field" (RESERVED) 11  4)
2071(dnf f-misc-null-4  "null field" (RESERVED) 17  2)
2072(dnf f-misc-null-5  "null field" (RESERVED) 17 16)
2073(dnf f-misc-null-6  "null field" (RESERVED) 30  3)
2074(dnf f-misc-null-7  "null field" (RESERVED) 17  3)
2075(dnf f-misc-null-8  "null field" (RESERVED)  5  3)
2076(dnf f-misc-null-9  "null field" (RESERVED)  5  4)
2077(dnf f-misc-null-10 "null field" (RESERVED) 16  5)
2078(dnf f-misc-null-11 "null field" (RESERVED)  5  1)
2079
2080(dnf f-LRA-null     "null field" (RESERVED)  2  3)
2081(dnf f-TLBPR-null   "null field" (RESERVED) 30  2)
2082
2083(dnf f-LI-off      "null field" (RESERVED) 25  1)
2084(dnf f-LI-on       "null field" (RESERVED) 25  1)
2085
2086; Relocation annotations.
2087(dsh h-reloc-ann   "relocation annotation" () (register BI))
2088(dnf f-reloc-ann   "relocation annotation" () 0 0)
2089
2090(define-pmacro (dann xname xcomment xmode xparse xprint)
2091  (define-operand
2092    (name xname)
2093    (comment xcomment)
2094    (type h-reloc-ann)
2095    (index f-reloc-ann)
2096    (mode xmode)
2097    (handlers (parse xparse) (print xprint))
2098    )
2099  )
2100
2101
2102; Enums.
2103
2104; insn-op:
2105; FIXME: should use die macro or some such
2106(define-normal-insn-enum insn-op "insn op enums" () OP_ f-op
2107 (
2108 "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
2109 "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F"
2110 "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F"
2111 "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F"
2112 "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "4A" "4B" "4C" "4D" "4E" "4F"
2113 "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "5A" "5B" "5C" "5D" "5E" "5F"
2114 "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "6A" "6B" "6C" "6D" "6E" "6F"
2115 "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "7A" "7B" "7C" "7D" "7E" "7F"
2116 )
2117)
2118
2119(define-normal-insn-enum insn-ope1 "insn ope enums" () OPE1_ f-ope1
2120 (
2121 "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
2122 "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F"
2123 "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F"
2124 "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F"
2125 )
2126)
2127
2128(define-normal-insn-enum insn-ope2 "insn ope enums" () OPE2_ f-ope2
2129 (
2130 "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
2131 )
2132)
2133
2134(define-normal-insn-enum insn-ope3 "insn ope enums" () OPE3_ f-ope3
2135 (
2136 "00" "01" "02" "03" "04" "05" "06" "07"
2137 )
2138)
2139
2140(define-normal-insn-enum insn-ope4 "insn ope enums" () OPE4_ f-ope4
2141 (
2142 "0" "1" "2" "3"
2143 )
2144)
2145
2146; int-cc: integer branch conditions
2147; FIXME: should use die macro or some such
2148(define-normal-insn-enum int-cc "integer branch cond enums" () ICC_ f-int-cc
2149  (
2150   "nev" "c"  "v"  "lt" "eq" "ls" "n" "le"
2151   "ra"  "nc" "nv" "ge" "ne" "hi" "p" "gt"
2152  )
2153)
2154
2155; flt-cc: floating-point/media branch conditions
2156; FIXME: should use die macro or some such
2157(define-normal-insn-enum flt-cc "float branch cond enums" () FCC_ f-flt-cc
2158  ("nev" "u" "gt" "ug" "lt" "ul" "lg" "ne"
2159   "eq" "ue" "ge" "uge" "le" "ule" "o" "ra")
2160)
2161
2162; Hardware pieces.
2163; These entries list the elements of the raw hardware.
2164; They're also used to provide tables and other elements of the assembly
2165; language.
2166(dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
2167
2168; The PSR. The individual fields are referenced more than the entire
2169; register, so reference them directly. We can assemble the
2170; entire register contents when necessary.
2171;
2172(dsh h-psr_imple "PSR.IMPLE"   () (register UQI))
2173(dsh h-psr_ver   "PSR.VER"     () (register UQI))
2174(dsh h-psr_ice   "PSR.ICE bit" () (register BI))
2175(dsh h-psr_nem   "PSR.NEM bit" () (register BI))
2176(dsh h-psr_cm    "PSR.CM  bit" () (register BI))
2177(dsh h-psr_be    "PSR.BE  bit" () (register BI))
2178(dsh h-psr_esr   "PSR.ESR bit" () (register BI))
2179(dsh h-psr_ef    "PSR.EF  bit" () (register BI))
2180(dsh h-psr_em    "PSR.EM  bit" () (register BI))
2181(dsh h-psr_pil   "PSR.PIL    " () (register UQI))
2182(dsh h-psr_ps    "PSR.PS  bit" () (register BI))
2183(dsh h-psr_et    "PSR.ET  bit" () (register BI))
2184
2185; PSR.S requires special handling because the shadow registers (SR0-SR4) must
2186; be switched with GR4-GR7 when changing from user to supervisor mode or
2187; vice-versa.
2188(define-hardware
2189  (name h-psr_s)
2190  (comment "PSR.S bit")
2191  (attrs)
2192  (type register BI)
2193  (get)
2194  (set (newval) (c-call VOID "@cpu@_h_psr_s_set_handler" newval))
2195)
2196
2197; The TBR. The individual bits are referenced more than the entire
2198; register, so reference them directly. We can assemble the
2199; entire register contents when necessary.
2200;
2201(dsh h-tbr_tba "TBR.TBA" () (register UWI))
2202(dsh h-tbr_tt  "TBR.TT"  () (register UQI))
2203
2204; The BPSR. The individual bits are referenced more than the entire
2205; register, so reference them directly. We can assemble the
2206; entire register contents when necessary.
2207;
2208(dsh h-bpsr_bs   "PSR.S   bit" () (register BI))
2209(dsh h-bpsr_bet  "PSR.ET  bit" () (register BI))
2210
2211; General registers
2212;
2213(define-keyword
2214  (name gr-names)
2215  (print-name h-gr)
2216  (prefix "")
2217  (values
2218   (sp 1) (fp 2)
2219   (gr0   0)(gr1   1)(gr2   2)(gr3   3)(gr4   4)(gr5   5)(gr6   6)(gr7   7)
2220   (gr8   8)(gr9   9)(gr10 10)(gr11 11)(gr12 12)(gr13 13)(gr14 14)(gr15 15)
2221   (gr16 16)(gr17 17)(gr18 18)(gr19 19)(gr20 20)(gr21 21)(gr22 22)(gr23 23)
2222   (gr24 24)(gr25 25)(gr26 26)(gr27 27)(gr28 28)(gr29 29)(gr30 30)(gr31 31)
2223   (gr32 32)(gr33 33)(gr34 34)(gr35 35)(gr36 36)(gr37 37)(gr38 38)(gr39 39)
2224   (gr40 40)(gr41 41)(gr42 42)(gr43 43)(gr44 44)(gr45 45)(gr46 46)(gr47 47)
2225   (gr48 48)(gr49 49)(gr50 50)(gr51 51)(gr52 52)(gr53 53)(gr54 54)(gr55 55)
2226   (gr56 56)(gr57 57)(gr58 58)(gr59 59)(gr60 60)(gr61 61)(gr62 62)(gr63 63)
2227  )
2228)
2229
2230(define-hardware
2231  (name h-gr)
2232  (comment "general registers")
2233  (attrs PROFILE)
2234  (type register USI (64))
2235  (indices extern-keyword gr-names)
2236  (get (index) (c-call WI "@cpu@_h_gr_get_handler" index))
2237  (set (index newval) (c-call VOID "@cpu@_h_gr_set_handler" index newval))
2238)
2239
2240; General Registers as double words
2241; These registers are shadowed onto h-gr
2242(define-hardware
2243  (name h-gr_double)
2244  (comment "general registers as double words")
2245  (attrs PROFILE VIRTUAL)
2246  (type register DI (32))
2247  ; FIXME: Need constraint to prohibit odd numbers.
2248  (indices extern-keyword gr-names)
2249  (get (index)
2250       (c-call DI "@cpu@_h_gr_double_get_handler" index))
2251  (set (index newval)
2252       (c-call VOID "@cpu@_h_gr_double_set_handler" index newval))
2253)
2254
2255; General Registers as high and low half words
2256; These registers are shadowed onto h-gr
2257(define-hardware
2258  (name h-gr_hi)
2259  (comment "general registers as high half word")
2260  (attrs PROFILE VIRTUAL)
2261  (type register UHI (64))
2262  (indices extern-keyword gr-names)
2263  (get (index) (c-call UHI "@cpu@_h_gr_hi_get_handler" index))
2264  (set (index newval) (c-call VOID "@cpu@_h_gr_hi_set_handler" index newval))
2265)
2266(define-hardware
2267  (name h-gr_lo)
2268  (comment "general registers as low half word")
2269  (attrs PROFILE VIRTUAL)
2270  (type register UHI (64))
2271  (indices extern-keyword gr-names)
2272  (get (index) (c-call UHI "@cpu@_h_gr_lo_get_handler" index))
2273  (set (index newval) (c-call VOID "@cpu@_h_gr_lo_set_handler" index newval))
2274)
2275
2276; Floating Point Registers
2277(define-keyword
2278  (name fr-names)
2279  (print-name h-fr)
2280  (prefix "")
2281  (values
2282   (fr0   0)(fr1   1)(fr2   2)(fr3   3)(fr4   4)(fr5   5)(fr6   6)(fr7   7)
2283   (fr8   8)(fr9   9)(fr10 10)(fr11 11)(fr12 12)(fr13 13)(fr14 14)(fr15 15)
2284   (fr16 16)(fr17 17)(fr18 18)(fr19 19)(fr20 20)(fr21 21)(fr22 22)(fr23 23)
2285   (fr24 24)(fr25 25)(fr26 26)(fr27 27)(fr28 28)(fr29 29)(fr30 30)(fr31 31)
2286   (fr32 32)(fr33 33)(fr34 34)(fr35 35)(fr36 36)(fr37 37)(fr38 38)(fr39 39)
2287   (fr40 40)(fr41 41)(fr42 42)(fr43 43)(fr44 44)(fr45 45)(fr46 46)(fr47 47)
2288   (fr48 48)(fr49 49)(fr50 50)(fr51 51)(fr52 52)(fr53 53)(fr54 54)(fr55 55)
2289   (fr56 56)(fr57 57)(fr58 58)(fr59 59)(fr60 60)(fr61 61)(fr62 62)(fr63 63)
2290  )
2291)
2292
2293(define-hardware
2294  (name h-fr)
2295  (comment "floating point registers")
2296  (attrs PROFILE)
2297  (type register SF (64))
2298  (indices extern-keyword fr-names)
2299  (get (index) (c-call SF "@cpu@_h_fr_get_handler" index))
2300  (set (index newval) (c-call VOID "@cpu@_h_fr_set_handler" index newval))
2301)
2302
2303; Floating Point Registers as double precision
2304; These registers are shadowed onto h-fr
2305
2306(define-hardware
2307  (name h-fr_double)
2308  (comment "floating point registers as double precision")
2309  (attrs PROFILE VIRTUAL)
2310  (type register DF (32))
2311  ; FIXME: Need constraint to prohibit odd numbers.
2312  (indices extern-keyword fr-names)
2313  (get (index)
2314       (c-call DF "@cpu@_h_fr_double_get_handler" index))
2315  (set (index newval)
2316       (c-call VOID "@cpu@_h_fr_double_set_handler" index newval))
2317)
2318
2319; Floating Point Registers as integer words.
2320; These registers are shadowed onto h-fr
2321
2322(define-hardware
2323  (name h-fr_int)
2324  (comment "floating point registers as integers")
2325  (attrs PROFILE VIRTUAL)
2326  (type register USI (64))
2327  (indices extern-keyword fr-names)
2328  (get (index)
2329       (c-call USI "@cpu@_h_fr_int_get_handler" index))
2330  (set (index newval)
2331       (c-call VOID "@cpu@_h_fr_int_set_handler" index newval))
2332)
2333
2334; Floating Point Registers as high and low half words
2335; These registers are shadowed onto h-fr
2336(define-hardware
2337  (name h-fr_hi)
2338  (comment "floating point registers as unsigned high half word")
2339  (attrs PROFILE VIRTUAL)
2340  (type register UHI (64))
2341  (indices extern-keyword fr-names)
2342  (get (regno) (srl (reg h-fr_int regno) 16))
2343  (set (regno newval) (set (reg h-fr_int regno)
2344			   (or (and (reg h-fr_int regno) #xffff)
2345			       (sll newval 16))))
2346)
2347(define-hardware
2348  (name h-fr_lo)
2349  (comment "floating point registers as unsigned low half word")
2350  (attrs PROFILE VIRTUAL)
2351  (type register UHI (64))
2352  (indices extern-keyword fr-names)
2353  (get (regno) (and (reg h-fr_int regno) #xffff))
2354  (set (regno newval) (set (reg h-fr_int regno)
2355			   (or (and (reg h-fr_int regno) #xffff0000)
2356			       (and newval #xffff))))
2357)
2358
2359; Floating Point Registers as unsigned bytes
2360; These registers are shadowed onto h-fr
2361(define-hardware
2362  (name h-fr_0)
2363  (comment "floating point registers as unsigned byte 0")
2364  (attrs PROFILE VIRTUAL)
2365  (type register UHI (64))
2366  (indices extern-keyword fr-names)
2367  (get (regno) (and (reg h-fr_int regno) #xff))
2368  (set (regno newval)
2369       (sequence ()
2370		 (if (gt USI newval #xff)
2371		     (set newval #xff))
2372		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xffffff00)
2373					   newval))))
2374)
2375(define-hardware
2376  (name h-fr_1)
2377  (comment "floating point registers as unsigned byte 1")
2378  (attrs PROFILE VIRTUAL)
2379  (type register UHI (64))
2380  (indices extern-keyword fr-names)
2381  (get (regno) (and (srl (reg h-fr_int regno) 8) #xff))
2382  (set (regno newval)
2383       (sequence ()
2384		 (if (gt USI newval #xff)
2385		     (set newval #xff))
2386		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xffff00ff)
2387					   (sll newval 8)))))
2388)
2389(define-hardware
2390  (name h-fr_2)
2391  (comment "floating point registers as unsigned byte 2")
2392  (attrs PROFILE VIRTUAL)
2393  (type register UHI (64))
2394  (indices extern-keyword fr-names)
2395  (get (regno) (and (srl (reg h-fr_int regno) 16) #xff))
2396  (set (regno newval)
2397       (sequence ()
2398		 (if (gt USI newval #xff)
2399		     (set newval #xff))
2400		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xff00ffff)
2401					   (sll newval 16)))))
2402)
2403(define-hardware
2404  (name h-fr_3)
2405  (comment "floating point registers as unsigned byte 3")
2406  (attrs PROFILE VIRTUAL)
2407  (type register UHI (64))
2408  (indices extern-keyword fr-names)
2409  (get (regno) (and (srl (reg h-fr_int regno) 24) #xff))
2410  (set (regno newval)
2411       (sequence ()
2412		 (if (gt USI newval #xff)
2413		     (set newval #xff))
2414		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #x00ffffff)
2415					   (sll newval 24)))))
2416)
2417; Coprocessor Registers
2418;
2419(define-keyword
2420  (name cpr-names)
2421  (print-name h-cpr)
2422  (prefix "")
2423  (values
2424(cpr0   0)(cpr1   1)(cpr2   2)(cpr3   3)(cpr4   4)(cpr5   5)(cpr6   6)(cpr7   7)
2425(cpr8   8)(cpr9   9)(cpr10 10)(cpr11 11)(cpr12 12)(cpr13 13)(cpr14 14)(cpr15 15)
2426(cpr16 16)(cpr17 17)(cpr18 18)(cpr19 19)(cpr20 20)(cpr21 21)(cpr22 22)(cpr23 23)
2427(cpr24 24)(cpr25 25)(cpr26 26)(cpr27 27)(cpr28 28)(cpr29 29)(cpr30 30)(cpr31 31)
2428(cpr32 32)(cpr33 33)(cpr34 34)(cpr35 35)(cpr36 36)(cpr37 37)(cpr38 38)(cpr39 39)
2429(cpr40 40)(cpr41 41)(cpr42 42)(cpr43 43)(cpr44 44)(cpr45 45)(cpr46 46)(cpr47 47)
2430(cpr48 48)(cpr49 49)(cpr50 50)(cpr51 51)(cpr52 52)(cpr53 53)(cpr54 54)(cpr55 55)
2431(cpr56 56)(cpr57 57)(cpr58 58)(cpr59 59)(cpr60 60)(cpr61 61)(cpr62 62)(cpr63 63)
2432  )
2433)
2434
2435(define-hardware
2436  (name h-cpr)
2437  (comment "coprocessor registers")
2438  (attrs PROFILE (MACH frv))
2439  (type register WI (64))
2440  (indices extern-keyword cpr-names)
2441)
2442
2443; Coprocessor Registers as double words
2444; These registers are shadowed onto h-cpr
2445(define-hardware
2446  (name h-cpr_double)
2447  (comment "coprocessor registers as double words")
2448  (attrs PROFILE VIRTUAL (MACH frv))
2449  (type register DI (32))
2450  ; FIXME: Need constraint to prohibit odd numbers.
2451  (indices extern-keyword cpr-names)
2452  (get (index)
2453       (c-call DI "@cpu@_h_cpr_double_get_handler" index))
2454  (set (index newval)
2455       (c-call VOID "@cpu@_h_cpr_double_set_handler" index newval))
2456)
2457
2458; Special Purpose Registers
2459;
2460(define-keyword
2461  (name spr-names)
2462  (print-name h-spr)
2463  (prefix "")
2464  (values
2465   (psr        0) (pcsr       1) (bpcsr      2) (tbr        3) (bpsr       4)
2466
2467   (hsr0      16) (hsr1      17) (hsr2      18) (hsr3      19)
2468   (hsr4      20) (hsr5      21) (hsr6      22) (hsr7      23)
2469   (hsr8      24) (hsr9      25) (hsr10     26) (hsr11     27)
2470   (hsr12     28) (hsr13     29) (hsr14     30) (hsr15     31)
2471   (hsr16     32) (hsr17     33) (hsr18     34) (hsr19     35)
2472   (hsr20     36) (hsr21     37) (hsr22     38) (hsr23     39)
2473   (hsr24     40) (hsr25     41) (hsr26     42) (hsr27     43)
2474   (hsr28     44) (hsr29     45) (hsr30     46) (hsr31     47)
2475   (hsr32     48) (hsr33     49) (hsr34     50) (hsr35     51)
2476   (hsr36     52) (hsr37     53) (hsr38     54) (hsr39     55)
2477   (hsr40     56) (hsr41     57) (hsr42     58) (hsr43     59)
2478   (hsr44     60) (hsr45     61) (hsr46     62) (hsr47     63)
2479   (hsr48     64) (hsr49     65) (hsr50     66) (hsr51     67)
2480   (hsr52     68) (hsr53     69) (hsr54     70) (hsr55     71)
2481   (hsr56     72) (hsr57     73) (hsr58     74) (hsr59     75)
2482   (hsr60     76) (hsr61     77) (hsr62     78) (hsr63     79)
2483
2484   (ccr      256) (cccr     263) (lr       272) (lcr      273) (iacc0h   280) (iacc0l   281) (isr      288)
2485
2486   (neear0   352) (neear1   353) (neear2   354) (neear3   355)
2487   (neear4   356) (neear5   357) (neear6   358) (neear7   359)
2488   (neear8   360) (neear9   361) (neear10  362) (neear11  363)
2489   (neear12  364) (neear13  365) (neear14  366) (neear15  367)
2490   (neear16  368) (neear17  369) (neear18  370) (neear19  371)
2491   (neear20  372) (neear21  373) (neear22  374) (neear23  375)
2492   (neear24  376) (neear25  377) (neear26  378) (neear27  379)
2493   (neear28  380) (neear29  381) (neear30  382) (neear31  383)
2494
2495   (nesr0    384) (nesr1    385) (nesr2    386) (nesr3    387)
2496   (nesr4    388) (nesr5    389) (nesr6    390) (nesr7    391)
2497   (nesr8    392) (nesr9    393) (nesr10   394) (nesr11   395)
2498   (nesr12   396) (nesr13   397) (nesr14   398) (nesr15   399)
2499   (nesr16   400) (nesr17   401) (nesr18   402) (nesr19   403)
2500   (nesr20   404) (nesr21   405) (nesr22   406) (nesr23   407)
2501   (nesr24   408) (nesr25   409) (nesr26   410) (nesr27   411)
2502   (nesr28   412) (nesr29   413) (nesr30   414) (nesr31   415)
2503
2504   (necr     416)
2505
2506   (gner0    432) (gner1    433)
2507
2508   (fner0    434) (fner1    435)
2509
2510   (epcr0    512) (epcr1    513) (epcr2    514) (epcr3    515)
2511   (epcr4    516) (epcr5    517) (epcr6    518) (epcr7    519)
2512   (epcr8    520) (epcr9    521) (epcr10   522) (epcr11   523)
2513   (epcr12   524) (epcr13   525) (epcr14   526) (epcr15   527)
2514   (epcr16   528) (epcr17   529) (epcr18   530) (epcr19   531)
2515   (epcr20   532) (epcr21   533) (epcr22   534) (epcr23   535)
2516   (epcr24   536) (epcr25   537) (epcr26   538) (epcr27   539)
2517   (epcr28   540) (epcr29   541) (epcr30   542) (epcr31   543)
2518   (epcr32   544) (epcr33   545) (epcr34   546) (epcr35   547)
2519   (epcr36   548) (epcr37   549) (epcr38   550) (epcr39   551)
2520   (epcr40   552) (epcr41   553) (epcr42   554) (epcr43   555)
2521   (epcr44   556) (epcr45   557) (epcr46   558) (epcr47   559)
2522   (epcr48   560) (epcr49   561) (epcr50   562) (epcr51   563)
2523   (epcr52   564) (epcr53   565) (epcr54   566) (epcr55   567)
2524   (epcr56   568) (epcr57   569) (epcr58   570) (epcr59   571)
2525   (epcr60   572) (epcr61   573) (epcr62   574) (epcr63   575)
2526
2527   (esr0     576) (esr1     577) (esr2     578) (esr3     579)
2528   (esr4     580) (esr5     581) (esr6     582) (esr7     583)
2529   (esr8     584) (esr9     585) (esr10    586) (esr11    587)
2530   (esr12    588) (esr13    589) (esr14    590) (esr15    591)
2531   (esr16    592) (esr17    593) (esr18    594) (esr19    595)
2532   (esr20    596) (esr21    597) (esr22    598) (esr23    599)
2533   (esr24    600) (esr25    601) (esr26    602) (esr27    603)
2534   (esr28    604) (esr29    605) (esr30    606) (esr31    607)
2535   (esr32    608) (esr33    609) (esr34    610) (esr35    611)
2536   (esr36    612) (esr37    613) (esr38    614) (esr39    615)
2537   (esr40    616) (esr41    617) (esr42    618) (esr43    619)
2538   (esr44    620) (esr45    621) (esr46    622) (esr47    623)
2539   (esr48    624) (esr49    625) (esr50    626) (esr51    627)
2540   (esr52    628) (esr53    629) (esr54    630) (esr55    631)
2541   (esr56    632) (esr57    633) (esr58    634) (esr59    635)
2542   (esr60    636) (esr61    637) (esr62    638) (esr63    639)
2543
2544   (eir0     640) (eir1     641) (eir2     642) (eir3     643)
2545   (eir4     644) (eir5     645) (eir6     646) (eir7     647)
2546   (eir8     648) (eir9     649) (eir10    650) (eir11    651)
2547   (eir12    652) (eir13    653) (eir14    654) (eir15    655)
2548   (eir16    656) (eir17    657) (eir18    658) (eir19    659)
2549   (eir20    660) (eir21    661) (eir22    662) (eir23    663)
2550   (eir24    664) (eir25    665) (eir26    666) (eir27    667)
2551   (eir28    668) (eir29    669) (eir30    670) (eir31    671)
2552
2553   (esfr0    672) (esfr1    673)
2554
2555   (sr0      768) (sr1      769) (sr2      770) (sr3      771)
2556
2557   (scr0     832) (scr1     833) (scr2     834) (scr3     835)
2558
2559   (fsr0    1024) (fsr1    1025) (fsr2    1026) (fsr3    1027)
2560   (fsr4    1028) (fsr5    1029) (fsr6    1030) (fsr7    1031)
2561   (fsr8    1032) (fsr9    1033) (fsr10   1034) (fsr11   1035)
2562   (fsr12   1036) (fsr13   1037) (fsr14   1038) (fsr15   1039)
2563   (fsr16   1040) (fsr17   1041) (fsr18   1042) (fsr19   1043)
2564   (fsr20   1044) (fsr21   1045) (fsr22   1046) (fsr23   1047)
2565   (fsr24   1048) (fsr25   1049) (fsr26   1050) (fsr27   1051)
2566   (fsr28   1052) (fsr29   1053) (fsr30   1054) (fsr31   1055)
2567   (fsr32   1056) (fsr33   1057) (fsr34   1058) (fsr35   1059)
2568   (fsr36   1060) (fsr37   1061) (fsr38   1062) (fsr39   1063)
2569   (fsr40   1064) (fsr41   1065) (fsr42   1066) (fsr43   1067)
2570   (fsr44   1068) (fsr45   1069) (fsr46   1070) (fsr47   1071)
2571   (fsr48   1072) (fsr49   1073) (fsr50   1074) (fsr51   1075)
2572   (fsr52   1076) (fsr53   1077) (fsr54   1078) (fsr55   1079)
2573   (fsr56   1080) (fsr57   1081) (fsr58   1082) (fsr59   1083)
2574   (fsr60   1084) (fsr61   1085) (fsr62   1086) (fsr63   1087)
2575
2576   ; FQ0-FQ31 are 64 bit registers.
2577   ; These names allow access to the upper 32 bits of the FQ registers.
2578   (fqop0   1088) (fqop1   1090) (fqop2   1092) (fqop3   1094)
2579   (fqop4   1096) (fqop5   1098) (fqop6   1100) (fqop7   1102)
2580   (fqop8   1104) (fqop9   1106) (fqop10  1108) (fqop11  1110)
2581   (fqop12  1112) (fqop13  1114) (fqop14  1116) (fqop15  1118)
2582   (fqop16  1120) (fqop17  1122) (fqop18  1124) (fqop19  1126)
2583   (fqop20  1128) (fqop21  1130) (fqop22  1132) (fqop23  1134)
2584   (fqop24  1136) (fqop25  1138) (fqop26  1140) (fqop27  1142)
2585   (fqop28  1144) (fqop29  1146) (fqop30  1148) (fqop31  1150)
2586   ; These names allow access to the lower 32 bits of the FQ registers.
2587   (fqst0   1089) (fqst1   1091) (fqst2   1093) (fqst3   1095)
2588   (fqst4   1097) (fqst5   1099) (fqst6   1101) (fqst7   1103)
2589   (fqst8   1105) (fqst9   1107) (fqst10  1109) (fqst11  1111)
2590   (fqst12  1113) (fqst13  1115) (fqst14  1117) (fqst15  1119)
2591   (fqst16  1121) (fqst17  1123) (fqst18  1125) (fqst19  1127)
2592   (fqst20  1129) (fqst21  1131) (fqst22  1133) (fqst23  1135)
2593   (fqst24  1137) (fqst25  1139) (fqst26  1141) (fqst27  1143)
2594   (fqst28  1145) (fqst29  1147) (fqst30  1149) (fqst31  1151)
2595   ; These also access the lower 32 bits of the FQ registers.
2596   ; These are not accessible as spr registers (see LSI appendix - section 13.4)
2597;  (fq0     1089) (fq1     1091) (fq2     1093) (fq3     1095)
2598;  (fq4     1097) (fq5     1099) (fq6     1101) (fq7     1103)
2599;  (fq8     1105) (fq9     1107) (fq10    1109) (fq11    1111)
2600;  (fq12    1113) (fq13    1115) (fq14    1117) (fq15    1119)
2601;  (fq16    1121) (fq17    1123) (fq18    1125) (fq19    1127)
2602;  (fq20    1129) (fq21    1131) (fq22    1133) (fq23    1135)
2603;  (fq24    1137) (fq25    1139) (fq26    1141) (fq27    1143)
2604;  (fq28    1145) (fq29    1147) (fq30    1149) (fq31    1151)
2605
2606   (mcilr0  1272) (mcilr1  1273)
2607
2608   (msr0    1280) (msr1    1281) (msr2    1282) (msr3    1283)
2609   (msr4    1284) (msr5    1285) (msr6    1286) (msr7    1287)
2610   (msr8    1288) (msr9    1289) (msr10   1290) (msr11   1291)
2611   (msr12   1292) (msr13   1293) (msr14   1294) (msr15   1295)
2612   (msr16   1296) (msr17   1297) (msr18   1298) (msr19   1299)
2613   (msr20   1300) (msr21   1301) (msr22   1302) (msr23   1303)
2614   (msr24   1304) (msr25   1305) (msr26   1306) (msr27   1307)
2615   (msr28   1308) (msr29   1309) (msr30   1310) (msr31   1311)
2616   (msr32   1312) (msr33   1313) (msr34   1314) (msr35   1315)
2617   (msr36   1316) (msr37   1317) (msr38   1318) (msr39   1319)
2618   (msr40   1320) (msr41   1321) (msr42   1322) (msr43   1323)
2619   (msr44   1324) (msr45   1325) (msr46   1326) (msr47   1327)
2620   (msr48   1328) (msr49   1329) (msr50   1330) (msr51   1331)
2621   (msr52   1332) (msr53   1333) (msr54   1334) (msr55   1335)
2622   (msr56   1336) (msr57   1337) (msr58   1338) (msr59   1339)
2623   (msr60   1340) (msr61   1341) (msr62   1342) (msr63   1343)
2624
2625   ; MQ0-MQ31 are 64 bit registers.
2626   ; These names allow access to the upper 32 bits of the MQ registers.
2627   (mqop0   1344) (mqop1   1346) (mqop2   1348) (mqop3   1350)
2628   (mqop4   1352) (mqop5   1354) (mqop6   1356) (mqop7   1358)
2629   (mqop8   1360) (mqop9   1362) (mqop10  1364) (mqop11  1366)
2630   (mqop12  1368) (mqop13  1370) (mqop14  1372) (mqop15  1374)
2631   (mqop16  1376) (mqop17  1378) (mqop18  1380) (mqop19  1382)
2632   (mqop20  1384) (mqop21  1386) (mqop22  1388) (mqop23  1390)
2633   (mqop24  1392) (mqop25  1394) (mqop26  1396) (mqop27  1398)
2634   (mqop28  1400) (mqop29  1402) (mqop30  1404) (mqop31  1406)
2635   ; These names allow access to the lower 32 bits of the MQ registers.
2636   (mqst0   1345) (mqst1   1347) (mqst2   1349) (mqst3   1351)
2637   (mqst4   1353) (mqst5   1355) (mqst6   1357) (mqst7   1359)
2638   (mqst8   1361) (mqst9   1363) (mqst10  1365) (mqst11  1367)
2639   (mqst12  1369) (mqst13  1371) (mqst14  1373) (mqst15  1375)
2640   (mqst16  1377) (mqst17  1379) (mqst18  1381) (mqst19  1383)
2641   (mqst20  1385) (mqst21  1387) (mqst22  1389) (mqst23  1391)
2642   (mqst24  1393) (mqst25  1395) (mqst26  1397) (mqst27  1399)
2643   (mqst28  1401) (mqst29  1403) (mqst30  1405) (mqst31  1407)
2644   ; These also access the lower 32 bits of the MQ registers.
2645   ; These are not accessible as spr registers (see LSI appendix - section 13.4)
2646;  (mq0     1345) (mq1     1347) (mq2     1349) (mq3     1351)
2647;  (mq4     1353) (mq5     1355) (mq6     1357) (mq7     1359)
2648;  (mq8     1361) (mq9     1363) (mq10    1365) (mq11    1367)
2649;  (mq12    1369) (mq13    1371) (mq14    1373) (mq15    1375)
2650;  (mq16    1377) (mq17    1379) (mq18    1381) (mq19    1383)
2651;  (mq20    1385) (mq21    1387) (mq22    1389) (mq23    1391)
2652;  (mq24    1393) (mq25    1395) (mq26    1397) (mq27    1399)
2653;  (mq28    1401) (mq29    1403) (mq30    1405) (mq31    1407)
2654
2655   ; These are not accessible as spr registers (see LSI appendix - section 13.4)
2656;  (acc0    1408) (acc1    1409) (acc2    1410) (acc3    1411)
2657;  (acc4    1412) (acc5    1413) (acc6    1414) (acc7    1415)
2658;  (acc8    1416) (acc9    1417) (acc10   1418) (acc11   1419)
2659;  (acc12   1420) (acc13   1421) (acc14   1422) (acc15   1423)
2660;  (acc16   1424) (acc17   1425) (acc18   1426) (acc19   1427)
2661;  (acc20   1428) (acc21   1429) (acc22   1430) (acc23   1431)
2662;  (acc24   1432) (acc25   1433) (acc26   1434) (acc27   1435)
2663;  (acc28   1436) (acc29   1437) (acc30   1438) (acc31   1439)
2664;  (acc32   1440) (acc33   1441) (acc34   1442) (acc35   1443)
2665;  (acc36   1444) (acc37   1445) (acc38   1446) (acc39   1447)
2666;  (acc40   1448) (acc41   1449) (acc42   1450) (acc43   1451)
2667;  (acc44   1452) (acc45   1453) (acc46   1454) (acc47   1455)
2668;  (acc48   1456) (acc49   1457) (acc50   1458) (acc51   1459)
2669;  (acc52   1460) (acc53   1461) (acc54   1462) (acc55   1463)
2670;  (acc56   1464) (acc57   1465) (acc58   1466) (acc59   1467)
2671;  (acc60   1468) (acc61   1469) (acc62   1470) (acc63   1471)
2672
2673;  (accg0   1472) (accg1   1473) (accg2   1474) (accg3   1475)
2674;  (accg4   1476) (accg5   1477) (accg6   1478) (accg7   1479)
2675;  (accg8   1480) (accg9   1481) (accg10  1482) (accg11  1483)
2676;  (accg12  1484) (accg13  1485) (accg14  1486) (accg15  1487)
2677;  (accg16  1488) (accg17  1489) (accg18  1490) (accg19  1491)
2678;  (accg20  1492) (accg21  1493) (accg22  1494) (accg23  1495)
2679;  (accg24  1496) (accg25  1497) (accg26  1498) (accg27  1499)
2680;  (accg28  1500) (accg29  1501) (accg30  1502) (accg31  1503)
2681;  (accg32  1504) (accg33  1505) (accg34  1506) (accg35  1507)
2682;  (accg36  1508) (accg37  1509) (accg38  1510) (accg39  1511)
2683;  (accg40  1512) (accg41  1513) (accg42  1514) (accg43  1515)
2684;  (accg44  1516) (accg45  1517) (accg46  1518) (accg47  1519)
2685;  (accg48  1520) (accg49  1521) (accg50  1522) (accg51  1523)
2686;  (accg52  1524) (accg53  1525) (accg54  1526) (accg55  1527)
2687;  (accg56  1528) (accg57  1529) (accg58  1530) (accg59  1531)
2688;  (accg60  1532) (accg61  1533) (accg62  1534) (accg63  1535)
2689
2690   (ear0    1536) (ear1    1537) (ear2    1538) (ear3    1539)
2691   (ear4    1540) (ear5    1541) (ear6    1542) (ear7    1543)
2692   (ear8    1544) (ear9    1545) (ear10   1546) (ear11   1547)
2693   (ear12   1548) (ear13   1549) (ear14   1550) (ear15   1551)
2694   (ear16   1552) (ear17   1553) (ear18   1554) (ear19   1555)
2695   (ear20   1556) (ear21   1557) (ear22   1558) (ear23   1559)
2696   (ear24   1560) (ear25   1561) (ear26   1562) (ear27   1563)
2697   (ear28   1564) (ear29   1565) (ear30   1566) (ear31   1567)
2698   (ear32   1568) (ear33   1569) (ear34   1570) (ear35   1571)
2699   (ear36   1572) (ear37   1573) (ear38   1574) (ear39   1575)
2700   (ear40   1576) (ear41   1577) (ear42   1578) (ear43   1579)
2701   (ear44   1580) (ear45   1581) (ear46   1582) (ear47   1583)
2702   (ear48   1584) (ear49   1585) (ear50   1586) (ear51   1587)
2703   (ear52   1588) (ear53   1589) (ear54   1590) (ear55   1591)
2704   (ear56   1592) (ear57   1593) (ear58   1594) (ear59   1595)
2705   (ear60   1596) (ear61   1597) (ear62   1598) (ear63   1599)
2706
2707   (edr0    1600) (edr1    1601) (edr2    1602) (edr3    1603)
2708   (edr4    1604) (edr5    1605) (edr6    1606) (edr7    1607)
2709   (edr8    1608) (edr9    1609) (edr10   1610) (edr11   1611)
2710   (edr12   1612) (edr13   1613) (edr14   1614) (edr15   1615)
2711   (edr16   1616) (edr17   1617) (edr18   1618) (edr19   1619)
2712   (edr20   1620) (edr21   1621) (edr22   1622) (edr23   1623)
2713   (edr24   1624) (edr25   1625) (edr26   1626) (edr27   1627)
2714   (edr28   1628) (edr29   1629) (edr30   1630) (edr31   1631)
2715   (edr32   1632) (edr33   1636) (edr34   1634) (edr35   1635)
2716   (edr36   1636) (edr37   1637) (edr38   1638) (edr39   1639)
2717   (edr40   1640) (edr41   1641) (edr42   1642) (edr43   1643)
2718   (edr44   1644) (edr45   1645) (edr46   1646) (edr47   1647)
2719   (edr48   1648) (edr49   1649) (edr50   1650) (edr51   1651)
2720   (edr52   1652) (edr53   1653) (edr54   1654) (edr55   1655)
2721   (edr56   1656) (edr57   1657) (edr58   1658) (edr59   1659)
2722   (edr60   1660) (edr61   1661) (edr62   1662) (edr63   1663)
2723
2724   (iamlr0  1664) (iamlr1  1665) (iamlr2  1666) (iamlr3  1667)
2725   (iamlr4  1668) (iamlr5  1669) (iamlr6  1670) (iamlr7  1671)
2726   (iamlr8  1672) (iamlr9  1673) (iamlr10 1674) (iamlr11 1675)
2727   (iamlr12 1676) (iamlr13 1677) (iamlr14 1678) (iamlr15 1679)
2728   (iamlr16 1680) (iamlr17 1681) (iamlr18 1682) (iamlr19 1683)
2729   (iamlr20 1684) (iamlr21 1685) (iamlr22 1686) (iamlr23 1687)
2730   (iamlr24 1688) (iamlr25 1689) (iamlr26 1690) (iamlr27 1691)
2731   (iamlr28 1692) (iamlr29 1693) (iamlr30 1694) (iamlr31 1695)
2732   (iamlr32 1696) (iamlr33 1697) (iamlr34 1698) (iamlr35 1699)
2733   (iamlr36 1700) (iamlr37 1701) (iamlr38 1702) (iamlr39 1703)
2734   (iamlr40 1704) (iamlr41 1705) (iamlr42 1706) (iamlr43 1707)
2735   (iamlr44 1708) (iamlr45 1709) (iamlr46 1710) (iamlr47 1711)
2736   (iamlr48 1712) (iamlr49 1713) (iamlr50 1714) (iamlr51 1715)
2737   (iamlr52 1716) (iamlr53 1717) (iamlr54 1718) (iamlr55 1719)
2738   (iamlr56 1720) (iamlr57 1721) (iamlr58 1722) (iamlr59 1723)
2739   (iamlr60 1724) (iamlr61 1725) (iamlr62 1726) (iamlr63 1727)
2740
2741   (iampr0  1728) (iampr1  1729) (iampr2  1730) (iampr3  1731)
2742   (iampr4  1732) (iampr5  1733) (iampr6  1734) (iampr7  1735)
2743   (iampr8  1736) (iampr9  1737) (iampr10 1738) (iampr11 1739)
2744   (iampr12 1740) (iampr13 1741) (iampr14 1742) (iampr15 1743)
2745   (iampr16 1744) (iampr17 1745) (iampr18 1746) (iampr19 1747)
2746   (iampr20 1748) (iampr21 1749) (iampr22 1750) (iampr23 1751)
2747   (iampr24 1752) (iampr25 1753) (iampr26 1754) (iampr27 1755)
2748   (iampr28 1756) (iampr29 1757) (iampr30 1758) (iampr31 1759)
2749   (iampr32 1760) (iampr33 1761) (iampr34 1762) (iampr35 1763)
2750   (iampr36 1764) (iampr37 1765) (iampr38 1766) (iampr39 1767)
2751   (iampr40 1768) (iampr41 1769) (iampr42 1770) (iampr43 1771)
2752   (iampr44 1772) (iampr45 1773) (iampr46 1774) (iampr47 1775)
2753   (iampr48 1776) (iampr49 1777) (iampr50 1778) (iampr51 1779)
2754   (iampr52 1780) (iampr53 1781) (iampr54 1782) (iampr55 1783)
2755   (iampr56 1784) (iampr57 1785) (iampr58 1786) (iampr59 1787)
2756   (iampr60 1788) (iampr61 1789) (iampr62 1790) (iampr63 1791)
2757
2758   (damlr0  1792) (damlr1  1793) (damlr2  1794) (damlr3  1795)
2759   (damlr4  1796) (damlr5  1797) (damlr6  1798) (damlr7  1799)
2760   (damlr8  1800) (damlr9  1801) (damlr10 1802) (damlr11 1803)
2761   (damlr12 1804) (damlr13 1805) (damlr14 1806) (damlr15 1807)
2762   (damlr16 1808) (damlr17 1809) (damlr18 1810) (damlr19 1811)
2763   (damlr20 1812) (damlr21 1813) (damlr22 1814) (damlr23 1815)
2764   (damlr24 1816) (damlr25 1817) (damlr26 1818) (damlr27 1819)
2765   (damlr28 1820) (damlr29 1821) (damlr30 1822) (damlr31 1823)
2766   (damlr32 1824) (damlr33 1825) (damlr34 1826) (damlr35 1827)
2767   (damlr36 1828) (damlr37 1829) (damlr38 1830) (damlr39 1831)
2768   (damlr40 1832) (damlr41 1833) (damlr42 1834) (damlr43 1835)
2769   (damlr44 1836) (damlr45 1837) (damlr46 1838) (damlr47 1839)
2770   (damlr48 1840) (damlr49 1841) (damlr50 1842) (damlr51 1843)
2771   (damlr52 1844) (damlr53 1845) (damlr54 1846) (damlr55 1847)
2772   (damlr56 1848) (damlr57 1849) (damlr58 1850) (damlr59 1851)
2773   (damlr60 1852) (damlr61 1853) (damlr62 1854) (damlr63 1855)
2774
2775   (dampr0  1856) (dampr1  1857) (dampr2  1858) (dampr3  1859)
2776   (dampr4  1860) (dampr5  1861) (dampr6  1862) (dampr7  1863)
2777   (dampr8  1864) (dampr9  1865) (dampr10 1866) (dampr11 1867)
2778   (dampr12 1868) (dampr13 1869) (dampr14 1870) (dampr15 1871)
2779   (dampr16 1872) (dampr17 1873) (dampr18 1874) (dampr19 1875)
2780   (dampr20 1876) (dampr21 1877) (dampr22 1878) (dampr23 1879)
2781   (dampr24 1880) (dampr25 1881) (dampr26 1882) (dampr27 1883)
2782   (dampr28 1884) (dampr29 1885) (dampr30 1886) (dampr31 1887)
2783   (dampr32 1888) (dampr33 1889) (dampr34 1890) (dampr35 1891)
2784   (dampr36 1892) (dampr37 1893) (dampr38 1894) (dampr39 1895)
2785   (dampr40 1896) (dampr41 1897) (dampr42 1898) (dampr43 1899)
2786   (dampr44 1900) (dampr45 1901) (dampr46 1902) (dampr47 1903)
2787   (dampr48 1904) (dampr49 1905) (dampr50 1906) (dampr51 1907)
2788   (dampr52 1908) (dampr53 1909) (dampr54 1910) (dampr55 1911)
2789   (dampr56 1912) (dampr57 1913) (dampr58 1914) (dampr59 1915)
2790   (dampr60 1916) (dampr61 1917) (dampr62 1918) (dampr63 1919)
2791
2792   (amcr    1920) (stbar   1921) (mmcr    1922)
2793   (iamvr1  1925) (damvr1  1927)
2794   (cxnr    1936) (ttbr    1937) (tplr    1938) (tppr    1939)
2795   (tpxr    1940)
2796   (timerh  1952) (timerl  1953) (timerd  1954)
2797   (dcr     2048) (brr     2049) (nmar    2050) (btbr    2051)
2798
2799   (ibar0   2052) (ibar1   2053) (ibar2   2054) (ibar3   2055)
2800   (dbar0   2056) (dbar1   2057) (dbar2   2058) (dbar3   2059)
2801
2802   (dbdr00  2060) (dbdr01  2061) (dbdr02  2062) (dbdr03  2063)
2803   (dbdr10  2064) (dbdr11  2065) (dbdr12  2066) (dbdr13  2067)
2804   (dbdr20  2068) (dbdr21  2069) (dbdr22  2070) (dbdr23  2071)
2805   (dbdr30  2072) (dbdr31  2073) (dbdr32  2074) (dbdr33  2075)
2806
2807   (dbmr00  2076) (dbmr01  2077) (dbmr02  2078) (dbmr03  2079)
2808   (dbmr10  2080) (dbmr11  2081) (dbmr12  2082) (dbmr13  2083)
2809   (dbmr20  2084) (dbmr21  2085) (dbmr22  2086) (dbmr23  2087)
2810   (dbmr30  2088) (dbmr31  2089) (dbmr32  2090) (dbmr33  2091)
2811
2812   (cpcfr   2304) (cpcr    2305) (cpsr    2306) (cptr    2307)
2813   (cphsr0  2308) (cphsr1  2309) (cpesr0  2320) (cpesr1  2321)
2814   (cpemr0  2322) (cpemr1  2323)
2815
2816   (iperr0  2324) (iperr1  2325) (ipjsr   2326) (ipjrr   2327)
2817   (ipcsr0  2336) (ipcsr1  2337) (ipcwer0 2338) (ipcwer1 2339)
2818   (ipcwr   2340)
2819
2820   (mbhsr   2352) (mbssr   2353) (mbrsr   2354) (mbsdr   2355)
2821   (mbrdr   2356) (mbsmr   2357) (mbstr0  2359) (mbstr1  2360)
2822
2823   (slpr    2368) (sldr    2369) (slhsr   2370) (sltr    2371)
2824   (slwr    2372)
2825
2826   (ihsr8   3848) (ihsr9   3849) (ihsr10  3850)
2827  )
2828)
2829
2830(define-hardware
2831  (name h-spr)
2832  (comment "special purpose registers")
2833  (attrs PROFILE)
2834  (type register UWI (4096))
2835  (indices extern-keyword spr-names)
2836  (get (index) (c-call UWI "@cpu@_h_spr_get_handler" index))
2837  (set (index newval) (c-call VOID "@cpu@_h_spr_set_handler" index newval))
2838)
2839
2840(define-pmacro (spr-pcsr)  (reg h-spr   1))
2841(define-pmacro (spr-bpcsr) (reg h-spr   2))
2842(define-pmacro (spr-lr)    (reg h-spr 272))
2843(define-pmacro (spr-lcr)   (reg h-spr 273))
2844(define-pmacro (spr-iacc0h) (reg h-spr 280))
2845(define-pmacro (spr-iacc0l) (reg h-spr 281))
2846(define-pmacro (spr-sr0)   (reg h-spr 768))
2847(define-pmacro (spr-sr1)   (reg h-spr 769))
2848(define-pmacro (spr-sr2)   (reg h-spr 770))
2849(define-pmacro (spr-sr3)   (reg h-spr 771))
2850
2851; Accumulator guard. Actually a subset of the SPR registers, but those SPRs
2852; are read-only in most insns. This hardware element is used by those insns
2853; which have direct access (mwtaccg, mrdaccg).
2854(define-keyword
2855  (name accg-names)
2856  (print-name h-accg)
2857  (prefix "")
2858  (values
2859   (accg0   0)(accg1   1)(accg2   2)(accg3   3)
2860   (accg4   4)(accg5   5)(accg6   6)(accg7   7)
2861   (accg8   8)(accg9   9)(accg10 10)(accg11 11)
2862   (accg12 12)(accg13 13)(accg14 14)(accg15 15)
2863   (accg16 16)(accg17 17)(accg18 18)(accg19 19)
2864   (accg20 20)(accg21 21)(accg22 22)(accg23 23)
2865   (accg24 24)(accg25 25)(accg26 26)(accg27 27)
2866   (accg28 28)(accg29 29)(accg30 30)(accg31 31)
2867   (accg32 32)(accg33 33)(accg34 34)(accg35 35)
2868   (accg36 36)(accg37 37)(accg38 38)(accg39 39)
2869   (accg40 40)(accg41 41)(accg42 42)(accg43 43)
2870   (accg44 44)(accg45 45)(accg46 46)(accg47 47)
2871   (accg48 48)(accg49 49)(accg50 50)(accg51 51)
2872   (accg52 52)(accg53 53)(accg54 54)(accg55 55)
2873   (accg56 56)(accg57 57)(accg58 58)(accg59 59)
2874   (accg60 60)(accg61 61)(accg62 62)(accg63 63)
2875  )
2876)
2877
2878(define-hardware
2879  (name h-accg)
2880  (comment "accumulator guard")
2881  (attrs PROFILE VIRTUAL)
2882  (type register UWI (64))
2883  (indices extern-keyword accg-names)
2884  (get (index)
2885       (and (reg h-spr (add index 1472)) #xff))
2886  (set (index newval)
2887       (set (raw-reg UWI h-spr (add index 1472)) (and newval #xff)))
2888)
2889
2890; 40 bit accumulator. Composed of ACCG and ACC registers concatenated, but
2891; referenced more often as the composed 40 bits.
2892(define-keyword
2893  (name acc-names)
2894  (print-name h-acc40)
2895  (prefix "")
2896  (values
2897(acc0   0)(acc1   1)(acc2   2)(acc3   3)(acc4   4)(acc5   5)(acc6   6)(acc7   7)
2898(acc8   8)(acc9   9)(acc10 10)(acc11 11)(acc12 12)(acc13 13)(acc14 14)(acc15 15)
2899(acc16 16)(acc17 17)(acc18 18)(acc19 19)(acc20 20)(acc21 21)(acc22 22)(acc23 23)
2900(acc24 24)(acc25 25)(acc26 26)(acc27 27)(acc28 28)(acc29 29)(acc30 30)(acc31 31)
2901(acc32 32)(acc33 33)(acc34 34)(acc35 35)(acc36 36)(acc37 37)(acc38 38)(acc39 39)
2902(acc40 40)(acc41 41)(acc42 42)(acc43 43)(acc44 44)(acc45 45)(acc46 46)(acc47 47)
2903(acc48 48)(acc49 49)(acc50 50)(acc51 51)(acc52 52)(acc53 53)(acc54 54)(acc55 55)
2904(acc56 56)(acc57 57)(acc58 58)(acc59 59)(acc60 60)(acc61 61)(acc62 62)(acc63 63)
2905  )
2906)
2907
2908(define-hardware
2909  (name h-acc40S)
2910  (comment "40 bit signed accumulator")
2911  (attrs PROFILE VIRTUAL)
2912  (type register DI (64))
2913  (indices extern-keyword acc-names)
2914  ; The accumlator is made up of two 32 bit registers, accgi/acci.
2915  ; We want to extract this as a combined 40 signed bits
2916  (get (index)
2917       (or DI
2918	   (sll  DI (ext DI (trunc QI (reg h-spr (add index 1472))))
2919		 32)
2920	   (zext DI (reg h-spr (add index 1408)))))
2921  ; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
2922  ; on ACC and ACCG registers
2923  (set (index newval)
2924       (sequence ()
2925		 (c-call VOID "frv_check_spr_write_access" (add index 1408))
2926		 (set (raw-reg UWI h-spr
2927			       (add index 1472)) (and (srl newval 32) #xff))
2928		 (set (raw-reg UWI h-spr
2929			       (add index 1408)) (trunc USI newval))))
2930)
2931
2932(define-hardware
2933  (name h-acc40U)
2934  (comment "40 bit unsigned accumulator")
2935  (attrs PROFILE VIRTUAL)
2936  (type register UDI (64))
2937  (indices extern-keyword acc-names)
2938  ; The accumlator is made up of two 32 bit registers, accgi/acci.
2939  ; We want to extract this as a combined 40 unsigned bits
2940  (get (index)
2941       (or DI
2942	   (sll  DI (zext DI (reg h-spr (add index 1472))) 32)
2943	   (zext DI (reg h-spr (add index 1408)))))
2944  ; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
2945  ; on ACC and ACCG registers
2946  (set (index newval)
2947       (sequence ()
2948		 (c-call VOID "frv_check_spr_write_access" (add index 1408))
2949		 (set (raw-reg UWI h-spr
2950			       (add index 1472)) (and (srl newval 32) #xff))
2951		 (set (raw-reg UWI h-spr
2952			       (add index 1408)) (trunc USI newval))))
2953)
2954; 64-bit signed accumulator.  Composed of iacc0h and iacc0l registers
2955; concatenated, but referenced more often as the composed 64 bits.
2956(define-keyword
2957  ; This is totally hokey -- I have to have an index!
2958  (name iacc0-names)
2959  (print-name h-iacc0)
2960  (prefix "")
2961  (values (iacc0 0))
2962)
2963
2964(define-hardware
2965  (name h-iacc0)
2966  (comment "64 bit signed accumulator")
2967  (attrs PROFILE VIRTUAL (MACH fr400,fr450))
2968  (type register DI (1))
2969  (indices extern-keyword iacc0-names)
2970  ; The single 64-bit integer accumulator is made up of two 32 bit
2971  ; registers, iacc0h and iacc0l.  We want to extract this as a
2972  ; combined 64 signed bits.
2973  (get (idx) (or DI (sll DI (ext DI (spr-iacc0h)) 32) (zext DI (spr-iacc0l))))
2974  (set (idx newval)
2975       (sequence ()
2976		 (set (spr-iacc0h) (trunc SI (srl newval 32)))
2977		 (set (spr-iacc0l) (trunc SI newval))))
2978)
2979
2980; Integer condition code registers (CCR)
2981;
2982; The individual sub registers bits of the CCR are referenced more often than
2983; the entire register so set them directly. We can assemble the
2984; entire register when necessary.
2985;
2986(define-keyword
2987  (name iccr-names)
2988  (print-name h-iccr)
2989  (prefix "")
2990  (values (icc0 0) (icc1 1) (icc2 2) (icc3 3))
2991)
2992
2993(define-hardware
2994  (name h-iccr)
2995  (comment "Integer condition code registers")
2996  (attrs PROFILE)
2997  (type register UQI (4))
2998  (indices extern-keyword iccr-names)
2999)
3000
3001; Floating point condition code registers (CCR)
3002;
3003; The individual sub registers bits of the CCR are referenced more often than
3004; the entire register so set them directly. We can assemble the
3005; entire register when necessary.
3006;
3007(define-keyword
3008  (name fccr-names)
3009  (print-name h-fccr)
3010  (prefix "")
3011  (values (fcc0 0) (fcc1 1) (fcc2 2) (fcc3 3))
3012)
3013
3014(define-hardware
3015  (name h-fccr)
3016  (comment "Floating point condition code registers")
3017  (attrs PROFILE)
3018  (type register UQI (4))
3019  (indices extern-keyword fccr-names)
3020)
3021
3022; C condition code registers (CCCR)
3023;
3024(define-keyword
3025  (name cccr-names)
3026  (print-name h-cccr)
3027  (prefix "")
3028  (values (cc0 0) (cc1 1) (cc2 2) (cc3 3) (cc4 4) (cc5 5) (cc6 6) (cc7 7))
3029)
3030
3031(define-hardware
3032  (name h-cccr)
3033  (comment "Condition code registers")
3034  (attrs PROFILE)
3035  (type register UQI (8))
3036  (indices extern-keyword cccr-names)
3037)
3038
3039; Dummy hardware used to define packing bit on insns
3040;
3041(define-hardware
3042  (name h-pack)
3043  (comment "Packing bit dummy hardware")
3044  (type immediate (UINT 1))
3045  (values keyword "" (("" 1) (".p" 0) (".P" 0)))
3046)
3047; Dummy hardware used to define hint field for branches always taken
3048;
3049(define-hardware
3050  (name h-hint-taken)
3051  (comment "Branch taken hint dummy hardware")
3052  (type immediate (UINT 1))
3053  ; The order of these is important. We want '2' to get written by default,
3054  ; but we also want the docoder/disassembler to allow the values '0', '1' and
3055  ; '3'.
3056  (values keyword "" (("" 2) ("" 0) ("" 1) ("" 3)))
3057)
3058; Dummy hardware used to define hint field for branches never taken
3059;
3060(define-hardware
3061  (name h-hint-not-taken)
3062  (comment "Branch not taken hint dummy hardware")
3063  (type immediate (UINT 1))
3064  ; The order of these is important. We want '0' to get written by default,
3065  ; but we also want the docoder/disassembler to allow the values '1', '2' and
3066  ; '3'.
3067  (values keyword "" (("" 0) ("" 1) ("" 2) ("" 3)))
3068)
3069
3070; Instruction Operands.
3071; These entries provide a layer between the assembler and the raw hardware
3072; description, and are used to refer to hardware elements in the semantic
3073; code.  Usually there's a bit of over-specification, but in more complicated
3074; instruction sets there isn't.
3075
3076; FRV specific operand attributes:
3077
3078(define-attr
3079  (for operand)
3080  (type boolean)
3081  (name HASH-PREFIX)
3082  (comment "immediates have an optional '#' prefix")
3083)
3084
3085; ??? Convention says this should be o-sr, but then the insn definitions
3086; should refer to o-sr which is clumsy.  The "o-" could be implicit, but
3087; then it should be implicit for all the symbols here, but then there would
3088; be confusion between (f-)simm8 and (h-)simm8.
3089; So for now the rule is exactly as it appears here.
3090
3091; dnmop: define-normal-mode-operand: temporary, pending potential removal
3092; of modes from h/w.
3093(define-pmacro (dnmop xname xcomment xattrs xtype xindex xmode)
3094  (define-operand
3095    (name xname)
3096    (comment xcomment)
3097    (.splice attrs (.unsplice xattrs))
3098    (type xtype)
3099    (index xindex)
3100    (mode xmode)
3101    )
3102)
3103
3104; dnpmop: define-normal-parsed-mode-operand: Normal mode operand with parse handler
3105(define-pmacro (dnpmop xname xcomment xattrs xtype xindex xmode xparse)
3106  (define-operand
3107    (name xname)
3108    (comment xcomment)
3109    (.splice attrs (.unsplice xattrs))
3110    (type xtype)
3111    (index xindex)
3112    (mode xmode)
3113    (handlers (parse xparse))
3114    )
3115)
3116
3117(dnop  pack "packing bit" () h-pack f-pack)
3118
3119(dnmop GRi        "source register 1"      () h-gr        f-GRi  SI)
3120(dnmop GRj        "source register 2"      () h-gr        f-GRj  SI)
3121(dnmop GRk        "destination register"   () h-gr        f-GRk  SI)
3122(dnmop GRkhi      "destination register"   () h-gr_hi     f-GRk  UHI)
3123(dnmop GRklo      "destination register"   () h-gr_lo     f-GRk  UHI)
3124(dnpmop GRdoublek "destination register"   () h-gr_double f-GRk  DI "even_register")
3125(dnmop ACC40Si    "signed accumulator"     () h-acc40S    f-ACC40Si DI)
3126(dnmop ACC40Ui    "unsigned accumulator"   () h-acc40U    f-ACC40Ui UDI)
3127(dnmop ACC40Sk    "target accumulator"     () h-acc40S    f-ACC40Sk DI)
3128(dnmop ACC40Uk    "target accumulator"     () h-acc40U    f-ACC40Uk UDI)
3129(dnmop ACCGi      "source register"        () h-accg      f-ACCGi   UWI)
3130(dnmop ACCGk      "target register"        () h-accg      f-ACCGk   UWI)
3131
3132(dnmop CPRi       "source register"        ((MACH frv)) h-cpr        f-CPRi SI)
3133(dnmop CPRj       "source register"        ((MACH frv)) h-cpr        f-CPRj SI)
3134(dnmop CPRk       "destination register"   ((MACH frv)) h-cpr        f-CPRk SI)
3135(dnpmop CPRdoublek "destination register"  ((MACH frv)) h-cpr_double f-CPRk DI "even_register")
3136
3137; floating point operands
3138(dnmop FRinti    "source register 1"      () h-fr_int    f-FRi SI)
3139(dnmop FRintj    "source register 2"      () h-fr_int    f-FRj SI)
3140(dnmop FRintk    "target register"        () h-fr_int    f-FRk SI)
3141(dnmop FRi       "source register 1"      () h-fr        f-FRi SF)
3142(dnmop FRj       "source register 2"      () h-fr        f-FRj SF)
3143(dnmop FRk       "destination register"   () h-fr        f-FRk SF)
3144(dnmop FRkhi     "destination register"   () h-fr_hi     f-FRk UHI)
3145(dnmop FRklo     "destination register"   () h-fr_lo     f-FRk UHI)
3146(dnpmop FRdoublei "source register 1"     () h-fr_double f-FRi DF "even_register")
3147(dnpmop FRdoublej "source register 2"     () h-fr_double f-FRj DF "even_register")
3148(dnpmop FRdoublek "target register"       () h-fr_double f-FRk DF "even_register")
3149
3150(dnop CRi       "source register 1"       () h-cccr f-CRi)
3151(dnop CRj       "source register 2"       () h-cccr f-CRj)
3152(dnop CRj_int   "destination register"    () h-cccr f-CRj_int)
3153(dnop CRj_float "destination register"    () h-cccr f-CRj_float)
3154(dnop CRk       "destination register"    () h-cccr f-CRk)
3155(dnop CCi       "condition   register"    () h-cccr f-CCi)
3156
3157(dnop ICCi_1  "condition   register"      () h-iccr f-ICCi_1)
3158(dnop ICCi_2  "condition   register"      () h-iccr f-ICCi_2)
3159(dnop ICCi_3  "condition   register"      () h-iccr f-ICCi_3)
3160(dnop FCCi_1  "condition   register"      () h-fccr f-FCCi_1)
3161(dnop FCCi_2  "condition   register"      () h-fccr f-FCCi_2)
3162(dnop FCCi_3  "condition   register"      () h-fccr f-FCCi_3)
3163(dnop FCCk    "condition   register"      () h-fccr f-FCCk)
3164
3165(dnop eir     "exception insn reg"        () h-uint f-eir)
3166(dnop s10     "10 bit signed immediate"   (HASH-PREFIX) h-sint f-s10)
3167(dnop u16     "16 bit unsigned immediate" (HASH-PREFIX) h-uint f-u16)
3168(dnop s16     "16 bit signed   immediate" (HASH-PREFIX) h-sint f-s16)
3169(dnop s6      "6  bit signed   immediate" (HASH-PREFIX) h-sint f-s6)
3170(dnop s6_1    "6  bit signed   immediate" (HASH-PREFIX) h-sint f-s6_1)
3171(dnop u6      "6  bit unsigned immediate" (HASH-PREFIX) h-uint f-u6)
3172(dnop s5      "5  bit signed   immediate" (HASH-PREFIX) h-sint f-s5)
3173(dnop cond    "conditional arithmetic"    (HASH-PREFIX) h-uint f-cond)
3174(dnop ccond   "lr branch condition"       (HASH-PREFIX) h-uint f-ccond)
3175(dnop hint    "2 bit branch predictor"    (HASH-PREFIX) h-uint f-hint)
3176(dnop hint_taken "2 bit branch predictor"     () h-hint-taken     f-hint)
3177(dnop hint_not_taken "2 bit branch predictor" () h-hint-not-taken f-hint)
3178
3179(dnop LI      "link indicator"            () h-uint f-LI)
3180(dnop lock    "cache lock indicator"      (HASH-PREFIX) h-uint f-lock)
3181(dnop debug   "debug mode indicator"      (HASH-PREFIX) h-uint f-debug)
3182(dnop ae      "all entries indicator"     (HASH-PREFIX) h-uint f-ae)
3183
3184(dnop label16  "18 bit pc relative address" () h-iaddr f-label16)
3185
3186(dnop LRAE "Load Real Address E flag" () h-uint f-LRAE)
3187(dnop LRAD "Load Real Address D flag" () h-uint f-LRAD)
3188(dnop LRAS "Load Real Address S flag" () h-uint f-LRAS)
3189
3190(dnop TLBPRopx "TLB Probe operation number" () h-uint f-TLBPRopx)
3191(dnop TLBPRL   "TLB Probe L flag"           () h-uint f-TLBPRL)
3192
3193(define-operand
3194  (name A0)
3195  (comment "A==0 operand of mclracc")
3196  (attrs)
3197  (type h-uint)
3198  (index f-A)
3199  (mode USI)
3200  (handlers (parse "A0"))
3201)
3202
3203(define-operand
3204  (name A1)
3205  (comment "A==1 operand of mclracc")
3206  (attrs)
3207  (type h-uint)
3208  (index f-A)
3209  (mode USI)
3210  (handlers (parse "A1"))
3211)
3212
3213(define-operand
3214  (name FRintieven)
3215  (comment "(even) source register 1")
3216  (attrs)
3217  (type h-fr_int)
3218  (index f-FRi)
3219  (mode SI)
3220  (handlers (parse "even_register"))
3221)
3222
3223(define-operand
3224  (name FRintjeven)
3225  (comment "(even) source register 2")
3226  (attrs)
3227  (type h-fr_int)
3228  (index f-FRj)
3229  (mode SI)
3230  (handlers (parse "even_register"))
3231)
3232
3233(define-operand
3234  (name FRintkeven)
3235  (comment "(even) target register")
3236  (attrs)
3237  (type h-fr_int)
3238  (index f-FRk)
3239  (mode SI)
3240  (handlers (parse "even_register"))
3241)
3242
3243(define-operand
3244  (name d12)
3245  (comment "12 bit signed immediate")
3246  (attrs)
3247  (type h-sint)
3248  (index f-d12)
3249  (handlers (parse "d12"))
3250)
3251
3252(define-operand
3253  (name s12)
3254  (comment "12 bit signed immediate")
3255  (attrs HASH-PREFIX)
3256  (type h-sint)
3257  (index f-d12)
3258  (handlers (parse "s12"))
3259)
3260
3261(define-operand
3262  (name u12)
3263  (comment "12 bit signed immediate")
3264  (attrs HASH-PREFIX)
3265  (type h-sint)
3266  (index f-u12)
3267  (handlers (parse "u12"))
3268)
3269
3270(define-operand
3271  (name spr)
3272  (comment "special purpose register")
3273  (attrs)
3274  (type  h-spr)
3275  (index f-spr)
3276  (handlers (parse "spr") (print "spr"))
3277)
3278
3279(define-operand
3280  (name ulo16)
3281  (comment "16 bit unsigned immediate, for #lo()")
3282  (attrs)
3283  (type h-uint)
3284  (index f-u16)
3285  (handlers (parse "ulo16") (print "lo"))
3286)
3287
3288(define-operand
3289  (name slo16)
3290  (comment "16 bit unsigned immediate, for #lo()")
3291  (attrs)
3292  (type h-sint)
3293  (index f-s16)
3294  (handlers (parse "uslo16") (print "lo"))
3295)
3296
3297(define-operand
3298  (name uhi16)
3299  (comment "16 bit unsigned immediate, for #hi()")
3300  (attrs)
3301  (type h-uint)
3302  (index f-u16)
3303  (handlers (parse "uhi16") (print "hi"))
3304)
3305
3306(define-operand
3307  (name label24)
3308  (comment "26 bit pc relative address")
3309  (attrs)
3310  (type h-iaddr)
3311  (index f-label24)
3312  (mode SI)
3313  (handlers (parse "call_label"))
3314)
3315
3316; operands representing hardware
3317;
3318(dnop psr_esr "PSR.ESR bit" (SEM-ONLY) h-psr_esr f-nil)
3319(dnop psr_s   "PSR.S   bit" (SEM-ONLY) h-psr_s   f-nil)
3320(dnop psr_ps  "PSR.PS  bit" (SEM-ONLY) h-psr_ps  f-nil)
3321(dnop psr_et  "PSR.ET  bit" (SEM-ONLY) h-psr_et  f-nil)
3322
3323(dnop bpsr_bs  "BPSR.BS  bit" (SEM-ONLY) h-bpsr_bs  f-nil)
3324(dnop bpsr_bet "BPSR.BET bit" (SEM-ONLY) h-bpsr_bet f-nil)
3325
3326(dnop tbr_tba "TBR.TBA" (SEM-ONLY) h-tbr_tba f-nil)
3327(dnop tbr_tt  "TBR.TT"  (SEM-ONLY) h-tbr_tt  f-nil)
3328
3329; Null operands
3330;
3331(define-pmacro (ICCi_1-null)  (f-ICCi_1-null 0))
3332(define-pmacro (ICCi_2-null)  (f-ICCi_2-null 0))
3333(define-pmacro (ICCi_3-null)  (f-ICCi_3-null 0))
3334(define-pmacro (FCCi_1-null)  (f-FCCi_1-null 0))
3335(define-pmacro (FCCi_2-null)  (f-FCCi_2-null 0))
3336(define-pmacro (FCCi_3-null)  (f-FCCi_3-null 0))
3337(define-pmacro (rs-null)      (f-rs-null     0))
3338(define-pmacro (GRi-null)     (f-GRi-null    0))
3339(define-pmacro (GRj-null)     (f-GRj-null    0))
3340(define-pmacro (GRk-null)     (f-GRk-null    0))
3341(define-pmacro (FRi-null)     (f-FRi-null    0))
3342(define-pmacro (FRj-null)     (f-FRj-null    0))
3343(define-pmacro (ACCj-null)    (f-ACCj-null   0))
3344(define-pmacro (rd-null)      (f-rd-null     0))
3345(define-pmacro (cond-null)    (f-cond-null   0))
3346(define-pmacro (ccond-null)   (f-ccond-null  0))
3347(define-pmacro (s12-null)     (f-s12-null    0))
3348(define-pmacro (label16-null) (f-label16-null 0))
3349(define-pmacro (misc-null-1)  (f-misc-null-1 0))
3350(define-pmacro (misc-null-2)  (f-misc-null-2 0))
3351(define-pmacro (misc-null-3)  (f-misc-null-3 0))
3352(define-pmacro (misc-null-4)  (f-misc-null-4 0))
3353(define-pmacro (misc-null-5)  (f-misc-null-5 0))
3354(define-pmacro (misc-null-6)  (f-misc-null-6 0))
3355(define-pmacro (misc-null-7)  (f-misc-null-7 0))
3356(define-pmacro (misc-null-8)  (f-misc-null-8 0))
3357(define-pmacro (misc-null-9)  (f-misc-null-9 0))
3358(define-pmacro (misc-null-10) (f-misc-null-10 0))
3359(define-pmacro (misc-null-11) (f-misc-null-11 0))
3360
3361(define-pmacro (LRA-null)     (f-LRA-null 0))
3362(define-pmacro (TLBPR-null)   (f-TLBPR-null 0))
3363
3364(define-pmacro (LI-on)       (f-LI-on  1))
3365(define-pmacro (LI-off)      (f-LI-off 0))
3366
3367; Instruction definitions.
3368;
3369; Notes:
3370; - dni is short for "define-normal-instruction"
3371; - Macros are used to represent each insn format. These should be used as much
3372;   as possible unless an insn has exceptional behaviour
3373;
3374
3375; Commonly used Macros
3376;
3377; Specific registers
3378;
3379
3380; Integer condition code manipulation
3381;
3382(define-pmacro (set-z-and-n icc x)
3383  (if (eq x 0)
3384      (set icc (or (and icc #x7) #x4))
3385      (if (lt x 0)
3386	  (set icc (or (and icc #xb) #x8))
3387	  (set icc (and icc #x3))))
3388)
3389
3390(define-pmacro (set-n icc val)
3391  (if (eq val 0)
3392      (set icc (and icc #x7))
3393      (set icc (or  icc #x8)))
3394)
3395
3396(define-pmacro (set-z icc val)
3397  (if (eq val 0)
3398      (set icc (and icc #xb))
3399      (set icc (or  icc #x4)))
3400)
3401
3402(define-pmacro (set-v icc val)
3403  (if (eq val 0)
3404      (set icc (and icc #xd))
3405      (set icc (or  icc #x2)))
3406)
3407
3408(define-pmacro (set-c icc val)
3409  (if (eq val 0)
3410      (set icc (and icc #xe))
3411      (set icc (or  icc #x1)))
3412)
3413
3414(define-pmacro (nbit icc)
3415  (trunc BI (srl (and icc #x8) 3))
3416)
3417
3418(define-pmacro (zbit icc)
3419  (trunc BI (srl (and icc #x4) 2))
3420)
3421
3422(define-pmacro (vbit icc)
3423  (trunc BI (srl (and icc #x2) 1))
3424)
3425
3426(define-pmacro (cbit icc)
3427  (trunc BI (and icc #x1))
3428)
3429
3430(define-pmacro (ebit icc)
3431  (trunc BI (srl (and icc #x8) 3))
3432)
3433
3434(define-pmacro (lbit icc)
3435  (trunc BI (srl (and icc #x4) 2))
3436)
3437
3438(define-pmacro (gbit icc)
3439  (trunc BI (srl (and icc #x2) 1))
3440)
3441
3442(define-pmacro (ubit icc)
3443  (trunc BI (and icc #x1))
3444)
3445
3446; FRV insns
3447;
3448;
3449; Format: INT, Logic, Shift r-r
3450;
3451(define-pmacro (int-logic-r-r name operation op ope comment)
3452  (dni name
3453       (comment)
3454       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3455	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3456       (.str name "$pack $GRi,$GRj,$GRk")
3457       (+ pack GRk op GRi (ICCi_1-null) ope GRj)
3458       (set GRk (operation GRi GRj))
3459       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3460	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3461  )
3462)
3463
3464(int-logic-r-r add  add   OP_00 OPE2_00 "add reg/reg")
3465(int-logic-r-r sub  sub   OP_00 OPE2_04 "sub reg/reg")
3466(int-logic-r-r and  and   OP_01 OPE2_00 "and reg/reg")
3467(int-logic-r-r or   or    OP_01 OPE2_02 "or  reg/reg")
3468(int-logic-r-r xor  xor   OP_01 OPE2_04 "xor reg/reg")
3469
3470(dni not
3471     ("not")
3472     ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3473      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
3474     ("not$pack $GRj,$GRk")
3475     (+ pack GRk OP_01 (rs-null) (ICCi_1-null) OPE2_06 GRj)
3476     (set GRk (inv GRj))
3477     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3478      (fr500 (unit u-integer)) (fr550 (unit u-integer)))
3479)
3480
3481(dni sdiv
3482     "signed division"
3483     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3484      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
3485     "sdiv$pack $GRi,$GRj,$GRk"
3486     (+ pack GRk OP_00 GRi (ICCi_1-null) OPE2_0E GRj)
3487     (sequence ()
3488	       (c-call VOID "@cpu@_signed_integer_divide"
3489		       GRi GRj (index-of GRk) 0)
3490	       (clobber GRk))
3491     ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
3492      (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
3493)
3494
3495(dni nsdiv
3496     "non excepting signed division"
3497     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
3498      (MACH simple,tomcat,fr500,fr550,frv))
3499     "nsdiv$pack $GRi,$GRj,$GRk"
3500     (+ pack GRk OP_01 GRi (ICCi_1-null) OPE2_0E GRj)
3501     (sequence ()
3502	       (c-call VOID "@cpu@_signed_integer_divide"
3503		       GRi GRj (index-of GRk) 1)
3504	       (clobber GRk))
3505     ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
3506)
3507
3508(dni udiv
3509     "unsigned division reg/reg"
3510     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3511      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
3512     "udiv$pack $GRi,$GRj,$GRk"
3513     (+ pack GRk OP_00 GRi (ICCi_1-null) OPE2_0F GRj)
3514     (sequence ()
3515	       (c-call VOID "@cpu@_unsigned_integer_divide"
3516		       GRi GRj (index-of GRk) 0)
3517	       (clobber GRk))
3518     ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
3519      (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
3520)
3521
3522(dni nudiv
3523     "non excepting unsigned division"
3524     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
3525      (MACH simple,tomcat,fr500,fr550,frv))
3526     "nudiv$pack $GRi,$GRj,$GRk"
3527     (+ pack GRk OP_01 GRi (ICCi_1-null) OPE2_0F GRj)
3528     (sequence ()
3529	       (c-call VOID "@cpu@_unsigned_integer_divide"
3530		       GRi GRj (index-of GRk) 1)
3531	       (clobber GRk))
3532     ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
3533)
3534
3535; Multiplication
3536;
3537(define-pmacro (multiply-r-r name signop op ope comment)
3538  (dni name
3539       (comment)
3540       ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3541	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3542       (.str name "$pack $GRi,$GRj,$GRdoublek")
3543       (+ pack GRdoublek op GRi (ICCi_1-null) ope GRj)
3544       (set GRdoublek (mul DI (signop DI GRi) (signop DI GRj)))
3545       ((fr400 (unit u-imul)) (fr450 (unit u-imul))
3546	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
3547  )
3548)
3549
3550(multiply-r-r smul ext  OP_00 OPE2_08 "signed   multiply reg/reg")
3551(multiply-r-r umul zext OP_00 OPE2_0A "unsigned multiply reg/reg")
3552
3553; Multiplication with integer accumulator IACC
3554;
3555
3556(define-pmacro (iacc-set value)
3557  (set (reg h-iacc0 0) value))
3558
3559(define-pmacro (iacc-add value)
3560  (set (reg h-iacc0 0)
3561       (cond DI
3562	     ((andif (andif (gt value 0) (gt (reg h-iacc0 0) 0))
3563		     (lt (sub DI #x7fffffffffffffff value) (reg h-iacc0 0)))
3564	      ; Positive overflow
3565	      (const DI #x7fffffffffffffff))
3566	     ((andif (andif (lt value 0) (lt (reg h-iacc0 0) 0))
3567		     (gt (sub DI #x8000000000000000 value) (reg h-iacc0 0)))
3568	      ; Negative overflow
3569	      (const DI #x8000000000000000))
3570	     (else
3571	      (add DI (reg h-iacc0 0) value))))
3572)
3573
3574(define-pmacro (iacc-sub value)
3575  (set (reg h-iacc0 0)
3576       (cond DI
3577	     ((andif (andif (lt value 0) (gt (reg h-iacc0 0) 0))
3578		     (lt (add DI #x7fffffffffffffff value) (reg h-iacc0 0)))
3579	      ; Positive overflow
3580	      (const DI #x7fffffffffffffff))
3581	     ((andif (andif (gt value 0) (lt (reg h-iacc0 0) 0))
3582		     (gt (add DI #x8000000000000000 value) (reg h-iacc0 0)))
3583	      ; Negative overflow
3584	      (const DI #x8000000000000000))
3585	     (else
3586	      (sub DI (reg h-iacc0 0) value))))
3587)
3588
3589(define-pmacro (iacc-multiply-r-r name operation op ope comment)
3590  (dni name
3591       (comment)
3592       ((UNIT IACC) (MACH fr400,fr450)
3593	(FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
3594       (.str name "$pack $GRi,$GRj")
3595       (+ pack (rd-null) op GRi ope GRj)
3596       ((.sym iacc- operation) (mul DI (ext DI GRi) (ext DI GRj)))
3597       ((fr400 (unit u-integer)) (fr450 (unit u-integer)))
3598  )
3599)
3600
3601(iacc-multiply-r-r smu   set OP_46 OPE1_05 "Signed multiply     reg/reg/iacc")
3602(iacc-multiply-r-r smass add OP_46 OPE1_06 "Signed multiply/add reg/reg/iacc")
3603(iacc-multiply-r-r smsss sub OP_46 OPE1_07 "Signed multiply/sub reg/reg/iacc")
3604
3605(define-pmacro (int-shift-r-r name op ope comment)
3606  (dni name
3607       (comment)
3608       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3609	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3610       (.str name "$pack $GRi,$GRj,$GRk")
3611       (+ pack GRk op GRi (ICCi_1-null) ope GRj)
3612       (set GRk (name GRi (and GRj #x1f)))
3613       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3614	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3615  )
3616)
3617
3618(int-shift-r-r sll OP_01 OPE2_08 "shift left  logical reg/reg")
3619(int-shift-r-r srl OP_01 OPE2_0A "shift right logical reg/reg")
3620(int-shift-r-r sra OP_01 OPE2_0C "shift right arith   reg/reg")
3621
3622(dni slass
3623     "shift left arith reg/reg with saturation"
3624     ((UNIT IALL) (MACH fr400,fr450)
3625      (FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
3626     "slass$pack $GRi,$GRj,$GRk"
3627     (+ pack GRk OP_46 GRi OPE1_02 GRj)
3628     (set GRk (c-call SI "@cpu@_shift_left_arith_saturate" GRi GRj))
3629     ()
3630)
3631
3632(dni scutss
3633     "Integer accumulator cut with saturation"
3634     ((UNIT I0) (MACH fr400,fr450)
3635      (FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
3636     "scutss$pack $GRj,$GRk"
3637     (+ pack GRk OP_46 (rs-null) OPE1_04 GRj)
3638     (set GRk (c-call SI "@cpu@_iacc_cut" (reg h-iacc0 0) GRj))
3639     ()
3640)
3641
3642(define-pmacro (scan-semantics arg1 arg2 targ)
3643  (sequence ((WI tmp1) (WI tmp2))
3644	    (set tmp1 arg1)
3645	    (set tmp2 (sra arg2 1))
3646	    (set targ (c-call WI "@cpu@_scan_result" (xor tmp1 tmp2))))
3647)
3648
3649(dni scan
3650     "scan"
3651     ((UNIT SCAN) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3652      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
3653     "scan$pack $GRi,$GRj,$GRk"
3654     (+ pack GRk OP_0B GRi (ICCi_1-null) OPE2_00 GRj)
3655     (scan-semantics GRi GRj GRk)
3656     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3657      (fr500 (unit u-integer)) (fr550 (unit u-integer)))
3658)
3659
3660; Format: conditional INT, Logic, Shift r-r
3661;
3662(define-pmacro (conditional-int-logic name operation op ope comment)
3663  (dni name
3664       (comment)
3665       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3666	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3667       (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
3668       (+ pack GRk op GRi CCi cond ope GRj)
3669       (if (eq CCi (or cond 2))
3670	   (set GRk (operation GRi GRj)))
3671       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3672	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3673  )
3674)
3675
3676(conditional-int-logic cadd  add  OP_58 OPE4_0 "conditional add")
3677(conditional-int-logic csub  sub  OP_58 OPE4_1 "conditional sub")
3678(conditional-int-logic cand  and  OP_5A OPE4_0 "conditional and")
3679(conditional-int-logic cor   or   OP_5A OPE4_1 "conditional or")
3680(conditional-int-logic cxor  xor  OP_5A OPE4_2 "conditional xor")
3681
3682(dni cnot
3683     "conditional not"
3684     ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3685      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3686     "cnot$pack $GRj,$GRk,$CCi,$cond"
3687     (+ pack GRk OP_5A (rs-null) CCi cond OPE4_3 GRj)
3688     (if (eq CCi (or cond 2))
3689	 (set GRk (inv GRj)))
3690     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3691      (fr500 (unit u-integer)) (fr550 (unit u-integer)))
3692)
3693
3694(dni csmul
3695     "conditional signed multiply"
3696     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3697      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3698     "csmul$pack $GRi,$GRj,$GRdoublek,$CCi,$cond"
3699     (+ pack GRdoublek OP_58 GRi CCi cond OPE4_2 GRj)
3700     (if (eq CCi (or cond 2))
3701	 (set GRdoublek (mul DI (ext DI GRi) (ext DI GRj))))
3702     ((fr400 (unit u-imul)) (fr450 (unit u-imul))
3703      (fr500 (unit u-imul)) (fr550 (unit u-imul)))
3704)
3705
3706(dni csdiv
3707     "conditional signed division"
3708     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3709      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3710     "csdiv$pack $GRi,$GRj,$GRk,$CCi,$cond"
3711     (+ pack GRk OP_58 GRi CCi cond OPE4_3 GRj)
3712     (if (eq CCi (or cond 2))
3713	 (sequence ()
3714		   (c-call VOID "@cpu@_signed_integer_divide"
3715			   GRi GRj (index-of GRk) 0)
3716		   (clobber GRk)))
3717     ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
3718      (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
3719)
3720
3721(dni cudiv
3722     "conditional unsigned division"
3723     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3724      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3725     "cudiv$pack $GRi,$GRj,$GRk,$CCi,$cond"
3726     (+ pack GRk OP_59 GRi CCi cond OPE4_3 GRj)
3727     (if (eq CCi (or cond 2))
3728	 (sequence ()
3729		   (c-call VOID "@cpu@_unsigned_integer_divide"
3730			   GRi GRj (index-of GRk) 0)
3731		   (clobber GRk)))
3732     ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
3733      (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
3734)
3735
3736(define-pmacro (conditional-shift name operation op ope comment)
3737  (dni name
3738       (comment)
3739       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3740	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3741       (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
3742       (+ pack GRk op GRi CCi cond ope GRj)
3743       (if (eq CCi (or cond 2))
3744	   (set GRk (operation GRi (and GRj #x1f))))
3745       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3746	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3747  )
3748)
3749
3750(conditional-shift csll sll OP_5C OPE4_0 "conditional shift left  logical")
3751(conditional-shift csrl srl OP_5C OPE4_1 "conditional shift right logical")
3752(conditional-shift csra sra OP_5C OPE4_2 "conditional shift right arith")
3753
3754(dni cscan
3755     "conditional scan"
3756     ((UNIT SCAN) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3757      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3758     "cscan$pack $GRi,$GRj,$GRk,$CCi,$cond"
3759     (+ pack GRk OP_65 GRi CCi cond OPE4_3 GRj)
3760     (if (eq CCi (or cond 2))
3761	 (scan-semantics GRi GRj GRk))
3762     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3763      (fr500 (unit u-integer)) (fr550 (unit u-integer)))
3764)
3765
3766; Format: INT, Logic, Shift, cc r-r
3767;
3768(define-pmacro (int-arith-cc-semantics operation icc)
3769  (sequence ((BI tmp) (QI cc) (SI result))
3770	    (set cc icc)
3771	    (set tmp ((.sym operation -oflag) GRi GRj (const 0)))
3772	    (set-v cc tmp)
3773	    (set tmp ((.sym operation -cflag) GRi GRj (const 0)))
3774	    (set-c cc tmp)
3775	    (set result (operation GRi GRj))
3776	    (set-z-and-n cc result)
3777	    (set GRk result)
3778	    (set icc cc))
3779)
3780
3781(define-pmacro (int-arith-cc-r-r name operation op ope comment)
3782  (dni name
3783       (comment)
3784       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3785	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3786       (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
3787       (+ pack GRk op GRi ICCi_1 ope GRj)
3788       (int-arith-cc-semantics operation ICCi_1)
3789       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3790	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3791  )
3792)
3793
3794(int-arith-cc-r-r addcc add OP_00 OPE2_01 "add reg/reg, set icc")
3795(int-arith-cc-r-r subcc sub OP_00 OPE2_05 "sub reg/reg, set icc")
3796
3797(define-pmacro (int-logic-cc-semantics op icc)
3798  (sequence ((SI tmp))
3799	    (set tmp (op GRi GRj))
3800	    (set GRk tmp)
3801	    (set-z-and-n icc tmp))
3802)
3803
3804(define-pmacro (int-logic-cc-r-r name op ope comment)
3805  (dni (.sym name cc)
3806       (comment)
3807       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3808	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3809       (.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
3810       (+ pack GRk op GRi ICCi_1 ope GRj)
3811       (int-logic-cc-semantics name ICCi_1)
3812       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3813	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3814  )
3815)
3816
3817(int-logic-cc-r-r and OP_01 OPE2_01 "and reg/reg, set icc")
3818(int-logic-cc-r-r or  OP_01 OPE2_03 "or  reg/reg, set icc")
3819(int-logic-cc-r-r xor OP_01 OPE2_05 "xor reg/reg, set icc")
3820
3821(define-pmacro (int-shift-cc-semantics op l-r icc)
3822  (sequence ((WI shift) (SI tmp) (QI cc))
3823	    (set shift (and GRj #x1f))
3824	    (set cc (c-call QI (.str "@cpu@_set_icc_for_shift_" l-r)
3825			    GRi shift icc))
3826	    (set tmp (op GRi shift))
3827	    (set GRk tmp)
3828	    (set-z-and-n cc tmp)
3829	    (set icc cc))
3830)
3831
3832(define-pmacro (int-shift-cc-r-r name l-r op ope comment)
3833  (dni (.sym name cc)
3834       (comment)
3835       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3836	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3837       (.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
3838       (+ pack GRk op GRi ICCi_1 ope GRj)
3839       (int-shift-cc-semantics name l-r ICCi_1)
3840       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3841	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3842  )
3843)
3844
3845(int-shift-cc-r-r sll left  OP_01 OPE2_09 "shift left  logical reg/reg,set icc")
3846(int-shift-cc-r-r srl right OP_01 OPE2_0B "shift right logical reg/reg,set icc")
3847(int-shift-cc-r-r sra right OP_01 OPE2_0D "shift right arith   reg/reg,set icc")
3848
3849(define-pmacro (multiply-cc-semantics signop arg1 arg2 targ icc)
3850  (sequence ((DI tmp) (QI cc))
3851	    (set cc icc)
3852	    (set tmp (mul DI (signop DI arg1) (signop DI arg2)))
3853	    (set-n cc (srl DI tmp 63))
3854	    (set-z cc (eq tmp 0))
3855	    (set targ tmp)
3856	    (set icc cc))
3857)
3858
3859(define-pmacro (multiply-cc-r-r name signop op ope comment)
3860  (dni name
3861       (comment)
3862       ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3863	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3864       (.str name "$pack $GRi,$GRj,$GRdoublek,$ICCi_1")
3865       (+ pack GRdoublek op GRi ICCi_1 ope GRj)
3866       (multiply-cc-semantics signop GRi GRj GRdoublek ICCi_1)
3867       ((fr400 (unit u-imul)) (fr450 (unit u-imul))
3868	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
3869  )
3870)
3871
3872(multiply-cc-r-r smulcc ext  OP_00 OPE2_09 "signed   multiply reg/reg")
3873(multiply-cc-r-r umulcc zext OP_00 OPE2_0B "unsigned multiply reg/reg")
3874
3875
3876; Format: conditional INT, Logic, Shift, cc r-r
3877;
3878(define-pmacro (conditional-int-arith-cc name operation op ope comment)
3879  (dni name
3880       (comment)
3881       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3882	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3883       (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
3884       (+ pack GRk op GRi CCi cond ope GRj)
3885       (if (eq CCi (or cond 2))
3886	   (int-arith-cc-semantics operation
3887				   (reg h-iccr (and (index-of CCi) 3))))
3888       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3889	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3890  )
3891)
3892
3893(conditional-int-arith-cc caddcc add OP_59 OPE4_0 "add, set icc")
3894(conditional-int-arith-cc csubcc sub OP_59 OPE4_1 "sub, set icc")
3895
3896(dni csmulcc
3897     "conditional signed multiply and set condition code"
3898     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
3899      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3900     "csmulcc$pack $GRi,$GRj,$GRdoublek,$CCi,$cond"
3901     (+ pack GRdoublek OP_59 GRi CCi cond OPE4_2 GRj)
3902     (if (eq CCi (or cond 2))
3903	 (multiply-cc-semantics ext GRi GRj GRdoublek
3904				(reg h-iccr (and (index-of CCi) 3))))
3905     ((fr400 (unit u-imul)) (fr450 (unit u-imul))
3906      (fr500 (unit u-imul)) (fr550 (unit u-imul)))
3907)
3908
3909(define-pmacro (conditional-int-logic-cc name operation op ope comment)
3910  (dni name
3911       (comment)
3912       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3913	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3914       (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
3915       (+ pack GRk op GRi CCi cond ope GRj)
3916       (if (eq CCi (or cond 2))
3917	   (int-logic-cc-semantics operation
3918				   (reg h-iccr (and (index-of CCi) 3))))
3919       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3920	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3921  )
3922)
3923
3924(conditional-int-logic-cc candcc and OP_5B OPE4_0 "conditional and, set icc")
3925(conditional-int-logic-cc corcc  or  OP_5B OPE4_1 "conditional or , set icc")
3926(conditional-int-logic-cc cxorcc xor OP_5B OPE4_2 "conditional xor, set icc")
3927
3928(define-pmacro (conditional-int-shift-cc name l-r op ope comment)
3929  (dni (.sym c name cc)
3930       (comment)
3931       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3932	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
3933       (.str (.sym c name cc) "$pack $GRi,$GRj,$GRk,$CCi,$cond")
3934       (+ pack GRk op GRi CCi cond ope GRj)
3935       (if (eq CCi (or cond 2))
3936	   (int-shift-cc-semantics name l-r
3937				   (reg h-iccr (and (index-of CCi) 3))))
3938       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3939	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3940  )
3941)
3942
3943(conditional-int-shift-cc sll left  OP_5D OPE4_0 "shift left  logical, set icc")
3944(conditional-int-shift-cc srl right OP_5D OPE4_1 "shift right logical, set icc")
3945(conditional-int-shift-cc sra right OP_5D OPE4_2 "shift right arith  , set icc")
3946
3947; Add and subtract with carry
3948;
3949(define-pmacro (int-arith-x-r-r name operation op ope comment)
3950  (dni name
3951       (comment)
3952       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3953	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3954       (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
3955       (+ pack GRk op GRi ICCi_1 ope GRj)
3956       (set GRk ((.sym operation c) GRi GRj (cbit ICCi_1)))
3957       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3958	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3959  )
3960)
3961
3962(int-arith-x-r-r addx add OP_00 OPE2_02 "Add reg/reg, with carry")
3963(int-arith-x-r-r subx sub OP_00 OPE2_06 "Sub reg/reg, with carry")
3964
3965(define-pmacro (int-arith-x-cc-r-r name operation op ope comment)
3966  (dni name
3967       (comment)
3968       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
3969	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
3970       (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
3971       (+ pack GRk op GRi ICCi_1 ope GRj)
3972       (sequence ((WI tmp) (QI cc))
3973		 (set cc ICCi_1)
3974		 (set tmp ((.sym operation c) GRi GRj (cbit cc)))
3975		 (set-v cc ((.sym operation -oflag) GRi GRj (cbit cc)))
3976		 (set-c cc ((.sym operation -cflag) GRi GRj (cbit cc)))
3977		 (set-z-and-n cc tmp)
3978		 (set GRk tmp)
3979		 (set ICCi_1 cc))
3980       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
3981	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
3982  )
3983)
3984
3985(int-arith-x-cc-r-r addxcc add OP_00 OPE2_03 "Add reg/reg, use/set carry")
3986(int-arith-x-cc-r-r subxcc sub OP_00 OPE2_07 "Sub reg/reg, use/set carry")
3987; Add and subtract with saturation
3988;
3989(define-pmacro (int-arith-ss-r-r name operation op ope comment)
3990  (dni name
3991       (comment)
3992       ((UNIT IALL) (MACH fr400,fr450)
3993	(FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
3994       (.str name "$pack $GRi,$GRj,$GRk")
3995       (+ pack GRk op GRi ope GRj)
3996       (sequence ()
3997		 (set GRk (operation GRi GRj))
3998		 (if ((.sym operation -oflag) GRi GRj (const 0))
3999					; Overflow, saturate.
4000					; Sign of result will be
4001					; same as sign of first operand.
4002		     (set GRk
4003			  (cond SI
4004				((gt GRi 0) (const #x7fffffff))
4005				((lt GRi 0) (const #x80000000))
4006				(else (const 0)))))
4007       )
4008       ((fr400 (unit u-integer)) (fr450 (unit u-integer)))
4009  )
4010)
4011
4012(int-arith-ss-r-r addss add OP_46 OPE1_00 "add reg/reg, with saturation")
4013(int-arith-ss-r-r subss sub OP_46 OPE1_01 "sub reg/reg, with saturation")
4014
4015; Format: INT, Logic, Shift r-simm
4016;
4017(define-pmacro (int-logic-r-simm name operation op comment)
4018  (dni name
4019       (comment)
4020       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4021	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4022       (.str name "$pack $GRi,$s12,$GRk")
4023       (+ pack GRk op GRi s12)
4024       (set GRk (operation GRi s12))
4025       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4026	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4027  )
4028)
4029
4030(int-logic-r-simm addi  add   OP_10 "add reg/immed")
4031(int-logic-r-simm subi  sub   OP_14 "sub reg/immed")
4032(int-logic-r-simm andi  and   OP_20 "and reg/immed")
4033(int-logic-r-simm ori   or    OP_22 "or  reg/immed")
4034(int-logic-r-simm xori  xor   OP_24 "xor reg/immed")
4035
4036(dni sdivi
4037     "signed division reg/immed"
4038     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
4039      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4040     "sdivi$pack $GRi,$s12,$GRk"
4041     (+ pack GRk OP_1E GRi s12)
4042     (sequence ()
4043	       (c-call VOID "@cpu@_signed_integer_divide"
4044		       GRi s12 (index-of GRk) 0)
4045	       (clobber GRk))
4046     ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
4047      (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
4048)
4049
4050(dni nsdivi
4051     "non excepting signed division reg/immed"
4052     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
4053      (MACH simple,tomcat,fr500,fr550,frv))
4054     "nsdivi$pack $GRi,$s12,$GRk"
4055     (+ pack GRk OP_2E GRi s12)
4056     (sequence ()
4057	       (c-call VOID "@cpu@_signed_integer_divide"
4058		       GRi s12 (index-of GRk) 1)
4059	       (clobber GRk))
4060     ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
4061)
4062
4063(dni udivi
4064     "unsigned division reg/immed"
4065     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
4066      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4067     "udivi$pack $GRi,$s12,$GRk"
4068     (+ pack GRk OP_1F GRi s12)
4069     (sequence ()
4070	       (c-call VOID "@cpu@_unsigned_integer_divide"
4071		       GRi s12 (index-of GRk) 0)
4072	       (clobber GRk))
4073     ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
4074      (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
4075)
4076
4077(dni nudivi
4078     "non excepting unsigned division reg/immed"
4079     ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
4080      (MACH simple,tomcat,fr500,fr550,frv))
4081     "nudivi$pack $GRi,$s12,$GRk"
4082     (+ pack GRk OP_2F GRi s12)
4083     (sequence ()
4084	       (c-call VOID "@cpu@_unsigned_integer_divide"
4085		       GRi s12 (index-of GRk) 1)
4086	       (clobber GRk))
4087     ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
4088)
4089
4090(define-pmacro (multiply-r-simm name signop op comment)
4091  (dni name
4092       (comment)
4093       ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
4094	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4095       (.str name "$pack $GRi,$s12,$GRdoublek")
4096       (+ pack GRdoublek op GRi s12)
4097       (set GRdoublek (mul DI (signop DI GRi) (signop DI s12)))
4098       ((fr400 (unit u-imul)) (fr450 (unit u-imul))
4099	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
4100  )
4101)
4102
4103(multiply-r-simm smuli ext  OP_18 "signed   multiply reg/immed")
4104(multiply-r-simm umuli zext OP_1A "unsigned multiply reg/immed")
4105
4106(define-pmacro (int-shift-r-simm name op comment)
4107  (dni (.sym name i)
4108       (comment)
4109       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4110	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4111       (.str (.sym name i) "$pack $GRi,$s12,$GRk")
4112       (+ pack GRk op GRi s12)
4113       (set GRk (name GRi (and s12 #x1f)))
4114       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4115	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4116  )
4117)
4118
4119(int-shift-r-simm sll OP_28 "shift left  logical reg/immed")
4120(int-shift-r-simm srl OP_2A "shift right logical reg/immed")
4121(int-shift-r-simm sra OP_2C "shift right arith   reg/immed")
4122
4123(dni scani
4124     "scan immediate"
4125     ((UNIT SCAN) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4126      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4127     "scani$pack $GRi,$s12,$GRk"
4128     (+ pack GRk OP_47 GRi s12)
4129     (scan-semantics GRi s12 GRk)
4130     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4131      (fr500 (unit u-integer)) (fr550 (unit u-integer)))
4132)
4133
4134; Format: INT, Logic, Shift cc r-simm
4135;
4136(define-pmacro (int-arith-cc-r-simm name operation op comment)
4137  (dni name
4138       (comment)
4139       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4140	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4141       (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
4142       (+ pack GRk op GRi ICCi_1 s10)
4143       (sequence ((BI tmp) (QI cc) (SI result))
4144		 (set cc ICCi_1)
4145		 (set tmp ((.sym operation -oflag) GRi s10 (const 0)))
4146		 (set-v cc tmp)
4147		 (set tmp ((.sym operation -cflag) GRi s10 (const 0)))
4148		 (set-c cc tmp)
4149		 (set result (operation GRi s10))
4150		 (set-z-and-n cc result)
4151		 (set GRk result)
4152		 (set ICCi_1 cc))
4153       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4154	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4155  )
4156)
4157
4158(int-arith-cc-r-simm addicc add OP_11 "add reg/immed, set icc")
4159(int-arith-cc-r-simm subicc sub OP_15 "sub reg/immed, set icc")
4160
4161(define-pmacro (int-logic-cc-r-simm name op comment)
4162  (dni (.sym name icc)
4163       (comment)
4164       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4165	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4166       (.str (.sym name icc) "$pack $GRi,$s10,$GRk,$ICCi_1")
4167       (+ pack GRk op GRi ICCi_1 s10)
4168       (sequence ((SI tmp))
4169		 (set tmp (name GRi s10))
4170		 (set GRk tmp)
4171		 (set-z-and-n ICCi_1 tmp))
4172       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4173	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4174  )
4175)
4176
4177(int-logic-cc-r-simm and  OP_21 "and reg/immed, set icc")
4178(int-logic-cc-r-simm or   OP_23 "or  reg/immed, set icc")
4179(int-logic-cc-r-simm xor  OP_25 "xor reg/immed, set icc")
4180
4181(define-pmacro (multiply-cc-r-simm name signop op comment)
4182  (dni name
4183       (comment)
4184       ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
4185	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4186       (.str name "$pack $GRi,$s10,$GRdoublek,$ICCi_1")
4187       (+ pack GRdoublek op GRi ICCi_1 s10)
4188       (multiply-cc-semantics signop GRi s10 GRdoublek ICCi_1)
4189       ((fr400 (unit u-imul)) (fr450 (unit u-imul))
4190	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
4191  )
4192)
4193
4194(multiply-cc-r-simm smulicc ext  OP_19 "signed   multiply reg/immed")
4195(multiply-cc-r-simm umulicc zext OP_1B "unsigned multiply reg/immed")
4196
4197(define-pmacro (int-shift-cc-r-simm name l-r op comment)
4198  (dni (.sym name icc)
4199       (comment)
4200       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4201	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4202       (.str (.sym name icc) "$pack $GRi,$s10,$GRk,$ICCi_1")
4203       (+ pack GRk op GRi ICCi_1 s10)
4204       (sequence ((WI shift) (SI tmp) (QI cc))
4205		 (set shift (and s10 #x1f))
4206		 (set cc (c-call QI (.str "@cpu@_set_icc_for_shift_" l-r)
4207				 GRi shift ICCi_1))
4208		 (set tmp (name GRi shift))
4209		 (set GRk tmp)
4210		 (set-z-and-n cc tmp)
4211		 (set ICCi_1 cc))
4212       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4213	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4214  )
4215)
4216
4217(int-shift-cc-r-simm sll left  OP_29 "shift left  logical reg/immed, set icc")
4218(int-shift-cc-r-simm srl right OP_2B "shift right logical reg/immed, set icc")
4219(int-shift-cc-r-simm sra right OP_2D "shift right arith   reg/immed, set icc")
4220
4221(define-pmacro (int-arith-x-r-simm name operation op comment)
4222  (dni name
4223       (comment)
4224       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4225	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4226       (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
4227       (+ pack GRk op GRi ICCi_1 s10)
4228       (set GRk ((.sym operation c) GRi s10 (cbit ICCi_1)))
4229       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4230	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4231  )
4232)
4233
4234(int-arith-x-r-simm addxi add OP_12 "Add reg/immed, with carry")
4235(int-arith-x-r-simm subxi sub OP_16 "Sub reg/immed, with carry")
4236
4237(define-pmacro (int-arith-x-cc-r-simm name operation op comment)
4238  (dni name
4239       (comment)
4240       ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4241	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
4242       (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
4243       (+ pack GRk op GRi ICCi_1 s10)
4244       (sequence ((WI tmp) (QI cc))
4245		 (set cc ICCi_1)
4246		 (set tmp ((.sym operation c) GRi s10 (cbit cc)))
4247		 (set-v cc ((.sym operation -oflag) GRi s10 (cbit cc)))
4248		 (set-c cc ((.sym operation -cflag) GRi s10 (cbit cc)))
4249		 (set-z-and-n cc tmp)
4250		 (set GRk tmp)
4251		 (set ICCi_1 cc))
4252       ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4253	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
4254  )
4255)
4256
4257(int-arith-x-cc-r-simm addxicc add OP_13 "Add reg/immed, with carry")
4258(int-arith-x-cc-r-simm subxicc sub OP_17 "Sub reg/immed, with carry")
4259
4260; Byte compare insns
4261
4262(dni cmpb
4263     "Compare bytes"
4264     ((UNIT IALL) (MACH fr400,fr450,fr550) (FR550-MAJOR I-1)
4265      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4266     "cmpb$pack $GRi,$GRj,$ICCi_1"
4267     (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0C GRj)
4268     (sequence ((QI cc))
4269	       (set cc 0)
4270	       (set-n cc (eq (and GRi #xff000000) (and GRj #xff000000)))
4271	       (set-z cc (eq (and GRi #x00ff0000) (and GRj #x00ff0000)))
4272	       (set-v cc (eq (and GRi #x0000ff00) (and GRj #x0000ff00)))
4273	       (set-c cc (eq (and GRi #x000000ff) (and GRj #x000000ff)))
4274	       (set ICCi_1 cc))
4275     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4276      (fr550 (unit u-integer)))
4277)
4278
4279(dni cmpba
4280     "OR of Compare bytes"
4281     ((UNIT IALL) (MACH fr400,fr450,fr550) (FR550-MAJOR I-1)
4282      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4283     "cmpba$pack $GRi,$GRj,$ICCi_1"
4284     (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0D GRj)
4285     (sequence ((QI cc))
4286	       (set cc 0)
4287	       (set-c cc
4288		      (orif (eq (and GRi #xff000000) (and GRj #xff000000))
4289			    (orif (eq (and GRi #x00ff0000) (and GRj #x00ff0000))
4290				  (orif (eq (and GRi #x0000ff00)
4291					    (and GRj #x0000ff00))
4292					 (eq (and GRi #x000000ff)
4293					    (and GRj #x000000ff))))))
4294	       (set ICCi_1 cc))
4295     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4296      (fr550 (unit u-integer)))
4297)
4298
4299; Format: Load immediate
4300;
4301(dni setlo
4302     "set low order bits"
4303     ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4304      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4305     "setlo$pack $ulo16,$GRklo"
4306     (+ pack GRk OP_3D (misc-null-4) u16)
4307     (set GRklo u16)
4308     ((fr400 (unit u-set-hilo)) (fr450 (unit u-set-hilo))
4309      (fr500 (unit u-set-hilo)) (fr550 (unit u-set-hilo)))
4310)
4311
4312(dni sethi
4313     "set high order bits"
4314     ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4315      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4316     "sethi$pack $uhi16,$GRkhi"
4317     (+ pack GRkhi OP_3E (misc-null-4) u16)
4318     (set GRkhi u16)
4319     ((fr400 (unit u-set-hilo)) (fr450 (unit u-set-hilo))
4320      (fr500 (unit u-set-hilo)) (fr550 (unit u-set-hilo)))
4321)
4322
4323(dni setlos
4324     "set low order bits and extend sign"
4325     ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
4326      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
4327     "setlos$pack $slo16,$GRk"
4328     (+ pack GRk OP_3F (misc-null-4) s16)
4329     (set GRk s16)
4330     ((fr400 (unit u-integer)) (fr450 (unit u-integer))
4331      (fr500 (unit u-integer)) (fr550 (unit u-integer)))
4332)
4333
4334(define-pmacro (load-gr-r name mode op ope comment ann)
4335  (dni name
4336       (comment)
4337       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4338	(FR400-MAJOR I-2) (FR450-MAJOR I-2))
4339       (.str name "$pack " ann "($GRi,$GRj),$GRk")
4340       (+ pack GRk op GRi ope GRj)
4341       (set GRk (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
4342       ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4343	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4344  )
4345)
4346
4347(dann ldann "ld annotation" SI "ld_annotation" "at")
4348
4349(load-gr-r ldsb   QI OP_02 OPE1_00 "Load   signed byte" "@")
4350(load-gr-r ldub  UQI OP_02 OPE1_01 "Load unsigned byte" "@")
4351(load-gr-r ldsh   HI OP_02 OPE1_02 "Load   signed half" "@")
4352(load-gr-r lduh  UHI OP_02 OPE1_03 "Load unsigned half" "@")
4353(load-gr-r ld     SI OP_02 OPE1_04 "Load          word" "$ldann")
4354
4355(define-pmacro (load-fr-r name mode op ope comment)
4356  (dni name
4357       (comment)
4358       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4359	(FR400-MAJOR I-2) (FR450-MAJOR I-2) FR-ACCESS)
4360       (.str name "$pack @($GRi,$GRj),$FRintk")
4361       (+ pack FRintk op GRi ope GRj)
4362       (set FRintk (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
4363       ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4364	(fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4365  )
4366)
4367
4368(load-fr-r ldbf UQI OP_02 OPE1_08 "Load byte   float")
4369(load-fr-r ldhf UHI OP_02 OPE1_09 "Load half   float")
4370(load-fr-r ldf   SI OP_02 OPE1_0A "Load word   float")
4371
4372(define-pmacro (load-cpr-r name mode op ope reg attr comment)
4373  (dni name
4374       (comment)
4375       ((UNIT LOAD) (FR500-MAJOR I-2) attr)
4376       (.str name "$pack @($GRi,$GRj),$" reg "k")
4377       (+ pack (.sym reg k) op GRi ope GRj)
4378       (set (.sym reg k)
4379	    (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
4380       ()
4381  )
4382)
4383
4384(load-cpr-r ldc SI OP_02 OPE1_0D CPR (MACH frv) "Load coprocessor word")
4385
4386; These correspond to enumerators in frv-sim.h
4387(define-pmacro (ne-UQI-size) 0)
4388(define-pmacro (ne-QI-size)  1)
4389(define-pmacro (ne-UHI-size) 2)
4390(define-pmacro (ne-HI-size)  3)
4391(define-pmacro (ne-SI-size)  4)
4392(define-pmacro (ne-DI-size)  5)
4393(define-pmacro (ne-XI-size)  6)
4394
4395(define-pmacro (ne-load-semantics base dispix targ idisp size is_float action)
4396  (sequence ((BI do_op))
4397	    (set do_op
4398		 (c-call BI "@cpu@_check_non_excepting_load"
4399			  (index-of base) dispix (index-of targ)
4400			  idisp size is_float))
4401	    (if do_op action))
4402)
4403
4404(define-pmacro (ne-load-gr-r name mode op ope size comment)
4405  (dni name
4406       (comment)
4407       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING
4408	(MACH simple,tomcat,fr500,fr550,frv))
4409       (.str name "$pack @($GRi,$GRj),$GRk")
4410       (+ pack GRk op GRi ope GRj)
4411       (ne-load-semantics GRi (index-of GRj) GRk 0 size 0
4412			  (set GRk
4413			       (c-call mode (.str "@cpu@_read_mem_" mode)
4414				       pc (add GRi GRj))))
4415       ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4416  )
4417)
4418
4419(ne-load-gr-r nldsb  QI OP_02 OPE1_20 (ne-QI-size)  "Load   signed byte")
4420(ne-load-gr-r nldub UQI OP_02 OPE1_21 (ne-UQI-size) "Load unsigned byte")
4421(ne-load-gr-r nldsh  HI OP_02 OPE1_22 (ne-HI-size)  "Load   signed half")
4422(ne-load-gr-r nlduh UHI OP_02 OPE1_23 (ne-UHI-size) "Load unsigned half")
4423(ne-load-gr-r nld    SI OP_02 OPE1_24 (ne-SI-size)  "Load          word")
4424
4425(define-pmacro (ne-load-fr-r name mode op ope size comment)
4426  (dni name
4427       (comment)
4428       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
4429	(MACH simple,tomcat,fr500,fr550,frv))
4430       (.str name "$pack @($GRi,$GRj),$FRintk")
4431       (+ pack FRintk op GRi ope GRj)
4432       (ne-load-semantics GRi (index-of GRj) FRintk 0 size 1
4433			  (set FRintk
4434			       (c-call mode (.str "@cpu@_read_mem_" mode)
4435				       pc (add GRi GRj))))
4436       ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4437  )
4438)
4439
4440(ne-load-fr-r nldbf UQI OP_02 OPE1_28 (ne-UQI-size) "Load byte float")
4441(ne-load-fr-r nldhf UHI OP_02 OPE1_29 (ne-UHI-size) "Load half float")
4442(ne-load-fr-r nldf   SI OP_02 OPE1_2A (ne-SI-size)  "Load word float")
4443
4444; Semantics for a load-double insn
4445;
4446(define-pmacro (load-double-semantics not_gr mode regtype address arg)
4447  (if (orif not_gr (ne (index-of (.sym regtype doublek)) 0))
4448      (sequence ()
4449		(set address (add GRi arg))
4450		(set (.sym regtype doublek)
4451		     (c-call mode (.str "@cpu@_read_mem_" mode) pc address))))
4452)
4453
4454(define-pmacro (load-double-r-r
4455		name not_gr mode op ope regtype attr profile comment ann)
4456  (dni name
4457       (comment)
4458       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4459	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
4460       (.str name "$pack " ann "($GRi,$GRj),$" regtype "doublek")
4461       (+ pack (.sym regtype doublek) op GRi ope GRj)
4462       (sequence ((WI address))
4463		 (load-double-semantics not_gr mode regtype address GRj))
4464       profile
4465  )
4466)
4467
4468(dann lddann "ldd annotation" SI "ldd_annotation" "at")
4469
4470(load-double-r-r ldd  0 DI OP_02 OPE1_05 GR  NA
4471		 ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4472		  (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4473		 "Load double word" "$lddann")
4474(load-double-r-r lddf 1 DF OP_02 OPE1_0B FR  FR-ACCESS
4475		 ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4476		  (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4477		 "Load double float" "@")
4478(load-double-r-r lddc 1 DI OP_02 OPE1_0E CPR (MACH frv) ()
4479		 "Load coprocessor double" "@")
4480
4481(define-pmacro (ne-load-double-r-r
4482		name not_gr mode op ope regtype size is_float attr profile
4483		comment)
4484  (dni name
4485       (comment)
4486       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING attr
4487	(MACH simple,tomcat,fr500,fr550,frv))
4488       (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
4489       (+ pack (.sym regtype doublek) op GRi ope GRj)
4490       (sequence ((WI address))
4491		 (ne-load-semantics GRi (index-of GRj) (.sym regtype doublek)
4492				    0 size is_float
4493				    (load-double-semantics not_gr mode
4494							   regtype
4495							   address GRj)))
4496       profile
4497  )
4498)
4499
4500(ne-load-double-r-r nldd  0 DI OP_02 OPE1_25 GR (ne-DI-size) 0 NA
4501		    ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load double   word")
4502(ne-load-double-r-r nlddf 1 DF OP_02 OPE1_2B FR (ne-DI-size) 1 FR-ACCESS
4503		    ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load double float")
4504
4505; Semantics for a load-quad insn
4506;
4507(define-pmacro (load-quad-semantics regtype address arg)
4508  (sequence ()
4509	    (set address (add GRi arg))
4510	    (c-call VOID (.str "@cpu@_load_quad_" regtype)
4511		    pc address (index-of (.sym regtype k))))
4512)
4513
4514(define-pmacro (load-quad-r-r name op ope regtype attr profile comment)
4515  (dni name
4516       (comment)
4517       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
4518       (.str name "$pack @($GRi,$GRj),$" regtype "k")
4519       (+ pack (.sym regtype k) op GRi ope GRj)
4520       (sequence ((WI address))
4521		 (load-quad-semantics regtype address GRj))
4522       ; TODO regtype-k not referenced for profiling
4523       profile
4524  )
4525)
4526
4527(load-quad-r-r ldq  OP_02 OPE1_06 GR    NA        ((fr500 (unit u-gr-load)))
4528	       "Load quad word")
4529(load-quad-r-r ldqf OP_02 OPE1_0C FRint FR-ACCESS ((fr500 (unit u-fr-load)))
4530	       "Load quad float")
4531(load-quad-r-r ldqc OP_02 OPE1_0F CPR   NA        () "Load coprocessor quad")
4532
4533(define-pmacro (ne-load-quad-r-r
4534		name op ope regtype size is_float attr profile comment)
4535  (dni name
4536       (comment)
4537       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING attr)
4538       (.str name "$pack @($GRi,$GRj),$" regtype "k")
4539       (+ pack (.sym regtype k) op GRi ope GRj)
4540       (sequence ((WI address))
4541		 (ne-load-semantics GRi (index-of GRj) (.sym regtype k)
4542				    0 size is_float
4543				    (load-quad-semantics regtype address GRj)))
4544       ; TODO regtype-k not referenced for profiling
4545       profile
4546  )
4547)
4548
4549(ne-load-quad-r-r nldq  OP_02 OPE1_26 GR    (ne-XI-size) 0 NA
4550		  ((fr500 (unit u-gr-load))) "Load quad word")
4551(ne-load-quad-r-r nldqf OP_02 OPE1_2C FRint (ne-XI-size) 1 FR-ACCESS
4552		  ((fr500 (unit u-fr-load))) "Load quad float")
4553
4554(define-pmacro (load-gr-u-semantics mode)
4555  (sequence ((UWI address))
4556	    (set address (add GRi GRj))
4557	    (set GRk (c-call mode (.str "@cpu@_read_mem_" mode) pc address))
4558	    (if (ne (index-of GRi) (index-of GRk))
4559		(sequence ()
4560			  (set GRi address)
4561			  (c-call VOID "@cpu@_force_update"))))
4562)
4563
4564(define-pmacro (load-gr-u name mode op ope comment)
4565  (dni name
4566       (comment)
4567       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4568	(FR400-MAJOR I-2) (FR450-MAJOR I-2))
4569       (.str name "$pack @($GRi,$GRj),$GRk")
4570       (+ pack GRk op GRi ope GRj)
4571       (load-gr-u-semantics mode)
4572       ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4573	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4574  )
4575)
4576
4577(load-gr-u ldsbu   QI OP_02 OPE1_10 "Load   signed byte, update index")
4578(load-gr-u ldubu  UQI OP_02 OPE1_11 "Load unsigned byte, update index")
4579(load-gr-u ldshu   HI OP_02 OPE1_12 "Load   signed half, update index")
4580(load-gr-u lduhu  UHI OP_02 OPE1_13 "Load unsigned half, update index")
4581(load-gr-u ldu     SI OP_02 OPE1_14 "Load          word, update index")
4582
4583(define-pmacro (ne-load-gr-u name mode op ope size comment)
4584  (dni name
4585       (comment)
4586       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING
4587	(MACH simple,tomcat,fr500,fr550,frv))
4588       (.str name "$pack @($GRi,$GRj),$GRk")
4589       (+ pack GRk op GRi ope GRj)
4590       (ne-load-semantics GRi (index-of GRj) GRk 0 size 0 (load-gr-u-semantics mode))
4591       ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4592  )
4593)
4594
4595(ne-load-gr-u nldsbu  QI OP_02 OPE1_30 (ne-QI-size)  "Load   signed byte, update index")
4596(ne-load-gr-u nldubu UQI OP_02 OPE1_31 (ne-UQI-size) "Load unsigned byte, update index")
4597(ne-load-gr-u nldshu  HI OP_02 OPE1_32 (ne-HI-size)  "Load   signed half, update index")
4598(ne-load-gr-u nlduhu UHI OP_02 OPE1_33 (ne-UHI-size) "Load unsigned half, update index")
4599(ne-load-gr-u nldu    SI OP_02 OPE1_34 (ne-SI-size)  "Load          word, update index")
4600
4601(define-pmacro (load-non-gr-u-semantics mode regtype)
4602  (sequence ((UWI address))
4603	    (set address (add GRi GRj))
4604	    (set (.sym regtype k)
4605		 (c-call mode (.str "@cpu@_read_mem_" mode) pc address))
4606	    (set GRi address)
4607	    (c-call VOID "@cpu@_force_update"))
4608)
4609
4610(define-pmacro (load-fr-u name mode op ope comment)
4611  (dni name
4612       (comment)
4613       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4614	(FR400-MAJOR I-2) (FR450-MAJOR I-2) FR-ACCESS)
4615       (.str name "$pack @($GRi,$GRj),$FRintk")
4616       (+ pack FRintk op GRi ope GRj)
4617       (load-non-gr-u-semantics mode FRint)
4618       ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4619	(fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4620  )
4621)
4622
4623(load-fr-u ldbfu  UQI OP_02 OPE1_18 "Load byte float, update index")
4624(load-fr-u ldhfu  UHI OP_02 OPE1_19 "Load half float, update index")
4625(load-fr-u ldfu    SI OP_02 OPE1_1A "Load word float, update index")
4626
4627(define-pmacro (load-cpr-u name mode op ope comment)
4628  (dni name
4629       (comment)
4630       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
4631       (.str name "$pack @($GRi,$GRj),$CPRk")
4632       (+ pack CPRk op GRi ope GRj)
4633       (load-non-gr-u-semantics mode CPR)
4634       ()
4635  )
4636)
4637
4638(load-cpr-u ldcu SI OP_02 OPE1_1D "Load coprocessor word float,update index")
4639
4640(define-pmacro (ne-load-non-gr-u name mode op ope regtype size comment)
4641  (dni name
4642       (comment)
4643       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
4644	(MACH simple,tomcat,fr500,fr550,frv))
4645       (.str name "$pack @($GRi,$GRj),$" regtype "k")
4646       (+ pack (.sym regtype k) op GRi ope GRj)
4647       (ne-load-semantics GRi (index-of GRj) (.sym regtype k) 0 size 1
4648			  (load-non-gr-u-semantics mode regtype))
4649       ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4650  )
4651)
4652
4653(ne-load-non-gr-u nldbfu UQI OP_02 OPE1_38 FRint (ne-UQI-size) "Load byte float, update index")
4654(ne-load-non-gr-u nldhfu UHI OP_02 OPE1_39 FRint (ne-UHI-size) "Load half float, update index")
4655(ne-load-non-gr-u nldfu   SI OP_02 OPE1_3A FRint (ne-SI-size)  "Load word float, update index")
4656
4657(define-pmacro (load-double-gr-u-semantics)
4658  (sequence ((WI address))
4659	    (load-double-semantics 0 DI GR address GRj)
4660	    (if (ne (index-of GRi) (index-of GRdoublek))
4661		(sequence ()
4662			  (set GRi address)
4663			  (c-call VOID "@cpu@_force_update"))))
4664)
4665
4666(define-pmacro (load-double-gr-u name op ope comment)
4667  (dni name
4668       (comment)
4669       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4670	(FR400-MAJOR I-2) (FR450-MAJOR I-2))
4671       (.str name "$pack @($GRi,$GRj),$GRdoublek")
4672       (+ pack GRdoublek op GRi ope GRj)
4673       (load-double-gr-u-semantics)
4674       ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4675	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4676  )
4677)
4678
4679(load-double-gr-u lddu  OP_02 OPE1_15 "Load double word, update index")
4680
4681(define-pmacro (ne-load-double-gr-u name op ope size comment)
4682  (dni name
4683       (comment)
4684       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING
4685	(MACH simple,tomcat,fr500,fr550,frv))
4686       (.str name "$pack @($GRi,$GRj),$GRdoublek")
4687       (+ pack GRdoublek op GRi ope GRj)
4688       (ne-load-semantics GRi (index-of GRj) GRdoublek 0 size 0
4689			  (load-double-gr-u-semantics))
4690       ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4691
4692  )
4693)
4694
4695(ne-load-double-gr-u nlddu OP_02 OPE1_35 (ne-DI-size) "Load double word, update index")
4696
4697(define-pmacro (load-double-non-gr-u-semantics mode regtype)
4698  (sequence ((WI address))
4699	    (load-double-semantics 1 mode regtype address GRj)
4700	    (set GRi address)
4701	    (c-call VOID "@cpu@_force_update"))
4702)
4703
4704(define-pmacro (load-double-non-gr-u
4705		name mode op ope regtype attr profile comment)
4706  (dni name
4707       (comment)
4708       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4709	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
4710       (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
4711       (+ pack (.sym regtype doublek) op GRi ope GRj)
4712       (load-double-non-gr-u-semantics mode regtype)
4713       profile
4714  )
4715)
4716
4717(load-double-non-gr-u lddfu DF OP_02 OPE1_1B FR  FR-ACCESS
4718		      ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4719		       (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4720		      "Load double float, update index")
4721(load-double-non-gr-u lddcu DI OP_02 OPE1_1E CPR (MACH frv)
4722		      () "Load coprocessor double float, update index")
4723
4724(define-pmacro (ne-load-double-non-gr-u name mode op ope regtype size comment)
4725  (dni name
4726       (comment)
4727       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
4728	(MACH simple,tomcat,fr500,fr550,frv))
4729       (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
4730       (+ pack (.sym regtype doublek) op GRi ope GRj)
4731       (ne-load-semantics GRi (index-of GRj) (.sym regtype doublek) 0 size 1
4732			  (load-double-non-gr-u-semantics mode regtype))
4733       ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4734  )
4735)
4736
4737(ne-load-double-non-gr-u nlddfu DF OP_02 OPE1_3B FR (ne-DI-size) "Load double float, update index")
4738
4739(define-pmacro (load-quad-gr-u-semantics)
4740  (sequence ((WI address))
4741	    (load-quad-semantics GR address GRj)
4742	    (if (ne (index-of GRi) (index-of GRk))
4743		(sequence ()
4744			  (set GRi address)
4745			  (c-call VOID "@cpu@_force_update"))))
4746)
4747
4748(define-pmacro (load-quad-gr-u name op ope comment)
4749  (dni name
4750       (comment)
4751       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
4752       (.str name "$pack @($GRi,$GRj),$GRk")
4753       (+ pack GRk op GRi ope GRj)
4754       (load-quad-gr-u-semantics)
4755       ; TODO - GRk not referenced here for profiling
4756       ((fr500 (unit u-gr-load)))
4757  )
4758)
4759
4760(load-quad-gr-u ldqu  OP_02 OPE1_16 "Load quad word, update index")
4761
4762(define-pmacro (ne-load-quad-gr-u name op ope size comment)
4763  (dni name
4764       (comment)
4765       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING)
4766       (.str name "$pack @($GRi,$GRj),$GRk")
4767       (+ pack GRk op GRi ope GRj)
4768       (ne-load-semantics GRi (index-of GRj) GRk 0 size 0
4769			  (load-quad-gr-u-semantics))
4770       ; TODO - GRk not referenced here for profiling
4771       ((fr500 (unit u-gr-load)))
4772  )
4773)
4774
4775(ne-load-quad-gr-u nldqu OP_02 OPE1_36 (ne-XI-size) "Load quad word, update index")
4776
4777(define-pmacro (load-quad-non-gr-u-semantics regtype)
4778  (sequence ((WI address))
4779	    (load-quad-semantics regtype address GRj)
4780	    (set GRi address)
4781	    (c-call VOID "@cpu@_force_update"))
4782)
4783
4784(define-pmacro (load-quad-non-gr-u name op ope regtype attr profile comment)
4785  (dni name
4786       (comment)
4787       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
4788       (.str name "$pack @($GRi,$GRj),$" regtype "k")
4789       (+ pack (.sym regtype k) op GRi ope GRj)
4790       (load-quad-non-gr-u-semantics regtype)
4791       profile
4792  )
4793)
4794
4795(load-quad-non-gr-u ldqfu OP_02 OPE1_1C FRint FR-ACCESS
4796		    ((fr500 (unit u-fr-load))) "Load quad float, update index")
4797(load-quad-non-gr-u ldqcu OP_02 OPE1_1F CPR   NA
4798		    () "Load coprocessor quad word, update index")
4799
4800(define-pmacro (ne-load-quad-non-gr-u name op ope regtype size comment)
4801  (dni name
4802       (comment)
4803       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING FR-ACCESS)
4804       (.str name "$pack @($GRi,$GRj),$" regtype "k")
4805       (+ pack (.sym regtype k) op GRi ope GRj)
4806       (ne-load-semantics GRi (index-of GRj) (.sym regtype k) 0 size 1
4807			  (load-quad-non-gr-u-semantics regtype))
4808       ((fr500 (unit u-fr-load)))
4809  )
4810)
4811
4812(ne-load-quad-non-gr-u nldqfu OP_02 OPE1_3C FRint (ne-XI-size) "Load quad float,update index")
4813
4814(define-pmacro (load-r-simm name mode op regtype attr profile comment)
4815  (dni name
4816       (comment)
4817       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4818	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
4819       (.str name "$pack @($GRi,$d12),$" regtype "k")
4820       (+ pack (.sym regtype k) op GRi d12)
4821       (set (.sym regtype k)
4822	    (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi d12)))
4823       profile
4824  )
4825)
4826
4827(load-r-simm ldsbi  QI OP_30 GR NA
4828	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4829	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4830	     "Load   signed byte")
4831(load-r-simm ldshi  HI OP_31 GR NA
4832	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4833	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4834	     "Load   signed half")
4835(load-r-simm ldi    SI OP_32 GR NA
4836	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4837	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4838	     "Load          word")
4839(load-r-simm ldubi UQI OP_35 GR NA
4840	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4841	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4842	     "Load unsigned byte")
4843(load-r-simm lduhi UHI OP_36 GR NA
4844	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4845	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4846	     "Load unsigned half")
4847
4848(load-r-simm ldbfi UQI OP_38 FRint FR-ACCESS
4849	     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4850	      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4851	     "Load byte float")
4852(load-r-simm ldhfi UHI OP_39 FRint FR-ACCESS
4853	     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4854	      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4855	     "Load half float")
4856(load-r-simm ldfi   SI OP_3A FRint FR-ACCESS
4857	     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4858	      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4859	     "Load word float")
4860
4861(define-pmacro (ne-load-r-simm
4862		name mode op regtype size is_float attr profile comment)
4863  (dni name
4864       (comment)
4865       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING attr
4866	(MACH simple,tomcat,fr500,fr550,frv))
4867       (.str name "$pack @($GRi,$d12),$" regtype "k")
4868       (+ pack (.sym regtype k) op GRi d12)
4869       (ne-load-semantics GRi -1 (.sym regtype k) d12 size is_float
4870			  (set (.sym regtype k)
4871			       (c-call mode (.str "@cpu@_read_mem_" mode)
4872				       pc (add GRi d12))))
4873       profile
4874  )
4875)
4876
4877(ne-load-r-simm nldsbi  QI OP_40 GR (ne-QI-size)  0 NA
4878		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load   signed byte")
4879(ne-load-r-simm nldubi UQI OP_41 GR (ne-UQI-size) 0 NA
4880		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load unsigned byte")
4881(ne-load-r-simm nldshi  HI OP_42 GR (ne-HI-size)  0 NA
4882		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load   signed half")
4883(ne-load-r-simm nlduhi UHI OP_43 GR (ne-UHI-size) 0 NA
4884		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load unsigned half")
4885(ne-load-r-simm nldi    SI OP_44 GR (ne-SI-size)  0 NA
4886		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load          word")
4887
4888(ne-load-r-simm nldbfi UQI OP_48 FRint (ne-UQI-size) 1 FR-ACCESS
4889		((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load byte float")
4890(ne-load-r-simm nldhfi UHI OP_49 FRint (ne-UHI-size) 1 FR-ACCESS
4891		((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load half float")
4892(ne-load-r-simm nldfi   SI OP_4A FRint (ne-SI-size)  1 FR-ACCESS
4893		((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load word float")
4894
4895(define-pmacro (load-double-r-simm
4896		name not_gr mode op regtype attr profile comment)
4897  (dni name
4898       (comment)
4899       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
4900	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
4901       (.str name "$pack @($GRi,$d12),$" regtype "doublek")
4902       (+ pack (.sym regtype doublek) op GRi d12)
4903       (sequence ((WI address))
4904		 (load-double-semantics not_gr mode regtype address d12))
4905       profile
4906  )
4907)
4908
4909(load-double-r-simm lddi  0 DI OP_33 GR NA
4910		    ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
4911		     (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
4912		    "Load double word")
4913(load-double-r-simm lddfi 1 DF OP_3B FR FR-ACCESS
4914		    ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
4915		     (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
4916		    "Load double float")
4917
4918(define-pmacro (ne-load-double-r-simm
4919		name not_gr mode op regtype size is_float attr profile comment)
4920  (dni name
4921       (comment)
4922       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING attr
4923	(MACH simple,tomcat,fr500,fr550,frv))
4924       (.str name "$pack @($GRi,$d12),$" regtype "doublek")
4925       (+ pack (.sym regtype doublek) op GRi d12)
4926       (sequence ((WI address))
4927		 (ne-load-semantics GRi -1 (.sym regtype doublek)
4928				    d12 size is_float
4929				    (load-double-semantics not_gr mode
4930							   regtype
4931							   address d12)))
4932       profile
4933  )
4934)
4935
4936(ne-load-double-r-simm nlddi  0 DI OP_45 GR (ne-DI-size) 0 NA
4937		       ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load double word")
4938(ne-load-double-r-simm nlddfi 1 DF OP_4B FR (ne-DI-size) 1 FR-ACCESS
4939		       ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load double float")
4940
4941(define-pmacro (load-quad-r-simm name op regtype attr profile comment)
4942  (dni name
4943       (comment)
4944       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
4945       (.str name "$pack @($GRi,$d12),$" regtype "k")
4946       (+ pack (.sym regtype k) op GRi d12)
4947       (sequence ((WI address))
4948		 (load-quad-semantics regtype address d12))
4949       profile
4950  )
4951)
4952
4953(load-quad-r-simm ldqi  OP_34 GR    NA
4954		  ((fr500 (unit u-gr-load))) "Load quad word")
4955(load-quad-r-simm ldqfi OP_3C FRint FR-ACCESS
4956		  ((fr500 (unit u-fr-load))) "Load quad float")
4957
4958(define-pmacro (ne-load-quad-r-simm
4959		name op regtype size is_float attr profile comment)
4960  (dni name
4961       (comment)
4962       ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING attr)
4963       (.str name "$pack @($GRi,$d12),$" regtype "k")
4964       (+ pack (.sym regtype k) op GRi d12)
4965       (sequence ((WI address))
4966		 (ne-load-semantics GRi -1 (.sym regtype k) d12 size is_float
4967				    (load-quad-semantics regtype address d12)))
4968       profile
4969  )
4970)
4971
4972(ne-load-quad-r-simm nldqfi OP_4C FRint (ne-XI-size) 1 FR-ACCESS
4973		     ((fr500 (unit u-fr-load))) "Load quad float")
4974
4975(define-pmacro (store-r-r name mode op ope reg attr profile comment)
4976  (dni name
4977       (comment)
4978       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
4979	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
4980       (.str name "$pack $" reg "k,@($GRi,$GRj)")
4981       (+ pack (.sym reg k) op GRi ope GRj)
4982       (c-call VOID (.str "@cpu@_write_mem_" mode)
4983	       pc (add GRi GRj) (.sym reg k))
4984       profile
4985  )
4986)
4987
4988(store-r-r stb   QI OP_03 OPE1_00 GR NA
4989	   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
4990	    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
4991	   "Store unsigned byte")
4992(store-r-r sth   HI OP_03 OPE1_01 GR NA
4993	   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
4994	    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
4995	   "Store unsigned half")
4996(store-r-r st    SI OP_03 OPE1_02 GR NA
4997	   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
4998	    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
4999	   "Store          word")
5000
5001(store-r-r stbf  QI OP_03 OPE1_08 FRint FR-ACCESS
5002	   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5003	    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5004	   "Store byte float")
5005(store-r-r sthf  HI OP_03 OPE1_09 FRint FR-ACCESS
5006	   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5007	    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5008	   "Store half float")
5009(store-r-r stf   SI OP_03 OPE1_0A FRint FR-ACCESS
5010	   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5011	    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5012	   "Store word float")
5013
5014(store-r-r stc   SI OP_03 OPE1_25 CPR (MACH frv) () "Store coprocessor word")
5015
5016; Semantics for a store-double insn
5017;
5018(define-pmacro (store-double-semantics mode regtype address arg)
5019  (sequence ()
5020	    (set address (add GRi arg))
5021	    (c-call VOID (.str "@cpu@_write_mem_" mode)
5022		    pc address (.sym regtype doublek)))
5023)
5024
5025(define-pmacro (store-double-r-r name mode op ope regtype attr profile comment)
5026  (dni name
5027       (comment)
5028       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5029	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
5030       (.str name "$pack $" regtype "doublek,@($GRi,$GRj)")
5031       (+ pack (.sym regtype doublek) op GRi ope GRj)
5032       (sequence ((WI address))
5033		 (store-double-semantics mode regtype address GRj))
5034       profile
5035  )
5036)
5037
5038(store-double-r-r std  DI OP_03 OPE1_03 GR  NA
5039		  ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5040		   (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5041		  "Store double word")
5042(store-double-r-r stdf DF OP_03 OPE1_0B FR  FR-ACCESS
5043		  ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5044		   (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5045		  "Store double float")
5046
5047(store-double-r-r stdc DI OP_03 OPE1_26 CPR (MACH frv)
5048		  () "Store coprocessor double word")
5049
5050; Semantics for a store-quad insn
5051;
5052(define-pmacro (store-quad-semantics regtype address arg)
5053  (sequence ()
5054	    (set address (add GRi arg))
5055	    (c-call VOID (.str "@cpu@_store_quad_" regtype)
5056		     pc address (index-of (.sym regtype k))))
5057)
5058
5059(define-pmacro (store-quad-r-r name op ope regtype attr profile comment)
5060  (dni name
5061       (comment)
5062       ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) attr)
5063       (.str name "$pack $" regtype "k,@($GRi,$GRj)")
5064       (+ pack (.sym regtype k) op GRi ope GRj)
5065       (sequence ((WI address))
5066		 (store-quad-semantics regtype address GRj))
5067       profile
5068  )
5069)
5070
5071(store-quad-r-r stq   OP_03 OPE1_04 GR    NA
5072		((fr500 (unit u-gr-store))) "Store quad word")
5073(store-quad-r-r stqf  OP_03 OPE1_0C FRint FR-ACCESS
5074		((fr500 (unit u-fr-store)))
5075		"Store quad float")
5076(store-quad-r-r stqc  OP_03 OPE1_27 CPR   NA
5077		() "Store coprocessor quad word")
5078
5079(define-pmacro (store-r-r-u name mode op ope regtype attr profile comment)
5080  (dni name
5081       (comment)
5082       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5083	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
5084       (.str name "$pack $" regtype "k,@($GRi,$GRj)")
5085       (+ pack (.sym regtype k) op GRi ope GRj)
5086       (sequence ((UWI address))
5087		 (set address (add GRi GRj))
5088		 (c-call VOID (.str "@cpu@_write_mem_" mode)
5089			 pc address (.sym regtype k))
5090		 (set GRi address))
5091       profile
5092  )
5093)
5094
5095(store-r-r-u stbu  QI OP_03 OPE1_10 GR NA
5096	     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5097	      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5098	     "Store unsigned byte, update index")
5099(store-r-r-u sthu  HI OP_03 OPE1_11 GR NA
5100	     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5101	      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5102	     "Store unsigned half, update index")
5103(store-r-r-u stu   WI OP_03 OPE1_12 GR NA
5104	     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5105	      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5106	     "Store          word, update index")
5107
5108(store-r-r-u stbfu QI OP_03 OPE1_18 FRint FR-ACCESS
5109	     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5110	      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5111	     "Store byte float, update index")
5112(store-r-r-u sthfu HI OP_03 OPE1_19 FRint FR-ACCESS
5113	     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5114	      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5115	     "Store half float, update index")
5116(store-r-r-u stfu  SI OP_03 OPE1_1A FRint FR-ACCESS
5117	     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5118	      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5119	     "Store word float, update index")
5120
5121(store-r-r-u stcu  SI OP_03 OPE1_2D CPR (MACH frv) ()
5122	     "Store coprocessor word, update index")
5123
5124(define-pmacro (store-double-r-r-u
5125		name mode op ope regtype attr profile comment)
5126  (dni name
5127       (comment)
5128       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5129	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
5130       (.str name "$pack $" regtype "doublek,@($GRi,$GRj)")
5131       (+ pack (.sym regtype doublek) op GRi ope GRj)
5132       (sequence ((WI address))
5133		 (store-double-semantics mode regtype address GRj)
5134		 (set GRi address))
5135       profile
5136  )
5137)
5138
5139(store-double-r-r-u stdu  DI OP_03 OPE1_13 GR  NA
5140		    ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5141		     (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5142		    "Store double word, update index")
5143(store-double-r-r-u stdfu DF OP_03 OPE1_1B FR  FR-ACCESS
5144		    ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5145		     (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5146		    "Store double float,update index")
5147(store-double-r-r-u stdcu DI OP_03 OPE1_2E CPR (MACH frv) ()
5148		    "Store coprocessor double word, update index")
5149
5150(define-pmacro (store-quad-r-r-u name op ope regtype attr profile comment)
5151  (dni name
5152       (comment)
5153       ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) attr)
5154       (.str name "$pack $" regtype "k,@($GRi,$GRj)")
5155       (+ pack (.sym regtype k) op GRi ope GRj)
5156       (sequence ((WI address))
5157		 (store-quad-semantics regtype address GRj)
5158		 (set GRi address))
5159       profile
5160  )
5161)
5162
5163(store-quad-r-r-u stqu  OP_03 OPE1_14 GR    NA
5164		  ((fr500 (unit u-gr-store)))
5165		  "Store quad word, update index")
5166(store-quad-r-r-u stqfu OP_03 OPE1_1C FRint FR-ACCESS
5167		  ((fr500 (unit u-fr-store)))
5168		  "Store quad float, update index")
5169(store-quad-r-r-u stqcu OP_03 OPE1_2F CPR   NA ()
5170		  "Store coprocessor quad   word, update index")
5171
5172(define-pmacro (conditional-load name mode op ope regtype profile comment)
5173  (dni name
5174       (comment)
5175       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
5176	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL)
5177       (.str name "$pack @($GRi,$GRj),$" regtype "k,$CCi,$cond")
5178       (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
5179       (if (eq CCi (or cond 2))
5180	   (set (.sym regtype k)
5181		(c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj))))
5182       profile
5183  )
5184)
5185
5186(conditional-load cldsb  QI OP_5E OPE4_0 GR
5187		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5188		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5189		  "Load   signed byte")
5190(conditional-load cldub UQI OP_5E OPE4_1 GR
5191		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5192		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5193		  "Load unsigned byte")
5194(conditional-load cldsh  HI OP_5E OPE4_2 GR
5195		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5196		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5197		  "Load   signed half")
5198(conditional-load clduh UHI OP_5E OPE4_3 GR
5199		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5200		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5201		  "Load unsigned half")
5202(conditional-load cld    SI OP_5F OPE4_0 GR
5203		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5204		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5205		  "Load          word")
5206
5207(conditional-load cldbf UQI OP_60 OPE4_0 FRint
5208		  ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
5209		   (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
5210		  "Load byte float")
5211(conditional-load cldhf UHI OP_60 OPE4_1 FRint
5212		  ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
5213		   (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
5214		  "Load half float")
5215(conditional-load cldf   SI OP_60 OPE4_2 FRint
5216		  ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
5217		   (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
5218		  "Load word float")
5219
5220(define-pmacro (conditional-load-double
5221		name not_gr mode op ope regtype attr profile comment)
5222  (dni name
5223       (comment)
5224       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
5225	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL attr)
5226       (.str name "$pack @($GRi,$GRj),$" regtype "doublek,$CCi,$cond")
5227       (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
5228       (if (eq CCi (or cond 2))
5229	   (sequence ((WI address))
5230		     (load-double-semantics not_gr mode regtype address GRj)))
5231       profile
5232  )
5233)
5234
5235(conditional-load-double cldd  0 DI OP_5F OPE4_1 GR NA
5236			 ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5237			  (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5238			 "Load double word")
5239(conditional-load-double clddf 1 DF OP_60 OPE4_3 FR FR-ACCESS
5240			 ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5241			  (fr500 (unit u-gr-load)) (fr550 (unit u-fr-load)))
5242			 "Load double float")
5243
5244(dni cldq
5245     "conditional load quad integer"
5246     ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) CONDITIONAL)
5247     "cldq$pack @($GRi,$GRj),$GRk,$CCi,$cond"
5248     (+ pack GRk OP_5F GRi CCi cond OPE4_2 GRj)
5249     (if (eq CCi (or cond 2))
5250	 (sequence ((WI address))
5251		   (load-quad-semantics GR address GRj)))
5252     ((fr500 (unit u-gr-load)))
5253)
5254
5255(define-pmacro (conditional-load-gr-u name mode op ope comment)
5256  (dni name
5257       (comment)
5258       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
5259	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL)
5260       (.str name "$pack @($GRi,$GRj),$GRk,$CCi,$cond")
5261       (+ pack GRk op GRi CCi  cond ope GRj)
5262       (if (eq CCi (or cond 2))
5263	   (sequence ((WI address))
5264		     (set address (add GRi GRj))
5265		     (set GRk
5266			  (c-call mode (.str "@cpu@_read_mem_" mode)
5267				  pc address))
5268		     (if (ne (index-of GRi) (index-of GRk))
5269			 (set GRi address))))
5270       ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5271	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5272  )
5273)
5274
5275(conditional-load-gr-u cldsbu  QI OP_61 OPE4_0 "Load   signed byte, update")
5276(conditional-load-gr-u cldubu UQI OP_61 OPE4_1 "Load unsigned byte, update")
5277(conditional-load-gr-u cldshu  HI OP_61 OPE4_2 "Load   signed half, update")
5278(conditional-load-gr-u clduhu UHI OP_61 OPE4_3 "Load unsigned half, update")
5279(conditional-load-gr-u cldu    SI OP_62 OPE4_0 "Load          word, update")
5280
5281(define-pmacro (conditional-load-non-gr-u name mode op ope regtype comment)
5282  (dni name
5283       (comment)
5284       ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
5285	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL FR-ACCESS)
5286       (.str name "$pack @($GRi,$GRj),$" regtype "k,$CCi,$cond")
5287       (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
5288       (if (eq CCi (or cond 2))
5289	   (sequence ((WI address))
5290		     (set address (add GRi GRj))
5291		     (set (.sym regtype k)
5292			  (c-call mode (.str "@cpu@_read_mem_" mode)
5293				  pc address))
5294		     (set GRi address)))
5295       ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
5296	(fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
5297  )
5298)
5299
5300(conditional-load-non-gr-u cldbfu UQI OP_63 OPE4_0 FRint "Load byte float, update")
5301(conditional-load-non-gr-u cldhfu UHI OP_63 OPE4_1 FRint "Load half float, update")
5302(conditional-load-non-gr-u cldfu   SI OP_63 OPE4_2 FRint "Load word float, update")
5303
5304
5305(dni clddu
5306     "Load double word,  update"
5307     ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
5308      (FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL)
5309     "clddu$pack @($GRi,$GRj),$GRdoublek,$CCi,$cond"
5310     (+ pack GRdoublek OP_62 GRi CCi cond OPE4_1 GRj)
5311     (if (eq CCi (or cond 2))
5312	 (sequence ((WI address))
5313		   (load-double-semantics 0 DI GR address GRj)
5314		   (if (ne (index-of GRi) (index-of GRdoublek))
5315		       (set GRi address))))
5316     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
5317      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
5318)
5319
5320(dni clddfu
5321     "Load double float, update"
5322     ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
5323      (FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL FR-ACCESS)
5324     "clddfu$pack @($GRi,$GRj),$FRdoublek,$CCi,$cond"
5325     (+ pack FRdoublek OP_63 GRi CCi cond OPE4_3 GRj)
5326     (if (eq CCi (or cond 2))
5327	 (sequence ((WI address))
5328		   (load-double-semantics 1 DF FR address GRj)
5329		   (set GRi address)))
5330     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
5331      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
5332)
5333
5334(dni cldqu
5335     "conditional load quad integer and update index"
5336     ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) CONDITIONAL)
5337     "cldqu$pack @($GRi,$GRj),$GRk,$CCi,$cond"
5338     (+ pack GRk OP_62 GRi CCi cond OPE4_2 GRj)
5339     (if (eq CCi (or cond 2))
5340	 (sequence ((WI address))
5341		   (load-quad-semantics GR address GRj)
5342		   (if (ne (index-of GRi) (index-of GRk))
5343		       (set GRi address))))
5344     ((fr500 (unit u-gr-load)))
5345)
5346
5347(define-pmacro (conditional-store name mode op ope regtype profile comment)
5348  (dni name
5349       (comment)
5350       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5351	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL)
5352       (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
5353       (+ pack (.sym regtype k) op GRi CCi cond ope GRj)
5354       (if (eq CCi (or cond 2))
5355	   (c-call VOID (.str "@cpu@_write_mem_" mode)
5356		   pc (add GRi GRj) (.sym regtype k)))
5357       profile
5358  )
5359)
5360
5361(conditional-store cstb  QI OP_64 OPE4_0 GR
5362		   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5363		    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5364		   "Store unsigned byte")
5365(conditional-store csth  HI OP_64 OPE4_1 GR
5366		   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5367		    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5368		   "Store unsigned half")
5369(conditional-store cst   SI OP_64 OPE4_2 GR
5370		   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5371		    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5372		   "Store          word")
5373
5374(conditional-store cstbf QI OP_66 OPE4_0 FRint
5375		   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5376		    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5377		   "Store byte float")
5378(conditional-store csthf HI OP_66 OPE4_1 FRint
5379		   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5380		    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5381		   "Store half float")
5382(conditional-store cstf  SI OP_66 OPE4_2 FRint
5383		   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5384		    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5385		   "Store word float")
5386
5387(define-pmacro (conditional-store-double
5388		name mode op ope regtype attr profile comment)
5389  (dni name
5390       (comment)
5391       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5392	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL attr)
5393       (.str name "$pack $" regtype "doublek,@($GRi,$GRj),$CCi,$cond")
5394       (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
5395       (if (eq CCi (or cond 2))
5396	   (sequence ((WI address))
5397		     (store-double-semantics mode regtype address GRj)))
5398       profile
5399  )
5400)
5401
5402(conditional-store-double cstd  DI OP_64 OPE4_3 GR NA
5403			  ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5404			   (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5405			  "Store double word")
5406(conditional-store-double cstdf DF OP_66 OPE4_3 FR FR-ACCESS
5407			  ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5408			   (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5409			  "Store double float")
5410
5411(dni cstq
5412     "conditionally store quad word"
5413     ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) CONDITIONAL)
5414     "cstq$pack $GRk,@($GRi,$GRj),$CCi,$cond"
5415     (+ pack GRk OP_65 GRi CCi cond OPE4_0 GRj)
5416     (if (eq CCi (or cond 2))
5417	 (sequence ((WI address))
5418		   (store-quad-semantics GR address GRj)))
5419     ((fr500 (unit u-gr-store)))
5420)
5421
5422(define-pmacro (conditional-store-u
5423		name mode op ope regtype attr profile comment)
5424  (dni name
5425       (comment)
5426       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5427	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL attr)
5428       (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
5429       (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
5430       (if (eq CCi (or cond 2))
5431	   (sequence ((WI address))
5432		     (set address (add GRi GRj))
5433		     (c-call VOID (.str "@cpu@_write_mem_" mode)
5434			     pc address (.sym regtype k))
5435		     (set GRi address)))
5436       profile
5437  )
5438)
5439
5440(conditional-store-u cstbu QI OP_67 OPE4_0 GR NA
5441		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5442		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5443		     "Store unsigned byte, update index")
5444(conditional-store-u csthu HI OP_67 OPE4_1 GR NA
5445		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5446		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5447		     "Store unsigned half, update index")
5448(conditional-store-u cstu  SI OP_67 OPE4_2 GR NA
5449		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5450		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5451		     "Store          word, update index")
5452
5453(conditional-store-u cstbfu QI OP_68 OPE4_0 FRint FR-ACCESS
5454		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5455		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5456		     "Store byte float, update index")
5457(conditional-store-u csthfu HI OP_68 OPE4_1 FRint FR-ACCESS
5458		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5459		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5460		     "Store half float, update index")
5461(conditional-store-u cstfu  SI OP_68 OPE4_2 FRint FR-ACCESS
5462		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5463		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5464		     "Store word float, update index")
5465
5466(define-pmacro (conditional-store-double-u
5467		name mode op ope regtype attr profile comment)
5468  (dni name
5469       (comment)
5470       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5471	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL attr)
5472       (.str name "$pack $" regtype "doublek,@($GRi,$GRj),$CCi,$cond")
5473       (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
5474       (if (eq CCi (or cond 2))
5475	   (sequence ((WI address))
5476		     (store-double-semantics mode regtype address GRj)
5477		     (set GRi address)))
5478       profile
5479  )
5480)
5481
5482(conditional-store-double-u cstdu  DI OP_67 OPE4_3 GR NA
5483			    ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5484			     (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5485			    "Store double word, update index")
5486(conditional-store-double-u cstdfu DF OP_68 OPE4_3 FR FR-ACCESS
5487			    ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5488			     (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5489			    "Store double float, update index")
5490
5491(define-pmacro (store-r-simm name mode op regtype attr profile comment)
5492  (dni name
5493       (comment)
5494       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5495	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
5496       (.str name "$pack $" regtype "k,@($GRi,$d12)")
5497       (+ pack (.sym regtype k) op GRi d12)
5498       (c-call VOID (.str "@cpu@_write_mem_" mode)
5499	       pc (add GRi d12) (.sym regtype k))
5500       profile
5501  )
5502)
5503
5504(store-r-simm stbi QI OP_50 GR NA
5505	      ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5506	       (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5507	      "Store unsigned byte")
5508(store-r-simm sthi HI OP_51 GR NA
5509	      ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5510	       (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5511	      "Store unsigned half")
5512(store-r-simm sti  SI OP_52 GR NA
5513	      ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5514	       (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5515	      "Store          word")
5516
5517(store-r-simm stbfi QI OP_4E FRint FR-ACCESS
5518	      ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5519	       (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5520	      "Store byte float")
5521(store-r-simm sthfi HI OP_4F FRint FR-ACCESS
5522	      ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5523	       (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5524	      "Store half float")
5525(store-r-simm stfi  SI OP_55 FRint FR-ACCESS
5526	      ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5527	       (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5528	      "Store word float")
5529
5530(define-pmacro (store-double-r-simm name mode op regtype attr profile comment)
5531  (dni name
5532       (comment)
5533       ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
5534	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
5535       (.str name "$pack $" regtype "doublek,@($GRi,$d12)")
5536       (+ pack (.sym regtype doublek) op GRi d12)
5537       (sequence ((WI address))
5538		 (store-double-semantics mode regtype address d12))
5539       profile
5540  )
5541)
5542
5543(store-double-r-simm stdi  DI OP_53 GR NA
5544		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
5545		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
5546		     "Store double word")
5547(store-double-r-simm stdfi DF OP_56 FR FR-ACCESS
5548		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
5549		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
5550		     "Store double float")
5551
5552(define-pmacro (store-quad-r-simm name op regtype attr profile comment)
5553  (dni name
5554       (comment)
5555       ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) attr)
5556       (.str name "$pack $" regtype "k,@($GRi,$d12)")
5557       (+ pack (.sym regtype k) op GRi d12)
5558       (sequence ((WI address))
5559		 (store-quad-semantics regtype address d12))
5560       profile
5561  )
5562)
5563
5564(store-quad-r-simm stqi  OP_54 GR    NA ((fr500 (unit u-gr-store)))
5565		   "Store quad word")
5566(store-quad-r-simm stqfi OP_57 FRint FR-ACCESS ()
5567		   "Store quad float")
5568
5569(define-pmacro (swap-semantics base offset arg)
5570  (sequence ((WI tmp) (WI address))
5571	    (set tmp arg)
5572	    (set address (add base offset))
5573	    (c-call VOID "@cpu@_check_swap_address" address)
5574	    (set arg (c-call WI "@cpu@_read_mem_WI" pc address))
5575	    (c-call VOID "@cpu@_write_mem_WI" pc address tmp))
5576)
5577
5578(dni swap
5579     "Swap contents of memory with GR"
5580     ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
5581      (FR400-MAJOR C-2) (FR450-MAJOR C-2))
5582     "swap$pack @($GRi,$GRj),$GRk"
5583     (+ pack GRk OP_03 GRi OPE1_05 GRj)
5584     (swap-semantics GRi GRj GRk)
5585     ((fr400 (unit u-swap)) (fr450 (unit u-swap))
5586      (fr500 (unit u-swap)) (fr550 (unit u-swap)))
5587)
5588
5589(dni "swapi"
5590     "Swap contents of memory with GR"
5591     ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
5592      (FR400-MAJOR C-2) (FR450-MAJOR C-2))
5593     ("swapi$pack @($GRi,$d12),$GRk")
5594     (+ pack GRk OP_4D GRi d12)
5595     (swap-semantics GRi d12 GRk)
5596     ((fr400 (unit u-swap)) (fr450 (unit u-swap))
5597      (fr500 (unit u-swap)) (fr550 (unit u-swap)))
5598)
5599
5600(dni cswap
5601     "Conditionally swap contents of memory with GR"
5602     ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
5603      (FR400-MAJOR C-2) (FR450-MAJOR C-2) CONDITIONAL)
5604     "cswap$pack @($GRi,$GRj),$GRk,$CCi,$cond"
5605     (+ pack GRk OP_65 GRi CCi cond OPE4_2 GRj)
5606     (if (eq CCi (or cond 2))
5607	 (swap-semantics GRi GRj GRk))
5608     ((fr400 (unit u-swap)) (fr450 (unit u-swap))
5609      (fr500 (unit u-swap)) (fr550 (unit u-swap)))
5610)
5611
5612(define-pmacro (register-transfer
5613		name op ope reg_src reg_targ pipe attrs	profile comment)
5614  (dni name
5615       (comment)
5616       (.splice (UNIT pipe) (.unsplice attrs))
5617       (.str name "$pack $" reg_src ",$" reg_targ)
5618       (+ pack reg_targ op (rs-null) ope reg_src)
5619       (set reg_targ reg_src)
5620       profile
5621  )
5622)
5623
5624(register-transfer movgf OP_03 OPE1_15
5625		   GRj FRintk I0
5626		   ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
5627		    (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
5628		   ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
5629		    (fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
5630		   "transfer gr to fr")
5631(register-transfer movfg OP_03 OPE1_0D
5632		   FRintk GRj I0
5633		   ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
5634		    (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
5635		   ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
5636		    (fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
5637		   "transfer fr to gr")
5638
5639(define-pmacro (nextreg hw r offset) (reg hw (add (index-of r) offset)))
5640
5641(define-pmacro (register-transfer-double-from-gr-semantics cond)
5642  (if cond
5643      (if (eq (index-of GRj) 0)
5644	  (sequence ()
5645		    (set FRintk 0)
5646		    (set (nextreg h-fr_int FRintk 1) 0))
5647	  (sequence ()
5648		    (set FRintk GRj)
5649		    (set (nextreg h-fr_int FRintk 1) (nextreg h-gr GRj 1)))))
5650)
5651
5652(dni movgfd
5653     "move GR for FR double"
5654     ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
5655      (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
5656     "movgfd$pack $GRj,$FRintk"
5657     (+ pack FRintk OP_03 (rs-null) OPE1_16 GRj)
5658     (register-transfer-double-from-gr-semantics 1)
5659     ; TODO -- doesn't handle second register in the pair
5660     ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
5661      (fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
5662)
5663
5664(define-pmacro (register-transfer-double-to-gr-semantics cond)
5665  (if (andif (ne (index-of GRj) 0) cond)
5666      (sequence ()
5667		(set GRj FRintk)
5668		(set (nextreg h-gr GRj 1) (nextreg h-fr_int FRintk 1))))
5669)
5670
5671(dni movfgd
5672     "move FR for GR double"
5673     ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
5674      (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
5675     "movfgd$pack $FRintk,$GRj"
5676     (+ pack FRintk OP_03 (rs-null) OPE1_0E GRj)
5677     (register-transfer-double-to-gr-semantics 1)
5678     ; TODO -- doesn't handle second register in the pair
5679     ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
5680      (fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
5681)
5682
5683(dni movgfq
5684     "move GR for FR quad"
5685     ((UNIT I0) (FR500-MAJOR I-4) (MACH frv) FR-ACCESS)
5686     "movgfq$pack $GRj,$FRintk"
5687     (+ pack FRintk OP_03 (rs-null) OPE1_17 GRj)
5688     (if (eq (index-of GRj) 0)
5689	 (sequence ()
5690		   (set FRintk 0)
5691		   (set (reg h-fr_int (add (index-of FRintk) 1)) 0)
5692		   (set (reg h-fr_int (add (index-of FRintk) 2)) 0)
5693		   (set (reg h-fr_int (add (index-of FRintk) 3)) 0))
5694	 (sequence ()
5695		   (set FRintk GRj)
5696		   (set (reg h-fr_int (add (index-of FRintk) 1))
5697			(reg h-gr (add (index-of GRj)    1)))
5698		   (set (reg h-fr_int (add (index-of FRintk) 2))
5699			(reg h-gr (add (index-of GRj)    2)))
5700		   (set (reg h-fr_int (add (index-of FRintk) 3))
5701			(reg h-gr (add (index-of GRj)    3)))))
5702     ()
5703)
5704
5705(dni movfgq
5706     "move FR for GR quad"
5707     ((UNIT I0) (FR500-MAJOR I-4) (MACH frv) FR-ACCESS)
5708     "movfgq$pack $FRintk,$GRj"
5709     (+ pack FRintk OP_03 (rs-null) OPE1_0F GRj)
5710     (if (ne (index-of GRj) 0)
5711	 (sequence ()
5712		   (set GRj FRintk)
5713		   (set (reg h-gr (add (index-of GRj)    1))
5714			(reg h-fr_int (add (index-of FRintk) 1)))
5715		   (set (reg h-gr (add (index-of GRj)    2))
5716			(reg h-fr_int (add (index-of FRintk) 2)))
5717		   (set (reg h-gr (add (index-of GRj)    3))
5718			(reg h-fr_int (add (index-of FRintk) 3)))))
5719     ()
5720)
5721
5722(define-pmacro (conditional-register-transfer
5723		name op ope reg_src reg_targ pipe attrs	profile comment)
5724  (dni name
5725       (comment)
5726       (.splice (UNIT pipe) CONDITIONAL FR-ACCESS (.unsplice attrs))
5727       (.str name "$pack $" reg_src ",$" reg_targ ",$CCi,$cond")
5728       (+ pack reg_targ op (rs-null) CCi cond ope reg_src)
5729       (if (eq CCi (or cond 2))
5730	   (set reg_targ reg_src))
5731       profile
5732  )
5733)
5734
5735(conditional-register-transfer cmovgf OP_69 OPE4_0 GRj FRintk I0
5736			       ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
5737				(FR400-MAJOR I-4) (FR450-MAJOR I-4))
5738			       ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
5739				(fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
5740			       "transfer gr to fr")
5741(conditional-register-transfer cmovfg OP_69 OPE4_2 FRintk GRj I0
5742			       ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
5743				(FR400-MAJOR I-4) (FR450-MAJOR I-4))
5744			       ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
5745				(fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
5746			       "transfer fr to gr")
5747
5748
5749(dni cmovgfd
5750     "Conditional move GR to FR double"
5751     ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
5752      (FR400-MAJOR I-4) (FR450-MAJOR I-4) CONDITIONAL FR-ACCESS)
5753     "cmovgfd$pack $GRj,$FRintk,$CCi,$cond"
5754     (+ pack FRintk OP_69 (rs-null) CCi cond OPE4_1 GRj)
5755     (register-transfer-double-from-gr-semantics (eq CCi (or cond 2)))
5756     ; TODO -- doesn't handle extra registers in double
5757     ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
5758      (fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
5759)
5760
5761(dni cmovfgd
5762     "Conditional move FR to GR double"
5763     ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
5764      (FR400-MAJOR I-4) (FR450-MAJOR I-4) CONDITIONAL FR-ACCESS)
5765     "cmovfgd$pack $FRintk,$GRj,$CCi,$cond"
5766     (+ pack FRintk OP_69 (rs-null) CCi cond OPE4_3 GRj)
5767     (register-transfer-double-to-gr-semantics (eq CCi (or cond 2)))
5768     ; TODO -- doesn't handle second register in the pair
5769     ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
5770      (fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
5771)
5772
5773(define-pmacro (register-transfer-spr
5774		name op ope reg_src reg_targ unitname comment)
5775  (dni name
5776       (comment)
5777       ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
5778	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
5779       (.str name "$pack $" reg_src ",$" reg_targ)
5780       (+ pack reg_targ op ope reg_src)
5781       (set reg_targ reg_src)
5782       ((fr400 (unit unitname)) (fr450 (unit unitname))
5783	(fr500 (unit unitname)) (fr550 (unit unitname)))
5784  )
5785)
5786
5787(register-transfer-spr movgs OP_03 OPE1_06 GRj spr u-gr2spr "transfer gr->spr")
5788(register-transfer-spr movsg OP_03 OPE1_07 spr GRj u-spr2gr "transfer spr->gr")
5789
5790; Integer Branch Conditions
5791(define-pmacro (Inev cc) (const BI 0))
5792(define-pmacro (Ira  cc) (const BI 1))
5793(define-pmacro (Ieq  cc) (     zbit cc))
5794(define-pmacro (Ine  cc) (not (zbit cc)))
5795(define-pmacro (Ile  cc) (     orif (zbit cc) (xor (nbit cc) (vbit cc))))
5796(define-pmacro (Igt  cc) (not (orif (zbit cc) (xor (nbit cc) (vbit cc)))))
5797(define-pmacro (Ilt  cc) (     xor  (nbit cc) (vbit cc)))
5798(define-pmacro (Ige  cc) (not (xor  (nbit cc) (vbit cc))))
5799(define-pmacro (Ils  cc) (     orif (cbit cc) (zbit cc)))
5800(define-pmacro (Ihi  cc) (not (orif (cbit cc) (zbit cc))))
5801(define-pmacro (Ic   cc) (     cbit cc))
5802(define-pmacro (Inc  cc) (not (cbit cc)))
5803(define-pmacro (In   cc) (     nbit cc))
5804(define-pmacro (Ip   cc) (not (nbit cc)))
5805(define-pmacro (Iv   cc) (     vbit cc))
5806(define-pmacro (Inv  cc) (not (vbit cc)))
5807
5808; Float Branch Conditions
5809(define-pmacro (Fnev cc) (const BI 0))
5810(define-pmacro (Fra  cc) (const BI 1))
5811(define-pmacro (Fne  cc) (orif (lbit cc) (orif (gbit cc) (ubit cc))))
5812(define-pmacro (Feq  cc) (ebit cc))
5813(define-pmacro (Flg  cc) (orif (lbit cc) (gbit cc)))
5814(define-pmacro (Fue  cc) (orif (ebit cc) (ubit cc)))
5815(define-pmacro (Ful  cc) (orif (lbit cc) (ubit cc)))
5816(define-pmacro (Fge  cc) (orif (ebit cc) (gbit cc)))
5817(define-pmacro (Flt  cc) (lbit cc))
5818(define-pmacro (Fuge cc) (orif (ebit cc) (orif (gbit cc) (ubit cc))))
5819(define-pmacro (Fug  cc) (orif (gbit cc) (ubit cc)))
5820(define-pmacro (Fle  cc) (orif (ebit cc) (lbit cc)))
5821(define-pmacro (Fgt  cc) (gbit cc))
5822(define-pmacro (Fule cc) (orif (ebit cc) (orif (lbit cc) (ubit cc))))
5823(define-pmacro (Fu   cc) (ubit cc))
5824(define-pmacro (Fo   cc) (orif (ebit cc) (orif (lbit cc) (gbit cc))))
5825
5826(define-pmacro (conditional-branch-i prefix cc op cond comment)
5827  (dni (.sym prefix cc)
5828       (comment)
5829       ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
5830	(FR400-MAJOR B-1) (FR450-MAJOR B-1))
5831       (.str (.sym prefix cc) "$pack $ICCi_2,$hint,$label16")
5832       (+ pack (.sym ICC_ cc) ICCi_2 op hint label16)
5833       (sequence ()
5834		 (c-call VOID "@cpu@_model_branch" label16 hint)
5835		 (if (cond ICCi_2)
5836		     (set pc label16)))
5837       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5838	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
5839  )
5840)
5841
5842(dni bra
5843     "integer branch equal"
5844      ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
5845       (FR400-MAJOR B-1) (FR450-MAJOR B-1))
5846      "bra$pack $hint_taken$label16"
5847      (+ pack ICC_ra (ICCi_2-null) OP_06 hint_taken label16)
5848      (sequence ()
5849		(c-call VOID "@cpu@_model_branch" label16 hint_taken)
5850		(set pc label16))
5851      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5852       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5853)
5854
5855(dni bno
5856     "integer branch never"
5857      ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
5858       (FR400-MAJOR B-1) (FR450-MAJOR B-1))
5859      "bno$pack$hint_not_taken"
5860      (+ pack ICC_nev (ICCi_2-null) OP_06 hint_not_taken (label16-null))
5861      (c-call VOID "@cpu@_model_branch" label16 hint_not_taken)
5862      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5863       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5864)
5865
5866(conditional-branch-i b eq  OP_06 Ieq  "integer branch equal")
5867(conditional-branch-i b ne  OP_06 Ine  "integer branch not equal")
5868(conditional-branch-i b le  OP_06 Ile  "integer branch less or equal")
5869(conditional-branch-i b gt  OP_06 Igt  "integer branch greater")
5870(conditional-branch-i b lt  OP_06 Ilt  "integer branch less")
5871(conditional-branch-i b ge  OP_06 Ige  "integer branch greater or equal")
5872(conditional-branch-i b ls  OP_06 Ils  "integer branch less or equal unsigned")
5873(conditional-branch-i b hi  OP_06 Ihi  "integer branch greater unsigned")
5874(conditional-branch-i b c   OP_06 Ic   "integer branch carry set")
5875(conditional-branch-i b nc  OP_06 Inc  "integer branch carry clear")
5876(conditional-branch-i b n   OP_06 In   "integer branch negative")
5877(conditional-branch-i b p   OP_06 Ip   "integer branch positive")
5878(conditional-branch-i b v   OP_06 Iv   "integer branch overflow set")
5879(conditional-branch-i b nv  OP_06 Inv  "integer branch overflow clear")
5880
5881(define-pmacro (conditional-branch-f prefix cc op cond comment)
5882  (dni (.sym prefix cc)
5883       (comment)
5884       ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
5885	(FR400-MAJOR B-1) (FR450-MAJOR B-1) FR-ACCESS)
5886       (.str (.sym prefix cc) "$pack $FCCi_2,$hint,$label16")
5887       (+ pack (.sym FCC_ cc) FCCi_2 op hint label16)
5888       (sequence ()
5889		 (c-call VOID "@cpu@_model_branch" label16 hint)
5890		 (if (cond FCCi_2) (set pc label16)))
5891       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5892	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
5893  )
5894)
5895
5896(dni fbra
5897     "float branch equal"
5898      ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
5899       (FR400-MAJOR B-1) (FR450-MAJOR B-1) FR-ACCESS)
5900      "fbra$pack $hint_taken$label16"
5901      (+ pack FCC_ra (FCCi_2-null) OP_07 hint_taken label16)
5902      (sequence ()
5903		(c-call VOID "@cpu@_model_branch" label16 hint_taken)
5904		(set pc label16))
5905      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5906       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5907)
5908
5909(dni fbno
5910     "float branch never"
5911      ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
5912       (FR400-MAJOR B-1) (FR450-MAJOR B-1) FR-ACCESS)
5913      "fbno$pack$hint_not_taken"
5914      (+ pack FCC_nev (FCCi_2-null) OP_07 hint_not_taken (label16-null))
5915      (c-call VOID "@cpu@_model_branch" label16 hint_not_taken)
5916      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5917       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5918)
5919
5920(conditional-branch-f fb ne  OP_07 Fne  "float branch not equal")
5921(conditional-branch-f fb eq  OP_07 Feq  "float branch equal")
5922(conditional-branch-f fb lg  OP_07 Flg  "float branch less or greater")
5923(conditional-branch-f fb ue  OP_07 Fue  "float branch unordered or equal")
5924(conditional-branch-f fb ul  OP_07 Ful  "float branch unordered or less")
5925(conditional-branch-f fb ge  OP_07 Fge  "float branch greater or equal")
5926(conditional-branch-f fb lt  OP_07 Flt  "float branch less")
5927(conditional-branch-f fb uge OP_07 Fuge "float branch unordered, greater,equal")
5928(conditional-branch-f fb ug  OP_07 Fug  "float branch unordered or greater")
5929(conditional-branch-f fb le  OP_07 Fle  "float branch less or equal")
5930(conditional-branch-f fb gt  OP_07 Fgt  "float branch greater")
5931(conditional-branch-f fb ule OP_07 Fule "float branch unordered, less or equal")
5932(conditional-branch-f fb u   OP_07 Fu   "float branch unordered")
5933(conditional-branch-f fb o   OP_07 Fo   "float branch ordered")
5934
5935(define-pmacro (ctrlr-branch-semantics cond ccond)
5936  (sequence ((SI tmp))
5937	    (set tmp (sub (spr-lcr) 1))
5938	    (set (spr-lcr) tmp)
5939	    (if cond
5940		(if (eq ccond 0)
5941		    (if (ne tmp 0)
5942			(set pc (spr-lr)))
5943		    (if (eq tmp 0)
5944			(set pc (spr-lr))))))
5945)
5946
5947(dni bctrlr
5948     "LCR conditional branch to lr"
5949     ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
5950      (FR400-MAJOR B-2) (FR450-MAJOR B-2))
5951     ("bctrlr$pack $ccond,$hint")
5952     (+ pack (cond-null) (ICCi_2-null) OP_0E hint OPE3_01 ccond (s12-null))
5953     (sequence ()
5954	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
5955	       (ctrlr-branch-semantics (const BI 1) ccond))
5956     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5957      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5958)
5959
5960(define-pmacro (conditional-branch-cclr prefix cc i-f op ope cond attr comment)
5961  (dni (.sym prefix cc lr)
5962       (comment)
5963       ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
5964	(FR400-MAJOR B-3) (FR450-MAJOR B-3) attr)
5965       (.str (.sym prefix cc lr) "$pack $" i-f "CCi_2,$hint")
5966       (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op hint ope
5967	  (ccond-null) (s12-null))
5968       (sequence ()
5969		 (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
5970		 (if (cond (.sym i-f CCi_2)) (set pc (spr-lr))))
5971       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5972	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
5973  )
5974)
5975
5976(dni bralr
5977     "integer cclr branch always"
5978     ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
5979      (FR400-MAJOR B-3) (FR450-MAJOR B-3))
5980     "bralr$pack$hint_taken"
5981     (+ pack ICC_ra (ICCi_2-null) OP_0E hint_taken OPE3_02 (ccond-null) (s12-null))
5982     (sequence ()
5983	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
5984	       (set pc (spr-lr)))
5985     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5986      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5987)
5988
5989(dni bnolr
5990     "integer cclr branch never"
5991     ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
5992      (FR400-MAJOR B-3) (FR450-MAJOR B-3))
5993     "bnolr$pack$hint_not_taken"
5994     (+ pack ICC_nev (ICCi_2-null) OP_0E hint_not_taken OPE3_02 (ccond-null) (s12-null))
5995     (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
5996     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
5997      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
5998)
5999
6000(conditional-branch-cclr b eq  I OP_0E OPE3_02 Ieq  NA "integer cclr branch equal")
6001(conditional-branch-cclr b ne  I OP_0E OPE3_02 Ine  NA "integer cclr branch not equal")
6002(conditional-branch-cclr b le  I OP_0E OPE3_02 Ile  NA "integer cclr branch less or equal")
6003(conditional-branch-cclr b gt  I OP_0E OPE3_02 Igt  NA "integer cclr branch greater")
6004(conditional-branch-cclr b lt  I OP_0E OPE3_02 Ilt  NA "integer cclr branch less")
6005(conditional-branch-cclr b ge  I OP_0E OPE3_02 Ige  NA "integer cclr branch greater or equal")
6006(conditional-branch-cclr b ls  I OP_0E OPE3_02 Ils  NA "integer cclr branch less or equal unsigned")
6007(conditional-branch-cclr b hi  I OP_0E OPE3_02 Ihi  NA "integer cclr branch greater unsigned")
6008(conditional-branch-cclr b c   I OP_0E OPE3_02 Ic   NA "integer cclr branch carry set")
6009(conditional-branch-cclr b nc  I OP_0E OPE3_02 Inc  NA "integer cclr branch carry clear")
6010(conditional-branch-cclr b n   I OP_0E OPE3_02 In   NA "integer cclr branch negative")
6011(conditional-branch-cclr b p   I OP_0E OPE3_02 Ip   NA "integer cclr branch positive")
6012(conditional-branch-cclr b v   I OP_0E OPE3_02 Iv   NA "integer cclr branch overflow set")
6013(conditional-branch-cclr b nv  I OP_0E OPE3_02 Inv  NA "integer cclr branch overflow clear")
6014
6015(dni fbralr
6016     "float cclr branch always"
6017     ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
6018      (FR400-MAJOR B-3) (FR450-MAJOR B-3) FR-ACCESS)
6019     "fbralr$pack$hint_taken"
6020     (+ pack FCC_ra (FCCi_2-null) OP_0E hint_taken OPE3_06 (ccond-null) (s12-null))
6021     (sequence ()
6022	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
6023	       (set pc (spr-lr)))
6024     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6025      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6026)
6027
6028(dni fbnolr
6029     "float cclr branch never"
6030     ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
6031      (FR400-MAJOR B-3) (FR450-MAJOR B-3) FR-ACCESS)
6032     "fbnolr$pack$hint_not_taken"
6033     (+ pack FCC_nev (FCCi_2-null) OP_0E hint_not_taken OPE3_06 (ccond-null) (s12-null))
6034     (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
6035     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6036      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6037)
6038
6039(conditional-branch-cclr fb eq  F OP_0E OPE3_06 Feq  FR-ACCESS "float cclr branch equal")
6040(conditional-branch-cclr fb ne  F OP_0E OPE3_06 Fne  FR-ACCESS "float cclr branch not equal")
6041(conditional-branch-cclr fb lg  F OP_0E OPE3_06 Flg  FR-ACCESS "float branch less or greater")
6042(conditional-branch-cclr fb ue  F OP_0E OPE3_06 Fue  FR-ACCESS "float branch unordered or equal")
6043(conditional-branch-cclr fb ul  F OP_0E OPE3_06 Ful  FR-ACCESS "float branch unordered or less")
6044(conditional-branch-cclr fb ge  F OP_0E OPE3_06 Fge  FR-ACCESS "float branch greater or equal")
6045(conditional-branch-cclr fb lt  F OP_0E OPE3_06 Flt  FR-ACCESS "float branch less")
6046(conditional-branch-cclr fb uge F OP_0E OPE3_06 Fuge FR-ACCESS "float branch unordered, greater, equal")
6047(conditional-branch-cclr fb ug  F OP_0E OPE3_06 Fug  FR-ACCESS "float branch unordered or greater")
6048(conditional-branch-cclr fb le  F OP_0E OPE3_06 Fle  FR-ACCESS "float branch less or equal")
6049(conditional-branch-cclr fb gt  F OP_0E OPE3_06 Fgt  FR-ACCESS "float branch greater")
6050(conditional-branch-cclr fb ule F OP_0E OPE3_06 Fule FR-ACCESS "float branch unordered, less or equal")
6051(conditional-branch-cclr fb u   F OP_0E OPE3_06 Fu   FR-ACCESS "float branch unordered")
6052(conditional-branch-cclr fb o   F OP_0E OPE3_06 Fo   FR-ACCESS "float branch ordered")
6053
6054(define-pmacro (conditional-branch-ctrlr prefix cc i-f op ope cond attr comment)
6055  (dni (.sym prefix cc lr)
6056       (comment)
6057       ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
6058	(FR400-MAJOR B-2) (FR450-MAJOR B-2) attr)
6059       (.str (.sym prefix cc lr) "$pack $" i-f "CCi_2,$ccond,$hint")
6060       (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op hint ope ccond (s12-null))
6061       (sequence ()
6062		 (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
6063		 (ctrlr-branch-semantics (cond (.sym i-f CCi_2)) ccond))
6064       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6065	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
6066  )
6067)
6068
6069(dni bcralr
6070     "integer ctrlr branch always"
6071     ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
6072      (FR400-MAJOR B-2) (FR450-MAJOR B-2))
6073     "bcralr$pack $ccond$hint_taken"
6074     (+ pack ICC_ra (ICCi_2-null) OP_0E hint_taken OPE3_03 ccond (s12-null))
6075     (sequence ()
6076	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
6077	       (ctrlr-branch-semantics (const BI 1) ccond))
6078     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6079      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6080)
6081
6082(dni bcnolr
6083     "integer ctrlr branch never"
6084     ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
6085      (FR400-MAJOR B-2) (FR450-MAJOR B-2))
6086     "bcnolr$pack$hint_not_taken"
6087     (+ pack ICC_nev (ICCi_2-null) OP_0E hint_not_taken OPE3_03 (ccond-null) (s12-null))
6088     (sequence ()
6089	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
6090	       (ctrlr-branch-semantics (const BI 0) ccond))
6091     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6092      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6093)
6094
6095(conditional-branch-ctrlr bc eq  I OP_0E OPE3_03 Ieq  NA "integer ctrlr branch equal")
6096(conditional-branch-ctrlr bc ne  I OP_0E OPE3_03 Ine  NA "integer ctrlr branch not equal")
6097(conditional-branch-ctrlr bc le  I OP_0E OPE3_03 Ile  NA "integer ctrlr branch less equal")
6098(conditional-branch-ctrlr bc gt  I OP_0E OPE3_03 Igt  NA "integer ctrlr branch greater")
6099(conditional-branch-ctrlr bc lt  I OP_0E OPE3_03 Ilt  NA "integer ctrlr branch less")
6100(conditional-branch-ctrlr bc ge  I OP_0E OPE3_03 Ige  NA "integer ctrlr branch greater equal")
6101(conditional-branch-ctrlr bc ls  I OP_0E OPE3_03 Ils  NA "integer ctrlr branch less equal unsigned")
6102(conditional-branch-ctrlr bc hi  I OP_0E OPE3_03 Ihi  NA "integer ctrlr branch greater unsigned")
6103(conditional-branch-ctrlr bc c   I OP_0E OPE3_03 Ic   NA "integer ctrlr branch carry set")
6104(conditional-branch-ctrlr bc nc  I OP_0E OPE3_03 Inc  NA "integer ctrlr branch carry clear")
6105(conditional-branch-ctrlr bc n   I OP_0E OPE3_03 In   NA "integer ctrlr branch negative")
6106(conditional-branch-ctrlr bc p   I OP_0E OPE3_03 Ip   NA "integer ctrlr branch positive")
6107(conditional-branch-ctrlr bc v   I OP_0E OPE3_03 Iv   NA "integer ctrlr branch overflow set")
6108(conditional-branch-ctrlr bc nv  I OP_0E OPE3_03 Inv  NA "integer ctrlr branch overflow clear")
6109
6110(dni fcbralr
6111     "float ctrlr branch always"
6112     ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
6113      (FR400-MAJOR B-2) (FR450-MAJOR B-2) FR-ACCESS)
6114     "fcbralr$pack $ccond$hint_taken"
6115     (+ pack FCC_ra (FCCi_2-null) OP_0E hint_taken OPE3_07 ccond (s12-null))
6116     (sequence ()
6117	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
6118	       (ctrlr-branch-semantics (const BI 1) ccond))
6119     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6120      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6121)
6122
6123(dni fcbnolr
6124     "float ctrlr branch never"
6125     ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
6126      (FR400-MAJOR B-2) (FR450-MAJOR B-2) FR-ACCESS)
6127     "fcbnolr$pack$hint_not_taken"
6128     (+ pack FCC_nev (FCCi_2-null) OP_0E hint_not_taken OPE3_07 (ccond-null) (s12-null))
6129     (sequence ()
6130	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
6131	       (ctrlr-branch-semantics (const BI 0) ccond))
6132     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6133      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6134)
6135
6136(conditional-branch-ctrlr fcb eq  F OP_0E OPE3_07 Feq  FR-ACCESS "float cclr branch equal")
6137(conditional-branch-ctrlr fcb ne  F OP_0E OPE3_07 Fne  FR-ACCESS "float cclr branch not equal")
6138(conditional-branch-ctrlr fcb lg  F OP_0E OPE3_07 Flg  FR-ACCESS "float branch less or greater")
6139(conditional-branch-ctrlr fcb ue  F OP_0E OPE3_07 Fue  FR-ACCESS "float branch unordered or equal")
6140(conditional-branch-ctrlr fcb ul  F OP_0E OPE3_07 Ful  FR-ACCESS "float branch unordered or less")
6141(conditional-branch-ctrlr fcb ge  F OP_0E OPE3_07 Fge  FR-ACCESS "float branch greater or equal")
6142(conditional-branch-ctrlr fcb lt  F OP_0E OPE3_07 Flt  FR-ACCESS "float branch less")
6143(conditional-branch-ctrlr fcb uge F OP_0E OPE3_07 Fuge FR-ACCESS "float branch unordered, greater, equal")
6144(conditional-branch-ctrlr fcb ug  F OP_0E OPE3_07 Fug  FR-ACCESS "float branch unordered or greater")
6145(conditional-branch-ctrlr fcb le  F OP_0E OPE3_07 Fle  FR-ACCESS "float branch less or equal")
6146(conditional-branch-ctrlr fcb gt  F OP_0E OPE3_07 Fgt  FR-ACCESS "float branch greater")
6147(conditional-branch-ctrlr fcb ule F OP_0E OPE3_07 Fule FR-ACCESS "float branch unordered, less or equal")
6148(conditional-branch-ctrlr fcb u   F OP_0E OPE3_07 Fu   FR-ACCESS "float branch unordered")
6149(conditional-branch-ctrlr fcb o   F OP_0E OPE3_07 Fo   FR-ACCESS "float branch ordered")
6150
6151(define-pmacro (jump-and-link-semantics base offset LI)
6152  (sequence ()
6153	    (if (eq LI 1)
6154		(c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1))
6155	    ; Target address gets aligned here
6156	    (set pc (and (add base offset) #xfffffffc))
6157	    (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
6158)
6159
6160(dni jmpl
6161     "jump and link"
6162     ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
6163      (FR400-MAJOR I-5) (FR450-MAJOR I-5))
6164     "jmpl$pack @($GRi,$GRj)"
6165     (+ pack (misc-null-1) (LI-off) OP_0C GRi (misc-null-2) GRj)
6166     (jump-and-link-semantics GRi GRj LI)
6167     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6168      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6169)
6170
6171(dann callann "call annotation" SI "call_annotation" "at")
6172
6173(dni calll
6174     "call and link"
6175     ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
6176      (FR400-MAJOR I-5) (FR450-MAJOR I-5))
6177     "calll$pack $callann($GRi,$GRj)"
6178     (+ pack (misc-null-1) (LI-on) OP_0C GRi (misc-null-2) GRj)
6179     (jump-and-link-semantics GRi GRj LI)
6180     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6181      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6182)
6183
6184(dni jmpil
6185     "jump immediate and link"
6186     ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
6187      (FR400-MAJOR I-5) (FR450-MAJOR I-5))
6188     "jmpil$pack @($GRi,$s12)"
6189     (+ pack (misc-null-1) (LI-off) OP_0D GRi s12)
6190     (jump-and-link-semantics GRi s12 LI)
6191     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6192      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6193)
6194
6195(dni callil
6196     "call immediate and link"
6197     ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
6198      (FR400-MAJOR I-5) (FR450-MAJOR I-5))
6199     "callil$pack @($GRi,$s12)"
6200     (+ pack (misc-null-1) (LI-on) OP_0D GRi s12)
6201     (jump-and-link-semantics GRi s12 LI)
6202     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6203      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6204)
6205
6206(dni call
6207     "call and link"
6208     ((UNIT B0) (FR500-MAJOR B-4) (FR550-MAJOR B-4)
6209      (FR400-MAJOR B-4) (FR450-MAJOR B-4))
6210     "call$pack $label24"
6211     (+ pack OP_0F label24)
6212     (sequence ()
6213	       (c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1)
6214	       (set pc label24)
6215	       (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
6216     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6217      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6218)
6219
6220(dni rett
6221    "return from trap"
6222    ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
6223     (FR400-MAJOR C-2) (FR450-MAJOR C-2) PRIVILEGED)
6224    "rett$pack $debug"
6225    (+ pack (misc-null-1) debug OP_05 (rs-null) (s12-null))
6226    ; frv_rett handles operating vs user mode
6227    (sequence ()
6228	      (set pc (c-call UWI "frv_rett" pc debug))
6229	      (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
6230    ()
6231)
6232
6233(dni rei
6234     "run exception instruction"
6235     ((UNIT C) (FR500-MAJOR C-1) (MACH frv) PRIVILEGED)
6236     "rei$pack $eir"
6237     (+ pack (rd-null) OP_37 eir (s12-null))
6238     (nop) ; for now
6239     ()
6240)
6241
6242(define-pmacro (trap-semantics cond base offset)
6243  (if cond
6244      (sequence ()
6245		; This is defered to frv_itrap because for the breakpoint
6246		; case we want to change as little of the machine state as
6247		; possible.
6248		;
6249		; PCSR=PC
6250		; PSR.PS=PSR.S
6251		; PSR.ET=0
6252		; if PSR.ESR==1
6253		;   SR0 through SR3=GR4 through GR7
6254		; TBR.TT=0x80 + ((GRi + s12) & 0x7f)
6255		; PC=TBR
6256		; We still should indicate what is modified by this insn.
6257		(clobber (spr-pcsr))
6258		(clobber psr_ps)
6259		(clobber psr_et)
6260		(clobber tbr_tt)
6261		(if (ne psr_esr (const 0))
6262		    (sequence ()
6263			      (clobber (spr-sr0))
6264			      (clobber (spr-sr1))
6265			      (clobber (spr-sr2))
6266			      (clobber (spr-sr3))))
6267		; frv_itrap handles operating vs user mode
6268		(c-call VOID "frv_itrap" pc base offset)))
6269)
6270
6271(define-pmacro (trap-r prefix cc i-f op ope cond attr comment)
6272  (dni (.sym prefix cc)
6273       (comment)
6274       ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6275	(FR400-MAJOR C-1) (FR450-MAJOR C-1) attr)
6276       (.str (.sym prefix cc) "$pack $" i-f "CCi_2,$GRi,$GRj")
6277       (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op GRi (misc-null-3) ope GRj)
6278       (trap-semantics (cond (.sym i-f CCi_2)) GRi GRj)
6279       ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6280	(fr500 (unit u-trap)) (fr550 (unit u-trap)))
6281  )
6282)
6283
6284(dni tra
6285     "integer trap always"
6286     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6287      (FR400-MAJOR C-1) (FR450-MAJOR C-1))
6288     "tra$pack $GRi,$GRj"
6289     (+ pack ICC_ra (ICCi_2-null) OP_04 GRi (misc-null-3) OPE4_0 GRj)
6290     (trap-semantics (const BI 1) GRi GRj)
6291     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6292      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6293)
6294
6295(dni tno
6296     "integer trap never"
6297     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6298      (FR400-MAJOR C-1) (FR450-MAJOR C-1))
6299     "tno$pack"
6300     (+ pack ICC_nev (ICCi_2-null) OP_04 (GRi-null) (misc-null-3) OPE4_0 (GRj-null))
6301     (trap-semantics (const BI 0) GRi GRj)
6302     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6303      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6304)
6305
6306(trap-r t eq  I OP_04 OPE4_0 Ieq  NA "integer trap equal")
6307(trap-r t ne  I OP_04 OPE4_0 Ine  NA "integer trap not equal")
6308(trap-r t le  I OP_04 OPE4_0 Ile  NA "integer trap less or equal")
6309(trap-r t gt  I OP_04 OPE4_0 Igt  NA "integer trap greater")
6310(trap-r t lt  I OP_04 OPE4_0 Ilt  NA "integer trap less")
6311(trap-r t ge  I OP_04 OPE4_0 Ige  NA "integer trap greater or equal")
6312(trap-r t ls  I OP_04 OPE4_0 Ils  NA "integer trap less or equal unsigned")
6313(trap-r t hi  I OP_04 OPE4_0 Ihi  NA "integer trap greater unsigned")
6314(trap-r t c   I OP_04 OPE4_0 Ic   NA "integer trap carry set")
6315(trap-r t nc  I OP_04 OPE4_0 Inc  NA "integer trap carry clear")
6316(trap-r t n   I OP_04 OPE4_0 In   NA "integer trap negative")
6317(trap-r t p   I OP_04 OPE4_0 Ip   NA "integer trap positive")
6318(trap-r t v   I OP_04 OPE4_0 Iv   NA "integer trap overflow set")
6319(trap-r t nv  I OP_04 OPE4_0 Inv  NA "integer trap overflow clear")
6320
6321(dni ftra
6322     "float trap always"
6323     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6324      (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
6325     "ftra$pack $GRi,$GRj"
6326     (+ pack FCC_ra (FCCi_2-null) OP_04 GRi (misc-null-3) OPE4_1 GRj)
6327     (trap-semantics (const BI 1) GRi GRj)
6328     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6329      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6330)
6331
6332(dni ftno
6333     "flost trap never"
6334     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6335      (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
6336     "ftno$pack"
6337     (+ pack FCC_nev (FCCi_2-null) OP_04 (GRi-null) (misc-null-3) OPE4_1 (GRj-null))
6338     (trap-semantics (const BI 0) GRi GRj)
6339     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6340      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6341)
6342
6343(trap-r ft ne  F OP_04 OPE4_1 Fne  FR-ACCESS "float trap not equal")
6344(trap-r ft eq  F OP_04 OPE4_1 Feq  FR-ACCESS "float trap equal")
6345(trap-r ft lg  F OP_04 OPE4_1 Flg  FR-ACCESS "float trap greater or less")
6346(trap-r ft ue  F OP_04 OPE4_1 Fue  FR-ACCESS "float trap unordered or equal")
6347(trap-r ft ul  F OP_04 OPE4_1 Ful  FR-ACCESS "float trap unordered or less")
6348(trap-r ft ge  F OP_04 OPE4_1 Fge  FR-ACCESS "float trap greater or equal")
6349(trap-r ft lt  F OP_04 OPE4_1 Flt  FR-ACCESS "float trap less")
6350(trap-r ft uge F OP_04 OPE4_1 Fuge FR-ACCESS "float trap unordered greater or equal")
6351(trap-r ft ug  F OP_04 OPE4_1 Fug  FR-ACCESS "float trap unordered or greater")
6352(trap-r ft le  F OP_04 OPE4_1 Fle  FR-ACCESS "float trap less or equal")
6353(trap-r ft gt  F OP_04 OPE4_1 Fgt  FR-ACCESS "float trap greater")
6354(trap-r ft ule F OP_04 OPE4_1 Fule FR-ACCESS "float trap unordered less or equal")
6355(trap-r ft u   F OP_04 OPE4_1 Fu   FR-ACCESS "float trap unordered")
6356(trap-r ft o   F OP_04 OPE4_1 Fo   FR-ACCESS "float trap ordered")
6357
6358(define-pmacro (trap-immed prefix cc i-f op cond attr comment)
6359  (dni (.sym prefix cc)
6360       (comment)
6361       ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6362	(FR400-MAJOR C-1) (FR450-MAJOR C-1) attr)
6363       (.str (.sym prefix cc) "$pack $" i-f "CCi_2,$GRi,$s12")
6364       (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op GRi s12)
6365       (trap-semantics (cond (.sym i-f CCi_2)) GRi s12)
6366       ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6367	(fr500 (unit u-trap)) (fr550 (unit u-trap)))
6368  )
6369)
6370
6371(dni tira
6372     "integer trap always"
6373     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6374      (FR400-MAJOR C-1) (FR450-MAJOR C-1))
6375     "tira$pack $GRi,$s12"
6376     (+ pack ICC_ra (ICCi_2-null) OP_1C GRi s12)
6377     (trap-semantics (const BI 1) GRi s12)
6378     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6379      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6380)
6381
6382(dni tino
6383     "integer trap never"
6384     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6385      (FR400-MAJOR C-1) (FR450-MAJOR C-1))
6386     "tino$pack"
6387     (+ pack ICC_nev (ICCi_2-null) OP_1C (GRi-null) (s12-null))
6388     (trap-semantics (const BI 0) GRi s12)
6389     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6390      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6391)
6392
6393(trap-immed ti eq  I OP_1C Ieq  NA "integer trap equal")
6394(trap-immed ti ne  I OP_1C Ine  NA "integer trap not equal")
6395(trap-immed ti le  I OP_1C Ile  NA "integer trap less or equal")
6396(trap-immed ti gt  I OP_1C Igt  NA "integer trap greater")
6397(trap-immed ti lt  I OP_1C Ilt  NA "integer trap less")
6398(trap-immed ti ge  I OP_1C Ige  NA "integer trap greater or equal")
6399(trap-immed ti ls  I OP_1C Ils  NA "integer trap less or equal unsigned")
6400(trap-immed ti hi  I OP_1C Ihi  NA "integer trap greater unsigned")
6401(trap-immed ti c   I OP_1C Ic   NA "integer trap carry set")
6402(trap-immed ti nc  I OP_1C Inc  NA "integer trap carry clear")
6403(trap-immed ti n   I OP_1C In   NA "integer trap negative")
6404(trap-immed ti p   I OP_1C Ip   NA "integer trap positive")
6405(trap-immed ti v   I OP_1C Iv   NA "integer trap overflow set")
6406(trap-immed ti nv  I OP_1C Inv  NA "integer trap overflow clear")
6407
6408(dni ftira
6409     "float trap always"
6410     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6411      (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
6412     "ftira$pack $GRi,$s12"
6413     (+ pack FCC_ra (ICCi_2-null) OP_1D GRi s12)
6414     (trap-semantics (const BI 1) GRi s12)
6415     ((fr400 (unit u-trap))
6416      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6417)
6418
6419(dni ftino
6420     "float trap never"
6421     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6422      (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
6423     "ftino$pack"
6424     (+ pack FCC_nev (FCCi_2-null) OP_1D (GRi-null) (s12-null))
6425     (trap-semantics (const BI 0) GRi s12)
6426     ((fr400 (unit u-trap)) (fr450 (unit u-trap))
6427      (fr500 (unit u-trap)) (fr550 (unit u-trap)))
6428)
6429
6430(trap-immed fti ne  F OP_1D Fne  FR-ACCESS "float trap not equal")
6431(trap-immed fti eq  F OP_1D Feq  FR-ACCESS "float trap equal")
6432(trap-immed fti lg  F OP_1D Flg  FR-ACCESS "float trap greater or less")
6433(trap-immed fti ue  F OP_1D Fue  FR-ACCESS "float trap unordered or equal")
6434(trap-immed fti ul  F OP_1D Ful  FR-ACCESS "float trap unordered or less")
6435(trap-immed fti ge  F OP_1D Fge  FR-ACCESS "float trap greater or equal")
6436(trap-immed fti lt  F OP_1D Flt  FR-ACCESS "float trap less")
6437(trap-immed fti uge F OP_1D Fuge FR-ACCESS "float trap unordered greater or equal")
6438(trap-immed fti ug  F OP_1D Fug  FR-ACCESS "float trap unordered or greater")
6439(trap-immed fti le  F OP_1D Fle  FR-ACCESS "float trap less or equal")
6440(trap-immed fti gt  F OP_1D Fgt  FR-ACCESS "float trap greater")
6441(trap-immed fti ule F OP_1D Fule FR-ACCESS "float trap unordered less or equal")
6442(trap-immed fti u   F OP_1D Fu   FR-ACCESS "float trap unordered")
6443(trap-immed fti o   F OP_1D Fo   FR-ACCESS "float trap ordered")
6444
6445(dni break
6446     "break trap"
6447     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6448      (FR400-MAJOR C-1) (FR450-MAJOR C-1))
6449     "break$pack"
6450     (+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_3 (GRj-null))
6451     (sequence ()
6452	       ; This is defered to frv_break because for the breakpoint
6453	       ; case we want to change as little of the machine state as
6454	       ; possible.
6455	       ;
6456	       ; BPCSR=PC
6457	       ; BPSR.BS=PSR.S
6458	       ; BPSR.BET=PSR.ET
6459	       ; PSR.S=1
6460	       ; PSR.ET=0
6461	       ; TBR.TT=0xff
6462	       ; PC=TBR
6463	       ; We still should indicate what is modified by this insn.
6464	       (clobber (spr-bpcsr))
6465	       (clobber bpsr_bs)
6466	       (clobber bpsr_bet)
6467	       (clobber psr_s)
6468	       (clobber psr_et)
6469	       (clobber tbr_tt)
6470	       (c-call VOID "frv_break"))
6471     ()
6472)
6473
6474(dni mtrap
6475     "media trap"
6476     ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
6477      (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
6478     "mtrap$pack"
6479     (+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_2 (GRj-null))
6480     (c-call VOID "frv_mtrap")
6481     ()
6482)
6483
6484(define-pmacro (condition-code-logic name operation ope comment)
6485  (dni name
6486       (comment)
6487       ((UNIT B01) (FR500-MAJOR B-6) (FR550-MAJOR B-6)
6488	(FR400-MAJOR B-6) (FR450-MAJOR B-6))
6489       (.str name "$pack $CRi,$CRj,$CRk")
6490       (+ pack (misc-null-6) CRk OP_0A (misc-null-7) CRi ope (misc-null-8) CRj)
6491       (set CRk (c-call UQI "@cpu@_cr_logic" operation CRi CRj))
6492       ()
6493  )
6494)
6495(define-pmacro (op-andcr)   0)
6496(define-pmacro (op-orcr)    1)
6497(define-pmacro (op-xorcr)   2)
6498(define-pmacro (op-nandcr)  3)
6499(define-pmacro (op-norcr)   4)
6500(define-pmacro (op-andncr)  5)
6501(define-pmacro (op-orncr)   6)
6502(define-pmacro (op-nandncr) 7)
6503(define-pmacro (op-norncr)  8)
6504
6505(define-pmacro (cr-true)  3)
6506(define-pmacro (cr-false) 2)
6507(define-pmacro (cr-undefined) 0)
6508
6509(condition-code-logic andcr   (op-andcr)   OPE1_08 "and   condition code regs")
6510(condition-code-logic orcr    (op-orcr)    OPE1_09 "or    condition code regs")
6511(condition-code-logic xorcr   (op-xorcr)   OPE1_0A "xor   condition code regs")
6512(condition-code-logic nandcr  (op-nandcr)  OPE1_0C "nand  condition code regs")
6513(condition-code-logic norcr   (op-norcr)   OPE1_0D "nor   condition code regs")
6514(condition-code-logic andncr  (op-andncr)  OPE1_10 "andn  condition code regs")
6515(condition-code-logic orncr   (op-orncr)   OPE1_11 "orn   condition code regs")
6516(condition-code-logic nandncr (op-nandncr) OPE1_14 "nandn condition code regs")
6517(condition-code-logic norncr  (op-norncr)  OPE1_15 "norn  condition code regs")
6518
6519(dni notcr
6520     ("not cccr register")
6521     ((UNIT B01) (FR500-MAJOR B-6) (FR550-MAJOR B-6)
6522      (FR400-MAJOR B-6) (FR450-MAJOR B-6))
6523     (.str notcr "$pack $CRj,$CRk")
6524     (+ pack (misc-null-6) CRk OP_0A (rs-null) OPE1_0B (misc-null-8) CRj)
6525     (set CRk (xor CRj 1))
6526     ()
6527)
6528
6529(define-pmacro (check-semantics cond cr)
6530  (if cond (set cr (cr-true)) (set cr (cr-false)))
6531)
6532
6533(define-pmacro (check-int-condition-code prefix cc op cond comment)
6534  (dni (.sym prefix cc)
6535       (comment)
6536       ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6537	(FR400-MAJOR B-5) (FR450-MAJOR B-5))
6538       (.str (.sym prefix cc) "$pack $ICCi_3,$CRj_int")
6539       (+ pack (.sym ICC_ cc) CRj_int op (misc-null-5) ICCi_3)
6540       (check-semantics (cond ICCi_3) CRj_int)
6541       ((fr400 (unit u-check)) (fr450 (unit u-check))
6542	(fr500 (unit u-check)) (fr550 (unit u-check)))
6543  )
6544)
6545
6546(dni ckra
6547     "check integer cc always"
6548     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6549      (FR400-MAJOR B-5) (FR450-MAJOR B-5))
6550     "ckra$pack $CRj_int"
6551     (+ pack ICC_ra CRj_int OP_08 (misc-null-5) (ICCi_3-null))
6552     (check-semantics (const BI 1) CRj_int)
6553     ((fr400 (unit u-check)) (fr450 (unit u-check))
6554      (fr500 (unit u-check)) (fr550 (unit u-check)))
6555)
6556
6557(dni ckno
6558     "check integer cc never"
6559     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6560      (FR400-MAJOR B-5) (FR450-MAJOR B-5))
6561     "ckno$pack $CRj_int"
6562     (+ pack ICC_nev CRj_int OP_08 (misc-null-5) (ICCi_3-null))
6563     (check-semantics (const BI 0) CRj_int)
6564     ((fr400 (unit u-check)) (fr450 (unit u-check))
6565      (fr500 (unit u-check)) (fr550 (unit u-check)))
6566)
6567
6568(check-int-condition-code ck eq  OP_08 Ieq  "check integer cc equal")
6569(check-int-condition-code ck ne  OP_08 Ine  "check integer cc not equal")
6570(check-int-condition-code ck le  OP_08 Ile  "check integer cc less or equal")
6571(check-int-condition-code ck gt  OP_08 Igt  "check integer cc greater")
6572(check-int-condition-code ck lt  OP_08 Ilt  "check integer cc less")
6573(check-int-condition-code ck ge  OP_08 Ige  "check integer cc greater or equal")
6574(check-int-condition-code ck ls  OP_08 Ils  "check integer cc less or equal unsigned")
6575(check-int-condition-code ck hi  OP_08 Ihi  "check integer cc greater unsigned")
6576(check-int-condition-code ck c   OP_08 Ic   "check integer cc carry set")
6577(check-int-condition-code ck nc  OP_08 Inc  "check integer cc carry clear")
6578(check-int-condition-code ck n   OP_08 In   "check integer cc negative")
6579(check-int-condition-code ck p   OP_08 Ip   "check integer cc positive")
6580(check-int-condition-code ck v   OP_08 Iv   "check integer cc overflow set")
6581(check-int-condition-code ck nv  OP_08 Inv  "check integer cc overflow clear")
6582
6583(define-pmacro (check-float-condition-code prefix cc op cond comment)
6584  (dni (.sym prefix cc)
6585       (comment)
6586       ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6587	(FR400-MAJOR B-5) (FR450-MAJOR B-5) FR-ACCESS)
6588       (.str (.sym prefix cc) "$pack $FCCi_3,$CRj_float")
6589       (+ pack (.sym FCC_ cc) CRj_float op (misc-null-5) FCCi_3)
6590       (check-semantics (cond FCCi_3) CRj_float)
6591       ((fr400 (unit u-check)) (fr450 (unit u-check))
6592	(fr500 (unit u-check)) (fr550 (unit u-check)))
6593  )
6594)
6595
6596(dni fckra
6597     "check float cc always"
6598     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6599      (FR400-MAJOR B-5) (FR450-MAJOR B-5) FR-ACCESS)
6600     "fckra$pack $CRj_float"
6601     (+ pack FCC_ra CRj_float OP_09 (misc-null-5) FCCi_3)
6602     (check-semantics (const BI 1) CRj_float)
6603     ((fr400 (unit u-check)) (fr450 (unit u-check))
6604      (fr500 (unit u-check)) (fr550 (unit u-check)))
6605)
6606
6607(dni fckno
6608     "check float cc never"
6609     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6610      (FR400-MAJOR B-5) (FR450-MAJOR B-5) FR-ACCESS)
6611     "fckno$pack $CRj_float"
6612     (+ pack FCC_nev CRj_float OP_09 (misc-null-5) FCCi_3)
6613     (check-semantics (const BI 0) CRj_float)
6614     ((fr400 (unit u-check)) (fr450 (unit u-check))
6615      (fr500 (unit u-check)) (fr550 (unit u-check)))
6616)
6617
6618(check-float-condition-code fck ne  OP_09 Fne  "check float cc not equal")
6619(check-float-condition-code fck eq  OP_09 Feq  "check float cc equal")
6620(check-float-condition-code fck lg  OP_09 Flg  "check float cc greater or less")
6621(check-float-condition-code fck ue  OP_09 Fue  "check float cc unordered or equal")
6622(check-float-condition-code fck ul  OP_09 Ful  "check float cc unordered or less")
6623(check-float-condition-code fck ge  OP_09 Fge  "check float cc greater or equal")
6624(check-float-condition-code fck lt  OP_09 Flt  "check float cc less")
6625(check-float-condition-code fck uge OP_09 Fuge "check float cc unordered greater or equal")
6626(check-float-condition-code fck ug  OP_09 Fug  "check float cc unordered or greater")
6627(check-float-condition-code fck le  OP_09 Fle  "check float cc less or equal")
6628(check-float-condition-code fck gt  OP_09 Fgt  "check float cc greater")
6629(check-float-condition-code fck ule OP_09 Fule "check float cc unordered less or equal")
6630(check-float-condition-code fck u   OP_09 Fu   "check float cc unordered")
6631(check-float-condition-code fck o   OP_09 Fo   "check float cc ordered")
6632
6633(define-pmacro (conditional-check-int-condition-code prefix cc op ope test comment)
6634  (dni (.sym prefix cc)
6635       (comment)
6636       ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6637	(FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL)
6638       (.str (.sym prefix cc) "$pack $ICCi_3,$CRj_int,$CCi,$cond")
6639       (+ pack (.sym ICC_ cc) CRj_int op (rs-null) CCi cond ope
6640	  (misc-null-9) ICCi_3)
6641       (if (eq CCi (or cond 2))
6642	   (check-semantics (test ICCi_3) CRj_int)
6643	   (set CRj_int (cr-undefined)))
6644       ((fr400 (unit u-check)) (fr450 (unit u-check))
6645	(fr500 (unit u-check)) (fr550 (unit u-check)))
6646  )
6647)
6648
6649(dni cckra
6650     "conditional check integer cc always"
6651     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6652      (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL)
6653     "cckra$pack $CRj_int,$CCi,$cond"
6654     (+ pack ICC_ra CRj_int OP_6A (rs-null) CCi cond OPE4_0
6655	(misc-null-9) (ICCi_3-null))
6656     (if (eq CCi (or cond 2))
6657	 (check-semantics (const BI 1) CRj_int)
6658	 (set CRj_int (cr-undefined)))
6659     ((fr400 (unit u-check)) (fr450 (unit u-check))
6660      (fr500 (unit u-check)) (fr550 (unit u-check)))
6661)
6662
6663(dni cckno
6664     "conditional check integer cc never"
6665     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6666      (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL)
6667     "cckno$pack $CRj_int,$CCi,$cond"
6668     (+ pack ICC_nev CRj_int OP_6A (rs-null) CCi cond OPE4_0
6669	(misc-null-9) (ICCi_3-null))
6670     (if (eq CCi (or cond 2))
6671	 (check-semantics (const BI 0) CRj_int)
6672	 (set CRj_int (cr-undefined)))
6673     ((fr400 (unit u-check)) (fr450 (unit u-check))
6674      (fr500 (unit u-check)) (fr550 (unit u-check)))
6675)
6676
6677(conditional-check-int-condition-code cck eq  OP_6A OPE4_0 Ieq  "check integer cc equal")
6678(conditional-check-int-condition-code cck ne  OP_6A OPE4_0 Ine  "check integer cc not equal")
6679(conditional-check-int-condition-code cck le  OP_6A OPE4_0 Ile  "check integer cc less or equal")
6680(conditional-check-int-condition-code cck gt  OP_6A OPE4_0 Igt  "check integer cc greater")
6681(conditional-check-int-condition-code cck lt  OP_6A OPE4_0 Ilt  "check integer cc less")
6682(conditional-check-int-condition-code cck ge  OP_6A OPE4_0 Ige  "check integer cc greater or equal")
6683(conditional-check-int-condition-code cck ls  OP_6A OPE4_0 Ils  "check integer cc less or equal unsigned")
6684(conditional-check-int-condition-code cck hi  OP_6A OPE4_0 Ihi  "check integer cc greater unsigned")
6685(conditional-check-int-condition-code cck c   OP_6A OPE4_0 Ic   "check integer cc carry set")
6686(conditional-check-int-condition-code cck nc  OP_6A OPE4_0 Inc  "check integer cc carry clear")
6687(conditional-check-int-condition-code cck n   OP_6A OPE4_0 In   "check integer cc negative")
6688(conditional-check-int-condition-code cck p   OP_6A OPE4_0 Ip   "check integer cc positive")
6689(conditional-check-int-condition-code cck v   OP_6A OPE4_0 Iv   "check integer cc overflow set")
6690(conditional-check-int-condition-code cck nv  OP_6A OPE4_0 Inv  "check integer cc overflow clear")
6691
6692(define-pmacro (conditional-check-float-condition-code prefix cc op ope test comment)
6693  (dni (.sym prefix cc)
6694       (comment)
6695       ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6696	(FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL FR-ACCESS)
6697       (.str (.sym prefix cc) "$pack $FCCi_3,$CRj_float,$CCi,$cond")
6698       (+ pack (.sym FCC_ cc) CRj_float op (rs-null) CCi cond ope
6699	  (misc-null-9) FCCi_3)
6700       (if (eq CCi (or cond 2))
6701	   (check-semantics (test FCCi_3) CRj_float)
6702	   (set CRj_float (cr-undefined)))
6703       ((fr400 (unit u-check)) (fr450 (unit u-check))
6704	(fr500 (unit u-check)) (fr550 (unit u-check)))
6705  )
6706)
6707
6708(dni cfckra
6709     "conditional check float cc always"
6710     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6711      (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL FR-ACCESS)
6712     "cfckra$pack $CRj_float,$CCi,$cond"
6713     (+ pack FCC_ra CRj_float OP_6A (rs-null) CCi cond OPE4_1
6714	(misc-null-9) (FCCi_3-null))
6715     (if (eq CCi (or cond 2))
6716	 (check-semantics (const BI 1) CRj_float)
6717	 (set CRj_float (cr-undefined)))
6718     ((fr400 (unit u-check)) (fr450 (unit u-check))
6719      (fr500 (unit u-check)) (fr550 (unit u-check)))
6720)
6721
6722(dni cfckno
6723     "conditional check float cc never"
6724     ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
6725      (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL FR-ACCESS)
6726     "cfckno$pack $CRj_float,$CCi,$cond"
6727     (+ pack FCC_nev CRj_float OP_6A (rs-null) CCi cond OPE4_1
6728	(misc-null-9) (FCCi_3-null))
6729     (if (eq CCi (or cond 2))
6730	 (check-semantics (const BI 0) CRj_float)
6731	 (set CRj_float (cr-undefined)))
6732     ((fr400 (unit u-check)) (fr450 (unit u-check))
6733      (fr500 (unit u-check)) (fr550 (unit u-check)))
6734)
6735
6736(conditional-check-float-condition-code cfck ne  OP_6A OPE4_1 Fne  "check float cc not equal")
6737(conditional-check-float-condition-code cfck eq  OP_6A OPE4_1 Feq  "check float cc equal")
6738(conditional-check-float-condition-code cfck lg  OP_6A OPE4_1 Flg  "check float cc greater or less")
6739(conditional-check-float-condition-code cfck ue  OP_6A OPE4_1 Fue  "check float cc unordered or equal")
6740(conditional-check-float-condition-code cfck ul  OP_6A OPE4_1 Ful  "check float cc unordered or less")
6741(conditional-check-float-condition-code cfck ge  OP_6A OPE4_1 Fge  "check float cc greater or equal")
6742(conditional-check-float-condition-code cfck lt  OP_6A OPE4_1 Flt  "check float cc less")
6743(conditional-check-float-condition-code cfck uge OP_6A OPE4_1 Fuge "check float cc unordered greater or equal")
6744(conditional-check-float-condition-code cfck ug  OP_6A OPE4_1 Fug  "check float cc unordered or greater")
6745(conditional-check-float-condition-code cfck le  OP_6A OPE4_1 Fle  "check float cc less or equal")
6746(conditional-check-float-condition-code cfck gt  OP_6A OPE4_1 Fgt  "check float cc greater")
6747(conditional-check-float-condition-code cfck ule OP_6A OPE4_1 Fule "check float cc unordered less or equal")
6748(conditional-check-float-condition-code cfck u   OP_6A OPE4_1 Fu   "check float cc unordered")
6749(conditional-check-float-condition-code cfck o   OP_6A OPE4_1 Fo   "check float cc ordered")
6750
6751(dni cjmpl
6752     "conditional jump and link"
6753     ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
6754      (FR400-MAJOR I-5) (FR450-MAJOR I-5) CONDITIONAL)
6755     "cjmpl$pack @($GRi,$GRj),$CCi,$cond"
6756     (+ pack (misc-null-1) (LI-off) OP_6A GRi CCi cond OPE4_2 GRj)
6757     (if (eq CCi (or cond 2))
6758	 (jump-and-link-semantics GRi GRj LI))
6759     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6760      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6761)
6762
6763(dni ccalll
6764     "conditional call and link"
6765     ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
6766      (FR400-MAJOR I-5) (FR450-MAJOR I-5) CONDITIONAL)
6767     "ccalll$pack @($GRi,$GRj),$CCi,$cond"
6768     (+ pack (misc-null-1) (LI-on) OP_6A GRi CCi cond OPE4_2 GRj)
6769     (if (eq CCi (or cond 2))
6770	 (jump-and-link-semantics GRi GRj LI))
6771     ((fr400 (unit u-branch)) (fr450 (unit u-branch))
6772      (fr500 (unit u-branch)) (fr550 (unit u-branch)))
6773)
6774
6775(define-pmacro (cache-invalidate name cache all op ope profile comment)
6776  (dni name
6777       (comment)
6778       ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
6779	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
6780       (.str name "$pack @($GRi,$GRj)")
6781       (+ pack (rd-null) op GRi ope GRj)
6782       (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) all)
6783       profile
6784  )
6785)
6786
6787(cache-invalidate ici insn 0 OP_03 OPE1_38
6788		  ((fr400 (unit u-ici)) (fr450 (unit u-ici))
6789		   (fr500 (unit u-ici)) (fr550 (unit u-ici)))
6790		  "invalidate insn cache")
6791(cache-invalidate dci data 0 OP_03 OPE1_3C
6792		  ((fr400 (unit u-dci)) (fr450 (unit u-dci))
6793		   (fr500 (unit u-dci)) (fr550 (unit u-dci)))
6794		  "invalidate data cache")
6795
6796(define-pmacro (cache-invalidate-entry name cache op ope profile comment)
6797  (dni name
6798       (comment)
6799       ((UNIT C) (MACH fr400,fr450,fr550) (FR550-MAJOR C-2)
6800	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
6801       (.str name "$pack @($GRi,$GRj),$ae")
6802       (+ pack (misc-null-1) ae op GRi ope GRj)
6803       (if (eq ae 0)
6804	   (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) -1) ; Invalid ae setting for this insn
6805	   (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) ae))
6806       profile
6807  )
6808)
6809
6810(cache-invalidate-entry icei insn OP_03 OPE1_39
6811			((fr400 (unit u-ici)) (fr450 (unit u-ici))
6812			 (fr550 (unit u-ici)))
6813			"invalidate insn cache entry")
6814(cache-invalidate-entry dcei data OP_03 OPE1_3A
6815			((fr400 (unit u-dci)) (fr450 (unit u-dci))
6816			 (fr550 (unit u-dci)))
6817			"invalidate data cache entry")
6818
6819(dni dcf
6820     "Data cache flush"
6821     ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
6822      (FR400-MAJOR C-2) (FR450-MAJOR C-2))
6823     "dcf$pack @($GRi,$GRj)"
6824     (+ pack (rd-null) OP_03 GRi OPE1_3D GRj)
6825     (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) 0)
6826     ((fr400 (unit u-dcf)) (fr450 (unit u-dcf))
6827      (fr500 (unit u-dcf)) (fr550 (unit u-dcf)))
6828)
6829
6830(dni dcef
6831     "Data cache entry flush"
6832     ((UNIT C) (MACH fr400,fr450,fr550) (FR550-MAJOR C-2)
6833      (FR400-MAJOR C-2) (FR450-MAJOR C-2))
6834     "dcef$pack @($GRi,$GRj),$ae"
6835     (+ pack (misc-null-1) ae OP_03 GRi OPE1_3B GRj)
6836     (if (eq ae 0)
6837	 (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) -1)
6838	 (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) ae))
6839     ((fr400 (unit u-dcf)) (fr450 (unit u-dcf)) (fr550 (unit u-dcf)))
6840)
6841
6842(define-pmacro (write-TLB name insn op ope comment)
6843  (dni name
6844       (comment)
6845       ((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
6846       (.str insn "$pack $GRk,@($GRi,$GRj)")
6847       (+ pack GRk op GRi ope GRj)
6848       (nop) ; for now
6849       ()
6850  )
6851)
6852
6853(write-TLB witlb witlb OP_03 OPE1_32 "write for insn TLB")
6854(write-TLB wdtlb wdtlb OP_03 OPE1_36 "write for data TLB")
6855
6856(define-pmacro (invalidate-TLB name insn op ope comment)
6857  (dni name
6858       (comment)
6859       ((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
6860       (.str insn "$pack @($GRi,$GRj)")
6861       (+ pack (rd-null) op GRi ope GRj)
6862       (nop) ; for now
6863       ()
6864  )
6865)
6866
6867(invalidate-TLB itlbi itlbi OP_03 OPE1_33 "invalidate insn TLB")
6868(invalidate-TLB dtlbi dtlbi OP_03 OPE1_37 "invalidate data TLB")
6869
6870(define-pmacro (cache-preload name cache pipe attrs op ope profile comment)
6871  (dni name
6872       (comment)
6873       (.splice (UNIT pipe) (FR500-MAJOR C-2)
6874		(FR400-MAJOR C-2) (.unsplice attrs))
6875       (.str name "$pack $GRi,$GRj,$lock")
6876       (+ pack (misc-null-1) lock op GRi ope GRj)
6877       (c-call VOID (.str "@cpu@_" cache "_cache_preload") GRi GRj lock)
6878       profile
6879  )
6880)
6881
6882(cache-preload icpl insn C ((FR550-MAJOR C-2) (FR450-MAJOR C-2)) OP_03 OPE1_30
6883	       ((fr400 (unit u-icpl)) (fr450 (unit u-icpl))
6884		(fr500 (unit u-icpl)) (fr550 (unit u-icpl)))
6885	       "preload insn cache")
6886(cache-preload dcpl data DCPL ((FR550-MAJOR I-8) (FR450-MAJOR I-2)) OP_03 OPE1_34
6887	       ((fr400 (unit u-dcpl)) (fr450 (unit u-dcpl))
6888		(fr500 (unit u-dcpl)) (fr550 (unit u-dcpl)))
6889	       "preload data cache")
6890
6891(define-pmacro (cache-unlock name cache op ope profile comment)
6892  (dni name
6893       (comment)
6894       ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
6895	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
6896       (.str name "$pack $GRi")
6897       (+ pack (rd-null) op GRi ope (GRj-null))
6898       (c-call VOID (.str "@cpu@_" cache "_cache_unlock") GRi)
6899       profile
6900  )
6901)
6902
6903(cache-unlock icul insn OP_03 OPE1_31
6904	      ((fr400 (unit u-icul)) (fr450 (unit u-icul))
6905	       (fr500 (unit u-icul)) (fr550 (unit u-icul)))
6906	      "unlock insn cache")
6907(cache-unlock dcul data OP_03 OPE1_35
6908	      ((fr400 (unit u-dcul)) (fr450 (unit u-dcul))
6909	       (fr500 (unit u-dcul)) (fr550 (unit u-dcul)))
6910	      "unlock data cache")
6911
6912(define-pmacro (barrier name insn op ope profile comment)
6913  (dni name
6914       (comment)
6915       ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
6916	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
6917       (.str insn "$pack")
6918       (+ pack (rd-null) op (rs-null) ope (GRj-null))
6919       (nop) ; sufficient implementation
6920       profile
6921  )
6922)
6923
6924(barrier bar    bar    OP_03 OPE1_3E
6925	 ((fr400 (unit u-barrier)) (fr450 (unit u-barrier))
6926	  (fr500 (unit u-barrier)))
6927	 "barrier")
6928(barrier membar membar OP_03 OPE1_3F
6929	 ((fr400 (unit u-membar)) (fr450 (unit u-membar))
6930	  (fr500 (unit u-membar)))
6931	 "memory barrier")
6932
6933; Load real address instructions
6934(define-pmacro (load-real-address name insn what op ope)
6935  (dni name
6936       (.str "Load real address of " what)
6937       ((UNIT C) (FR450-MAJOR C-2) (MACH fr450))
6938       (.str insn "$pack $GRi,$GRk,$LRAE,$LRAD,$LRAS")
6939       (+ pack GRk op GRi ope LRAE LRAD LRAS (LRA-null))
6940       (nop) ; not simulated
6941       ()
6942  )
6943)
6944
6945(load-real-address lrai "lrai" "instruction" OP_03 OPE1_20)
6946(load-real-address lrad "lrad" "data" OP_03 OPE1_21)
6947
6948(dni tlbpr
6949     "TLB Probe"
6950     ((UNIT C) (FR450-MAJOR C-2) (MACH fr450))
6951     "tlbpr$pack $GRi,$GRj,$TLBPRopx,$TLBPRL"
6952     (+ pack (TLBPR-null) TLBPRopx TLBPRL OP_03 GRi OPE1_24 GRj)
6953     (nop) ; not simulated
6954     ()
6955)
6956
6957; Coprocessor operations
6958(define-pmacro (cop-op num op)
6959  (dni (.sym cop num)
6960       "Coprocessor operation"
6961       ((UNIT C) (FR500-MAJOR C-2) (MACH frv))
6962       (.str "cop" num "$pack $s6_1,$CPRi,$CPRj,$CPRk")
6963       (+ pack CPRk op CPRi s6_1 CPRj)
6964       (nop) ; sufficient implementation
6965       ()
6966  )
6967)
6968
6969(cop-op 1 OP_7E)
6970(cop-op 2 OP_7F)
6971
6972(define-pmacro (clear-ne-flag-semantics target_index is_float)
6973  (c-call VOID "@cpu@_clear_ne_flags" target_index is_float)
6974)
6975
6976(define-pmacro (clear-ne-flag-r name op ope reg is_float attr profile comment)
6977  (dni name
6978       (comment)
6979       ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH simple,tomcat,fr500,fr550,frv) attr)
6980       (.str name "$pack $" reg "k")
6981       (+ pack (.sym reg k) op (rs-null) ope (GRj-null))
6982       (sequence ()
6983		 ; hack to get this referenced for profiling
6984		 (c-raw-call VOID "frv_ref_SI" (.sym reg k))
6985		 (clear-ne-flag-semantics (index-of (.sym reg k)) is_float))
6986       profile
6987  )
6988)
6989
6990(clear-ne-flag-r clrgr OP_0A OPE1_00 GR 0 NA
6991		 ((fr500 (unit u-clrgr)) (fr550 (unit u-clrgr)))
6992		 "Clear GR NE flag")
6993(clear-ne-flag-r clrfr OP_0A OPE1_02 FR 1 FR-ACCESS
6994		 ((fr500 (unit u-clrfr)) (fr550 (unit u-clrfr)))
6995		 "Clear FR NE flag")
6996
6997(define-pmacro (clear-ne-flag-all name op ope is_float attr profile comment)
6998  (dni name
6999       (comment)
7000       ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH simple,tomcat,fr500,fr550,frv) attr)
7001       (.str name "$pack")
7002       (+ pack (rd-null) op (rs-null) ope (GRj-null))
7003       (clear-ne-flag-semantics -1 is_float)
7004       profile
7005  )
7006)
7007
7008(clear-ne-flag-all clrga OP_0A OPE1_01 0 NA
7009		 ((fr500 (unit u-clrgr)) (fr550 (unit u-clrgr)))
7010		   "Clear GR NE flag ALL")
7011(clear-ne-flag-all clrfa OP_0A OPE1_03 1 FR-ACCESS
7012		 ((fr500 (unit u-clrfr)) (fr550 (unit u-clrfr)))
7013		   "Clear FR NE flag ALL")
7014
7015(define-pmacro (commit-semantics target_index is_float)
7016  (c-call VOID "@cpu@_commit" target_index is_float)
7017)
7018
7019(define-pmacro (commit-r name op ope reg is_float attr comment)
7020  (dni name
7021       (comment)
7022       ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH frv,fr500,fr550) attr)
7023       (.str name "$pack $" reg "k")
7024       (+ pack (.sym reg k) op (rs-null) ope (GRj-null))
7025       (commit-semantics (index-of (.sym reg k)) is_float)
7026       ((fr500 (unit u-commit)) (fr550 (unit u-commit)))
7027  )
7028)
7029
7030(commit-r commitgr OP_0A OPE1_04 GR 0 NA        "commit exceptions, specific GR")
7031(commit-r commitfr OP_0A OPE1_06 FR 1 FR-ACCESS "commit exceptions, specific FR")
7032
7033(define-pmacro (commit name op ope is_float attr comment)
7034  (dni name
7035       (comment)
7036       ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH frv,fr500,fr550) attr)
7037       (.str name "$pack")
7038       (+ pack (rd-null) op (rs-null) ope (GRj-null))
7039       (commit-semantics -1 is_float)
7040       ((fr500 (unit u-commit)) (fr550 (unit u-commit)))
7041  )
7042)
7043
7044(commit commitga OP_0A OPE1_05 0 NA        "commit exceptions, any GR")
7045(commit commitfa OP_0A OPE1_07 1 FR-ACCESS "commit exceptions, any FR")
7046
7047(define-pmacro (floating-point-conversion
7048		name op ope conv mode src targ attr comment)
7049  (dni name
7050       (comment)
7051       (.splice (UNIT FMALL) (FR500-MAJOR F-1) (.unsplice attr))
7052       (.str name "$pack $" src ",$" targ)
7053       (+ pack targ op (rs-null) ope src)
7054       (set targ (conv mode FPCONV-DEFAULT src))
7055       ((fr500 (unit u-float-convert)) (fr550 (unit u-float-convert)))
7056  )
7057)
7058
7059(floating-point-conversion fitos OP_79 OPE1_00 float SF FRintj FRk
7060			   ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7061			   "Convert Integer to Single")
7062(floating-point-conversion fstoi OP_79 OPE1_01 fix   SI FRj FRintk
7063			   ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7064			   "Convert Single  to Integer")
7065(floating-point-conversion fitod OP_7A OPE1_00 float DF FRintj FRdoublek
7066			   ((MACH frv))
7067			   "Convert Integer to Double")
7068(floating-point-conversion fdtoi OP_7A OPE1_01 fix   SI FRdoublej FRintk
7069			   ((MACH frv))
7070			   "Convert Double to Integer")
7071
7072(define-pmacro (floating-point-dual-conversion
7073		name op ope conv mode src src_hw targ targ_hw attr comment)
7074  (dni name
7075       (comment)
7076       ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1) attr)
7077       (.str name "$pack $" src ",$" targ)
7078       (+ pack targ op (rs-null) ope src)
7079       (sequence ()
7080		 (set targ (conv mode FPCONV-DEFAULT src))
7081		 (set (nextreg targ_hw targ 1)
7082		      (conv mode FPCONV-DEFAULT (nextreg src_hw src 1))))
7083       ((fr500 (unit u-float-dual-convert)))
7084  )
7085)
7086
7087(floating-point-dual-conversion fditos OP_79 OPE1_10 float SF FRintj h-fr_int FRk h-fr NA "Dual Convert Integer to Single")
7088(floating-point-dual-conversion fdstoi OP_79 OPE1_11 fix   SI FRj h-fr FRintk h-fr_int NA "Dual Convert Single  to Integer")
7089
7090(define-pmacro (ne-floating-point-dual-conversion
7091		name op ope conv mode src src_hw targ targ_hw attr comment)
7092  (dni name
7093       (comment)
7094       ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1) NON-EXCEPTING attr)
7095       (.str name "$pack $" src ",$" targ)
7096       (+ pack targ op (rs-null) ope src)
7097       (sequence ()
7098		 (c-call VOID "@cpu@_set_ne_index" (index-of targ))
7099		 (set targ (conv mode FPCONV-DEFAULT src))
7100		 (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 1))
7101		 (set (nextreg targ_hw targ 1)
7102		      (conv mode FPCONV-DEFAULT (nextreg src_hw src 1))))
7103       ((fr500 (unit u-float-dual-convert)))
7104  )
7105)
7106
7107(ne-floating-point-dual-conversion nfditos OP_79 OPE1_30 float SF FRintj h-fr_int FRk h-fr NA "Non excepting dual Convert Integer to Single")
7108(ne-floating-point-dual-conversion nfdstoi OP_79 OPE1_31 fix   SI FRj h-fr FRintk h-fr_int NA "Non excepting dual Convert Single  to Integer")
7109
7110(define-pmacro (conditional-floating-point-conversion
7111		name op ope conv mode src targ comment)
7112  (dni name
7113       (comment)
7114       ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7115       (.str name "$pack $" src ",$" targ ",$CCi,$cond")
7116       (+ pack targ op (rs-null) CCi cond ope src)
7117       (if (eq CCi (or cond 2))
7118	   (set targ (conv mode FPCONV-DEFAULT src)))
7119       ((fr500 (unit u-float-convert)) (fr550 (unit u-float-convert)))
7120  )
7121)
7122
7123(conditional-floating-point-conversion cfitos OP_6B OPE4_0 float SF FRintj FRk "Conditional convert Integer to Single")
7124(conditional-floating-point-conversion cfstoi OP_6B OPE4_1 fix   SI FRj FRintk "Conditional convert Single to Integer")
7125
7126(define-pmacro (ne-floating-point-conversion
7127		name op ope conv mode src targ comment)
7128  (dni name
7129       (comment)
7130       ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7131       (.str name "$pack $" src ",$" targ)
7132       (+ pack targ op (rs-null) ope src)
7133       (sequence ()
7134		 (c-call VOID "@cpu@_set_ne_index" (index-of targ))
7135		 (set targ (conv mode FPCONV-DEFAULT src)))
7136       ((fr500 (unit u-float-convert)) (fr550 (unit u-float-convert)))
7137  )
7138)
7139
7140(ne-floating-point-conversion nfitos OP_79 OPE1_20 float SF FRintj FRk "NE convert Integer to Single")
7141(ne-floating-point-conversion nfstoi OP_79 OPE1_21 fix   SI FRj FRintk "NE convert Single to Integer")
7142
7143(register-transfer fmovs OP_79 OPE1_02
7144		   FRj FRk FMALL
7145		   ((FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7146		   ((fr500 (unit u-fr2fr)))
7147		   "Move Single Float")
7148(register-transfer fmovd OP_7A OPE1_02
7149		   ; TODO -- unit doesn't handle extra register
7150		   FRdoublej FRdoublek FM01
7151		   ((FR500-MAJOR F-1) (MACH frv))
7152		   ((fr500 (unit u-fr2fr)) (fr550 (unit u-fr2fr)))
7153		   "Move Double Float")
7154
7155(dni fdmovs
7156     "Dual move single float"
7157     ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1))
7158     "fdmovs$pack $FRj,$FRk"
7159     (+ pack FRk OP_79 (rs-null) OPE1_12 FRj)
7160     (sequence ()
7161	       (set FRk FRj)
7162	       (set (nextreg h-fr FRk 1) (nextreg h-fr FRj 1)))
7163     ; TODO -- unit doesn't handle extra register
7164     ((fr500 (unit u-fr2fr)))
7165)
7166
7167(conditional-register-transfer cfmovs OP_6C OPE4_0 FRj FRk FMALL
7168			       ((FR500-MAJOR F-1) (FR550-MAJOR F-2)
7169				(MACH simple,tomcat,fr500,fr550,frv))
7170			       ((fr500 (unit u-fr2fr)) (fr550 (unit u-fr2fr)))
7171			       "Conditional move Single Float")
7172
7173(define-pmacro (floating-point-neg name src targ op ope attr comment)
7174  (dni name
7175       (comment)
7176       (.splice (UNIT FMALL) (FR500-MAJOR F-1) (.unsplice attr))
7177       (.str name "$pack $" src ",$" targ)
7178       (+ pack src op (rs-null) ope targ)
7179       (set targ (neg src))
7180       ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7181  )
7182)
7183
7184(floating-point-neg fnegs FRj FRk OP_79 OPE1_03 ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv)) "Floating point negate, single")
7185(floating-point-neg fnegd FRdoublej FRdoublek OP_7A OPE1_03 ((MACH frv)) "Floating point negate, double")
7186
7187(dni fdnegs
7188     "Floating point dual negate, single"
7189     ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1))
7190     "fdnegs$pack $FRj,$FRk"
7191     (+ pack FRk OP_79 (rs-null) OPE1_13 FRj)
7192     (sequence ()
7193	       (set FRk (neg FRj))
7194	       (set (nextreg h-fr FRk 1) (neg (nextreg h-fr FRj 1))))
7195     ((fr500 (unit u-float-dual-arith)))
7196)
7197
7198(dni cfnegs
7199     "Conditional floating point negate, single"
7200     ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7201     "cfnegs$pack $FRj,$FRk,$CCi,$cond"
7202     (+ pack FRj OP_6C (rs-null) CCi cond OPE4_1 FRk)
7203     (if (eq CCi (or cond 2))
7204	 (set FRk (neg FRj)))
7205     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7206)
7207
7208(define-pmacro (float-abs name src targ op ope attr comment)
7209  (dni name
7210       (comment)
7211       (.splice (UNIT FMALL) (FR500-MAJOR F-1) (.unsplice attr))
7212       (.str name "$pack $" src ",$" targ )
7213       (+ pack targ op (rs-null) ope src)
7214       (set targ (abs src))
7215       ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7216  )
7217)
7218
7219(float-abs fabss FRj FRk OP_79 OPE1_04 ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv)) "Float absolute value, single")
7220(float-abs fabsd FRdoublej FRdoublek OP_7A OPE1_04 ((MACH frv)) "Float absolute value, double")
7221
7222(dni fdabss
7223     "Floating point dual absolute value, single"
7224     ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1))
7225     "fdabss$pack $FRj,$FRk"
7226     (+ pack FRk OP_79 (rs-null) OPE1_14 FRj)
7227     (sequence ()
7228	       (set FRk (abs FRj))
7229	       (set (nextreg h-fr FRk 1) (abs (nextreg h-fr FRj 1))))
7230     ((fr500 (unit u-float-dual-arith)))
7231)
7232
7233(dni cfabss
7234     "Conditional floating point absolute value, single"
7235     ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7236     "cfabss$pack $FRj,$FRk,$CCi,$cond"
7237     (+ pack FRj OP_6C (rs-null) CCi cond OPE4_2 FRk)
7238     (if (eq CCi (or cond 2))
7239	 (set FRk (abs FRj)))
7240     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7241)
7242
7243(dni fsqrts
7244     "Square root single"
7245     ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
7246     "fsqrts$pack $FRj,$FRk"
7247     (+ pack FRk OP_79 (rs-null) OPE1_05 FRj)
7248     (set FRk (sqrt SF FRj))
7249     ((fr500 (unit u-float-sqrt)) (fr550 (unit u-float-sqrt)))
7250)
7251
7252(dni fdsqrts
7253     "Dual square root single"
7254     ((MACH frv) (UNIT FM01) (FR500-MAJOR F-4))
7255     "fdsqrts$pack $FRj,$FRk"
7256     (+ pack FRk OP_79 (rs-null) OPE1_15 FRj)
7257     (sequence ()
7258	       (set FRk (sqrt SF FRj))
7259	       (set (nextreg h-fr FRk 1) (sqrt (nextreg h-fr FRj 1))))
7260     ((fr500 (unit u-float-dual-sqrt)))
7261)
7262
7263(dni nfdsqrts
7264     "Non excepting Dual square root single"
7265     ((MACH frv) (UNIT FM01) (FR500-MAJOR F-4) NON-EXCEPTING)
7266     "nfdsqrts$pack $FRj,$FRk"
7267     (+ pack FRk OP_79 (rs-null) OPE1_35 FRj)
7268     (sequence ()
7269	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7270	       (set FRk (sqrt SF FRj))
7271	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
7272	       (set (nextreg h-fr FRk 1) (sqrt (nextreg h-fr FRj 1))))
7273     ((fr500 (unit u-float-dual-sqrt)))
7274)
7275
7276(dni fsqrtd
7277     "Square root double"
7278     ((UNIT FM01) (FR500-MAJOR F-4) (MACH frv))
7279     "fsqrtd$pack $FRdoublej,$FRdoublek"
7280     (+ pack FRdoublek OP_7A (rs-null) OPE1_05 FRdoublej)
7281     (set FRdoublek (sqrt DF FRdoublej))
7282     ((fr500 (unit u-float-sqrt)))
7283)
7284
7285(dni cfsqrts
7286     "Conditional square root single"
7287     ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
7288     "cfsqrts$pack $FRj,$FRk,$CCi,$cond"
7289     (+ pack FRk OP_6E (rs-null) CCi cond OPE4_2 FRj)
7290     (if (eq CCi (or cond 2))
7291	 (set FRk (sqrt SF FRj)))
7292     ((fr500 (unit u-float-sqrt)) (fr550 (unit u-float-sqrt)))
7293)
7294
7295(dni nfsqrts
7296     "Non exception square root, single"
7297     ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
7298     "nfsqrts$pack $FRj,$FRk"
7299     (+ pack FRk OP_79 (rs-null) OPE1_25 FRj)
7300     (sequence ()
7301	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7302	       (set FRk (sqrt SF FRj)))
7303     ((fr500 (unit u-float-sqrt)) (fr550 (unit u-float-sqrt)))
7304)
7305
7306(define-pmacro (float-binary-op-s name pipe attr operation op ope comment)
7307  (dni name
7308       (comment)
7309       (.splice (UNIT pipe) (MACH simple,tomcat,fr500,fr550,frv) (.unsplice attr))
7310       (.str name "$pack $FRi,$FRj,$FRk")
7311       (+ pack FRk op FRi ope FRj)
7312       (set FRk (operation FRi FRj))
7313       ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7314  )
7315)
7316
7317(float-binary-op-s fadds FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) add OP_79 OPE1_06 "add single float")
7318(float-binary-op-s fsubs FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) sub OP_79 OPE1_07 "sub single float")
7319(float-binary-op-s fmuls FM01  ((FR500-MAJOR F-3) (FR550-MAJOR F-3)) mul OP_79 OPE1_08 "mul single float")
7320
7321(dni fdivs
7322     "div single float"
7323     ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
7324     "fdivs$pack $FRi,$FRj,$FRk"
7325     (+ pack FRk OP_79 FRi OPE1_09 FRj)
7326     (set FRk (div FRi FRj))
7327     ((fr500 (unit u-float-div))
7328      (fr550 (unit u-float-div)))
7329)
7330
7331(define-pmacro (float-binary-op-d name operation op ope major comment)
7332  (dni name
7333       (comment)
7334       ((UNIT FMALL) (FR500-MAJOR major) (MACH frv))
7335       (.str name "$pack $FRdoublei,$FRdoublej,$FRdoublek")
7336       (+ pack FRdoublek op FRdoublei ope FRdoublej)
7337       (set FRdoublek (operation FRdoublei FRdoublej))
7338       ((fr500 (unit u-float-arith)))
7339  )
7340)
7341
7342(float-binary-op-d faddd add OP_7A OPE1_06 F-2 "add double float")
7343(float-binary-op-d fsubd sub OP_7A OPE1_07 F-2 "sub double float")
7344(float-binary-op-d fmuld mul OP_7A OPE1_08 F-3 "mul double float")
7345(float-binary-op-d fdivd div OP_7A OPE1_09 F-4 "div double float")
7346
7347(define-pmacro (conditional-float-binary-op name pipe attr operation op ope profile comment)
7348  (dni name
7349       (comment)
7350       (.splice (UNIT pipe) (MACH simple,tomcat,fr500,fr550,frv)
7351		(.unsplice attr))
7352       (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
7353       (+ pack FRk op FRi CCi cond ope FRj)
7354       (if (eq CCi (or cond 2))
7355	   (set FRk (operation FRi FRj)))
7356       profile
7357  )
7358)
7359
7360(conditional-float-binary-op cfadds FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) add OP_6D OPE4_0
7361			     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7362			     "cond add single")
7363(conditional-float-binary-op cfsubs FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) sub OP_6D OPE4_1
7364			     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7365			     "cond sub single")
7366(conditional-float-binary-op cfmuls FM01  ((FR500-MAJOR F-3) (FR550-MAJOR F-3)) mul OP_6E OPE4_0
7367			     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7368			     "cond mul single")
7369(conditional-float-binary-op cfdivs FM01  ((FR500-MAJOR F-4) (FR550-MAJOR F-3)) div OP_6E OPE4_1
7370			     ((fr500 (unit u-float-div)) (fr550 (unit u-float-div)))
7371			     "cond div single")
7372
7373(define-pmacro (ne-float-binary-op name pipe attr operation op ope profile comment)
7374  (dni name
7375       (comment)
7376       (.splice (UNIT pipe) (MACH simple,tomcat,fr500,fr550,frv)
7377		(.unsplice attr))
7378       (.str name "$pack $FRi,$FRj,$FRk")
7379       (+ pack FRk op FRi ope FRj)
7380       (sequence ()
7381		 (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7382		 (set FRk (operation FRi FRj)))
7383       profile
7384  )
7385)
7386
7387(ne-float-binary-op nfadds FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) add OP_79 OPE1_26
7388		    ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7389		    "ne add single")
7390(ne-float-binary-op nfsubs FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) sub OP_79 OPE1_27
7391		    ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7392		    "ne sub single")
7393(ne-float-binary-op nfmuls FM01  ((FR500-MAJOR F-3) (FR550-MAJOR F-3)) mul OP_79 OPE1_28
7394		    ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
7395		    "ne mul single")
7396(ne-float-binary-op nfdivs FM01  ((FR500-MAJOR F-4) (FR550-MAJOR F-3)) div OP_79 OPE1_29
7397		    ((fr500 (unit u-float-div)) (fr550 (unit u-float-div)))
7398		    "ne div single")
7399
7400(define-pmacro (fcc-eq) 8)
7401(define-pmacro (fcc-lt) 4)
7402(define-pmacro (fcc-gt) 2)
7403(define-pmacro (fcc-uo) 1)
7404
7405(define-pmacro (compare-and-set-fcc arg1 arg2 fcc)
7406  (if (gt arg1 arg2)
7407      (set fcc (fcc-gt))
7408      (if (eq arg1 arg2)
7409	  (set fcc (fcc-eq))
7410	  (if (lt arg1 arg2)
7411	      (set fcc (fcc-lt))
7412	      (set fcc (fcc-uo)))))
7413)
7414
7415(dni fcmps
7416     "compare single float"
7417     ((UNIT FMALL) (FR500-MAJOR F-2) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7418     "fcmps$pack $FRi,$FRj,$FCCi_2"
7419     (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_0A FRj)
7420     (compare-and-set-fcc FRi FRj FCCi_2)
7421     ((fr500 (unit u-float-compare)) (fr550 (unit u-float-compare)))
7422)
7423
7424(dni fcmpd
7425     "compare double float"
7426     ((UNIT FMALL) (FR500-MAJOR F-2) (MACH frv))
7427     "fcmpd$pack $FRdoublei,$FRdoublej,$FCCi_2"
7428     (+ pack (cond-null) FCCi_2 OP_7A FRdoublei OPE1_0A FRdoublej)
7429     (compare-and-set-fcc FRdoublei FRdoublej FCCi_2)
7430     ((fr500 (unit u-float-compare)))
7431)
7432
7433(dni cfcmps
7434     "Conditional compare single, float"
7435     ((UNIT FMALL) (FR500-MAJOR F-2) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
7436     "cfcmps$pack $FRi,$FRj,$FCCi_2,$CCi,$cond"
7437     (+ pack (cond-null) FCCi_2 OP_6D FRi CCi cond OPE4_2 FRj)
7438     (if (eq CCi (or cond 2))
7439	 (compare-and-set-fcc FRi FRj FCCi_2))
7440     ((fr500 (unit u-float-compare)) (fr550 (unit u-float-compare)))
7441)
7442
7443(dni fdcmps
7444     "float dual compare single"
7445     ((UNIT FMALL) (FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
7446     "fdcmps$pack $FRi,$FRj,$FCCi_2"
7447     (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_1A FRj)
7448     (sequence ()
7449	       (compare-and-set-fcc FRi FRj FCCi_2)
7450	       (compare-and-set-fcc (nextreg h-fr FRi 1) (nextreg h-fr FRj 1)
7451				    (nextreg h-fccr FCCi_2 1)))
7452     ((fr500 (unit u-float-dual-compare)) (fr550 (unit u-float-dual-compare)))
7453)
7454
7455(define-pmacro (float-mul-with-add name add_sub arg1 arg2 targ op ope comment)
7456  (dni name
7457       (comment)
7458       ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv))
7459       (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
7460       (+ pack targ op arg1 ope arg2)
7461       (set targ (add_sub (mul arg1 arg2) targ))
7462       ((fr500 (unit u-float-dual-arith)))
7463  )
7464)
7465
7466(float-mul-with-add fmadds add FRi FRj FRk OP_79 OPE1_0B "mul with add, single")
7467(float-mul-with-add fmsubs sub FRi FRj FRk OP_79 OPE1_0C "mul with sub, single")
7468
7469(float-mul-with-add fmaddd add FRdoublei FRdoublej FRdoublek OP_7A OPE1_0B "mul with add, double")
7470(float-mul-with-add fmsubd sub FRdoublei FRdoublej FRdoublek OP_7A OPE1_0C "mul with sub, double")
7471
7472(dni fdmadds
7473     "Float dual multiply with add"
7474     ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv))
7475     "fdmadds$pack $FRi,$FRj,$FRk"
7476     (+ pack FRk OP_79 FRi OPE1_1B FRj)
7477     (sequence ()
7478	       (set FRk (add (mul FRi FRj) FRk))
7479	       (set (nextreg h-fr FRk 1)
7480		    (add (mul (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))
7481			 (nextreg h-fr FRk 1))))
7482     ; TODO dual registers not referenced for profiling
7483     ((fr500 (unit u-float-dual-arith)))
7484)
7485
7486(dni nfdmadds
7487     "Non excepting float dual multiply with add"
7488     ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv))
7489     "nfdmadds$pack $FRi,$FRj,$FRk"
7490     (+ pack FRk OP_79 FRi OPE1_3B FRj)
7491     (sequence ()
7492	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7493	       (set FRk (add (mul FRi FRj) FRk))
7494	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
7495	       (set (nextreg h-fr FRk 1)
7496		    (add (mul (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))
7497			 (nextreg h-fr FRk 1))))
7498     ; TODO dual registers not referenced for profiling
7499     ((fr500 (unit u-float-dual-arith)))
7500)
7501
7502(define-pmacro (conditional-float-mul-with-add
7503		name add_sub arg1 arg2 targ op ope comment)
7504  (dni name
7505       (comment)
7506       ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv) CONDITIONAL)
7507       (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
7508       (+ pack FRk op FRi CCi cond ope FRj)
7509       (if (eq CCi (or cond 2))
7510	   (set targ (add_sub (mul arg1 arg2) targ)))
7511       ((fr500 (unit u-float-dual-arith)))
7512  )
7513)
7514
7515(conditional-float-mul-with-add cfmadds add FRi FRj FRk OP_6F OPE4_0 "conditional mul with add, single")
7516(conditional-float-mul-with-add cfmsubs sub FRi FRj FRk OP_6F OPE4_1 "conditional mul with sub, single")
7517
7518(define-pmacro (ne-float-mul-with-add name add_sub arg1 arg2 targ op ope comment)
7519  (dni name
7520       (comment)
7521       ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv) NON-EXCEPTING)
7522       (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
7523       (+ pack targ op arg1 ope arg2)
7524       (sequence ()
7525		 (c-call VOID "@cpu@_set_ne_index" (index-of targ))
7526		 (set targ (add_sub (mul arg1 arg2) targ)))
7527       ((fr500 (unit u-float-dual-arith)))
7528  )
7529)
7530
7531(ne-float-mul-with-add nfmadds add FRi FRj FRk OP_79 OPE1_2B "non excepting mul with add, single")
7532(ne-float-mul-with-add nfmsubs sub FRi FRj FRk OP_79 OPE1_2C "non excepting mul with sub, single")
7533
7534(define-pmacro (float-parallel-mul-add-semantics cond add_sub arg1 arg2 targ)
7535  (if cond
7536      (sequence ()
7537		(set targ (mul arg1 arg2))
7538		(set (nextreg h-fr targ 1)
7539		     (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))))
7540)
7541
7542(define-pmacro (float-parallel-mul-add
7543		name add_sub arg1 arg2 targ op ope comment)
7544  (dni name
7545       (comment)
7546       ((UNIT FM01) (FR500-MAJOR F-5) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
7547       (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
7548       (+ pack targ op arg1 ope arg2)
7549       (float-parallel-mul-add-semantics 1 add_sub arg1 arg2 targ)
7550       ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7551  )
7552)
7553
7554(float-parallel-mul-add fmas add FRi FRj FRk OP_79 OPE1_0E "parallel mul/add, single")
7555(float-parallel-mul-add fmss sub FRi FRj FRk OP_79 OPE1_0F "parallel mul/sub, single")
7556
7557(define-pmacro (float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
7558  (sequence ()
7559	    (set targ (mul arg1 arg2))
7560	    (set (nextreg h-fr targ 1)
7561		 (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))
7562	    (set (nextreg h-fr targ 2)
7563		 (mul (nextreg h-fr arg1 2)	(nextreg h-fr arg2 2)))
7564	    (set (nextreg h-fr targ 3)
7565		 (add_sub (nextreg h-fr arg1 3) (nextreg h-fr arg2 3))))
7566)
7567
7568(define-pmacro (float-dual-parallel-mul-add
7569		name add_sub arg1 arg2 targ op ope comment)
7570  (dni name
7571       (comment)
7572       ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
7573       (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
7574       (+ pack targ op arg1 ope arg2)
7575       (float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
7576       ()
7577  )
7578)
7579
7580(float-dual-parallel-mul-add fdmas add FRi FRj FRk OP_79 OPE1_1C "dual parallel mul/add, single")
7581(float-dual-parallel-mul-add fdmss sub FRi FRj FRk OP_79 OPE1_1D "dual parallel mul/sub, single")
7582
7583(define-pmacro (ne-float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
7584  (sequence ()
7585	    (c-call VOID "@cpu@_set_ne_index" (index-of targ))
7586	    (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 1))
7587	    (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 2))
7588	    (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 3))
7589	    (set targ (mul arg1 arg2))
7590	    (set (nextreg h-fr targ 1)
7591		 (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))
7592	    (set (nextreg h-fr targ 2)
7593		 (mul (nextreg h-fr arg1 2)	(nextreg h-fr arg2 2)))
7594	    (set (nextreg h-fr targ 3)
7595		 (add_sub (nextreg h-fr arg1 3) (nextreg h-fr arg2 3))))
7596)
7597
7598(define-pmacro (ne-float-dual-parallel-mul-add
7599		name add_sub arg1 arg2 targ op ope comment)
7600  (dni name
7601       (comment)
7602       ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
7603       (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
7604       (+ pack targ op arg1 ope arg2)
7605       (ne-float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
7606       ()
7607  )
7608)
7609
7610(ne-float-dual-parallel-mul-add nfdmas add FRi FRj FRk OP_79 OPE1_3C "non excepting dual parallel mul/add, single")
7611(ne-float-dual-parallel-mul-add nfdmss sub FRi FRj FRk OP_79 OPE1_3D "non excepting dual parallel mul/sub, single")
7612
7613(define-pmacro (conditional-float-parallel-mul-add name add_sub op ope comment)
7614  (dni name
7615       (comment)
7616       ((UNIT FM01) (FR500-MAJOR F-5) (FR550-MAJOR F-4) CONDITIONAL (MACH simple,tomcat,fr500,fr550,frv))
7617       (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
7618       (+ pack FRk op FRi CCi cond ope FRj)
7619       (float-parallel-mul-add-semantics (eq CCi (or cond 2))
7620					 add_sub FRi FRj FRk)
7621       ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7622  )
7623)
7624
7625(conditional-float-parallel-mul-add cfmas add OP_6F OPE4_2 "conditional parallel mul/add, single")
7626(conditional-float-parallel-mul-add cfmss sub OP_6F OPE4_3 "conditional parallel mul/sub, single")
7627
7628(define-pmacro (float-parallel-mul-add-double-semantics add_sub arg1 arg2 targ)
7629  (sequence ()
7630	    (set targ (ftrunc SF FPCONV-DEFAULT
7631			      (mul DF
7632				   (fext DF FPCONV-DEFAULT arg1)
7633				   (fext DF FPCONV-DEFAULT arg2))))
7634	    (set (nextreg h-fr targ 1)
7635		 (ftrunc SF FPCONV-DEFAULT
7636			 (add_sub DF
7637				  (fext DF FPCONV-DEFAULT (nextreg h-fr arg1 1))
7638				  (fext DF FPCONV-DEFAULT (nextreg h-fr arg2 1))))))
7639)
7640
7641(define-pmacro (float-parallel-mul-add-double
7642		name add_sub arg1 arg2 targ op ope comment)
7643  (dni name
7644       (comment)
7645       ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
7646       (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
7647       (+ pack targ op arg1 ope arg2)
7648       (float-parallel-mul-add-double-semantics add_sub arg1 arg2 targ)
7649       ()
7650  )
7651)
7652
7653(float-parallel-mul-add-double fmad add FRi FRj FRk OP_7A OPE1_0E "parallel mul/add, double")
7654(float-parallel-mul-add-double fmsd sub FRi FRj FRk OP_7A OPE1_0F "parallel mul/sub, double")
7655
7656(define-pmacro (ne-float-parallel-mul-add name add_sub op ope comment)
7657  (dni name
7658       (comment)
7659       ((UNIT FM01) (FR500-MAJOR F-5) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
7660       (.str name "$pack $FRi,$FRj,$FRk")
7661       (+ pack FRk op FRi ope FRj)
7662       (sequence ()
7663		 (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7664		 (set FRk (mul FRi FRj))
7665		 (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
7666		 (set (nextreg h-fr FRk 1)
7667		      (add_sub (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
7668       ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7669  )
7670)
7671
7672(ne-float-parallel-mul-add nfmas add OP_79 OPE1_2E "ne parallel mul/add,single")
7673(ne-float-parallel-mul-add nfmss sub OP_79 OPE1_2F "ne parallel mul/sub,single")
7674
7675(define-pmacro (float-dual-arith name attr oper1 oper2 op ope comment)
7676  (dni name
7677       (comment)
7678       (.splice (UNIT FM01) (.unsplice attr))
7679       (.str name "$pack $FRi,$FRj,$FRk")
7680       (+ pack FRk op FRi ope FRj)
7681       (sequence ()
7682		 (set FRk (oper1 FRi FRj))
7683		 (set (nextreg h-fr FRk 1)
7684		      (oper2 (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
7685       ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7686  )
7687)
7688
7689(float-dual-arith fdadds ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add add OP_79 OPE1_16 "dual add, single")
7690(float-dual-arith fdsubs ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) sub sub OP_79 OPE1_17 "dual sub, single")
7691(float-dual-arith fdmuls ((FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) mul mul OP_79 OPE1_18 "dual mul, single")
7692(float-dual-arith fddivs ((FR500-MAJOR F-7) (MACH frv))                           div div OP_79 OPE1_19 "dual div,single")
7693(float-dual-arith fdsads ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add sub OP_79 OPE1_1E "dual add/sub, single")
7694
7695(dni fdmulcs
7696     "Float dual cross multiply single"
7697     ((UNIT FM01) (FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
7698     "fdmulcs$pack $FRi,$FRj,$FRk"
7699     (+ pack FRk OP_79 FRi OPE1_1F FRj)
7700     (sequence ()
7701	       (set FRk (mul FRi (nextreg h-fr FRj 1)))
7702	       (set (nextreg h-fr FRk 1) (mul (nextreg h-fr FRi 1) FRj)))
7703     ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7704)
7705
7706(dni nfdmulcs
7707     "NE float dual cross multiply single"
7708     ((UNIT FM01) (FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
7709     "nfdmulcs$pack $FRi,$FRj,$FRk"
7710     (+ pack FRk OP_79 FRi OPE1_3F FRj)
7711     (sequence ()
7712	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7713	       (set FRk (mul FRi (nextreg h-fr FRj 1)))
7714	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
7715	       (set (nextreg h-fr FRk 1) (mul (nextreg h-fr FRi 1) FRj)))
7716     ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7717)
7718
7719(define-pmacro (ne-float-dual-arith name attr oper1 oper2 op ope comment)
7720  (dni name
7721       (comment)
7722       (.splice (UNIT FM01) (.unsplice attr))
7723       (.str name "$pack $FRi,$FRj,$FRk")
7724       (+ pack FRk op FRi ope FRj)
7725       (sequence ()
7726		 (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7727		 (set FRk (oper1 FRi FRj))
7728		 (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
7729		 (set (nextreg h-fr FRk 1)
7730		      (oper2 (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
7731       ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
7732  )
7733)
7734
7735(ne-float-dual-arith nfdadds ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add add OP_79 OPE1_36 "ne dual add, single")
7736(ne-float-dual-arith nfdsubs ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) sub sub OP_79 OPE1_37 "ne dual sub, single")
7737(ne-float-dual-arith nfdmuls ((FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) mul mul OP_79 OPE1_38 "ne dual mul, single")
7738(ne-float-dual-arith nfddivs ((FR500-MAJOR F-7) (MACH frv))                           div div OP_79 OPE1_39 "ne dual div,single")
7739(ne-float-dual-arith nfdsads ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add sub OP_79 OPE1_3E "ne dual add/sub, single")
7740
7741(dni nfdcmps
7742     "non-excepting dual float compare"
7743     ((UNIT FM01) (FR500-MAJOR F-6) (MACH simple,tomcat,frv))
7744     "nfdcmps$pack $FRi,$FRj,$FCCi_2"
7745     (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_3A FRj)
7746     (sequence ()
7747	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
7748	       (compare-and-set-fcc FRi FRj FCCi_2)
7749	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
7750	       (compare-and-set-fcc (nextreg h-fr FRi 1) (nextreg h-fr FRj 1)
7751				    (nextreg h-fccr FCCi_2 1)))
7752     ((fr500 (unit u-float-dual-compare)))
7753)
7754
7755; Media Instructions
7756;
7757(define-pmacro (halfword hilo arg offset)
7758  (reg (.sym h-fr_ hilo) (add (index-of arg) offset)))
7759
7760(dni mhsetlos
7761     "Media set lower signed 12 bits"
7762     ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
7763      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
7764     "mhsetlos$pack $u12,$FRklo"
7765     (+ pack FRklo OP_78 OPE1_20 u12)
7766     (set FRklo u12)
7767     ((fr400 (unit u-media-hilo)) (fr450 (unit u-media-hilo))
7768      (fr550 (unit u-media-set (out FRintk FRklo))))
7769)
7770
7771(dni mhsethis
7772     "Media set upper signed 12 bits"
7773     ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
7774      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
7775     "mhsethis$pack $u12,$FRkhi"
7776     (+ pack FRkhi OP_78 OPE1_22 u12)
7777     (set FRkhi u12)
7778     ((fr400 (unit u-media-hilo)) (fr450 (unit u-media-hilo))
7779      (fr550 (unit u-media-set (out FRintk FRkhi))))
7780)
7781
7782(dni mhdsets
7783     "Media dual set halfword signed 12 bits"
7784     ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
7785      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
7786     "mhdsets$pack $u12,$FRintk"
7787     (+ pack FRintk OP_78 OPE1_24 u12)
7788     (sequence ()
7789	       ; hack to get FRintk passed to modelling functions
7790	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
7791	       (set (halfword hi FRintk 0) u12)
7792	       (set (halfword lo FRintk 0) u12))
7793     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
7794      (fr550 (unit u-media-set)))
7795)
7796
7797(define-pmacro (set-5-semantics target value)
7798  (sequence ((HI tmp))
7799	    (set tmp target)
7800	    (set tmp (and tmp #x07ff))
7801	    (set tmp (or tmp (sll (and s5 #x1f) 11)))
7802	    (set target tmp))
7803)
7804
7805(define-pmacro (media-set-5 name hilo op ope comment)
7806  (dni name
7807       (comment)
7808       ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
7809	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
7810       (.str name "$pack $s5,$FRk" hilo)
7811       (+ pack (.sym FRk hilo) op (FRi-null) ope (misc-null-11) s5)
7812       (set-5-semantics (.sym FRk hilo) s5)
7813       ((fr400 (unit u-media-hilo)) (fr450 (unit u-media-hilo))
7814	(fr550 (unit u-media-set (out FRintk (.sym FRk hilo)))))
7815  )
7816)
7817
7818(media-set-5 mhsetloh lo OP_78 OPE1_21 "Media set upper 5 bits lo")
7819(media-set-5 mhsethih hi OP_78 OPE1_23 "Media set upper 5 bits hi")
7820
7821(dni mhdseth
7822     "Media dual set halfword upper 5 bits"
7823     ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
7824      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
7825     "mhdseth$pack $s5,$FRintk"
7826     (+ pack FRintk OP_78 (FRi-null) OPE1_25 (misc-null-11) s5)
7827     (sequence ()
7828	       ; hack to get FRintk passed to modelling functions
7829	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
7830	       (set-5-semantics (halfword hi FRintk 0) s5)
7831	       (set-5-semantics (halfword lo FRintk 0) s5))
7832     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
7833      (fr550 (unit u-media-set)))
7834)
7835
7836(define-pmacro (media-logic-r-r name operation op ope comment)
7837  (dni name
7838       (comment)
7839       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
7840	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
7841       (.str name "$pack $FRinti,$FRintj,$FRintk")
7842       (+ pack FRintk op FRinti ope FRintj)
7843       (set FRintk (operation FRinti FRintj))
7844       ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
7845	(fr500 (unit u-media)) (fr550 (unit u-media)))
7846  )
7847)
7848
7849(media-logic-r-r mand and OP_7B OPE1_00 "and reg/reg")
7850(media-logic-r-r mor  or  OP_7B OPE1_01 "or  reg/reg")
7851(media-logic-r-r mxor xor OP_7B OPE1_02 "xor reg/reg")
7852
7853(define-pmacro (conditional-media-logic name operation op ope comment)
7854  (dni name
7855       (comment)
7856       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
7857	(FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
7858       (.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
7859       (+ pack FRintk op FRinti CCi cond ope FRintj)
7860       (if (eq CCi (or cond 2))
7861	   (set FRintk (operation FRinti FRintj)))
7862       ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
7863	(fr500 (unit u-media)) (fr550 (unit u-media)))
7864  )
7865)
7866
7867(conditional-media-logic cmand and OP_70 OPE4_0 "conditional and reg/reg")
7868(conditional-media-logic cmor  or  OP_70 OPE4_1 "conditional or  reg/reg")
7869(conditional-media-logic cmxor xor OP_70 OPE4_2 "conditional xor reg/reg")
7870
7871(dni mnot
7872     ("mnot")
7873     ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
7874      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
7875     ("mnot$pack $FRintj,$FRintk")
7876     (+ pack FRintk OP_7B (rs-null) OPE1_03 FRintj)
7877     (set FRintk (inv FRintj))
7878     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
7879      (fr500 (unit u-media)) (fr550 (unit u-media)))
7880)
7881
7882(dni cmnot
7883     ("cmnot")
7884     ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
7885      (FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
7886     ("cmnot$pack $FRintj,$FRintk,$CCi,$cond")
7887     (+ pack FRintk OP_70 (rs-null) CCi cond OPE4_3 FRintj)
7888     (if (eq CCi (or cond 2))
7889	 (set FRintk (inv FRintj)))
7890     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
7891      (fr500 (unit u-media)) (fr550 (unit u-media)))
7892)
7893
7894(define-pmacro (media-rotate-r-r name operation op ope comment)
7895  (dni name
7896       (comment)
7897       ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
7898	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
7899       (.str name "$pack $FRinti,$u6,$FRintk")
7900       (+ pack FRintk op FRinti ope u6)
7901       (set FRintk (operation FRinti (and u6 #x1f)))
7902       ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
7903	(fr500 (unit u-media)) (fr550 (unit u-media)))
7904  )
7905)
7906
7907(media-rotate-r-r mrotli rol OP_7B OPE1_04 "rotate left reg/reg")
7908(media-rotate-r-r mrotri ror OP_7B OPE1_05 "rotate right reg/reg")
7909
7910(define-pmacro (media-cut-r-r name arg op ope comment)
7911  (dni name
7912       (comment)
7913       ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
7914	(FR400-MAJOR M-2) (FR450-MAJOR M-2))
7915       (.str name "$pack $FRinti,$" arg ",$FRintk")
7916       (+ pack FRintk op FRinti ope arg)
7917       (set FRintk (c-call SI "@cpu@_cut" FRinti (nextreg h-fr_int FRinti 1) arg))
7918       ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
7919	(fr500 (unit u-media)) (fr550 (unit u-media)))
7920  )
7921)
7922
7923(media-cut-r-r mwcut  FRintj OP_7B OPE1_06 "media cut")
7924(media-cut-r-r mwcuti u6     OP_7B OPE1_07 "media cut")
7925
7926(define-pmacro (media-cut-acc name arg op ope fr450-major comment)
7927  (dni name
7928       (comment)
7929       ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
7930	(FR400-MAJOR M-1) (FR450-MAJOR fr450-major))
7931       (.str name "$pack $ACC40Si,$" arg ",$FRintk")
7932       (+ pack FRintk op ACC40Si ope arg)
7933       (set FRintk (c-call SI "@cpu@_media_cut" ACC40Si arg))
7934       ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
7935	(fr500 (unit u-media)) (fr550 (unit u-media-3-acc)))
7936  )
7937)
7938
7939(media-cut-acc mcut  FRintj OP_7B OPE1_2C M-1 "media accumulator cut reg")
7940(media-cut-acc mcuti s6     OP_7B OPE1_2E M-5 "media accumulator cut immed")
7941
7942(define-pmacro (media-cut-acc-ss name arg op ope fr450-major comment)
7943  (dni name
7944       (comment)
7945       ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
7946	(FR400-MAJOR M-1) (FR450-MAJOR fr450-major))
7947       (.str name "$pack $ACC40Si,$" arg ",$FRintk")
7948       (+ pack FRintk op ACC40Si ope arg)
7949       (set FRintk (c-call SI "@cpu@_media_cut_ss" ACC40Si arg))
7950       ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
7951	(fr500 (unit u-media)) (fr550 (unit u-media-3-acc)))
7952  )
7953)
7954
7955(media-cut-acc-ss mcutss  FRintj OP_7B OPE1_2D M-1 "media accumulator cut reg with saturation")
7956(media-cut-acc-ss mcutssi s6     OP_7B OPE1_2F M-5 "media accumulator cut immed with saturation")
7957
7958; Dual Media Instructions
7959;
7960(define-pmacro (register-unaligned register alignment)
7961  (and (index-of register) (sub alignment 1))
7962)
7963
7964(dni mdcutssi
7965     "Media dual cut with signed saturation"
7966     ((UNIT MDCUTSSI) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
7967      (FR400-MAJOR M-2) (FR450-MAJOR M-6))
7968     "mdcutssi$pack $ACC40Si,$s6,$FRintkeven"
7969     (+ pack FRintkeven OP_78 ACC40Si OPE1_0E s6)
7970     (if (register-unaligned ACC40Si 2)
7971	 (c-call VOID "@cpu@_media_acc_not_aligned")
7972	 (if (register-unaligned FRintkeven 2)
7973	     (c-call VOID "@cpu@_media_register_not_aligned")
7974	     (sequence ()
7975		       (set FRintkeven (c-call SI "@cpu@_media_cut_ss" ACC40Si s6))
7976		       (set (nextreg h-fr_int FRintkeven 1)
7977			    (c-call SI "@cpu@_media_cut_ss"
7978				    (nextreg h-acc40S ACC40Si 1) s6)))))
7979     ((fr400 (unit u-media-4-acc-dual
7980		   (out FRintk FRintkeven)))
7981      (fr450 (unit u-media-4-acc-dual
7982		   (out FRintk FRintkeven)))
7983      (fr550 (unit u-media-3-acc-dual)))
7984)
7985
7986; The (add (xxxx) (mul arg 0)) is a hack to get a reference to arg generated
7987; so it will be passed to the unit modelers.   YUCK!!!!!
7988(define-pmacro (extract-hilo reg1 off1 reg2 off2 arg1hi arg1lo arg2hi arg2lo)
7989  (sequence ()
7990	    (set arg1hi (add (halfword hi reg1 off1) (mul reg1 0)))
7991	    (set arg1lo (add (halfword lo reg1 off1) (mul reg1 0)))
7992	    (set arg2hi (add (halfword hi reg2 off2) (mul reg2 0)))
7993	    (set arg2lo (add (halfword lo reg2 off2) (mul reg2 0))))
7994)
7995
7996(dni maveh
7997     "Media dual average"
7998     ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
7999      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
8000     "maveh$pack $FRinti,$FRintj,$FRintk"
8001     (+ pack FRintk OP_7B FRinti OPE1_08 FRintj)
8002     (set FRintk (c-call SI "@cpu@_media_average" FRinti FRintj))
8003     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
8004      (fr500 (unit u-media)) (fr550 (unit u-media)))
8005)
8006
8007(define-pmacro (media-dual-shift name operation op ope profile comment)
8008  (dni name
8009       (comment)
8010       ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
8011	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
8012       (.str name "$pack $FRinti,$u6,$FRintk")
8013       (+ pack FRintk op FRinti ope u6)
8014       (sequence ()
8015		 ; hack to get these referenced for profiling
8016		 (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
8017		 (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
8018		 (set (halfword hi FRintk 0)
8019		      (operation (halfword hi FRinti 0) (and u6 #xf)))
8020		 (set (halfword lo FRintk 0)
8021		      (operation (halfword lo FRinti 0) (and u6 #xf))))
8022       profile
8023  )
8024)
8025
8026(media-dual-shift msllhi sll OP_7B OPE1_09
8027		  ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
8028		   (fr500 (unit u-media)) (fr550 (unit u-media)))
8029		  "Media dual shift left  logical")
8030(media-dual-shift msrlhi srl OP_7B OPE1_0A
8031		  ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
8032		   (fr500 (unit u-media)) (fr550 (unit u-media)))
8033		  "Media dual shift right logical")
8034(media-dual-shift msrahi sra OP_7B OPE1_0B
8035		  ((fr400 (unit u-media-6)) (fr450 (unit u-media-6))
8036		   (fr500 (unit u-media)) (fr550 (unit u-media)))
8037		  "Media dual shift right arithmetic")
8038
8039(define-pmacro (media-dual-word-rotate-r-r name operation op ope comment)
8040  (dni name
8041       (comment)
8042       ((UNIT FMLOW) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
8043	(FR400-MAJOR M-2) (FR450-MAJOR M-2))
8044       (.str name "$pack $FRintieven,$s6,$FRintkeven")
8045       (+ pack FRintkeven op FRintieven ope s6)
8046       (if (orif (register-unaligned FRintieven 2)
8047		 (register-unaligned FRintkeven 2))
8048	   (c-call VOID "@cpu@_media_register_not_aligned")
8049	   (sequence ()
8050		     (set FRintkeven (operation FRintieven (and s6 #x1f)))
8051		     (set (nextreg h-fr_int FRintkeven 1)
8052			  (operation (nextreg h-fr_int FRintieven 1)
8053				     (and s6 #x1f)))))
8054       ((fr400 (unit u-media-3-quad
8055		     (in  FRinti FRintieven)
8056		     (out FRintk FRintkeven)))
8057	(fr450 (unit u-media-3-quad
8058		     (in  FRinti FRintieven)
8059		     (out FRintk FRintkeven)))
8060	(fr550 (unit u-media-quad)))
8061  )
8062)
8063
8064(media-dual-word-rotate-r-r mdrotli rol OP_78 OPE1_0B "rotate left reg/reg")
8065
8066(dni mcplhi
8067     "Media bit concatenate, halfword"
8068     ((UNIT FMLOW) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
8069      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
8070     "mcplhi$pack $FRinti,$u6,$FRintk"
8071     (+ pack FRintk OP_78 FRinti OPE1_0C u6)
8072     (sequence ((HI arg1) (HI arg2) (HI shift))
8073	       (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
8074	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
8075	       (set shift (and u6 #xf))
8076	       (set arg1 (sll (halfword hi FRinti 0) shift))
8077	       (if (ne shift 0)
8078		   (sequence ()
8079			     (set arg2 (halfword hi FRinti 1))
8080			     (set arg2 (srl HI (sll HI arg2 (sub 15 shift))
8081					    (sub 15 shift)))
8082			     (set arg1 (or HI arg1 arg2))))
8083	       (set (halfword hi FRintk 0) arg1))
8084     ((fr400 (unit u-media-3-dual)) (fr450 (unit u-media-3-dual))
8085      (fr550 (unit u-media-3-dual)))
8086)
8087
8088(dni mcpli
8089     "Media bit concatenate, word"
8090     ((UNIT FMLOW) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
8091      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
8092     "mcpli$pack $FRinti,$u6,$FRintk"
8093     (+ pack FRintk OP_78 FRinti OPE1_0D u6)
8094     (sequence ((SI tmp) (SI shift))
8095	       (set shift (and u6 #x1f))
8096	       (set tmp (sll FRinti shift))
8097	       (if (ne shift 0)
8098		   (sequence ((SI tmp1))
8099			     (set tmp1 (srl (sll (nextreg h-fr_int FRinti 1)
8100						 (sub 31 shift))
8101					    (sub 31 shift)))
8102			     (set tmp (or tmp tmp1))))
8103	       (set FRintk tmp))
8104     ((fr400 (unit u-media-3-dual)) (fr450 (unit u-media-3-dual))
8105      (fr550 (unit u-media-3-dual)))
8106)
8107
8108(define-pmacro (saturate arg max min result)
8109  (if (gt arg max)
8110      (set result max)
8111      (if (lt arg min)
8112	  (set result min)
8113	  (set result arg)))
8114)
8115
8116(dni msaths
8117     "Media dual saturation signed"
8118     ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8119      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
8120     "msaths$pack $FRinti,$FRintj,$FRintk"
8121     (+ pack FRintk OP_7B FRinti OPE1_0C FRintj)
8122     (sequence ((HI argihi) (HI argilo) (HI argjhi) (HI argjlo))
8123	       (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
8124	       (saturate argihi argjhi (inv argjhi) (halfword hi FRintk 0))
8125	       (saturate argilo argjlo (inv argjlo) (halfword lo FRintk 0)))
8126     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
8127      (fr500 (unit u-media)) (fr550 (unit u-media)))
8128)
8129
8130(dni mqsaths
8131     "Media quad saturation signed"
8132     ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-2)
8133      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
8134     "mqsaths$pack $FRintieven,$FRintjeven,$FRintkeven"
8135     (+ pack FRintkeven OP_78 FRintieven OPE1_0F FRintjeven)
8136     (if (orif (register-unaligned FRintieven 2)
8137	       (orif (register-unaligned FRintjeven 2)
8138		     (register-unaligned FRintkeven 2)))
8139	 (c-call VOID "@cpu@_media_register_not_aligned")
8140	 (sequence ((HI argihi) (HI argilo) (HI argjhi) (HI argjlo))
8141		   ; hack to get FRintkeven referenced as a target for profiling
8142		   (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
8143		   (extract-hilo FRintieven 0 FRintjeven 0 argihi argilo argjhi argjlo)
8144		   (saturate argihi argjhi (inv argjhi) (halfword hi FRintkeven 0))
8145		   (saturate argilo argjlo (inv argjlo) (halfword lo FRintkeven 0))
8146		   (extract-hilo FRintieven 1 FRintjeven 1 argihi argilo argjhi argjlo)
8147		   (saturate argihi argjhi (inv argjhi) (halfword hi FRintkeven 1))
8148		   (saturate argilo argjlo (inv argjlo) (halfword lo FRintkeven 1))))
8149     ((fr400 (unit u-media-1-quad
8150		   (in  FRinti FRintieven)
8151		   (in  FRintj FRintjeven)
8152		   (out FRintk FRintkeven)))
8153      (fr450 (unit u-media-1-quad
8154		   (in  FRinti FRintieven)
8155		   (in  FRintj FRintjeven)
8156		   (out FRintk FRintkeven)))
8157      (fr550 (unit u-media-quad)))
8158)
8159
8160(define-pmacro (saturate-unsigned arg max result)
8161  (if (gt arg max)
8162      (set result max)
8163      (set result arg))
8164)
8165
8166(dni msathu
8167     "Media dual saturation unsigned"
8168     ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8169      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
8170     "msathu$pack $FRinti,$FRintj,$FRintk"
8171     (+ pack FRintk OP_7B FRinti OPE1_0D FRintj)
8172     (sequence ((UHI argihi) (UHI argilo) (UHI argjhi) (UHI argjlo))
8173	       (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
8174	       (saturate-unsigned argihi argjhi (halfword hi FRintk 0))
8175	       (saturate-unsigned argilo argjlo (halfword lo FRintk 0)))
8176     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
8177      (fr500 (unit u-media)) (fr550 (unit u-media)))
8178)
8179
8180(define-pmacro (media-dual-compare name mode op ope comment)
8181  (dni name
8182       (comment)
8183       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8184	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
8185       (.str name "$pack $FRinti,$FRintj,$FCCk")
8186       (+ pack (cond-null) FCCk op FRinti ope FRintj)
8187       (if (register-unaligned FCCk 2)
8188	   (c-call VOID "@cpu@_media_cr_not_aligned")
8189	   (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
8190		     (extract-hilo FRinti 0 FRintj 0
8191				   argihi argilo argjhi argjlo)
8192		     (compare-and-set-fcc argihi argjhi FCCk)
8193		     (compare-and-set-fcc argilo argjlo (nextreg h-fccr FCCk 1))))
8194       ; TODO - doesn't handle second FCC
8195       ((fr400 (unit u-media-7)) (fr450 (unit u-media-7))
8196	(fr500 (unit u-media)) (fr550 (unit u-media)))
8197  )
8198)
8199
8200(media-dual-compare mcmpsh HI  OP_7B OPE1_0E "Media dual compare signed")
8201(media-dual-compare mcmpuh UHI OP_7B OPE1_0F "Media dual compare unsigned")
8202
8203; Bits for the MSR.SIE field
8204(define-pmacro (msr-sie-nil)      0)
8205(define-pmacro (msr-sie-fri-hi)   8)
8206(define-pmacro (msr-sie-fri-lo)   4)
8207(define-pmacro (msr-sie-fri-1-hi) 2)
8208(define-pmacro (msr-sie-fri-1-lo) 1)
8209(define-pmacro (msr-sie-acci)     8)
8210(define-pmacro (msr-sie-acci-1)   4)
8211(define-pmacro (msr-sie-acci-2)   2)
8212(define-pmacro (msr-sie-acci-3)   1)
8213
8214(define-pmacro (saturate-v arg max min sie result)
8215  (if (gt DI arg max)
8216      (sequence ()
8217		(set result max)
8218		(c-call VOID "@cpu@_media_overflow" sie))
8219      (if (lt DI arg min)
8220	  (sequence ()
8221		    (set result min)
8222		    (c-call VOID "@cpu@_media_overflow" sie))
8223	  (set result arg)))
8224)
8225
8226(dni mabshs
8227     "Media dual absolute value, halfword"
8228     ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-2)
8229      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
8230     "mabshs$pack $FRintj,$FRintk"
8231     (+ pack FRintk OP_78 (FRi-null) OPE1_0A FRintj)
8232     (sequence ((HI arghi) (HI arglo))
8233	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
8234	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
8235	       (set arghi (halfword hi FRintj 0))
8236	       (set arglo (halfword lo FRintj 0))
8237	       ; We extend the argument before the abs operation so we can
8238	       ; notice -32768 overflowing as 32768.
8239	       (saturate-v (abs (ext DI arghi)) 32767 -32768 (msr-sie-fri-hi)
8240			   (halfword hi FRintk 0))
8241	       (saturate-v (abs (ext DI arglo)) 32767 -32768 (msr-sie-fri-lo)
8242			   (halfword lo FRintk 0)))
8243     ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
8244      (fr550 (unit u-media)))
8245)
8246
8247; How to extend from a mode to get the intended signedness.
8248(define-pmacro (DI-ext-HI x) (ext DI x))
8249(define-pmacro (DI-ext-UHI x) (zext DI x))
8250(define-pmacro (DI-ext-DI x) x)
8251
8252(define-pmacro (media-arith-sat-semantics
8253		operation arg1 arg2 res mode max min sie)
8254  (sequence ((DI tmp))
8255	    ; Make sure we saturate at max/min against a value that is
8256	    ; sign- or zero-extended appropriately from "mode".
8257	    (set tmp (operation DI
8258		      ((.sym DI-ext- mode) arg1) ((.sym DI-ext- mode) arg2)))
8259	    (saturate-v tmp max min sie res))
8260)
8261
8262(define-pmacro (media-dual-arith-sat-semantics operation mode max min)
8263  (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
8264	    (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
8265	    (media-arith-sat-semantics operation argihi argjhi
8266				       (halfword hi FRintk 0) mode max min
8267				       (msr-sie-fri-hi))
8268	    (media-arith-sat-semantics operation argilo argjlo
8269				       (halfword lo FRintk 0) mode max min
8270				       (msr-sie-fri-lo)))
8271)
8272
8273(define-pmacro (media-dual-arith-sat name operation mode max min op ope comment)
8274  (dni name
8275       (comment)
8276       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8277	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
8278       (.str name "$pack $FRinti,$FRintj,$FRintk")
8279       (+ pack FRintk op FRinti ope FRintj)
8280       (media-dual-arith-sat-semantics operation mode max min)
8281       ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
8282	(fr500 (unit u-media)) (fr550 (unit u-media)))
8283  )
8284)
8285
8286(media-dual-arith-sat maddhss add  HI 32767 -32768 OP_7B OPE1_10 "Media dual add signed with saturation")
8287(media-dual-arith-sat maddhus add UHI 65535      0 OP_7B OPE1_11 "Media dual add unsigned with saturation")
8288
8289(media-dual-arith-sat msubhss sub  HI 32767 -32768 OP_7B OPE1_12 "Media dual sub signed with saturation")
8290(media-dual-arith-sat msubhus sub UHI 65535      0 OP_7B OPE1_13 "Media dual sub unsigned with saturation")
8291
8292(define-pmacro (conditional-media-dual-arith-sat
8293		name operation mode max min op ope comment)
8294  (dni name
8295       (comment)
8296       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8297	(FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
8298       (.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
8299       (+ pack FRintk op FRinti CCi cond ope FRintj)
8300       (if (eq CCi (or cond 2))
8301	   (media-dual-arith-sat-semantics operation mode max min))
8302       ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
8303	(fr500 (unit u-media)) (fr550 (unit u-media)))
8304  )
8305)
8306
8307(conditional-media-dual-arith-sat cmaddhss add  HI 32767 -32768 OP_71 OPE4_0 "Conditional Media dual add signed with saturation")
8308(conditional-media-dual-arith-sat cmaddhus add UHI 65535      0 OP_71 OPE4_1 "Conditional Media dual add unsigned with saturation")
8309
8310(conditional-media-dual-arith-sat cmsubhss sub  HI 32767 -32768 OP_71 OPE4_2 "Conditional Media dual sub signed with saturation")
8311(conditional-media-dual-arith-sat cmsubhus sub UHI 65535      0 OP_71 OPE4_3 "Conditional Media dual sub unsigned with saturation")
8312
8313(define-pmacro (media-quad-arith-sat-semantics cond operation mode max min)
8314  (if (orif (register-unaligned FRintieven 2)
8315	    (orif (register-unaligned FRintjeven 2)
8316		  (register-unaligned FRintkeven 2)))
8317      (c-call VOID "@cpu@_media_register_not_aligned")
8318      (if cond
8319	  (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
8320		    ; hack to get FRintkeven referenced as a target for profiling
8321		    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
8322		    (extract-hilo FRintieven 0 FRintjeven 0
8323				  argihi argilo argjhi argjlo)
8324		    (media-arith-sat-semantics operation argihi argjhi
8325					       (halfword hi FRintkeven 0) mode
8326					       max min (msr-sie-fri-hi))
8327		    (media-arith-sat-semantics operation argilo argjlo
8328					       (halfword lo FRintkeven 0) mode
8329					       max min (msr-sie-fri-lo))
8330		    (extract-hilo FRintieven 1 FRintjeven 1
8331				  argihi argilo argjhi argjlo)
8332		    (media-arith-sat-semantics operation argihi argjhi
8333					       (halfword hi FRintkeven 1) mode
8334					       max min	(msr-sie-fri-1-hi))
8335		    (media-arith-sat-semantics operation argilo argjlo
8336					       (halfword lo FRintkeven 1) mode
8337					       max min (msr-sie-fri-1-lo)))))
8338)
8339
8340(define-pmacro (media-quad-arith-sat name operation mode max min op ope comment)
8341  (dni name
8342       (comment)
8343       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8344	(FR400-MAJOR M-2) (FR450-MAJOR M-2))
8345       (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
8346       (+ pack FRintkeven op FRintieven ope FRintjeven)
8347       (media-quad-arith-sat-semantics 1 operation mode max min)
8348       ((fr400 (unit u-media-1-quad
8349		     (in  FRinti FRintieven)
8350		     (in  FRintj FRintjeven)
8351		     (out FRintk FRintkeven)))
8352	(fr450 (unit u-media-1-quad
8353		     (in  FRinti FRintieven)
8354		     (in  FRintj FRintjeven)
8355		     (out FRintk FRintkeven)))
8356	(fr500 (unit u-media-quad-arith
8357		     (in  FRinti FRintieven)
8358		     (in  FRintj FRintjeven)
8359		     (out FRintk FRintkeven))) (fr550 (unit u-media-quad)))
8360  )
8361)
8362
8363(media-quad-arith-sat mqaddhss add  HI 32767 -32768 OP_7B OPE1_18 "Media quad add signed with saturation")
8364(media-quad-arith-sat mqaddhus add UHI 65535      0 OP_7B OPE1_19 "Media quad add unsigned with saturation")
8365
8366(media-quad-arith-sat mqsubhss sub  HI 32767 -32768 OP_7B OPE1_1A "Media quad sub signed with saturation")
8367(media-quad-arith-sat mqsubhus sub UHI 65535      0 OP_7B OPE1_1B "Media quad sub unsigned with saturation")
8368
8369(define-pmacro (conditional-media-quad-arith-sat
8370		name operation mode max min op ope comment)
8371  (dni name
8372       (comment)
8373       ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
8374	(FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
8375       (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven,$CCi,$cond")
8376       (+ pack FRintkeven op FRintieven CCi cond ope FRintjeven)
8377       (media-quad-arith-sat-semantics (eq CCi (or cond 2))
8378				       operation mode max min)
8379       ((fr400 (unit u-media-1-quad
8380		     (in  FRinti FRintieven)
8381		     (in  FRintj FRintjeven)
8382		     (out FRintk FRintkeven)))
8383	(fr450 (unit u-media-1-quad
8384		     (in  FRinti FRintieven)
8385		     (in  FRintj FRintjeven)
8386		     (out FRintk FRintkeven)))
8387	(fr500 (unit u-media-quad-arith
8388		     (in  FRinti FRintieven)
8389		     (in  FRintj FRintjeven)
8390		     (out FRintk FRintkeven))) (fr550 (unit u-media-quad)))
8391  )
8392)
8393
8394(conditional-media-quad-arith-sat cmqaddhss add  HI 32767 -32768 OP_73 OPE4_0 "Conditional Media quad add signed with saturation")
8395(conditional-media-quad-arith-sat cmqaddhus add UHI 65535      0 OP_73 OPE4_1 "Conditional Media quad add unsigned with saturation")
8396
8397(conditional-media-quad-arith-sat cmqsubhss sub  HI 32767 -32768 OP_73 OPE4_2 "Conditional Media quad sub signed with saturation")
8398(conditional-media-quad-arith-sat cmqsubhus sub UHI 65535      0 OP_73 OPE4_3 "Conditional Media quad sub unsigned with saturation")
8399
8400;; Return A if |A| > |B| and B is positive.  Return -A if |A| > |B| and
8401;; B is negative, saturating 0x8000 as 0x7fff.  Return 0 otherwise.
8402(define-pmacro (media-low-clear-semantics a b)
8403  (cond HI
8404	((le UHI (abs a) (abs b)) 0)
8405	((le HI 0 b) a)
8406	((eq HI a -32768) 32767)
8407	(else (neg a))))
8408
8409;; Return A if -|B| < A < |B|.  Return -B if A <= -|B|, saturating 0x8000
8410;; as 0x7fff.  Return B if A >= |B|.
8411(define-pmacro (media-scope-limit-semantics a b)
8412  (cond HI
8413	((andif (gt HI b -32768)
8414		(ge HI a (abs b))) b)
8415	((gt HI a (neg (abs b))) a)
8416	((eq HI b -32768) 32767)
8417	(else (neg b))))
8418
8419(define-pmacro (media-quad-limit name operation op ope comment)
8420  (dni name
8421       comment
8422       ((UNIT FM0) (MACH fr450) (FR450-MAJOR M-2))
8423       (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
8424       (+ pack FRintkeven op FRintieven ope FRintjeven)
8425       (if (orif (register-unaligned FRintieven 2)
8426		 (orif (register-unaligned FRintjeven 2)
8427		       (register-unaligned FRintkeven 2)))
8428	   (c-call VOID "@cpu@_media_register_not_aligned")
8429	   (sequence ((HI a1) (HI a2) (HI a3) (HI a4)
8430		      (HI b1) (HI b2) (HI b3) (HI b4))
8431		     ; hack to get FRintkeven referenced as a target
8432		     ; for profiling
8433		     (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
8434		     (extract-hilo FRintieven 0 FRintjeven 0 a1 a2 b1 b2)
8435		     (extract-hilo FRintieven 1 FRintjeven 1 a3 a4 b3 b4)
8436		     (set (halfword hi FRintkeven 0) (operation a1 b1))
8437		     (set (halfword lo FRintkeven 0) (operation a2 b2))
8438		     (set (halfword hi FRintkeven 1) (operation a3 b3))
8439		     (set (halfword lo FRintkeven 1) (operation a4 b4))))
8440       ((fr450 (unit u-media-1-quad
8441		     (in  FRinti FRintieven)
8442		     (in  FRintj FRintjeven)
8443		     (out FRintk FRintkeven))))
8444  )
8445)
8446
8447(media-quad-limit mqlclrhs media-low-clear-semantics OP_78 OPE1_10
8448		  "Media quad low clear")
8449(media-quad-limit mqlmths media-scope-limit-semantics OP_78 OPE1_14
8450		  "Media quad scope limitation")
8451
8452(define-pmacro (media-quad-shift name operation op ope comment)
8453  (dni name
8454       (comment)
8455       ((UNIT FM0) (MACH fr450) (FR450-MAJOR M-2))
8456       (.str name "$pack $FRintieven,$u6,$FRintkeven")
8457       (+ pack FRintkeven op FRintieven ope u6)
8458       (if (orif (register-unaligned FRintieven 2)
8459		 (register-unaligned FRintkeven 2))
8460	   (c-call VOID "@cpu@_media_register_not_aligned")
8461	   (sequence ()
8462		     ; hack to get these referenced for profiling
8463		     (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
8464		     (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
8465		     (set (halfword hi FRintkeven 0)
8466			  (operation HI (halfword hi FRintieven 0)
8467					(and u6 #xf)))
8468		     (set (halfword lo FRintkeven 0)
8469			  (operation HI (halfword lo FRintieven 0)
8470					(and u6 #xf)))
8471		     (set (halfword hi FRintkeven 1)
8472			  (operation HI (halfword hi FRintieven 1)
8473					(and u6 #xf)))
8474		     (set (halfword lo FRintkeven 1)
8475			  (operation HI (halfword lo FRintieven 1)
8476					(and u6 #xf)))))
8477       ((fr450 (unit u-media-3-quad
8478		     (in  FRinti FRintieven)
8479		     (in  FRintj FRintieven)
8480		     (out FRintk FRintkeven))))
8481  )
8482)
8483
8484(media-quad-shift mqsllhi sll OP_78 OPE1_11 "Media quad left shift")
8485(media-quad-shift mqsrahi sra OP_78 OPE1_13 "Media quad right shift")
8486
8487(define-pmacro (media-acc-arith-sat name operation mode max min op ope comment)
8488  (dni name
8489       (comment)
8490       ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
8491	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
8492       (.str name "$pack $ACC40Si,$ACC40Sk")
8493       (+ pack ACC40Sk op ACC40Si ope (ACCj-null))
8494       (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
8495	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
8496	       (if (register-unaligned ACC40Si 2)
8497		   (c-call VOID "@cpu@_media_acc_not_aligned")
8498		   (media-arith-sat-semantics operation ACC40Si
8499					      (nextreg h-acc40S ACC40Si 1)
8500					      ACC40Sk mode max min (msr-sie-acci)))))
8501       ((fr400 (unit u-media-2-acc)) (fr450 (unit u-media-2-acc))
8502	(fr550 (unit u-media-4-acc)))
8503  )
8504)
8505
8506(media-acc-arith-sat maddaccs add DI #x7fffffffff (inv DI #x7fffffffff)
8507		     OP_78 OPE1_04 "Media accumulator addition")
8508(media-acc-arith-sat msubaccs sub DI #x7fffffffff (inv DI #x7fffffffff)
8509		     OP_78 OPE1_05 "Media accumulator subtraction")
8510
8511(define-pmacro (media-dual-acc-arith-sat name operation mode max min op ope
8512					 comment)
8513  (dni name
8514       (comment)
8515       ((UNIT MDUALACC) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
8516	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
8517       (.str name "$pack $ACC40Si,$ACC40Sk")
8518       (+ pack ACC40Sk op ACC40Si ope (ACCj-null))
8519       (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
8520	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
8521	       (if (register-unaligned ACC40Si 4)
8522		   (c-call VOID "@cpu@_media_acc_not_aligned")
8523		   (if (register-unaligned ACC40Sk 2)
8524		       (c-call VOID "@cpu@_media_acc_not_aligned")
8525		       (sequence ()
8526				 (media-arith-sat-semantics operation ACC40Si
8527							    (nextreg h-acc40S ACC40Si 1)
8528							    ACC40Sk mode max min
8529							    (msr-sie-acci))
8530				 (media-arith-sat-semantics operation
8531							    (nextreg h-acc40S ACC40Si 2)
8532							    (nextreg h-acc40S ACC40Si 3)
8533							    (nextreg h-acc40S ACC40Sk 1)
8534							    mode max min
8535							    (msr-sie-acci-1)))))))
8536       ((fr400 (unit u-media-2-acc-dual)) (fr450 (unit u-media-2-acc-dual))
8537	(fr550 (unit u-media-4-acc-dual)))
8538  )
8539)
8540
8541(media-dual-acc-arith-sat mdaddaccs add DI #x7fffffffff (inv DI #x7fffffffff)
8542			  OP_78 OPE1_06 "Media accumulator addition")
8543(media-dual-acc-arith-sat mdsubaccs sub DI #x7fffffffff (inv DI #x7fffffffff)
8544			  OP_78 OPE1_07 "Media accumulator subtraction")
8545
8546(dni masaccs
8547     "Media add and subtract signed accumulator with saturation"
8548       ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
8549	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
8550       "masaccs$pack $ACC40Si,$ACC40Sk"
8551       (+ pack ACC40Sk OP_78 ACC40Si OPE1_08 (ACCj-null))
8552       (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
8553	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
8554	       (if (register-unaligned ACC40Si 2)
8555		   (c-call VOID "@cpu@_media_acc_not_aligned")
8556		   (if (register-unaligned ACC40Sk 2)
8557		       (c-call VOID "@cpu@_media_acc_not_aligned")
8558		       (sequence ()
8559				 (media-arith-sat-semantics add ACC40Si
8560							    (nextreg h-acc40S ACC40Si 1)
8561							    ACC40Sk DI
8562							    #x7fffffffff
8563							    (inv DI #x7fffffffff)
8564							    (msr-sie-acci))
8565				 (media-arith-sat-semantics sub ACC40Si
8566							    (nextreg h-acc40S ACC40Si 1)
8567							    (nextreg h-acc40S ACC40Sk 1)
8568							    DI
8569							    #x7fffffffff
8570							    (inv DI #x7fffffffff)
8571							    (msr-sie-acci-1)))))))
8572       ((fr400 (unit u-media-2-add-sub)) (fr450 (unit u-media-2-add-sub))
8573	(fr550 (unit u-media-4-add-sub)))
8574  )
8575
8576(dni mdasaccs
8577     "Media add and subtract signed accumulator with saturation"
8578       ((UNIT MDUALACC) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
8579	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
8580       "mdasaccs$pack $ACC40Si,$ACC40Sk"
8581       (+ pack ACC40Sk OP_78 ACC40Si OPE1_09 (ACCj-null))
8582       (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
8583	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
8584	       (if (register-unaligned ACC40Si 4)
8585		   (c-call VOID "@cpu@_media_acc_not_aligned")
8586		   (if (register-unaligned ACC40Sk 4)
8587		       (c-call VOID "@cpu@_media_acc_not_aligned")
8588		       (sequence ()
8589				 (media-arith-sat-semantics add ACC40Si
8590							    (nextreg h-acc40S ACC40Si 1)
8591							    ACC40Sk DI
8592							    #x7fffffffff
8593							    (inv DI #x7fffffffff)
8594							    (msr-sie-acci))
8595				 (media-arith-sat-semantics sub ACC40Si
8596							    (nextreg h-acc40S ACC40Si 1)
8597							    (nextreg h-acc40S ACC40Sk 1)
8598							    DI
8599							    #x7fffffffff
8600							    (inv DI #x7fffffffff)
8601							    (msr-sie-acci-1))
8602				 (media-arith-sat-semantics add
8603							    (nextreg h-acc40S ACC40Si 2)
8604							    (nextreg h-acc40S ACC40Si 3)
8605							    (nextreg h-acc40S ACC40Sk 2)
8606							    DI
8607							    #x7fffffffff
8608							    (inv DI #x7fffffffff)
8609							    (msr-sie-acci-2))
8610				 (media-arith-sat-semantics sub
8611							    (nextreg h-acc40S ACC40Si 2)
8612							    (nextreg h-acc40S ACC40Si 3)
8613							    (nextreg h-acc40S ACC40Sk 3)
8614							    DI
8615							    #x7fffffffff
8616							    (inv DI #x7fffffffff)
8617							    (msr-sie-acci-3)))))))
8618       ((fr400 (unit u-media-2-add-sub-dual))
8619	(fr450 (unit u-media-2-add-sub-dual))
8620	(fr550 (unit u-media-4-add-sub-dual)))
8621  )
8622
8623(define-pmacro (media-multiply-semantics conv arg1 arg2 res)
8624  (set res (mul DI (conv DI arg1) (conv DI arg2)))
8625)
8626
8627(define-pmacro (media-dual-multiply-semantics cond mode conv rhs1 rhs2)
8628  (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
8629      (if (register-unaligned ACC40Sk 2)
8630	  (c-call VOID "@cpu@_media_acc_not_aligned")
8631	  (if cond
8632	      (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
8633			(extract-hilo FRinti 0 FRintj 0
8634				      argihi argilo argjhi argjlo)
8635			(media-multiply-semantics conv argihi rhs1 ACC40Sk)
8636			(media-multiply-semantics conv argilo rhs2
8637						  (nextreg h-acc40S ACC40Sk 1))))))
8638)
8639
8640(define-pmacro (media-dual-multiply name mode conv rhs1 rhs2 op ope comment)
8641  (dni name
8642       (comment)
8643       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8644	(FR400-MAJOR M-1) (FR450-MAJOR M-3) PRESERVE-OVF)
8645       (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
8646       (+ pack ACC40Sk op FRinti ope FRintj)
8647       (media-dual-multiply-semantics 1 mode conv rhs1 rhs2)
8648       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
8649	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
8650  )
8651)
8652
8653(media-dual-multiply mmulhs  HI ext  argjhi argjlo OP_7B OPE1_14 "Media dual multiply signed")
8654(media-dual-multiply mmulhu UHI zext argjhi argjlo OP_7B OPE1_15 "Media dual multiply unsigned")
8655
8656(media-dual-multiply mmulxhs  HI ext  argjlo argjhi OP_7B OPE1_28 "Media dual cross multiply signed")
8657(media-dual-multiply mmulxhu UHI zext argjlo argjhi OP_7B OPE1_29 "Media dual cross multiply unsigned")
8658
8659(define-pmacro (conditional-media-dual-multiply
8660		name mode conv rhs1 rhs2 op ope comment)
8661  (dni name
8662       (comment)
8663       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8664	(FR400-MAJOR M-1) (FR450-MAJOR M-3)
8665	PRESERVE-OVF CONDITIONAL)
8666       (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
8667       (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
8668       (media-dual-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
8669       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
8670	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
8671  )
8672)
8673
8674(conditional-media-dual-multiply cmmulhs  HI ext  argjhi argjlo OP_72 OPE4_0 "Conditional Media dual multiply signed")
8675(conditional-media-dual-multiply cmmulhu UHI zext argjhi argjlo OP_72 OPE4_1 "Conditional Media dual multiply unsigned")
8676
8677(define-pmacro (media-quad-multiply-semantics cond mode conv rhs1 rhs2)
8678  (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
8679      (if (register-unaligned ACC40Sk 4)
8680	  (c-call VOID "@cpu@_media_acc_not_aligned")
8681	  (if (orif (register-unaligned FRintieven 2)
8682		    (register-unaligned FRintjeven 2))
8683	      (c-call VOID "@cpu@_media_register_not_aligned")
8684	      (if cond
8685		  (sequence ((mode argihi) (mode argilo)
8686			     (mode argjhi) (mode argjlo))
8687			    (extract-hilo FRintieven 0 FRintjeven 0
8688					  argihi argilo argjhi argjlo)
8689			    (media-multiply-semantics conv argihi rhs1 ACC40Sk)
8690			    (media-multiply-semantics conv argilo rhs2
8691						      (nextreg h-acc40S ACC40Sk 1))
8692			    (extract-hilo FRintieven 1 FRintjeven 1
8693					  argihi argilo argjhi argjlo)
8694			    (media-multiply-semantics conv argihi rhs1
8695						      (nextreg h-acc40S ACC40Sk 2))
8696			    (media-multiply-semantics conv argilo rhs2
8697						      (nextreg h-acc40S ACC40Sk 3)))))))
8698)
8699
8700(define-pmacro (media-quad-multiply name mode conv rhs1 rhs2 op ope comment)
8701  (dni name
8702       (comment)
8703       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8704	(FR400-MAJOR M-2) (FR450-MAJOR M-4) PRESERVE-OVF)
8705       (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
8706       (+ pack ACC40Sk op FRintieven ope FRintjeven)
8707       (media-quad-multiply-semantics 1 mode conv rhs1 rhs2)
8708       ((fr400 (unit u-media-2-quad
8709		     (in  FRinti FRintieven)
8710		     (in  FRintj FRintjeven)))
8711	(fr450 (unit u-media-2-quad
8712		     (in  FRinti FRintieven)
8713		     (in  FRintj FRintjeven)))
8714	(fr500 (unit u-media-quad-mul
8715		     (in  FRinti FRintieven)
8716		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
8717  )
8718)
8719
8720(media-quad-multiply mqmulhs  HI ext  argjhi argjlo OP_7B OPE1_1C "Media quad multiply signed")
8721(media-quad-multiply mqmulhu UHI zext argjhi argjlo OP_7B OPE1_1D "Media quad multiply unsigned")
8722
8723(media-quad-multiply mqmulxhs  HI ext  argjlo argjhi OP_7B OPE1_2A "Media quad cross multiply signed")
8724(media-quad-multiply mqmulxhu UHI zext argjlo argjhi OP_7B OPE1_2B "Media quad cross multiply unsigned")
8725
8726(define-pmacro (conditional-media-quad-multiply
8727		name mode conv rhs1 rhs2 op ope comment)
8728  (dni name
8729       (comment)
8730       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8731	(FR400-MAJOR M-2) (FR450-MAJOR M-4)
8732	PRESERVE-OVF CONDITIONAL)
8733       (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk,$CCi,$cond")
8734       (+ pack ACC40Sk op FRintieven CCi cond ope FRintjeven)
8735       (media-quad-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
8736       ((fr400 (unit u-media-2-quad
8737		     (in  FRinti FRintieven)
8738		     (in  FRintj FRintjeven)))
8739	(fr450 (unit u-media-2-quad
8740		     (in  FRinti FRintieven)
8741		     (in  FRintj FRintjeven)))
8742	(fr500 (unit u-media-quad-mul
8743		     (in  FRinti FRintieven)
8744		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
8745  )
8746)
8747
8748(conditional-media-quad-multiply cmqmulhs  HI ext  argjhi argjlo OP_74 OPE4_0 "Conditional Media quad multiply signed")
8749(conditional-media-quad-multiply cmqmulhu UHI zext argjhi argjlo OP_74 OPE4_1 "Conditional Media quad multiply unsigned")
8750
8751(define-pmacro (media-multiply-acc-semantics
8752		conv arg1 addop arg2 res max min sie)
8753  (sequence ((DI tmp))
8754	    (set tmp (addop res (mul DI (conv DI arg1) (conv DI arg2))))
8755	    (saturate-v tmp max min sie res))
8756)
8757
8758(define-pmacro (media-dual-multiply-acc-semantics
8759		cond mode conv addop rhw res max min)
8760  (if (c-call SI "@cpu@_check_acc_range" (index-of res))
8761      (if (register-unaligned res 2)
8762	  (c-call VOID "@cpu@_media_acc_not_aligned")
8763	  (if cond
8764	      (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
8765			(extract-hilo FRinti 0 FRintj 0
8766				      argihi argilo argjhi argjlo)
8767			(media-multiply-acc-semantics conv argihi addop argjhi
8768						      res
8769						      max min (msr-sie-acci))
8770			(media-multiply-acc-semantics conv argilo addop argjlo
8771						      (nextreg rhw res 1)
8772						      max min (msr-sie-acci-1))))))
8773)
8774
8775(define-pmacro (media-dual-multiply-acc
8776		name mode conv addop rhw res max min op ope comment)
8777  (dni name
8778       (comment)
8779       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8780	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
8781       (.str name "$pack $FRinti,$FRintj,$" res)
8782       (+ pack res op FRinti ope FRintj)
8783       (media-dual-multiply-acc-semantics 1 mode conv addop rhw res max min)
8784       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
8785	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
8786  )
8787)
8788
8789(media-dual-multiply-acc mmachs HI ext add h-acc40S ACC40Sk
8790			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
8791			 OP_7B OPE1_16
8792			 "Media dual multiply and accumulate signed")
8793
8794(media-dual-multiply-acc mmachu UHI zext add h-acc40U ACC40Uk
8795			 (const DI #xffffffffff) (const DI 0)
8796			 OP_7B OPE1_17
8797			 "Media dual multiply and accumulate unsigned")
8798
8799(media-dual-multiply-acc mmrdhs HI ext sub h-acc40S ACC40Sk
8800			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
8801			 OP_7B OPE1_30
8802			 "Media dual multiply and reduce signed")
8803
8804(media-dual-multiply-acc mmrdhu UHI zext sub h-acc40U ACC40Uk
8805			 (const DI #xffffffffff) (const DI 0)
8806			 OP_7B OPE1_31
8807			 "Media dual multiply and reduce unsigned")
8808
8809(define-pmacro (conditional-media-dual-multiply-acc
8810		name mode conv addop rhw res max min op ope comment)
8811  (dni name
8812       (comment)
8813       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8814	(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
8815       (.str name "$pack $FRinti,$FRintj,$" res ",$CCi,$cond")
8816       (+ pack res op FRinti CCi cond ope FRintj)
8817       (media-dual-multiply-acc-semantics (eq CCi (or cond 2))
8818					  mode conv addop rhw res max min)
8819       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
8820	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
8821  )
8822)
8823
8824(conditional-media-dual-multiply-acc cmmachs HI ext add h-acc40S ACC40Sk
8825			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
8826			 OP_72 OPE4_2
8827			 "Conditional Media dual multiply and accumulate signed")
8828
8829(conditional-media-dual-multiply-acc cmmachu UHI zext add  h-acc40U ACC40Uk
8830			 (const DI #xffffffffff) (const DI 0)
8831			 OP_72 OPE4_3
8832			 "Conditional Media dual multiply and accumulate unsigned")
8833
8834(define-pmacro (media-quad-multiply-acc-semantics
8835		cond mode conv addop rhw res max min)
8836  (if (c-call SI "@cpu@_check_acc_range" (index-of res))
8837      (if (register-unaligned res 4)
8838	  (c-call VOID "@cpu@_media_acc_not_aligned")
8839	  (if (orif (register-unaligned FRintieven 2)
8840		    (register-unaligned FRintjeven 2))
8841	      (c-call VOID "@cpu@_media_register_not_aligned")
8842	      (if cond
8843		  (sequence ((mode argihi) (mode argilo)
8844			     (mode argjhi) (mode argjlo))
8845			    (extract-hilo FRintieven 0 FRintjeven 0
8846					  argihi argilo argjhi argjlo)
8847			    (media-multiply-acc-semantics conv argihi addop argjhi
8848							  res
8849							  max min (msr-sie-acci))
8850			    (media-multiply-acc-semantics conv argilo addop argjlo
8851							  (nextreg rhw res 1)
8852							  max min (msr-sie-acci-1))
8853			    (extract-hilo FRintieven 1 FRintjeven 1
8854					  argihi argilo argjhi argjlo)
8855			    (media-multiply-acc-semantics conv argihi addop argjhi
8856							  (nextreg rhw res 2)
8857							  max min (msr-sie-acci-2))
8858			    (media-multiply-acc-semantics conv argilo addop argjlo
8859							  (nextreg rhw res 3)
8860							  max min
8861							  (msr-sie-acci-3)))))))
8862)
8863
8864(define-pmacro (media-quad-multiply-acc
8865		name mode conv addop rhw res max min op ope comment)
8866  (dni name
8867       (comment)
8868       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8869	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
8870       (.str name "$pack $FRintieven,$FRintjeven,$" res)
8871       (+ pack res op FRintieven ope FRintjeven)
8872       (media-quad-multiply-acc-semantics 1 mode conv addop rhw res max min)
8873       ((fr400 (unit u-media-2-quad
8874		     (in  FRinti FRintieven)
8875		     (in  FRintj FRintjeven)))
8876	(fr450 (unit u-media-2-quad
8877		     (in  FRinti FRintieven)
8878		     (in  FRintj FRintjeven)))
8879	(fr500 (unit u-media-quad-mul
8880		     (in  FRinti FRintieven)
8881		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
8882  )
8883)
8884
8885(media-quad-multiply-acc mqmachs HI ext add h-acc40S ACC40Sk
8886			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
8887			 OP_7B OPE1_1E
8888			 "Media quad multiply and accumulate signed")
8889
8890(media-quad-multiply-acc mqmachu UHI zext add h-acc40U ACC40Uk
8891			 (const DI #xffffffffff) (const DI 0)
8892			 OP_7B OPE1_1F
8893			 "Media quad multiply and accumulate unsigned")
8894
8895(define-pmacro (conditional-media-quad-multiply-acc
8896		name mode conv addop rhw res max min op ope comment)
8897  (dni name
8898       (comment)
8899       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
8900	(FR400-MAJOR M-2) (FR450-MAJOR M-4) CONDITIONAL)
8901       (.str name "$pack $FRintieven,$FRintjeven,$" res ",$CCi,$cond")
8902       (+ pack res op FRintieven CCi cond ope FRintjeven)
8903       (media-quad-multiply-acc-semantics (eq CCi (or cond 2))
8904					  mode conv addop rhw res max min)
8905       ((fr400 (unit u-media-2-quad
8906		     (in  FRinti FRintieven)
8907		     (in  FRintj FRintjeven)))
8908	(fr450 (unit u-media-2-quad
8909		     (in  FRinti FRintieven)
8910		     (in  FRintj FRintjeven)))
8911	(fr500 (unit u-media-quad-mul
8912		     (in  FRinti FRintieven)
8913		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
8914  )
8915)
8916
8917(conditional-media-quad-multiply-acc cmqmachs HI ext add h-acc40S ACC40Sk
8918			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
8919			 OP_74 OPE4_2
8920			 "Conditional Media quad multiply and accumulate signed")
8921
8922(conditional-media-quad-multiply-acc cmqmachu UHI zext add h-acc40U ACC40Uk
8923			 (const DI #xffffffffff) (const DI 0)
8924			 OP_74 OPE4_3
8925			 "Conditional media quad multiply and accumulate unsigned")
8926
8927(define-pmacro (media-quad-multiply-cross-acc-semantics
8928		cond mode conv addop rhw res max min)
8929  (if (c-call SI "@cpu@_check_acc_range" (index-of res))
8930      (if (register-unaligned res 4)
8931	  (c-call VOID "@cpu@_media_acc_not_aligned")
8932	  (if (orif (register-unaligned FRintieven 2)
8933		    (register-unaligned FRintjeven 2))
8934	      (c-call VOID "@cpu@_media_register_not_aligned")
8935	      (if cond
8936		  (sequence ((mode argihi) (mode argilo)
8937			     (mode argjhi) (mode argjlo))
8938			    (extract-hilo FRintieven 0 FRintjeven 0
8939					  argihi argilo argjhi argjlo)
8940			    (media-multiply-acc-semantics conv argihi addop argjhi
8941							  (nextreg rhw res 2)
8942							  max min (msr-sie-acci-2))
8943			    (media-multiply-acc-semantics conv argilo addop argjlo
8944							  (nextreg rhw res 3)
8945							  max min (msr-sie-acci-3))
8946			    (extract-hilo FRintieven 1 FRintjeven 1
8947					  argihi argilo argjhi argjlo)
8948			    (media-multiply-acc-semantics conv argihi addop argjhi
8949							  res
8950							  max min (msr-sie-acci))
8951			    (media-multiply-acc-semantics conv argilo addop argjlo
8952							  (nextreg rhw res 1)
8953							  max min
8954							  (msr-sie-acci-1)))))))
8955)
8956
8957(define-pmacro (media-quad-multiply-cross-acc
8958		name mode conv addop rhw res max min op ope comment)
8959  (dni name
8960       (comment)
8961       ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
8962	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
8963       (.str name "$pack $FRintieven,$FRintjeven,$" res)
8964       (+ pack res op FRintieven ope FRintjeven)
8965       (media-quad-multiply-cross-acc-semantics 1 mode conv addop rhw res
8966						max min)
8967       ((fr400 (unit u-media-2-quad
8968		     (in  FRinti FRintieven)
8969		     (in  FRintj FRintjeven)))
8970	(fr450 (unit u-media-2-quad
8971		     (in  FRinti FRintieven)
8972		     (in  FRintj FRintjeven)))
8973	(fr550 (unit u-media-4-quad)))
8974  )
8975)
8976
8977(media-quad-multiply-cross-acc mqxmachs HI ext add h-acc40S ACC40Sk
8978			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
8979			 OP_78 OPE1_00
8980			 "Media quad multiply and cross accumulate signed")
8981
8982(define-pmacro (media-quad-cross-multiply-cross-acc-semantics
8983		cond mode conv addop rhw res max min)
8984  (if (c-call SI "@cpu@_check_acc_range" (index-of res))
8985      (if (register-unaligned res 4)
8986	  (c-call VOID "@cpu@_media_acc_not_aligned")
8987	  (if (orif (register-unaligned FRintieven 2)
8988		    (register-unaligned FRintjeven 2))
8989	      (c-call VOID "@cpu@_media_register_not_aligned")
8990	      (if cond
8991		  (sequence ((mode argihi) (mode argilo)
8992			     (mode argjhi) (mode argjlo))
8993			    (extract-hilo FRintieven 0 FRintjeven 0
8994					  argihi argilo argjhi argjlo)
8995			    (media-multiply-acc-semantics conv argihi addop argjlo
8996							  (nextreg rhw res 2)
8997							  max min (msr-sie-acci-2))
8998			    (media-multiply-acc-semantics conv argilo addop argjhi
8999							  (nextreg rhw res 3)
9000							  max min (msr-sie-acci-3))
9001			    (extract-hilo FRintieven 1 FRintjeven 1
9002					  argihi argilo argjhi argjlo)
9003			    (media-multiply-acc-semantics conv argihi addop argjlo
9004							  res
9005							  max min (msr-sie-acci))
9006			    (media-multiply-acc-semantics conv argilo addop argjhi
9007							  (nextreg rhw res 1)
9008							  max min
9009							  (msr-sie-acci-1)))))))
9010)
9011
9012(define-pmacro (media-quad-cross-multiply-cross-acc
9013		name mode conv addop rhw res max min op ope comment)
9014  (dni name
9015       (comment)
9016       ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
9017	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
9018       (.str name "$pack $FRintieven,$FRintjeven,$" res)
9019       (+ pack res op FRintieven ope FRintjeven)
9020       (media-quad-cross-multiply-cross-acc-semantics 1 mode conv addop rhw res
9021						      max min)
9022       ((fr400 (unit u-media-2-quad
9023		     (in  FRinti FRintieven)
9024		     (in  FRintj FRintjeven)))
9025	(fr450 (unit u-media-2-quad
9026		     (in  FRinti FRintieven)
9027		     (in  FRintj FRintjeven)))
9028	(fr550 (unit u-media-4-quad)))
9029  )
9030)
9031
9032(media-quad-cross-multiply-cross-acc mqxmacxhs HI ext add h-acc40S ACC40Sk
9033			(const DI #x7fffffffff) (const DI #xffffff8000000000)
9034			OP_78 OPE1_01
9035			"Media quad cross multiply and cross accumulate signed")
9036
9037(define-pmacro (media-quad-cross-multiply-acc-semantics
9038		cond mode conv addop rhw res max min)
9039  (if (c-call SI "@cpu@_check_acc_range" (index-of res))
9040      (if (register-unaligned res 4)
9041	  (c-call VOID "@cpu@_media_acc_not_aligned")
9042	  (if (orif (register-unaligned FRintieven 2)
9043		    (register-unaligned FRintjeven 2))
9044	      (c-call VOID "@cpu@_media_register_not_aligned")
9045	      (if cond
9046		  (sequence ((mode argihi) (mode argilo)
9047			     (mode argjhi) (mode argjlo))
9048			    (extract-hilo FRintieven 0 FRintjeven 0
9049					  argihi argilo argjhi argjlo)
9050			    (media-multiply-acc-semantics conv argihi addop argjlo
9051							  res
9052							  max min (msr-sie-acci))
9053			    (media-multiply-acc-semantics conv argilo addop argjhi
9054							  (nextreg rhw res 1)
9055							  max min (msr-sie-acci-1))
9056			    (extract-hilo FRintieven 1 FRintjeven 1
9057					  argihi argilo argjhi argjlo)
9058			    (media-multiply-acc-semantics conv argihi addop argjlo
9059							  (nextreg rhw res 2)
9060							  max min (msr-sie-acci-2))
9061			    (media-multiply-acc-semantics conv argilo addop argjhi
9062							  (nextreg rhw res 3)
9063							  max min
9064							  (msr-sie-acci-3)))))))
9065)
9066
9067(define-pmacro (media-quad-cross-multiply-acc
9068		name mode conv addop rhw res max min op ope comment)
9069  (dni name
9070       (comment)
9071       ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
9072	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
9073       (.str name "$pack $FRintieven,$FRintjeven,$" res)
9074       (+ pack res op FRintieven ope FRintjeven)
9075       (media-quad-cross-multiply-acc-semantics 1 mode conv addop rhw res
9076						max min)
9077       ((fr400 (unit u-media-2-quad
9078		     (in FRinti FRintieven)
9079		     (in FRintj FRintjeven)))
9080	(fr450 (unit u-media-2-quad
9081		     (in FRinti FRintieven)
9082		     (in FRintj FRintjeven)))
9083	(fr550 (unit u-media-4-quad)))
9084  )
9085)
9086
9087(media-quad-cross-multiply-acc mqmacxhs HI ext add h-acc40S ACC40Sk
9088			(const DI #x7fffffffff) (const DI #xffffff8000000000)
9089			OP_78 OPE1_02
9090			"Media quad cross multiply and accumulate signed")
9091
9092(define-pmacro (media-complex-semantics
9093		conv lhs1 rhs1 lhs2 rhs2 res max min sie)
9094  (sequence ((DI tmp1) (DI tmp2))
9095	    (media-multiply-semantics conv lhs1 rhs1 tmp1)
9096	    (media-multiply-semantics conv lhs2 rhs2 tmp2)
9097	    (set tmp1 (sub tmp1 tmp2))
9098	    (saturate-v tmp1 max min sie res))
9099)
9100
9101(define-pmacro (media-complex-semantics-i
9102		conv lhs1 rhs1 lhs2 rhs2 res max min sie)
9103  (sequence ((DI tmp1) (DI tmp2))
9104	    (media-multiply-semantics conv lhs1 rhs1 tmp1)
9105	    (media-multiply-semantics conv lhs2 rhs2 tmp2)
9106	    (set tmp1 (add tmp1 tmp2))
9107	    (saturate-v tmp1 max min sie res))
9108)
9109
9110(define-pmacro (media-dual-complex-semantics mode conv rhs1 rhs2 max min)
9111  (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
9112      (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
9113		(extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
9114		(media-complex-semantics conv argihi rhs1 argilo rhs2 ACC40Sk
9115					 max min (msr-sie-acci))))
9116)
9117
9118(define-pmacro (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
9119  (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
9120      (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
9121		(extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
9122		(media-complex-semantics-i conv argihi rhs1 argilo rhs2 ACC40Sk
9123					   max min (msr-sie-acci))))
9124)
9125
9126(define-pmacro (media-dual-complex
9127		name mode conv rhs1 rhs2 max min op ope comment)
9128  (dni name
9129       (comment)
9130       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
9131	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
9132       (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
9133       (+ pack ACC40Sk op FRinti ope FRintj)
9134       (media-dual-complex-semantics mode conv rhs1 rhs2 max min)
9135       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
9136	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
9137  )
9138)
9139
9140(define-pmacro (media-dual-complex-i
9141		name mode conv rhs1 rhs2 max min op ope comment)
9142  (dni name
9143       (comment)
9144       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
9145	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
9146       (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
9147       (+ pack ACC40Sk op FRinti ope FRintj)
9148       (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
9149       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
9150	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
9151  )
9152)
9153
9154(media-dual-complex mcpxrs HI ext argjhi argjlo
9155		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
9156		    OP_7B OPE1_20
9157		    "Media dual complex real signed with saturation")
9158
9159(media-dual-complex mcpxru UHI zext argjhi argjlo
9160		    (const DI #xffffffffff) (const DI 0)
9161		    OP_7B OPE1_21
9162		    "Media dual complex real unsigned with saturation")
9163
9164(media-dual-complex-i mcpxis HI ext argjlo argjhi
9165		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
9166		    OP_7B OPE1_22
9167		    "Media dual complex imaginary signed with saturation")
9168
9169(media-dual-complex-i mcpxiu UHI zext argjlo argjhi
9170		    (const DI #xffffffffff) (const DI 0)
9171		    OP_7B OPE1_23
9172		    "Media dual complex imaginary unsigned with saturation")
9173
9174(define-pmacro (conditional-media-dual-complex
9175		name mode conv rhs1 rhs2 max min op ope comment)
9176  (dni name
9177       (comment)
9178       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
9179	(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
9180       (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
9181       (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
9182       (if (eq CCi (or cond 2))
9183	   (media-dual-complex-semantics mode conv rhs1 rhs2 max min))
9184       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
9185	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
9186  )
9187)
9188
9189(define-pmacro (conditional-media-dual-complex-i
9190		name mode conv rhs1 rhs2 max min op ope comment)
9191  (dni name
9192       (comment)
9193       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
9194	(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
9195       (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
9196       (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
9197       (if (eq CCi (or cond 2))
9198	   (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min))
9199       ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
9200	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
9201  )
9202)
9203
9204(conditional-media-dual-complex cmcpxrs HI ext argjhi argjlo
9205		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
9206		    OP_75 OPE4_0
9207		    "Conditional Media dual complex real signed with saturation")
9208
9209(conditional-media-dual-complex cmcpxru UHI zext argjhi argjlo
9210		    (const DI #xffffffffff) (const DI 0)
9211		    OP_75 OPE4_1
9212		    "Conditional Media dual complex real unsigned with saturation")
9213
9214(conditional-media-dual-complex-i cmcpxis HI ext argjlo argjhi
9215		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
9216		    OP_75 OPE4_2
9217		    "Conditional Media dual complex imaginary signed with saturation")
9218
9219(conditional-media-dual-complex-i cmcpxiu UHI zext argjlo argjhi
9220		    (const DI #xffffffffff) (const DI 0)
9221		    OP_75 OPE4_3
9222		    "Conditional Media dual complex imaginary unsigned with saturation")
9223
9224(define-pmacro (media-quad-complex
9225		name mode conv rhs1 rhs2 max min op ope comment)
9226  (dni name
9227       (comment)
9228       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
9229	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
9230       (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
9231       (+ pack ACC40Sk op FRintieven ope FRintjeven)
9232       (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
9233	   (if (register-unaligned ACC40Sk 2)
9234	       (c-call VOID "@cpu@_media_acc_not_aligned")
9235	       (if (orif (register-unaligned FRintieven 2)
9236			 (register-unaligned FRintjeven 2))
9237		   (c-call VOID "@cpu@_media_register_not_aligned")
9238		   (sequence ((mode argihi) (mode argilo)
9239			      (mode argjhi) (mode argjlo))
9240			     (extract-hilo FRintieven 0 FRintjeven 0
9241					   argihi argilo argjhi argjlo)
9242			     (media-complex-semantics conv argihi rhs1 argilo rhs2
9243						      ACC40Sk
9244						      max min (msr-sie-acci))
9245			     (extract-hilo FRintieven 1 FRintjeven 1
9246					   argihi argilo argjhi argjlo)
9247			     (media-complex-semantics conv argihi rhs1 argilo rhs2
9248						      (nextreg h-acc40S ACC40Sk 1)
9249						      max min (msr-sie-acci-1))))))
9250       ((fr400 (unit u-media-2-quad
9251		     (in FRinti FRintieven)
9252		     (in FRintj FRintjeven)))
9253	(fr450 (unit u-media-2-quad
9254		     (in FRinti FRintieven)
9255		     (in FRintj FRintjeven)))
9256	(fr500 (unit u-media-quad-complex
9257		     (in FRinti FRintieven)
9258		     (in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
9259  )
9260)
9261
9262(define-pmacro (media-quad-complex-i
9263		name mode conv rhs1 rhs2 max min op ope comment)
9264  (dni name
9265       (comment)
9266       ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
9267	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
9268       (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
9269       (+ pack ACC40Sk op FRintieven ope FRintjeven)
9270       (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
9271	   (if (register-unaligned ACC40Sk 2)
9272	       (c-call VOID "@cpu@_media_acc_not_aligned")
9273	       (if (orif (register-unaligned FRintieven 2)
9274			 (register-unaligned FRintjeven 2))
9275		   (c-call VOID "@cpu@_media_register_not_aligned")
9276		   (sequence ((mode argihi) (mode argilo)
9277			      (mode argjhi) (mode argjlo))
9278			     (extract-hilo FRintieven 0 FRintjeven 0
9279					   argihi argilo argjhi argjlo)
9280			     (media-complex-semantics-i conv argihi rhs1 argilo rhs2
9281							ACC40Sk
9282							max min (msr-sie-acci))
9283			     (extract-hilo FRintieven 1 FRintjeven 1
9284					   argihi argilo argjhi argjlo)
9285			     (media-complex-semantics-i conv argihi rhs1 argilo rhs2
9286							(nextreg h-acc40S ACC40Sk 1)
9287							max min (msr-sie-acci-1))))))
9288       ((fr400 (unit u-media-2-quad
9289		     (in FRinti FRintieven)
9290		     (in FRintj FRintjeven)))
9291	(fr450 (unit u-media-2-quad
9292		     (in FRinti FRintieven)
9293		     (in FRintj FRintjeven)))
9294	(fr500 (unit u-media-quad-complex
9295		     (in FRinti FRintieven)
9296		     (in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
9297  )
9298)
9299
9300(media-quad-complex mqcpxrs HI ext argjhi argjlo
9301		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
9302		    OP_7B OPE1_24
9303		    "Media quad complex real signed with saturation")
9304
9305(media-quad-complex mqcpxru UHI zext argjhi argjlo
9306		    (const DI #xffffffffff) (const DI 0)
9307		    OP_7B OPE1_25
9308		    "Media quad complex real unsigned with saturation")
9309
9310(media-quad-complex-i mqcpxis HI ext argjlo argjhi
9311		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
9312		    OP_7B OPE1_26
9313		    "Media quad complex imaginary signed with saturation")
9314
9315(media-quad-complex-i mqcpxiu UHI zext argjlo argjhi
9316		    (const DI #xffffffffff) (const DI 0)
9317		    OP_7B OPE1_27
9318		    "Media quad complex imaginary unsigned with saturation")
9319
9320(define-pmacro (media-pack src1 src2 targ offset)
9321  (sequence ()
9322	    (set (halfword hi targ offset) (halfword lo src1 offset))
9323	    (set (halfword lo targ offset) (halfword lo src2 offset)))
9324)
9325
9326(define-pmacro (media-expand-halfword-to-word-semantics cond)
9327  (if cond
9328      (sequence ((UHI tmp))
9329		(if (and u6 1)
9330		    (set tmp (halfword lo FRinti 0))
9331		    (set tmp (halfword hi FRinti 0)))
9332		(set (halfword hi FRintk 0) tmp)
9333		(set (halfword lo FRintk 0) tmp)))
9334)
9335
9336(dni mexpdhw
9337     "Media expand halfword to word"
9338     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9339      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
9340     "mexpdhw$pack $FRinti,$u6,$FRintk"
9341     (+ pack FRintk OP_7B FRinti OPE1_32 u6)
9342     (media-expand-halfword-to-word-semantics 1)
9343     ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
9344      (fr500 (unit u-media)) (fr550 (unit u-media)))
9345)
9346
9347(dni cmexpdhw
9348     "Conditional media expand halfword to word"
9349     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9350      (FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
9351     "cmexpdhw$pack $FRinti,$u6,$FRintk,$CCi,$cond"
9352     (+ pack FRintk OP_76 FRinti CCi cond OPE4_2 u6)
9353     (media-expand-halfword-to-word-semantics (eq CCi (or cond 2)))
9354     ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
9355      (fr500 (unit u-media)) (fr550 (unit u-media)))
9356)
9357
9358(define-pmacro (media-expand-halfword-to-double-semantics cond)
9359  (if (register-unaligned FRintkeven 2)
9360      (c-call VOID "@cpu@_media_register_not_aligned")
9361      (if cond
9362	  (sequence ((UHI tmp))
9363		    ; a hack to get FRintkeven referenced for profiling
9364		    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
9365		    (if (and u6 1)
9366			(set tmp (halfword lo FRinti 0))
9367			(set tmp (halfword hi FRinti 0)))
9368		    (set (halfword hi FRintkeven 0) tmp)
9369		    (set (halfword lo FRintkeven 0) tmp)
9370		    (set (halfword hi FRintkeven 1) tmp)
9371		    (set (halfword lo FRintkeven 1) tmp))))
9372)
9373
9374(dni mexpdhd
9375     "Media expand halfword to double"
9376     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9377      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
9378     "mexpdhd$pack $FRinti,$u6,$FRintkeven"
9379     (+ pack FRintkeven OP_7B FRinti OPE1_33 u6)
9380     (media-expand-halfword-to-double-semantics 1)
9381     ((fr400 (unit u-media-dual-expand
9382		   (out FRintk FRintkeven)))
9383      (fr450 (unit u-media-dual-expand
9384		   (out FRintk FRintkeven)))
9385      (fr500 (unit u-media-dual-expand
9386		   (out FRintk FRintkeven)))
9387      (fr550 (unit u-media-dual-expand)))
9388)
9389
9390(dni cmexpdhd
9391     "Conditional media expand halfword to double"
9392     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9393      (FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
9394     "cmexpdhd$pack $FRinti,$u6,$FRintkeven,$CCi,$cond"
9395     (+ pack FRintkeven OP_76 FRinti CCi cond OPE4_3 u6)
9396     (media-expand-halfword-to-double-semantics (eq CCi (or cond 2)))
9397     ((fr400 (unit u-media-dual-expand
9398		   (out FRintk FRintkeven)))
9399      (fr450 (unit u-media-dual-expand
9400		   (out FRintk FRintkeven)))
9401      (fr500 (unit u-media-dual-expand
9402		   (out FRintk FRintkeven)))
9403      (fr550 (unit u-media-dual-expand)))
9404)
9405
9406(dni mpackh
9407     "Media halfword pack"
9408     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9409      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
9410     "mpackh$pack $FRinti,$FRintj,$FRintk"
9411     (+ pack FRintk OP_7B FRinti OPE1_34 FRintj)
9412     (media-pack FRinti FRintj FRintk 0)
9413     ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
9414      (fr500 (unit u-media)) (fr550 (unit u-media)))
9415)
9416
9417(dni mdpackh
9418     "Media dual pack"
9419     ((UNIT FM01) (FR500-MAJOR M-5) (FR550-MAJOR M-3)
9420      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
9421     "mdpackh$pack $FRintieven,$FRintjeven,$FRintkeven"
9422     (+ pack FRintkeven OP_7B FRintieven OPE1_36 FRintjeven)
9423     (if (orif (register-unaligned FRintieven 2)
9424	       (orif (register-unaligned FRintjeven 2)
9425		     (register-unaligned FRintkeven 2)))
9426	 (c-call VOID "@cpu@_media_register_not_aligned")
9427	 (sequence ()
9428		   ; hack to get these referenced for profiling
9429		   (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
9430		   (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
9431		   (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
9432		   (media-pack FRintieven FRintjeven FRintkeven 0)
9433		   (media-pack FRintieven FRintjeven FRintkeven 1)))
9434     ((fr400 (unit u-media-3-quad
9435		   (in  FRinti FRintieven)
9436		   (in  FRintj FRintjeven)
9437		   (out FRintk FRintkeven)))
9438      (fr450 (unit u-media-3-quad
9439		   (in  FRinti FRintieven)
9440		   (in  FRintj FRintjeven)
9441		   (out FRintk FRintkeven)))
9442      (fr500 (unit u-media-quad-arith
9443		   (in  FRinti FRintieven)
9444		   (in  FRintj FRintjeven)
9445		   (out FRintk FRintkeven)))
9446      (fr550 (unit u-media-quad)))
9447)
9448
9449(define-pmacro (media-unpack src soff targ toff)
9450  (sequence ()
9451	    (set (halfword hi targ toff) (halfword hi src soff))
9452	    (set (halfword lo targ toff) (halfword hi src soff))
9453	    (set (halfword hi targ (add toff 1)) (halfword lo src soff))
9454	    (set (halfword lo targ (add toff 1)) (halfword lo src soff)))
9455)
9456
9457(dni munpackh
9458     "Media halfword unpack"
9459     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9460      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
9461     "munpackh$pack $FRinti,$FRintkeven"
9462     (+ pack FRintkeven OP_7B FRinti OPE1_35 (FRj-null))
9463     (if (register-unaligned FRintkeven 2)
9464	 (c-call VOID "@cpu@_media_register_not_aligned")
9465	 (sequence ()
9466		   ; hack to get these referenced for profiling
9467		   (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
9468		   (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
9469		   (media-unpack FRinti 0 FRintkeven 0)))
9470     ((fr400 (unit u-media-dual-expand
9471		   (out FRintk FRintkeven)))
9472      (fr450 (unit u-media-dual-expand
9473		   (out FRintk FRintkeven)))
9474      (fr500 (unit u-media-dual-expand
9475		   (out FRintk FRintkeven)))
9476      (fr550 (unit u-media-dual-expand)))
9477)
9478
9479(dni mdunpackh
9480     "Media dual unpack"
9481     ((UNIT FM01) (FR500-MAJOR M-7) (MACH simple,tomcat,frv))
9482     "mdunpackh$pack $FRintieven,$FRintk"
9483     (+ pack FRintk OP_7B FRintieven OPE1_37 (FRj-null))
9484     (if (orif (register-unaligned FRintieven 2) (register-unaligned FRintk 4))
9485	 (c-call VOID "@cpu@_media_register_not_aligned")
9486	 (sequence ()
9487		   ; hack to get these referenced for profiling
9488		   (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
9489		   (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
9490		   (media-unpack FRintieven 0 FRintk 0)
9491		   (media-unpack FRintieven 1 FRintk 2)))
9492     ((fr500 (unit u-media-dual-unpack
9493		   (in FRinti FRintieven))))
9494)
9495
9496(define-pmacro (ubyte num arg offset)
9497  (reg (.sym h-fr_ num) (add (index-of arg) offset)))
9498
9499(define-pmacro (mbtoh-semantics cond)
9500  (if (register-unaligned FRintkeven 2)
9501      (c-call VOID "@cpu@_media_register_not_aligned")
9502      (if cond
9503	  (sequence ()
9504		    (set (halfword hi FRintkeven 0) (ubyte 3 FRintj 0))
9505		    (set (halfword lo FRintkeven 0) (ubyte 2 FRintj 0))
9506		    (set (halfword hi FRintkeven 1) (ubyte 1 FRintj 0))
9507		    (set (halfword lo FRintkeven 1) (ubyte 0 FRintj 0)))))
9508)
9509
9510(dni mbtoh
9511     "Media convert byte to halfword"
9512     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9513      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
9514     "mbtoh$pack $FRintj,$FRintkeven"
9515     (+ pack FRintkeven OP_7B (FRi-null) OPE1_38 FRintj)
9516     (sequence ()
9517	       ; hack to get these referenced for profiling
9518	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
9519	       (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
9520	       (mbtoh-semantics 1))
9521     ((fr400 (unit u-media-dual-expand
9522		   (out FRintk FRintkeven)))
9523      (fr450 (unit u-media-dual-expand
9524		   (out FRintk FRintkeven)))
9525      (fr500 (unit u-media-dual-btoh
9526		   (out FRintk FRintkeven)))
9527      (fr550 (unit u-media-dual-expand)))
9528)
9529
9530(dni cmbtoh
9531     "Conditional media convert byte to halfword"
9532     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9533      (FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
9534     "cmbtoh$pack $FRintj,$FRintkeven,$CCi,$cond"
9535     (+ pack FRintkeven OP_77 (FRi-null) CCi cond OPE4_0 FRintj)
9536     (sequence ()
9537	       ; hack to get these referenced for profiling
9538	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
9539	       (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
9540	       (mbtoh-semantics (eq CCi (or cond 2))))
9541     ((fr400 (unit u-media-dual-expand
9542		   (out FRintk FRintkeven)))
9543      (fr450 (unit u-media-dual-expand
9544		   (out FRintk FRintkeven)))
9545      (fr500 (unit u-media-dual-btoh
9546		   (out FRintk FRintkeven)))
9547      (fr550 (unit u-media-dual-expand
9548		   (in FRinti FRintj))))
9549)
9550
9551(define-pmacro (mhtob-semantics cond)
9552  (if (register-unaligned FRintjeven 2)
9553      (c-call VOID "@cpu@_media_register_not_aligned")
9554      (if cond
9555	  (sequence ()
9556		    (set (ubyte 3 FRintk 0) (halfword hi FRintjeven 0))
9557		    (set (ubyte 2 FRintk 0) (halfword lo FRintjeven 0))
9558		    (set (ubyte 1 FRintk 0) (halfword hi FRintjeven 1))
9559		    (set (ubyte 0 FRintk 0) (halfword lo FRintjeven 1)))))
9560)
9561
9562(dni mhtob
9563     "Media convert halfword to byte"
9564     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9565      (FR400-MAJOR M-2) (FR450-MAJOR M-2))
9566     "mhtob$pack $FRintjeven,$FRintk"
9567     (+ pack FRintk OP_7B (FRi-null) OPE1_39 FRintjeven)
9568     (sequence ()
9569	       ; hack to get these referenced for profiling
9570	       (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
9571	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
9572	       (mhtob-semantics 1))
9573     ((fr400 (unit u-media-dual-htob
9574		   (in FRintj FRintjeven)))
9575      (fr450 (unit u-media-dual-htob
9576		   (in FRintj FRintjeven)))
9577      (fr500 (unit u-media-dual-htob
9578		   (in FRintj FRintjeven)))
9579      (fr550 (unit u-media-3-dual
9580		   (in FRinti FRintjeven))))
9581)
9582
9583(dni cmhtob
9584     "Conditional media convert halfword to byte"
9585     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9586      (FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
9587     "cmhtob$pack $FRintjeven,$FRintk,$CCi,$cond"
9588     (+ pack FRintk OP_77 (FRi-null) CCi cond OPE4_1 FRintjeven)
9589     (sequence ()
9590	       ; hack to get these referenced for profiling
9591	       (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
9592	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
9593	       (mhtob-semantics (eq CCi (or cond 2))))
9594     ((fr400 (unit u-media-dual-htob
9595		   (in FRintj FRintjeven)))
9596      (fr450 (unit u-media-dual-htob
9597		   (in FRintj FRintjeven)))
9598      (fr500 (unit u-media-dual-htob
9599		   (in FRintj FRintjeven)))
9600      (fr550 (unit u-media-3-dual
9601		   (in FRinti FRintjeven))))
9602)
9603
9604(define-pmacro (mbtohe-semantics cond)
9605  (if (register-unaligned FRintk 4)
9606      (c-call VOID "@cpu@_media_register_not_aligned")
9607      (if cond
9608	  (sequence ()
9609		    (set (halfword hi FRintk 0) (ubyte 3 FRintj 0))
9610		    (set (halfword lo FRintk 0) (ubyte 3 FRintj 0))
9611		    (set (halfword hi FRintk 1) (ubyte 2 FRintj 0))
9612		    (set (halfword lo FRintk 1) (ubyte 2 FRintj 0))
9613		    (set (halfword hi FRintk 2) (ubyte 1 FRintj 0))
9614		    (set (halfword lo FRintk 2) (ubyte 1 FRintj 0))
9615		    (set (halfword hi FRintk 3) (ubyte 0 FRintj 0))
9616		    (set (halfword lo FRintk 3) (ubyte 0 FRintj 0)))))
9617)
9618
9619(dni mbtohe
9620     "Media convert byte to halfword extended"
9621     ((UNIT FM01) (FR500-MAJOR M-7) (MACH simple,tomcat,frv))
9622     "mbtohe$pack $FRintj,$FRintk"
9623     (+ pack FRintk OP_7B (FRi-null) OPE1_3A FRintj)
9624     (sequence ()
9625	       ; hack to get these referenced for profiling
9626	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
9627	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
9628	       (mbtohe-semantics 1))
9629     ((fr500 (unit u-media-dual-btohe)))
9630)
9631
9632(dni cmbtohe
9633     "Conditional media convert byte to halfword extended"
9634     ((UNIT FM01) (FR500-MAJOR M-7) CONDITIONAL (MACH simple,tomcat,frv))
9635     "cmbtohe$pack $FRintj,$FRintk,$CCi,$cond"
9636     (+ pack FRintk OP_77 (FRi-null) CCi cond OPE4_2 FRintj)
9637     (sequence ()
9638	       ; hack to get these referenced for profiling
9639	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
9640	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
9641	       (mbtohe-semantics (eq CCi (or cond 2))))
9642     ((fr500 (unit u-media-dual-btohe)))
9643)
9644
9645; Media NOP
9646; A special case of mclracc
9647(dni mnop "Media nop"
9648     ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-1)
9649      (FR400-MAJOR M-1) (FR450-MAJOR M-1))
9650     "mnop$pack"
9651     (+ pack (f-ACC40Sk 63) OP_7B (f-A 1) (misc-null-10) OPE1_3B (FRj-null))
9652     (nop)
9653     ()
9654)
9655
9656; mclracc with #A==0
9657(dni mclracc-0
9658     "Media clear accumulator(s)"
9659     ((UNIT FM01) (FR500-MAJOR M-3) (FR550-MAJOR M-3)
9660      (FR400-MAJOR M-1) (FR450-MAJOR M-3))
9661     "mclracc$pack $ACC40Sk,$A0"
9662     (+ pack ACC40Sk OP_7B (f-A 0) (misc-null-10) OPE1_3B (FRj-null))
9663     (c-call VOID "@cpu@_clear_accumulators" (index-of ACC40Sk) 0)
9664     ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
9665      (fr500 (unit u-media)) (fr550 (unit u-media-3-mclracc)))
9666)
9667
9668; mclracc with #A==1
9669(dni mclracc-1
9670     "Media clear accumulator(s)"
9671     ((UNIT MCLRACC-1) (FR500-MAJOR M-6) (FR550-MAJOR M-3)
9672      (FR400-MAJOR M-2) (FR450-MAJOR M-4))
9673     "mclracc$pack $ACC40Sk,$A1"
9674     (+ pack ACC40Sk OP_7B (f-A 1) (misc-null-10) OPE1_3B (FRj-null))
9675     (c-call VOID "@cpu@_clear_accumulators" (index-of ACC40Sk) 1)
9676     ((fr400 (unit u-media-4)) (fr450 (unit u-media-4-mclracca))
9677      (fr500 (unit u-media)) (fr550 (unit u-media-3-mclracc)))
9678)
9679
9680(dni mrdacc
9681     "Media read accumulator"
9682     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9683      (FR400-MAJOR M-1) (FR450-MAJOR M-5))
9684     "mrdacc$pack $ACC40Si,$FRintk"
9685     (+ pack FRintk OP_7B ACC40Si OPE1_3C (FRj-null))
9686     (set FRintk ACC40Si)
9687     ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
9688      (fr500 (unit u-media)) (fr550 (unit u-media-3-acc)))
9689)
9690
9691(dni mrdaccg
9692     "Media read accumulator guard"
9693     ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
9694      (FR400-MAJOR M-1) (FR450-MAJOR M-5))
9695     "mrdaccg$pack $ACCGi,$FRintk"
9696     (+ pack FRintk OP_7B ACCGi OPE1_3E (FRj-null))
9697     (set FRintk ACCGi)
9698     ((fr400 (unit u-media-4-accg)) (fr450 (unit u-media-4-accg))
9699      (fr500 (unit u-media)) (fr550 (unit u-media-3-acc (in ACC40Si ACCGi))))
9700)
9701
9702(dni mwtacc
9703     "Media write accumulator"
9704     ((UNIT FM01) (FR500-MAJOR M-3) (FR550-MAJOR M-3)
9705      (FR400-MAJOR M-1) (FR450-MAJOR M-3))
9706     "mwtacc$pack $FRinti,$ACC40Sk"
9707     (+ pack ACC40Sk OP_7B FRinti OPE1_3D (FRj-null))
9708     (set ACC40Sk (or (and ACC40Sk (const DI #xffffffff00000000))
9709		     FRinti))
9710     ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
9711      (fr500 (unit u-media)) (fr550 (unit u-media-3-wtacc)))
9712)
9713
9714(dni mwtaccg
9715     "Media write accumulator guard"
9716     ((UNIT FM01) (FR500-MAJOR M-3) (FR550-MAJOR M-3)
9717      (FR400-MAJOR M-1) (FR450-MAJOR M-3))
9718     "mwtaccg$pack $FRinti,$ACCGk"
9719     (+ pack ACCGk OP_7B FRinti OPE1_3F (FRj-null))
9720     (sequence ()
9721	       ; hack to get these referenced for profiling
9722	       (c-raw-call VOID "frv_ref_SI" ACCGk)
9723	       (set ACCGk FRinti))
9724     ((fr400 (unit u-media-4-accg)) (fr450 (unit u-media-4-accg))
9725      (fr500 (unit u-media)) (fr550 (unit u-media-3-wtacc (in ACC40Sk ACCGk))))
9726)
9727
9728(define-pmacro (media-cop num op)
9729  (dni (.sym mcop num)
9730       "Media custom instruction"
9731       ((UNIT FM01) (FR500-MAJOR M-1) (MACH frv))
9732       (.str "mcop" num "$pack $FRi,$FRj,$FRk")
9733       (+ pack FRk op FRi OPE1_00 FRj)
9734       (c-call VOID "@cpu@_media_cop" num)
9735       ()
9736  )
9737)
9738
9739(media-cop 1 OP_7C)
9740(media-cop 2 OP_7D)
9741
9742; nop
9743; A nop is defined to be a "ori gr0,0,gr0"
9744; This needn't be a macro-insn, but making it one greatly simplifies decode.c
9745; On the other hand spending a little time in the decoder is often worth it.
9746;
9747(dnmi nop "nop"
9748     ((UNIT IALL) (FR500-MAJOR I-1) (FR400-MAJOR I-1) (FR450-MAJOR I-1))
9749     "nop$pack"
9750     (emit ori pack (GRi 0) (s12 0) (GRk 0))
9751)
9752
9753; Floating point NOP
9754(dni fnop
9755     "Floating point nop"
9756     ((UNIT FMALL) (FR500-MAJOR F-8) (FR550-MAJOR F-1) (MACH simple,tomcat,fr500,fr550,frv))
9757     "fnop$pack"
9758     (+ pack (rd-null) OP_79 (FRi-null) OPE1_0D (FRj-null))
9759     (nop)
9760     ()
9761)
9762
9763; A return instruction
9764(dnmi ret "return"
9765      (NO-DIS (UNIT B01) (FR500-MAJOR B-3)
9766	      (FR400-MAJOR B-3) (FR450-MAJOR B-3))
9767      "ret$pack"
9768      (emit bralr pack (hint_taken 2))
9769)
9770
9771(dnmi cmp "compare"
9772      (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
9773	      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
9774      "cmp$pack $GRi,$GRj,$ICCi_1"
9775      (emit subcc pack GRi GRj (GRk 0) ICCi_1)
9776)
9777
9778(dnmi cmpi "compare immediate"
9779      (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
9780	      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
9781      "cmpi$pack $GRi,$s10,$ICCi_1"
9782      (emit subicc pack GRi s10 (GRk 0) ICCi_1)
9783)
9784
9785(dnmi ccmp "conditional compare"
9786      (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
9787	      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
9788      "ccmp$pack $GRi,$GRj,$CCi,$cond"
9789      (emit csubcc pack GRi GRj (GRk 0) CCi cond)
9790)
9791
9792(dnmi mov "move"
9793      (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
9794	      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
9795      "mov$pack $GRi,$GRk"
9796      (emit ori pack GRi (s12 0) GRk)
9797)
9798
9799(dnmi cmov "conditional move"
9800      (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
9801	      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
9802      "cmov$pack $GRi,$GRk,$CCi,$cond"
9803      (emit cor pack GRi (GRj 0) GRk CCi cond)
9804)
9805