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