Add code to handle even-numbered only register operands
[platform/upstream/binutils.git] / cpu / frv.cpu
1 ; Fujitsu FRV opcode support, for GNU Binutils.  -*- Scheme -*-
2 ;
3 ; Copyright 2000, 2001 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 (include "simplify.inc")
24
25 ; define-arch must appear first
26
27 (define-arch
28   (name frv) ; name of cpu architecture
29   (comment "Fujitsu FRV")
30   (insn-lsb0? #t)
31   (machs frv fr500 fr400 tomcat simple)
32   (isas frv)
33 )
34
35 (define-isa
36   (name frv)
37   (base-insn-bitsize 32)
38   ; Initial bitnumbers to decode insns by.
39   (decode-assist (24 23 22 21 20 19 18))
40   (liw-insns 1)       ; The frv fetches  up to 1 insns at a time.
41   (parallel-insns 4)  ; The frv executes up to 4 insns at a time.
42 )
43
44 ; Cpu family definitions.
45 ;
46 (define-cpu
47   ; cpu names must be distinct from the architecture name and machine names.
48   ; The "b" suffix stands for "base" and is the convention.
49   ; The "f" suffix stands for "family" and is the convention.
50   (name frvbf)
51   (comment "Fujitsu FRV base family")
52   (endian big)
53   (word-bitsize 32)
54 )
55 \f
56 ; Generic FR-V machine. Supports the entire architecture
57 (define-mach
58   (name frv)
59   (comment "Generic FRV cpu")
60   (cpu frvbf)
61 )
62 (define-model
63   (name frv) (comment "Generic FRV model") (attrs)
64   (mach frv)
65
66   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
67
68   ; `state' is a list of variables for recording model state
69   ; (state)
70
71   (unit u-exec "Execution Unit" ()
72         1 1 ; issue done
73         () ; state
74         () ; inputs
75         () ; outputs
76         () ; profile action (default)
77         )
78 )
79 \f
80 ; FR500 machine.
81 (define-mach
82   (name fr500)
83   (comment "FR500 cpu")
84   (cpu frvbf)
85 )
86 (define-model
87   (name fr500) (comment "FR500 model") (attrs)
88   (mach fr500)
89
90   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
91
92   ; `state' is a list of variables for recording model state
93   (state
94    ; State items
95    ; These are all masks with each bit representing one register.
96    (prev-fpop       DI) ; Previous use of FR register was floating point insn
97    (prev-media      DI) ; Previous use of FR register was a media insn
98    (prev-cc-complex DI) ; Previous use of ICC register was not simple
99    (cur-fpop        DI) ; Current use of FR register was floating point insn
100    (cur-media       DI) ; Current use of FR register was a media insn
101    (cur-cc-complex  DI) ; Current use of ICC register was not simple
102   )
103   ; Basic unit for instructions with no latency penalties
104   (unit u-exec "Execution Unit" ()
105         1 1 ; issue done
106         () ; state
107         () ; inputs
108         () ; outputs
109         () ; profile action (default)
110         )
111   ; Basic integer insn unit
112   (unit u-integer "Integer Unit" ()
113         1 1 ; issue done
114         () ; state
115         ((GRi INT -1) (GRj INT -1)) ; inputs
116         ((GRk INT -1) (ICCi_1 INT -1)) ; outputs
117         () ; profile action (default)
118         )
119   ; Integer multiplication unit
120   (unit u-imul "Integer Multiplication Unit" ()
121         1 1 ; issue done
122         () ; state
123         ((GRi INT -1) (GRj INT -1)) ; inputs
124         ((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
125         () ; profile action (default)
126         )
127   ; Integer division unit
128   (unit u-idiv "Integer Division Unit" ()
129         1 1 ; issue done
130         () ; state
131         ((GRi INT -1) (GRj INT -1)) ; inputs
132         ((GRk INT -1) (ICCi_1 INT -1)) ; outputs
133         () ; profile action (default)
134         )
135   ; Branch unit
136   (unit u-branch "Branch Unit" ()
137         1 1 ; issue done
138         () ; state
139         ((GRi INT -1) (GRj INT -1)
140          (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
141         ((pc)) ; outputs
142         () ; profile action (default)
143         )
144   ; Trap unit
145   (unit u-trap "Trap Unit" ()
146         1 1 ; issue done
147         () ; state
148         ((GRi INT -1) (GRj INT -1)
149          (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
150         () ; outputs
151         () ; profile action (default)
152         )
153   ; Condition code check unit
154   (unit u-check "Check Unit" ()
155         1 1 ; issue done
156         () ; state
157         ((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
158         () ; outputs
159         () ; profile action (default)
160         )
161   ; GR set half unit
162   (unit u-set-hilo "GR Set Half" ()
163         1 1 ; issue done
164         () ; state
165         () ; inputs
166         ((GRkhi INT -1) (GRklo INT -1)) ; outputs
167         () ; profile action (default)
168         )
169   ; GR load unit -- TODO doesn't handle quad
170   (unit u-gr-load "GR Load Unit" ()
171         1 1 ; issue done
172         () ; state
173         ((GRi INT -1) (GRj INT -1)) ; inputs
174         ((GRk INT -1) (GRdoublek INT -1)) ; outputs
175         () ; profile action (default)
176         )
177   ; GR store unit -- TODO doesn't handle quad
178   (unit u-gr-store "GR Store Unit" ()
179         1 1 ; issue done
180         () ; state
181         ((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
182         () ; outputs
183         () ; profile action (default)
184         )
185   ; GR recovering store unit -- TODO doesn't handle quad
186   (unit u-gr-r-store "GR Recovering Store Unit" ()
187         1 1 ; issue done
188         () ; state
189         ((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
190         () ; outputs
191         () ; profile action (default)
192         )
193   ; FR load unit -- TODO doesn't handle quad
194   (unit u-fr-load "FR Load Unit" ()
195         1 1 ; issue done
196         () ; state
197         ((GRi INT -1) (GRj INT -1)) ; inputs
198         ((FRintk INT -1) (FRdoublek INT -1)) ; outputs
199         () ; profile action (default)
200         )
201   ; FR store unit -- TODO doesn't handle quad
202   (unit u-fr-store "FR Store Unit" ()
203         1 1 ; issue done
204         () ; state
205         ((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
206         () ; outputs
207         () ; profile action (default)
208         )
209   ; FR recovering store unit -- TODO doesn't handle quad
210   (unit u-fr-r-store "FR Recovering Store Unit" ()
211         1 1 ; issue done
212         () ; state
213         ((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
214         () ; outputs
215         () ; profile action (default)
216         )
217   ; Swap unit
218   (unit u-swap "Swap Unit" ()
219         1 1 ; issue done
220         () ; state
221         ((GRi INT -1) (GRj INT -1)) ; inputs
222         ((GRk INT -1)) ; outputs
223         () ; profile action (default)
224         )
225   ; FR Move to FR unit
226   (unit u-fr2fr "FR Move to FR Unit" ()
227         1 1 ; issue done
228         () ; state
229         ((FRi INT -1)) ; inputs
230         ((FRk INT -1)) ; outputs
231         () ; profile action (default)
232         )
233   ; FR Move to GR unit
234   (unit u-fr2gr "FR Move to GR Unit" ()
235         1 1 ; issue done
236         () ; state
237         ((FRintk INT -1)) ; inputs
238         ((GRj INT -1)) ; outputs
239         () ; profile action (default)
240         )
241   ; SPR Move to GR unit
242   (unit u-spr2gr "SPR Move to GR Unit" ()
243         1 1 ; issue done
244         () ; state
245         ((spr INT -1)) ; inputs
246         ((GRj INT -1)) ; outputs
247         () ; profile action (default)
248         )
249   ; GR Move to FR unit
250   (unit u-gr2fr "GR Move to FR Unit" ()
251         1 1 ; issue done
252         () ; state
253         ((GRj INT -1)) ; inputs
254         ((FRintk INT -1)) ; outputs
255         () ; profile action (default)
256         )
257   ; GR Move to SPR unit
258   (unit u-gr2spr "GR Move to SPR Unit" ()
259         1 1 ; issue done
260         () ; state
261         ((GRj INT -1)) ; inputs
262         ((spr INT -1)) ; outputs
263         () ; profile action (default)
264         )
265   ; Float Arithmetic unit
266   (unit u-float-arith "Float Arithmetic unit" ()
267         1 1 ; issue done
268         () ; state
269         ((FRi INT -1) (FRj INT -1) ; inputs
270          (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
271         ((FRk INT -1) (FRdoublek INT -1)) ; outputs
272         () ; profile action (default)
273         )
274   ; Float Dual Arithmetic unit
275   (unit u-float-dual-arith "Float Arithmetic unit" ()
276         1 1 ; issue done
277         () ; state
278         ((FRi INT -1) (FRj INT -1) ; inputs
279          (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
280         ((FRk INT -1) (FRdoublek INT -1)) ; outputs
281         () ; profile action (default)
282         )
283   ; Float Div unit
284   (unit u-float-div "Float Div unit" ()
285         1 1 ; issue done
286         () ; state
287         ((FRi INT -1) (FRj INT -1)) ; inputs
288         ((FRk INT -1)) ; outputs
289         () ; profile action (default)
290         )
291   ; Float Square Root unit
292   (unit u-float-sqrt "Float Square Root unit" ()
293         1 1 ; issue done
294         () ; state
295         ((FRj INT -1) (FRdoublej INT -1)) ; inputs
296         ((FRk INT -1) (FRdoublek INT -1)) ; outputs
297         () ; profile action (default)
298         )
299   ; Float Dual Square Root unit
300   (unit u-float-dual-sqrt "Float Dual Square Root unit" ()
301         1 1 ; issue done
302         () ; state
303         ((FRj INT -1)) ; inputs
304         ((FRk INT -1)) ; outputs
305         () ; profile action (default)
306         )
307   ; Float Compare unit
308   (unit u-float-compare "Float Compare unit" ()
309         1 1 ; issue done
310         () ; state
311         ((FRi INT -1) (FRj INT -1)
312          (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
313         ((FCCi_2 INT -1)) ; outputs
314         () ; profile action (default)
315         )
316   ; Dual Float Compare unit
317   (unit u-float-dual-compare "Float Dual Compare unit" ()
318         1 1 ; issue done
319         () ; state
320         ((FRi INT -1) (FRj INT -1)) ; inputs
321         ((FCCi_2 INT -1)) ; outputs
322         () ; profile action (default)
323         )
324   ; Float Conversion unit
325   (unit u-float-convert "Float Conversion unit" ()
326         1 1 ; issue done
327         () ; state
328         ((FRj INT -1) (FRintj INT -1) (FRdoublej INT -1)) ; inputs
329         ((FRk INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; outputs
330         () ; profile action (default)
331         )
332   ; Dual Float Conversion unit
333   (unit u-float-dual-convert "Float Dual Conversion unit" ()
334         1 1 ; issue done
335         () ; state
336         ((FRj INT -1) (FRintj INT -1)) ; inputs
337         ((FRk INT -1) (FRintk INT -1)) ; outputs
338         () ; profile action (default)
339         )
340   ; Media unit
341   (unit u-media "Media unit" ()
342         1 1 ; issue done
343         () ; state
344         ((FRinti INT -1) (FRintj INT -1) (ACC40Si INT -1) (ACCGi INT -1)) ; inputs
345         ((FRintk INT -1) (ACC40Sk INT -1) (ACC40Uk INT -1) (ACCGk INT -1)) ; outputs
346         () ; profile action (default)
347         )
348   ; Media Quad Arithmetic unit
349   (unit u-media-quad-arith "Media Quad Arithmetic unit" ()
350         1 1 ; issue done
351         () ; state
352         ((FRinti INT -1) (FRintj INT -1)) ; inputs
353         ((FRintk INT -1)) ; outputs
354         () ; profile action (default)
355         )
356   ; Media Dual Multiplication unit
357   (unit u-media-dual-mul "Media Dual Multiplication unit" ()
358         1 1 ; issue done
359         () ; state
360         ((FRinti INT -1) (FRintj INT -1)) ; inputs
361         ((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
362         () ; profile action (default)
363         )
364   ; Media Quad Multiplication unit
365   (unit u-media-quad-mul "Media Quad Multiplication unit" ()
366         1 1 ; issue done
367         () ; state
368         ((FRinti INT -1) (FRintj INT -1)) ; inputs
369         ((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
370         () ; profile action (default)
371         )
372   ; Media Quad Complex unit
373   (unit u-media-quad-complex "Media Quad Complex unit" ()
374         1 1 ; issue done
375         () ; state
376         ((FRinti INT -1) (FRintj INT -1)) ; inputs
377         ((ACC40Sk INT -1)) ; outputs
378         () ; profile action (default)
379         )
380   ; Media Dual Expand unit
381   (unit u-media-dual-expand "Media Dual Expand unit" ()
382         1 1 ; issue done
383         () ; state
384         ((FRinti INT -1)) ; inputs
385         ((FRintk INT -1)) ; outputs
386         () ; profile action (default)
387         )
388   ; Media Dual Unpack unit
389   (unit u-media-dual-unpack "Media Dual Unpack unit" ()
390         1 1 ; issue done
391         () ; state
392         ((FRinti INT -1)) ; inputs
393         ((FRintk INT -1)) ; outputs
394         () ; profile action (default)
395         )
396   ; Media Dual byte to half unit
397   (unit u-media-dual-btoh "Media Byte to byte" ()
398         1 1 ; issue done
399         () ; state
400         ((FRintj INT -1)) ; inputs
401         ((FRintk INT -1)) ; outputs
402         () ; profile action (default)
403         )
404   ; Media Dual half to byte unit
405   (unit u-media-dual-htob "Media Half to byte" ()
406         1 1 ; issue done
407         () ; state
408         ((FRintj INT -1)) ; inputs
409         ((FRintk INT -1)) ; outputs
410         () ; profile action (default)
411         )
412   ; Media Dual byte to half unit extended
413   (unit u-media-dual-btohe "Media Byte to byte extended" ()
414         1 1 ; issue done
415         () ; state
416         ((FRintj INT -1)) ; inputs
417         ((FRintk INT -1)) ; outputs
418         () ; profile action (default)
419         )
420   ; Barrier unit
421   (unit u-barrier "Barrier unit" ()
422         1 1 ; issue done
423         () ; state
424         () ; inputs
425         () ; outputs
426         () ; profile action (default)
427         )
428   ; Memory Barrier unit
429   (unit u-membar "Memory Barrier unit" ()
430         1 1 ; issue done
431         () ; state
432         () ; inputs
433         () ; outputs
434         () ; profile action (default)
435         )
436   ; Insn cache invalidate unit
437   (unit u-ici "Insn cache invalidate unit" ()
438         1 1 ; issue done
439         () ; state
440         ((GRi INT -1) (GRj INT -1)) ; inputs
441         () ; outputs
442         () ; profile action (default)
443         )
444   ; Data cache invalidate unit
445   (unit u-dci "Data cache invalidate unit" ()
446         1 1 ; issue done
447         () ; state
448         ((GRi INT -1) (GRj INT -1)) ; inputs
449         () ; outputs
450         () ; profile action (default)
451         )
452   ; Data cache flush unit
453   (unit u-dcf "Data cache flush unit" ()
454         1 1 ; issue done
455         () ; state
456         ((GRi INT -1) (GRj INT -1)) ; inputs
457         () ; outputs
458         () ; profile action (default)
459         )
460   ; Insn cache preload unit
461   (unit u-icpl "Insn cache preload unit" ()
462         1 1 ; issue done
463         () ; state
464         ((GRi INT -1) (GRj INT -1)) ; inputs
465         () ; outputs
466         () ; profile action (default)
467         )
468   ; Data cache preload unit
469   (unit u-dcpl "Data cache preload unit" ()
470         1 1 ; issue done
471         () ; state
472         ((GRi INT -1) (GRj INT -1)) ; inputs
473         () ; outputs
474         () ; profile action (default)
475         )
476   ; Insn cache unlock unit
477   (unit u-icul "Insn cache unlock unit" ()
478         1 1 ; issue done
479         () ; state
480         ((GRi INT -1) (GRj INT -1)) ; inputs
481         () ; outputs
482         () ; profile action (default)
483         )
484   ; Data cache unlock unit
485   (unit u-dcul "Data cache unlock unit" ()
486         1 1 ; issue done
487         () ; state
488         ((GRi INT -1) (GRj INT -1)) ; inputs
489         () ; outputs
490         () ; profile action (default)
491         )
492 )
493 \f
494 ; Tomcat machine. Early version of fr500 machine
495 (define-mach
496   (name tomcat)
497   (comment "Tomcat -- early version of fr500")
498   (cpu frvbf)
499 )
500 (define-model
501   (name tomcat) (comment "Tomcat model") (attrs)
502   (mach tomcat)
503
504   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
505
506   ; `state' is a list of variables for recording model state
507   ; (state)
508
509   (unit u-exec "Execution Unit" ()
510         1 1 ; issue done
511         () ; state
512         () ; inputs
513         () ; outputs
514         () ; profile action (default)
515         )
516 )
517 \f
518 ; FR400 machine
519 (define-mach
520   (name fr400)
521   (comment "FR400 cpu")
522   (cpu frvbf)
523 )
524 (define-model
525   (name fr400) (comment "FR400 model") (attrs)
526   (mach fr400)
527   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
528   ; `state' is a list of variables for recording model state
529   (state
530    ; State items
531    ; These are all masks with each bit representing one register.
532    (prev-fp-load    DI) ; Previous use of FR  register was floating point load
533    (prev-fr-p4      DI) ; Previous use of FR  register was media unit 4
534    (prev-fr-p6      DI) ; Previous use of FR  register was media unit 6
535    (prev-acc-p2     DI) ; Previous use of ACC register was media unit 2
536    (prev-acc-p4     DI) ; Previous use of ACC register was media unit 4
537    (cur-fp-load     DI) ; Current  use of FR  register is  floating point load
538    (cur-fr-p4       DI) ; Current  use of FR  register is  media unit 4
539    (cur-fr-p6       DI) ; Current  use of FR  register is  media unit 6
540    (cur-acc-p2      DI) ; Current  use of ACC register is  media unit 2
541    (cur-acc-p4      DI) ; Current  use of ACC register is  media unit 4
542   )
543   (unit u-exec "Execution Unit" ()
544         1 1 ; issue done
545         () ; state
546         () ; inputs
547         () ; outputs
548         () ; profile action (default)
549         )
550   ; Basic integer insn unit
551   (unit u-integer "Integer 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   ; Integer multiplication unit
559   (unit u-imul "Integer Multiplication Unit" ()
560         1 1 ; issue done
561         () ; state
562         ((GRi INT -1) (GRj INT -1)) ; inputs
563         ((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
564         () ; profile action (default)
565         )
566   ; Integer division unit
567   (unit u-idiv "Integer Division Unit" ()
568         1 1 ; issue done
569         () ; state
570         ((GRi INT -1) (GRj INT -1)) ; inputs
571         ((GRk INT -1) (ICCi_1 INT -1)) ; outputs
572         () ; profile action (default)
573         )
574   ; Branch unit
575   (unit u-branch "Branch Unit" ()
576         1 1 ; issue done
577         () ; state
578         ((GRi INT -1) (GRj INT -1)
579          (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
580         ((pc)) ; outputs
581         () ; profile action (default)
582         )
583   ; Trap unit
584   (unit u-trap "Trap Unit" ()
585         1 1 ; issue done
586         () ; state
587         ((GRi INT -1) (GRj INT -1)
588          (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
589         () ; outputs
590         () ; profile action (default)
591         )
592   ; Condition code check unit
593   (unit u-check "Check Unit" ()
594         1 1 ; issue done
595         () ; state
596         ((ICCi_3 INT -1) (FCCi_3 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   ; FR load unit -- TODO doesn't handle quad
625   (unit u-fr-load "FR Load Unit" ()
626         1 1 ; issue done
627         () ; state
628         ((GRi INT -1) (GRj INT -1)) ; inputs
629         ((FRintk INT -1) (FRdoublek INT -1)) ; outputs
630         () ; profile action (default)
631         )
632   ; FR store unit -- TODO doesn't handle quad
633   (unit u-fr-store "FR Store Unit" ()
634         1 1 ; issue done
635         () ; state
636         ((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
637         () ; outputs
638         () ; profile action (default)
639         )
640   ; Swap unit
641   (unit u-swap "Swap Unit" ()
642         1 1 ; issue done
643         () ; state
644         ((GRi INT -1) (GRj INT -1)) ; inputs
645         ((GRk INT -1)) ; outputs
646         () ; profile action (default)
647         )
648   ; FR Move to GR unit
649   (unit u-fr2gr "FR Move to GR Unit" ()
650         1 1 ; issue done
651         () ; state
652         ((FRintk INT -1)) ; inputs
653         ((GRj INT -1)) ; outputs
654         () ; profile action (default)
655         )
656   ; SPR Move to GR unit
657   (unit u-spr2gr "SPR Move to GR Unit" ()
658         1 1 ; issue done
659         () ; state
660         ((spr INT -1)) ; inputs
661         ((GRj INT -1)) ; outputs
662         () ; profile action (default)
663         )
664   ; GR Move to FR unit
665   (unit u-gr2fr "GR Move to FR Unit" ()
666         1 1 ; issue done
667         () ; state
668         ((GRj INT -1)) ; inputs
669         ((FRintk INT -1)) ; outputs
670         () ; profile action (default)
671         )
672   ; GR Move to SPR unit
673   (unit u-gr2spr "GR Move to SPR Unit" ()
674         1 1 ; issue done
675         () ; state
676         ((GRj INT -1)) ; inputs
677         ((spr INT -1)) ; outputs
678         () ; profile action (default)
679         )
680   ; Media unit M1 -- see table 13-8 in the fr400 LSI
681   (unit u-media-1 "Media-1 unit" ()
682         1 1 ; issue done
683         () ; state
684         ((FRinti INT -1) (FRintj INT -1)) ; inputs
685         ((FRintk INT -1)) ; outputs
686         () ; profile action (default)
687         )
688   (unit u-media-1-quad "Media-1-quad unit" ()
689         1 1 ; issue done
690         () ; state
691         ((FRinti INT -1) (FRintj INT -1)) ; inputs
692         ((FRintk INT -1)) ; outputs
693         () ; profile action (default)
694         )
695   (unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
696         1 1 ; issue done
697         () ; state
698         () ; inputs
699         ((FRkhi INT -1) (FRklo INT -1)) ; outputs
700         () ; profile action (default)
701         )
702   ; Media unit M2 -- see table 13-8 in the fr400 LSI
703   (unit u-media-2 "Media-2 unit" ()
704         1 1 ; issue done
705         () ; state
706         ((FRinti INT -1) (FRintj INT -1)) ; inputs
707         ((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
708         () ; profile action (default)
709         )
710   (unit u-media-2-quad "Media-2-quad unit" ()
711         1 1 ; issue done
712         () ; state
713         ((FRinti INT -1) (FRintj INT -1)) ; inputs
714         ((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
715         () ; profile action (default)
716         )
717   (unit u-media-2-acc "Media-2-acc unit" ()
718         1 1 ; issue done
719         () ; state
720         ((ACC40Si INT -1)) ; inputs
721         ((ACC40Sk INT -1)) ; outputs
722         () ; profile action (default)
723         )
724   (unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
725         1 1 ; issue done
726         () ; state
727         ((ACC40Si INT -1)) ; inputs
728         ((ACC40Sk INT -1)) ; outputs
729         () ; profile action (default)
730         )
731   (unit u-media-2-add-sub "Media-2-add-sub unit" ()
732         1 1 ; issue done
733         () ; state
734         ((ACC40Si INT -1)) ; inputs
735         ((ACC40Sk INT -1)) ; outputs
736         () ; profile action (default)
737         )
738   (unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
739         1 1 ; issue done
740         () ; state
741         ((ACC40Si INT -1)) ; inputs
742         ((ACC40Sk INT -1)) ; outputs
743         () ; profile action (default)
744         )
745   ; Media unit M3 -- see table 13-8 in the fr400 LSI
746   (unit u-media-3 "Media-3 unit" ()
747         1 1 ; issue done
748         () ; state
749         ((FRinti INT -1) (FRintj INT -1)) ; inputs
750         ((FRintk INT -1)) ; outputs
751         () ; profile action (default)
752         )
753   (unit u-media-3-dual "Media-3-dual unit" ()
754         1 1 ; issue done
755         () ; state
756         ((FRinti INT -1)) ; inputs
757         ((FRintk INT -1)) ; outputs
758         () ; profile action (default)
759         )
760   (unit u-media-3-quad "Media-3-quad unit" ()
761         1 1 ; issue done
762         () ; state
763         ((FRinti INT -1) (FRintj INT -1)) ; inputs
764         ((FRintk INT -1)) ; outputs
765         () ; profile action (default)
766         )
767   ; Media unit M4 -- see table 13-8 in the fr400 LSI
768   (unit u-media-4 "Media-4 unit" ()
769         1 1 ; issue done
770         () ; state
771         ((ACC40Si INT -1) (FRintj INT -1)) ; inputs
772         ((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
773         () ; profile action (default)
774         )
775   (unit u-media-4-accg "Media-4-accg unit" ()
776         1 1 ; issue done
777         () ; state
778         ((ACCGi INT -1) (FRinti INT -1)) ; inputs
779         ((ACCGk INT -1) (FRintk INT -1)) ; outputs
780         () ; profile action (default)
781         )
782   (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
783         1 1 ; issue done
784         () ; state
785         ((ACC40Si INT -1)) ; inputs
786         ((FRintk INT -1)) ; outputs
787         () ; profile action (default)
788         )
789   ; Media unit M6 -- see table 13-8 in the fr400 LSI
790   (unit u-media-6 "Media-6 unit" ()
791         1 1 ; issue done
792         () ; state
793         ((FRinti INT -1)) ; inputs
794         ((FRintk INT -1)) ; outputs
795         () ; profile action (default)
796         )
797   ; Media unit M7 -- see table 13-8 in the fr400 LSI
798   (unit u-media-7 "Media-1 unit" ()
799         1 1 ; issue done
800         () ; state
801         ((FRinti INT -1) (FRintj INT -1)) ; inputs
802         ((FCCk INT -1)) ; outputs
803         () ; profile action (default)
804         )
805   ; Media Dual Expand unit
806   (unit u-media-dual-expand "Media Dual Expand unit" ()
807         1 1 ; issue done
808         () ; state
809         ((FRinti INT -1)) ; inputs
810         ((FRintk INT -1)) ; outputs
811         () ; profile action (default)
812         )
813   ; Media Dual half to byte unit
814   (unit u-media-dual-htob "Media Half to byte" ()
815         1 1 ; issue done
816         () ; state
817         ((FRintj INT -1)) ; inputs
818         ((FRintk INT -1)) ; outputs
819         () ; profile action (default)
820         )
821   ; Barrier unit
822   (unit u-barrier "Barrier unit" ()
823         1 1 ; issue done
824         () ; state
825         () ; inputs
826         () ; outputs
827         () ; profile action (default)
828         )
829   ; Memory Barrier unit
830   (unit u-membar "Memory Barrier unit" ()
831         1 1 ; issue done
832         () ; state
833         () ; inputs
834         () ; outputs
835         () ; profile action (default)
836         )
837   ; Insn cache invalidate unit
838   (unit u-ici "Insn cache invalidate unit" ()
839         1 1 ; issue done
840         () ; state
841         ((GRi INT -1) (GRj INT -1)) ; inputs
842         () ; outputs
843         () ; profile action (default)
844         )
845   ; Data cache invalidate unit
846   (unit u-dci "Data cache invalidate unit" ()
847         1 1 ; issue done
848         () ; state
849         ((GRi INT -1) (GRj INT -1)) ; inputs
850         () ; outputs
851         () ; profile action (default)
852         )
853   ; Data cache flush unit
854   (unit u-dcf "Data cache flush unit" ()
855         1 1 ; issue done
856         () ; state
857         ((GRi INT -1) (GRj INT -1)) ; inputs
858         () ; outputs
859         () ; profile action (default)
860         )
861   ; Insn cache preload unit
862   (unit u-icpl "Insn cache preload unit" ()
863         1 1 ; issue done
864         () ; state
865         ((GRi INT -1) (GRj INT -1)) ; inputs
866         () ; outputs
867         () ; profile action (default)
868         )
869   ; Data cache preload unit
870   (unit u-dcpl "Data cache preload unit" ()
871         1 1 ; issue done
872         () ; state
873         ((GRi INT -1) (GRj INT -1)) ; inputs
874         () ; outputs
875         () ; profile action (default)
876         )
877   ; Insn cache unlock unit
878   (unit u-icul "Insn cache unlock unit" ()
879         1 1 ; issue done
880         () ; state
881         ((GRi INT -1) (GRj INT -1)) ; inputs
882         () ; outputs
883         () ; profile action (default)
884         )
885   ; Data cache unlock unit
886   (unit u-dcul "Data cache unlock unit" ()
887         1 1 ; issue done
888         () ; state
889         ((GRi INT -1) (GRj INT -1)) ; inputs
890         () ; outputs
891         () ; profile action (default)
892         )
893 )
894 \f
895 ; Simple machine - single issue integer machine
896 (define-mach
897   (name simple)
898   (comment "Simple single issue integer cpu")
899   (cpu frvbf)
900 )
901 (define-model
902   (name simple) (comment "Simple model") (attrs)
903   (mach simple)
904   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
905   ; `state' is a list of variables for recording model state
906   (state)
907   (unit u-exec "Execution Unit" ()
908         1 1 ; issue done
909         () ; state
910         () ; inputs
911         () ; outputs
912         () ; profile action (default)
913         )
914 )
915 \f
916 ; The instruction fetch/execute cycle.
917 ;
918 ; This is how to fetch and decode an instruction.
919 ; Leave it out for now
920
921 ; (define-extract (const SI 0))
922
923 ; This is how to execute a decoded instruction.
924 ; Leave it out for now
925
926 ; (define-execute (const SI 0))
927 \f
928 ; An attribute to describe which unit an insn runs in.
929 (define-attr
930   (for insn)
931   (type enum)
932   (name UNIT)
933   (comment "parallel execution pipeline selection")
934   ; The order of declaration is significant. Keep variations on the same unit
935   ; together and keep the '01' variation last within each unit.
936   (values NIL
937           I0 I1 I01
938           FM0 FM1 FM01
939           B0 B1 B01
940           C
941           MULT-DIV ; multiply/division slotted differently on different machines
942           LOAD     ; loads             slotted differently on different machines
943           NUM_UNITS
944   )
945 )
946 ; Attributes to describe major categories of insns
947 (define-attr
948   (for insn)
949   (type enum)
950   (name FR400-MAJOR)
951   (comment "fr400 major insn categories")
952   ; The order of declaration is significant. Keep variations on the same major
953   ; together.
954   (values NONE
955           I-1 I-2 I-3 I-4 I-5
956           B-1 B-2 B-3 B-4 B-5 B-6
957           C-1 C-2
958           M-1 M-2
959   )
960 )
961 (define-attr
962   (for insn)
963   (type enum)
964   (name FR500-MAJOR)
965   (comment "fr500 major insn categories")
966   ; The order of declaration is significant. Keep variations on the same major
967   ; together.
968   (values NONE
969           I-1 I-2 I-3 I-4 I-5 I-6
970           B-1 B-2 B-3 B-4 B-5 B-6
971           C-1 C-2
972           F-1 F-2 F-3 F-4 F-5 F-6 F-7 F-8
973           M-1 M-2 M-3 M-4 M-5 M-6 M-7 M-8
974   )
975 )
976 ; Privileged insn
977 (define-attr
978   (for insn)
979   (type boolean)
980   (name PRIVILEGED)
981   (comment "insn only allowed in supervisor mode")
982 )
983 ; Non-Excepting insn
984 (define-attr
985   (for insn)
986   (type boolean)
987   (name NON-EXCEPTING)
988   (comment "non-excepting insn")
989 )
990 ; Conditional insn
991 (define-attr
992   (for insn)
993   (type boolean)
994   (name CONDITIONAL)
995   (comment "conditional insn")
996 )
997 ; insn accesses FR registers
998 (define-attr
999   (for insn)
1000   (type boolean)
1001   (name FR-ACCESS)
1002   (comment "insn accesses FR registers")
1003 )
1004 ; insn preserves MSR.OVF
1005 (define-attr
1006   (for insn)
1007   (type boolean)
1008   (name PRESERVE-OVF)
1009   (comment "Preserve value of MSR.OVF")
1010 )
1011 ; null attribute -- used as a place holder for where an attribue it required.
1012 (define-attr
1013   (for insn)
1014   (type boolean)
1015   (name NA)
1016   (comment "placeholder attribute")
1017   (attrs META) ; do not define in any generated file for now
1018 )
1019 \f
1020 ; Instruction fields.
1021 ;
1022 ; Attributes:
1023 ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
1024 ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
1025 ; RESERVED: bits are not used to decode insn, must be all 0
1026 (dnf f-pack      "packing bit"                  () 31  1)
1027 (dnf f-op        "primary opcode"               () 24  7)
1028 (dnf f-ope1      "extended opcode"              () 11  6)
1029 (dnf f-ope2      "extended opcode"              ()  9  4)
1030 (dnf f-ope3      "extended opcode"              () 15  3)
1031 (dnf f-ope4      "extended opcode"              ()  7  2)
1032
1033 (dnf f-GRi       "source register 1"            () 17  6)
1034 (dnf f-GRj       "source register 2"            ()  5  6)
1035 (dnf f-GRk       "destination register"         () 30  6)
1036
1037 (dnf f-FRi       "source register 1"            () 17  6)
1038 (dnf f-FRj       "source register 2"            ()  5  6)
1039 (dnf f-FRk       "destination register"         () 30  6)
1040
1041 (dnf f-CPRi      "source register 1"            () 17  6)
1042 (dnf f-CPRj      "source register 2"            ()  5  6)
1043 (dnf f-CPRk      "destination register"         () 30  6)
1044
1045 (dnf f-ACCGi     "source register"              () 17  6)
1046 (dnf f-ACCGk     "destination register"         () 30  6)
1047
1048 (dnf f-ACC40Si   "40 bit signed accumulator"    () 17  6)
1049 (dnf f-ACC40Ui   "40 bit unsigned accumulator"  () 17  6)
1050 (dnf f-ACC40Sk   "40 bit accumulator"           () 30  6)
1051 (dnf f-ACC40Uk   "40 bit accumulator"           () 30  6)
1052
1053 (dnf f-CRi       "source      register"         () 14  3)
1054 (dnf f-CRj       "source      register"         ()  2  3)
1055 (dnf f-CRk       "destination register"         () 27  3)
1056 (dnf f-CCi       "condition   register"         () 11  3)
1057
1058 (df  f-CRj_int   "target cr for ck insns"       () 26  2 UINT
1059      ((value pc) (sub WI value 4))
1060      ((value pc) (add WI value 4))
1061 )
1062 (dnf f-CRj_float "target cr for fck insns"      () 26  2)
1063
1064 (dnf f-ICCi_1    "condition register"           () 11  2)
1065 (dnf f-ICCi_2    "condition register"           () 26  2)
1066 (dnf f-ICCi_3    "condition register"           ()  1  2)
1067 (dnf f-FCCi_1    "condition register"           () 11  2)
1068 (dnf f-FCCi_2    "condition register"           () 26  2)
1069 (dnf f-FCCi_3    "condition register"           ()  1  2)
1070 (dnf f-FCCk      "condition register"           () 26  2)
1071 (dnf f-eir       "exception insn register"      () 17  6)
1072
1073 (df  f-s10       "10 bit sign extended"         ()  9 10  INT #f #f)
1074 (df  f-s12       "12 bit sign extended"         () 11 12  INT #f #f)
1075 (df  f-d12       "12 bit sign extended"         () 11 12  INT #f #f)
1076 (df  f-u16       "16 bit unsigned"              () 15 16 UINT #f #f)
1077 (df  f-s16       "16 bit sign extended"         () 15 16  INT #f #f)
1078 (df  f-s6        "6  bit   signed"              ()  5  6  INT #f #f)
1079 (df  f-s6_1      "6  bit   signed"              () 11  6  INT #f #f)
1080 (df  f-u6        "6  bit unsigned"              ()  5  6 UINT #f #f)
1081 (df  f-s5        "5  bit   signed"              ()  4  5  INT #f #f)
1082
1083 (df  f-u12-h "upper 6 bits of u12"  () 17 6  INT #f #f)
1084 (df  f-u12-l "lower 6 bits of u12"  ()  5 6 UINT #f #f)
1085 (dnmf f-u12   "12 bit signed immediate" () INT
1086       (f-u12-h f-u12-l)
1087       (sequence () ; insert
1088                 (set (ifield f-u12-h) (sra SI (ifield f-u12) 6))
1089                 (set (ifield f-u12-l) (and (ifield f-u12) #x3f))
1090                 )
1091       (sequence () ; extract
1092                 (set (ifield f-u12) (or (sll (ifield f-u12-h) 6)
1093                                         (ifield f-u12-l)))
1094                 )
1095 )
1096
1097 (dnf f-int-cc    "integer  branch conditions"   () 30  4)
1098 (dnf f-flt-cc    "floating branch conditions"   () 30  4)
1099 (df  f-cond      "conditional arithmetic"       ()  8  1 UINT #f #f)
1100 (df  f-ccond     "lr branch condition"          () 12  1 UINT #f #f)
1101 (df  f-hint      "2 bit branch prediction hint" () 17  2 UINT #f #f)
1102 (df  f-LI        "link indicator"               () 25  1 UINT #f #f)
1103 (df  f-lock      "cache lock indicator"         () 25  1 UINT #f #f)
1104 (df  f-debug     "debug mode indicator"         () 25  1 UINT #f #f)
1105 (df  f-A         "all accumulator bit"          () 17  1 UINT #f #f)
1106 (df  f-ae        "cache all entries indicator"  () 25  1 UINT #f #f)
1107
1108 (dnf  f-spr-h "upper 6 bits of spr"  () 30  6)
1109 (dnf  f-spr-l "lower 6 bits of spr"  () 17  6)
1110 (dnmf f-spr   "special purpose register" () UINT
1111       (f-spr-h f-spr-l)
1112       (sequence () ; insert
1113                 (set (ifield f-spr-h) (srl (ifield f-spr) (const 6)))
1114                 (set (ifield f-spr-l) (and (ifield f-spr) (const #x3f)))
1115                 )
1116       (sequence () ; extract
1117                 (set (ifield f-spr) (or (sll (ifield f-spr-h) (const 6))
1118                                         (ifield f-spr-l)))
1119                 )
1120 )
1121
1122 (df  f-label16    "18 bit pc relative signed offset" (PCREL-ADDR) 15 16 INT
1123      ((value pc) (sra WI (sub WI value pc) (const 2)))
1124      ((value pc) (add WI (sll WI value (const 2)) pc))
1125 )
1126
1127 (df   f-labelH6   "upper 6  bits of label24"  () 30  6 INT #f #f)
1128 (dnf  f-labelL18  "lower 18 bits of label24"  () 17 18)
1129 (dnmf f-label24   "26 bit signed offset"     (PCREL-ADDR) INT
1130       (f-labelH6 f-labelL18)
1131       ; insert
1132       (sequence ()
1133                 (set (ifield f-labelH6)
1134                      (sra WI (sub (ifield f-label24) pc) (const 20)))
1135                 (set (ifield f-labelL18)
1136                      (and (srl (sub (ifield f-label24) pc) (const 2))
1137                           (const #x3ffff)))
1138                 )
1139       ; extract
1140       (sequence ()
1141                 (set (ifield f-label24)
1142                      (add (sll (or (sll (ifield f-labelH6) (const 18))
1143                                    (ifield f-labelL18))
1144                                (const 2))
1145                           pc)))
1146 )
1147
1148 (dnf f-ICCi_1-null  "null field" (RESERVED) 11  2)
1149 (dnf f-ICCi_2-null  "null field" (RESERVED) 26  2)
1150 (dnf f-ICCi_3-null  "null field" (RESERVED)  1  2)
1151 (dnf f-FCCi_1-null  "null field" (RESERVED) 11  2)
1152 (dnf f-FCCi_2-null  "null field" (RESERVED) 26  2)
1153 (dnf f-FCCi_3-null  "null field" (RESERVED)  1  2)
1154 (dnf f-rs-null      "null field" (RESERVED) 17  6)
1155 (dnf f-GRi-null     "null field" (RESERVED) 17  6)
1156 (dnf f-GRj-null     "null field" (RESERVED)  5  6)
1157 (dnf f-GRk-null     "null field" (RESERVED) 30  6)
1158 (dnf f-FRi-null     "null field" (RESERVED) 17  6)
1159 (dnf f-FRj-null     "null field" (RESERVED)  5  6)
1160 (dnf f-ACCj-null    "null field" (RESERVED)  5  6)
1161 (dnf f-rd-null      "null field" (RESERVED) 30  6)
1162 (dnf f-cond-null    "null field" (RESERVED) 30  4)
1163 (dnf f-ccond-null   "null field" (RESERVED) 12  1)
1164 (dnf f-s12-null     "null field" (RESERVED) 11 12)
1165 (dnf f-label16-null "null field" (RESERVED) 15 16)
1166 (dnf f-misc-null-1  "null field" (RESERVED) 30  5)
1167 (dnf f-misc-null-2  "null field" (RESERVED) 11  6)
1168 (dnf f-misc-null-3  "null field" (RESERVED) 11  4)
1169 (dnf f-misc-null-4  "null field" (RESERVED) 17  2)
1170 (dnf f-misc-null-5  "null field" (RESERVED) 17 16)
1171 (dnf f-misc-null-6  "null field" (RESERVED) 30  3)
1172 (dnf f-misc-null-7  "null field" (RESERVED) 17  3)
1173 (dnf f-misc-null-8  "null field" (RESERVED)  5  3)
1174 (dnf f-misc-null-9  "null field" (RESERVED)  5  4)
1175 (dnf f-misc-null-10 "null field" (RESERVED) 16  5)
1176 (dnf f-misc-null-11 "null field" (RESERVED)  5  1)
1177
1178 (dnf f-LI-off      "null field" (RESERVED) 25  1)
1179 (dnf f-LI-on       "null field" (RESERVED) 25  1)
1180 \f
1181 ; Enums.
1182
1183 ; insn-op:
1184 ; FIXME: should use die macro or some such
1185 (define-normal-insn-enum insn-op "insn op enums" () OP_ f-op
1186  (
1187  "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
1188  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F"
1189  "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F"
1190  "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F"
1191  "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "4A" "4B" "4C" "4D" "4E" "4F"
1192  "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "5A" "5B" "5C" "5D" "5E" "5F"
1193  "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "6A" "6B" "6C" "6D" "6E" "6F"
1194  "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "7A" "7B" "7C" "7D" "7E" "7F"
1195  )
1196 )
1197
1198 (define-normal-insn-enum insn-ope1 "insn ope enums" () OPE1_ f-ope1
1199  (
1200  "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
1201  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F"
1202  "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F"
1203  "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F"
1204  )
1205 )
1206
1207 (define-normal-insn-enum insn-ope2 "insn ope enums" () OPE2_ f-ope2
1208  (
1209  "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
1210  )
1211 )
1212
1213 (define-normal-insn-enum insn-ope3 "insn ope enums" () OPE3_ f-ope3
1214  (
1215  "00" "01" "02" "03" "04" "05" "06" "07"
1216  )
1217 )
1218
1219 (define-normal-insn-enum insn-ope4 "insn ope enums" () OPE4_ f-ope4
1220  (
1221  "0" "1" "2" "3"
1222  )
1223 )
1224
1225 ; int-cc: integer branch conditions
1226 ; FIXME: should use die macro or some such
1227 (define-normal-insn-enum int-cc "integer branch cond enums" () ICC_ f-int-cc
1228   (
1229    "nev" "c"  "v"  "lt" "eq" "ls" "n" "le"
1230    "ra"  "nc" "nv" "ge" "ne" "hi" "p" "gt"
1231   )
1232 )
1233
1234 ; flt-cc: floating-point/media branch conditions
1235 ; FIXME: should use die macro or some such
1236 (define-normal-insn-enum flt-cc "float branch cond enums" () FCC_ f-flt-cc
1237   ("nev" "u" "gt" "ug" "lt" "ul" "lg" "ne"
1238    "eq" "ue" "ge" "uge" "le" "ule" "o" "ra")
1239 )
1240 \f
1241 ; Hardware pieces.
1242 ; These entries list the elements of the raw hardware.
1243 ; They're also used to provide tables and other elements of the assembly
1244 ; language.
1245 (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
1246
1247 ; The PSR. The individual fields are referenced more than the entire
1248 ; register, so reference them directly. We can assemble the
1249 ; entire register contents when necessary.
1250 ;
1251 (dsh h-psr_imple "PSR.IMPLE"   () (register UQI))
1252 (dsh h-psr_ver   "PSR.VER"     () (register UQI))
1253 (dsh h-psr_ice   "PSR.ICE bit" () (register BI))
1254 (dsh h-psr_nem   "PSR.NEM bit" () (register BI))
1255 (dsh h-psr_cm    "PSR.CM  bit" () (register BI))
1256 (dsh h-psr_be    "PSR.BE  bit" () (register BI))
1257 (dsh h-psr_esr   "PSR.ESR bit" () (register BI))
1258 (dsh h-psr_ef    "PSR.EF  bit" () (register BI))
1259 (dsh h-psr_em    "PSR.EM  bit" () (register BI))
1260 (dsh h-psr_pil   "PSR.PIL    " () (register UQI))
1261 (dsh h-psr_ps    "PSR.PS  bit" () (register BI))
1262 (dsh h-psr_et    "PSR.ET  bit" () (register BI))
1263
1264 ; PSR.S requires special handling because the shadow registers (SR0-SR4) must
1265 ; be switched with GR4-GR7 when changing from user to supervisor mode or
1266 ; vice-versa.
1267 (define-hardware
1268   (name h-psr_s)
1269   (comment "PSR.S bit")
1270   (attrs)
1271   (type register BI)
1272   (get)
1273   (set (newval) (c-call VOID "@cpu@_h_psr_s_set_handler" newval))
1274 )
1275
1276 ; The TBR. The individual bits are referenced more than the entire
1277 ; register, so reference them directly. We can assemble the
1278 ; entire register contents when necessary.
1279 ;
1280 (dsh h-tbr_tba "TBR.TBA" () (register UWI))
1281 (dsh h-tbr_tt  "TBR.TT"  () (register UQI))
1282
1283 ; The BPSR. The individual bits are referenced more than the entire
1284 ; register, so reference them directly. We can assemble the
1285 ; entire register contents when necessary.
1286 ;
1287 (dsh h-bpsr_bs   "PSR.S   bit" () (register BI))
1288 (dsh h-bpsr_bet  "PSR.ET  bit" () (register BI))
1289
1290 ; General registers
1291 ;
1292 (define-keyword
1293   (name gr-names)
1294   (print-name h-gr)
1295   (prefix "")
1296   (values
1297    (sp 1) (fp 2)
1298    (gr0   0)(gr1   1)(gr2   2)(gr3   3)(gr4   4)(gr5   5)(gr6   6)(gr7   7)
1299    (gr8   8)(gr9   9)(gr10 10)(gr11 11)(gr12 12)(gr13 13)(gr14 14)(gr15 15)
1300    (gr16 16)(gr17 17)(gr18 18)(gr19 19)(gr20 20)(gr21 21)(gr22 22)(gr23 23)
1301    (gr24 24)(gr25 25)(gr26 26)(gr27 27)(gr28 28)(gr29 29)(gr30 30)(gr31 31)
1302    (gr32 32)(gr33 33)(gr34 34)(gr35 35)(gr36 36)(gr37 37)(gr38 38)(gr39 39)
1303    (gr40 40)(gr41 41)(gr42 42)(gr43 43)(gr44 44)(gr45 45)(gr46 46)(gr47 47)
1304    (gr48 48)(gr49 49)(gr50 50)(gr51 51)(gr52 52)(gr53 53)(gr54 54)(gr55 55)
1305    (gr56 56)(gr57 57)(gr58 58)(gr59 59)(gr60 60)(gr61 61)(gr62 62)(gr63 63)
1306   )
1307 )
1308
1309 (define-hardware
1310   (name h-gr)
1311   (comment "general registers")
1312   (attrs PROFILE)
1313   (type register USI (64))
1314   (indices extern-keyword gr-names)
1315   (get (index) (c-call WI "@cpu@_h_gr_get_handler" index))
1316   (set (index newval) (c-call VOID "@cpu@_h_gr_set_handler" index newval))
1317 )
1318
1319 ; General Registers as double words
1320 ; These registers are shadowed onto h-gr
1321 (define-hardware
1322   (name h-gr_double)
1323   (comment "general registers as double words")
1324   (attrs PROFILE VIRTUAL)
1325   (type register DI (32))
1326   ; FIXME: Need constraint to prohibit odd numbers.
1327   (indices extern-keyword gr-names)
1328   (get (index)
1329        (c-call DI "@cpu@_h_gr_double_get_handler" index))
1330   (set (index newval)
1331        (c-call VOID "@cpu@_h_gr_double_set_handler" index newval))
1332 )
1333
1334 ; General Registers as high and low half words
1335 ; These registers are shadowed onto h-gr
1336 (define-hardware
1337   (name h-gr_hi)
1338   (comment "general registers as high half word")
1339   (attrs PROFILE VIRTUAL)
1340   (type register UHI (64))
1341   (indices extern-keyword gr-names)
1342   (get (index) (c-call UHI "@cpu@_h_gr_hi_get_handler" index))
1343   (set (index newval) (c-call VOID "@cpu@_h_gr_hi_set_handler" index newval))
1344 )
1345 (define-hardware
1346   (name h-gr_lo)
1347   (comment "general registers as low half word")
1348   (attrs PROFILE VIRTUAL)
1349   (type register UHI (64))
1350   (indices extern-keyword gr-names)
1351   (get (index) (c-call UHI "@cpu@_h_gr_lo_get_handler" index))
1352   (set (index newval) (c-call VOID "@cpu@_h_gr_lo_set_handler" index newval))
1353 )
1354
1355 ; Floating Point Registers
1356 (define-keyword
1357   (name fr-names)
1358   (print-name h-fr)
1359   (prefix "")
1360   (values
1361    (fr0   0)(fr1   1)(fr2   2)(fr3   3)(fr4   4)(fr5   5)(fr6   6)(fr7   7)
1362    (fr8   8)(fr9   9)(fr10 10)(fr11 11)(fr12 12)(fr13 13)(fr14 14)(fr15 15)
1363    (fr16 16)(fr17 17)(fr18 18)(fr19 19)(fr20 20)(fr21 21)(fr22 22)(fr23 23)
1364    (fr24 24)(fr25 25)(fr26 26)(fr27 27)(fr28 28)(fr29 29)(fr30 30)(fr31 31)
1365    (fr32 32)(fr33 33)(fr34 34)(fr35 35)(fr36 36)(fr37 37)(fr38 38)(fr39 39)
1366    (fr40 40)(fr41 41)(fr42 42)(fr43 43)(fr44 44)(fr45 45)(fr46 46)(fr47 47)
1367    (fr48 48)(fr49 49)(fr50 50)(fr51 51)(fr52 52)(fr53 53)(fr54 54)(fr55 55)
1368    (fr56 56)(fr57 57)(fr58 58)(fr59 59)(fr60 60)(fr61 61)(fr62 62)(fr63 63)
1369   )
1370 )
1371
1372 (define-hardware
1373   (name h-fr)
1374   (comment "floating point registers")
1375   (attrs PROFILE)
1376   (type register SF (64))
1377   (indices extern-keyword fr-names)
1378   (get (index) (c-call SF "@cpu@_h_fr_get_handler" index))
1379   (set (index newval) (c-call VOID "@cpu@_h_fr_set_handler" index newval))
1380 )
1381
1382 ; Floating Point Registers as double precision
1383 ; These registers are shadowed onto h-fr
1384
1385 (define-hardware
1386   (name h-fr_double)
1387   (comment "floating point registers as double precision")
1388   (attrs PROFILE VIRTUAL)
1389   (type register DF (32))
1390   ; FIXME: Need constraint to prohibit odd numbers.
1391   (indices extern-keyword fr-names)
1392   (get (index)
1393        (c-call DF "@cpu@_h_fr_double_get_handler" index))
1394   (set (index newval)
1395        (c-call VOID "@cpu@_h_fr_double_set_handler" index newval))
1396 )
1397
1398 ; Floating Point Registers as integer words.
1399 ; These registers are shadowed onto h-fr
1400
1401 (define-hardware
1402   (name h-fr_int)
1403   (comment "floating point registers as integers")
1404   (attrs PROFILE VIRTUAL)
1405   (type register USI (64))
1406   (indices extern-keyword fr-names)
1407   (get (index)
1408        (c-call USI "@cpu@_h_fr_int_get_handler" index))
1409   (set (index newval)
1410        (c-call VOID "@cpu@_h_fr_int_set_handler" index newval))
1411 )
1412
1413 ; Floating Point Registers as high and low half words
1414 ; These registers are shadowed onto h-fr
1415 (define-hardware
1416   (name h-fr_hi)
1417   (comment "floating point registers as unsigned high half word")
1418   (attrs PROFILE VIRTUAL)
1419   (type register UHI (64))
1420   (indices extern-keyword fr-names)
1421   (get (regno) (srl (reg h-fr_int regno) 16))
1422   (set (regno newval) (set (reg h-fr_int regno)
1423                            (or (and (reg h-fr_int regno) #xffff)
1424                                (sll newval 16))))
1425 )
1426 (define-hardware
1427   (name h-fr_lo)
1428   (comment "floating point registers as unsigned low half word")
1429   (attrs PROFILE VIRTUAL)
1430   (type register UHI (64))
1431   (indices extern-keyword fr-names)
1432   (get (regno) (and (reg h-fr_int regno) #xffff))
1433   (set (regno newval) (set (reg h-fr_int regno)
1434                            (or (and (reg h-fr_int regno) #xffff0000)
1435                                (and newval #xffff))))
1436 )
1437
1438 ; Floating Point Registers as unsigned bytes
1439 ; These registers are shadowed onto h-fr
1440 (define-hardware
1441   (name h-fr_0)
1442   (comment "floating point registers as unsigned byte 0")
1443   (attrs PROFILE VIRTUAL)
1444   (type register UHI (64))
1445   (indices extern-keyword fr-names)
1446   (get (regno) (and (reg h-fr_int regno) #xff))
1447   (set (regno newval)
1448        (sequence ()
1449                  (if (gt USI newval #xff)
1450                      (set newval #xff))
1451                  (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xffffff00)
1452                                            newval))))
1453 )
1454 (define-hardware
1455   (name h-fr_1)
1456   (comment "floating point registers as unsigned byte 1")
1457   (attrs PROFILE VIRTUAL)
1458   (type register UHI (64))
1459   (indices extern-keyword fr-names)
1460   (get (regno) (and (srl (reg h-fr_int regno) 8) #xff))
1461   (set (regno newval)
1462        (sequence ()
1463                  (if (gt USI newval #xff)
1464                      (set newval #xff))
1465                  (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xffff00ff) 
1466                                            (sll newval 8)))))
1467 )
1468 (define-hardware
1469   (name h-fr_2)
1470   (comment "floating point registers as unsigned byte 2")
1471   (attrs PROFILE VIRTUAL)
1472   (type register UHI (64))
1473   (indices extern-keyword fr-names)
1474   (get (regno) (and (srl (reg h-fr_int regno) 16) #xff))
1475   (set (regno newval)
1476        (sequence ()
1477                  (if (gt USI newval #xff)
1478                      (set newval #xff))
1479                  (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xff00ffff) 
1480                                            (sll newval 16)))))
1481 )
1482 (define-hardware
1483   (name h-fr_3)
1484   (comment "floating point registers as unsigned byte 3")
1485   (attrs PROFILE VIRTUAL)
1486   (type register UHI (64))
1487   (indices extern-keyword fr-names)
1488   (get (regno) (and (srl (reg h-fr_int regno) 24) #xff))
1489   (set (regno newval)
1490        (sequence ()
1491                  (if (gt USI newval #xff)
1492                      (set newval #xff))
1493                  (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #x00ffffff) 
1494                                            (sll newval 24)))))
1495 )
1496 ; Coprocessor Registers
1497 ;
1498 (define-keyword
1499   (name cpr-names)
1500   (print-name h-cpr)
1501   (prefix "")
1502   (values
1503 (cpr0   0)(cpr1   1)(cpr2   2)(cpr3   3)(cpr4   4)(cpr5   5)(cpr6   6)(cpr7   7)
1504 (cpr8   8)(cpr9   9)(cpr10 10)(cpr11 11)(cpr12 12)(cpr13 13)(cpr14 14)(cpr15 15)
1505 (cpr16 16)(cpr17 17)(cpr18 18)(cpr19 19)(cpr20 20)(cpr21 21)(cpr22 22)(cpr23 23)
1506 (cpr24 24)(cpr25 25)(cpr26 26)(cpr27 27)(cpr28 28)(cpr29 29)(cpr30 30)(cpr31 31)
1507 (cpr32 32)(cpr33 33)(cpr34 34)(cpr35 35)(cpr36 36)(cpr37 37)(cpr38 38)(cpr39 39)
1508 (cpr40 40)(cpr41 41)(cpr42 42)(cpr43 43)(cpr44 44)(cpr45 45)(cpr46 46)(cpr47 47)
1509 (cpr48 48)(cpr49 49)(cpr50 50)(cpr51 51)(cpr52 52)(cpr53 53)(cpr54 54)(cpr55 55)
1510 (cpr56 56)(cpr57 57)(cpr58 58)(cpr59 59)(cpr60 60)(cpr61 61)(cpr62 62)(cpr63 63)
1511   )
1512 )
1513
1514 (define-hardware
1515   (name h-cpr)
1516   (comment "coprocessor registers")
1517   (attrs PROFILE (MACH frv))
1518   (type register WI (64))
1519   (indices extern-keyword cpr-names)
1520 )
1521
1522 ; Coprocessor Registers as double words
1523 ; These registers are shadowed onto h-cpr
1524 (define-hardware
1525   (name h-cpr_double)
1526   (comment "coprocessor registers as double words")
1527   (attrs PROFILE VIRTUAL (MACH frv))
1528   (type register DI (32))
1529   ; FIXME: Need constraint to prohibit odd numbers.
1530   (indices extern-keyword cpr-names)
1531   (get (index)
1532        (c-call DI "@cpu@_h_cpr_double_get_handler" index))
1533   (set (index newval)
1534        (c-call VOID "@cpu@_h_cpr_double_set_handler" index newval))
1535 )
1536
1537 ; Special Purpose Registers
1538 ;
1539 (define-keyword
1540   (name spr-names)
1541   (print-name h-spr)
1542   (prefix "")
1543   (values
1544    (psr        0) (pcsr       1) (bpcsr      2) (tbr        3) (bpsr       4)
1545
1546    (hsr0      16) (hsr1      17) (hsr2      18) (hsr3      19)
1547    (hsr4      20) (hsr5      21) (hsr6      22) (hsr7      23)
1548    (hsr8      24) (hsr9      25) (hsr10     26) (hsr11     27)
1549    (hsr12     28) (hsr13     29) (hsr14     30) (hsr15     31)
1550    (hsr16     32) (hsr17     33) (hsr18     34) (hsr19     35)
1551    (hsr20     36) (hsr21     37) (hsr22     38) (hsr23     39)
1552    (hsr24     40) (hsr25     41) (hsr26     42) (hsr27     43)
1553    (hsr28     44) (hsr29     45) (hsr30     46) (hsr31     47)
1554    (hsr32     48) (hsr33     49) (hsr34     50) (hsr35     51)
1555    (hsr36     52) (hsr37     53) (hsr38     54) (hsr39     55)
1556    (hsr40     56) (hsr41     57) (hsr42     58) (hsr43     59)
1557    (hsr44     60) (hsr45     61) (hsr46     62) (hsr47     63)
1558    (hsr48     64) (hsr49     65) (hsr50     66) (hsr51     67)
1559    (hsr52     68) (hsr53     69) (hsr54     70) (hsr55     71)
1560    (hsr56     72) (hsr57     73) (hsr58     74) (hsr59     75)
1561    (hsr60     76) (hsr61     77) (hsr62     78) (hsr63     79)
1562
1563    (ccr      256) (cccr     263) (lr       272) (lcr      273) (isr      288)
1564
1565    (neear0   352) (neear1   353) (neear2   354) (neear3   355)
1566    (neear4   356) (neear5   357) (neear6   358) (neear7   359)
1567    (neear8   360) (neear9   361) (neear10  362) (neear11  363)
1568    (neear12  364) (neear13  365) (neear14  366) (neear15  367)
1569    (neear16  368) (neear17  369) (neear18  370) (neear19  371)
1570    (neear20  372) (neear21  373) (neear22  374) (neear23  375)
1571    (neear24  376) (neear25  377) (neear26  378) (neear27  379)
1572    (neear28  380) (neear29  381) (neear30  382) (neear31  383)
1573
1574    (nesr0    384) (nesr1    385) (nesr2    386) (nesr3    387)
1575    (nesr4    388) (nesr5    389) (nesr6    390) (nesr7    391)
1576    (nesr8    392) (nesr9    393) (nesr10   394) (nesr11   395)
1577    (nesr12   396) (nesr13   397) (nesr14   398) (nesr15   399)
1578    (nesr16   400) (nesr17   401) (nesr18   402) (nesr19   403)
1579    (nesr20   404) (nesr21   405) (nesr22   406) (nesr23   407)
1580    (nesr24   408) (nesr25   409) (nesr26   410) (nesr27   411)
1581    (nesr28   412) (nesr29   413) (nesr30   414) (nesr31   415)
1582
1583    (necr     416)
1584
1585    (gner0    432) (gner1    433)
1586
1587    (fner0    434) (fner1    435)
1588
1589    (epcr0    512) (epcr1    513) (epcr2    514) (epcr3    515)
1590    (epcr4    516) (epcr5    517) (epcr6    518) (epcr7    519)
1591    (epcr8    520) (epcr9    521) (epcr10   522) (epcr11   523)
1592    (epcr12   524) (epcr13   525) (epcr14   526) (epcr15   527)
1593    (epcr16   528) (epcr17   529) (epcr18   530) (epcr19   531)
1594    (epcr20   532) (epcr21   533) (epcr22   534) (epcr23   535)
1595    (epcr24   536) (epcr25   537) (epcr26   538) (epcr27   539)
1596    (epcr28   540) (epcr29   541) (epcr30   542) (epcr31   543)
1597    (epcr32   544) (epcr33   545) (epcr34   546) (epcr35   547)
1598    (epcr36   548) (epcr37   549) (epcr38   550) (epcr39   551)
1599    (epcr40   552) (epcr41   553) (epcr42   554) (epcr43   555)
1600    (epcr44   556) (epcr45   557) (epcr46   558) (epcr47   559)
1601    (epcr48   560) (epcr49   561) (epcr50   562) (epcr51   563)
1602    (epcr52   564) (epcr53   565) (epcr54   566) (epcr55   567)
1603    (epcr56   568) (epcr57   569) (epcr58   570) (epcr59   571)
1604    (epcr60   572) (epcr61   573) (epcr62   574) (epcr63   575)
1605
1606    (esr0     576) (esr1     577) (esr2     578) (esr3     579)
1607    (esr4     580) (esr5     581) (esr6     582) (esr7     583)
1608    (esr8     584) (esr9     585) (esr10    586) (esr11    587)
1609    (esr12    588) (esr13    589) (esr14    590) (esr15    591)
1610    (esr16    592) (esr17    593) (esr18    594) (esr19    595)
1611    (esr20    596) (esr21    597) (esr22    598) (esr23    599)
1612    (esr24    600) (esr25    601) (esr26    602) (esr27    603)
1613    (esr28    604) (esr29    605) (esr30    606) (esr31    607)
1614    (esr32    608) (esr33    609) (esr34    610) (esr35    611)
1615    (esr36    612) (esr37    613) (esr38    614) (esr39    615)
1616    (esr40    616) (esr41    617) (esr42    618) (esr43    619)
1617    (esr44    620) (esr45    621) (esr46    622) (esr47    623)
1618    (esr48    624) (esr49    625) (esr50    626) (esr51    627)
1619    (esr52    628) (esr53    629) (esr54    630) (esr55    631)
1620    (esr56    632) (esr57    633) (esr58    634) (esr59    635)
1621    (esr60    636) (esr61    637) (esr62    638) (esr63    639)
1622
1623    (eir0     640) (eir1     641) (eir2     642) (eir3     643)
1624    (eir4     644) (eir5     645) (eir6     646) (eir7     647)
1625    (eir8     648) (eir9     649) (eir10    650) (eir11    651)
1626    (eir12    652) (eir13    653) (eir14    654) (eir15    655)
1627    (eir16    656) (eir17    657) (eir18    658) (eir19    659)
1628    (eir20    660) (eir21    661) (eir22    662) (eir23    663)
1629    (eir24    664) (eir25    665) (eir26    666) (eir27    667)
1630    (eir28    668) (eir29    669) (eir30    670) (eir31    671)
1631
1632    (esfr0    672) (esfr1    673)
1633
1634    (sr0      768) (sr1      769) (sr2      770) (sr3      771) 
1635
1636    (fsr0    1024) (fsr1    1025) (fsr2    1026) (fsr3    1027)
1637    (fsr4    1028) (fsr5    1029) (fsr6    1030) (fsr7    1031)
1638    (fsr8    1032) (fsr9    1033) (fsr10   1034) (fsr11   1035)
1639    (fsr12   1036) (fsr13   1037) (fsr14   1038) (fsr15   1039)
1640    (fsr16   1040) (fsr17   1041) (fsr18   1042) (fsr19   1043)
1641    (fsr20   1044) (fsr21   1045) (fsr22   1046) (fsr23   1047)
1642    (fsr24   1048) (fsr25   1049) (fsr26   1050) (fsr27   1051)
1643    (fsr28   1052) (fsr29   1053) (fsr30   1054) (fsr31   1055)
1644    (fsr32   1056) (fsr33   1057) (fsr34   1058) (fsr35   1059)
1645    (fsr36   1060) (fsr37   1061) (fsr38   1062) (fsr39   1063)
1646    (fsr40   1064) (fsr41   1065) (fsr42   1066) (fsr43   1067)
1647    (fsr44   1068) (fsr45   1069) (fsr46   1070) (fsr47   1071)
1648    (fsr48   1072) (fsr49   1073) (fsr50   1074) (fsr51   1075)
1649    (fsr52   1076) (fsr53   1077) (fsr54   1078) (fsr55   1079)
1650    (fsr56   1080) (fsr57   1081) (fsr58   1082) (fsr59   1083)
1651    (fsr60   1084) (fsr61   1085) (fsr62   1086) (fsr63   1087)
1652
1653    ; FQ0-FQ31 are 64 bit registers.
1654    ; These names allow access to the upper 32 bits of the FQ registers.
1655    (fqop0   1088) (fqop1   1090) (fqop2   1092) (fqop3   1094) 
1656    (fqop4   1096) (fqop5   1098) (fqop6   1100) (fqop7   1102) 
1657    (fqop8   1104) (fqop9   1106) (fqop10  1108) (fqop11  1110) 
1658    (fqop12  1112) (fqop13  1114) (fqop14  1116) (fqop15  1118) 
1659    (fqop16  1120) (fqop17  1122) (fqop18  1124) (fqop19  1126) 
1660    (fqop20  1128) (fqop21  1130) (fqop22  1132) (fqop23  1134) 
1661    (fqop24  1136) (fqop25  1138) (fqop26  1140) (fqop27  1142) 
1662    (fqop28  1144) (fqop29  1146) (fqop30  1148) (fqop31  1150) 
1663    ; These names allow access to the lower 32 bits of the FQ registers.
1664    (fqst0   1089) (fqst1   1091) (fqst2   1093) (fqst3   1095) 
1665    (fqst4   1097) (fqst5   1099) (fqst6   1101) (fqst7   1103) 
1666    (fqst8   1105) (fqst9   1107) (fqst10  1109) (fqst11  1111) 
1667    (fqst12  1113) (fqst13  1115) (fqst14  1117) (fqst15  1119) 
1668    (fqst16  1121) (fqst17  1123) (fqst18  1125) (fqst19  1127) 
1669    (fqst20  1129) (fqst21  1131) (fqst22  1133) (fqst23  1135) 
1670    (fqst24  1137) (fqst25  1139) (fqst26  1141) (fqst27  1143) 
1671    (fqst28  1145) (fqst29  1147) (fqst30  1149) (fqst31  1151) 
1672    ; These also access the lower 32 bits of the FQ registers.
1673    ; These are not accessible as spr registers (see LSI appendix - section 13.4)
1674 ;  (fq0     1089) (fq1     1091) (fq2     1093) (fq3     1095) 
1675 ;  (fq4     1097) (fq5     1099) (fq6     1101) (fq7     1103) 
1676 ;  (fq8     1105) (fq9     1107) (fq10    1109) (fq11    1111) 
1677 ;  (fq12    1113) (fq13    1115) (fq14    1117) (fq15    1119) 
1678 ;  (fq16    1121) (fq17    1123) (fq18    1125) (fq19    1127) 
1679 ;  (fq20    1129) (fq21    1131) (fq22    1133) (fq23    1135) 
1680 ;  (fq24    1137) (fq25    1139) (fq26    1141) (fq27    1143) 
1681 ;  (fq28    1145) (fq29    1147) (fq30    1149) (fq31    1151) 
1682
1683    (mcilr0  1272) (mcilr1  1273)
1684
1685    (msr0    1280) (msr1    1281) (msr2    1282) (msr3    1283)
1686    (msr4    1284) (msr5    1285) (msr6    1286) (msr7    1287)
1687    (msr8    1288) (msr9    1289) (msr10   1290) (msr11   1291)
1688    (msr12   1292) (msr13   1293) (msr14   1294) (msr15   1295)
1689    (msr16   1296) (msr17   1297) (msr18   1298) (msr19   1299)
1690    (msr20   1300) (msr21   1301) (msr22   1302) (msr23   1303)
1691    (msr24   1304) (msr25   1305) (msr26   1306) (msr27   1307)
1692    (msr28   1308) (msr29   1309) (msr30   1310) (msr31   1311)
1693    (msr32   1312) (msr33   1313) (msr34   1314) (msr35   1315)
1694    (msr36   1316) (msr37   1317) (msr38   1318) (msr39   1319)
1695    (msr40   1320) (msr41   1321) (msr42   1322) (msr43   1323)
1696    (msr44   1324) (msr45   1325) (msr46   1326) (msr47   1327)
1697    (msr48   1328) (msr49   1329) (msr50   1330) (msr51   1331)
1698    (msr52   1332) (msr53   1333) (msr54   1334) (msr55   1335)
1699    (msr56   1336) (msr57   1337) (msr58   1338) (msr59   1339)
1700    (msr60   1340) (msr61   1341) (msr62   1342) (msr63   1343)
1701
1702    ; MQ0-MQ31 are 64 bit registers.
1703    ; These names allow access to the upper 32 bits of the MQ registers.
1704    (mqop0   1344) (mqop1   1346) (mqop2   1348) (mqop3   1350) 
1705    (mqop4   1352) (mqop5   1354) (mqop6   1356) (mqop7   1358) 
1706    (mqop8   1360) (mqop9   1362) (mqop10  1364) (mqop11  1366) 
1707    (mqop12  1368) (mqop13  1370) (mqop14  1372) (mqop15  1374) 
1708    (mqop16  1376) (mqop17  1378) (mqop18  1380) (mqop19  1382) 
1709    (mqop20  1384) (mqop21  1386) (mqop22  1388) (mqop23  1390) 
1710    (mqop24  1392) (mqop25  1394) (mqop26  1396) (mqop27  1398) 
1711    (mqop28  1400) (mqop29  1402) (mqop30  1404) (mqop31  1406) 
1712    ; These names allow access to the lower 32 bits of the MQ registers.
1713    (mqst0   1345) (mqst1   1347) (mqst2   1349) (mqst3   1351) 
1714    (mqst4   1353) (mqst5   1355) (mqst6   1357) (mqst7   1359) 
1715    (mqst8   1361) (mqst9   1363) (mqst10  1365) (mqst11  1367) 
1716    (mqst12  1369) (mqst13  1371) (mqst14  1373) (mqst15  1375) 
1717    (mqst16  1377) (mqst17  1379) (mqst18  1381) (mqst19  1383) 
1718    (mqst20  1385) (mqst21  1387) (mqst22  1389) (mqst23  1391) 
1719    (mqst24  1393) (mqst25  1395) (mqst26  1397) (mqst27  1399) 
1720    (mqst28  1401) (mqst29  1403) (mqst30  1405) (mqst31  1407) 
1721    ; These also access the lower 32 bits of the MQ registers.
1722    ; These are not accessible as spr registers (see LSI appendix - section 13.4)
1723 ;  (mq0     1345) (mq1     1347) (mq2     1349) (mq3     1351) 
1724 ;  (mq4     1353) (mq5     1355) (mq6     1357) (mq7     1359) 
1725 ;  (mq8     1361) (mq9     1363) (mq10    1365) (mq11    1367) 
1726 ;  (mq12    1369) (mq13    1371) (mq14    1373) (mq15    1375) 
1727 ;  (mq16    1377) (mq17    1379) (mq18    1381) (mq19    1383) 
1728 ;  (mq20    1385) (mq21    1387) (mq22    1389) (mq23    1391) 
1729 ;  (mq24    1393) (mq25    1395) (mq26    1397) (mq27    1399) 
1730 ;  (mq28    1401) (mq29    1403) (mq30    1405) (mq31    1407) 
1731
1732    ; These are not accessible as spr registers (see LSI appendix - section 13.4)
1733 ;  (acc0    1408) (acc1    1409) (acc2    1410) (acc3    1411)
1734 ;  (acc4    1412) (acc5    1413) (acc6    1414) (acc7    1415)
1735 ;  (acc8    1416) (acc9    1417) (acc10   1418) (acc11   1419)
1736 ;  (acc12   1420) (acc13   1421) (acc14   1422) (acc15   1423)
1737 ;  (acc16   1424) (acc17   1425) (acc18   1426) (acc19   1427)
1738 ;  (acc20   1428) (acc21   1429) (acc22   1430) (acc23   1431)
1739 ;  (acc24   1432) (acc25   1433) (acc26   1434) (acc27   1435)
1740 ;  (acc28   1436) (acc29   1437) (acc30   1438) (acc31   1439)
1741 ;  (acc32   1440) (acc33   1441) (acc34   1442) (acc35   1443)
1742 ;  (acc36   1444) (acc37   1445) (acc38   1446) (acc39   1447)
1743 ;  (acc40   1448) (acc41   1449) (acc42   1450) (acc43   1451)
1744 ;  (acc44   1452) (acc45   1453) (acc46   1454) (acc47   1455)
1745 ;  (acc48   1456) (acc49   1457) (acc50   1458) (acc51   1459)
1746 ;  (acc52   1460) (acc53   1461) (acc54   1462) (acc55   1463)
1747 ;  (acc56   1464) (acc57   1465) (acc58   1466) (acc59   1467)
1748 ;  (acc60   1468) (acc61   1469) (acc62   1470) (acc63   1471)
1749
1750 ;  (accg0   1472) (accg1   1473) (accg2   1474) (accg3   1475)
1751 ;  (accg4   1476) (accg5   1477) (accg6   1478) (accg7   1479)
1752 ;  (accg8   1480) (accg9   1481) (accg10  1482) (accg11  1483)
1753 ;  (accg12  1484) (accg13  1485) (accg14  1486) (accg15  1487)
1754 ;  (accg16  1488) (accg17  1489) (accg18  1490) (accg19  1491)
1755 ;  (accg20  1492) (accg21  1493) (accg22  1494) (accg23  1495)
1756 ;  (accg24  1496) (accg25  1497) (accg26  1498) (accg27  1499)
1757 ;  (accg28  1500) (accg29  1501) (accg30  1502) (accg31  1503)
1758 ;  (accg32  1504) (accg33  1505) (accg34  1506) (accg35  1507)
1759 ;  (accg36  1508) (accg37  1509) (accg38  1510) (accg39  1511)
1760 ;  (accg40  1512) (accg41  1513) (accg42  1514) (accg43  1515)
1761 ;  (accg44  1516) (accg45  1517) (accg46  1518) (accg47  1519)
1762 ;  (accg48  1520) (accg49  1521) (accg50  1522) (accg51  1523)
1763 ;  (accg52  1524) (accg53  1525) (accg54  1526) (accg55  1527)
1764 ;  (accg56  1528) (accg57  1529) (accg58  1530) (accg59  1531)
1765 ;  (accg60  1532) (accg61  1533) (accg62  1534) (accg63  1535)
1766
1767    (ear0    1536) (ear1    1537) (ear2    1538) (ear3    1539)
1768    (ear4    1540) (ear5    1541) (ear6    1542) (ear7    1543)
1769    (ear8    1544) (ear9    1545) (ear10   1546) (ear11   1547)
1770    (ear12   1548) (ear13   1549) (ear14   1550) (ear15   1551)
1771    (ear16   1552) (ear17   1553) (ear18   1554) (ear19   1555)
1772    (ear20   1556) (ear21   1557) (ear22   1558) (ear23   1559)
1773    (ear24   1560) (ear25   1561) (ear26   1562) (ear27   1563)
1774    (ear28   1564) (ear29   1565) (ear30   1566) (ear31   1567)
1775    (ear32   1568) (ear33   1569) (ear34   1570) (ear35   1571)
1776    (ear36   1572) (ear37   1573) (ear38   1574) (ear39   1575)
1777    (ear40   1576) (ear41   1577) (ear42   1578) (ear43   1579)
1778    (ear44   1580) (ear45   1581) (ear46   1582) (ear47   1583)
1779    (ear48   1584) (ear49   1585) (ear50   1586) (ear51   1587)
1780    (ear52   1588) (ear53   1589) (ear54   1590) (ear55   1591)
1781    (ear56   1592) (ear57   1593) (ear58   1594) (ear59   1595)
1782    (ear60   1596) (ear61   1597) (ear62   1598) (ear63   1599)
1783
1784    (edr0    1600) (edr1    1601) (edr2    1602) (edr3    1603)
1785    (edr4    1604) (edr5    1605) (edr6    1606) (edr7    1607)
1786    (edr8    1608) (edr9    1609) (edr10   1610) (edr11   1611)
1787    (edr12   1612) (edr13   1613) (edr14   1614) (edr15   1615)
1788    (edr16   1616) (edr17   1617) (edr18   1618) (edr19   1619)
1789    (edr20   1620) (edr21   1621) (edr22   1622) (edr23   1623)
1790    (edr24   1624) (edr25   1625) (edr26   1626) (edr27   1627)
1791    (edr28   1628) (edr29   1629) (edr30   1630) (edr31   1631)
1792    (edr32   1632) (edr33   1636) (edr34   1634) (edr35   1635)
1793    (edr36   1636) (edr37   1637) (edr38   1638) (edr39   1639)
1794    (edr40   1640) (edr41   1641) (edr42   1642) (edr43   1643)
1795    (edr44   1644) (edr45   1645) (edr46   1646) (edr47   1647)
1796    (edr48   1648) (edr49   1649) (edr50   1650) (edr51   1651)
1797    (edr52   1652) (edr53   1653) (edr54   1654) (edr55   1655)
1798    (edr56   1656) (edr57   1657) (edr58   1658) (edr59   1659)
1799    (edr60   1660) (edr61   1661) (edr62   1662) (edr63   1663)
1800
1801    (iamlr0  1664) (iamlr1  1665) (iamlr2  1666) (iamlr3  1667)
1802    (iamlr4  1668) (iamlr5  1669) (iamlr6  1670) (iamlr7  1671)
1803    (iamlr8  1672) (iamlr9  1673) (iamlr10 1674) (iamlr11 1675)
1804    (iamlr12 1676) (iamlr13 1677) (iamlr14 1678) (iamlr15 1679)
1805    (iamlr16 1680) (iamlr17 1681) (iamlr18 1682) (iamlr19 1683)
1806    (iamlr20 1684) (iamlr21 1685) (iamlr22 1686) (iamlr23 1687)
1807    (iamlr24 1688) (iamlr25 1689) (iamlr26 1690) (iamlr27 1691)
1808    (iamlr28 1692) (iamlr29 1693) (iamlr30 1694) (iamlr31 1695)
1809    (iamlr32 1696) (iamlr33 1697) (iamlr34 1698) (iamlr35 1699)
1810    (iamlr36 1700) (iamlr37 1701) (iamlr38 1702) (iamlr39 1703)
1811    (iamlr40 1704) (iamlr41 1705) (iamlr42 1706) (iamlr43 1707)
1812    (iamlr44 1708) (iamlr45 1709) (iamlr46 1710) (iamlr47 1711)
1813    (iamlr48 1712) (iamlr49 1713) (iamlr50 1714) (iamlr51 1715)
1814    (iamlr52 1716) (iamlr53 1717) (iamlr54 1718) (iamlr55 1719)
1815    (iamlr56 1720) (iamlr57 1721) (iamlr58 1722) (iamlr59 1723)
1816    (iamlr60 1724) (iamlr61 1725) (iamlr62 1726) (iamlr63 1727)
1817
1818    (iampr0  1728) (iampr1  1729) (iampr2  1730) (iampr3  1731)
1819    (iampr4  1732) (iampr5  1733) (iampr6  1734) (iampr7  1735)
1820    (iampr8  1736) (iampr9  1737) (iampr10 1738) (iampr11 1739)
1821    (iampr12 1740) (iampr13 1741) (iampr14 1742) (iampr15 1743)
1822    (iampr16 1744) (iampr17 1745) (iampr18 1746) (iampr19 1747)
1823    (iampr20 1748) (iampr21 1749) (iampr22 1750) (iampr23 1751)
1824    (iampr24 1752) (iampr25 1753) (iampr26 1754) (iampr27 1755)
1825    (iampr28 1756) (iampr29 1757) (iampr30 1758) (iampr31 1759)
1826    (iampr32 1760) (iampr33 1761) (iampr34 1762) (iampr35 1763)
1827    (iampr36 1764) (iampr37 1765) (iampr38 1766) (iampr39 1767)
1828    (iampr40 1768) (iampr41 1769) (iampr42 1770) (iampr43 1771)
1829    (iampr44 1772) (iampr45 1773) (iampr46 1774) (iampr47 1775)
1830    (iampr48 1776) (iampr49 1777) (iampr50 1778) (iampr51 1779)
1831    (iampr52 1780) (iampr53 1781) (iampr54 1782) (iampr55 1783)
1832    (iampr56 1784) (iampr57 1785) (iampr58 1786) (iampr59 1787)
1833    (iampr60 1788) (iampr61 1789) (iampr62 1790) (iampr63 1791)
1834
1835    (damlr0  1792) (damlr1  1793) (damlr2  1794) (damlr3  1795)
1836    (damlr4  1796) (damlr5  1797) (damlr6  1798) (damlr7  1799)
1837    (damlr8  1800) (damlr9  1801) (damlr10 1802) (damlr11 1803)
1838    (damlr12 1804) (damlr13 1805) (damlr14 1806) (damlr15 1807)
1839    (damlr16 1808) (damlr17 1809) (damlr18 1810) (damlr19 1811)
1840    (damlr20 1812) (damlr21 1813) (damlr22 1814) (damlr23 1815)
1841    (damlr24 1816) (damlr25 1817) (damlr26 1818) (damlr27 1819)
1842    (damlr28 1820) (damlr29 1821) (damlr30 1822) (damlr31 1823)
1843    (damlr32 1824) (damlr33 1825) (damlr34 1826) (damlr35 1827)
1844    (damlr36 1828) (damlr37 1829) (damlr38 1830) (damlr39 1831)
1845    (damlr40 1832) (damlr41 1833) (damlr42 1834) (damlr43 1835)
1846    (damlr44 1836) (damlr45 1837) (damlr46 1838) (damlr47 1839)
1847    (damlr48 1840) (damlr49 1841) (damlr50 1842) (damlr51 1843)
1848    (damlr52 1844) (damlr53 1845) (damlr54 1846) (damlr55 1847)
1849    (damlr56 1848) (damlr57 1849) (damlr58 1850) (damlr59 1851)
1850    (damlr60 1852) (damlr61 1853) (damlr62 1854) (damlr63 1855)
1851
1852    (dampr0  1856) (dampr1  1857) (dampr2  1858) (dampr3  1859)
1853    (dampr4  1860) (dampr5  1861) (dampr6  1862) (dampr7  1863)
1854    (dampr8  1864) (dampr9  1865) (dampr10 1866) (dampr11 1867)
1855    (dampr12 1868) (dampr13 1869) (dampr14 1870) (dampr15 1871)
1856    (dampr16 1872) (dampr17 1873) (dampr18 1874) (dampr19 1875)
1857    (dampr20 1876) (dampr21 1877) (dampr22 1878) (dampr23 1879)
1858    (dampr24 1880) (dampr25 1881) (dampr26 1882) (dampr27 1883)
1859    (dampr28 1884) (dampr29 1885) (dampr30 1886) (dampr31 1887)
1860    (dampr32 1888) (dampr33 1889) (dampr34 1890) (dampr35 1891)
1861    (dampr36 1892) (dampr37 1893) (dampr38 1894) (dampr39 1895)
1862    (dampr40 1896) (dampr41 1897) (dampr42 1898) (dampr43 1899)
1863    (dampr44 1900) (dampr45 1901) (dampr46 1902) (dampr47 1903)
1864    (dampr48 1904) (dampr49 1905) (dampr50 1906) (dampr51 1907)
1865    (dampr52 1908) (dampr53 1909) (dampr54 1910) (dampr55 1911)
1866    (dampr56 1912) (dampr57 1913) (dampr58 1914) (dampr59 1915)
1867    (dampr60 1916) (dampr61 1917) (dampr62 1918) (dampr63 1919)
1868
1869    (amcr    1920) (stbar   1921) (mmcr    1922)
1870    (dcr     2048) (brr     2049) (nmar    2050)
1871
1872    (ibar0   2052) (ibar1   2053) (ibar2   2054) (ibar3   2055)
1873    (dbar0   2056) (dbar1   2057) (dbar2   2058) (dbar3   2059)
1874
1875    (dbdr00  2060) (dbdr01  2061) (dbdr02  2062) (dbdr03  2063)
1876    (dbdr10  2064) (dbdr11  2065) (dbdr12  2066) (dbdr13  2067)
1877    (dbdr20  2068) (dbdr21  2069) (dbdr22  2070) (dbdr23  2071)
1878    (dbdr30  2072) (dbdr31  2073) (dbdr32  2074) (dbdr33  2075)
1879
1880    (dbmr00  2076) (dbmr01  2077) (dbmr02  2078) (dbmr03  2079)
1881    (dbmr10  2080) (dbmr11  2081) (dbmr12  2082) (dbmr13  2083)
1882    (dbmr20  2084) (dbmr21  2085) (dbmr22  2086) (dbmr23  2087)
1883    (dbmr30  2088) (dbmr31  2089) (dbmr32  2090) (dbmr33  2091)
1884
1885    (cpcfr   2092) (cpcr    2093) (cpsr    2094)
1886
1887    (cpesr0  2096) (cpesr1  2097)
1888    (cpemr0  2098) (cpemr1  2099)
1889
1890    (ihsr8   3848)
1891   )
1892 )
1893
1894 (define-hardware
1895   (name h-spr)
1896   (comment "special purpose registers")
1897   (attrs PROFILE)
1898   (type register UWI (4096))
1899   (indices extern-keyword spr-names)
1900   (get (index) (c-call UWI "@cpu@_h_spr_get_handler" index))
1901   (set (index newval) (c-call VOID "@cpu@_h_spr_set_handler" index newval))
1902 )
1903
1904 (define-pmacro (spr-pcsr)  (reg h-spr   1))
1905 (define-pmacro (spr-bpcsr) (reg h-spr   2))
1906 (define-pmacro (spr-lr)    (reg h-spr 272))
1907 (define-pmacro (spr-lcr)   (reg h-spr 273))
1908 (define-pmacro (spr-sr0)   (reg h-spr 768))
1909 (define-pmacro (spr-sr1)   (reg h-spr 769))
1910 (define-pmacro (spr-sr2)   (reg h-spr 770))
1911 (define-pmacro (spr-sr3)   (reg h-spr 771))
1912
1913 ; Accumulator guard. Actually a subset of the SPR registers, but those SPRs
1914 ; are read-only in most insns. This hardware element is used by those insns
1915 ; which have direct access (mwtaccg, mrdaccg).
1916 (define-keyword
1917   (name accg-names)
1918   (print-name h-accg)
1919   (prefix "")
1920   (values
1921    (accg0   0)(accg1   1)(accg2   2)(accg3   3)
1922    (accg4   4)(accg5   5)(accg6   6)(accg7   7)
1923    (accg8   8)(accg9   9)(accg10 10)(accg11 11)
1924    (accg12 12)(accg13 13)(accg14 14)(accg15 15)
1925    (accg16 16)(accg17 17)(accg18 18)(accg19 19)
1926    (accg20 20)(accg21 21)(accg22 22)(accg23 23)
1927    (accg24 24)(accg25 25)(accg26 26)(accg27 27)
1928    (accg28 28)(accg29 29)(accg30 30)(accg31 31)
1929    (accg32 32)(accg33 33)(accg34 34)(accg35 35)
1930    (accg36 36)(accg37 37)(accg38 38)(accg39 39)
1931    (accg40 40)(accg41 41)(accg42 42)(accg43 43)
1932    (accg44 44)(accg45 45)(accg46 46)(accg47 47)
1933    (accg48 48)(accg49 49)(accg50 50)(accg51 51)
1934    (accg52 52)(accg53 53)(accg54 54)(accg55 55)
1935    (accg56 56)(accg57 57)(accg58 58)(accg59 59)
1936    (accg60 60)(accg61 61)(accg62 62)(accg63 63)
1937   )
1938 )
1939
1940 (define-hardware
1941   (name h-accg)
1942   (comment "accumulator guard")
1943   (attrs PROFILE VIRTUAL)
1944   (type register UWI (64))
1945   (indices extern-keyword accg-names)
1946   (get (index)
1947        (and (reg h-spr (add index 1472)) #xff))
1948   (set (index newval)
1949        (set (raw-reg UWI h-spr (add index 1472)) (and newval #xff)))
1950 )
1951
1952 ; 40 bit accumulator. Composed of ACCG and ACC registers concatenated, but
1953 ; referenced more often as the composed 40 bits.
1954 (define-keyword
1955   (name acc-names)
1956   (print-name h-acc40)
1957   (prefix "")
1958   (values
1959 (acc0   0)(acc1   1)(acc2   2)(acc3   3)(acc4   4)(acc5   5)(acc6   6)(acc7   7)
1960 (acc8   8)(acc9   9)(acc10 10)(acc11 11)(acc12 12)(acc13 13)(acc14 14)(acc15 15)
1961 (acc16 16)(acc17 17)(acc18 18)(acc19 19)(acc20 20)(acc21 21)(acc22 22)(acc23 23)
1962 (acc24 24)(acc25 25)(acc26 26)(acc27 27)(acc28 28)(acc29 29)(acc30 30)(acc31 31)
1963 (acc32 32)(acc33 33)(acc34 34)(acc35 35)(acc36 36)(acc37 37)(acc38 38)(acc39 39)
1964 (acc40 40)(acc41 41)(acc42 42)(acc43 43)(acc44 44)(acc45 45)(acc46 46)(acc47 47)
1965 (acc48 48)(acc49 49)(acc50 50)(acc51 51)(acc52 52)(acc53 53)(acc54 54)(acc55 55)
1966 (acc56 56)(acc57 57)(acc58 58)(acc59 59)(acc60 60)(acc61 61)(acc62 62)(acc63 63)
1967   )
1968 )
1969
1970 (define-hardware
1971   (name h-acc40S)
1972   (comment "40 bit signed accumulator")
1973   (attrs PROFILE VIRTUAL)
1974   (type register DI (64))
1975   (indices extern-keyword acc-names)
1976   ; The accumlator is made up of two 32 bit registers, accgi/acci.
1977   ; We want to extract this as a combined 40 signed bits
1978   (get (index)
1979        (or DI
1980            (sll  DI (ext DI (trunc QI (reg h-spr (add index 1472))))
1981                  32)
1982            (zext DI (reg h-spr (add index 1408)))))
1983   ; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
1984   ; on ACC and ACCG registers
1985   (set (index newval)
1986        (sequence ()
1987                  (c-call VOID "frv_check_spr_write_access" (add index 1408))
1988                  (set (raw-reg UWI h-spr
1989                                (add index 1472)) (and (srl newval 32) #xff))
1990                  (set (raw-reg UWI h-spr
1991                                (add index 1408)) (trunc USI newval))))
1992 )
1993
1994 (define-hardware
1995   (name h-acc40U)
1996   (comment "40 bit unsigned accumulator")
1997   (attrs PROFILE VIRTUAL)
1998   (type register UDI (64))
1999   (indices extern-keyword acc-names)
2000   ; The accumlator is made up of two 32 bit registers, accgi/acci.
2001   ; We want to extract this as a combined 40 unsigned bits
2002   (get (index)
2003        (or DI
2004            (sll  DI (zext DI (reg h-spr (add index 1472))) 32)
2005            (zext DI (reg h-spr (add index 1408)))))
2006   ; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
2007   ; on ACC and ACCG registers
2008   (set (index newval)
2009        (sequence ()
2010                  (c-call VOID "frv_check_spr_write_access" (add index 1408))
2011                  (set (raw-reg UWI h-spr
2012                                (add index 1472)) (and (srl newval 32) #xff))
2013                  (set (raw-reg UWI h-spr
2014                                (add index 1408)) (trunc USI newval))))
2015 )
2016
2017 ; Integer condition code registers (CCR)
2018 ;
2019 ; The individual sub registers bits of the CCR are referenced more often than
2020 ; the entire register so set them directly. We can assemble the
2021 ; entire register when necessary.
2022 ;
2023 (define-keyword
2024   (name iccr-names)
2025   (print-name h-iccr)
2026   (prefix "")
2027   (values (icc0 0) (icc1 1) (icc2 2) (icc3 3))
2028 )
2029
2030 (define-hardware
2031   (name h-iccr)
2032   (comment "Integer condition code registers")
2033   (attrs PROFILE)
2034   (type register UQI (4))
2035   (indices extern-keyword iccr-names)
2036 )
2037
2038 ; Floating point condition code registers (CCR)
2039 ;
2040 ; The individual sub registers bits of the CCR are referenced more often than
2041 ; the entire register so set them directly. We can assemble the
2042 ; entire register when necessary.
2043 ;
2044 (define-keyword
2045   (name fccr-names)
2046   (print-name h-fccr)
2047   (prefix "")
2048   (values (fcc0 0) (fcc1 1) (fcc2 2) (fcc3 3))
2049 )
2050
2051 (define-hardware
2052   (name h-fccr)
2053   (comment "Integer condition code registers")
2054   (attrs PROFILE)
2055   (type register UQI (4))
2056   (indices extern-keyword fccr-names)
2057 )
2058
2059 ; C condition code registers (CCCR)
2060 ;
2061 (define-keyword
2062   (name cccr-names)
2063   (print-name h-cccr)
2064   (prefix "")
2065   (values (cc0 0) (cc1 1) (cc2 2) (cc3 3) (cc4 4) (cc5 5) (cc6 6) (cc7 7))
2066 )
2067
2068 (define-hardware
2069   (name h-cccr)
2070   (comment "Condition code registers")
2071   (attrs PROFILE)
2072   (type register UQI (8))
2073   (indices extern-keyword cccr-names)
2074 )
2075 \f
2076 ; Dummy hardware used to define packing bit on insns
2077 ;
2078 (define-hardware
2079   (name h-pack)
2080   (comment "Packing bit dummy hardware")
2081   (type immediate (UINT 1))
2082   (values keyword "" (("" 1) (".p" 0) (".P" 0)))
2083 )
2084 ; Dummy hardware used to define hint field for branches always taken
2085 ;
2086 (define-hardware
2087   (name h-hint-taken)
2088   (comment "Branch taken hint dummy hardware")
2089   (type immediate (UINT 1))
2090   ; The order of these is important. We want '2' to get written by default,
2091   ; but we also want the docoder/disassembler to allow the values '0', '1' and
2092   ; '3'.
2093   (values keyword "" (("" 2) ("" 0) ("" 1) ("" 3)))
2094 )
2095 ; Dummy hardware used to define hint field for branches never taken
2096 ;
2097 (define-hardware
2098   (name h-hint-not-taken)
2099   (comment "Branch not taken hint dummy hardware")
2100   (type immediate (UINT 1))
2101   ; The order of these is important. We want '0' to get written by default,
2102   ; but we also want the docoder/disassembler to allow the values '1', '2' and
2103   ; '3'.
2104   (values keyword "" (("" 0) ("" 1) ("" 2) ("" 3)))
2105 )
2106 \f
2107 ; Instruction Operands.
2108 ; These entries provide a layer between the assembler and the raw hardware
2109 ; description, and are used to refer to hardware elements in the semantic
2110 ; code.  Usually there's a bit of over-specification, but in more complicated
2111 ; instruction sets there isn't.
2112
2113 ; FRV specific operand attributes:
2114
2115 (define-attr
2116   (for operand)
2117   (type boolean)
2118   (name HASH-PREFIX)
2119   (comment "immediates have an optional '#' prefix")
2120 )
2121
2122 ; ??? Convention says this should be o-sr, but then the insn definitions
2123 ; should refer to o-sr which is clumsy.  The "o-" could be implicit, but
2124 ; then it should be implicit for all the symbols here, but then there would
2125 ; be confusion between (f-)simm8 and (h-)simm8.
2126 ; So for now the rule is exactly as it appears here.
2127
2128 ; dnmop: define-normal-mode-operand: temporary, pending potential removal
2129 ; of modes from h/w.
2130 (define-pmacro (dnmop xname xcomment xattrs xtype xindex xmode)
2131   (define-operand
2132     (name xname)
2133     (comment xcomment)
2134     (.splice attrs (.unsplice xattrs))
2135     (type xtype)
2136     (index xindex)
2137     (mode xmode)
2138     )
2139 )
2140
2141 (dnop  pack "packing bit" () h-pack f-pack)
2142
2143 (dnmop GRi        "source register 1"      () h-gr        f-GRi  SI)
2144 (dnmop GRj        "source register 2"      () h-gr        f-GRj  SI)
2145 (dnmop GRk        "destination register"   () h-gr        f-GRk  SI)
2146 (dnmop GRkhi      "destination register"   () h-gr_hi     f-GRk  UHI)
2147 (dnmop GRklo      "destination register"   () h-gr_lo     f-GRk  UHI)
2148 (dnmop GRdoublek  "destination register"   () h-gr_double f-GRk  DI)
2149 (dnmop ACC40Si    "signed accumulator"     () h-acc40S    f-ACC40Si DI)
2150 (dnmop ACC40Ui    "unsigned accumulator"   () h-acc40U    f-ACC40Ui UDI)
2151 (dnmop ACC40Sk    "target accumulator"     () h-acc40S    f-ACC40Sk DI)
2152 (dnmop ACC40Uk    "target accumulator"     () h-acc40U    f-ACC40Uk UDI)
2153 (dnmop ACCGi      "source register"        () h-accg      f-ACCGi   UWI)
2154 (dnmop ACCGk      "target register"        () h-accg      f-ACCGk   UWI)
2155
2156 (dnmop CPRi       "source register"        ((MACH frv)) h-cpr        f-CPRi SI)
2157 (dnmop CPRj       "source register"        ((MACH frv)) h-cpr        f-CPRj SI)
2158 (dnmop CPRk       "destination register"   ((MACH frv)) h-cpr        f-CPRk SI)
2159 (dnmop CPRdoublek "destination register"   ((MACH frv)) h-cpr_double f-CPRk DI)
2160
2161 ; floating point operands
2162 (dnmop FRinti    "source register 1"      () h-fr_int    f-FRi SI)
2163 (dnmop FRintj    "source register 2"      () h-fr_int    f-FRj SI)
2164 (dnmop FRintk    "target register"        () h-fr_int    f-FRk SI)
2165 (dnmop FRi       "source register 1"      () h-fr        f-FRi SF)
2166 (dnmop FRj       "source register 2"      () h-fr        f-FRj SF)
2167 (dnmop FRk       "destination register"   () h-fr        f-FRk SF)
2168 (dnmop FRkhi     "destination register"   () h-fr_hi     f-FRk UHI)
2169 (dnmop FRklo     "destination register"   () h-fr_lo     f-FRk UHI)
2170 (dnmop FRdoublei "source register 1"      () h-fr_double f-FRi DF)
2171 (dnmop FRdoublej "source register 2"      () h-fr_double f-FRj DF)
2172 (dnmop FRdoublek "target register"        () h-fr_double f-FRk DF)
2173
2174 (dnop CRi       "source register 1"       () h-cccr f-CRi)
2175 (dnop CRj       "source register 2"       () h-cccr f-CRj)
2176 (dnop CRj_int   "destination register"    () h-cccr f-CRj_int)
2177 (dnop CRj_float "destination register"    () h-cccr f-CRj_float)
2178 (dnop CRk       "destination register"    () h-cccr f-CRk)
2179 (dnop CCi       "condition   register"    () h-cccr f-CCi)
2180
2181 (dnop ICCi_1  "condition   register"      () h-iccr f-ICCi_1)
2182 (dnop ICCi_2  "condition   register"      () h-iccr f-ICCi_2)
2183 (dnop ICCi_3  "condition   register"      () h-iccr f-ICCi_3)
2184 (dnop FCCi_1  "condition   register"      () h-fccr f-FCCi_1)
2185 (dnop FCCi_2  "condition   register"      () h-fccr f-FCCi_2)
2186 (dnop FCCi_3  "condition   register"      () h-fccr f-FCCi_3)
2187 (dnop FCCk    "condition   register"      () h-fccr f-FCCk)
2188
2189 (dnop eir     "exception insn reg"        () h-uint f-eir)
2190 (dnop s10     "10 bit signed immediate"   (HASH-PREFIX) h-sint f-s10)
2191 (dnop u16     "16 bit unsigned immediate" (HASH-PREFIX) h-uint f-u16)
2192 (dnop s16     "16 bit signed   immediate" (HASH-PREFIX) h-sint f-s16)
2193 (dnop s6      "6  bit signed   immediate" (HASH-PREFIX) h-sint f-s6)
2194 (dnop s6_1    "6  bit signed   immediate" (HASH-PREFIX) h-sint f-s6_1)
2195 (dnop u6      "6  bit unsigned immediate" (HASH-PREFIX) h-uint f-u6)
2196 (dnop s5      "5  bit signed   immediate" (HASH-PREFIX) h-sint f-s5)
2197 (dnop cond    "conditional arithmetic"    (HASH-PREFIX) h-uint f-cond)
2198 (dnop ccond   "lr branch condition"       (HASH-PREFIX) h-uint f-ccond)
2199 (dnop hint    "2 bit branch predictor"    (HASH-PREFIX) h-uint f-hint)
2200 (dnop hint_taken "2 bit branch predictor"     () h-hint-taken     f-hint)
2201 (dnop hint_not_taken "2 bit branch predictor" () h-hint-not-taken f-hint)
2202
2203 (dnop LI      "link indicator"            () h-uint f-LI)
2204 (dnop lock    "cache lock indicator"      (HASH-PREFIX) h-uint f-lock)
2205 (dnop debug   "debug mode indicator"      (HASH-PREFIX) h-uint f-debug)
2206 (dnop A       "all accumulator indicator" (HASH-PREFIX) h-uint f-A)
2207 (dnop ae      "all entries indicator"     (HASH-PREFIX) h-uint f-ae)
2208
2209 (dnop label16  "18 bit pc relative address" () h-iaddr f-label16)
2210 (dnop label24  "26 bit pc relative address" () h-iaddr f-label24)
2211
2212 (define-operand
2213   (name FRintieven)
2214   (comment "(even) source register 1")
2215   (attrs)
2216   (type h-fr_int)
2217   (index f-FRi)
2218   (mode SI)
2219   (handlers (parse "even_register"))
2220 )
2221
2222 (define-operand
2223   (name FRintjeven)
2224   (comment "(even) source register 2")
2225   (attrs)
2226   (type h-fr_int)
2227   (index f-FRj)
2228   (mode SI)
2229   (handlers (parse "even_register"))
2230 )
2231
2232 (define-operand
2233   (name FRintkeven)
2234   (comment "(even) target register")
2235   (attrs)
2236   (type h-fr_int)
2237   (index f-FRk)
2238   (mode SI)
2239   (handlers (parse "even_register"))
2240 )
2241
2242 (define-operand
2243   (name d12)
2244   (comment "12 bit signed immediate")
2245   (attrs)
2246   (type h-sint)
2247   (index f-d12)
2248   (handlers (parse "d12"))
2249 )
2250
2251 (define-operand
2252   (name s12)
2253   (comment "12 bit signed immediate")
2254   (attrs HASH-PREFIX)
2255   (type h-sint)
2256   (index f-d12)
2257   (handlers (parse "s12"))
2258 )
2259
2260 (define-operand
2261   (name u12)
2262   (comment "12 bit signed immediate")
2263   (attrs HASH-PREFIX)
2264   (type h-sint)
2265   (index f-u12)
2266   (handlers (parse "u12"))
2267 )
2268
2269 (define-operand 
2270   (name spr)
2271   (comment "special purpose register")
2272   (attrs)
2273   (type  h-spr)
2274   (index f-spr)
2275   (handlers (parse "spr") (print "spr"))
2276 )
2277
2278 (define-operand
2279   (name ulo16)
2280   (comment "16 bit unsigned immediate, for #lo()")
2281   (attrs)
2282   (type h-uint)
2283   (index f-u16)
2284   (handlers (parse "ulo16") (print "lo"))
2285 )
2286
2287 (define-operand
2288   (name slo16)
2289   (comment "16 bit unsigned immediate, for #lo()")
2290   (attrs)
2291   (type h-sint)
2292   (index f-s16)
2293   (handlers (parse "uslo16") (print "lo"))
2294 )
2295
2296 (define-operand
2297   (name uhi16)
2298   (comment "16 bit unsigned immediate, for #hi()")
2299   (attrs)
2300   (type h-uint)
2301   (index f-u16)
2302   (handlers (parse "uhi16") (print "hi"))
2303 )
2304
2305 ; operands representing hardware
2306 ;
2307 (dnop psr_esr "PSR.ESR bit" (SEM-ONLY) h-psr_esr f-nil)
2308 (dnop psr_s   "PSR.S   bit" (SEM-ONLY) h-psr_s   f-nil)
2309 (dnop psr_ps  "PSR.PS  bit" (SEM-ONLY) h-psr_ps  f-nil)
2310 (dnop psr_et  "PSR.ET  bit" (SEM-ONLY) h-psr_et  f-nil)
2311
2312 (dnop bpsr_bs  "BPSR.BS  bit" (SEM-ONLY) h-bpsr_bs  f-nil)
2313 (dnop bpsr_bet "BPSR.BET bit" (SEM-ONLY) h-bpsr_bet f-nil)
2314
2315 (dnop tbr_tba "TBR.TBA" (SEM-ONLY) h-tbr_tba f-nil)
2316 (dnop tbr_tt  "TBR.TT"  (SEM-ONLY) h-tbr_tt  f-nil)
2317
2318 ; Null operands
2319 ;
2320 (define-pmacro (ICCi_1-null)  (f-ICCi_1-null 0))
2321 (define-pmacro (ICCi_2-null)  (f-ICCi_2-null 0))
2322 (define-pmacro (ICCi_3-null)  (f-ICCi_3-null 0))
2323 (define-pmacro (FCCi_1-null)  (f-FCCi_1-null 0))
2324 (define-pmacro (FCCi_2-null)  (f-FCCi_2-null 0))
2325 (define-pmacro (FCCi_3-null)  (f-FCCi_3-null 0))
2326 (define-pmacro (rs-null)      (f-rs-null     0))
2327 (define-pmacro (GRi-null)     (f-GRi-null    0))
2328 (define-pmacro (GRj-null)     (f-GRj-null    0))
2329 (define-pmacro (GRk-null)     (f-GRk-null    0))
2330 (define-pmacro (FRi-null)     (f-FRi-null    0))
2331 (define-pmacro (FRj-null)     (f-FRj-null    0))
2332 (define-pmacro (ACCj-null)    (f-ACCj-null   0))
2333 (define-pmacro (rd-null)      (f-rd-null     0))
2334 (define-pmacro (cond-null)    (f-cond-null   0))
2335 (define-pmacro (ccond-null)   (f-ccond-null  0))
2336 (define-pmacro (s12-null)     (f-s12-null    0))
2337 (define-pmacro (label16-null) (f-label16-null 0))
2338 (define-pmacro (misc-null-1)  (f-misc-null-1 0))
2339 (define-pmacro (misc-null-2)  (f-misc-null-2 0))
2340 (define-pmacro (misc-null-3)  (f-misc-null-3 0))
2341 (define-pmacro (misc-null-4)  (f-misc-null-4 0))
2342 (define-pmacro (misc-null-5)  (f-misc-null-5 0))
2343 (define-pmacro (misc-null-6)  (f-misc-null-6 0))
2344 (define-pmacro (misc-null-7)  (f-misc-null-7 0))
2345 (define-pmacro (misc-null-8)  (f-misc-null-8 0))
2346 (define-pmacro (misc-null-9)  (f-misc-null-9 0))
2347 (define-pmacro (misc-null-10) (f-misc-null-10 0))
2348 (define-pmacro (misc-null-11) (f-misc-null-11 0))
2349
2350 (define-pmacro (LI-on)       (f-LI-on  1))
2351 (define-pmacro (LI-off)      (f-LI-off 0))
2352 \f
2353 ; Instruction definitions.
2354 ;
2355 ; Notes:
2356 ; - dni is short for "define-normal-instruction"
2357 ; - Macros are used to represent each insn format. These should be used as much
2358 ;   as possible unless an insn has exceptional behaviour
2359 ;
2360
2361 ; Commonly used Macros
2362 ;
2363 ; Specific registers
2364 ;
2365
2366 ; Integer condition code manipulation
2367 ;
2368 (define-pmacro (set-z-and-n icc x)
2369   (if (eq x 0)
2370       (set icc (or (and icc #x7) #x4))
2371       (if (lt x 0)
2372           (set icc (or (and icc #xb) #x8))
2373           (set icc (and icc #x3))))
2374 )
2375
2376 (define-pmacro (set-n icc val)
2377   (if (eq val 0)
2378       (set icc (and icc #x7))
2379       (set icc (or  icc #x8)))
2380 )
2381
2382 (define-pmacro (set-z icc val)
2383   (if (eq val 0)
2384       (set icc (and icc #xb))
2385       (set icc (or  icc #x4)))
2386 )
2387
2388 (define-pmacro (set-v icc val)
2389   (if (eq val 0)
2390       (set icc (and icc #xd))
2391       (set icc (or  icc #x2)))
2392 )
2393
2394 (define-pmacro (set-c icc val)
2395   (if (eq val 0)
2396       (set icc (and icc #xe))
2397       (set icc (or  icc #x1)))
2398 )
2399
2400 (define-pmacro (nbit icc)
2401   (trunc BI (srl (and icc #x8) 3))
2402 )
2403
2404 (define-pmacro (zbit icc)
2405   (trunc BI (srl (and icc #x4) 2))
2406 )
2407
2408 (define-pmacro (vbit icc)
2409   (trunc BI (srl (and icc #x2) 1))
2410 )
2411
2412 (define-pmacro (cbit icc)
2413   (trunc BI (and icc #x1))
2414 )
2415
2416 (define-pmacro (ebit icc)
2417   (trunc BI (srl (and icc #x8) 3))
2418 )
2419
2420 (define-pmacro (lbit icc)
2421   (trunc BI (srl (and icc #x4) 2))
2422 )
2423
2424 (define-pmacro (gbit icc)
2425   (trunc BI (srl (and icc #x2) 1))
2426 )
2427
2428 (define-pmacro (ubit icc)
2429   (trunc BI (and icc #x1))
2430 )
2431
2432 ; FRV specific insn attributes:
2433 ;
2434
2435 ; Format: INT, Logic, Shift r-r
2436 ;
2437 (define-pmacro (int-logic-r-r name operation op ope comment)
2438   (dni name
2439        (comment)
2440        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2441        (.str name "$pack $GRi,$GRj,$GRk")
2442        (+ pack GRk op GRi (ICCi_1-null) ope GRj)
2443        (set GRk (operation GRi GRj))
2444        ((fr400 (unit u-integer))
2445         (fr500 (unit u-integer)))
2446   )
2447 )
2448
2449 (int-logic-r-r add  add   OP_00 OPE2_00 "add reg/reg")
2450 (int-logic-r-r sub  sub   OP_00 OPE2_04 "sub reg/reg")
2451 (int-logic-r-r and  and   OP_01 OPE2_00 "and reg/reg")
2452 (int-logic-r-r or   or    OP_01 OPE2_02 "or  reg/reg")
2453 (int-logic-r-r xor  xor   OP_01 OPE2_04 "xor reg/reg")
2454
2455 (dni not
2456      ("not")
2457      ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2458      ("not$pack $GRj,$GRk")
2459      (+ pack GRk OP_01 (rs-null) (ICCi_1-null) OPE2_06 GRj)
2460      (set GRk (inv GRj))
2461      ((fr400 (unit u-integer))
2462       (fr500 (unit u-integer)))
2463 )
2464
2465 (dni sdiv
2466      "signed division"
2467      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2468      "sdiv$pack $GRi,$GRj,$GRk"
2469      (+ pack GRk OP_00 GRi (ICCi_1-null) OPE2_0E GRj)
2470      (sequence ()
2471                (c-call VOID "@cpu@_signed_integer_divide"
2472                        GRi GRj (index-of GRk) 0)
2473                (clobber GRk))
2474      ((fr400 (unit u-idiv))
2475       (fr500 (unit u-idiv)))
2476 )
2477
2478 (dni nsdiv
2479      "non excepting signed division"
2480      ((UNIT MULT-DIV) (FR500-MAJOR I-1) NON-EXCEPTING
2481       (MACH simple,tomcat,fr500,frv))
2482      "nsdiv$pack $GRi,$GRj,$GRk"
2483      (+ pack GRk OP_01 GRi (ICCi_1-null) OPE2_0E GRj)
2484      (sequence ()
2485                (c-call VOID "@cpu@_signed_integer_divide"
2486                        GRi GRj (index-of GRk) 1)
2487                (clobber GRk))
2488      ((fr400 (unit u-idiv))
2489       (fr500 (unit u-idiv)))
2490 )
2491
2492 (dni udiv
2493      "unsigned division reg/reg"
2494      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2495      "udiv$pack $GRi,$GRj,$GRk"
2496      (+ pack GRk OP_00 GRi (ICCi_1-null) OPE2_0F GRj)
2497      (sequence ()
2498                (c-call VOID "@cpu@_unsigned_integer_divide"
2499                        GRi GRj (index-of GRk) 0)
2500                (clobber GRk))
2501      ((fr400 (unit u-idiv))
2502       (fr500 (unit u-idiv)))
2503 )
2504
2505 (dni nudiv
2506      "non excepting unsigned division"
2507      ((UNIT MULT-DIV) (FR500-MAJOR I-1) NON-EXCEPTING
2508       (MACH simple,tomcat,fr500,frv))
2509      "nudiv$pack $GRi,$GRj,$GRk"
2510      (+ pack GRk OP_01 GRi (ICCi_1-null) OPE2_0F GRj)
2511      (sequence ()
2512                (c-call VOID "@cpu@_unsigned_integer_divide"
2513                        GRi GRj (index-of GRk) 1)
2514                (clobber GRk))
2515      ((fr400 (unit u-idiv))
2516       (fr500 (unit u-idiv)))
2517 )
2518
2519 ; Multiplication
2520 ;
2521 (define-pmacro (multiply-r-r name signop op ope comment)
2522   (dni name
2523        (comment)
2524        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2525        (.str name "$pack $GRi,$GRj,$GRdoublek")
2526        (+ pack GRdoublek op GRi (ICCi_1-null) ope GRj) 
2527        (set GRdoublek (mul DI (signop DI GRi) (signop DI GRj)))
2528        ((fr400 (unit u-imul))
2529         (fr500 (unit u-imul)))
2530   )
2531 )
2532
2533 (multiply-r-r smul ext  OP_00 OPE2_08 "signed   multiply reg/reg")
2534 (multiply-r-r umul zext OP_00 OPE2_0A "unsigned multiply reg/reg")
2535
2536 (define-pmacro (int-shift-r-r name op ope comment)
2537   (dni name
2538        (comment)
2539        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2540        (.str name "$pack $GRi,$GRj,$GRk")
2541        (+ pack GRk op GRi (ICCi_1-null) ope GRj)
2542        (set GRk (name GRi (and GRj #x1f)))
2543        ((fr400 (unit u-integer))
2544         (fr500 (unit u-integer)))
2545   )
2546 )
2547
2548 (int-shift-r-r sll OP_01 OPE2_08 "shift left  logical reg/reg")
2549 (int-shift-r-r srl OP_01 OPE2_0A "shift right logical reg/reg")
2550 (int-shift-r-r sra OP_01 OPE2_0C "shift right arith   reg/reg")
2551
2552 (define-pmacro (scan-semantics arg1 arg2 targ)
2553   (sequence ((WI tmp1) (WI tmp2))
2554             (set tmp1 arg1)
2555             (set tmp2 (sra arg2 1))
2556             (set targ (c-call WI "@cpu@_scan_result" (xor tmp1 tmp2))))
2557 )
2558
2559 (dni scan
2560      "scan"
2561      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2562      "scan$pack $GRi,$GRj,$GRk"
2563      (+ pack GRk OP_0B GRi (ICCi_1-null) OPE2_00 GRj)
2564      (scan-semantics GRi GRj GRk)
2565      ((fr400 (unit u-integer))
2566       (fr500 (unit u-integer)))
2567 )
2568
2569 ; Format: conditional INT, Logic, Shift r-r
2570 ;
2571 (define-pmacro (conditional-int-logic name operation op ope comment)
2572   (dni name
2573        (comment)
2574        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2575        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
2576        (+ pack GRk op GRi CCi cond ope GRj)
2577        (if (eq CCi (or cond 2))
2578            (set GRk (operation GRi GRj)))
2579        ((fr400 (unit u-integer))
2580         (fr500 (unit u-integer)))
2581   )
2582 )
2583
2584 (conditional-int-logic cadd  add  OP_58 OPE4_0 "conditional add")
2585 (conditional-int-logic csub  sub  OP_58 OPE4_1 "conditional sub")
2586 (conditional-int-logic cand  and  OP_5A OPE4_0 "conditional and")
2587 (conditional-int-logic cor   or   OP_5A OPE4_1 "conditional or")
2588 (conditional-int-logic cxor  xor  OP_5A OPE4_2 "conditional xor")
2589
2590 (dni cnot
2591      "conditional not"
2592      ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2593      "cnot$pack $GRj,$GRk,$CCi,$cond"
2594      (+ pack GRk OP_5A (rs-null) CCi cond OPE4_3 GRj)
2595      (if (eq CCi (or cond 2))
2596          (set GRk (inv GRj)))
2597      ((fr400 (unit u-integer))
2598       (fr500 (unit u-integer)))
2599 )
2600
2601 (dni csmul
2602      "conditional signed multiply"
2603      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2604      "csmul$pack $GRi,$GRj,$GRdoublek,$CCi,$cond"
2605      (+ pack GRdoublek OP_58 GRi CCi cond OPE4_2 GRj)
2606      (if (eq CCi (or cond 2))
2607          (set GRdoublek (mul DI (ext DI GRi) (ext DI GRj))))
2608      ((fr400 (unit u-imul))
2609       (fr500 (unit u-imul)))
2610 )
2611
2612 (dni csdiv
2613      "conditional signed division"
2614      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2615      "csdiv$pack $GRi,$GRj,$GRk,$CCi,$cond"
2616      (+ pack GRk OP_58 GRi CCi cond OPE4_3 GRj)
2617      (if (eq CCi (or cond 2))
2618          (sequence ()
2619                    (c-call VOID "@cpu@_signed_integer_divide"
2620                            GRi GRj (index-of GRk) 0)
2621                    (clobber GRk)))
2622      ((fr400 (unit u-idiv))
2623       (fr500 (unit u-idiv)))
2624 )
2625
2626 (dni cudiv
2627      "conditional unsigned division"
2628      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2629      "cudiv$pack $GRi,$GRj,$GRk,$CCi,$cond"
2630      (+ pack GRk OP_59 GRi CCi cond OPE4_3 GRj)
2631      (if (eq CCi (or cond 2))
2632          (sequence ()
2633                    (c-call VOID "@cpu@_unsigned_integer_divide"
2634                            GRi GRj (index-of GRk) 0)
2635                    (clobber GRk)))
2636      ((fr400 (unit u-idiv))
2637       (fr500 (unit u-idiv)))
2638 )
2639
2640 (define-pmacro (conditional-shift name operation op ope comment)
2641   (dni name
2642        (comment)
2643        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2644        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
2645        (+ pack GRk op GRi CCi cond ope GRj)
2646        (if (eq CCi (or cond 2))
2647            (set GRk (operation GRi (and GRj #x1f))))
2648        ((fr400 (unit u-integer))
2649         (fr500 (unit u-integer)))
2650   )
2651 )
2652
2653 (conditional-shift csll sll OP_5C OPE4_0 "conditional shift left  logical")
2654 (conditional-shift csrl srl OP_5C OPE4_1 "conditional shift right logical")
2655 (conditional-shift csra sra OP_5C OPE4_2 "conditional shift right arith")
2656
2657 (dni cscan
2658      "conditional scan"
2659      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2660      "cscan$pack $GRi,$GRj,$GRk,$CCi,$cond"
2661      (+ pack GRk OP_65 GRi CCi cond OPE4_3 GRj)
2662      (if (eq CCi (or cond 2))
2663          (scan-semantics GRi GRj GRk))
2664      ((fr400 (unit u-integer))
2665       (fr500 (unit u-integer)))
2666 )
2667
2668 ; Format: INT, Logic, Shift, cc r-r
2669 ;
2670 (define-pmacro (int-arith-cc-semantics operation icc)
2671   (sequence ((BI tmp) (QI cc) (SI result))
2672             (set cc icc)
2673             (set tmp ((.sym operation -oflag) GRi GRj (const 0)))
2674             (set-v cc tmp)
2675             (set tmp ((.sym operation -cflag) GRi GRj (const 0)))
2676             (set-c cc tmp)
2677             (set result (operation GRi GRj))
2678             (set-z-and-n cc result)
2679             (set GRk result)
2680             (set icc cc))
2681 )
2682
2683 (define-pmacro (int-arith-cc-r-r name operation op ope comment)
2684   (dni name
2685        (comment)
2686        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2687        (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
2688        (+ pack GRk op GRi ICCi_1 ope GRj)
2689        (int-arith-cc-semantics operation ICCi_1)
2690        ((fr400 (unit u-integer))
2691         (fr500 (unit u-integer)))
2692   )
2693 )
2694
2695 (int-arith-cc-r-r addcc add OP_00 OPE2_01 "add reg/reg, set icc")
2696 (int-arith-cc-r-r subcc sub OP_00 OPE2_05 "sub reg/reg, set icc")
2697
2698 (define-pmacro (int-logic-cc-semantics op icc)
2699   (sequence ((SI tmp))
2700             (set tmp (op GRi GRj))
2701             (set GRk tmp)
2702             (set-z-and-n icc tmp))
2703 )
2704
2705 (define-pmacro (int-logic-cc-r-r name op ope comment)
2706   (dni (.sym name cc)
2707        (comment)
2708        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2709        (.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
2710        (+ pack GRk op GRi ICCi_1 ope GRj)
2711        (int-logic-cc-semantics name ICCi_1)
2712        ((fr400 (unit u-integer))
2713         (fr500 (unit u-integer)))
2714   )
2715 )
2716
2717 (int-logic-cc-r-r and OP_01 OPE2_01 "and reg/reg, set icc")
2718 (int-logic-cc-r-r or  OP_01 OPE2_03 "or  reg/reg, set icc")
2719 (int-logic-cc-r-r xor OP_01 OPE2_05 "xor reg/reg, set icc")
2720
2721 (define-pmacro (int-shift-cc-semantics op l-r icc)
2722   (sequence ((WI shift) (SI tmp) (QI cc))
2723             (set shift (and GRj #x1f))
2724             (set cc (c-call QI (.str "@cpu@_set_icc_for_shift_" l-r)
2725                             GRi shift icc))
2726             (set tmp (op GRi shift))
2727             (set GRk tmp)
2728             (set-z-and-n cc tmp)
2729             (set icc cc))
2730 )
2731
2732 (define-pmacro (int-shift-cc-r-r name l-r op ope comment)
2733   (dni (.sym name cc)
2734        (comment)
2735        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2736        (.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
2737        (+ pack GRk op GRi ICCi_1 ope GRj)
2738        (int-shift-cc-semantics name l-r ICCi_1)
2739        ((fr400 (unit u-integer))
2740         (fr500 (unit u-integer)))
2741   )
2742 )
2743
2744 (int-shift-cc-r-r sll left  OP_01 OPE2_09 "shift left  logical reg/reg,set icc")
2745 (int-shift-cc-r-r srl right OP_01 OPE2_0B "shift right logical reg/reg,set icc")
2746 (int-shift-cc-r-r sra right OP_01 OPE2_0D "shift right arith   reg/reg,set icc")
2747
2748 (define-pmacro (multiply-cc-semantics signop arg1 arg2 targ icc)
2749   (sequence ((DI tmp) (QI cc))
2750             (set cc icc)
2751             (set tmp (mul DI (signop DI arg1) (signop DI arg2)))
2752             (set-n cc (srl DI tmp 63))
2753             (set-z cc (eq tmp 0))
2754             (set targ tmp)
2755             (set icc cc))
2756 )
2757
2758 (define-pmacro (multiply-cc-r-r name signop op ope comment)
2759   (dni name
2760        (comment)
2761        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2762        (.str name "$pack $GRi,$GRj,$GRdoublek,$ICCi_1")
2763        (+ pack GRdoublek op GRi ICCi_1 ope GRj)
2764        (multiply-cc-semantics signop GRi GRj GRdoublek ICCi_1)
2765        ((fr400 (unit u-imul))
2766         (fr500 (unit u-imul)))
2767   )
2768 )
2769
2770 (multiply-cc-r-r smulcc ext  OP_00 OPE2_09 "signed   multiply reg/reg")
2771 (multiply-cc-r-r umulcc zext OP_00 OPE2_0B "unsigned multiply reg/reg")
2772
2773
2774 ; Format: conditional INT, Logic, Shift, cc r-r
2775 ;
2776 (define-pmacro (conditional-int-arith-cc name operation op ope comment)
2777   (dni name
2778        (comment)
2779        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2780        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
2781        (+ pack GRk op GRi CCi cond ope GRj)
2782        (if (eq CCi (or cond 2))
2783            (int-arith-cc-semantics operation
2784                                    (reg h-iccr (and (index-of CCi) 3))))
2785        ((fr400 (unit u-integer))
2786         (fr500 (unit u-integer)))
2787   )
2788 )
2789
2790 (conditional-int-arith-cc caddcc add OP_59 OPE4_0 "add, set icc")
2791 (conditional-int-arith-cc csubcc sub OP_59 OPE4_1 "sub, set icc")
2792
2793 (dni csmulcc
2794      "conditional signed multiply and set condition code"
2795      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2796      "csmulcc$pack $GRi,$GRj,$GRdoublek,$CCi,$cond"
2797      (+ pack GRdoublek OP_59 GRi CCi cond OPE4_2 GRj)
2798      (if (eq CCi (or cond 2))
2799          (multiply-cc-semantics ext GRi GRj GRdoublek
2800                                 (reg h-iccr (and (index-of CCi) 3))))
2801      ((fr400 (unit u-imul))
2802       (fr500 (unit u-imul)))
2803 )
2804
2805 (define-pmacro (conditional-int-logic-cc name operation op ope comment)
2806   (dni name
2807        (comment)
2808        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2809        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
2810        (+ pack GRk op GRi CCi cond ope GRj)
2811        (if (eq CCi (or cond 2))
2812            (int-logic-cc-semantics operation
2813                                    (reg h-iccr (and (index-of CCi) 3))))
2814        ((fr400 (unit u-integer))
2815         (fr500 (unit u-integer)))
2816   )
2817 )
2818
2819 (conditional-int-logic-cc candcc and OP_5B OPE4_0 "conditional and, set icc")
2820 (conditional-int-logic-cc corcc  or  OP_5B OPE4_1 "conditional or , set icc")
2821 (conditional-int-logic-cc cxorcc xor OP_5B OPE4_2 "conditional xor, set icc")
2822
2823 (define-pmacro (conditional-int-shift-cc name l-r op ope comment)
2824   (dni (.sym c name cc)
2825        (comment)
2826        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
2827        (.str (.sym c name cc) "$pack $GRi,$GRj,$GRk,$CCi,$cond")
2828        (+ pack GRk op GRi CCi cond ope GRj)
2829        (if (eq CCi (or cond 2))
2830            (int-shift-cc-semantics name l-r
2831                                    (reg h-iccr (and (index-of CCi) 3))))
2832        ((fr400 (unit u-integer))
2833         (fr500 (unit u-integer)))
2834   )
2835 )
2836
2837 (conditional-int-shift-cc sll left  OP_5D OPE4_0 "shift left  logical, set icc")
2838 (conditional-int-shift-cc srl right OP_5D OPE4_1 "shift right logical, set icc")
2839 (conditional-int-shift-cc sra right OP_5D OPE4_2 "shift right arith  , set icc")
2840
2841 ; Add and subtract with carry
2842 ;
2843 (define-pmacro (int-arith-x-r-r name operation op ope comment)
2844   (dni name
2845        (comment)
2846        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2847        (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
2848        (+ pack GRk op GRi ICCi_1 ope GRj)
2849        (set GRk ((.sym operation c) GRi GRj (cbit ICCi_1)))
2850        ((fr400 (unit u-integer))
2851         (fr500 (unit u-integer)))
2852   )
2853 )
2854
2855 (int-arith-x-r-r addx add OP_00 OPE2_02 "Add reg/reg, with carry")
2856 (int-arith-x-r-r subx sub OP_00 OPE2_06 "Sub reg/reg, with carry")
2857
2858 (define-pmacro (int-arith-x-cc-r-r name operation op ope comment)
2859   (dni name
2860        (comment)
2861        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2862        (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
2863        (+ pack GRk op GRi ICCi_1 ope GRj)
2864        (sequence ((WI tmp) (QI cc))
2865                  (set cc ICCi_1)
2866                  (set tmp ((.sym operation c) GRi GRj (cbit cc)))
2867                  (set-v cc ((.sym operation -oflag) GRi GRj (cbit cc)))
2868                  (set-c cc ((.sym operation -cflag) GRi GRj (cbit cc)))
2869                  (set-z-and-n cc tmp)
2870                  (set GRk tmp)
2871                  (set ICCi_1 cc))
2872        ((fr400 (unit u-integer))
2873         (fr500 (unit u-integer)))
2874   )
2875 )
2876
2877 (int-arith-x-cc-r-r addxcc add OP_00 OPE2_03 "Add reg/reg, use/set carry")
2878 (int-arith-x-cc-r-r subxcc sub OP_00 OPE2_07 "Sub reg/reg, use/set carry")
2879
2880 ; Format: INT, Logic, Shift r-simm
2881 ;
2882 (define-pmacro (int-logic-r-simm name operation op comment)
2883   (dni name
2884        (comment)
2885        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2886        (.str name "$pack $GRi,$s12,$GRk")
2887        (+ pack GRk op GRi s12)
2888        (set GRk (operation GRi s12))
2889        ((fr400 (unit u-integer))
2890         (fr500 (unit u-integer)))
2891   )
2892 )
2893
2894 (int-logic-r-simm addi  add   OP_10 "add reg/immed")
2895 (int-logic-r-simm subi  sub   OP_14 "sub reg/immed")
2896 (int-logic-r-simm andi  and   OP_20 "and reg/immed")
2897 (int-logic-r-simm ori   or    OP_22 "or  reg/immed")
2898 (int-logic-r-simm xori  xor   OP_24 "xor reg/immed")
2899
2900 (dni sdivi
2901      "signed division reg/immed"
2902      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2903      "sdivi$pack $GRi,$s12,$GRk"
2904      (+ pack GRk OP_1E GRi s12)
2905      (sequence ()
2906                (c-call VOID "@cpu@_signed_integer_divide"
2907                        GRi s12 (index-of GRk) 0)
2908                (clobber GRk))
2909      ((fr400 (unit u-idiv))
2910       (fr500 (unit u-idiv)))
2911 )
2912
2913 (dni nsdivi
2914      "non excepting signed division reg/immed"
2915      ((UNIT MULT-DIV) (FR500-MAJOR I-1) NON-EXCEPTING
2916       (MACH simple,tomcat,fr500,frv))
2917      "nsdivi$pack $GRi,$s12,$GRk"
2918      (+ pack GRk OP_2E GRi s12)
2919      (sequence ()
2920                (c-call VOID "@cpu@_signed_integer_divide"
2921                        GRi s12 (index-of GRk) 1)
2922                (clobber GRk))
2923      ((fr400 (unit u-idiv))
2924       (fr500 (unit u-idiv)))
2925 )
2926
2927 (dni udivi
2928      "unsigned division reg/immed"
2929      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2930      "udivi$pack $GRi,$s12,$GRk"
2931      (+ pack GRk OP_1F GRi s12)
2932      (sequence ()
2933                (c-call VOID "@cpu@_unsigned_integer_divide"
2934                        GRi s12 (index-of GRk) 0)
2935                (clobber GRk))
2936      ((fr400 (unit u-idiv))
2937       (fr500 (unit u-idiv)))
2938 )
2939
2940 (dni nudivi
2941      "non excepting unsigned division reg/immed"
2942      ((UNIT MULT-DIV) (FR500-MAJOR I-1) NON-EXCEPTING
2943       (MACH simple,tomcat,fr500,frv))
2944      "nudivi$pack $GRi,$s12,$GRk"
2945      (+ pack GRk OP_2F GRi s12)
2946      (sequence ()
2947                (c-call VOID "@cpu@_unsigned_integer_divide"
2948                        GRi s12 (index-of GRk) 1)
2949                (clobber GRk))
2950      ((fr400 (unit u-idiv))
2951       (fr500 (unit u-idiv)))
2952 )
2953
2954 (define-pmacro (multiply-r-simm name signop op comment)
2955   (dni name
2956        (comment)
2957        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2958        (.str name "$pack $GRi,$s12,$GRdoublek")
2959        (+ pack GRdoublek op GRi s12)
2960        (set GRdoublek (mul DI (signop DI GRi) (signop DI s12)))
2961        ((fr400 (unit u-imul))
2962         (fr500 (unit u-imul)))
2963   )
2964 )
2965
2966 (multiply-r-simm smuli ext  OP_18 "signed   multiply reg/immed")
2967 (multiply-r-simm umuli zext OP_1A "unsigned multiply reg/immed")
2968
2969 (define-pmacro (int-shift-r-simm name op comment)
2970   (dni (.sym name i)
2971        (comment)
2972        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2973        (.str (.sym name i) "$pack $GRi,$s12,$GRk")
2974        (+ pack GRk op GRi s12)
2975        (set GRk (name GRi (and s12 #x1f)))
2976        ((fr400 (unit u-integer))
2977         (fr500 (unit u-integer)))
2978   )
2979 )
2980
2981 (int-shift-r-simm sll OP_28 "shift left  logical reg/immed")
2982 (int-shift-r-simm srl OP_2A "shift right logical reg/immed")
2983 (int-shift-r-simm sra OP_2C "shift right arith   reg/immed")
2984
2985 (dni scani
2986      "scan immediate"
2987      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
2988      "scani$pack $GRi,$s12,$GRk"
2989      (+ pack GRk OP_47 GRi s12)
2990      (scan-semantics GRi s12 GRk)
2991      ((fr400 (unit u-integer))
2992       (fr500 (unit u-integer)))
2993 )
2994
2995 ; Format: INT, Logic, Shift cc r-simm
2996 ;
2997 (define-pmacro (int-arith-cc-r-simm name operation op comment)
2998   (dni name
2999        (comment)
3000        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3001        (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
3002        (+ pack GRk op GRi ICCi_1 s10)
3003        (sequence ((BI tmp) (QI cc) (SI result))
3004                  (set cc ICCi_1)
3005                  (set tmp ((.sym operation -oflag) GRi s10 (const 0)))
3006                  (set-v cc tmp)
3007                  (set tmp ((.sym operation -cflag) GRi s10 (const 0)))
3008                  (set-c cc tmp)
3009                  (set result (operation GRi s10))
3010                  (set-z-and-n cc result)
3011                  (set GRk result)
3012                  (set ICCi_1 cc))
3013        ((fr400 (unit u-integer))
3014         (fr500 (unit u-integer)))
3015   )
3016 )
3017
3018 (int-arith-cc-r-simm addicc add OP_11 "add reg/immed, set icc")
3019 (int-arith-cc-r-simm subicc sub OP_15 "sub reg/immed, set icc")
3020
3021 (define-pmacro (int-logic-cc-r-simm name op comment)
3022   (dni (.sym name icc)
3023        (comment)
3024        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3025        (.str (.sym name icc) "$pack $GRi,$s10,$GRk,$ICCi_1")
3026        (+ pack GRk op GRi ICCi_1 s10)
3027        (sequence ((SI tmp))
3028                  (set tmp (name GRi s10))
3029                  (set GRk tmp)
3030                  (set-z-and-n ICCi_1 tmp))
3031        ((fr400 (unit u-integer))
3032         (fr500 (unit u-integer)))
3033   )
3034 )
3035
3036 (int-logic-cc-r-simm and  OP_21 "and reg/immed, set icc")
3037 (int-logic-cc-r-simm or   OP_23 "or  reg/immed, set icc")
3038 (int-logic-cc-r-simm xor  OP_25 "xor reg/immed, set icc")
3039
3040 (define-pmacro (multiply-cc-r-simm name signop op comment)
3041   (dni name
3042        (comment)
3043        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3044        (.str name "$pack $GRi,$s10,$GRdoublek,$ICCi_1")
3045        (+ pack GRdoublek op GRi ICCi_1 s10)
3046        (multiply-cc-semantics signop GRi s10 GRdoublek ICCi_1)
3047        ((fr400 (unit u-imul))
3048         (fr500 (unit u-imul)))
3049   )
3050 )
3051
3052 (multiply-cc-r-simm smulicc ext  OP_19 "signed   multiply reg/immed")
3053 (multiply-cc-r-simm umulicc zext OP_1B "unsigned multiply reg/immed")
3054
3055 (define-pmacro (int-shift-cc-r-simm name l-r op comment)
3056   (dni (.sym name icc)
3057        (comment)
3058        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3059        (.str (.sym name icc) "$pack $GRi,$s10,$GRk,$ICCi_1")
3060        (+ pack GRk op GRi ICCi_1 s10)
3061        (sequence ((WI shift) (SI tmp) (QI cc))
3062                  (set shift (and s10 #x1f))
3063                  (set cc (c-call QI (.str "@cpu@_set_icc_for_shift_" l-r)
3064                                  GRi shift ICCi_1))
3065                  (set tmp (name GRi shift))
3066                  (set GRk tmp)
3067                  (set-z-and-n cc tmp)
3068                  (set ICCi_1 cc))
3069        ((fr400 (unit u-integer))
3070         (fr500 (unit u-integer)))
3071   )
3072 )
3073
3074 (int-shift-cc-r-simm sll left  OP_29 "shift left  logical reg/immed, set icc")
3075 (int-shift-cc-r-simm srl right OP_2B "shift right logical reg/immed, set icc")
3076 (int-shift-cc-r-simm sra right OP_2D "shift right arith   reg/immed, set icc")
3077
3078 (define-pmacro (int-arith-x-r-simm name operation op comment)
3079   (dni name
3080        (comment)
3081        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3082        (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
3083        (+ pack GRk op GRi ICCi_1 s10)
3084        (set GRk ((.sym operation c) GRi s10 (cbit ICCi_1)))
3085        ((fr400 (unit u-integer))
3086         (fr500 (unit u-integer)))
3087   )
3088 )
3089
3090 (int-arith-x-r-simm addxi add OP_12 "Add reg/immed, with carry")
3091 (int-arith-x-r-simm subxi sub OP_16 "Sub reg/immed, with carry")
3092
3093 (define-pmacro (int-arith-x-cc-r-simm name operation op comment)
3094   (dni name
3095        (comment)
3096        ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3097        (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
3098        (+ pack GRk op GRi ICCi_1 s10)
3099        (sequence ((WI tmp) (QI cc))
3100                  (set cc ICCi_1)
3101                  (set tmp ((.sym operation c) GRi s10 (cbit cc)))
3102                  (set-v cc ((.sym operation -oflag) GRi s10 (cbit cc)))
3103                  (set-c cc ((.sym operation -cflag) GRi s10 (cbit cc)))
3104                  (set-z-and-n cc tmp)
3105                  (set GRk tmp)
3106                  (set ICCi_1 cc))
3107        ((fr400 (unit u-integer))
3108         (fr500 (unit u-integer)))
3109   )
3110 )
3111
3112 (int-arith-x-cc-r-simm addxicc add OP_13 "Add reg/immed, with carry")
3113 (int-arith-x-cc-r-simm subxicc sub OP_17 "Sub reg/immed, with carry")
3114
3115 ; Byte compare insns
3116
3117 (dni cmpb
3118      "Compare bytes"
3119      ((UNIT I01) (FR400-MAJOR I-1) (MACH fr400))
3120      "cmpb$pack $GRi,$GRj,$ICCi_1"
3121      (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0C GRj)
3122      (sequence ((QI cc))
3123                (set-n cc (eq (and GRi #xff000000) (and GRj #xff000000)))
3124                (set-z cc (eq (and GRi #x00ff0000) (and GRj #x00ff0000)))
3125                (set-v cc (eq (and GRi #x0000ff00) (and GRj #x0000ff00)))
3126                (set-c cc (eq (and GRi #x000000ff) (and GRj #x000000ff)))
3127                (set ICCi_1 cc))
3128      ((fr400 (unit u-integer)))
3129 )
3130
3131 (dni cmpba
3132      "OR of Compare bytes"
3133      ((UNIT I01) (FR400-MAJOR I-1) (MACH fr400))
3134      "cmpba$pack $GRi,$GRj,$ICCi_1"
3135      (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0D GRj)
3136      (sequence ((QI cc))
3137                (set cc 0)
3138                (set-c cc
3139                       (orif (eq (and GRi #xff000000) (and GRj #xff000000))
3140                             (orif (eq (and GRi #x00ff0000) (and GRj #x00ff0000))
3141                                   (orif (eq (and GRi #x0000ff00)
3142                                             (and GRj #x0000ff00))
3143                                          (eq (and GRi #x000000ff)
3144                                             (and GRj #x000000ff))))))
3145                (set ICCi_1 cc))
3146      ((fr400 (unit u-integer)))
3147 )
3148
3149 ; Format: Load immediate
3150 ;
3151 (dni setlo
3152      "set low order bits"
3153      ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3154      "setlo$pack $ulo16,$GRklo"
3155      (+ pack GRk OP_3D (misc-null-4) u16)
3156      (set GRklo u16)
3157      ((fr400 (unit u-set-hilo))
3158       (fr500 (unit u-set-hilo)))
3159 )
3160
3161 (dni sethi
3162      "set high order bits"
3163      ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3164      "sethi$pack $uhi16,$GRkhi"
3165      (+ pack GRkhi OP_3E (misc-null-4) u16)
3166      (set GRkhi u16)
3167      ((fr400 (unit u-set-hilo))
3168       (fr500 (unit u-set-hilo)))
3169 )
3170
3171 (dni setlos
3172      "set low order bits and extend sign"
3173      ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
3174      "setlos$pack $slo16,$GRk"
3175      (+ pack GRk OP_3F (misc-null-4) s16)
3176      (set GRk s16)
3177      ((fr400 (unit u-integer))
3178       (fr500 (unit u-integer)))
3179 )
3180
3181 (define-pmacro (load-gr-r name mode op ope comment)
3182   (dni name
3183        (comment)
3184        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2))
3185        (.str name "$pack @($GRi,$GRj),$GRk")
3186        (+ pack GRk op GRi ope GRj)
3187        (set GRk (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
3188        ((fr400 (unit u-gr-load))
3189         (fr500 (unit u-gr-load)))
3190   )
3191 )
3192
3193 (load-gr-r ldsb   QI OP_02 OPE1_00 "Load   signed byte")
3194 (load-gr-r ldub  UQI OP_02 OPE1_01 "Load unsigned byte")
3195 (load-gr-r ldsh   HI OP_02 OPE1_02 "Load   signed half")
3196 (load-gr-r lduh  UHI OP_02 OPE1_03 "Load unsigned half")
3197 (load-gr-r ld     SI OP_02 OPE1_04 "Load          word")
3198
3199 (define-pmacro (load-fr-r name mode op ope comment)
3200   (dni name
3201        (comment)
3202        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) FR-ACCESS)
3203        (.str name "$pack @($GRi,$GRj),$FRintk")
3204        (+ pack FRintk op GRi ope GRj)
3205        (set FRintk (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
3206        ((fr400 (unit u-fr-load))
3207         (fr500 (unit u-fr-load)))
3208   )
3209 )
3210
3211 (load-fr-r ldbf UQI OP_02 OPE1_08 "Load byte   float")
3212 (load-fr-r ldhf UHI OP_02 OPE1_09 "Load half   float")
3213 (load-fr-r ldf   SI OP_02 OPE1_0A "Load word   float")
3214
3215 (define-pmacro (load-cpr-r name mode op ope reg attr comment)
3216   (dni name
3217        (comment)
3218        ((UNIT LOAD) (FR500-MAJOR I-2) attr)
3219        (.str name "$pack @($GRi,$GRj),$" reg "k")
3220        (+ pack (.sym reg k) op GRi ope GRj)
3221        (set (.sym reg k)
3222             (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
3223        ()
3224   )
3225 )
3226
3227 (load-cpr-r ldc SI OP_02 OPE1_0D CPR (MACH frv) "Load coprocessor word")
3228
3229 ; These correspond to enumerators in frv-sim.h
3230 (define-pmacro (ne-UQI-size) 0)
3231 (define-pmacro (ne-QI-size)  1)
3232 (define-pmacro (ne-UHI-size) 2)
3233 (define-pmacro (ne-HI-size)  3)
3234 (define-pmacro (ne-SI-size)  4)
3235 (define-pmacro (ne-DI-size)  5)
3236 (define-pmacro (ne-XI-size)  6)
3237
3238 (define-pmacro (ne-load-semantics base dispix targ idisp size is_float action)
3239   (sequence ((BI do_op))
3240             (set do_op
3241                  (c-call BI "@cpu@_check_non_excepting_load"
3242                           (index-of base) dispix (index-of targ)
3243                           idisp size is_float))
3244             (if do_op action))
3245 )
3246
3247 (define-pmacro (ne-load-gr-r name mode op ope size comment)
3248   (dni name
3249        (comment)
3250        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING
3251         (MACH simple,tomcat,fr500,frv))
3252        (.str name "$pack @($GRi,$GRj),$GRk")
3253        (+ pack GRk op GRi ope GRj)
3254        (ne-load-semantics GRi (index-of GRj) GRk 0 size 0
3255                           (set GRk
3256                                (c-call mode (.str "@cpu@_read_mem_" mode)
3257                                        pc (add GRi GRj))))
3258        ((fr500 (unit u-gr-load)))
3259   )
3260 )
3261
3262 (ne-load-gr-r nldsb  QI OP_02 OPE1_20 (ne-QI-size)  "Load   signed byte")
3263 (ne-load-gr-r nldub UQI OP_02 OPE1_21 (ne-UQI-size) "Load unsigned byte")
3264 (ne-load-gr-r nldsh  HI OP_02 OPE1_22 (ne-HI-size)  "Load   signed half")
3265 (ne-load-gr-r nlduh UHI OP_02 OPE1_23 (ne-UHI-size) "Load unsigned half")
3266 (ne-load-gr-r nld    SI OP_02 OPE1_24 (ne-SI-size)  "Load          word")
3267
3268 (define-pmacro (ne-load-fr-r name mode op ope size comment)
3269   (dni name
3270        (comment)
3271        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
3272         (MACH simple,tomcat,fr500,frv))
3273        (.str name "$pack @($GRi,$GRj),$FRintk")
3274        (+ pack FRintk op GRi ope GRj)
3275        (ne-load-semantics GRi (index-of GRj) FRintk 0 size 1
3276                           (set FRintk
3277                                (c-call mode (.str "@cpu@_read_mem_" mode)
3278                                        pc (add GRi GRj))))
3279        ((fr500 (unit u-fr-load)))
3280   )
3281 )
3282
3283 (ne-load-fr-r nldbf UQI OP_02 OPE1_28 (ne-UQI-size) "Load byte float")
3284 (ne-load-fr-r nldhf UHI OP_02 OPE1_29 (ne-UHI-size) "Load half float")
3285 (ne-load-fr-r nldf   SI OP_02 OPE1_2A (ne-SI-size)  "Load word float")
3286
3287 ; Semantics for a load-double insn
3288 ;
3289 (define-pmacro (load-double-semantics not_gr mode regtype address arg)
3290   (if (orif not_gr (ne (index-of (.sym regtype doublek)) 0))
3291       (sequence ()
3292                 (set address (add GRi arg))
3293                 (set (.sym regtype doublek)
3294                      (c-call mode (.str "@cpu@_read_mem_" mode) pc address))))
3295 )
3296
3297 (define-pmacro (load-double-r-r
3298                 name not_gr mode op ope regtype attr profile comment)
3299   (dni name
3300        (comment)
3301        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) attr)
3302        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
3303        (+ pack (.sym regtype doublek) op GRi ope GRj)
3304        (sequence ((WI address))
3305                  (load-double-semantics not_gr mode regtype address GRj))
3306        profile
3307   )
3308 )
3309
3310 (load-double-r-r ldd  0 DI OP_02 OPE1_05 GR  NA
3311                  ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3312                  "Load double word")
3313 (load-double-r-r lddf 1 DF OP_02 OPE1_0B FR  FR-ACCESS
3314                  ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
3315                  "Load double float")
3316 (load-double-r-r lddc 1 DI OP_02 OPE1_0E CPR (MACH frv) ()
3317                  "Load coprocessor double")
3318
3319 (define-pmacro (ne-load-double-r-r
3320                 name not_gr mode op ope regtype size is_float attr profile
3321                 comment)
3322   (dni name
3323        (comment)
3324        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING attr
3325         (MACH simple,tomcat,fr500,frv))
3326        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
3327        (+ pack (.sym regtype doublek) op GRi ope GRj)
3328        (sequence ((WI address))
3329                  (ne-load-semantics GRi (index-of GRj) (.sym regtype doublek)
3330                                     0 size is_float
3331                                     (load-double-semantics not_gr mode
3332                                                            regtype
3333                                                            address GRj)))
3334        profile
3335   )
3336 )
3337
3338 (ne-load-double-r-r nldd  0 DI OP_02 OPE1_25 GR (ne-DI-size) 0 NA
3339                     ((fr500 (unit u-gr-load))) "Load double   word")
3340 (ne-load-double-r-r nlddf 1 DF OP_02 OPE1_2B FR (ne-DI-size) 1 FR-ACCESS
3341                     ((fr500 (unit u-fr-load))) "Load double float")
3342
3343 ; Semantics for a load-quad insn
3344 ;
3345 (define-pmacro (load-quad-semantics regtype address arg)
3346   (sequence ()
3347             (set address (add GRi arg))
3348             (c-call VOID (.str "@cpu@_load_quad_" regtype)
3349                     pc address (index-of (.sym regtype k))))
3350 )
3351
3352 (define-pmacro (load-quad-r-r name op ope regtype attr profile comment)
3353   (dni name
3354        (comment)
3355        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
3356        (.str name "$pack @($GRi,$GRj),$" regtype "k")
3357        (+ pack (.sym regtype k) op GRi ope GRj)
3358        (sequence ((WI address))
3359                  (load-quad-semantics regtype address GRj))
3360        ; TODO regtype-k not referenced for profiling
3361        profile
3362   )
3363 )
3364
3365 (load-quad-r-r ldq  OP_02 OPE1_06 GR    NA        ((fr500 (unit u-gr-load)))
3366                "Load quad word")
3367 (load-quad-r-r ldqf OP_02 OPE1_0C FRint FR-ACCESS ((fr500 (unit u-fr-load)))
3368                "Load quad float")
3369 (load-quad-r-r ldqc OP_02 OPE1_0F CPR   NA        () "Load coprocessor quad")
3370
3371 (define-pmacro (ne-load-quad-r-r
3372                 name op ope regtype size is_float attr profile comment)
3373   (dni name
3374        (comment)
3375        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING attr)
3376        (.str name "$pack @($GRi,$GRj),$" regtype "k")
3377        (+ pack (.sym regtype k) op GRi ope GRj)
3378        (sequence ((WI address))
3379                  (ne-load-semantics GRi (index-of GRj) (.sym regtype k)
3380                                     0 size is_float
3381                                     (load-quad-semantics regtype address GRj)))
3382        ; TODO regtype-k not referenced for profiling
3383        profile
3384   )
3385 )
3386
3387 (ne-load-quad-r-r nldq  OP_02 OPE1_26 GR    (ne-XI-size) 0 NA
3388                   ((fr500 (unit u-gr-load))) "Load quad word")
3389 (ne-load-quad-r-r nldqf OP_02 OPE1_2C FRint (ne-XI-size) 1 FR-ACCESS
3390                   ((fr500 (unit u-fr-load))) "Load quad float")
3391
3392 (define-pmacro (load-gr-u-semantics mode)
3393   (sequence ((UWI address))
3394             (set address (add GRi GRj))
3395             (set GRk (c-call mode (.str "@cpu@_read_mem_" mode) pc address))
3396             (if (ne (index-of GRi) (index-of GRk))
3397                 (sequence ()
3398                           (set GRi address)
3399                           (c-call VOID "@cpu@_force_update"))))
3400 )
3401
3402 (define-pmacro (load-gr-u name mode op ope comment)
3403   (dni name
3404        (comment)
3405        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2))
3406        (.str name "$pack @($GRi,$GRj),$GRk")
3407        (+ pack GRk op GRi ope GRj)
3408        (load-gr-u-semantics mode)
3409        ((fr400 (unit u-gr-load))
3410         (fr500 (unit u-gr-load)))
3411   )
3412 )
3413
3414 (load-gr-u ldsbu   QI OP_02 OPE1_10 "Load   signed byte, update index")
3415 (load-gr-u ldubu  UQI OP_02 OPE1_11 "Load unsigned byte, update index")
3416 (load-gr-u ldshu   HI OP_02 OPE1_12 "Load   signed half, update index")
3417 (load-gr-u lduhu  UHI OP_02 OPE1_13 "Load unsigned half, update index")
3418 (load-gr-u ldu     SI OP_02 OPE1_14 "Load          word, update index")
3419
3420 (define-pmacro (ne-load-gr-u name mode op ope size comment)
3421   (dni name
3422        (comment)
3423        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING
3424         (MACH simple,tomcat,fr500,frv))
3425        (.str name "$pack @($GRi,$GRj),$GRk")
3426        (+ pack GRk op GRi ope GRj)
3427        (ne-load-semantics GRi (index-of GRj) GRk 0 size 0 (load-gr-u-semantics mode))
3428        ((fr500 (unit u-gr-load)))
3429   )
3430 )
3431
3432 (ne-load-gr-u nldsbu  QI OP_02 OPE1_30 (ne-QI-size)  "Load   signed byte, update index")
3433 (ne-load-gr-u nldubu UQI OP_02 OPE1_31 (ne-UQI-size) "Load unsigned byte, update index")
3434 (ne-load-gr-u nldshu  HI OP_02 OPE1_32 (ne-HI-size)  "Load   signed half, update index")
3435 (ne-load-gr-u nlduhu UHI OP_02 OPE1_33 (ne-UHI-size) "Load unsigned half, update index")
3436 (ne-load-gr-u nldu    SI OP_02 OPE1_34 (ne-SI-size)  "Load          word, update index")
3437
3438 (define-pmacro (load-non-gr-u-semantics mode regtype)
3439   (sequence ((UWI address))
3440             (set address (add GRi GRj))
3441             (set (.sym regtype k)
3442                  (c-call mode (.str "@cpu@_read_mem_" mode) pc address))
3443             (set GRi address)
3444             (c-call VOID "@cpu@_force_update"))
3445 )
3446
3447 (define-pmacro (load-fr-u name mode op ope comment)
3448   (dni name
3449        (comment)
3450        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) FR-ACCESS)
3451        (.str name "$pack @($GRi,$GRj),$FRintk")
3452        (+ pack FRintk op GRi ope GRj)
3453        (load-non-gr-u-semantics mode FRint)
3454        ((fr400 (unit u-fr-load))
3455         (fr500 (unit u-fr-load)))
3456   )
3457 )
3458
3459 (load-fr-u ldbfu  UQI OP_02 OPE1_18 "Load byte float, update index")
3460 (load-fr-u ldhfu  UHI OP_02 OPE1_19 "Load half float, update index")
3461 (load-fr-u ldfu    SI OP_02 OPE1_1A "Load word float, update index")
3462
3463 (define-pmacro (load-cpr-u name mode op ope comment)
3464   (dni name
3465        (comment)
3466        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
3467        (.str name "$pack @($GRi,$GRj),$CPRk")
3468        (+ pack CPRk op GRi ope GRj)
3469        (load-non-gr-u-semantics mode CPR)
3470        ()
3471   )
3472 )
3473
3474 (load-cpr-u ldcu SI OP_02 OPE1_1D "Load coprocessor word float,update index")
3475
3476 (define-pmacro (ne-load-non-gr-u name mode op ope regtype size comment)
3477   (dni name
3478        (comment)
3479        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
3480         (MACH simple,tomcat,fr500,frv))
3481        (.str name "$pack @($GRi,$GRj),$" regtype "k")
3482        (+ pack (.sym regtype k) op GRi ope GRj)
3483        (ne-load-semantics GRi (index-of GRj) (.sym regtype k) 0 size 1
3484                           (load-non-gr-u-semantics mode regtype))
3485        ((fr500 (unit u-fr-load)))
3486   )
3487 )
3488
3489 (ne-load-non-gr-u nldbfu UQI OP_02 OPE1_38 FRint (ne-UQI-size) "Load byte float, update index")
3490 (ne-load-non-gr-u nldhfu UHI OP_02 OPE1_39 FRint (ne-UHI-size) "Load half float, update index")
3491 (ne-load-non-gr-u nldfu   SI OP_02 OPE1_3A FRint (ne-SI-size)  "Load word float, update index")
3492
3493 (define-pmacro (load-double-gr-u-semantics)
3494   (sequence ((WI address))
3495             (load-double-semantics 0 DI GR address GRj)
3496             (if (ne (index-of GRi) (index-of GRdoublek))
3497                 (sequence ()
3498                           (set GRi address)
3499                           (c-call VOID "@cpu@_force_update"))))
3500 )
3501
3502 (define-pmacro (load-double-gr-u name op ope comment)
3503   (dni name
3504        (comment)
3505        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2))
3506        (.str name "$pack @($GRi,$GRj),$GRdoublek")
3507        (+ pack GRdoublek op GRi ope GRj)
3508        (load-double-gr-u-semantics)
3509        ((fr400 (unit u-gr-load))
3510         (fr500 (unit u-gr-load)))
3511   )
3512 )
3513
3514 (load-double-gr-u lddu  OP_02 OPE1_15 "Load double word, update index")
3515
3516 (define-pmacro (ne-load-double-gr-u name op ope size comment)
3517   (dni name
3518        (comment)
3519        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING
3520         (MACH simple,tomcat,fr500,frv))
3521        (.str name "$pack @($GRi,$GRj),$GRdoublek")
3522        (+ pack GRdoublek op GRi ope GRj)
3523        (ne-load-semantics GRi (index-of GRj) GRdoublek 0 size 0
3524                           (load-double-gr-u-semantics))
3525        ((fr500 (unit u-gr-load)))
3526
3527   )
3528 )
3529
3530 (ne-load-double-gr-u nlddu OP_02 OPE1_35 (ne-DI-size) "Load double word, update index")
3531
3532 (define-pmacro (load-double-non-gr-u-semantics mode regtype)
3533   (sequence ((WI address))
3534             (load-double-semantics 1 mode regtype address GRj)
3535             (set GRi address)
3536             (c-call VOID "@cpu@_force_update"))
3537 )
3538
3539 (define-pmacro (load-double-non-gr-u
3540                 name mode op ope regtype attr profile comment)
3541   (dni name
3542        (comment)
3543        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) attr)
3544        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
3545        (+ pack (.sym regtype doublek) op GRi ope GRj)
3546        (load-double-non-gr-u-semantics mode regtype)
3547        profile
3548   )
3549 )
3550
3551 (load-double-non-gr-u lddfu DF OP_02 OPE1_1B FR  FR-ACCESS
3552                       ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
3553                       "Load double float, update index")
3554 (load-double-non-gr-u lddcu DI OP_02 OPE1_1E CPR (MACH frv)
3555                       () "Load coprocessor double float, update index")
3556
3557 (define-pmacro (ne-load-double-non-gr-u name mode op ope regtype size comment)
3558   (dni name
3559        (comment)
3560        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
3561         (MACH simple,tomcat,fr500,frv))
3562        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
3563        (+ pack (.sym regtype doublek) op GRi ope GRj)
3564        (ne-load-semantics GRi (index-of GRj) (.sym regtype doublek) 0 size 1
3565                           (load-double-non-gr-u-semantics mode regtype))
3566        ((fr500 (unit u-fr-load)))
3567   )
3568 )
3569
3570 (ne-load-double-non-gr-u nlddfu DF OP_02 OPE1_3B FR (ne-DI-size) "Load double float, update index")
3571
3572 (define-pmacro (load-quad-gr-u-semantics)
3573   (sequence ((WI address))
3574             (load-quad-semantics GR address GRj)
3575             (if (ne (index-of GRi) (index-of GRk))
3576                 (sequence ()
3577                           (set GRi address)
3578                           (c-call VOID "@cpu@_force_update"))))
3579 )
3580
3581 (define-pmacro (load-quad-gr-u name op ope comment)
3582   (dni name
3583        (comment)
3584        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
3585        (.str name "$pack @($GRi,$GRj),$GRk")
3586        (+ pack GRk op GRi ope GRj)
3587        (load-quad-gr-u-semantics)
3588        ; TODO - GRk not referenced here for profiling
3589        ((fr500 (unit u-gr-load)))
3590   )
3591 )
3592
3593 (load-quad-gr-u ldqu  OP_02 OPE1_16 "Load quad word, update index")
3594
3595 (define-pmacro (ne-load-quad-gr-u name op ope size comment)
3596   (dni name
3597        (comment)
3598        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING)
3599        (.str name "$pack @($GRi,$GRj),$GRk")
3600        (+ pack GRk op GRi ope GRj)
3601        (ne-load-semantics GRi (index-of GRj) GRk 0 size 0
3602                           (load-quad-gr-u-semantics))
3603        ; TODO - GRk not referenced here for profiling
3604        ((fr500 (unit u-gr-load)))
3605   )
3606 )
3607
3608 (ne-load-quad-gr-u nldqu OP_02 OPE1_36 (ne-XI-size) "Load quad word, update index")
3609
3610 (define-pmacro (load-quad-non-gr-u-semantics regtype)
3611   (sequence ((WI address))
3612             (load-quad-semantics regtype address GRj)
3613             (set GRi address)
3614             (c-call VOID "@cpu@_force_update"))
3615 )
3616
3617 (define-pmacro (load-quad-non-gr-u name op ope regtype attr profile comment)
3618   (dni name
3619        (comment)
3620        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
3621        (.str name "$pack @($GRi,$GRj),$" regtype "k")
3622        (+ pack (.sym regtype k) op GRi ope GRj)
3623        (load-quad-non-gr-u-semantics regtype)
3624        profile
3625   )
3626 )
3627
3628 (load-quad-non-gr-u ldqfu OP_02 OPE1_1C FRint FR-ACCESS
3629                     ((fr500 (unit u-fr-load))) "Load quad float, update index")
3630 (load-quad-non-gr-u ldqcu OP_02 OPE1_1F CPR   NA
3631                     () "Load coprocessor quad word, update index")
3632
3633 (define-pmacro (ne-load-quad-non-gr-u name op ope regtype size comment)
3634   (dni name
3635        (comment)
3636        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING FR-ACCESS)
3637        (.str name "$pack @($GRi,$GRj),$" regtype "k")
3638        (+ pack (.sym regtype k) op GRi ope GRj)
3639        (ne-load-semantics GRi (index-of GRj) (.sym regtype k) 0 size 1
3640                           (load-quad-non-gr-u-semantics regtype))
3641        ((fr500 (unit u-fr-load)))
3642   )
3643 )
3644
3645 (ne-load-quad-non-gr-u nldqfu OP_02 OPE1_3C FRint (ne-XI-size) "Load quad float,update index")
3646
3647 (define-pmacro (load-r-simm name mode op regtype attr profile comment)
3648   (dni name
3649        (comment)
3650        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) attr)
3651        (.str name "$pack @($GRi,$d12),$" regtype "k")
3652        (+ pack (.sym regtype k) op GRi d12)
3653        (set (.sym regtype k)
3654             (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi d12)))
3655        profile
3656   )
3657 )
3658
3659 (load-r-simm ldsbi  QI OP_30 GR NA
3660              ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3661              "Load   signed byte")
3662 (load-r-simm ldshi  HI OP_31 GR NA
3663              ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3664              "Load   signed half")
3665 (load-r-simm ldi    SI OP_32 GR NA
3666              ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3667              "Load          word")
3668 (load-r-simm ldubi UQI OP_35 GR NA
3669              ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3670              "Load unsigned byte")
3671 (load-r-simm lduhi UHI OP_36 GR NA
3672              ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3673              "Load unsigned half")
3674
3675 (load-r-simm ldbfi UQI OP_38 FRint FR-ACCESS
3676              ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
3677              "Load byte float")
3678 (load-r-simm ldhfi UHI OP_39 FRint FR-ACCESS
3679              ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
3680              "Load half float")
3681 (load-r-simm ldfi   SI OP_3A FRint FR-ACCESS
3682              ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
3683              "Load word float")
3684
3685 (define-pmacro (ne-load-r-simm
3686                 name mode op regtype size is_float attr profile comment)
3687   (dni name
3688        (comment)
3689        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING attr
3690         (MACH simple,tomcat,fr500,frv))
3691        (.str name "$pack @($GRi,$d12),$" regtype "k")
3692        (+ pack (.sym regtype k) op GRi d12)
3693        (ne-load-semantics GRi -1 (.sym regtype k) d12 size is_float
3694                           (set (.sym regtype k)
3695                                (c-call mode (.str "@cpu@_read_mem_" mode)
3696                                        pc (add GRi d12))))
3697        profile
3698   )
3699 )
3700
3701 (ne-load-r-simm nldsbi  QI OP_40 GR (ne-QI-size)  0 NA
3702                 ((fr500 (unit u-gr-load))) "Load   signed byte")
3703 (ne-load-r-simm nldubi UQI OP_41 GR (ne-UQI-size) 0 NA
3704                 ((fr500 (unit u-gr-load))) "Load unsigned byte")
3705 (ne-load-r-simm nldshi  HI OP_42 GR (ne-HI-size)  0 NA
3706                 ((fr500 (unit u-gr-load))) "Load   signed half")
3707 (ne-load-r-simm nlduhi UHI OP_43 GR (ne-UHI-size) 0 NA
3708                 ((fr500 (unit u-gr-load))) "Load unsigned half")
3709 (ne-load-r-simm nldi    SI OP_44 GR (ne-SI-size)  0 NA
3710                 ((fr500 (unit u-gr-load))) "Load          word")
3711
3712 (ne-load-r-simm nldbfi UQI OP_48 FRint (ne-UQI-size) 1 FR-ACCESS
3713                 ((fr500 (unit u-fr-load))) "Load byte float")
3714 (ne-load-r-simm nldhfi UHI OP_49 FRint (ne-UHI-size) 1 FR-ACCESS
3715                 ((fr500 (unit u-fr-load))) "Load half float")
3716 (ne-load-r-simm nldfi   SI OP_4A FRint (ne-SI-size)  1 FR-ACCESS
3717                 ((fr500 (unit u-fr-load))) "Load word float")
3718
3719 (define-pmacro (load-double-r-simm
3720                 name not_gr mode op regtype attr profile comment)
3721   (dni name
3722        (comment)
3723        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) attr)
3724        (.str name "$pack @($GRi,$d12),$" regtype "doublek")
3725        (+ pack (.sym regtype doublek) op GRi d12)
3726        (sequence ((WI address))
3727                  (load-double-semantics not_gr mode regtype address d12))
3728        profile
3729   )
3730 )
3731
3732 (load-double-r-simm lddi  0 DI OP_33 GR NA
3733                     ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
3734                     "Load double word")
3735 (load-double-r-simm lddfi 1 DF OP_3B FR FR-ACCESS
3736                     ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
3737                     "Load double float")
3738
3739 (define-pmacro (ne-load-double-r-simm
3740                 name not_gr mode op regtype size is_float attr profile comment)
3741   (dni name
3742        (comment)
3743        ((UNIT LOAD) (FR500-MAJOR I-2) NON-EXCEPTING attr
3744         (MACH simple,tomcat,fr500,frv))
3745        (.str name "$pack @($GRi,$d12),$" regtype "doublek")
3746        (+ pack (.sym regtype doublek) op GRi d12)
3747        (sequence ((WI address))
3748                  (ne-load-semantics GRi -1 (.sym regtype doublek)
3749                                     d12 size is_float
3750                                     (load-double-semantics not_gr mode
3751                                                            regtype
3752                                                            address d12)))
3753        profile
3754   )
3755 )
3756
3757 (ne-load-double-r-simm nlddi  0 DI OP_45 GR (ne-DI-size) 0 NA
3758                        ((fr500 (unit u-gr-load))) "Load double word")
3759 (ne-load-double-r-simm nlddfi 1 DF OP_4B FR (ne-DI-size) 1 FR-ACCESS
3760                        ((fr500 (unit u-fr-load))) "Load double float")
3761
3762 (define-pmacro (load-quad-r-simm name op regtype attr profile comment)
3763   (dni name
3764        (comment)
3765        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
3766        (.str name "$pack @($GRi,$d12),$" regtype "k")
3767        (+ pack (.sym regtype k) op GRi d12)
3768        (sequence ((WI address))
3769                  (load-quad-semantics regtype address d12))
3770        profile
3771   )
3772 )
3773
3774 (load-quad-r-simm ldqi  OP_34 GR    NA
3775                   ((fr500 (unit u-gr-load))) "Load quad word")
3776 (load-quad-r-simm ldqfi OP_3C FRint FR-ACCESS
3777                   ((fr500 (unit u-fr-load))) "Load quad float")
3778
3779 (define-pmacro (ne-load-quad-r-simm
3780                 name op regtype size is_float attr profile comment)
3781   (dni name
3782        (comment)
3783        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING attr)
3784        (.str name "$pack @($GRi,$d12),$" regtype "k")
3785        (+ pack (.sym regtype k) op GRi d12)
3786        (sequence ((WI address))
3787                  (ne-load-semantics GRi -1 (.sym regtype k) d12 size is_float
3788                                     (load-quad-semantics regtype address d12)))
3789        profile
3790   )
3791 )
3792
3793 (ne-load-quad-r-simm nldqi  OP_46 GR    (ne-XI-size) 0 NA
3794                      ((fr500 (unit u-gr-load))) "Load quad word")
3795 (ne-load-quad-r-simm nldqfi OP_4C FRint (ne-XI-size) 1 FR-ACCESS
3796                      ((fr500 (unit u-fr-load))) "Load quad float")
3797
3798 (define-pmacro (store-r-r name mode op ope reg attr profile comment)
3799   (dni name
3800        (comment)
3801        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) attr)
3802        (.str name "$pack $" reg "k,@($GRi,$GRj)")
3803        (+ pack (.sym reg k) op GRi ope GRj)
3804        (c-call VOID (.str "@cpu@_write_mem_" mode)
3805                pc (add GRi GRj) (.sym reg k))
3806        profile
3807   )
3808 )
3809
3810 (store-r-r stb   QI OP_03 OPE1_00 GR NA
3811            ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3812            "Store unsigned byte")
3813 (store-r-r sth   HI OP_03 OPE1_01 GR NA
3814            ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3815            "Store unsigned half")
3816 (store-r-r st    SI OP_03 OPE1_02 GR NA
3817            ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3818            "Store          word")
3819
3820 (store-r-r stbf  QI OP_03 OPE1_08 FRint FR-ACCESS
3821            ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3822            "Store byte float")
3823 (store-r-r sthf  HI OP_03 OPE1_09 FRint FR-ACCESS
3824            ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3825            "Store half float")
3826 (store-r-r stf   SI OP_03 OPE1_0A FRint FR-ACCESS
3827            ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3828            "Store word float")
3829
3830 (store-r-r stc   SI OP_03 OPE1_25 CPR (MACH frv) () "Store coprocessor word")
3831
3832 (define-pmacro (r-store name mode op ope reg size is_float profile comment)
3833   (dni name
3834        (comment)
3835        ((UNIT I0) (FR500-MAJOR I-3) (MACH frv))
3836        (.str name "$pack $" reg "k,@($GRi,$GRj)")
3837        (+ pack (.sym reg k) op GRi ope GRj)
3838        (sequence ((WI address))
3839                  (set address (add GRi GRj))
3840                  (c-call VOID (.str "@cpu@_write_mem_" mode)
3841                          pc address (.sym reg k))
3842                  (c-call VOID "@cpu@_check_recovering_store"
3843                          address (index-of (.sym reg k)) size is_float))
3844        profile
3845   )
3846 )
3847
3848 (r-store rstb  QI OP_03 OPE1_20 GR 1 0
3849          ((fr500 (unit u-gr-r-store))) "Store unsigned byte")
3850 (r-store rsth  HI OP_03 OPE1_21 GR 2 0
3851          ((fr500 (unit u-gr-r-store))) "Store unsigned half")
3852 (r-store rst   SI OP_03 OPE1_22 GR 4 0
3853          ((fr500 (unit u-gr-r-store))) "Store          word")
3854
3855 (r-store rstbf QI OP_03 OPE1_28 FRint 1 1
3856          ((fr500 (unit u-fr-r-store))) "Store byte float")
3857 (r-store rsthf HI OP_03 OPE1_29 FRint 2 1
3858          ((fr500 (unit u-fr-r-store))) "Store half float")
3859 (r-store rstf  SI OP_03 OPE1_2A FRint 4 1
3860          ((fr500 (unit u-fr-r-store))) "Store word float")
3861
3862 ; Semantics for a store-double insn
3863 ;
3864 (define-pmacro (store-double-semantics mode regtype address arg)
3865   (sequence ()
3866             (set address (add GRi arg))
3867             (c-call VOID (.str "@cpu@_write_mem_" mode)
3868                     pc address (.sym regtype doublek)))
3869 )
3870
3871 (define-pmacro (store-double-r-r name mode op ope regtype attr profile comment)
3872   (dni name
3873        (comment)
3874        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) attr)
3875        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
3876        (+ pack (.sym regtype k) op GRi ope GRj)
3877        (sequence ((WI address))
3878                  (store-double-semantics mode regtype address GRj))
3879        profile
3880   )
3881 )
3882
3883 (store-double-r-r std  DI OP_03 OPE1_03 GR  NA
3884                   ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3885                   "Store double word")
3886 (store-double-r-r stdf DF OP_03 OPE1_0B FR  FR-ACCESS
3887                   ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3888                   "Store double float")
3889
3890 (store-double-r-r stdc DI OP_03 OPE1_26 CPR (MACH frv)
3891                   () "Store coprocessor double word")
3892
3893 (define-pmacro (r-store-double
3894                 name mode op ope regtype is_float attr profile comment)
3895   (dni name
3896        (comment)
3897        ((UNIT I0) (FR500-MAJOR I-3) (MACH frv) attr)
3898        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
3899        (+ pack (.sym regtype k) op GRi ope GRj)
3900        (sequence ((WI address))
3901                  (store-double-semantics mode regtype address GRj)
3902                  (c-call VOID "@cpu@_check_recovering_store"
3903                          address (index-of (.sym regtype k)) 8 is_float))
3904        profile
3905   )
3906 )
3907
3908 (r-store-double rstd  DI OP_03 OPE1_23 GR 0 NA
3909                 ((fr500 (unit u-gr-r-store))) "Store double word")
3910 (r-store-double rstdf DF OP_03 OPE1_2B FR 1 FR-ACCESS
3911                 ((fr500 (unit u-fr-r-store))) "Store double float")
3912
3913 ; Semantics for a store-quad insn
3914 ;
3915 (define-pmacro (store-quad-semantics regtype address arg)
3916   (sequence ()
3917             (set address (add GRi arg))
3918             (c-call VOID (.str "@cpu@_store_quad_" regtype)
3919                      pc address (index-of (.sym regtype k))))
3920 )
3921
3922 (define-pmacro (store-quad-r-r name op ope regtype attr profile comment)
3923   (dni name
3924        (comment)
3925        ((UNIT I0) (FR500-MAJOR I-3) (MACH frv) attr)
3926        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
3927        (+ pack (.sym regtype k) op GRi ope GRj)
3928        (sequence ((WI address))
3929                  (store-quad-semantics regtype address GRj))
3930        profile
3931   )
3932 )
3933
3934 (store-quad-r-r stq   OP_03 OPE1_04 GR    NA
3935                 ((fr500 (unit u-gr-store))) "Store quad word")
3936 (store-quad-r-r stqf  OP_03 OPE1_0C FRint FR-ACCESS
3937                 ((fr500 (unit u-fr-store)))
3938                 "Store quad float")
3939 (store-quad-r-r stqc  OP_03 OPE1_27 CPR   NA
3940                 () "Store coprocessor quad word")
3941
3942 (define-pmacro (r-store-quad name op ope regtype is_float attr profile comment)
3943   (dni name
3944        (comment)
3945        ((UNIT I0) (FR500-MAJOR I-3) (MACH frv) attr)
3946        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
3947        (+ pack (.sym regtype k) op GRi ope GRj)
3948        (sequence ((WI address))
3949                  (store-quad-semantics regtype address GRj)
3950                  (c-call VOID "@cpu@_check_recovering_store"
3951                          address (index-of (.sym regtype k)) 16 is_float))
3952        profile
3953   )
3954 )
3955
3956 (r-store-quad rstq  OP_03 OPE1_24 GR    0 NA
3957               ((fr500 (unit u-gr-r-store))) "Store quad word")
3958 (r-store-quad rstqf OP_03 OPE1_2C FRint 1 FR-ACCESS
3959               ((fr500 (unit u-fr-r-store))) "Store quad float")
3960
3961 (define-pmacro (store-r-r-u name mode op ope regtype attr profile comment)
3962   (dni name
3963        (comment)
3964        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) attr)
3965        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
3966        (+ pack (.sym regtype k) op GRi ope GRj)
3967        (sequence ((UWI address))
3968                  (set address (add GRi GRj))
3969                  (c-call VOID (.str "@cpu@_write_mem_" mode)
3970                          pc address (.sym regtype k))
3971                  (set GRi address))
3972        profile
3973   )
3974 )
3975
3976 (store-r-r-u stbu  QI OP_03 OPE1_10 GR NA
3977              ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3978              "Store unsigned byte, update index")
3979 (store-r-r-u sthu  HI OP_03 OPE1_11 GR NA
3980              ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3981              "Store unsigned half, update index")
3982 (store-r-r-u stu   WI OP_03 OPE1_12 GR NA
3983              ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
3984              "Store          word, update index")
3985
3986 (store-r-r-u stbfu QI OP_03 OPE1_18 FRint FR-ACCESS
3987              ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3988              "Store byte float, update index")
3989 (store-r-r-u sthfu HI OP_03 OPE1_19 FRint FR-ACCESS
3990              ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3991              "Store half float, update index")
3992 (store-r-r-u stfu  SI OP_03 OPE1_1A FRint FR-ACCESS
3993              ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
3994              "Store word float, update index")
3995
3996 (store-r-r-u stcu  SI OP_03 OPE1_2D CPR (MACH frv) ()
3997              "Store coprocessor word, update index")
3998
3999 (define-pmacro (store-double-r-r-u
4000                 name mode op ope regtype attr profile comment)
4001   (dni name
4002        (comment)
4003        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) attr)
4004        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
4005        (+ pack (.sym regtype k) op GRi ope GRj)
4006        (sequence ((WI address))
4007                  (store-double-semantics mode regtype address GRj)
4008                  (set GRi address))
4009        profile
4010   )
4011 )
4012
4013 (store-double-r-r-u stdu  DI OP_03 OPE1_13 GR  NA
4014                     ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4015                     "Store double word, update index")
4016 (store-double-r-r-u stdfu DF OP_03 OPE1_1B FR  FR-ACCESS
4017                     ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4018                     "Store double float,update index")
4019 (store-double-r-r-u stdcu DI OP_03 OPE1_2E CPR (MACH frv) ()
4020                     "Store coprocessor double word, update index")
4021
4022 (define-pmacro (store-quad-r-r-u name op ope regtype attr profile comment)
4023   (dni name
4024        (comment)
4025        ((UNIT I0) (FR500-MAJOR I-3) (MACH frv) attr)
4026        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
4027        (+ pack (.sym regtype k) op GRi ope GRj)
4028        (sequence ((WI address))
4029                  (store-quad-semantics regtype address GRj)
4030                  (set GRi address))
4031        profile
4032   )
4033 )
4034
4035 (store-quad-r-r-u stqu  OP_03 OPE1_14 GR    NA
4036                   ((fr500 (unit u-gr-store)))
4037                   "Store quad word, update index")
4038 (store-quad-r-r-u stqfu OP_03 OPE1_1C FRint FR-ACCESS
4039                   ((fr500 (unit u-fr-store)))
4040                   "Store quad float, update index")
4041 (store-quad-r-r-u stqcu OP_03 OPE1_2F CPR   NA ()
4042                   "Store coprocessor quad   word, update index")
4043
4044 (define-pmacro (conditional-load name mode op ope regtype profile comment)
4045   (dni name
4046        (comment)
4047        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) CONDITIONAL)
4048        (.str name "$pack @($GRi,$GRj),$" regtype "k,$CCi,$cond")
4049        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
4050        (if (eq CCi (or cond 2))
4051            (set (.sym regtype k)
4052                 (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj))))
4053        profile
4054   )
4055 )
4056
4057 (conditional-load cldsb  QI OP_5E OPE4_0 GR
4058                   ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4059                   "Load   signed byte")
4060 (conditional-load cldub UQI OP_5E OPE4_1 GR
4061                   ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4062                   "Load unsigned byte")
4063 (conditional-load cldsh  HI OP_5E OPE4_2 GR
4064                   ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4065                   "Load   signed half")
4066 (conditional-load clduh UHI OP_5E OPE4_3 GR
4067                   ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4068                   "Load unsigned half")
4069 (conditional-load cld    SI OP_5F OPE4_0 GR
4070                   ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4071                   "Load          word")
4072
4073 (conditional-load cldbf UQI OP_60 OPE4_0 FRint
4074                   ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
4075                   "Load byte float")
4076 (conditional-load cldhf UHI OP_60 OPE4_1 FRint
4077                   ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
4078                   "Load half float")
4079 (conditional-load cldf   SI OP_60 OPE4_2 FRint
4080                   ((fr400 (unit u-fr-load)) (fr500 (unit u-fr-load)))
4081                   "Load word float")
4082
4083 (define-pmacro (conditional-load-double
4084                 name not_gr mode op ope regtype attr profile comment)
4085   (dni name
4086        (comment)
4087        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) CONDITIONAL attr)
4088        (.str name "$pack @($GRi,$GRj),$" regtype "doublek,$CCi,$cond")
4089        (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
4090        (if (eq CCi (or cond 2))
4091            (sequence ((WI address))
4092                      (load-double-semantics not_gr mode regtype address GRj)))
4093        profile
4094   )
4095 )
4096
4097 (conditional-load-double cldd  0 DI OP_5F OPE4_1 GR NA
4098                          ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4099                          "Load double word")
4100 (conditional-load-double clddf 1 DF OP_60 OPE4_3 FR FR-ACCESS
4101                          ((fr400 (unit u-gr-load)) (fr500 (unit u-gr-load)))
4102                          "Load double float")
4103
4104 (dni cldq
4105      "conditional load quad integer"
4106      ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) CONDITIONAL)
4107      "cldq$pack @($GRi,$GRj),$GRk,$CCi,$cond"
4108      (+ pack GRk OP_5F GRi CCi cond OPE4_2 GRj)
4109      (if (eq CCi (or cond 2))
4110          (sequence ((WI address))
4111                    (load-quad-semantics GR address GRj)))
4112      ((fr500 (unit u-gr-load)))
4113 )
4114
4115 (define-pmacro (conditional-load-gr-u name mode op ope comment)
4116   (dni name
4117        (comment)
4118        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) CONDITIONAL)
4119        (.str name "$pack @($GRi,$GRj),$GRk,$CCi,$cond")
4120        (+ pack GRk op GRi CCi  cond ope GRj)
4121        (if (eq CCi (or cond 2))
4122            (sequence ((WI address))
4123                      (set address (add GRi GRj))
4124                      (set GRk
4125                           (c-call mode (.str "@cpu@_read_mem_" mode)
4126                                   pc address))
4127                      (if (ne (index-of GRi) (index-of GRk))
4128                          (set GRi address))))
4129        ((fr400 (unit u-gr-load))
4130         (fr500 (unit u-gr-load)))
4131   )
4132 )
4133
4134 (conditional-load-gr-u cldsbu  QI OP_61 OPE4_0 "Load   signed byte, update")
4135 (conditional-load-gr-u cldubu UQI OP_61 OPE4_1 "Load unsigned byte, update")
4136 (conditional-load-gr-u cldshu  HI OP_61 OPE4_2 "Load   signed half, update")
4137 (conditional-load-gr-u clduhu UHI OP_61 OPE4_3 "Load unsigned half, update")
4138 (conditional-load-gr-u cldu    SI OP_62 OPE4_0 "Load          word, update")
4139
4140 (define-pmacro (conditional-load-non-gr-u name mode op ope regtype comment)
4141   (dni name
4142        (comment)
4143        ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) CONDITIONAL FR-ACCESS)
4144        (.str name "$pack @($GRi,$GRj),$" regtype "k,$CCi,$cond")
4145        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
4146        (if (eq CCi (or cond 2))
4147            (sequence ((WI address))
4148                      (set address (add GRi GRj))
4149                      (set (.sym regtype k)
4150                           (c-call mode (.str "@cpu@_read_mem_" mode)
4151                                   pc address))
4152                      (set GRi address)))
4153        ((fr400 (unit u-fr-load))
4154         (fr500 (unit u-fr-load)))
4155   )
4156 )
4157
4158 (conditional-load-non-gr-u cldbfu UQI OP_63 OPE4_0 FRint "Load byte float, update")
4159 (conditional-load-non-gr-u cldhfu UHI OP_63 OPE4_1 FRint "Load half float, update")
4160 (conditional-load-non-gr-u cldfu   SI OP_63 OPE4_2 FRint "Load word float, update")
4161
4162
4163 (dni clddu
4164      "Load double word,  update"
4165      ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) CONDITIONAL)
4166      "clddu$pack @($GRi,$GRj),$GRdoublek,$CCi,$cond"
4167      (+ pack GRdoublek OP_62 GRi CCi cond OPE4_1 GRj)
4168      (if (eq CCi (or cond 2))
4169          (sequence ((WI address))
4170                    (load-double-semantics 0 DI GR address GRj)
4171                    (if (ne (index-of GRi) (index-of GRdoublek))
4172                        (set GRi address))))
4173      ((fr400 (unit u-gr-load))
4174       (fr500 (unit u-gr-load)))
4175 )
4176
4177 (dni clddfu
4178      "Load double float, update"
4179      ((UNIT LOAD) (FR500-MAJOR I-2) (FR400-MAJOR I-2) CONDITIONAL FR-ACCESS)
4180      "clddfu$pack @($GRi,$GRj),$FRdoublek,$CCi,$cond"
4181      (+ pack FRdoublek OP_63 GRi CCi cond OPE4_3 GRj)
4182      (if (eq CCi (or cond 2))
4183          (sequence ((WI address))
4184                    (load-double-semantics 1 DF FR address GRj)
4185                    (set GRi address)))
4186      ((fr400 (unit u-fr-load))
4187       (fr500 (unit u-fr-load)))
4188 )
4189
4190 (dni cldqu
4191      "conditional load quad integer and update index"
4192      ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) CONDITIONAL)
4193      "cldqu$pack @($GRi,$GRj),$GRk,$CCi,$cond"
4194      (+ pack GRk OP_62 GRi CCi cond OPE4_2 GRj)
4195      (if (eq CCi (or cond 2))
4196          (sequence ((WI address))
4197                    (load-quad-semantics GR address GRj)
4198                    (if (ne (index-of GRi) (index-of GRk))
4199                        (set GRi address))))
4200      ((fr500 (unit u-gr-load)))
4201 )
4202
4203 (define-pmacro (conditional-store name mode op ope regtype profile comment)
4204   (dni name
4205        (comment)
4206        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) CONDITIONAL)
4207        (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
4208        (+ pack (.sym regtype k) op GRi CCi cond ope GRj)
4209        (if (eq CCi (or cond 2))
4210            (c-call VOID (.str "@cpu@_write_mem_" mode)
4211                    pc (add GRi GRj) (.sym regtype k)))
4212        profile
4213   )
4214 )
4215
4216 (conditional-store cstb  QI OP_64 OPE4_0 GR
4217                    ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4218                    "Store unsigned byte")
4219 (conditional-store csth  HI OP_64 OPE4_1 GR
4220                    ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4221                    "Store unsigned half")
4222 (conditional-store cst   SI OP_64 OPE4_2 GR
4223                    ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4224                    "Store          word")
4225
4226 (conditional-store cstbf QI OP_66 OPE4_0 FRint
4227                    ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4228                    "Store byte float")
4229 (conditional-store csthf HI OP_66 OPE4_1 FRint
4230                    ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4231                    "Store half float")
4232 (conditional-store cstf  SI OP_66 OPE4_2 FRint
4233                    ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4234                    "Store word float")
4235
4236 (define-pmacro (conditional-store-double
4237                 name mode op ope regtype attr profile comment)
4238   (dni name
4239        (comment)
4240        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) CONDITIONAL attr)
4241        (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
4242        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
4243        (if (eq CCi (or cond 2))
4244            (sequence ((WI address))
4245                      (store-double-semantics mode regtype address GRj)))
4246        profile
4247   )
4248 )
4249
4250 (conditional-store-double cstd  DI OP_64 OPE4_3 GR NA
4251                           ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4252                           "Store double word")
4253 (conditional-store-double cstdf DF OP_66 OPE4_3 FR FR-ACCESS
4254                           ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4255                           "Store double float")
4256
4257 (dni cstq
4258      "conditionally store quad word"
4259      ((UNIT I0) (FR500-MAJOR I-3) (MACH frv) CONDITIONAL)
4260      "cstq$pack $GRk,@($GRi,$GRj),$CCi,$cond"
4261      (+ pack GRk OP_65 GRi CCi cond OPE4_0 GRj)
4262      (if (eq CCi (or cond 2))
4263          (sequence ((WI address))
4264                    (store-quad-semantics GR address GRj)))
4265      ((fr500 (unit u-gr-store)))
4266 )
4267
4268 (define-pmacro (conditional-store-u
4269                 name mode op ope regtype attr profile comment)
4270   (dni name
4271        (comment)
4272        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) CONDITIONAL attr)
4273        (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
4274        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
4275        (if (eq CCi (or cond 2))
4276            (sequence ((WI address))
4277                      (set address (add GRi GRj))
4278                      (c-call VOID (.str "@cpu@_write_mem_" mode)
4279                              pc address (.sym regtype k))
4280                      (set GRi address)))
4281        profile
4282   )
4283 )
4284
4285 (conditional-store-u cstbu QI OP_67 OPE4_0 GR NA
4286                      ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4287                      "Store unsigned byte, update index")
4288 (conditional-store-u csthu HI OP_67 OPE4_1 GR NA
4289                      ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4290                      "Store unsigned half, update index")
4291 (conditional-store-u cstu  SI OP_67 OPE4_2 GR NA
4292                      ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4293                      "Store          word, update index")
4294
4295 (conditional-store-u cstbfu QI OP_68 OPE4_0 FRint FR-ACCESS
4296                      ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4297                      "Store byte float, update index")
4298 (conditional-store-u csthfu HI OP_68 OPE4_1 FRint FR-ACCESS
4299                      ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4300                      "Store half float, update index")
4301 (conditional-store-u cstfu  SI OP_68 OPE4_2 FRint FR-ACCESS
4302                      ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4303                      "Store word float, update index")
4304
4305 (define-pmacro (conditional-store-double-u
4306                 name mode op ope regtype attr profile comment)
4307   (dni name
4308        (comment)
4309        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) CONDITIONAL attr)
4310        (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
4311        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
4312        (if (eq CCi (or cond 2))
4313            (sequence ((WI address))
4314                      (store-double-semantics mode regtype address GRj)
4315                      (set GRi address)))
4316        profile
4317   )
4318 )
4319
4320 (conditional-store-double-u cstdu  DI OP_67 OPE4_3 GR NA
4321                             ((fr400 (unit u-gr-store))
4322                              (fr500 (unit u-gr-store)))
4323                             "Store double word, update index")
4324 (conditional-store-double-u cstdfu DF OP_68 OPE4_3 FR FR-ACCESS
4325                             ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4326                             "Store double float, update index")
4327
4328 (define-pmacro (store-r-simm name mode op regtype attr profile comment)
4329   (dni name
4330        (comment)
4331        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) attr)
4332        (.str name "$pack $" regtype "k,@($GRi,$d12)")
4333        (+ pack (.sym regtype k) op GRi d12)
4334        (c-call VOID (.str "@cpu@_write_mem_" mode)
4335                pc (add GRi d12) (.sym regtype k))
4336        profile
4337   )
4338 )
4339
4340 (store-r-simm stbi QI OP_50 GR NA
4341               ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4342               "Store unsigned byte")
4343 (store-r-simm sthi HI OP_51 GR NA
4344               ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4345               "Store unsigned half")
4346 (store-r-simm sti  SI OP_52 GR NA
4347               ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4348               "Store          word")
4349
4350 (store-r-simm stbfi QI OP_4E FRint FR-ACCESS
4351               ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4352               "Store byte float")
4353 (store-r-simm sthfi HI OP_4F FRint FR-ACCESS
4354               ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4355               "Store half float")
4356 (store-r-simm stfi  SI OP_55 FRint FR-ACCESS
4357               ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4358               "Store word float")
4359
4360 (define-pmacro (store-double-r-simm name mode op regtype attr profile comment)
4361   (dni name
4362        (comment)
4363        ((UNIT I0) (FR500-MAJOR I-3) (FR400-MAJOR I-3) attr)
4364        (.str name "$pack $" regtype "k,@($GRi,$d12)")
4365        (+ pack (.sym regtype k) op GRi d12)
4366        (sequence ((WI address))
4367                  (store-double-semantics mode regtype address d12))
4368        profile
4369   )
4370 )
4371
4372 (store-double-r-simm stdi  DI OP_53 GR NA
4373                      ((fr400 (unit u-gr-store)) (fr500 (unit u-gr-store)))
4374                      "Store double word")
4375 (store-double-r-simm stdfi DF OP_56 FR FR-ACCESS
4376                      ((fr400 (unit u-fr-store)) (fr500 (unit u-fr-store)))
4377                      "Store double float")
4378
4379 (define-pmacro (store-quad-r-simm name op regtype attr profile comment)
4380   (dni name
4381        (comment)
4382        ((UNIT I0) (FR500-MAJOR I-3) (MACH frv) attr)
4383        (.str name "$pack $" regtype "k,@($GRi,$d12)")
4384        (+ pack (.sym regtype k) op GRi d12)
4385        (sequence ((WI address))
4386                  (store-quad-semantics regtype address d12))
4387        profile
4388   )
4389 )
4390
4391 (store-quad-r-simm stqi  OP_54 GR    NA ((fr500 (unit u-gr-store)))
4392                    "Store quad word")
4393 (store-quad-r-simm stqfi OP_57 FRint FR-ACCESS ()
4394                    "Store quad float")
4395
4396 (define-pmacro (swap-semantics base offset arg)
4397   (sequence ((WI tmp) (WI address))
4398             (set tmp arg)
4399             (set address (add base offset))
4400             (set arg (c-call WI "@cpu@_read_mem_WI" pc address))
4401             (c-call VOID "@cpu@_write_mem_WI" pc address tmp))
4402 )
4403
4404 (dni swap
4405      "Swap contents of memory with GR"
4406      ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
4407      "swap$pack @($GRi,$GRj),$GRk"
4408      (+ pack GRk OP_03 GRi OPE1_05 GRj)
4409      (swap-semantics GRi GRj GRk)
4410      ((fr400 (unit u-swap))
4411       (fr500 (unit u-swap)))
4412 )
4413
4414 (dni "swapi"
4415      "Swap contents of memory with GR"
4416      ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
4417      ("swapi$pack @($GRi,$d12),$GRk")
4418      (+ pack GRk OP_4D GRi d12)
4419      (swap-semantics GRi d12 GRk)
4420      ((fr400 (unit u-swap))
4421       (fr500 (unit u-swap)))
4422 )
4423
4424 (dni cswap
4425      "Conditionally swap contents of memory with GR"
4426      ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2) CONDITIONAL)
4427      "cswap$pack @($GRi,$GRj),$GRk,$CCi,$cond"
4428      (+ pack GRk OP_65 GRi CCi cond OPE4_2 GRj)
4429      (if (eq CCi (or cond 2))
4430          (swap-semantics GRi GRj GRk))
4431      ((fr400 (unit u-swap))
4432       (fr500 (unit u-swap)))
4433 )
4434
4435 (define-pmacro (register-transfer
4436                 name op ope reg_src reg_targ pipe major1 major2 attr1 attr2
4437                 profile comment)
4438   (dni name
4439        (comment)
4440        ((UNIT pipe) major1 major2 attr1 attr2)
4441        (.str name "$pack $" reg_src ",$" reg_targ)
4442        (+ pack reg_targ op (rs-null) ope reg_src)
4443        (set reg_targ reg_src)
4444        profile
4445   )
4446 )
4447
4448 (register-transfer movgf OP_03 OPE1_15
4449                    GRj FRintk I0 (FR500-MAJOR I-4) (FR400-MAJOR I-4)
4450                    FR-ACCESS NA
4451                    ((fr400 (unit u-gr2fr)) (fr500 (unit u-gr2fr)))
4452                    "transfer gr to fr")
4453 (register-transfer movfg OP_03 OPE1_0D
4454                    FRintk GRj I0 (FR500-MAJOR I-4) (FR400-MAJOR I-4)
4455                    FR-ACCESS NA
4456                    ((fr400 (unit u-fr2gr)) (fr500 (unit u-fr2gr)))
4457                    "transfer fr to gr")
4458
4459 (define-pmacro (nextreg hw r offset) (reg hw (add (index-of r) offset)))
4460
4461 (define-pmacro (register-transfer-double-from-gr-semantics cond)
4462   (if cond
4463       (if (eq (index-of GRj) 0)
4464           (sequence ()
4465                     (set FRintk 0)
4466                     (set (nextreg h-fr_int FRintk 1) 0))
4467           (sequence ()
4468                     (set FRintk GRj)
4469                     (set (nextreg h-fr_int FRintk 1) (nextreg h-gr GRj 1)))))
4470 )
4471
4472 (dni movgfd
4473      "move GR for FR double"
4474      ((UNIT I0) (FR500-MAJOR I-4) (FR400-MAJOR I-4) FR-ACCESS)
4475      "movgfd$pack $GRj,$FRintk"
4476      (+ pack FRintk OP_03 (rs-null) OPE1_16 GRj)
4477      (register-transfer-double-from-gr-semantics 1)
4478      ; TODO -- doesn't handle second register in the pair
4479      ((fr400 (unit u-gr2fr))
4480       (fr500 (unit u-gr2fr)))
4481 )
4482
4483 (define-pmacro (register-transfer-double-to-gr-semantics cond)
4484   (if (andif (ne (index-of GRj) 0) cond)
4485       (sequence ()
4486                 (set GRj FRintk)
4487                 (set (nextreg h-gr GRj 1) (nextreg h-fr_int FRintk 1))))
4488 )
4489
4490 (dni movfgd
4491      "move FR for GR double"
4492      ((UNIT I0) (FR500-MAJOR I-4) (FR400-MAJOR I-4) FR-ACCESS)
4493      "movfgd$pack $FRintk,$GRj"
4494      (+ pack FRintk OP_03 (rs-null) OPE1_0E GRj)
4495      (register-transfer-double-to-gr-semantics 1)
4496      ; TODO -- doesn't handle second register in the pair
4497      ((fr400 (unit u-fr2gr))
4498       (fr500 (unit u-fr2gr)))
4499 )
4500
4501 (dni movgfq
4502      "move GR for FR quad"
4503      ((UNIT I0) (FR500-MAJOR I-4) (MACH frv) FR-ACCESS)
4504      "movgfq$pack $GRj,$FRintk"
4505      (+ pack FRintk OP_03 (rs-null) OPE1_17 GRj)
4506      (if (eq (index-of GRj) 0)
4507          (sequence ()
4508                    (set FRintk 0)
4509                    (set (reg h-fr_int (add (index-of FRintk) 1)) 0)
4510                    (set (reg h-fr_int (add (index-of FRintk) 2)) 0)
4511                    (set (reg h-fr_int (add (index-of FRintk) 3)) 0))
4512          (sequence ()
4513                    (set FRintk GRj)
4514                    (set (reg h-fr_int (add (index-of FRintk) 1))
4515                         (reg h-gr (add (index-of GRj)    1)))
4516                    (set (reg h-fr_int (add (index-of FRintk) 2))
4517                         (reg h-gr (add (index-of GRj)    2)))
4518                    (set (reg h-fr_int (add (index-of FRintk) 3))
4519                         (reg h-gr (add (index-of GRj)    3)))))
4520      ()
4521 )
4522
4523 (dni movfgq
4524      "move FR for GR quad"
4525      ((UNIT I0) (FR500-MAJOR I-4) (MACH frv) FR-ACCESS)
4526      "movfgq$pack $FRintk,$GRj"
4527      (+ pack FRintk OP_03 (rs-null) OPE1_0F GRj)
4528      (if (ne (index-of GRj) 0)
4529          (sequence ()
4530                    (set GRj FRintk)
4531                    (set (reg h-gr (add (index-of GRj)    1))
4532                         (reg h-fr_int (add (index-of FRintk) 1)))
4533                    (set (reg h-gr (add (index-of GRj)    2))
4534                         (reg h-fr_int (add (index-of FRintk) 2)))
4535                    (set (reg h-gr (add (index-of GRj)    3))
4536                         (reg h-fr_int (add (index-of FRintk) 3)))))
4537      ()
4538 )
4539
4540 (define-pmacro (conditional-register-transfer
4541                 name op ope reg_src reg_targ pipe major1 major2 mach
4542                 profile comment)
4543   (dni name
4544        (comment)
4545        ((UNIT pipe) major1 major2 CONDITIONAL FR-ACCESS mach)
4546        (.str name "$pack $" reg_src ",$" reg_targ ",$CCi,$cond")
4547        (+ pack reg_targ op (rs-null) CCi cond ope reg_src)
4548        (if (eq CCi (or cond 2))
4549            (set reg_targ reg_src))
4550        profile
4551   )
4552 )
4553
4554 (conditional-register-transfer cmovgf OP_69 OPE4_0 GRj FRintk I0
4555                                (FR500-MAJOR I-4) (FR400-MAJOR I-4)
4556                                NA
4557                                ((fr400 (unit u-gr2fr)) (fr500 (unit u-gr2fr)))
4558                                "transfer gr to fr")
4559 (conditional-register-transfer cmovfg OP_69 OPE4_2 FRintk GRj I0
4560                                (FR500-MAJOR I-4) (FR400-MAJOR I-4)
4561                                NA
4562                                ((fr400 (unit u-fr2gr)) (fr500 (unit u-fr2gr)))
4563                                "transfer fr to gr")
4564
4565
4566 (dni cmovgfd
4567      "Conditional move GR to FR double"
4568      ((UNIT I0) (FR500-MAJOR I-4) (FR400-MAJOR I-4) CONDITIONAL FR-ACCESS)
4569      "cmovgfd$pack $GRj,$FRintk,$CCi,$cond"
4570      (+ pack FRintk OP_69 (rs-null) CCi cond OPE4_1 GRj)
4571      (register-transfer-double-from-gr-semantics (eq CCi (or cond 2)))
4572      ; TODO -- doesn't handle extra registers in double
4573      ((fr400 (unit u-gr2fr))
4574       (fr500 (unit u-gr2fr)))
4575 )
4576
4577 (dni cmovfgd
4578      "Conditional move FR to GR double"
4579      ((UNIT I0) (FR500-MAJOR I-4) (FR400-MAJOR I-4) CONDITIONAL FR-ACCESS)
4580      "cmovfgd$pack $FRintk,$GRj,$CCi,$cond"
4581      (+ pack FRintk OP_69 (rs-null) CCi cond OPE4_3 GRj)
4582      (register-transfer-double-to-gr-semantics (eq CCi (or cond 2)))
4583      ; TODO -- doesn't handle second register in the pair
4584      ((fr400 (unit u-fr2gr))
4585       (fr500 (unit u-fr2gr)))
4586 )
4587
4588 (define-pmacro (register-transfer-spr
4589                 name op ope reg_src reg_targ unitname comment)
4590   (dni name
4591        (comment)
4592        ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
4593        (.str name "$pack $" reg_src ",$" reg_targ)
4594        (+ pack reg_targ op ope reg_src)
4595        (set reg_targ reg_src)
4596        ((fr400 (unit unitname))
4597         (fr500 (unit unitname)))
4598   )
4599 )
4600
4601 (register-transfer-spr movgs OP_03 OPE1_06 GRj spr u-gr2spr "transfer gr->spr")
4602 (register-transfer-spr movsg OP_03 OPE1_07 spr GRj u-spr2gr "transfer spr->gr")
4603
4604 ; Integer Branch Conditions
4605 (define-pmacro (Inev cc) (const BI 0))
4606 (define-pmacro (Ira  cc) (const BI 1))
4607 (define-pmacro (Ieq  cc) (     zbit cc))
4608 (define-pmacro (Ine  cc) (not (zbit cc)))
4609 (define-pmacro (Ile  cc) (     orif (zbit cc) (xor (nbit cc) (vbit cc))))
4610 (define-pmacro (Igt  cc) (not (orif (zbit cc) (xor (nbit cc) (vbit cc)))))
4611 (define-pmacro (Ilt  cc) (     xor  (nbit cc) (vbit cc)))
4612 (define-pmacro (Ige  cc) (not (xor  (nbit cc) (vbit cc))))
4613 (define-pmacro (Ils  cc) (     orif (cbit cc) (zbit cc)))
4614 (define-pmacro (Ihi  cc) (not (orif (cbit cc) (zbit cc))))
4615 (define-pmacro (Ic   cc) (     cbit cc))
4616 (define-pmacro (Inc  cc) (not (cbit cc)))
4617 (define-pmacro (In   cc) (     nbit cc))
4618 (define-pmacro (Ip   cc) (not (nbit cc)))
4619 (define-pmacro (Iv   cc) (     vbit cc))
4620 (define-pmacro (Inv  cc) (not (vbit cc)))
4621
4622 ; Float Branch Conditions
4623 (define-pmacro (Fnev cc) (const BI 0))
4624 (define-pmacro (Fra  cc) (const BI 1))
4625 (define-pmacro (Fne  cc) (orif (lbit cc) (orif (gbit cc) (ubit cc))))
4626 (define-pmacro (Feq  cc) (ebit cc))
4627 (define-pmacro (Flg  cc) (orif (lbit cc) (gbit cc)))
4628 (define-pmacro (Fue  cc) (orif (ebit cc) (ubit cc)))
4629 (define-pmacro (Ful  cc) (orif (lbit cc) (ubit cc)))
4630 (define-pmacro (Fge  cc) (orif (ebit cc) (gbit cc)))
4631 (define-pmacro (Flt  cc) (lbit cc))
4632 (define-pmacro (Fuge cc) (orif (ebit cc) (orif (gbit cc) (ubit cc))))
4633 (define-pmacro (Fug  cc) (orif (gbit cc) (ubit cc)))
4634 (define-pmacro (Fle  cc) (orif (ebit cc) (lbit cc)))
4635 (define-pmacro (Fgt  cc) (gbit cc))
4636 (define-pmacro (Fule cc) (orif (ebit cc) (orif (lbit cc) (ubit cc))))
4637 (define-pmacro (Fu   cc) (ubit cc))
4638 (define-pmacro (Fo   cc) (orif (ebit cc) (orif (lbit cc) (gbit cc))))
4639
4640 (define-pmacro (conditional-branch-i prefix cc op cond comment)
4641   (dni (.sym prefix cc)
4642        (comment)
4643        ((UNIT B01) (FR500-MAJOR B-1) (FR400-MAJOR B-1))
4644        (.str (.sym prefix cc) "$pack $ICCi_2,$hint,$label16")
4645        (+ pack (.sym ICC_ cc) ICCi_2 op hint label16)
4646        (sequence ()
4647                  (c-call VOID "@cpu@_model_branch" label16 hint)
4648                  (if (cond ICCi_2)
4649                      (set pc label16)))
4650        ((fr400 (unit u-branch))
4651         (fr500 (unit u-branch)))
4652   )
4653 )
4654
4655 (dni bra
4656      "integer branch equal"
4657       ((UNIT B01) (FR500-MAJOR B-1) (FR400-MAJOR B-1))
4658       "bra$pack $hint_taken$label16"
4659       (+ pack ICC_ra (ICCi_2-null) OP_06 hint_taken label16)
4660       (sequence ()
4661                 (c-call VOID "@cpu@_model_branch" label16 hint_taken)
4662                 (set pc label16))
4663       ((fr400 (unit u-branch))
4664        (fr500 (unit u-branch)))
4665 )
4666
4667 (dni bno
4668      "integer branch never"
4669       ((UNIT B01) (FR500-MAJOR B-1) (FR400-MAJOR B-1))
4670       "bno$pack$hint_not_taken"
4671       (+ pack ICC_nev (ICCi_2-null) OP_06 hint_not_taken (label16-null))
4672       (c-call VOID "@cpu@_model_branch" label16 hint_not_taken)
4673       ((fr400 (unit u-branch))
4674        (fr500 (unit u-branch)))
4675 )
4676
4677 (conditional-branch-i b eq  OP_06 Ieq  "integer branch equal")
4678 (conditional-branch-i b ne  OP_06 Ine  "integer branch not equal")
4679 (conditional-branch-i b le  OP_06 Ile  "integer branch less or equal")
4680 (conditional-branch-i b gt  OP_06 Igt  "integer branch greater")
4681 (conditional-branch-i b lt  OP_06 Ilt  "integer branch less")
4682 (conditional-branch-i b ge  OP_06 Ige  "integer branch greater or equal")
4683 (conditional-branch-i b ls  OP_06 Ils  "integer branch less or equal unsigned")
4684 (conditional-branch-i b hi  OP_06 Ihi  "integer branch greater unsigned")
4685 (conditional-branch-i b c   OP_06 Ic   "integer branch carry set")
4686 (conditional-branch-i b nc  OP_06 Inc  "integer branch carry clear")
4687 (conditional-branch-i b n   OP_06 In   "integer branch negative")
4688 (conditional-branch-i b p   OP_06 Ip   "integer branch positive")
4689 (conditional-branch-i b v   OP_06 Iv   "integer branch overflow set")
4690 (conditional-branch-i b nv  OP_06 Inv  "integer branch overflow clear")
4691
4692 (define-pmacro (conditional-branch-f prefix cc op cond comment)
4693   (dni (.sym prefix cc)
4694        (comment)
4695        ((UNIT B01) (FR500-MAJOR B-1) (FR400-MAJOR B-1) FR-ACCESS)
4696        (.str (.sym prefix cc) "$pack $FCCi_2,$hint,$label16")
4697        (+ pack (.sym FCC_ cc) FCCi_2 op hint label16)
4698        (sequence ()
4699                  (c-call VOID "@cpu@_model_branch" label16 hint)
4700                  (if (cond FCCi_2) (set pc label16)))
4701        ((fr400 (unit u-branch))
4702         (fr500 (unit u-branch)))
4703   )
4704 )
4705
4706 (dni fbra
4707      "float branch equal"
4708       ((UNIT B01) (FR500-MAJOR B-1) (FR400-MAJOR B-1) FR-ACCESS)
4709       "fbra$pack $hint_taken$label16"
4710       (+ pack FCC_ra (FCCi_2-null) OP_07 hint_taken label16)
4711       (sequence ()
4712                 (c-call VOID "@cpu@_model_branch" label16 hint_taken)
4713                 (set pc label16))
4714       ((fr400 (unit u-branch))
4715        (fr500 (unit u-branch)))
4716 )
4717
4718 (dni fbno
4719      "float branch never"
4720       ((UNIT B01) (FR500-MAJOR B-1) (FR400-MAJOR B-1) FR-ACCESS)
4721       "fbno$pack$hint_not_taken"
4722       (+ pack FCC_nev (FCCi_2-null) OP_07 hint_not_taken (label16-null))
4723       (c-call VOID "@cpu@_model_branch" label16 hint_not_taken)
4724       ((fr400 (unit u-branch))
4725        (fr500 (unit u-branch)))
4726 )
4727
4728 (conditional-branch-f fb ne  OP_07 Fne  "float branch not equal")
4729 (conditional-branch-f fb eq  OP_07 Feq  "float branch equal")
4730 (conditional-branch-f fb lg  OP_07 Flg  "float branch less or greater")
4731 (conditional-branch-f fb ue  OP_07 Fue  "float branch unordered or equal")
4732 (conditional-branch-f fb ul  OP_07 Ful  "float branch unordered or less")
4733 (conditional-branch-f fb ge  OP_07 Fge  "float branch greater or equal")
4734 (conditional-branch-f fb lt  OP_07 Flt  "float branch less")
4735 (conditional-branch-f fb uge OP_07 Fuge "float branch unordered, greater,equal")
4736 (conditional-branch-f fb ug  OP_07 Fug  "float branch unordered or greater")
4737 (conditional-branch-f fb le  OP_07 Fle  "float branch less or equal")
4738 (conditional-branch-f fb gt  OP_07 Fgt  "float branch greater")
4739 (conditional-branch-f fb ule OP_07 Fule "float branch unordered, less or equal")
4740 (conditional-branch-f fb u   OP_07 Fu   "float branch unordered")
4741 (conditional-branch-f fb o   OP_07 Fo   "float branch ordered")
4742
4743 (define-pmacro (ctrlr-branch-semantics cond ccond)
4744   (sequence ((SI tmp))
4745             (set tmp (sub (spr-lcr) 1))
4746             (set (spr-lcr) tmp)
4747             (if cond
4748                 (if (eq ccond 0)
4749                     (if (ne tmp 0)
4750                         (set pc (spr-lr)))
4751                     (if (eq tmp 0)
4752                         (set pc (spr-lr))))))
4753 )
4754
4755 (dni bctrlr
4756      "LCR conditional branch to lr"
4757      ((UNIT B0) (FR500-MAJOR B-2) (FR400-MAJOR B-2))
4758      ("bctrlr$pack $ccond,$hint")
4759      (+ pack (cond-null) (ICCi_2-null) OP_0E hint OPE3_01 ccond (s12-null))
4760      (sequence ()
4761                (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
4762                (ctrlr-branch-semantics (const BI 1) ccond))
4763      ((fr400 (unit u-branch))
4764       (fr500 (unit u-branch)))
4765 )
4766
4767 (define-pmacro (conditional-branch-cclr prefix cc i-f op ope cond attr comment)
4768   (dni (.sym prefix cc lr)
4769        (comment)
4770        ((UNIT B01) (FR500-MAJOR B-3) (FR400-MAJOR B-3) attr)
4771        (.str (.sym prefix cc lr) "$pack $" i-f "CCi_2,$hint")
4772        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op hint ope
4773           (ccond-null) (s12-null))
4774        (sequence ()
4775                  (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
4776                  (if (cond (.sym i-f CCi_2)) (set pc (spr-lr))))
4777        ((fr400 (unit u-branch))
4778         (fr500 (unit u-branch)))
4779   )
4780 )
4781
4782 (dni bralr
4783      "integer cclr branch always"
4784      ((UNIT B01) (FR500-MAJOR B-3) (FR400-MAJOR B-3))
4785      "bralr$pack$hint_taken"
4786      (+ pack ICC_ra (ICCi_2-null) OP_0E hint_taken OPE3_02 (ccond-null) (s12-null))
4787      (sequence ()
4788                (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
4789                (set pc (spr-lr)))
4790      ((fr400 (unit u-branch))
4791       (fr500 (unit u-branch)))
4792 )
4793
4794 (dni bnolr
4795      "integer cclr branch never"
4796      ((UNIT B01) (FR500-MAJOR B-3) (FR400-MAJOR B-3))
4797      "bnolr$pack$hint_not_taken"
4798      (+ pack ICC_nev (ICCi_2-null) OP_0E hint_not_taken OPE3_02 (ccond-null) (s12-null))
4799      (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
4800      ((fr400 (unit u-branch))
4801       (fr500 (unit u-branch)))
4802 )
4803
4804 (conditional-branch-cclr b eq  I OP_0E OPE3_02 Ieq  NA "integer cclr branch equal")
4805 (conditional-branch-cclr b ne  I OP_0E OPE3_02 Ine  NA "integer cclr branch not equal")
4806 (conditional-branch-cclr b le  I OP_0E OPE3_02 Ile  NA "integer cclr branch less or equal")
4807 (conditional-branch-cclr b gt  I OP_0E OPE3_02 Igt  NA "integer cclr branch greater")
4808 (conditional-branch-cclr b lt  I OP_0E OPE3_02 Ilt  NA "integer cclr branch less")
4809 (conditional-branch-cclr b ge  I OP_0E OPE3_02 Ige  NA "integer cclr branch greater or equal")
4810 (conditional-branch-cclr b ls  I OP_0E OPE3_02 Ils  NA "integer cclr branch less or equal unsigned")
4811 (conditional-branch-cclr b hi  I OP_0E OPE3_02 Ihi  NA "integer cclr branch greater unsigned")
4812 (conditional-branch-cclr b c   I OP_0E OPE3_02 Ic   NA "integer cclr branch carry set")
4813 (conditional-branch-cclr b nc  I OP_0E OPE3_02 Inc  NA "integer cclr branch carry clear")
4814 (conditional-branch-cclr b n   I OP_0E OPE3_02 In   NA "integer cclr branch negative")
4815 (conditional-branch-cclr b p   I OP_0E OPE3_02 Ip   NA "integer cclr branch positive")
4816 (conditional-branch-cclr b v   I OP_0E OPE3_02 Iv   NA "integer cclr branch overflow set")
4817 (conditional-branch-cclr b nv  I OP_0E OPE3_02 Inv  NA "integer cclr branch overflow clear")
4818
4819 (dni fbralr
4820      "float cclr branch always"
4821      ((UNIT B01) (FR500-MAJOR B-3) (FR400-MAJOR B-3) FR-ACCESS)
4822      "fbralr$pack$hint_taken"
4823      (+ pack FCC_ra (FCCi_2-null) OP_0E hint_taken OPE3_06 (ccond-null) (s12-null))
4824      (sequence ()
4825                (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
4826                (set pc (spr-lr)))
4827      ((fr400 (unit u-branch))
4828       (fr500 (unit u-branch)))
4829 )
4830
4831 (dni fbnolr
4832      "float cclr branch never"
4833      ((UNIT B01) (FR500-MAJOR B-3) (FR400-MAJOR B-3) FR-ACCESS)
4834      "fbnolr$pack$hint_not_taken"
4835      (+ pack FCC_nev (FCCi_2-null) OP_0E hint_not_taken OPE3_06 (ccond-null) (s12-null))
4836      (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
4837      ((fr400 (unit u-branch))
4838       (fr500 (unit u-branch)))
4839 )
4840
4841 (conditional-branch-cclr fb eq  F OP_0E OPE3_06 Feq  FR-ACCESS "float cclr branch equal")
4842 (conditional-branch-cclr fb ne  F OP_0E OPE3_06 Fne  FR-ACCESS "float cclr branch not equal")
4843 (conditional-branch-cclr fb lg  F OP_0E OPE3_06 Flg  FR-ACCESS "float branch less or greater")
4844 (conditional-branch-cclr fb ue  F OP_0E OPE3_06 Fue  FR-ACCESS "float branch unordered or equal")
4845 (conditional-branch-cclr fb ul  F OP_0E OPE3_06 Ful  FR-ACCESS "float branch unordered or less")
4846 (conditional-branch-cclr fb ge  F OP_0E OPE3_06 Fge  FR-ACCESS "float branch greater or equal")
4847 (conditional-branch-cclr fb lt  F OP_0E OPE3_06 Flt  FR-ACCESS "float branch less")
4848 (conditional-branch-cclr fb uge F OP_0E OPE3_06 Fuge FR-ACCESS "float branch unordered, greater, equal")
4849 (conditional-branch-cclr fb ug  F OP_0E OPE3_06 Fug  FR-ACCESS "float branch unordered or greater")
4850 (conditional-branch-cclr fb le  F OP_0E OPE3_06 Fle  FR-ACCESS "float branch less or equal")
4851 (conditional-branch-cclr fb gt  F OP_0E OPE3_06 Fgt  FR-ACCESS "float branch greater")
4852 (conditional-branch-cclr fb ule F OP_0E OPE3_06 Fule FR-ACCESS "float branch unordered, less or equal")
4853 (conditional-branch-cclr fb u   F OP_0E OPE3_06 Fu   FR-ACCESS "float branch unordered")
4854 (conditional-branch-cclr fb o   F OP_0E OPE3_06 Fo   FR-ACCESS "float branch ordered")
4855
4856 (define-pmacro (conditional-branch-ctrlr prefix cc i-f op ope cond attr comment)
4857   (dni (.sym prefix cc lr)
4858        (comment)
4859        ((UNIT B0) (FR500-MAJOR B-2) (FR400-MAJOR B-2) attr)
4860        (.str (.sym prefix cc lr) "$pack $" i-f "CCi_2,$ccond,$hint")
4861        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op hint ope ccond (s12-null))
4862        (sequence ()
4863                  (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
4864                  (ctrlr-branch-semantics (cond (.sym i-f CCi_2)) ccond))
4865        ((fr400 (unit u-branch))
4866         (fr500 (unit u-branch)))
4867   )
4868 )
4869
4870 (dni bcralr
4871      "integer ctrlr branch always"
4872      ((UNIT B0) (FR500-MAJOR B-2) (FR400-MAJOR B-2))
4873      "bcralr$pack $ccond$hint_taken"
4874      (+ pack ICC_ra (ICCi_2-null) OP_0E hint_taken OPE3_03 ccond (s12-null))
4875      (sequence ()
4876                (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
4877                (ctrlr-branch-semantics (const BI 1) ccond))
4878      ((fr400 (unit u-branch))
4879       (fr500 (unit u-branch)))
4880 )
4881
4882 (dni bcnolr
4883      "integer ctrlr branch never"
4884      ((UNIT B0) (FR500-MAJOR B-2) (FR400-MAJOR B-2))
4885      "bcnolr$pack$hint_not_taken"
4886      (+ pack ICC_nev (ICCi_2-null) OP_0E hint_not_taken OPE3_03 (ccond-null) (s12-null))
4887      (sequence ()
4888                (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
4889                (ctrlr-branch-semantics (const BI 0) ccond))
4890      ((fr400 (unit u-branch))
4891       (fr500 (unit u-branch)))
4892 )
4893
4894 (conditional-branch-ctrlr bc eq  I OP_0E OPE3_03 Ieq  NA "integer ctrlr branch equal")
4895 (conditional-branch-ctrlr bc ne  I OP_0E OPE3_03 Ine  NA "integer ctrlr branch not equal")
4896 (conditional-branch-ctrlr bc le  I OP_0E OPE3_03 Ile  NA "integer ctrlr branch less equal")
4897 (conditional-branch-ctrlr bc gt  I OP_0E OPE3_03 Igt  NA "integer ctrlr branch greater")
4898 (conditional-branch-ctrlr bc lt  I OP_0E OPE3_03 Ilt  NA "integer ctrlr branch less")
4899 (conditional-branch-ctrlr bc ge  I OP_0E OPE3_03 Ige  NA "integer ctrlr branch greater equal")
4900 (conditional-branch-ctrlr bc ls  I OP_0E OPE3_03 Ils  NA "integer ctrlr branch less equal unsigned")
4901 (conditional-branch-ctrlr bc hi  I OP_0E OPE3_03 Ihi  NA "integer ctrlr branch greater unsigned")
4902 (conditional-branch-ctrlr bc c   I OP_0E OPE3_03 Ic   NA "integer ctrlr branch carry set")
4903 (conditional-branch-ctrlr bc nc  I OP_0E OPE3_03 Inc  NA "integer ctrlr branch carry clear")
4904 (conditional-branch-ctrlr bc n   I OP_0E OPE3_03 In   NA "integer ctrlr branch negative")
4905 (conditional-branch-ctrlr bc p   I OP_0E OPE3_03 Ip   NA "integer ctrlr branch positive")
4906 (conditional-branch-ctrlr bc v   I OP_0E OPE3_03 Iv   NA "integer ctrlr branch overflow set")
4907 (conditional-branch-ctrlr bc nv  I OP_0E OPE3_03 Inv  NA "integer ctrlr branch overflow clear")
4908
4909 (dni fcbralr
4910      "float ctrlr branch always"
4911      ((UNIT B0) (FR500-MAJOR B-2) (FR400-MAJOR B-2) FR-ACCESS)
4912      "fcbralr$pack $ccond$hint_taken"
4913      (+ pack FCC_ra (FCCi_2-null) OP_0E hint_taken OPE3_07 ccond (s12-null))
4914      (sequence ()
4915                (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
4916                (ctrlr-branch-semantics (const BI 1) ccond))
4917      ((fr400 (unit u-branch))
4918       (fr500 (unit u-branch)))
4919 )
4920
4921 (dni fcbnolr
4922      "float ctrlr branch never"
4923      ((UNIT B0) (FR500-MAJOR B-2) (FR400-MAJOR B-2) FR-ACCESS)
4924      "fcbnolr$pack$hint_not_taken"
4925      (+ pack FCC_nev (FCCi_2-null) OP_0E hint_not_taken OPE3_07 (ccond-null) (s12-null))
4926      (sequence ()
4927                (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
4928                (ctrlr-branch-semantics (const BI 0) ccond))
4929      ((fr400 (unit u-branch))
4930       (fr500 (unit u-branch)))
4931 )
4932
4933 (conditional-branch-ctrlr fcb eq  F OP_0E OPE3_07 Feq  FR-ACCESS "float cclr branch equal")
4934 (conditional-branch-ctrlr fcb ne  F OP_0E OPE3_07 Fne  FR-ACCESS "float cclr branch not equal")
4935 (conditional-branch-ctrlr fcb lg  F OP_0E OPE3_07 Flg  FR-ACCESS "float branch less or greater")
4936 (conditional-branch-ctrlr fcb ue  F OP_0E OPE3_07 Fue  FR-ACCESS "float branch unordered or equal")
4937 (conditional-branch-ctrlr fcb ul  F OP_0E OPE3_07 Ful  FR-ACCESS "float branch unordered or less")
4938 (conditional-branch-ctrlr fcb ge  F OP_0E OPE3_07 Fge  FR-ACCESS "float branch greater or equal")
4939 (conditional-branch-ctrlr fcb lt  F OP_0E OPE3_07 Flt  FR-ACCESS "float branch less")
4940 (conditional-branch-ctrlr fcb uge F OP_0E OPE3_07 Fuge FR-ACCESS "float branch unordered, greater, equal")
4941 (conditional-branch-ctrlr fcb ug  F OP_0E OPE3_07 Fug  FR-ACCESS "float branch unordered or greater")
4942 (conditional-branch-ctrlr fcb le  F OP_0E OPE3_07 Fle  FR-ACCESS "float branch less or equal")
4943 (conditional-branch-ctrlr fcb gt  F OP_0E OPE3_07 Fgt  FR-ACCESS "float branch greater")
4944 (conditional-branch-ctrlr fcb ule F OP_0E OPE3_07 Fule FR-ACCESS "float branch unordered, less or equal")
4945 (conditional-branch-ctrlr fcb u   F OP_0E OPE3_07 Fu   FR-ACCESS "float branch unordered")
4946 (conditional-branch-ctrlr fcb o   F OP_0E OPE3_07 Fo   FR-ACCESS "float branch ordered")
4947
4948 (define-pmacro (jump-and-link-semantics base offset LI)
4949   (sequence ()
4950             (if (eq LI 1)
4951                 (c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1))
4952             ; Target address gets aligned here
4953             (set pc (and (add base offset) #xfffffffc))
4954             (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
4955 )
4956
4957 (dni jmpl
4958      "jump and link"
4959      ((UNIT I0) (FR500-MAJOR I-5) (FR400-MAJOR I-5))
4960      "jmpl$pack @($GRi,$GRj)"
4961      (+ pack (misc-null-1) (LI-off) OP_0C GRi (misc-null-2) GRj)
4962      (jump-and-link-semantics GRi GRj LI)
4963      ((fr400 (unit u-branch))
4964       (fr500 (unit u-branch)))
4965 )
4966
4967 (dni calll
4968      "call and link"
4969      ((UNIT I0) (FR500-MAJOR I-5) (FR400-MAJOR I-5))
4970      "calll$pack @($GRi,$GRj)"
4971      (+ pack (misc-null-1) (LI-on) OP_0C GRi (misc-null-2) GRj)
4972      (jump-and-link-semantics GRi GRj LI)
4973      ((fr400 (unit u-branch))
4974       (fr500 (unit u-branch)))
4975 )
4976
4977 (dni jmpil
4978      "jump immediate and link"
4979      ((UNIT I0) (FR500-MAJOR I-5) (FR400-MAJOR I-5))
4980      "jmpil$pack @($GRi,$s12)"
4981      (+ pack (misc-null-1) (LI-off) OP_0D GRi s12)
4982      (jump-and-link-semantics GRi s12 LI)
4983      ((fr400 (unit u-branch))
4984       (fr500 (unit u-branch)))
4985 )
4986
4987 (dni callil
4988      "call immediate and link"
4989      ((UNIT I0) (FR500-MAJOR I-5) (FR400-MAJOR I-5))
4990      "callil$pack @($GRi,$s12)"
4991      (+ pack (misc-null-1) (LI-on) OP_0D GRi s12)
4992      (jump-and-link-semantics GRi s12 LI)
4993      ((fr400 (unit u-branch))
4994       (fr500 (unit u-branch)))
4995 )
4996
4997 (dni call
4998      "call and link"
4999      ((UNIT B0) (FR500-MAJOR B-4) (FR400-MAJOR B-4))
5000      "call$pack $label24"
5001      (+ pack OP_0F label24)
5002      (sequence ()
5003                (c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1)
5004                (set pc label24)
5005                (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
5006      ((fr400 (unit u-branch))
5007       (fr500 (unit u-branch)))
5008 )
5009
5010 (dni rett
5011     "return from trap"
5012     ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2) PRIVILEGED)
5013     "rett$pack $debug"
5014     (+ pack (misc-null-1) debug OP_05 (rs-null) (s12-null))
5015     ; frv_rett handles operating vs user mode
5016     (sequence ()
5017               (set pc (c-call UWI "frv_rett" pc debug))
5018               (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
5019     ()
5020 )
5021
5022 (dni rei
5023      "run exception instruction"
5024      ((UNIT C) (FR500-MAJOR C-1) (MACH frv) PRIVILEGED)
5025      "rei$pack $eir"
5026      (+ pack (rd-null) OP_37 eir (s12-null))
5027      (nop) ; for now
5028      ()
5029 )
5030
5031 (define-pmacro (trap-semantics cond base offset)
5032   (if cond
5033       (sequence ()
5034                 ; This is defered to frv_itrap because for the breakpoint
5035                 ; case we want to change as little of the machine state as
5036                 ; possible.
5037                 ;
5038                 ; PCSR=PC
5039                 ; PSR.PS=PSR.S
5040                 ; PSR.ET=0
5041                 ; if PSR.ESR==1
5042                 ;   SR0 through SR3=GR4 through GR7
5043                 ; TBR.TT=0x80 + ((GRi + s12) & 0x7f)
5044                 ; PC=TBR
5045                 ; We still should indicate what is modified by this insn.
5046                 (clobber (spr-pcsr))
5047                 (clobber psr_ps)
5048                 (clobber psr_et)
5049                 (clobber tbr_tt)
5050                 (if (ne psr_esr (const 0))
5051                     (sequence ()
5052                               (clobber (spr-sr0))
5053                               (clobber (spr-sr1))
5054                               (clobber (spr-sr2))
5055                               (clobber (spr-sr3))))
5056                 ; frv_itrap handles operating vs user mode
5057                 (c-call VOID "frv_itrap" pc base offset)))
5058 )
5059
5060 (define-pmacro (trap-r prefix cc i-f op ope cond attr comment)
5061   (dni (.sym prefix cc)
5062        (comment)
5063        ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) attr)
5064        (.str (.sym prefix cc) "$pack $" i-f "CCi_2,$GRi,$GRj")
5065        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op GRi (misc-null-3) ope GRj)
5066        (trap-semantics (cond (.sym i-f CCi_2)) GRi GRj)
5067        ((fr400 (unit u-trap))
5068         (fr500 (unit u-trap)))
5069   )
5070 )
5071
5072 (dni tra
5073      "integer trap always"
5074      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1))
5075      "tra$pack $GRi,$GRj"
5076      (+ pack ICC_ra (ICCi_2-null) OP_04 GRi (misc-null-3) OPE4_0 GRj)
5077      (trap-semantics (const BI 1) GRi GRj)
5078      ((fr400 (unit u-trap))
5079       (fr500 (unit u-trap)))
5080 )
5081
5082 (dni tno
5083      "integer trap never"
5084      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1))
5085      "tno$pack"
5086      (+ pack ICC_nev (ICCi_2-null) OP_04 (GRi-null) (misc-null-3) OPE4_0 (GRj-null))
5087      (trap-semantics (const BI 0) GRi GRj)
5088      ((fr400 (unit u-trap))
5089       (fr500 (unit u-trap)))
5090 )
5091
5092 (trap-r t eq  I OP_04 OPE4_0 Ieq  NA "integer trap equal")
5093 (trap-r t ne  I OP_04 OPE4_0 Ine  NA "integer trap not equal")
5094 (trap-r t le  I OP_04 OPE4_0 Ile  NA "integer trap less or equal")
5095 (trap-r t gt  I OP_04 OPE4_0 Igt  NA "integer trap greater")
5096 (trap-r t lt  I OP_04 OPE4_0 Ilt  NA "integer trap less")
5097 (trap-r t ge  I OP_04 OPE4_0 Ige  NA "integer trap greater or equal")
5098 (trap-r t ls  I OP_04 OPE4_0 Ils  NA "integer trap less or equal unsigned")
5099 (trap-r t hi  I OP_04 OPE4_0 Ihi  NA "integer trap greater unsigned")
5100 (trap-r t c   I OP_04 OPE4_0 Ic   NA "integer trap carry set")
5101 (trap-r t nc  I OP_04 OPE4_0 Inc  NA "integer trap carry clear")
5102 (trap-r t n   I OP_04 OPE4_0 In   NA "integer trap negative")
5103 (trap-r t p   I OP_04 OPE4_0 Ip   NA "integer trap positive")
5104 (trap-r t v   I OP_04 OPE4_0 Iv   NA "integer trap overflow set")
5105 (trap-r t nv  I OP_04 OPE4_0 Inv  NA "integer trap overflow clear")
5106
5107 (dni ftra
5108      "float trap always"
5109      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) FR-ACCESS)
5110      "ftra$pack $GRi,$GRj"
5111      (+ pack FCC_ra (FCCi_2-null) OP_04 GRi (misc-null-3) OPE4_1 GRj)
5112      (trap-semantics (const BI 1) GRi GRj)
5113      ((fr400 (unit u-trap))
5114       (fr500 (unit u-trap)))
5115 )
5116
5117 (dni ftno
5118      "flost trap never"
5119      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) FR-ACCESS)
5120      "ftno$pack"
5121      (+ pack FCC_nev (FCCi_2-null) OP_04 (GRi-null) (misc-null-3) OPE4_1 (GRj-null))
5122      (trap-semantics (const BI 0) GRi GRj)
5123      ((fr400 (unit u-trap))
5124       (fr500 (unit u-trap)))
5125 )
5126
5127 (trap-r ft ne  F OP_04 OPE4_1 Fne  FR-ACCESS "float trap not equal")
5128 (trap-r ft eq  F OP_04 OPE4_1 Feq  FR-ACCESS "float trap equal")
5129 (trap-r ft lg  F OP_04 OPE4_1 Flg  FR-ACCESS "float trap greater or less")
5130 (trap-r ft ue  F OP_04 OPE4_1 Fue  FR-ACCESS "float trap unordered or equal")
5131 (trap-r ft ul  F OP_04 OPE4_1 Ful  FR-ACCESS "float trap unordered or less")
5132 (trap-r ft ge  F OP_04 OPE4_1 Fge  FR-ACCESS "float trap greater or equal")
5133 (trap-r ft lt  F OP_04 OPE4_1 Flt  FR-ACCESS "float trap less")
5134 (trap-r ft uge F OP_04 OPE4_1 Fuge FR-ACCESS "float trap unordered greater or equal")
5135 (trap-r ft ug  F OP_04 OPE4_1 Fug  FR-ACCESS "float trap unordered or greater")
5136 (trap-r ft le  F OP_04 OPE4_1 Fle  FR-ACCESS "float trap less or equal")
5137 (trap-r ft gt  F OP_04 OPE4_1 Fgt  FR-ACCESS "float trap greater")
5138 (trap-r ft ule F OP_04 OPE4_1 Fule FR-ACCESS "float trap unordered less or equal")
5139 (trap-r ft u   F OP_04 OPE4_1 Fu   FR-ACCESS "float trap unordered")
5140 (trap-r ft o   F OP_04 OPE4_1 Fo   FR-ACCESS "float trap ordered")
5141
5142 (define-pmacro (trap-immed prefix cc i-f op cond attr comment)
5143   (dni (.sym prefix cc)
5144        (comment)
5145        ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) attr)
5146        (.str (.sym prefix cc) "$pack $" i-f "CCi_2,$GRi,$s12")
5147        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op GRi s12)
5148        (trap-semantics (cond (.sym i-f CCi_2)) GRi s12)
5149        ((fr400 (unit u-trap))
5150         (fr500 (unit u-trap)))
5151   )
5152 )
5153
5154 (dni tira
5155      "integer trap always"
5156      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1))
5157      "tira$pack $GRi,$s12"
5158      (+ pack ICC_ra (ICCi_2-null) OP_1C GRi s12)
5159      (trap-semantics (const BI 1) GRi s12)
5160      ((fr400 (unit u-trap))
5161       (fr500 (unit u-trap)))
5162 )
5163
5164 (dni tino
5165      "integer trap never"
5166      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1))
5167      "tino$pack"
5168      (+ pack ICC_nev (ICCi_2-null) OP_1C (GRi-null) (s12-null))
5169      (trap-semantics (const BI 0) GRi s12)
5170      ((fr400 (unit u-trap))
5171       (fr500 (unit u-trap)))
5172 )
5173
5174 (trap-immed ti eq  I OP_1C Ieq  NA "integer trap equal")
5175 (trap-immed ti ne  I OP_1C Ine  NA "integer trap not equal")
5176 (trap-immed ti le  I OP_1C Ile  NA "integer trap less or equal")
5177 (trap-immed ti gt  I OP_1C Igt  NA "integer trap greater")
5178 (trap-immed ti lt  I OP_1C Ilt  NA "integer trap less")
5179 (trap-immed ti ge  I OP_1C Ige  NA "integer trap greater or equal")
5180 (trap-immed ti ls  I OP_1C Ils  NA "integer trap less or equal unsigned")
5181 (trap-immed ti hi  I OP_1C Ihi  NA "integer trap greater unsigned")
5182 (trap-immed ti c   I OP_1C Ic   NA "integer trap carry set")
5183 (trap-immed ti nc  I OP_1C Inc  NA "integer trap carry clear")
5184 (trap-immed ti n   I OP_1C In   NA "integer trap negative")
5185 (trap-immed ti p   I OP_1C Ip   NA "integer trap positive")
5186 (trap-immed ti v   I OP_1C Iv   NA "integer trap overflow set")
5187 (trap-immed ti nv  I OP_1C Inv  NA "integer trap overflow clear")
5188
5189 (dni ftira
5190      "float trap always"
5191      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) FR-ACCESS)
5192      "ftira$pack $GRi,$s12"
5193      (+ pack FCC_ra (ICCi_2-null) OP_1D GRi s12)
5194      (trap-semantics (const BI 1) GRi s12)
5195      ((fr400 (unit u-trap))
5196       (fr500 (unit u-trap)))
5197 )
5198
5199 (dni ftino
5200      "float trap never"
5201      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) FR-ACCESS)
5202      "ftino$pack"
5203      (+ pack FCC_nev (FCCi_2-null) OP_1D (GRi-null) (s12-null))
5204      (trap-semantics (const BI 0) GRi s12)
5205      ((fr400 (unit u-trap))
5206       (fr500 (unit u-trap)))
5207 )
5208
5209 (trap-immed fti ne  F OP_1D Fne  FR-ACCESS "float trap not equal")
5210 (trap-immed fti eq  F OP_1D Feq  FR-ACCESS "float trap equal")
5211 (trap-immed fti lg  F OP_1D Flg  FR-ACCESS "float trap greater or less")
5212 (trap-immed fti ue  F OP_1D Fue  FR-ACCESS "float trap unordered or equal")
5213 (trap-immed fti ul  F OP_1D Ful  FR-ACCESS "float trap unordered or less")
5214 (trap-immed fti ge  F OP_1D Fge  FR-ACCESS "float trap greater or equal")
5215 (trap-immed fti lt  F OP_1D Flt  FR-ACCESS "float trap less")
5216 (trap-immed fti uge F OP_1D Fuge FR-ACCESS "float trap unordered greater or equal")
5217 (trap-immed fti ug  F OP_1D Fug  FR-ACCESS "float trap unordered or greater")
5218 (trap-immed fti le  F OP_1D Fle  FR-ACCESS "float trap less or equal")
5219 (trap-immed fti gt  F OP_1D Fgt  FR-ACCESS "float trap greater")
5220 (trap-immed fti ule F OP_1D Fule FR-ACCESS "float trap unordered less or equal")
5221 (trap-immed fti u   F OP_1D Fu   FR-ACCESS "float trap unordered")
5222 (trap-immed fti o   F OP_1D Fo   FR-ACCESS "float trap ordered")
5223
5224 (dni break
5225      "break trap"
5226      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1))
5227      "break$pack"
5228      (+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_3 (GRj-null))
5229      (sequence ()
5230                ; This is defered to frv_break because for the breakpoint
5231                ; case we want to change as little of the machine state as
5232                ; possible.
5233                ;
5234                ; BPCSR=PC
5235                ; BPSR.BS=PSR.S
5236                ; BPSR.BET=PSR.ET
5237                ; PSR.S=1
5238                ; PSR.ET=0
5239                ; TBR.TT=0xff
5240                ; PC=TBR
5241                ; We still should indicate what is modified by this insn.
5242                (clobber (spr-bpcsr))
5243                (clobber bpsr_bs)
5244                (clobber bpsr_bet)
5245                (clobber psr_s)
5246                (clobber psr_et)
5247                (clobber tbr_tt)
5248                (c-call VOID "frv_break"))
5249      ()
5250 )
5251
5252 (dni mtrap
5253      "media trap"
5254      ((UNIT C) (FR500-MAJOR C-1) (FR400-MAJOR C-1) FR-ACCESS)
5255      "mtrap$pack"
5256      (+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_2 (GRj-null))
5257      (c-call VOID "frv_mtrap")
5258      ()
5259 )
5260
5261 (define-pmacro (condition-code-logic name operation ope comment)
5262   (dni name
5263        (comment)
5264        ((UNIT B01) (FR500-MAJOR B-6) (FR400-MAJOR B-6))
5265        (.str name "$pack $CRi,$CRj,$CRk")
5266        (+ pack (misc-null-6) CRk OP_0A (misc-null-7) CRi ope (misc-null-8) CRj)
5267        (set CRk (c-call UQI "@cpu@_cr_logic" operation CRi CRj))
5268        ()
5269   )
5270 )
5271 (define-pmacro (op-andcr)   0)
5272 (define-pmacro (op-orcr)    1)
5273 (define-pmacro (op-xorcr)   2)
5274 (define-pmacro (op-nandcr)  3)
5275 (define-pmacro (op-norcr)   4)
5276 (define-pmacro (op-andncr)  5)
5277 (define-pmacro (op-orncr)   6)
5278 (define-pmacro (op-nandncr) 7)
5279 (define-pmacro (op-norncr)  8)
5280
5281 (define-pmacro (cr-true)  3)
5282 (define-pmacro (cr-false) 2)
5283 (define-pmacro (cr-undefined) 0)
5284
5285 (condition-code-logic andcr   (op-andcr)   OPE1_08 "and   condition code regs")
5286 (condition-code-logic orcr    (op-orcr)    OPE1_09 "or    condition code regs")
5287 (condition-code-logic xorcr   (op-xorcr)   OPE1_0A "xor   condition code regs")
5288 (condition-code-logic nandcr  (op-nandcr)  OPE1_0C "nand  condition code regs")
5289 (condition-code-logic norcr   (op-norcr)   OPE1_0D "nor   condition code regs")
5290 (condition-code-logic andncr  (op-andncr)  OPE1_10 "andn  condition code regs")
5291 (condition-code-logic orncr   (op-orncr)   OPE1_11 "orn   condition code regs")
5292 (condition-code-logic nandncr (op-nandncr) OPE1_14 "nandn condition code regs")
5293 (condition-code-logic norncr  (op-norncr)  OPE1_15 "norn  condition code regs")
5294
5295 (dni notcr
5296      ("not cccr register")
5297      ((UNIT B01) (FR500-MAJOR B-6) (FR400-MAJOR B-6))
5298      (.str notcr "$pack $CRj,$CRk")
5299      (+ pack (misc-null-6) CRk OP_0A (rs-null) OPE1_0B (misc-null-8) CRj)
5300      (set CRk (xor CRj 1))
5301      ()
5302 )
5303
5304 (define-pmacro (check-semantics cond cr)
5305   (if cond (set cr (cr-true)) (set cr (cr-false)))
5306 )
5307
5308 (define-pmacro (check-int-condition-code prefix cc op cond comment)
5309   (dni (.sym prefix cc)
5310        (comment)
5311        ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5))
5312        (.str (.sym prefix cc) "$pack $ICCi_3,$CRj_int")
5313        (+ pack (.sym ICC_ cc) CRj_int op (misc-null-5) ICCi_3)
5314        (check-semantics (cond ICCi_3) CRj_int)
5315        ((fr400 (unit u-check))
5316         (fr500 (unit u-check)))
5317   )
5318 )
5319
5320 (dni ckra
5321      "check integer cc always"
5322      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5))
5323      "ckra$pack $CRj_int"
5324      (+ pack ICC_ra CRj_int OP_08 (misc-null-5) (ICCi_3-null))
5325      (check-semantics (const BI 1) CRj_int)
5326      ((fr400 (unit u-check))
5327       (fr500 (unit u-check)))
5328 )
5329
5330 (dni ckno
5331      "check integer cc never"
5332      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5))
5333      "ckno$pack $CRj_int"
5334      (+ pack ICC_nev CRj_int OP_08 (misc-null-5) (ICCi_3-null))
5335      (check-semantics (const BI 0) CRj_int)
5336      ((fr400 (unit u-check))
5337       (fr500 (unit u-check)))
5338 )
5339
5340 (check-int-condition-code ck eq  OP_08 Ieq  "check integer cc equal")
5341 (check-int-condition-code ck ne  OP_08 Ine  "check integer cc not equal")
5342 (check-int-condition-code ck le  OP_08 Ile  "check integer cc less or equal")
5343 (check-int-condition-code ck gt  OP_08 Igt  "check integer cc greater")
5344 (check-int-condition-code ck lt  OP_08 Ilt  "check integer cc less")
5345 (check-int-condition-code ck ge  OP_08 Ige  "check integer cc greater or equal")
5346 (check-int-condition-code ck ls  OP_08 Ils  "check integer cc less or equal unsigned")
5347 (check-int-condition-code ck hi  OP_08 Ihi  "check integer cc greater unsigned")
5348 (check-int-condition-code ck c   OP_08 Ic   "check integer cc carry set")
5349 (check-int-condition-code ck nc  OP_08 Inc  "check integer cc carry clear")
5350 (check-int-condition-code ck n   OP_08 In   "check integer cc negative")
5351 (check-int-condition-code ck p   OP_08 Ip   "check integer cc positive")
5352 (check-int-condition-code ck v   OP_08 Iv   "check integer cc overflow set")
5353 (check-int-condition-code ck nv  OP_08 Inv  "check integer cc overflow clear")
5354
5355 (define-pmacro (check-float-condition-code prefix cc op cond comment)
5356   (dni (.sym prefix cc)
5357        (comment)
5358        ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) FR-ACCESS)
5359        (.str (.sym prefix cc) "$pack $FCCi_3,$CRj_float")
5360        (+ pack (.sym FCC_ cc) CRj_float op (misc-null-5) FCCi_3)
5361        (check-semantics (cond FCCi_3) CRj_float)
5362        ((fr400 (unit u-check))
5363         (fr500 (unit u-check)))
5364   )
5365 )
5366
5367 (dni fckra
5368      "check float cc always"
5369      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) FR-ACCESS)
5370      "fckra$pack $CRj_float"
5371      (+ pack FCC_ra CRj_float OP_09 (misc-null-5) FCCi_3)
5372      (check-semantics (const BI 1) CRj_float)
5373      ((fr400 (unit u-check))
5374       (fr500 (unit u-check)))
5375 )
5376
5377 (dni fckno
5378      "check float cc never"
5379      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) FR-ACCESS)
5380      "fckno$pack $CRj_float"
5381      (+ pack FCC_nev CRj_float OP_09 (misc-null-5) FCCi_3)
5382      (check-semantics (const BI 0) CRj_float)
5383      ((fr400 (unit u-check))
5384       (fr500 (unit u-check)))
5385 )
5386
5387 (check-float-condition-code fck ne  OP_09 Fne  "check float cc not equal")
5388 (check-float-condition-code fck eq  OP_09 Feq  "check float cc equal")
5389 (check-float-condition-code fck lg  OP_09 Flg  "check float cc greater or less")
5390 (check-float-condition-code fck ue  OP_09 Fue  "check float cc unordered or equal")
5391 (check-float-condition-code fck ul  OP_09 Ful  "check float cc unordered or less")
5392 (check-float-condition-code fck ge  OP_09 Fge  "check float cc greater or equal")
5393 (check-float-condition-code fck lt  OP_09 Flt  "check float cc less")
5394 (check-float-condition-code fck uge OP_09 Fuge "check float cc unordered greater or equal")
5395 (check-float-condition-code fck ug  OP_09 Fug  "check float cc unordered or greater")
5396 (check-float-condition-code fck le  OP_09 Fle  "check float cc less or equal")
5397 (check-float-condition-code fck gt  OP_09 Fgt  "check float cc greater")
5398 (check-float-condition-code fck ule OP_09 Fule "check float cc unordered less or equal")
5399 (check-float-condition-code fck u   OP_09 Fu   "check float cc unordered")
5400 (check-float-condition-code fck o   OP_09 Fo   "check float cc ordered")
5401
5402 (define-pmacro (conditional-check-int-condition-code prefix cc op ope test comment)
5403   (dni (.sym prefix cc)
5404        (comment)
5405        ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) CONDITIONAL)
5406        (.str (.sym prefix cc) "$pack $ICCi_3,$CRj_int,$CCi,$cond")
5407        (+ pack (.sym ICC_ cc) CRj_int op (rs-null) CCi cond ope
5408           (misc-null-9) ICCi_3)
5409        (if (eq CCi (or cond 2))
5410            (check-semantics (test ICCi_3) CRj_int)
5411            (set CRj_int (cr-undefined)))
5412        ((fr400 (unit u-check))
5413         (fr500 (unit u-check)))
5414   )
5415 )
5416
5417 (dni cckra
5418      "conditional check integer cc always"
5419      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) CONDITIONAL)
5420      "cckra$pack $CRj_int,$CCi,$cond"
5421      (+ pack ICC_ra CRj_int OP_6A (rs-null) CCi cond OPE4_0
5422         (misc-null-9) (ICCi_3-null))
5423      (if (eq CCi (or cond 2))
5424          (check-semantics (const BI 1) CRj_int)
5425          (set CRj_int (cr-undefined)))
5426      ((fr400 (unit u-check))
5427       (fr500 (unit u-check)))
5428 )
5429
5430 (dni cckno
5431      "conditional check integer cc never"
5432      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) CONDITIONAL)
5433      "cckno$pack $CRj_int,$CCi,$cond"
5434      (+ pack ICC_nev CRj_int OP_6A (rs-null) CCi cond OPE4_0
5435         (misc-null-9) (ICCi_3-null))
5436      (if (eq CCi (or cond 2))
5437          (check-semantics (const BI 0) CRj_int)
5438          (set CRj_int (cr-undefined)))
5439      ((fr400 (unit u-check))
5440       (fr500 (unit u-check)))
5441 )
5442
5443 (conditional-check-int-condition-code cck eq  OP_6A OPE4_0 Ieq  "check integer cc equal")
5444 (conditional-check-int-condition-code cck ne  OP_6A OPE4_0 Ine  "check integer cc not equal")
5445 (conditional-check-int-condition-code cck le  OP_6A OPE4_0 Ile  "check integer cc less or equal")
5446 (conditional-check-int-condition-code cck gt  OP_6A OPE4_0 Igt  "check integer cc greater")
5447 (conditional-check-int-condition-code cck lt  OP_6A OPE4_0 Ilt  "check integer cc less")
5448 (conditional-check-int-condition-code cck ge  OP_6A OPE4_0 Ige  "check integer cc greater or equal")
5449 (conditional-check-int-condition-code cck ls  OP_6A OPE4_0 Ils  "check integer cc less or equal unsigned")
5450 (conditional-check-int-condition-code cck hi  OP_6A OPE4_0 Ihi  "check integer cc greater unsigned")
5451 (conditional-check-int-condition-code cck c   OP_6A OPE4_0 Ic   "check integer cc carry set")
5452 (conditional-check-int-condition-code cck nc  OP_6A OPE4_0 Inc  "check integer cc carry clear")
5453 (conditional-check-int-condition-code cck n   OP_6A OPE4_0 In   "check integer cc negative")
5454 (conditional-check-int-condition-code cck p   OP_6A OPE4_0 Ip   "check integer cc positive")
5455 (conditional-check-int-condition-code cck v   OP_6A OPE4_0 Iv   "check integer cc overflow set")
5456 (conditional-check-int-condition-code cck nv  OP_6A OPE4_0 Inv  "check integer cc overflow clear")
5457
5458 (define-pmacro (conditional-check-float-condition-code prefix cc op ope test comment)
5459   (dni (.sym prefix cc)
5460        (comment)
5461        ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) CONDITIONAL FR-ACCESS)
5462        (.str (.sym prefix cc) "$pack $FCCi_3,$CRj_float,$CCi,$cond")
5463        (+ pack (.sym FCC_ cc) CRj_float op (rs-null) CCi cond ope
5464           (misc-null-9) FCCi_3)
5465        (if (eq CCi (or cond 2))
5466            (check-semantics (test FCCi_3) CRj_float)
5467            (set CRj_float (cr-undefined)))
5468        ((fr400 (unit u-check))
5469         (fr500 (unit u-check)))
5470   )
5471 )
5472
5473 (dni cfckra
5474      "conditional check float cc always"
5475      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) CONDITIONAL FR-ACCESS)
5476      "cfckra$pack $CRj_float,$CCi,$cond"
5477      (+ pack FCC_ra CRj_float OP_6A (rs-null) CCi cond OPE4_1
5478         (misc-null-9) (FCCi_3-null))
5479      (if (eq CCi (or cond 2))
5480          (check-semantics (const BI 1) CRj_float)
5481          (set CRj_float (cr-undefined)))
5482      ((fr400 (unit u-check))
5483       (fr500 (unit u-check)))
5484 )
5485
5486 (dni cfckno
5487      "conditional check float cc never"
5488      ((UNIT B01) (FR500-MAJOR B-5) (FR400-MAJOR B-5) CONDITIONAL FR-ACCESS)
5489      "cfckno$pack $CRj_float,$CCi,$cond"
5490      (+ pack FCC_nev CRj_float OP_6A (rs-null) CCi cond OPE4_1
5491         (misc-null-9) (FCCi_3-null))
5492      (if (eq CCi (or cond 2))
5493          (check-semantics (const BI 0) CRj_float)
5494          (set CRj_float (cr-undefined)))
5495      ((fr400 (unit u-check))
5496       (fr500 (unit u-check)))
5497 )
5498
5499 (conditional-check-float-condition-code cfck ne  OP_6A OPE4_1 Fne  "check float cc not equal")
5500 (conditional-check-float-condition-code cfck eq  OP_6A OPE4_1 Feq  "check float cc equal")
5501 (conditional-check-float-condition-code cfck lg  OP_6A OPE4_1 Flg  "check float cc greater or less")
5502 (conditional-check-float-condition-code cfck ue  OP_6A OPE4_1 Fue  "check float cc unordered or equal")
5503 (conditional-check-float-condition-code cfck ul  OP_6A OPE4_1 Ful  "check float cc unordered or less")
5504 (conditional-check-float-condition-code cfck ge  OP_6A OPE4_1 Fge  "check float cc greater or equal")
5505 (conditional-check-float-condition-code cfck lt  OP_6A OPE4_1 Flt  "check float cc less")
5506 (conditional-check-float-condition-code cfck uge OP_6A OPE4_1 Fuge "check float cc unordered greater or equal")
5507 (conditional-check-float-condition-code cfck ug  OP_6A OPE4_1 Fug  "check float cc unordered or greater")
5508 (conditional-check-float-condition-code cfck le  OP_6A OPE4_1 Fle  "check float cc less or equal")
5509 (conditional-check-float-condition-code cfck gt  OP_6A OPE4_1 Fgt  "check float cc greater")
5510 (conditional-check-float-condition-code cfck ule OP_6A OPE4_1 Fule "check float cc unordered less or equal")
5511 (conditional-check-float-condition-code cfck u   OP_6A OPE4_1 Fu   "check float cc unordered")
5512 (conditional-check-float-condition-code cfck o   OP_6A OPE4_1 Fo   "check float cc ordered")
5513
5514 (dni cjmpl
5515      "conditional jump and link"
5516      ((UNIT I0) (FR500-MAJOR I-5) (FR400-MAJOR I-5) CONDITIONAL)
5517      "cjmpl$pack @($GRi,$GRj),$CCi,$cond"
5518      (+ pack (misc-null-1) (LI-off) OP_6A GRi CCi cond OPE4_2 GRj)
5519      (if (eq CCi (or cond 2))
5520          (jump-and-link-semantics GRi GRj LI))
5521      ((fr400 (unit u-branch))
5522       (fr500 (unit u-branch)))
5523 )
5524
5525 (dni ccalll
5526      "conditional call and link"
5527      ((UNIT I0) (FR500-MAJOR I-5) (FR400-MAJOR I-5) CONDITIONAL)
5528      "ccalll$pack @($GRi,$GRj),$CCi,$cond"
5529      (+ pack (misc-null-1) (LI-on) OP_6A GRi CCi cond OPE4_2 GRj)
5530      (if (eq CCi (or cond 2))
5531          (jump-and-link-semantics GRi GRj LI))
5532      ((fr400 (unit u-branch))
5533       (fr500 (unit u-branch)))
5534 )
5535
5536 (define-pmacro (cache-invalidate name cache all op ope profile comment)
5537   (dni name
5538        (comment)
5539        ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
5540        (.str name "$pack @($GRi,$GRj)")
5541        (+ pack (rd-null) op GRi ope GRj)
5542        (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) all)
5543        profile
5544   )
5545 )
5546
5547 (cache-invalidate ici insn 0 OP_03 OPE1_38
5548                   ((fr400 (unit u-ici)) (fr500 (unit u-ici)))
5549                   "invalidate insn cache")
5550 (cache-invalidate dci data 0 OP_03 OPE1_3C
5551                   ((fr400 (unit u-dci)) (fr500 (unit u-dci)))
5552                   "invalidate data cache")
5553
5554 (define-pmacro (cache-invalidate-entry name cache op ope profile comment)
5555   (dni name
5556        (comment)
5557        ((UNIT C) (FR400-MAJOR C-2) (MACH fr400))
5558        (.str name "$pack @($GRi,$GRj),$ae")
5559        (+ pack (misc-null-1) ae op GRi ope GRj)
5560        (if (eq ae 0)
5561            (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) -1) ; Invalid ae setting for this insn
5562            (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) ae))
5563        profile
5564   )
5565 )
5566
5567 (cache-invalidate-entry icei insn OP_03 OPE1_39
5568                         ((fr400 (unit u-ici)))
5569                         "invalidate insn cache entry")
5570 (cache-invalidate-entry dcei data OP_03 OPE1_3A
5571                         ((fr400 (unit u-dci)))
5572                         "invalidate data cache entry")
5573
5574 (dni dcf
5575      "Data cache flush"
5576      ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
5577      "dcf$pack @($GRi,$GRj)"
5578      (+ pack (rd-null) OP_03 GRi OPE1_3D GRj)
5579      (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) 0)
5580      ((fr400 (unit u-dcf))
5581       (fr500 (unit u-dcf)))
5582 )
5583
5584 (dni dcef
5585      "Data cache entry flush"
5586      ((UNIT C) (FR400-MAJOR C-2) (MACH fr400))
5587      "dcef$pack @($GRi,$GRj),$ae"
5588      (+ pack (misc-null-1) ae OP_03 GRi OPE1_3B GRj)
5589      (if (eq ae 0)
5590          (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) -1)
5591          (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) ae))
5592      ((fr400 (unit u-dcf)))
5593 )
5594
5595 (define-pmacro (write-TLB name insn op ope comment)
5596   (dni name
5597        (comment)
5598        ((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
5599        (.str insn "$pack $GRk,@($GRi,$GRj)")
5600        (+ pack GRk op GRi ope GRj)
5601        (nop) ; for now
5602        ()
5603   )
5604 )
5605
5606 (write-TLB witlb witlb OP_03 OPE1_32 "write for insn TLB")
5607 (write-TLB wdtlb wdtlb OP_03 OPE1_36 "write for data TLB")
5608
5609 (define-pmacro (invalidate-TLB name insn op ope comment)
5610   (dni name
5611        (comment)
5612        ((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
5613        (.str insn "$pack @($GRi,$GRj)")
5614        (+ pack (rd-null) op GRi ope GRj)
5615        (nop) ; for now
5616        ()
5617   )
5618 )
5619
5620 (invalidate-TLB itlbi itlbi OP_03 OPE1_33 "invalidate insn TLB")
5621 (invalidate-TLB dtlbi dtlbi OP_03 OPE1_37 "invalidate data TLB")
5622
5623 (define-pmacro (cache-preload name cache op ope profile comment)
5624   (dni name
5625        (comment)
5626        ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
5627        (.str name "$pack $GRi,$GRj,$lock")
5628        (+ pack (misc-null-1) lock op GRi ope GRj)
5629        (c-call VOID (.str "@cpu@_" cache "_cache_preload") GRi GRj lock)
5630        profile
5631   )
5632 )
5633
5634 (cache-preload icpl insn OP_03 OPE1_30
5635                ((fr400 (unit u-icpl)) (fr500 (unit u-icpl)))
5636                "preload insn cache")
5637 (cache-preload dcpl data OP_03 OPE1_34
5638                ((fr400 (unit u-dcpl)) (fr500 (unit u-dcpl)))
5639                "preload data cache")
5640
5641 (define-pmacro (cache-unlock name cache op ope profile comment)
5642   (dni name
5643        (comment)
5644        ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
5645        (.str name "$pack $GRi")
5646        (+ pack (rd-null) op GRi ope (GRj-null))
5647        (c-call VOID (.str "@cpu@_" cache "_cache_unlock") GRi)
5648        profile
5649   )
5650 )
5651
5652 (cache-unlock icul insn OP_03 OPE1_31
5653               ((fr400 (unit u-icul)) (fr500 (unit u-icul)))
5654               "unlock insn cache")
5655 (cache-unlock dcul data OP_03 OPE1_35
5656               ((fr400 (unit u-dcul)) (fr500 (unit u-dcul)))
5657               "unlock data cache")
5658
5659 (define-pmacro (barrier name insn op ope profile comment)
5660   (dni name
5661        (comment)
5662        ((UNIT C) (FR500-MAJOR C-2) (FR400-MAJOR C-2))
5663        (.str insn "$pack")
5664        (+ pack (rd-null) op (rs-null) ope (GRj-null))
5665        (nop) ; sufficient implementation
5666        profile
5667   )
5668 )
5669
5670 (barrier bar    bar    OP_03 OPE1_3E
5671          ((fr400 (unit u-barrier)) (fr500 (unit u-barrier)))
5672          "barrier")
5673 (barrier membar membar OP_03 OPE1_3F
5674          ((fr400 (unit u-membar)) (fr500 (unit u-membar)))
5675          "memory barrier")
5676
5677 ; Coprocessor operations
5678 (define-pmacro (cop-op num op)
5679   (dni (.sym cop num)
5680        "Coprocessor operation"
5681        ((UNIT C) (FR500-MAJOR C-2) (MACH frv))
5682        (.str "cop" num "$pack $s6_1,$CPRi,$CPRj,$CPRk")
5683        (+ pack CPRk op CPRi s6_1 CPRj)
5684        (nop) ; sufficient implementation
5685        ()
5686   )
5687 )
5688
5689 (cop-op 1 OP_7E)
5690 (cop-op 2 OP_7F)
5691
5692 (define-pmacro (clear-ne-flag-semantics target_index is_float)
5693   (c-call VOID "@cpu@_clear_ne_flags" target_index is_float)
5694 )
5695
5696 (define-pmacro (clear-ne-flag-r name op ope reg is_float attr comment)
5697   (dni name
5698        (comment)
5699        ((UNIT I01) (FR500-MAJOR I-6) (MACH simple,tomcat,fr500,frv) attr)
5700        (.str name "$pack $" reg "k")
5701        (+ pack (.sym reg k) op (rs-null) ope (GRj-null))
5702        (clear-ne-flag-semantics (index-of (.sym reg k)) is_float)
5703        ()
5704   )
5705 )
5706
5707 (clear-ne-flag-r clrgr OP_0A OPE1_00 GR 0 NA        "Clear GR NE flag")
5708 (clear-ne-flag-r clrfr OP_0A OPE1_02 FR 1 FR-ACCESS "Clear FR NE flag")
5709
5710 (define-pmacro (clear-ne-flag-all name op ope is_float attr comment)
5711   (dni name
5712        (comment)
5713        ((UNIT I01) (FR500-MAJOR I-6) (MACH simple,tomcat,fr500,frv) attr)
5714        (.str name "$pack")
5715        (+ pack (rd-null) op (rs-null) ope (GRj-null))
5716        (clear-ne-flag-semantics -1 is_float)
5717        ()
5718   )
5719 )
5720
5721 (clear-ne-flag-all clrga OP_0A OPE1_01 0 NA        "Clear GR NE flag ALL")
5722 (clear-ne-flag-all clrfa OP_0A OPE1_03 1 FR-ACCESS "Clear FR NE flag ALL")
5723
5724 (define-pmacro (commit-semantics target_index is_float)
5725   (c-call VOID "@cpu@_commit" target_index is_float)
5726 )
5727
5728 (define-pmacro (commit-r name op ope reg is_float attr comment)
5729   (dni name
5730        (comment)
5731        ((UNIT I01) (FR500-MAJOR I-6) (MACH frv,fr500) attr)
5732        (.str name "$pack $" reg "k")
5733        (+ pack (.sym reg k) op (rs-null) ope (GRj-null))
5734        (commit-semantics (index-of (.sym reg k)) is_float)
5735        ()
5736   )
5737 )
5738
5739 (commit-r commitgr OP_0A OPE1_04 GR 0 NA        "commit exceptions, specific GR")
5740 (commit-r commitfr OP_0A OPE1_06 FR 1 FR-ACCESS "commit exceptions, specific FR")
5741
5742 (define-pmacro (commit name op ope is_float attr comment)
5743   (dni name
5744        (comment)
5745        ((UNIT I01) (FR500-MAJOR I-6) (MACH frv,fr500) attr)
5746        (.str name "$pack")
5747        (+ pack (rd-null) op (rs-null) ope (GRj-null))
5748        (commit-semantics -1 is_float)
5749        ()
5750   )
5751 )
5752
5753 (commit commitga OP_0A OPE1_05 0 NA        "commit exceptions, any GR")
5754 (commit commitfa OP_0A OPE1_07 1 FR-ACCESS "commit exceptions, any FR")
5755
5756 (define-pmacro (floating-point-conversion
5757                 name op ope conv mode src targ attr comment)
5758   (dni name
5759        (comment)
5760        ((UNIT FM01) (FR500-MAJOR F-1) (MACH simple,tomcat,fr500,frv) attr)
5761        (.str name "$pack $" src ",$" targ)
5762        (+ pack targ op (rs-null) ope src)
5763        (set targ (conv mode src))
5764        ((fr500 (unit u-float-convert)))
5765   )
5766 )
5767
5768 (floating-point-conversion fitos OP_79 OPE1_00 float SF FRintj FRk NA "Convert Integer to Single")
5769 (floating-point-conversion fstoi OP_79 OPE1_01 fix   SI FRj FRintk NA "Convert Single  to Integer")
5770 (floating-point-conversion fitod OP_7A OPE1_00 float DF FRintj FRdoublek (MACH frv) "Convert Integer to Double")
5771 (floating-point-conversion fdtoi OP_7A OPE1_01 fix   SI FRdoublej FRintk (MACH frv) "Convert Double to Integer")
5772
5773 (define-pmacro (floating-point-dual-conversion
5774                 name op ope conv mode src src_hw targ targ_hw attr comment)
5775   (dni name
5776        (comment)
5777        ((MACH frv) (UNIT FM01) (FR500-MAJOR F-1) attr)
5778        (.str name "$pack $" src ",$" targ)
5779        (+ pack targ op (rs-null) ope src)
5780        (sequence ()
5781                  (set targ (conv mode src))
5782                  (set (nextreg targ_hw targ 1)
5783                       (conv mode (nextreg src_hw src 1))))
5784        ((fr500 (unit u-float-dual-convert)))
5785   )
5786 )
5787
5788 (floating-point-dual-conversion fditos OP_79 OPE1_10 float SF FRintj h-fr_int FRk h-fr NA "Dual Convert Integer to Single")
5789 (floating-point-dual-conversion fdstoi OP_79 OPE1_11 fix   SI FRj h-fr FRintk h-fr_int NA "Dual Convert Single  to Integer")
5790
5791 (define-pmacro (ne-floating-point-dual-conversion
5792                 name op ope conv mode src src_hw targ targ_hw attr comment)
5793   (dni name
5794        (comment)
5795        ((MACH frv) (UNIT FM01) (FR500-MAJOR F-1) NON-EXCEPTING attr)
5796        (.str name "$pack $" src ",$" targ)
5797        (+ pack targ op (rs-null) ope src)
5798        (sequence ()
5799                  (c-call VOID "@cpu@_set_ne_index" (index-of targ))
5800                  (set targ (conv mode src))
5801                  (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 1))
5802                  (set (nextreg targ_hw targ 1)
5803                       (conv mode (nextreg src_hw src 1))))
5804        ((fr500 (unit u-float-dual-convert)))
5805   )
5806 )
5807
5808 (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")
5809 (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")
5810
5811 (define-pmacro (conditional-floating-point-conversion
5812                 name op ope conv mode src targ comment)
5813   (dni name
5814        (comment)
5815        ((UNIT FM01) (FR500-MAJOR F-1) (MACH simple,tomcat,fr500,frv))
5816        (.str name "$pack $" src ",$" targ ",$CCi,$cond")
5817        (+ pack targ op (rs-null) CCi cond ope src)
5818        (if (eq CCi (or cond 2))
5819            (set targ (conv mode src)))
5820        ((fr500 (unit u-float-convert)))
5821   )
5822 )
5823
5824 (conditional-floating-point-conversion cfitos OP_6B OPE4_0 float SF FRintj FRk "Conditional convert Integer to Single")
5825 (conditional-floating-point-conversion cfstoi OP_6B OPE4_1 fix   SI FRj FRintk "Conditional convert Single to Integer")
5826
5827 (define-pmacro (ne-floating-point-conversion 
5828                 name op ope conv mode src targ comment)
5829   (dni name
5830        (comment)
5831        ((UNIT FM01) (FR500-MAJOR F-1) (MACH simple,tomcat,fr500,frv))
5832        (.str name "$pack $" src ",$" targ)
5833        (+ pack targ op (rs-null) ope src)
5834        (sequence ()
5835                  (c-call VOID "@cpu@_set_ne_index" (index-of targ))
5836                  (set targ (conv mode src)))
5837        ((fr500 (unit u-float-convert)))
5838   )
5839 )
5840
5841 (ne-floating-point-conversion nfitos OP_79 OPE1_20 float SF FRintj FRk "NE convert Integer to Single")
5842 (ne-floating-point-conversion nfstoi OP_79 OPE1_21 fix   SI FRj FRintk "NE convert Single to Integer")
5843
5844 (register-transfer fmovs OP_79 OPE1_02
5845                    FRj FRk FM01 (FR500-MAJOR F-1) NA
5846                    (MACH simple,tomcat,fr500,frv) NA
5847                    ((fr500 (unit u-fr2fr)))
5848                    "Move Single Float")
5849 (register-transfer fmovd OP_7A OPE1_02
5850                    ; TODO -- unit doesn't handle extra register
5851                    FRdoublej FRdoublek FM01 (FR500-MAJOR F-1) NA
5852                    (MACH frv) NA
5853                    ((fr500 (unit u-fr2fr)))
5854                    "Move Double Float")
5855
5856 (dni fdmovs
5857      "Dual move single float"
5858      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-1))
5859      "fdmovs$pack $FRj,$FRk"
5860      (+ pack FRk OP_79 (rs-null) OPE1_12 FRj)
5861      (sequence ()
5862                (set FRk FRj)
5863                (set (nextreg h-fr FRk 1) (nextreg h-fr FRj 1)))
5864      ; TODO -- unit doesn't handle extra register
5865      ((fr500 (unit u-fr2fr)))
5866 )
5867
5868 (conditional-register-transfer cfmovs OP_6C OPE4_0 FRj FRk FM01
5869                                (FR500-MAJOR F-1) NA
5870                                (MACH simple,tomcat,fr500,frv)
5871                                ((fr500 (unit u-fr2fr)))
5872                                "Conditional move Single Float")
5873
5874 (define-pmacro (floating-point-neg name src targ op ope attr comment)
5875   (dni name
5876        (comment)
5877        ((UNIT FM01) (FR500-MAJOR F-1) attr)
5878        (.str name "$pack $" src ",$" targ)
5879        (+ pack src op (rs-null) ope targ)
5880        (set targ (neg src))
5881        ((fr500 (unit u-float-arith)))
5882   )
5883 )
5884
5885 (floating-point-neg fnegs FRj FRk OP_79 OPE1_03 (MACH simple,tomcat,fr500,frv) "Floating point negate, single")
5886 (floating-point-neg fnegd FRdoublej FRdoublek OP_7A OPE1_03 (MACH frv) "Floating point negate, double")
5887
5888 (dni fdnegs
5889      "Floating point dual negate, single"
5890      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-1))
5891      "fdnegs$pack $FRj,$FRk"
5892      (+ pack FRk OP_79 (rs-null) OPE1_13 FRj)
5893      (sequence ()
5894                (set FRk (neg FRj))
5895                (set (nextreg h-fr FRk 1) (neg (nextreg h-fr FRj 1))))
5896      ((fr500 (unit u-float-dual-arith)))
5897 )
5898
5899 (dni cfnegs
5900      "Conditional floating point negate, single"
5901      ((UNIT FM01) (FR500-MAJOR F-1) (MACH simple,tomcat,fr500,frv))
5902      "cfnegs$pack $FRj,$FRk,$CCi,$cond"
5903      (+ pack FRj OP_6C (rs-null) CCi cond OPE4_1 FRk)
5904      (if (eq CCi (or cond 2))
5905          (set FRk (neg FRj)))
5906      ((fr500 (unit u-float-arith)))
5907 )
5908
5909 (define-pmacro (float-abs name src targ op ope attr comment)
5910   (dni name
5911        (comment)
5912        ((UNIT FM01) (FR500-MAJOR F-1) attr)
5913        (.str name "$pack $" src ",$" targ )
5914        (+ pack targ op (rs-null) ope src)
5915        (set targ (abs src))
5916        ((fr500 (unit u-float-arith)))
5917   )
5918 )
5919
5920 (float-abs fabss FRj FRk OP_79 OPE1_04 (MACH simple,tomcat,fr500,frv) "Float absolute value, single")
5921 (float-abs fabsd FRdoublej FRdoublek OP_7A OPE1_04 (MACH frv) "Float absolute value, double")
5922
5923 (dni fdabss
5924      "Floating point dual absolute value, single"
5925      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-1))
5926      "fdabss$pack $FRj,$FRk"
5927      (+ pack FRk OP_79 (rs-null) OPE1_14 FRj)
5928      (sequence ()
5929                (set FRk (abs FRj))
5930                (set (nextreg h-fr FRk 1) (abs (nextreg h-fr FRj 1))))
5931      ((fr500 (unit u-float-dual-arith)))
5932 )
5933
5934 (dni cfabss
5935      "Conditional floating point absolute value, single"
5936      ((UNIT FM01) (FR500-MAJOR F-1) (MACH simple,tomcat,fr500,frv))
5937      "cfabss$pack $FRj,$FRk,$CCi,$cond"
5938      (+ pack FRj OP_6C (rs-null) CCi cond OPE4_2 FRk)
5939      (if (eq CCi (or cond 2))
5940          (set FRk (abs FRj)))
5941      ((fr500 (unit u-float-arith)))
5942 )
5943
5944 (dni fsqrts
5945      "Square root single"
5946      ((UNIT FM01) (FR500-MAJOR F-4) (MACH simple,tomcat,fr500,frv))
5947      "fsqrts$pack $FRj,$FRk"
5948      (+ pack FRk OP_79 (rs-null) OPE1_05 FRj)
5949      (set FRk (sqrt SF FRj))
5950      ((fr500 (unit u-float-sqrt)))
5951 )
5952
5953 (dni fdsqrts
5954      "Dual square root single"
5955      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-4))
5956      "fdsqrts$pack $FRj,$FRk"
5957      (+ pack FRk OP_79 (rs-null) OPE1_15 FRj)
5958      (sequence ()
5959                (set FRk (sqrt SF FRj))
5960                (set (nextreg h-fr FRk 1) (sqrt (nextreg h-fr FRj 1))))
5961      ((fr500 (unit u-float-dual-sqrt)))
5962 )
5963
5964 (dni nfdsqrts
5965      "Non excepting Dual square root single"
5966      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-4) NON-EXCEPTING)
5967      "nfdsqrts$pack $FRj,$FRk"
5968      (+ pack FRk OP_79 (rs-null) OPE1_35 FRj)
5969      (sequence ()
5970                (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
5971                (set FRk (sqrt SF FRj))
5972                (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
5973                (set (nextreg h-fr FRk 1) (sqrt (nextreg h-fr FRj 1))))
5974      ((fr500 (unit u-float-dual-sqrt)))
5975 )
5976
5977 (dni fsqrtd
5978      "Square root double"
5979      ((UNIT FM01) (FR500-MAJOR F-4) (MACH frv))
5980      "fsqrtd$pack $FRdoublej,$FRdoublek"
5981      (+ pack FRdoublek OP_7A (rs-null) OPE1_05 FRdoublej)
5982      (set FRdoublek (sqrt DF FRdoublej))
5983      ((fr500 (unit u-float-sqrt)))
5984 )
5985
5986 (dni cfsqrts
5987      "Conditional square root single"
5988      ((UNIT FM01) (FR500-MAJOR F-4) (MACH simple,tomcat,fr500,frv))
5989      "cfsqrts$pack $FRj,$FRk,$CCi,$cond"
5990      (+ pack FRk OP_6E (rs-null) CCi cond OPE4_2 FRj)
5991      (if (eq CCi (or cond 2))
5992          (set FRk (sqrt SF FRj)))
5993      ((fr500 (unit u-float-sqrt)))
5994 )
5995
5996 (dni nfsqrts
5997      "Non exception square root, single"
5998      ((UNIT FM01) (FR500-MAJOR F-4) (MACH simple,tomcat,fr500,frv))
5999      "nfsqrts$pack $FRj,$FRk"
6000      (+ pack FRk OP_79 (rs-null) OPE1_25 FRj)
6001      (sequence ()
6002                (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6003                (set FRk (sqrt SF FRj)))
6004      ((fr500 (unit u-float-sqrt)))
6005 )
6006
6007 (define-pmacro (float-binary-op-s name operation op ope major comment)
6008   (dni name
6009        (comment)
6010        ((UNIT FM01) (FR500-MAJOR major) (MACH simple,tomcat,fr500,frv))
6011        (.str name "$pack $FRi,$FRj,$FRk")
6012        (+ pack FRk op FRi ope FRj)
6013        (set FRk (operation FRi FRj))
6014        ((fr500 (unit u-float-arith)))
6015   )
6016 )
6017
6018 (float-binary-op-s fadds add OP_79 OPE1_06 F-2 "add single float")
6019 (float-binary-op-s fsubs sub OP_79 OPE1_07 F-2 "sub single float")
6020 (float-binary-op-s fmuls mul OP_79 OPE1_08 F-3 "mul single float")
6021
6022 (dni fdivs
6023      "div single float"
6024      ((UNIT FM01) (FR500-MAJOR F-4) (MACH simple,tomcat,fr500,frv))
6025      "fdivs$pack $FRi,$FRj,$FRk"
6026      (+ pack FRk OP_79 FRi OPE1_09 FRj)
6027      (set FRk (div FRi FRj))
6028      ((fr500 (unit u-float-div)))
6029 )
6030
6031 (define-pmacro (float-binary-op-d name operation op ope major comment)
6032   (dni name
6033        (comment)
6034        ((UNIT FM01) (FR500-MAJOR major) (MACH frv))
6035        (.str name "$pack $FRdoublei,$FRdoublej,$FRdoublek")
6036        (+ pack FRdoublek op FRdoublei ope FRdoublej)
6037        (set FRdoublek (operation FRdoublei FRdoublej))
6038        ((fr500 (unit u-float-arith)))
6039   )
6040 )
6041
6042 (float-binary-op-d faddd add OP_7A OPE1_06 F-2 "add double float")
6043 (float-binary-op-d fsubd sub OP_7A OPE1_07 F-2 "sub double float")
6044 (float-binary-op-d fmuld mul OP_7A OPE1_08 F-3 "mul double float")
6045 (float-binary-op-d fdivd div OP_7A OPE1_09 F-4 "div double float")
6046
6047 (define-pmacro (conditional-float-binary-op name operation op ope major comment)
6048   (dni name
6049        (comment)
6050        ((UNIT FM01) (FR500-MAJOR major) (MACH simple,tomcat,fr500,frv))
6051        (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
6052        (+ pack FRk op FRi CCi cond ope FRj)
6053        (if (eq CCi (or cond 2))
6054            (set FRk (operation FRi FRj)))
6055        ((fr500 (unit u-float-arith)))
6056   )
6057 )
6058
6059 (conditional-float-binary-op cfadds add OP_6D OPE4_0 F-2 "cond add single")
6060 (conditional-float-binary-op cfsubs sub OP_6D OPE4_1 F-2 "cond sub single")
6061 (conditional-float-binary-op cfmuls mul OP_6E OPE4_0 F-3 "cond mul single")
6062 (conditional-float-binary-op cfdivs div OP_6E OPE4_1 F-4 "cond div single")
6063
6064 (define-pmacro (ne-float-binary-op name operation op ope major comment)
6065   (dni name
6066        (comment)
6067        ((UNIT FM01) (FR500-MAJOR major) (MACH simple,tomcat,fr500,frv))
6068        (.str name "$pack $FRi,$FRj,$FRk")
6069        (+ pack FRk op FRi ope FRj)
6070        (sequence ()
6071                  (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6072                  (set FRk (operation FRi FRj)))
6073        ((fr500 (unit u-float-arith)))
6074   )
6075 )
6076
6077 (ne-float-binary-op nfadds add OP_79 OPE1_26 F-2 "ne add single")
6078 (ne-float-binary-op nfsubs sub OP_79 OPE1_27 F-2 "ne sub single")
6079 (ne-float-binary-op nfmuls mul OP_79 OPE1_28 F-3 "ne mul single")
6080 (ne-float-binary-op nfdivs div OP_79 OPE1_29 F-4 "ne div single")
6081
6082 (define-pmacro (fcc-eq) 8)
6083 (define-pmacro (fcc-lt) 4)
6084 (define-pmacro (fcc-gt) 2)
6085 (define-pmacro (fcc-uo) 1)
6086
6087 (define-pmacro (compare-and-set-fcc arg1 arg2 fcc)
6088   (if (gt arg1 arg2)
6089       (set fcc (fcc-gt))
6090       (if (eq arg1 arg2)
6091           (set fcc (fcc-eq))
6092           (if (lt arg1 arg2)
6093               (set fcc (fcc-lt))
6094               (set fcc (fcc-uo)))))
6095 )
6096
6097 (dni fcmps
6098      "compare single float"
6099      ((UNIT FM01) (FR500-MAJOR F-2) (MACH simple,tomcat,fr500,frv))
6100      "fcmps$pack $FRi,$FRj,$FCCi_2"
6101      (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_0A FRj)
6102      (compare-and-set-fcc FRi FRj FCCi_2)
6103      ((fr500 (unit u-float-compare)))
6104 )
6105
6106 (dni fcmpd
6107      "compare double float"
6108      ((UNIT FM01) (FR500-MAJOR F-2) (MACH frv))
6109      "fcmpd$pack $FRdoublei,$FRdoublej,$FCCi_2"
6110      (+ pack (cond-null) FCCi_2 OP_7A FRdoublei OPE1_0A FRdoublej)
6111      (compare-and-set-fcc FRdoublei FRdoublej FCCi_2)
6112      ((fr500 (unit u-float-compare)))
6113 )
6114
6115 (dni cfcmps
6116      "Conditional compare single, float"
6117      ((UNIT FM01) (FR500-MAJOR F-2) (MACH simple,tomcat,fr500,frv))
6118      "cfcmps$pack $FRi,$FRj,$FCCi_2,$CCi,$cond"
6119      (+ pack (cond-null) FCCi_2 OP_6D FRi CCi cond OPE4_2 FRj)
6120      (if (eq CCi (or cond 2))
6121          (compare-and-set-fcc FRi FRj FCCi_2))
6122      ((fr500 (unit u-float-compare)))
6123 )
6124
6125 (dni fdcmps
6126      "float dual compare single"
6127      ((UNIT FM01) (FR500-MAJOR F-6) (MACH simple,tomcat,fr500,frv))
6128      "fdcmps$pack $FRi,$FRj,$FCCi_2"
6129      (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_1A FRj)
6130      (sequence ()
6131                (compare-and-set-fcc FRi FRj FCCi_2)
6132                (compare-and-set-fcc (nextreg h-fr FRi 1) (nextreg h-fr FRj 1)
6133                                     (nextreg h-fccr FCCi_2 1)))
6134      ((fr500 (unit u-float-dual-compare)))
6135 )
6136
6137 (define-pmacro (float-mul-with-add name add_sub arg1 arg2 targ op ope comment)
6138   (dni name
6139        (comment)
6140        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
6141        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
6142        (+ pack targ op arg1 ope arg2)
6143        (set targ (add_sub (mul arg1 arg2) targ))
6144        ((fr500 (unit u-float-dual-arith)))
6145   )
6146 )
6147
6148 (float-mul-with-add fmadds add FRi FRj FRk OP_79 OPE1_0B "mul with add, single")
6149 (float-mul-with-add fmsubs sub FRi FRj FRk OP_79 OPE1_0C "mul with sub, single")
6150
6151 (float-mul-with-add fmaddd add FRdoublei FRdoublej FRdoublek OP_7A OPE1_0B "mul with add, double")
6152 (float-mul-with-add fmsubd sub FRdoublei FRdoublej FRdoublek OP_7A OPE1_0C "mul with sub, double")
6153
6154 (dni fdmadds
6155      "Float dual multiply with add"
6156      ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
6157      "fdmadds$pack $FRi,$FRj,$FRk"
6158      (+ pack FRk OP_79 FRi OPE1_1B FRj)
6159      (sequence ()
6160                (set FRk (add (mul FRi FRj) FRk))
6161                (set (nextreg h-fr FRk 1)
6162                     (add (mul (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))
6163                          (nextreg h-fr FRk 1))))
6164      ; TODO dual registers not referenced for profiling
6165      ((fr500 (unit u-float-dual-arith)))
6166 )
6167
6168 (dni nfdmadds
6169      "Non excepting float dual multiply with add"
6170      ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
6171      "nfdmadds$pack $FRi,$FRj,$FRk"
6172      (+ pack FRk OP_79 FRi OPE1_3B FRj)
6173      (sequence ()
6174                (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6175                (set FRk (add (mul FRi FRj) FRk))
6176                (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
6177                (set (nextreg h-fr FRk 1)
6178                     (add (mul (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))
6179                          (nextreg h-fr FRk 1))))
6180      ; TODO dual registers not referenced for profiling
6181      ((fr500 (unit u-float-dual-arith)))
6182 )
6183
6184 (define-pmacro (conditional-float-mul-with-add
6185                 name add_sub arg1 arg2 targ op ope comment)
6186   (dni name
6187        (comment)
6188        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv) CONDITIONAL)
6189        (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
6190        (+ pack FRk op FRi CCi cond ope FRj)
6191        (if (eq CCi (or cond 2))
6192            (set targ (add_sub (mul arg1 arg2) targ)))
6193        ((fr500 (unit u-float-dual-arith)))
6194   )
6195 )
6196
6197 (conditional-float-mul-with-add cfmadds add FRi FRj FRk OP_6F OPE4_0 "conditional mul with add, single")
6198 (conditional-float-mul-with-add cfmsubs sub FRi FRj FRk OP_6F OPE4_1 "conditional mul with sub, single")
6199
6200 (define-pmacro (ne-float-mul-with-add name add_sub arg1 arg2 targ op ope comment)
6201   (dni name
6202        (comment)
6203        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv) NON-EXCEPTING)
6204        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
6205        (+ pack targ op arg1 ope arg2)
6206        (sequence ()
6207                  (c-call VOID "@cpu@_set_ne_index" (index-of targ))
6208                  (set targ (add_sub (mul arg1 arg2) targ)))
6209        ((fr500 (unit u-float-dual-arith)))
6210   )
6211 )
6212
6213 (ne-float-mul-with-add nfmadds add FRi FRj FRk OP_79 OPE1_2B "non excepting mul with add, single")
6214 (ne-float-mul-with-add nfmsubs sub FRi FRj FRk OP_79 OPE1_2C "non excepting mul with sub, single")
6215
6216 (define-pmacro (float-parallel-mul-add-semantics cond add_sub arg1 arg2 targ)
6217   (if cond
6218       (sequence ()
6219                 (set targ (mul arg1 arg2))
6220                 (set (nextreg h-fr targ 1)
6221                      (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))))
6222 )
6223
6224 (define-pmacro (float-parallel-mul-add
6225                 name add_sub arg1 arg2 targ op ope comment)
6226   (dni name
6227        (comment)
6228        ((UNIT FM01) (FR500-MAJOR F-5) (MACH simple,tomcat,fr500,frv))
6229        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
6230        (+ pack targ op arg1 ope arg2)
6231        (float-parallel-mul-add-semantics 1 add_sub arg1 arg2 targ)
6232        ((fr500 (unit u-float-dual-arith)))
6233   )
6234 )
6235
6236 (float-parallel-mul-add fmas add FRi FRj FRk OP_79 OPE1_0E "parallel mul/add, single")
6237 (float-parallel-mul-add fmss sub FRi FRj FRk OP_79 OPE1_0F "parallel mul/sub, single")
6238
6239 (define-pmacro (float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
6240   (sequence ()
6241             (set targ (mul arg1 arg2))
6242             (set (nextreg h-fr targ 1)
6243                  (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))
6244             (set (nextreg h-fr targ 2)
6245                  (mul (nextreg h-fr arg1 2)     (nextreg h-fr arg2 2)))
6246             (set (nextreg h-fr targ 3)
6247                  (add_sub (nextreg h-fr arg1 3) (nextreg h-fr arg2 3))))
6248 )
6249
6250 (define-pmacro (float-dual-parallel-mul-add
6251                 name add_sub arg1 arg2 targ op ope comment)
6252   (dni name
6253        (comment)
6254        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
6255        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
6256        (+ pack targ op arg1 ope arg2)
6257        (float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
6258        ()
6259   )
6260 )
6261
6262 (float-dual-parallel-mul-add fdmas add FRi FRj FRk OP_79 OPE1_1C "dual parallel mul/add, single")
6263 (float-dual-parallel-mul-add fdmss sub FRi FRj FRk OP_79 OPE1_1D "dual parallel mul/sub, single")
6264
6265 (define-pmacro (ne-float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
6266   (sequence ()
6267             (c-call VOID "@cpu@_set_ne_index" (index-of targ))
6268             (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 1))
6269             (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 2))
6270             (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 3))
6271             (set targ (mul arg1 arg2))
6272             (set (nextreg h-fr targ 1)
6273                  (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))
6274             (set (nextreg h-fr targ 2)
6275                  (mul (nextreg h-fr arg1 2)     (nextreg h-fr arg2 2)))
6276             (set (nextreg h-fr targ 3)
6277                  (add_sub (nextreg h-fr arg1 3) (nextreg h-fr arg2 3))))
6278 )
6279
6280 (define-pmacro (ne-float-dual-parallel-mul-add
6281                 name add_sub arg1 arg2 targ op ope comment)
6282   (dni name
6283        (comment)
6284        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
6285        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
6286        (+ pack targ op arg1 ope arg2)
6287        (ne-float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
6288        ()
6289   )
6290 )
6291
6292 (ne-float-dual-parallel-mul-add nfdmas add FRi FRj FRk OP_79 OPE1_3C "non excepting dual parallel mul/add, single")
6293 (ne-float-dual-parallel-mul-add nfdmss sub FRi FRj FRk OP_79 OPE1_3D "non excepting dual parallel mul/sub, single")
6294
6295 (define-pmacro (conditional-float-parallel-mul-add name add_sub op ope comment)
6296   (dni name
6297        (comment)
6298        ((UNIT FM01) (FR500-MAJOR F-5) CONDITIONAL (MACH simple,tomcat,fr500,frv))
6299        (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
6300        (+ pack FRk op FRi CCi cond ope FRj)
6301        (float-parallel-mul-add-semantics (eq CCi (or cond 2))
6302                                          add_sub FRi FRj FRk)
6303        ((fr500 (unit u-float-dual-arith)))
6304   )
6305 )
6306
6307 (conditional-float-parallel-mul-add cfmas add OP_6F OPE4_2 "conditional parallel mul/add, single")
6308 (conditional-float-parallel-mul-add cfmss sub OP_6F OPE4_3 "conditional parallel mul/sub, single")
6309
6310 (define-pmacro (float-parallel-mul-add-double-semantics add_sub arg1 arg2 targ)
6311   (sequence ()
6312             (set targ (ftrunc SF (mul DF (fext DF arg1) (fext DF arg2))))
6313             (set (nextreg h-fr targ 1)
6314                  (ftrunc SF (add_sub DF
6315                                      (fext DF (nextreg h-fr arg1 1))
6316                                      (fext DF (nextreg h-fr arg2 1))))))
6317 )
6318
6319 (define-pmacro (float-parallel-mul-add-double
6320                 name add_sub arg1 arg2 targ op ope comment)
6321   (dni name
6322        (comment)
6323        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
6324        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
6325        (+ pack targ op arg1 ope arg2)
6326        (float-parallel-mul-add-double-semantics add_sub arg1 arg2 targ)
6327        ()
6328   )
6329 )
6330
6331 (float-parallel-mul-add-double fmad add FRi FRj FRk OP_7A OPE1_0E "parallel mul/add, double")
6332 (float-parallel-mul-add-double fmsd sub FRi FRj FRk OP_7A OPE1_0F "parallel mul/sub, double")
6333
6334 (define-pmacro (ne-float-parallel-mul-add name add_sub op ope comment)
6335   (dni name
6336        (comment)
6337        ((UNIT FM01) (FR500-MAJOR F-5) (MACH simple,tomcat,fr500,frv))
6338        (.str name "$pack $FRi,$FRj,$FRk")
6339        (+ pack FRk op FRi ope FRj)
6340        (sequence ()
6341                  (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6342                  (set FRk (mul FRi FRj))
6343                  (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
6344                  (set (nextreg h-fr FRk 1)
6345                       (add_sub (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
6346        ((fr500 (unit u-float-dual-arith)))
6347   )
6348 )
6349
6350 (ne-float-parallel-mul-add nfmas add OP_79 OPE1_2E "ne parallel mul/add,single")
6351 (ne-float-parallel-mul-add nfmss sub OP_79 OPE1_2F "ne parallel mul/sub,single")
6352
6353 (define-pmacro (float-dual-arith name major oper1 oper2 op ope attr comment)
6354   (dni name
6355        (comment)
6356        ((UNIT FM01) (FR500-MAJOR major) attr)
6357        (.str name "$pack $FRi,$FRj,$FRk")
6358        (+ pack FRk op FRi ope FRj)
6359        (sequence ()
6360                  (set FRk (oper1 FRi FRj))
6361                  (set (nextreg h-fr FRk 1)
6362                       (oper2 (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
6363        ((fr500 (unit u-float-dual-arith)))
6364   )
6365 )
6366
6367 (float-dual-arith fdadds F-6 add add OP_79 OPE1_16 (MACH simple,tomcat,fr500,frv) "dual add, single")
6368 (float-dual-arith fdsubs F-6 sub sub OP_79 OPE1_17 (MACH simple,tomcat,fr500,frv) "dual sub, single")
6369 (float-dual-arith fdmuls F-7 mul mul OP_79 OPE1_18 (MACH simple,tomcat,fr500,frv) "dual mul, single")
6370 (float-dual-arith fddivs F-7 div div OP_79 OPE1_19 (MACH frv) "dual div,single")
6371 (float-dual-arith fdsads F-6 add sub OP_79 OPE1_1E (MACH simple,tomcat,fr500,frv) "dual add/sub, single")
6372
6373 (dni fdmulcs
6374      "Float dual cross multiply single"
6375      ((UNIT FM01) (FR500-MAJOR F-7) (MACH simple,tomcat,fr500,frv))
6376      "fdmulcs$pack $FRi,$FRj,$FRk"
6377      (+ pack FRk OP_79 FRi OPE1_1F FRj)
6378      (sequence ()
6379                (set FRk (mul FRi (nextreg h-fr FRj 1)))
6380                (set (nextreg h-fr FRk 1) (mul (nextreg h-fr FRi 1) FRj)))
6381      ((fr500 (unit u-float-dual-arith)))
6382 )
6383
6384 (dni nfdmulcs
6385      "NE float dual cross multiply single"
6386      ((UNIT FM01) (FR500-MAJOR F-7) (MACH simple,tomcat,fr500,frv))
6387      "nfdmulcs$pack $FRi,$FRj,$FRk"
6388      (+ pack FRk OP_79 FRi OPE1_3F FRj)
6389      (sequence ()
6390                (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6391                (set FRk (mul FRi (nextreg h-fr FRj 1)))
6392                (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
6393                (set (nextreg h-fr FRk 1) (mul (nextreg h-fr FRi 1) FRj)))
6394      ((fr500 (unit u-float-dual-arith)))
6395 )
6396
6397 (define-pmacro (ne-float-dual-arith name major oper1 oper2 op ope attr comment)
6398   (dni name
6399        (comment)
6400        ((UNIT FM01) (FR500-MAJOR major) attr)
6401        (.str name "$pack $FRi,$FRj,$FRk")
6402        (+ pack FRk op FRi ope FRj)
6403        (sequence ()
6404                  (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6405                  (set FRk (oper1 FRi FRj))
6406                  (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
6407                  (set (nextreg h-fr FRk 1)
6408                       (oper2 (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
6409        ((fr500 (unit u-float-dual-arith)))
6410   )
6411 )
6412
6413 (ne-float-dual-arith nfdadds F-6 add add OP_79 OPE1_36 (MACH simple,tomcat,fr500,frv) "ne dual add, single")
6414 (ne-float-dual-arith nfdsubs F-6 sub sub OP_79 OPE1_37 (MACH simple,tomcat,fr500,frv) "ne dual sub, single")
6415 (ne-float-dual-arith nfdmuls F-7 mul mul OP_79 OPE1_38 (MACH simple,tomcat,fr500,frv) "ne dual mul, single")
6416 (ne-float-dual-arith nfddivs F-7 div div OP_79 OPE1_39 (MACH frv) "ne dual div,single")
6417 (ne-float-dual-arith nfdsads F-6 add sub OP_79 OPE1_3E (MACH simple,tomcat,fr500,frv) "ne dual add/sub, single")
6418
6419 (dni nfdcmps
6420      "non-excepting dual float compare"
6421      ((UNIT FM01) (FR500-MAJOR F-6) (MACH simple,tomcat,frv))
6422      "nfdcmps$pack $FRi,$FRj,$FCCi_2"
6423      (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_3A FRj)
6424      (sequence ()
6425                (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
6426                (compare-and-set-fcc FRi FRj FCCi_2)
6427                (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
6428                (compare-and-set-fcc (nextreg h-fr FRi 1) (nextreg h-fr FRj 1)
6429                                     (nextreg h-fccr FCCi_2 1)))
6430      ((fr500 (unit u-float-dual-compare)))
6431 )
6432
6433 ; Media Instructions
6434 ;
6435 (define-pmacro (halfword hilo arg offset)
6436   (reg (.sym h-fr_ hilo) (add (index-of arg) offset)))
6437
6438 (dni mhsetlos
6439      "Media set lower signed 12 bits"
6440      ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6441      "mhsetlos$pack $u12,$FRklo"
6442      (+ pack FRklo OP_78 OPE1_20 u12)
6443      (set FRklo u12)
6444      ((fr400 (unit u-media-hilo)))
6445 )
6446
6447 (dni mhsethis
6448      "Media set upper signed 12 bits"
6449      ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6450      "mhsethis$pack $u12,$FRkhi"
6451      (+ pack FRkhi OP_78 OPE1_22 u12)
6452      (set FRkhi u12)
6453      ((fr400 (unit u-media-hilo)))
6454 )
6455
6456 (dni mhdsets
6457      "Media dual set halfword signed 12 bits"
6458      ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6459      "mhdsets$pack $u12,$FRintk"
6460      (+ pack FRintk OP_78 OPE1_24 u12)
6461      (sequence ()
6462                ; hack to get FRintk passed to modelling functions
6463                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
6464                (set (halfword hi FRintk 0) u12)
6465                (set (halfword lo FRintk 0) u12))
6466      ((fr400 (unit u-media-1)))
6467 )
6468
6469 (define-pmacro (set-5-semantics target value)
6470   (sequence ((HI tmp))
6471             (set tmp target)
6472             (set tmp (and tmp #x07ff))
6473             (set tmp (or tmp (sll (and s5 #x1f) 11)))
6474             (set target tmp))
6475 )
6476
6477 (define-pmacro (media-set-5 name hilo op ope comment)
6478   (dni name
6479        (comment)
6480        ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6481        (.str name "$pack $s5,$FRk" hilo)
6482        (+ pack (.sym FRk hilo) op (FRi-null) ope (misc-null-11) s5)
6483        (set-5-semantics (.sym FRk hilo) s5)
6484        ((fr400 (unit u-media-hilo)))
6485   )
6486 )
6487
6488 (media-set-5 mhsetloh lo OP_78 OPE1_21 "Media set upper 5 bits lo")
6489 (media-set-5 mhsethih hi OP_78 OPE1_23 "Media set upper 5 bits hi")
6490
6491 (dni mhdseth
6492      "Media dual set halfword upper 5 bits"
6493      ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6494      "mhdseth$pack $s5,$FRintk"
6495      (+ pack FRintk OP_78 (FRi-null) OPE1_25 (misc-null-11) s5)
6496      (sequence ()
6497                ; hack to get FRintk passed to modelling functions
6498                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
6499                (set-5-semantics (halfword hi FRintk 0) s5)
6500                (set-5-semantics (halfword lo FRintk 0) s5))
6501      ((fr400 (unit u-media-1)))
6502 )
6503
6504 (define-pmacro (media-logic-r-r name operation op ope comment)
6505   (dni name
6506        (comment)
6507        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6508        (.str name "$pack $FRinti,$FRintj,$FRintk")
6509        (+ pack FRintk op FRinti ope FRintj)
6510        (set FRintk (operation FRinti FRintj))
6511        ((fr400 (unit u-media-1))
6512         (fr500 (unit u-media)))
6513   )
6514 )
6515
6516 (media-logic-r-r mand and OP_7B OPE1_00 "and reg/reg")
6517 (media-logic-r-r mor  or  OP_7B OPE1_01 "or  reg/reg")
6518 (media-logic-r-r mxor xor OP_7B OPE1_02 "xor reg/reg")
6519
6520 (define-pmacro (conditional-media-logic name operation op ope comment)
6521   (dni name
6522        (comment)
6523        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1) CONDITIONAL)
6524        (.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
6525        (+ pack FRintk op FRinti CCi cond ope FRintj)
6526        (if (eq CCi (or cond 2))
6527            (set FRintk (operation FRinti FRintj)))
6528        ((fr400 (unit u-media-1))
6529         (fr500 (unit u-media)))
6530   )
6531 )
6532
6533 (conditional-media-logic cmand and OP_70 OPE4_0 "conditional and reg/reg")
6534 (conditional-media-logic cmor  or  OP_70 OPE4_1 "conditional or  reg/reg")
6535 (conditional-media-logic cmxor xor OP_70 OPE4_2 "conditional xor reg/reg")
6536
6537 (dni mnot
6538      ("mnot")
6539      ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6540      ("mnot$pack $FRintj,$FRintk")
6541      (+ pack FRintk OP_7B (rs-null) OPE1_03 FRintj)
6542      (set FRintk (inv FRintj))
6543      ((fr400 (unit u-media-1))
6544       (fr500 (unit u-media)))
6545 )
6546
6547 (dni cmnot
6548      ("cmnot")
6549      ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1) CONDITIONAL)
6550      ("cmnot$pack $FRintj,$FRintk,$CCi,$cond")
6551      (+ pack FRintk OP_70 (rs-null) CCi cond OPE4_3 FRintj)
6552      (if (eq CCi (or cond 2))
6553          (set FRintk (inv FRintj)))
6554      ((fr400 (unit u-media-1))
6555       (fr500 (unit u-media)))
6556 )
6557
6558 (define-pmacro (media-rotate-r-r name operation op ope comment)
6559   (dni name
6560        (comment)
6561        ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
6562        (.str name "$pack $FRinti,$u6,$FRintk")
6563        (+ pack FRintk op FRinti ope u6)
6564        (set FRintk (operation FRinti (and u6 #x1f)))
6565        ((fr400 (unit u-media-3))
6566         (fr500 (unit u-media)))
6567   )
6568 )
6569
6570 (media-rotate-r-r mrotli rol OP_7B OPE1_04 "rotate left reg/reg")
6571 (media-rotate-r-r mrotri ror OP_7B OPE1_05 "rotate right reg/reg")
6572
6573 (define-pmacro (media-cut-r-r name arg op ope comment)
6574   (dni name
6575        (comment)
6576        ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2))
6577        (.str name "$pack $FRinti,$" arg ",$FRintk")
6578        (+ pack FRintk op FRinti ope arg)
6579        (set FRintk (c-call SI "@cpu@_cut" FRinti (nextreg h-fr_int FRinti 1) arg))
6580        ((fr400 (unit u-media-3))
6581         (fr500 (unit u-media)))
6582   )
6583 )
6584
6585 (media-cut-r-r mwcut  FRintj OP_7B OPE1_06 "media cut")
6586 (media-cut-r-r mwcuti u6     OP_7B OPE1_07 "media cut")
6587
6588 (define-pmacro (media-cut-acc name arg op ope comment)
6589   (dni name
6590        (comment)
6591        ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
6592        (.str name "$pack $ACC40Si,$" arg ",$FRintk")
6593        (+ pack FRintk op ACC40Si ope arg)
6594        (set FRintk (c-call SI "@cpu@_media_cut" ACC40Si arg))
6595        ((fr400 (unit u-media-4))
6596         (fr500 (unit u-media)))
6597   )
6598 )
6599
6600 (media-cut-acc mcut  FRintj OP_7B OPE1_2C "media accumulator cut reg")
6601 (media-cut-acc mcuti s6     OP_7B OPE1_2E "media accumulator cut immed")
6602
6603 (define-pmacro (media-cut-acc-ss name arg op ope comment)
6604   (dni name
6605        (comment)
6606        ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
6607        (.str name "$pack $ACC40Si,$" arg ",$FRintk")
6608        (+ pack FRintk op ACC40Si ope arg)
6609        (set FRintk (c-call SI "@cpu@_media_cut_ss" ACC40Si arg))
6610        ((fr400 (unit u-media-4))
6611         (fr500 (unit u-media)))
6612   )
6613 )
6614
6615 (media-cut-acc-ss mcutss  FRintj OP_7B OPE1_2D "media accumulator cut reg with saturation")
6616 (media-cut-acc-ss mcutssi s6     OP_7B OPE1_2F "media accumulator cut immed with saturation")
6617
6618 ; Dual Media Instructions
6619 ;
6620 (define-pmacro (register-unaligned register alignment)
6621   (and (index-of register) (sub alignment 1))
6622 )
6623
6624 (dni mdcutssi
6625      "Media dual cut with signed saturation"
6626      ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
6627      "mdcutssi$pack $ACC40Si,$s6,$FRintkeven"
6628      (+ pack FRintkeven OP_78 ACC40Si OPE1_0E s6)
6629      (if (register-unaligned ACC40Si 2)
6630          (c-call VOID "@cpu@_media_acc_not_aligned")
6631          (if (register-unaligned FRintkeven 2)
6632              (c-call VOID "@cpu@_media_register_not_aligned")
6633              (sequence ()
6634                        (set FRintkeven (c-call SI "@cpu@_media_cut_ss" ACC40Si s6))
6635                        (set (nextreg h-fr_int FRintkeven 1)
6636                             (c-call SI "@cpu@_media_cut_ss"
6637                                     (nextreg h-acc40S ACC40Si 1) s6)))))
6638      ((fr400 (unit u-media-4-acc-dual
6639                    (out FRintk FRintkeven))))
6640 )
6641
6642 ; The (add (xxxx) (mul arg 0)) is a hack to get a reference to arg generated
6643 ; so it will be passed to the unit modelers.   YUCK!!!!!
6644 (define-pmacro (extract-hilo reg1 off1 reg2 off2 arg1hi arg1lo arg2hi arg2lo)
6645   (sequence ()
6646             (set arg1hi (add (halfword hi reg1 off1) (mul reg1 0)))
6647             (set arg1lo (add (halfword lo reg1 off1) (mul reg1 0)))
6648             (set arg2hi (add (halfword hi reg2 off2) (mul reg2 0)))
6649             (set arg2lo (add (halfword lo reg2 off2) (mul reg2 0))))
6650 )
6651
6652 (dni maveh
6653      "Media dual average"
6654      ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6655      "maveh$pack $FRinti,$FRintj,$FRintk"
6656      (+ pack FRintk OP_7B FRinti OPE1_08 FRintj)
6657      (set FRintk (c-call SI "@cpu@_media_average" FRinti FRintj))
6658      ((fr400 (unit u-media-1))
6659       (fr500 (unit u-media)))
6660 )
6661
6662 (define-pmacro (media-dual-shift name operation op ope profile comment)
6663   (dni name
6664        (comment)
6665        ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
6666        (.str name "$pack $FRinti,$u6,$FRintk")
6667        (+ pack FRintk op FRinti ope u6)
6668        (sequence ()
6669                  ; hack to get these referenced for profiling
6670                  (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
6671                  (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
6672                  (set (halfword hi FRintk 0)
6673                       (operation (halfword hi FRinti 0) (and u6 #xf)))
6674                  (set (halfword lo FRintk 0)
6675                       (operation (halfword lo FRinti 0) (and u6 #xf))))
6676        profile
6677   )
6678 )
6679
6680 (media-dual-shift msllhi sll OP_7B OPE1_09
6681                   ((fr400 (unit u-media-3)) (fr500 (unit u-media)))
6682                   "Media dual shift left  logical")
6683 (media-dual-shift msrlhi srl OP_7B OPE1_0A
6684                   ((fr400 (unit u-media-3)) (fr500 (unit u-media)))
6685                   "Media dual shift right logical")
6686 (media-dual-shift msrahi sra OP_7B OPE1_0B
6687                   ((fr400 (unit u-media-6)) (fr500 (unit u-media)))
6688                   "Media dual shift right arithmetic")
6689
6690 (define-pmacro (media-dual-word-rotate-r-r name operation op ope comment)
6691   (dni name
6692        (comment)
6693        ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
6694        (.str name "$pack $FRintieven,$s6,$FRintkeven")
6695        (+ pack FRintkeven op FRintieven ope s6)
6696        (if (orif (register-unaligned FRintieven 2)
6697                  (register-unaligned FRintkeven 2))
6698            (c-call VOID "@cpu@_media_register_not_aligned")
6699            (sequence ()
6700                      (set FRintkeven (operation FRintieven (and s6 #x1f)))
6701                      (set (nextreg h-fr_int FRintkeven 1)
6702                           (operation (nextreg h-fr_int FRintieven 1)
6703                                      (and s6 #x1f)))))
6704        ((fr400 (unit u-media-3-quad
6705                      (in  FRinti FRintieven)
6706                      (out FRintk FRintkeven))))
6707   )
6708 )
6709
6710 (media-dual-word-rotate-r-r mdrotli rol OP_78 OPE1_0B "rotate left reg/reg")
6711
6712 (dni mcplhi
6713      "Media dual couple, halfword"
6714      ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
6715      "mcplhi$pack $FRinti,$u6,$FRintk"
6716      (+ pack FRintk OP_78 FRinti OPE1_0C u6)
6717      (sequence ((HI arg1) (HI arg2) (HI shift))
6718                (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
6719                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
6720                (set shift (and u6 #xf))
6721                (set arg1 (sll (halfword hi FRinti 0) shift))
6722                (if (ne shift 0)
6723                    (sequence ()
6724                              (set arg2 (halfword hi FRinti 1))
6725                              (set arg2 (srl HI (sll HI arg2 (sub 15 shift))
6726                                             (sub 15 shift)))
6727                              (set arg1 (or HI arg1 arg2))))
6728                (set (halfword hi FRintk 0) arg1))
6729      ((fr400 (unit u-media-3-dual)))
6730 )
6731
6732 (dni mcpli
6733      "Media dual couple, word"
6734      ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
6735      "mcpli$pack $FRinti,$u6,$FRintk"
6736      (+ pack FRintk OP_78 FRinti OPE1_0D u6)
6737      (sequence ((SI tmp) (SI shift))
6738                (set shift (and u6 #x1f))
6739                (set tmp (sll FRinti shift))
6740                (if (ne shift 0)
6741                    (sequence ((SI tmp1))
6742                              (set tmp1 (srl (sll (nextreg h-fr_int FRinti 1)
6743                                                  (sub 31 shift))
6744                                             (sub 31 shift)))
6745                              (set tmp (or tmp tmp1))))
6746                (set FRintk tmp))
6747      ((fr400 (unit u-media-3-dual)))
6748 )
6749
6750 (define-pmacro (saturate arg max min result)
6751   (if (gt arg max)
6752       (set result max)
6753       (if (lt arg min)
6754           (set result min)
6755           (set result arg)))
6756 )
6757
6758 (dni msaths
6759      "Media dual saturation signed"
6760      ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6761      "msaths$pack $FRinti,$FRintj,$FRintk"
6762      (+ pack FRintk OP_7B FRinti OPE1_0C FRintj)
6763      (sequence ((HI argihi) (HI argilo) (HI argjhi) (HI argjlo))
6764                (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
6765                (saturate argihi argjhi (inv argjhi) (halfword hi FRintk 0))
6766                (saturate argilo argjlo (inv argjlo) (halfword lo FRintk 0)))
6767      ((fr400 (unit u-media-1))
6768       (fr500 (unit u-media)))
6769 )
6770
6771 (dni mqsaths
6772      "Media quad saturation signed"
6773      ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6774      "mqsaths$pack $FRintieven,$FRintjeven,$FRintkeven"
6775      (+ pack FRintkeven OP_78 FRintieven OPE1_0F FRintjeven)
6776      (if (orif (register-unaligned FRintieven 2)
6777                (orif (register-unaligned FRintjeven 2)
6778                      (register-unaligned FRintkeven 2)))
6779          (c-call VOID "@cpu@_media_register_not_aligned")
6780          (sequence ((HI argihi) (HI argilo) (HI argjhi) (HI argjlo))
6781                    ; hack to get FRintkeven referenced as a target for profiling
6782                    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
6783                    (extract-hilo FRintieven 0 FRintjeven 0 argihi argilo argjhi argjlo)
6784                    (saturate argihi argjhi (inv argjhi) (halfword hi FRintkeven 0))
6785                    (saturate argilo argjlo (inv argjlo) (halfword lo FRintkeven 0))
6786                    (extract-hilo FRintieven 1 FRintjeven 1 argihi argilo argjhi argjlo)
6787                    (saturate argihi argjhi (inv argjhi) (halfword hi FRintkeven 1))
6788                    (saturate argilo argjlo (inv argjlo) (halfword lo FRintkeven 1))))
6789      ((fr400 (unit u-media-1-quad
6790                    (in  FRinti FRintieven)
6791                    (in  FRintj FRintjeven)
6792                    (out FRintk FRintkeven))))
6793 )
6794
6795 (define-pmacro (saturate-unsigned arg max result)
6796   (if (gt arg max)
6797       (set result max)
6798       (set result arg))
6799 )
6800
6801 (dni msathu
6802      "Media dual saturation unsigned"
6803      ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6804      "msathu$pack $FRinti,$FRintj,$FRintk"
6805      (+ pack FRintk OP_7B FRinti OPE1_0D FRintj)
6806      (sequence ((UHI argihi) (UHI argilo) (UHI argjhi) (UHI argjlo))
6807                (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
6808                (saturate-unsigned argihi argjhi (halfword hi FRintk 0))
6809                (saturate-unsigned argilo argjlo (halfword lo FRintk 0)))
6810      ((fr400 (unit u-media-1))
6811       (fr500 (unit u-media)))
6812 )
6813
6814 (define-pmacro (media-dual-compare name mode op ope comment)
6815   (dni name
6816        (comment)
6817        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6818        (.str name "$pack $FRinti,$FRintj,$FCCk")
6819        (+ pack (cond-null) FCCk op FRinti ope FRintj)
6820        (if (register-unaligned FCCk 2)
6821            (c-call VOID "@cpu@_media_cr_not_aligned")
6822            (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
6823                      (extract-hilo FRinti 0 FRintj 0
6824                                    argihi argilo argjhi argjlo)
6825                      (compare-and-set-fcc argihi argjhi FCCk)
6826                      (compare-and-set-fcc argilo argjlo (nextreg h-fccr FCCk 1))))
6827        ; TODO - doesn't handle second FCC
6828        ((fr400 (unit u-media-7))
6829         (fr500 (unit u-media)))
6830   )
6831 )
6832
6833 (media-dual-compare mcmpsh HI  OP_7B OPE1_0E "Media dual compare signed")
6834 (media-dual-compare mcmpuh UHI OP_7B OPE1_0F "Media dual compare unsigned")
6835
6836 ; Bits for the MSR.SIE field
6837 (define-pmacro (msr-sie-nil)      0)
6838 (define-pmacro (msr-sie-fri-hi)   8)
6839 (define-pmacro (msr-sie-fri-lo)   4)
6840 (define-pmacro (msr-sie-fri-1-hi) 2)
6841 (define-pmacro (msr-sie-fri-1-lo) 1)
6842 (define-pmacro (msr-sie-acci)     8)
6843 (define-pmacro (msr-sie-acci-1)   4)
6844 (define-pmacro (msr-sie-acci-2)   2)
6845 (define-pmacro (msr-sie-acci-3)   1)
6846
6847 (define-pmacro (saturate-v arg max min sie result)
6848   (if (gt DI arg max)
6849       (sequence ()
6850                 (set result max)
6851                 (c-call VOID "@cpu@_media_overflow" sie))
6852       (if (lt DI arg min)
6853           (sequence ()
6854                     (set result min)
6855                     (c-call VOID "@cpu@_media_overflow" sie))
6856           (set result arg)))
6857 )
6858
6859 (dni mabshs
6860      "Media dual absolute value, halfword"
6861      ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
6862      "mabshs$pack $FRintj,$FRintk"
6863      (+ pack FRintk OP_78 (FRi-null) OPE1_0A FRintj)
6864      (sequence ((HI arghi) (HI arglo))
6865                (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
6866                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
6867                (set arghi (halfword hi FRintj 0))
6868                (set arglo (halfword lo FRintj 0))
6869                (saturate-v (abs arghi) 32767 -32768 (msr-sie-fri-hi)
6870                            (halfword hi FRintk 0))
6871                (saturate-v (abs arglo) 32767 -32768 (msr-sie-fri-lo)
6872                            (halfword lo FRintk 0)))
6873      ((fr400 (unit u-media-1)))
6874 )
6875
6876 (define-pmacro (media-arith-sat-semantics
6877                 operation arg1 arg2 res mode max min sie)
6878   (sequence ((DI tmp))
6879             (set tmp (operation arg1 arg2))
6880             (saturate-v tmp max min sie res))
6881 )
6882
6883 (define-pmacro (media-dual-arith-sat-semantics operation mode max min)
6884   (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
6885             (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
6886             (media-arith-sat-semantics operation argihi argjhi
6887                                        (halfword hi FRintk 0) mode max min
6888                                        (msr-sie-fri-hi))
6889             (media-arith-sat-semantics operation argilo argjlo
6890                                        (halfword lo FRintk 0) mode max min
6891                                        (msr-sie-fri-lo)))
6892 )
6893
6894 (define-pmacro (media-dual-arith-sat name operation mode max min op ope comment)
6895   (dni name
6896        (comment)
6897        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1))
6898        (.str name "$pack $FRinti,$FRintj,$FRintk")
6899        (+ pack FRintk op FRinti ope FRintj)
6900        (media-dual-arith-sat-semantics operation mode max min)
6901        ((fr400 (unit u-media-1))
6902         (fr500 (unit u-media)))
6903   )
6904 )
6905
6906 (media-dual-arith-sat maddhss add  HI 32767 -32768 OP_7B OPE1_10 "Media dual add signed with saturation")
6907 (media-dual-arith-sat maddhus add UHI 65535      0 OP_7B OPE1_11 "Media dual add unsigned with saturation")
6908
6909 (media-dual-arith-sat msubhss sub  HI 32767 -32768 OP_7B OPE1_12 "Media dual sub signed with saturation")
6910 (media-dual-arith-sat msubhus sub UHI 65535      0 OP_7B OPE1_13 "Media dual sub unsigned with saturation")
6911
6912 (define-pmacro (conditional-media-dual-arith-sat
6913                 name operation mode max min op ope comment)
6914   (dni name
6915        (comment)
6916        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-1) CONDITIONAL)
6917        (.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
6918        (+ pack FRintk op FRinti CCi cond ope FRintj)
6919        (if (eq CCi (or cond 2))
6920            (media-dual-arith-sat-semantics operation mode max min))
6921        ((fr400 (unit u-media-1))
6922         (fr500 (unit u-media)))
6923   )
6924 )
6925
6926 (conditional-media-dual-arith-sat cmaddhss add  HI 32767 -32768 OP_71 OPE4_0 "Conditional Media dual add signed with saturation")
6927 (conditional-media-dual-arith-sat cmaddhus add UHI 65535      0 OP_71 OPE4_1 "Conditional Media dual add unsigned with saturation")
6928
6929 (conditional-media-dual-arith-sat cmsubhss sub  HI 32767 -32768 OP_71 OPE4_2 "Conditional Media dual sub signed with saturation")
6930 (conditional-media-dual-arith-sat cmsubhus sub UHI 65535      0 OP_71 OPE4_3 "Conditional Media dual sub unsigned with saturation")
6931
6932 (define-pmacro (media-quad-arith-sat-semantics cond operation mode max min)
6933   (if (orif (register-unaligned FRintieven 2)
6934             (orif (register-unaligned FRintjeven 2)
6935                   (register-unaligned FRintkeven 2)))
6936       (c-call VOID "@cpu@_media_register_not_aligned")
6937       (if cond
6938           (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
6939                     ; hack to get FRintkeven referenced as a target for profiling
6940                     (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
6941                     (extract-hilo FRintieven 0 FRintjeven 0
6942                                   argihi argilo argjhi argjlo)
6943                     (media-arith-sat-semantics operation argihi argjhi
6944                                                (halfword hi FRintkeven 0) mode
6945                                                max min (msr-sie-fri-hi))
6946                     (media-arith-sat-semantics operation argilo argjlo
6947                                                (halfword lo FRintkeven 0) mode
6948                                                max min (msr-sie-fri-lo))
6949                     (extract-hilo FRintieven 1 FRintjeven 1
6950                                   argihi argilo argjhi argjlo)
6951                     (media-arith-sat-semantics operation argihi argjhi
6952                                                (halfword hi FRintkeven 1) mode
6953                                                max min  (msr-sie-fri-1-hi))
6954                     (media-arith-sat-semantics operation argilo argjlo
6955                                                (halfword lo FRintkeven 1) mode
6956                                                max min (msr-sie-fri-1-lo)))))
6957 )
6958
6959 (define-pmacro (media-quad-arith-sat name operation mode max min op ope comment)
6960   (dni name
6961        (comment)
6962        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-2))
6963        (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
6964        (+ pack FRintkeven op FRintieven ope FRintjeven)
6965        (media-quad-arith-sat-semantics 1 operation mode max min)
6966        ((fr400 (unit u-media-1-quad
6967                      (in  FRinti FRintieven)
6968                      (in  FRintj FRintjeven)
6969                      (out FRintk Frintkeven)))
6970         (fr500 (unit u-media-quad-arith
6971                      (in  FRinti FRintieven)
6972                      (in  FRintj FRintjeven)
6973                      (out FRintk Frintkeven))))
6974   )
6975 )
6976
6977 (media-quad-arith-sat mqaddhss add  HI 32767 -32768 OP_7B OPE1_18 "Media quad add signed with saturation")
6978 (media-quad-arith-sat mqaddhus add UHI 65535      0 OP_7B OPE1_19 "Media quad add unsigned with saturation")
6979
6980 (media-quad-arith-sat mqsubhss sub  HI 32767 -32768 OP_7B OPE1_1A "Media quad sub signed with saturation")
6981 (media-quad-arith-sat mqsubhus sub UHI 65535      0 OP_7B OPE1_1B "Media quad sub unsigned with saturation")
6982
6983 (define-pmacro (conditional-media-quad-arith-sat
6984                 name operation mode max min op ope comment)
6985   (dni name
6986        (comment)
6987        ((UNIT FM01) (FR500-MAJOR M-1) (FR400-MAJOR M-2) CONDITIONAL)
6988        (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven,$CCi,$cond")
6989        (+ pack FRintkeven op FRintieven CCi cond ope FRintjeven)
6990        (media-quad-arith-sat-semantics (eq CCi (or cond 2))
6991                                        operation mode max min)
6992        ((fr400 (unit u-media-1-quad
6993                      (in  FRinti FRintieven)
6994                      (in  FRintj FRintjeven)
6995                      (out FRintk Frintkeven)))
6996         (fr500 (unit u-media-quad-arith
6997                      (in  FRinti FRintieven)
6998                      (in  FRintj FRintjeven)
6999                      (out FRintk Frintkeven))))
7000   )
7001 )
7002
7003 (conditional-media-quad-arith-sat cmqaddhss add  HI 32767 -32768 OP_73 OPE4_0 "Conditional Media quad add signed with saturation")
7004 (conditional-media-quad-arith-sat cmqaddhus add UHI 65535      0 OP_73 OPE4_1 "Conditional Media quad add unsigned with saturation")
7005
7006 (conditional-media-quad-arith-sat cmqsubhss sub  HI 32767 -32768 OP_73 OPE4_2 "Conditional Media quad sub signed with saturation")
7007 (conditional-media-quad-arith-sat cmqsubhus sub UHI 65535      0 OP_73 OPE4_3 "Conditional Media quad sub unsigned with saturation")
7008
7009 (define-pmacro (media-acc-arith-sat name operation mode max min op ope comment)
7010   (dni name
7011        (comment)
7012        ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
7013        (.str name "$pack $ACC40Si,$ACC40Sk")
7014        (+ pack ACC40Sk op ACC40Si ope (ACCj-null))
7015        (if (register-unaligned ACC40Si 2)
7016            (c-call VOID "@cpu@_media_acc_not_aligned")
7017            (media-arith-sat-semantics operation ACC40Si
7018                                       (nextreg h-acc40S ACC40Si 1)
7019                                       ACC40Sk mode max min (msr-sie-acci)))
7020        ((fr400 (unit u-media-2-acc)))
7021   )
7022 )
7023
7024 (media-acc-arith-sat maddaccs add DI #x7fffffffff (inv DI #x7fffffffff)
7025                      OP_78 OPE1_04 "Media accumulator addition")
7026 (media-acc-arith-sat msubaccs sub DI #x7fffffffff (inv DI #x7fffffffff)
7027                      OP_78 OPE1_05 "Media accumulator subtraction")
7028
7029 (define-pmacro (media-dual-acc-arith-sat name operation mode max min op ope
7030                                          comment)
7031   (dni name
7032        (comment)
7033        ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
7034        (.str name "$pack $ACC40Si,$ACC40Sk")
7035        (+ pack ACC40Sk op ACC40Si ope (ACCj-null))
7036        (if (register-unaligned ACC40Si 4)
7037            (c-call VOID "@cpu@_media_acc_not_aligned")
7038            (if (register-unaligned ACC40Sk 2)
7039                (c-call VOID "@cpu@_media_acc_not_aligned")
7040                (sequence ()
7041                          (media-arith-sat-semantics operation ACC40Si
7042                                                     (nextreg h-acc40S ACC40Si 1)
7043                                                     ACC40Sk mode max min
7044                                                     (msr-sie-acci))
7045                          (media-arith-sat-semantics operation
7046                                                     (nextreg h-acc40S ACC40Si 2)
7047                                                     (nextreg h-acc40S ACC40Si 3)
7048                                                     (nextreg h-acc40S ACC40Sk 1)
7049                                                     mode max min
7050                                                     (msr-sie-acci-1)))))
7051        ((fr400 (unit u-media-2-acc-dual)))
7052   )
7053 )
7054
7055 (media-dual-acc-arith-sat mdaddaccs add DI #x7fffffffff (inv DI #x7fffffffff)
7056                           OP_78 OPE1_06 "Media accumulator addition")
7057 (media-dual-acc-arith-sat mdsubaccs sub DI #x7fffffffff (inv DI #x7fffffffff)
7058                           OP_78 OPE1_07 "Media accumulator subtraction")
7059
7060 (dni masaccs
7061      "Media add and subtract signed accumulator with saturation"
7062        ((UNIT FM01) (MACH fr400) (FR400-MAJOR M-1))
7063        "masaccs$pack $ACC40Si,$ACC40Sk"
7064        (+ pack ACC40Sk OP_78 ACC40Si OPE1_08 (ACCj-null))
7065        (if (register-unaligned ACC40Si 2)
7066            (c-call VOID "@cpu@_media_acc_not_aligned")
7067            (if (register-unaligned ACC40Sk 2)
7068                (c-call VOID "@cpu@_media_acc_not_aligned")
7069                (sequence ()
7070                          (media-arith-sat-semantics add ACC40Si
7071                                                     (nextreg h-acc40S ACC40Si 1)
7072                                                     ACC40Sk DI
7073                                                     #x7fffffffff
7074                                                     (inv DI #x7fffffffff)
7075                                                     (msr-sie-acci))
7076                          (media-arith-sat-semantics sub ACC40Si
7077                                                     (nextreg h-acc40S ACC40Si 1)
7078                                                     (nextreg h-acc40S ACC40Sk 1)
7079                                                     DI
7080                                                     #x7fffffffff
7081                                                     (inv DI #x7fffffffff)
7082                                                     (msr-sie-acci-1)))))
7083        ((fr400 (unit u-media-2-add-sub)))
7084   )
7085
7086 (dni mdasaccs
7087      "Media add and subtract signed accumulator with saturation"
7088        ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
7089        "mdasaccs$pack $ACC40Si,$ACC40Sk"
7090        (+ pack ACC40Sk OP_78 ACC40Si OPE1_09 (ACCj-null))
7091        (if (register-unaligned ACC40Si 4)
7092            (c-call VOID "@cpu@_media_acc_not_aligned")
7093            (if (register-unaligned ACC40Sk 4)
7094                (c-call VOID "@cpu@_media_acc_not_aligned")
7095                (sequence ()
7096                          (media-arith-sat-semantics add ACC40Si
7097                                                     (nextreg h-acc40S ACC40Si 1)
7098                                                     ACC40Sk DI
7099                                                     #x7fffffffff
7100                                                     (inv DI #x7fffffffff)
7101                                                     (msr-sie-acci))
7102                          (media-arith-sat-semantics sub ACC40Si
7103                                                     (nextreg h-acc40S ACC40Si 1)
7104                                                     (nextreg h-acc40S ACC40Sk 1)
7105                                                     DI
7106                                                     #x7fffffffff
7107                                                     (inv DI #x7fffffffff)
7108                                                     (msr-sie-acci-1))
7109                          (media-arith-sat-semantics add
7110                                                     (nextreg h-acc40S ACC40Si 2)
7111                                                     (nextreg h-acc40S ACC40Si 3)
7112                                                     (nextreg h-acc40S ACC40Sk 2)
7113                                                     DI
7114                                                     #x7fffffffff
7115                                                     (inv DI #x7fffffffff)
7116                                                     (msr-sie-acci-2))
7117                          (media-arith-sat-semantics sub
7118                                                     (nextreg h-acc40S ACC40Si 2)
7119                                                     (nextreg h-acc40S ACC40Si 3)
7120                                                     (nextreg h-acc40S ACC40Sk 3)
7121                                                     DI
7122                                                     #x7fffffffff
7123                                                     (inv DI #x7fffffffff)
7124                                                     (msr-sie-acci-3)))))
7125        ((fr400 (unit u-media-2-add-sub-dual)))
7126   )
7127
7128 (define-pmacro (media-multiply-semantics conv arg1 arg2 res)
7129   (set res (mul DI (conv DI arg1) (conv DI arg2)))
7130 )
7131
7132 (define-pmacro (media-dual-multiply-semantics cond mode conv rhs1 rhs2)
7133   (if (register-unaligned ACC40Sk 2)
7134       (c-call VOID "@cpu@_media_acc_not_aligned")
7135       (if cond
7136           (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
7137                     (extract-hilo FRinti 0 FRintj 0
7138                                   argihi argilo argjhi argjlo)
7139                     (media-multiply-semantics conv argihi rhs1 ACC40Sk)
7140                     (media-multiply-semantics conv argilo rhs2
7141                                               (nextreg h-acc40S ACC40Sk 1)))))
7142 )
7143
7144 (define-pmacro (media-dual-multiply name mode conv rhs1 rhs2 op ope comment)
7145   (dni name
7146        (comment)
7147        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1) PRESERVE-OVF)
7148        (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
7149        (+ pack ACC40Sk op FRinti ope FRintj)
7150        (media-dual-multiply-semantics 1 mode conv rhs1 rhs2)
7151        ((fr400 (unit u-media-2))
7152         (fr500 (unit u-media-dual-mul)))
7153   )
7154 )
7155
7156 (media-dual-multiply mmulhs  HI ext  argjhi argjlo OP_7B OPE1_14 "Media dual multiply signed")
7157 (media-dual-multiply mmulhu UHI zext argjhi argjlo OP_7B OPE1_15 "Media dual multiply unsigned")
7158
7159 (media-dual-multiply mmulxhs  HI ext  argjlo argjhi OP_7B OPE1_28 "Media dual cross multiply signed")
7160 (media-dual-multiply mmulxhu UHI zext argjlo argjhi OP_7B OPE1_29 "Media dual cross multiply unsigned")
7161
7162 (define-pmacro (conditional-media-dual-multiply
7163                 name mode conv rhs1 rhs2 op ope comment)
7164   (dni name
7165        (comment)
7166        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1)
7167         PRESERVE-OVF CONDITIONAL)
7168        (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
7169        (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
7170        (media-dual-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
7171        ((fr400 (unit u-media-2))
7172         (fr500 (unit u-media-dual-mul)))
7173   )
7174 )
7175
7176 (conditional-media-dual-multiply cmmulhs  HI ext  argjhi argjlo OP_72 OPE4_0 "Conditional Media dual multiply signed")
7177 (conditional-media-dual-multiply cmmulhu UHI zext argjhi argjlo OP_72 OPE4_1 "Conditional Media dual multiply unsigned")
7178
7179 (define-pmacro (media-quad-multiply-semantics cond mode conv rhs1 rhs2)
7180   (if (register-unaligned ACC40Sk 4)
7181       (c-call VOID "@cpu@_media_acc_not_aligned")
7182       (if (orif (register-unaligned FRintieven 2)
7183                 (register-unaligned FRintjeven 2))
7184           (c-call VOID "@cpu@_media_register_not_aligned")
7185           (if cond
7186               (sequence ((mode argihi) (mode argilo)
7187                          (mode argjhi) (mode argjlo))
7188                         (extract-hilo FRintieven 0 FRintjeven 0
7189                                       argihi argilo argjhi argjlo)
7190                         (media-multiply-semantics conv argihi rhs1 ACC40Sk)
7191                         (media-multiply-semantics conv argilo rhs2
7192                                                   (nextreg h-acc40S ACC40Sk 1))
7193                         (extract-hilo FRintieven 1 FRintjeven 1
7194                                       argihi argilo argjhi argjlo)
7195                         (media-multiply-semantics conv argihi rhs1
7196                                                   (nextreg h-acc40S ACC40Sk 2))
7197                         (media-multiply-semantics conv argilo rhs2
7198                                                   (nextreg h-acc40S ACC40Sk 3))))))
7199 )
7200
7201 (define-pmacro (media-quad-multiply name mode conv rhs1 rhs2 op ope comment)
7202   (dni name
7203        (comment)
7204        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-2) PRESERVE-OVF)
7205        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
7206        (+ pack ACC40Sk op FRintieven ope FRintjeven)
7207        (media-quad-multiply-semantics 1 mode conv rhs1 rhs2) 
7208        ((fr400 (unit u-media-2-quad
7209                      (in  FRinti FRintieven)
7210                      (in  FRintj FRintjeven)))
7211         (fr500 (unit u-media-quad-mul
7212                      (in  FRinti FRintieven)
7213                      (in  FRintj FRintjeven))))
7214   )
7215 )
7216
7217 (media-quad-multiply mqmulhs  HI ext  argjhi argjlo OP_7B OPE1_1C "Media quad multiply signed")
7218 (media-quad-multiply mqmulhu UHI zext argjhi argjlo OP_7B OPE1_1D "Media quad multiply unsigned")
7219
7220 (media-quad-multiply mqmulxhs  HI ext  argjlo argjhi OP_7B OPE1_2A "Media quad cross multiply signed")
7221 (media-quad-multiply mqmulxhu UHI zext argjlo argjhi OP_7B OPE1_2B "Media quad cross multiply unsigned")
7222
7223 (define-pmacro (conditional-media-quad-multiply
7224                 name mode conv rhs1 rhs2 op ope comment)
7225   (dni name
7226        (comment)
7227        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-2)
7228         PRESERVE-OVF CONDITIONAL)
7229        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk,$CCi,$cond")
7230        (+ pack ACC40Sk op FRintieven CCi cond ope FRintjeven)
7231        (media-quad-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
7232        ((fr400 (unit u-media-2-quad
7233                      (in  FRinti FRintieven)
7234                      (in  FRintj FRintjeven)))
7235         (fr500 (unit u-media-quad-mul
7236                      (in  FRinti FRintieven)
7237                      (in  FRintj FRintjeven))))      
7238   )
7239 )
7240
7241 (conditional-media-quad-multiply cmqmulhs  HI ext  argjhi argjlo OP_74 OPE4_0 "Conditional Media quad multiply signed")
7242 (conditional-media-quad-multiply cmqmulhu UHI zext argjhi argjlo OP_74 OPE4_1 "Conditional Media quad multiply unsigned")
7243
7244 (define-pmacro (media-multiply-acc-semantics 
7245                 conv arg1 addop arg2 res max min sie)
7246   (sequence ((DI tmp))
7247             (set tmp (addop res (mul DI (conv DI arg1) (conv DI arg2))))
7248             (saturate-v tmp max min sie res))
7249 )
7250
7251 (define-pmacro (media-dual-multiply-acc-semantics
7252                 cond mode conv addop rhw res max min)
7253   (if (register-unaligned res 2)
7254       (c-call VOID "@cpu@_media_acc_not_aligned")
7255       (if cond
7256           (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
7257                     (extract-hilo FRinti 0 FRintj 0
7258                                   argihi argilo argjhi argjlo)
7259                     (media-multiply-acc-semantics conv argihi addop argjhi
7260                                                   res
7261                                                   max min (msr-sie-acci))
7262                     (media-multiply-acc-semantics conv argilo addop argjlo
7263                                                   (nextreg rhw res 1)
7264                                                   max min (msr-sie-acci-1)))))
7265 )
7266
7267 (define-pmacro (media-dual-multiply-acc
7268                 name mode conv addop rhw res max min op ope comment)
7269   (dni name
7270        (comment)
7271        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1))
7272        (.str name "$pack $FRinti,$FRintj,$" res)
7273        (+ pack res op FRinti ope FRintj)
7274        (media-dual-multiply-acc-semantics 1 mode conv addop rhw res max min)
7275        ((fr400 (unit u-media-2))
7276         (fr500 (unit u-media-dual-mul)))
7277   )
7278 )
7279
7280 (media-dual-multiply-acc mmachs HI ext add h-acc40S ACC40Sk
7281                          (const DI #x7fffffffff) (const DI #xffffff8000000000)
7282                          OP_7B OPE1_16
7283                          "Media dual multiply and accumulate signed")
7284
7285 (media-dual-multiply-acc mmachu UHI zext add h-acc40U ACC40Uk
7286                          (const DI #xffffffffff) (const DI 0)
7287                          OP_7B OPE1_17
7288                          "Media dual multiply and accumulate unsigned")
7289
7290 (media-dual-multiply-acc mmrdhs HI ext sub h-acc40S ACC40Sk
7291                          (const DI #x7fffffffff) (const DI #xffffff8000000000)
7292                          OP_7B OPE1_30
7293                          "Media dual multiply and reduce signed")
7294
7295 (media-dual-multiply-acc mmrdhu UHI zext sub h-acc40U ACC40Uk
7296                          (const DI #xffffffffff) (const DI 0)
7297                          OP_7B OPE1_31
7298                          "Media dual multiply and reduce unsigned")
7299
7300 (define-pmacro (conditional-media-dual-multiply-acc
7301                 name mode conv addop rhw res max min op ope comment)
7302   (dni name
7303        (comment)
7304        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1) CONDITIONAL)
7305        (.str name "$pack $FRinti,$FRintj,$" res ",$CCi,$cond")
7306        (+ pack res op FRinti CCi cond ope FRintj)
7307        (media-dual-multiply-acc-semantics (eq CCi (or cond 2))
7308                                           mode conv addop rhw res max min)
7309        ((fr400 (unit u-media-2))
7310         (fr500 (unit u-media-dual-mul)))
7311   )
7312 )
7313
7314 (conditional-media-dual-multiply-acc cmmachs HI ext add h-acc40S ACC40Sk
7315                          (const DI #x7fffffffff) (const DI #xffffff8000000000)
7316                          OP_72 OPE4_2
7317                          "Conditional Media dual multiply and accumulate signed")
7318
7319 (conditional-media-dual-multiply-acc cmmachu UHI zext add  h-acc40U ACC40Uk
7320                          (const DI #xffffffffff) (const DI 0)
7321                          OP_72 OPE4_3
7322                          "Conditional Media dual multiply and accumulate unsigned")
7323
7324 (define-pmacro (media-quad-multiply-acc-semantics
7325                 cond mode conv addop rhw res max min)
7326   (if (register-unaligned res 4)
7327       (c-call VOID "@cpu@_media_acc_not_aligned")
7328       (if (orif (register-unaligned FRintieven 2)
7329                 (register-unaligned FRintjeven 2))
7330           (c-call VOID "@cpu@_media_register_not_aligned")
7331           (if cond
7332               (sequence ((mode argihi) (mode argilo)
7333                          (mode argjhi) (mode argjlo))
7334                         (extract-hilo FRintieven 0 FRintjeven 0
7335                                       argihi argilo argjhi argjlo)
7336                         (media-multiply-acc-semantics conv argihi addop argjhi
7337                                                       res
7338                                                       max min (msr-sie-acci))
7339                         (media-multiply-acc-semantics conv argilo addop argjlo
7340                                                       (nextreg rhw res 1)
7341                                                       max min (msr-sie-acci-1))
7342                         (extract-hilo FRintieven 1 FRintjeven 1
7343                                       argihi argilo argjhi argjlo)
7344                         (media-multiply-acc-semantics conv argihi addop argjhi
7345                                                       (nextreg rhw res 2)
7346                                                       max min (msr-sie-acci-2))
7347                         (media-multiply-acc-semantics conv argilo addop argjlo
7348                                                       (nextreg rhw res 3)
7349                                                       max min
7350                                                       (msr-sie-acci-3))))))
7351 )
7352
7353 (define-pmacro (media-quad-multiply-acc
7354                 name mode conv addop rhw res max min op ope comment)
7355   (dni name
7356        (comment)
7357        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-2))
7358        (.str name "$pack $FRintieven,$FRintjeven,$" res)
7359        (+ pack res op FRintieven ope FRintjeven)
7360        (media-quad-multiply-acc-semantics 1 mode conv addop rhw res max min)
7361        ((fr400 (unit u-media-2-quad
7362                      (in  FRinti FRintieven)
7363                      (in  FRintj FRintjeven)))
7364         (fr500 (unit u-media-quad-mul
7365                      (in  FRinti FRintieven)
7366                      (in  FRintj FRintjeven))))
7367   )
7368 )
7369
7370 (media-quad-multiply-acc mqmachs HI ext add h-acc40S ACC40Sk
7371                          (const DI #x7fffffffff) (const DI #xffffff8000000000)
7372                          OP_7B OPE1_1E
7373                          "Media quad multiply and accumulate signed")
7374
7375 (media-quad-multiply-acc mqmachu UHI zext add h-acc40U ACC40Uk
7376                          (const DI #xffffffffff) (const DI 0)
7377                          OP_7B OPE1_1F
7378                          "Media quad multiply and accumulate unsigned")
7379
7380 (define-pmacro (conditional-media-quad-multiply-acc
7381                 name mode conv addop rhw res max min op ope comment)
7382   (dni name
7383        (comment)
7384        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-2) CONDITIONAL)
7385        (.str name "$pack $FRintieven,$FRintjeven,$" res ",$CCi,$cond")
7386        (+ pack res op FRintieven CCi cond ope FRintjeven)
7387        (media-quad-multiply-acc-semantics (eq CCi (or cond 2))
7388                                           mode conv addop rhw res max min)
7389        ((fr400 (unit u-media-2-quad
7390                      (in  FRinti FRintieven)
7391                      (in  FRintj FRintjeven)))
7392         (fr500 (unit u-media-quad-mul
7393                      (in  FRinti FRintieven)
7394                      (in  FRintj FRintjeven))))
7395   )
7396 )
7397
7398 (conditional-media-quad-multiply-acc cmqmachs HI ext add h-acc40S ACC40Sk
7399                          (const DI #x7fffffffff) (const DI #xffffff8000000000)
7400                          OP_74 OPE4_2
7401                          "Conditional Media quad multiply and accumulate signed")
7402
7403 (conditional-media-quad-multiply-acc cmqmachu UHI zext add h-acc40U ACC40Uk
7404                          (const DI #xffffffffff) (const DI 0)
7405                          OP_74 OPE4_3
7406                          "Conditional media quad multiply and accumulate unsigned")
7407
7408 (define-pmacro (media-quad-multiply-cross-acc-semantics
7409                 cond mode conv addop rhw res max min)
7410   (if (register-unaligned res 4)
7411       (c-call VOID "@cpu@_media_acc_not_aligned")
7412       (if (orif (register-unaligned FRintieven 2)
7413                 (register-unaligned FRintjeven 2))
7414           (c-call VOID "@cpu@_media_register_not_aligned")
7415           (if cond
7416               (sequence ((mode argihi) (mode argilo)
7417                          (mode argjhi) (mode argjlo))
7418                         (extract-hilo FRintieven 0 FRintjeven 0
7419                                       argihi argilo argjhi argjlo)
7420                         (media-multiply-acc-semantics conv argihi addop argjhi
7421                                                       (nextreg rhw res 2)
7422                                                       max min (msr-sie-acci-2))
7423                         (media-multiply-acc-semantics conv argilo addop argjlo
7424                                                       (nextreg rhw res 3)
7425                                                       max min (msr-sie-acci-3))
7426                         (extract-hilo FRintieven 1 FRintjeven 1
7427                                       argihi argilo argjhi argjlo)
7428                         (media-multiply-acc-semantics conv argihi addop argjhi
7429                                                       res
7430                                                       max min (msr-sie-acci))
7431                         (media-multiply-acc-semantics conv argilo addop argjlo
7432                                                       (nextreg rhw res 1)
7433                                                       max min
7434                                                       (msr-sie-acci-1))))))
7435 )
7436
7437 (define-pmacro (media-quad-multiply-cross-acc
7438                 name mode conv addop rhw res max min op ope comment)
7439   (dni name
7440        (comment)
7441        ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
7442        (.str name "$pack $FRintieven,$FRintjeven,$" res)
7443        (+ pack res op FRintieven ope FRintjeven)
7444        (media-quad-multiply-cross-acc-semantics 1 mode conv addop rhw res
7445                                                 max min)
7446        ((fr400 (unit u-media-2-quad
7447                      (in  FRinti FRintieven)
7448                      (in  FRintj FRintjeven))))
7449   )
7450 )
7451
7452 (media-quad-multiply-cross-acc mqxmachs HI ext add h-acc40S ACC40Sk
7453                          (const DI #x7fffffffff) (const DI #xffffff8000000000)
7454                          OP_78 OPE1_00
7455                          "Media quad multiply and cross accumulate signed")
7456
7457 (define-pmacro (media-quad-cross-multiply-cross-acc-semantics
7458                 cond mode conv addop rhw res max min)
7459   (if (register-unaligned res 4)
7460       (c-call VOID "@cpu@_media_acc_not_aligned")
7461       (if (orif (register-unaligned FRintieven 2)
7462                 (register-unaligned FRintjeven 2))
7463           (c-call VOID "@cpu@_media_register_not_aligned")
7464           (if cond
7465               (sequence ((mode argihi) (mode argilo)
7466                          (mode argjhi) (mode argjlo))
7467                         (extract-hilo FRintieven 0 FRintjeven 0
7468                                       argihi argilo argjhi argjlo)
7469                         (media-multiply-acc-semantics conv argihi addop argjlo
7470                                                       (nextreg rhw res 2)
7471                                                       max min (msr-sie-acci-2))
7472                         (media-multiply-acc-semantics conv argilo addop argjhi
7473                                                       (nextreg rhw res 3)
7474                                                       max min (msr-sie-acci-3))
7475                         (extract-hilo FRintieven 1 FRintjeven 1
7476                                       argihi argilo argjhi argjlo)
7477                         (media-multiply-acc-semantics conv argihi addop argjlo
7478                                                       res
7479                                                       max min (msr-sie-acci))
7480                         (media-multiply-acc-semantics conv argilo addop argjhi
7481                                                       (nextreg rhw res 1)
7482                                                       max min
7483                                                       (msr-sie-acci-1))))))
7484 )
7485
7486 (define-pmacro (media-quad-cross-multiply-cross-acc
7487                 name mode conv addop rhw res max min op ope comment)
7488   (dni name
7489        (comment)
7490        ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
7491        (.str name "$pack $FRintieven,$FRintjeven,$" res)
7492        (+ pack res op FRintieven ope FRintjeven)
7493        (media-quad-cross-multiply-cross-acc-semantics 1 mode conv addop rhw res
7494                                                       max min)
7495        ((fr400 (unit u-media-2-quad
7496                      (in  FRinti FRintieven)
7497                      (in  FRintj FRintjeven))))
7498   )
7499 )
7500
7501 (media-quad-cross-multiply-cross-acc mqxmacxhs HI ext add h-acc40S ACC40Sk
7502                         (const DI #x7fffffffff) (const DI #xffffff8000000000)
7503                         OP_78 OPE1_01
7504                         "Media quad cross multiply and cross accumulate signed")
7505
7506 (define-pmacro (media-quad-cross-multiply-acc-semantics
7507                 cond mode conv addop rhw res max min)
7508   (if (register-unaligned res 4)
7509       (c-call VOID "@cpu@_media_acc_not_aligned")
7510       (if (orif (register-unaligned FRintieven 2)
7511                 (register-unaligned FRintjeven 2))
7512           (c-call VOID "@cpu@_media_register_not_aligned")
7513           (if cond
7514               (sequence ((mode argihi) (mode argilo)
7515                          (mode argjhi) (mode argjlo))
7516                         (extract-hilo FRintieven 0 FRintjeven 0
7517                                       argihi argilo argjhi argjlo)
7518                         (media-multiply-acc-semantics conv argihi addop argjlo
7519                                                       res
7520                                                       max min (msr-sie-acci))
7521                         (media-multiply-acc-semantics conv argilo addop argjhi
7522                                                       (nextreg rhw res 1)
7523                                                       max min (msr-sie-acci-1))
7524                         (extract-hilo FRintieven 1 FRintjeven 1
7525                                       argihi argilo argjhi argjlo)
7526                         (media-multiply-acc-semantics conv argihi addop argjlo
7527                                                       (nextreg rhw res 2)
7528                                                       max min (msr-sie-acci-2))
7529                         (media-multiply-acc-semantics conv argilo addop argjhi
7530                                                       (nextreg rhw res 3)
7531                                                       max min
7532                                                       (msr-sie-acci-3))))))
7533 )
7534
7535 (define-pmacro (media-quad-cross-multiply-acc
7536                 name mode conv addop rhw res max min op ope comment)
7537   (dni name
7538        (comment)
7539        ((UNIT FM0) (MACH fr400) (FR400-MAJOR M-2))
7540        (.str name "$pack $FRintieven,$FRintjeven,$" res)
7541        (+ pack res op FRintieven ope FRintjeven)
7542        (media-quad-cross-multiply-acc-semantics 1 mode conv addop rhw res
7543                                                 max min)
7544        ((fr400 (unit u-media-2-quad
7545                      (in FRinti FRintieven)
7546                      (in FRintj FRintjeven))))
7547   )
7548 )
7549
7550 (media-quad-cross-multiply-acc mqmacxhs HI ext add h-acc40S ACC40Sk
7551                         (const DI #x7fffffffff) (const DI #xffffff8000000000)
7552                         OP_78 OPE1_02
7553                         "Media quad cross multiply and accumulate signed")
7554
7555 (define-pmacro (media-complex-semantics
7556                 conv lhs1 rhs1 lhs2 rhs2 res max min sie)
7557   (sequence ((DI tmp1) (DI tmp2))
7558             (media-multiply-semantics conv lhs1 rhs1 tmp1)
7559             (media-multiply-semantics conv lhs2 rhs2 tmp2)
7560             (set tmp1 (sub tmp1 tmp2))
7561             (saturate-v tmp1 max min sie res))
7562 )
7563
7564 (define-pmacro (media-complex-semantics-i
7565                 conv lhs1 rhs1 lhs2 rhs2 res max min sie)
7566   (sequence ((DI tmp1) (DI tmp2))
7567             (media-multiply-semantics conv lhs1 rhs1 tmp1)
7568             (media-multiply-semantics conv lhs2 rhs2 tmp2)
7569             (set tmp1 (add tmp1 tmp2))
7570             (saturate-v tmp1 max min sie res))
7571 )
7572
7573 (define-pmacro (media-dual-complex-semantics mode conv rhs1 rhs2 max min)
7574   (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
7575             (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
7576             (media-complex-semantics conv argihi rhs1 argilo rhs2 ACC40Sk
7577                                      max min (msr-sie-acci)))
7578 )
7579
7580 (define-pmacro (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
7581   (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
7582             (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
7583             (media-complex-semantics-i conv argihi rhs1 argilo rhs2 ACC40Sk
7584                                      max min (msr-sie-acci)))
7585 )
7586
7587 (define-pmacro (media-dual-complex
7588                 name mode conv rhs1 rhs2 max min op ope comment)
7589   (dni name
7590        (comment)
7591        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1))
7592        (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
7593        (+ pack ACC40Sk op FRinti ope FRintj)
7594        (media-dual-complex-semantics mode conv rhs1 rhs2 max min)
7595        ((fr400 (unit u-media-2))
7596         (fr500 (unit u-media)))
7597   )
7598 )
7599
7600 (define-pmacro (media-dual-complex-i
7601                 name mode conv rhs1 rhs2 max min op ope comment)
7602   (dni name
7603        (comment)
7604        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1))
7605        (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
7606        (+ pack ACC40Sk op FRinti ope FRintj)
7607        (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
7608        ((fr400 (unit u-media-2))
7609         (fr500 (unit u-media-dual-mul)))
7610   )
7611 )
7612
7613 (media-dual-complex mcpxrs HI ext argjhi argjlo
7614                     (const DI #x7fffffffff) (const DI #xffffff8000000000)
7615                     OP_7B OPE1_20
7616                     "Media dual complex real signed with saturation")
7617
7618 (media-dual-complex mcpxru UHI zext argjhi argjlo
7619                     (const DI #xffffffffff) (const DI 0)
7620                     OP_7B OPE1_21
7621                     "Media dual complex real unsigned with saturation")
7622
7623 (media-dual-complex-i mcpxis HI ext argjlo argjhi
7624                     (const DI #x7fffffffff) (const DI #xffffff8000000000)
7625                     OP_7B OPE1_22
7626                     "Media dual complex imaginary signed with saturation")
7627
7628 (media-dual-complex-i mcpxiu UHI zext argjlo argjhi
7629                     (const DI #xffffffffff) (const DI 0)
7630                     OP_7B OPE1_23
7631                     "Media dual complex imaginary unsigned with saturation")
7632
7633 (define-pmacro (conditional-media-dual-complex
7634                 name mode conv rhs1 rhs2 max min op ope comment)
7635   (dni name
7636        (comment)
7637        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1) CONDITIONAL)
7638        (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
7639        (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
7640        (if (eq CCi (or cond 2))
7641            (media-dual-complex-semantics mode conv rhs1 rhs2 max min))
7642        ((fr400 (unit u-media-2))
7643         (fr500 (unit u-media)))
7644   )
7645 )
7646
7647 (define-pmacro (conditional-media-dual-complex-i
7648                 name mode conv rhs1 rhs2 max min op ope comment)
7649   (dni name
7650        (comment)
7651        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-1) CONDITIONAL)
7652        (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
7653        (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
7654        (if (eq CCi (or cond 2))
7655            (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min))
7656        ((fr400 (unit u-media-2))
7657         (fr500 (unit u-media-dual-mul)))
7658   )
7659 )
7660
7661 (conditional-media-dual-complex cmcpxrs HI ext argjhi argjlo
7662                     (const DI #x7fffffffff) (const DI #xffffff8000000000)
7663                     OP_75 OPE4_0
7664                     "Conditional Media dual complex real signed with saturation")
7665
7666 (conditional-media-dual-complex cmcpxru UHI zext argjhi argjlo
7667                     (const DI #xffffffffff) (const DI 0)
7668                     OP_75 OPE4_1
7669                     "Conditional Media dual complex real unsigned with saturation")
7670
7671 (conditional-media-dual-complex-i cmcpxis HI ext argjlo argjhi
7672                     (const DI #x7fffffffff) (const DI #xffffff8000000000)
7673                     OP_75 OPE4_2
7674                     "Conditional Media dual complex imaginary signed with saturation")
7675
7676 (conditional-media-dual-complex-i cmcpxiu UHI zext argjlo argjhi
7677                     (const DI #xffffffffff) (const DI 0)
7678                     OP_75 OPE4_3
7679                     "Conditional Media dual complex imaginary unsigned with saturation")
7680
7681 (define-pmacro (media-quad-complex
7682                 name mode conv rhs1 rhs2 max min op ope comment)
7683   (dni name
7684        (comment)
7685        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-2))
7686        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
7687        (+ pack ACC40Sk op FRintieven ope FRintjeven)
7688        (if (register-unaligned ACC40Sk 2)
7689            (c-call VOID "@cpu@_media_acc_not_aligned")
7690            (if (orif (register-unaligned FRintieven 2)
7691                      (register-unaligned FRintjeven 2))
7692                (c-call VOID "@cpu@_media_register_not_aligned")
7693                (sequence ((mode argihi) (mode argilo)
7694                           (mode argjhi) (mode argjlo))
7695                          (extract-hilo FRintieven 0 FRintjeven 0
7696                                        argihi argilo argjhi argjlo)
7697                          (media-complex-semantics conv argihi rhs1 argilo rhs2
7698                                                   ACC40Sk
7699                                                   max min (msr-sie-acci))
7700                          (extract-hilo FRintieven 1 FRintjeven 1
7701                                        argihi argilo argjhi argjlo)
7702                          (media-complex-semantics conv argihi rhs1 argilo rhs2
7703                                                   (nextreg h-acc40S ACC40Sk 1)
7704                                                   max min (msr-sie-acci-1)))))
7705        ((fr400 (unit u-media-2-quad
7706                      (in FRinti FRintieven)
7707                      (in FRintj FRintjeven)))
7708         (fr500 (unit u-media-quad-complex
7709                      (in FRinti FRintieven)
7710                      (in FRintj FRintjeven))))
7711   )
7712 )
7713
7714 (define-pmacro (media-quad-complex-i
7715                 name mode conv rhs1 rhs2 max min op ope comment)
7716   (dni name
7717        (comment)
7718        ((UNIT FM01) (FR500-MAJOR M-4) (FR400-MAJOR M-2))
7719        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
7720        (+ pack ACC40Sk op FRintieven ope FRintjeven)
7721        (if (register-unaligned ACC40Sk 2)
7722            (c-call VOID "@cpu@_media_acc_not_aligned")
7723            (if (orif (register-unaligned FRintieven 2)
7724                      (register-unaligned FRintjeven 2))
7725                (c-call VOID "@cpu@_media_register_not_aligned")
7726                (sequence ((mode argihi) (mode argilo)
7727                           (mode argjhi) (mode argjlo))
7728                          (extract-hilo FRintieven 0 FRintjeven 0
7729                                        argihi argilo argjhi argjlo)
7730                          (media-complex-semantics-i conv argihi rhs1 argilo rhs2
7731                                                   ACC40Sk
7732                                                   max min (msr-sie-acci))
7733                          (extract-hilo FRintieven 1 FRintjeven 1
7734                                        argihi argilo argjhi argjlo)
7735                          (media-complex-semantics-i conv argihi rhs1 argilo rhs2
7736                                                   (nextreg h-acc40S ACC40Sk 1)
7737                                                   max min (msr-sie-acci-1)))))
7738        ((fr400 (unit u-media-2-quad
7739                      (in FRinti FRintieven)
7740                      (in FRintj FRintjeven)))
7741         (fr500 (unit u-media-quad-complex
7742                      (in FRinti FRintieven)
7743                      (in FRintj FRintjeven))))
7744   )
7745 )
7746
7747 (media-quad-complex mqcpxrs HI ext argjhi argjlo
7748                     (const DI #x7fffffffff) (const DI #xffffff8000000000)
7749                     OP_7B OPE1_24
7750                     "Media quad complex real signed with saturation")
7751
7752 (media-quad-complex mqcpxru UHI zext argjhi argjlo
7753                     (const DI #xffffffffff) (const DI 0)
7754                     OP_7B OPE1_25
7755                     "Media quad complex real unsigned with saturation")
7756
7757 (media-quad-complex-i mqcpxis HI ext argjlo argjhi
7758                     (const DI #x7fffffffff) (const DI #xffffff8000000000)
7759                     OP_7B OPE1_26
7760                     "Media quad complex imaginary signed with saturation")
7761
7762 (media-quad-complex-i mqcpxiu UHI zext argjlo argjhi
7763                     (const DI #xffffffffff) (const DI 0)
7764                     OP_7B OPE1_27
7765                     "Media quad complex imaginary unsigned with saturation")
7766
7767 (define-pmacro (media-pack src1 src2 targ offset)
7768   (sequence ()
7769             (set (halfword hi targ offset) (halfword lo src1 offset))
7770             (set (halfword lo targ offset) (halfword lo src2 offset)))
7771 )
7772
7773 (define-pmacro (media-expand-halfword-to-word-semantics cond)
7774   (if cond
7775       (sequence ((UHI tmp))
7776                 (if (and u6 1)
7777                     (set tmp (halfword lo FRinti 0))
7778                     (set tmp (halfword hi FRinti 0)))
7779                 (set (halfword hi FRintk 0) tmp)
7780                 (set (halfword lo FRintk 0) tmp)))
7781 )
7782
7783 (dni mexpdhw
7784      "Media expand halfword to word"
7785      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
7786      "mexpdhw$pack $FRinti,$u6,$FRintk"
7787      (+ pack FRintk OP_7B FRinti OPE1_32 u6)
7788      (media-expand-halfword-to-word-semantics 1)
7789      ((fr400 (unit u-media-3))
7790       (fr500 (unit u-media)))
7791 )
7792
7793 (dni cmexpdhw
7794      "Conditional media expand halfword to word"
7795      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1) CONDITIONAL)
7796      "cmexpdhw$pack $FRinti,$u6,$FRintk,$CCi,$cond"
7797      (+ pack FRintk OP_76 FRinti CCi cond OPE4_2 u6)
7798      (media-expand-halfword-to-word-semantics (eq CCi (or cond 2)))
7799      ((fr400 (unit u-media-3))
7800       (fr500 (unit u-media)))
7801 )
7802
7803 (define-pmacro (media-expand-halfword-to-double-semantics cond)
7804   (if (register-unaligned FRintkeven 2)
7805       (c-call VOID "@cpu@_media_register_not_aligned")
7806       (if cond
7807           (sequence ((UHI tmp))
7808                     ; a hack to get FRintkeven referenced for profiling
7809                     (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
7810                     (if (and u6 1)
7811                         (set tmp (halfword lo FRinti 0))
7812                         (set tmp (halfword hi FRinti 0)))
7813                     (set (halfword hi FRintkeven 0) tmp)
7814                     (set (halfword lo FRintkeven 0) tmp)
7815                     (set (halfword hi FRintkeven 1) tmp)
7816                     (set (halfword lo FRintkeven 1) tmp))))
7817 )
7818
7819 (dni mexpdhd
7820      "Media expand halfword to double"
7821      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2))
7822      "mexpdhd$pack $FRinti,$u6,$FRintkeven"
7823      (+ pack FRintkeven OP_7B FRinti OPE1_33 u6)
7824      (media-expand-halfword-to-double-semantics 1)
7825      ((fr400 (unit u-media-dual-expand
7826                      (out FRintk FRintkeven)))
7827       (fr500 (unit u-media-dual-expand
7828                      (out FRintk FRintkeven))))
7829 )
7830
7831 (dni cmexpdhd
7832      "Conditional media expand halfword to double"
7833      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2) CONDITIONAL)
7834      "cmexpdhd$pack $FRinti,$u6,$FRintkeven,$CCi,$cond"
7835      (+ pack FRintkeven OP_76 FRinti CCi cond OPE4_3 u6)
7836      (media-expand-halfword-to-double-semantics (eq CCi (or cond 2)))
7837      ((fr400 (unit u-media-dual-expand
7838                    (out FRintk FRintkeven)))
7839       (fr500 (unit u-media-dual-expand
7840                    (out FRintk FRintkeven))))
7841 )
7842
7843 (dni mpackh
7844      "Media halfword pack"
7845      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
7846      "mpackh$pack $FRinti,$FRintj,$FRintk"
7847      (+ pack FRintk OP_7B FRinti OPE1_34 FRintj)
7848      (media-pack FRinti FRintj FRintk 0)
7849      ((fr400 (unit u-media-3))
7850       (fr500 (unit u-media)))
7851 )
7852
7853 (dni mdpackh
7854      "Media dual pack"
7855      ((UNIT FM01) (FR500-MAJOR M-5) (FR400-MAJOR M-2))
7856      "mdpackh$pack $FRintieven,$FRintjeven,$FRintkeven"
7857      (+ pack FRintkeven OP_7B FRintieven OPE1_36 FRintjeven)
7858      (if (orif (register-unaligned FRintieven 2)
7859                (orif (register-unaligned FRintjeven 2)
7860                      (register-unaligned FRintkeven 2)))
7861          (c-call VOID "@cpu@_media_register_not_aligned")
7862          (sequence ()
7863                    ; hack to get these referenced for profiling
7864                    (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
7865                    (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
7866                    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
7867                    (media-pack FRintieven FRintjeven FRintkeven 0)
7868                    (media-pack FRintieven FRintjeven FRintkeven 1)))
7869      ((fr400 (unit u-media-3-quad
7870                    (in  FRinti FRintieven)
7871                    (in  FRintj FRintjeven)
7872                    (out FRintk FRintkeven)))
7873       (fr500 (unit u-media-quad-arith
7874                    (in  FRinti FRintieven)
7875                    (in  FRintj FRintjeven)
7876                    (out FRintk FRintkeven))))
7877 )
7878
7879 (define-pmacro (media-unpack src soff targ toff)
7880   (sequence ()
7881             (set (halfword hi targ toff) (halfword hi src soff))
7882             (set (halfword lo targ toff) (halfword hi src soff))
7883             (set (halfword hi targ (add toff 1)) (halfword lo src soff))
7884             (set (halfword lo targ (add toff 1)) (halfword lo src soff)))
7885 )
7886
7887 (dni munpackh
7888      "Media halfword unpack"
7889      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2))
7890      "munpackh$pack $FRinti,$FRintkeven"
7891      (+ pack FRintkeven OP_7B FRinti OPE1_35 (FRj-null))
7892      (if (register-unaligned FRintkeven 2)
7893          (c-call VOID "@cpu@_media_register_not_aligned")
7894          (sequence ()
7895                    ; hack to get these referenced for profiling
7896                    (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
7897                    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
7898                    (media-unpack FRinti 0 FRintkeven 0)))
7899      ((fr400 (unit u-media-dual-expand
7900                    (out FRintk FRintkeven)))
7901       (fr500 (unit u-media-dual-expand
7902                    (out FRintk FRintkeven))))
7903 )
7904
7905 (dni mdunpackh
7906      "Media dual unpack"
7907      ((UNIT FM01) (FR500-MAJOR M-7) (MACH simple,tomcat,frv))
7908      "mdunpackh$pack $FRintieven,$FRintk"
7909      (+ pack FRintk OP_7B FRintieven OPE1_37 (FRj-null))
7910      (if (orif (register-unaligned FRintieven 2) (register-unaligned FRintk 4))
7911          (c-call VOID "@cpu@_media_register_not_aligned")
7912          (sequence ()
7913                    ; hack to get these referenced for profiling
7914                    (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
7915                    (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
7916                    (media-unpack FRintieven 0 FRintk 0)
7917                    (media-unpack FRintieven 1 FRintk 2)))
7918      ((fr500 (unit u-media-dual-unpack
7919                    (in FRinti FRintieven))))
7920 )
7921
7922 (define-pmacro (ubyte num arg offset)
7923   (reg (.sym h-fr_ num) (add (index-of arg) offset)))
7924
7925 (define-pmacro (mbtoh-semantics cond)
7926   (if (register-unaligned FRintkeven 2)
7927       (c-call VOID "@cpu@_media_register_not_aligned")
7928       (if cond
7929           (sequence ()
7930                     (set (halfword hi FRintkeven 0) (ubyte 3 FRintj 0))
7931                     (set (halfword lo FRintkeven 0) (ubyte 2 FRintj 0))
7932                     (set (halfword hi FRintkeven 1) (ubyte 1 FRintj 0))
7933                     (set (halfword lo FRintkeven 1) (ubyte 0 FRintj 0)))))
7934 )
7935
7936 (dni mbtoh
7937      "Media convert byte to halfword"
7938      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2))
7939      "mbtoh$pack $FRintj,$FRintkeven"
7940      (+ pack FRintkeven OP_7B (FRi-null) OPE1_38 FRintj)
7941      (sequence ()
7942                ; hack to get these referenced for profiling
7943                (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
7944                (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
7945                (mbtoh-semantics 1))
7946      ((fr400 (unit u-media-dual-expand
7947                    (in FRinti FRintieven)))
7948       (fr500 (unit u-media-dual-btoh
7949                    (in FRinti FRintieven))))
7950 )
7951
7952 (dni cmbtoh
7953      "Conditional media convert byte to halfword"
7954      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2) CONDITIONAL)
7955      "cmbtoh$pack $FRintj,$FRintkeven,$CCi,$cond"
7956      (+ pack FRintkeven OP_77 (FRi-null) CCi cond OPE4_0 FRintj)
7957      (mbtoh-semantics (eq CCi (or cond 2)))
7958      ((fr400 (unit u-media-dual-expand
7959                    (out FRintk FRintkeven)))
7960       (fr500 (unit u-media-dual-btoh
7961                    (out FRintk FRintkeven))))
7962 )
7963
7964 (define-pmacro (mhtob-semantics cond)
7965   (if (register-unaligned FRintjeven 2)
7966       (c-call VOID "@cpu@_media_register_not_aligned")
7967       (if cond
7968           (sequence ()
7969                     (set (ubyte 3 FRintk 0) (halfword hi FRintjeven 0))
7970                     (set (ubyte 2 FRintk 0) (halfword lo FRintjeven 0))
7971                     (set (ubyte 1 FRintk 0) (halfword hi FRintjeven 1))
7972                     (set (ubyte 0 FRintk 0) (halfword lo FRintjeven 1)))))
7973 )
7974
7975 (dni mhtob
7976      "Media convert halfword to byte"
7977      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2))
7978      "mhtob$pack $FRintjeven,$FRintk"
7979      (+ pack FRintk OP_7B (FRi-null) OPE1_39 FRintjeven)
7980      (sequence ()
7981                ; hack to get these referenced for profiling
7982                (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
7983                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
7984                (mhtob-semantics 1))
7985      ((fr400 (unit u-media-dual-htob
7986                    (in FRintj FRintjeven)))
7987       (fr500 (unit u-media-dual-htob
7988                    (in FRintj FRintjeven))))
7989 )
7990
7991 (dni cmhtob
7992      "Conditional media convert halfword to byte"
7993      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-2) CONDITIONAL)
7994      "cmhtob$pack $FRintjeven,$FRintk,$CCi,$cond"
7995      (+ pack FRintk OP_77 (FRi-null) CCi cond OPE4_1 FRintjeven)
7996      (sequence ()
7997                ; hack to get these referenced for profiling
7998                (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
7999                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
8000                (mhtob-semantics (eq CCi (or cond 2))))
8001      ((fr400 (unit u-media-dual-htob
8002                    (in FRintj FRintjeven)))
8003       (fr500 (unit u-media-dual-htob
8004                    (in FRintj FRintjeven))))
8005 )
8006
8007 (define-pmacro (mbtohe-semantics cond)
8008   (if (register-unaligned FRintk 4)
8009       (c-call VOID "@cpu@_media_register_not_aligned")
8010       (if cond
8011           (sequence ()
8012                     (set (halfword hi FRintk 0) (ubyte 3 FRintj 0))
8013                     (set (halfword lo FRintk 0) (ubyte 3 FRintj 0))
8014                     (set (halfword hi FRintk 1) (ubyte 2 FRintj 0))
8015                     (set (halfword lo FRintk 1) (ubyte 2 FRintj 0))
8016                     (set (halfword hi FRintk 2) (ubyte 1 FRintj 0))
8017                     (set (halfword lo FRintk 2) (ubyte 1 FRintj 0))
8018                     (set (halfword hi FRintk 3) (ubyte 0 FRintj 0))
8019                     (set (halfword lo FRintk 3) (ubyte 0 FRintj 0)))))
8020 )
8021
8022 (dni mbtohe
8023      "Media convert byte to halfword extended"
8024      ((UNIT FM01) (FR500-MAJOR M-7) (MACH simple,tomcat,frv))
8025      "mbtohe$pack $FRintj,$FRintk"
8026      (+ pack FRintk OP_7B (FRi-null) OPE1_3A FRintj)
8027      (sequence ()
8028                ; hack to get these referenced for profiling
8029                (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
8030                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
8031                (mbtohe-semantics 1))
8032      ((fr500 (unit u-media-dual-btohe)))
8033 )
8034
8035 (dni cmbtohe
8036      "Conditional media convert byte to halfword extended"
8037      ((UNIT FM01) (FR500-MAJOR M-7) CONDITIONAL (MACH simple,tomcat,frv))
8038      "cmbtohe$pack $FRintj,$FRintk,$CCi,$cond"
8039      (+ pack FRintk OP_77 (FRi-null) CCi cond OPE4_2 FRintj)
8040      (sequence ()
8041                ; hack to get these referenced for profiling
8042                (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
8043                (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
8044                (mbtohe-semantics (eq CCi (or cond 2))))
8045      ((fr500 (unit u-media-dual-btohe)))
8046 )
8047
8048 (dni mclracc
8049      "Media clear accumulator(s)"
8050      ((UNIT FM01) (FR500-MAJOR M-3))
8051      "mclracc$pack $ACC40Sk,$A"
8052      (+ pack ACC40Sk OP_7B A (misc-null-10) OPE1_3B (FRj-null))
8053      (c-call VOID "@cpu@_clear_accumulators" (index-of ACC40Sk) A)
8054      ((fr400 (unit u-media-4))
8055       (fr500 (unit u-media)))
8056 )
8057
8058 (dni mrdacc
8059      "Media read accumulator"
8060      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
8061      "mrdacc$pack $ACC40Si,$FRintk"
8062      (+ pack FRintk OP_7B ACC40Si OPE1_3C (FRj-null))
8063      (set FRintk ACC40Si)
8064      ((fr400 (unit u-media-4))
8065       (fr500 (unit u-media)))
8066 )
8067
8068 (dni mrdaccg
8069      "Media read accumulator guard"
8070      ((UNIT FM01) (FR500-MAJOR M-2) (FR400-MAJOR M-1))
8071      "mrdaccg$pack $ACCGi,$FRintk"
8072      (+ pack FRintk OP_7B ACCGi OPE1_3E (FRj-null))
8073      (set FRintk ACCGi)
8074      ((fr400 (unit u-media-4-accg))
8075       (fr500 (unit u-media)))
8076 )
8077
8078 (dni mwtacc
8079      "Media write accumulator"
8080      ((UNIT FM01) (FR500-MAJOR M-3) (FR400-MAJOR M-1))
8081      "mwtacc$pack $FRinti,$ACC40Sk"
8082      (+ pack ACC40Sk OP_7B FRinti OPE1_3D (FRj-null))
8083      (set ACC40Sk (or (and ACC40Sk (const DI #xffffffff00000000))
8084                      FRinti))
8085      ((fr400 (unit u-media-4))
8086       (fr500 (unit u-media)))
8087 )
8088
8089 (dni mwtaccg
8090      "Media write accumulator guard"
8091      ((UNIT FM01) (FR500-MAJOR M-3) (FR400-MAJOR M-1))
8092      "mwtaccg$pack $FRinti,$ACCGk"
8093      (+ pack ACCGk OP_7B FRinti OPE1_3F (FRj-null))
8094      (set ACCGk FRinti)
8095      ((fr400 (unit u-media-4-accg))
8096       (fr500 (unit u-media)))
8097 )
8098
8099 (define-pmacro (media-cop num op)
8100   (dni (.sym mcop num)
8101        "Media custom instruction"
8102        ((UNIT FM01) (FR500-MAJOR M-1) (MACH frv))
8103        (.str "mcop" num "$pack $FRi,$FRj,$FRk")
8104        (+ pack FRk op FRi OPE1_00 FRj)
8105        (c-call VOID "@cpu@_media_cop" num)
8106        ()
8107   )
8108 )
8109
8110 (media-cop 1 OP_7C)
8111 (media-cop 2 OP_7D)
8112
8113 ; nop
8114 ; A nop is defined to be a "ori gr0,0,gr0"
8115 ; This needn't be a macro-insn, but making it one greatly simplifies decode.c
8116 ; On the other hand spending a little time in the decoder is often worth it.
8117 ;
8118 (dnmi nop "nop"
8119      ((UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
8120      "nop$pack"
8121      (emit ori pack (GRi 0) (s12 0) (GRk 0))
8122 )
8123
8124 ; Floating point NOP
8125 (dni fnop
8126      "Floating point nop"
8127      ((UNIT FM01) (FR500-MAJOR F-8) (MACH simple,tomcat,fr500,frv))
8128      "fnop$pack"
8129      (+ pack (rd-null) OP_79 (FRi-null) OPE1_0D (FRj-null))
8130      (nop)
8131      ()
8132 )
8133
8134 ; Media NOP
8135 ; A special case of mclracc
8136 (dnmi mnop "Media nop"
8137       (NO-DIS (UNIT FM01) (FR500-MAJOR M-3))
8138      "mnop$pack"
8139      (emit mclracc pack (ACC40Sk 63) (A 1))
8140 )
8141
8142 ; A return instruction
8143 (dnmi ret "return"
8144       (NO-DIS (UNIT B01) (FR500-MAJOR B-3) (FR400-MAJOR B-3))
8145       "ret$pack"
8146       (emit bralr pack (hint_taken 2))
8147 )
8148
8149 (dnmi cmp "compare"
8150       (NO-DIS (UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
8151       "cmp$pack $GRi,$GRj,$ICCi_1"
8152       (emit subcc pack GRi GRj (GRk 0) ICCi_1)
8153 )
8154
8155 (dnmi cmpi "compare immediate"
8156       (NO-DIS (UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
8157       "cmpi$pack $GRi,$s10,$ICCi_1"
8158       (emit subicc pack GRi s10 (GRk 0) ICCi_1)
8159 )
8160
8161 (dnmi ccmp "conditional compare"
8162       (NO-DIS (UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
8163       "ccmp$pack $GRi,$GRj,$CCi,$cond"
8164       (emit csubcc pack GRi GRj (GRk 0) CCi cond)
8165 )
8166
8167 (dnmi mov "move"
8168       (NO-DIS (UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1))
8169       "mov$pack $GRi,$GRk"
8170       (emit ori pack GRi (s12 0) GRk)
8171 )   
8172
8173 (dnmi cmov "conditional move"
8174       (NO-DIS (UNIT I01) (FR500-MAJOR I-1) (FR400-MAJOR I-1) CONDITIONAL)
8175       "cmov$pack $GRi,$GRk,$CCi,$cond"
8176       (emit cor pack GRi (GRj 0) GRk CCi cond)
8177 )