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