Home | History | Annotate | Line # | Download | only in cpu
      1 ; Fujitsu FRV opcode support, for GNU Binutils.  -*- Scheme -*-
      2 ;
      3 ; Copyright 2000, 2001, 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
      4 ;
      5 ; Contributed by Red Hat Inc; developed under contract from Fujitsu.
      6 ;
      7 ; This file is part of the GNU Binutils.
      8 ;
      9 ; This program is free software; you can redistribute it and/or modify
     10 ; it under the terms of the GNU General Public License as published by
     11 ; the Free Software Foundation; either version 3 of the License, or
     12 ; (at your option) any later version.
     13 ;
     14 ; This program is distributed in the hope that it will be useful,
     15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 ; GNU General Public License for more details.
     18 ;
     19 ; You should have received a copy of the GNU General Public License
     20 ; along with this program; if not, write to the Free Software
     21 ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     22 ; MA 02110-1301, USA.
     23 
     24 (include "simplify.inc")
     25 
     26 ; define-arch must appear first
     27 
     28 (define-arch
     29   (name frv) ; name of cpu architecture
     30   (comment "Fujitsu FRV")
     31   (insn-lsb0? #t)
     32   (machs frv fr550 fr500 fr450 fr400 tomcat simple)
     33   (isas frv)
     34 )
     35 
     36 (define-isa
     37   (name frv)
     38   (base-insn-bitsize 32)
     39   ; Initial bitnumbers to decode insns by.
     40   (decode-assist (24 23 22 21 20 19 18))
     41   (liw-insns 1)       ; The frv fetches  up to 1 insns at a time.
     42   (parallel-insns 8)  ; The frv executes up to 8 insns at a time.
     43 )
     44 
     45 ; Cpu family definitions.
     46 ;
     47 (define-cpu
     48   ; cpu names must be distinct from the architecture name and machine names.
     49   ; The "b" suffix stands for "base" and is the convention.
     50   ; The "f" suffix stands for "family" and is the convention.
     51   (name frvbf)
     52   (comment "Fujitsu FRV base family")
     53   (endian big)
     54   (word-bitsize 32)
     55 )
     56 
     58 ; Generic FR-V machine. Supports the entire architecture
     59 (define-mach
     60   (name frv)
     61   (comment "Generic FRV cpu")
     62   (cpu frvbf)
     63 )
     64 (define-model
     65   (name frv) (comment "Generic FRV model") (attrs)
     66   (mach frv)
     67 
     68   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
     69 
     70   ; `state' is a list of variables for recording model state
     71   ; (state)
     72 
     73   (unit u-exec "Execution Unit" ()
     74 	1 1 ; issue done
     75 	() ; state
     76 	() ; inputs
     77 	() ; outputs
     78 	() ; profile action (default)
     79 	)
     80 )
     81 
     83 ; FR550 machine
     84 (define-mach
     85   (name fr550)
     86   (comment "FR550 cpu")
     87   (cpu frvbf)
     88 )
     89 (define-model
     90   (name fr550) (comment "FR550 model") (attrs)
     91   (mach fr550)
     92 
     93   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
     94 
     95   ; `state' is a list of variables for recording model state
     96   (state
     97    ; State items
     98    ; These are all masks with each bit representing one register.
     99    (prev-fr-load      DI) ; Previous use of FR  register was target of a load
    100    (prev-fr-complex-1 DI) ; Previous use of FR  register has variable latency
    101    (prev-fr-complex-2 DI) ; Previous use of FR  register has variable latency
    102    (prev-ccr-complex  DI) ; Previous use of CCR register has variable latency
    103    (prev-acc-mmac     DI) ; Previous use of ACC register was a MMAC category
    104    (cur-fr-load       DI) ; Current  use of FR  register was target of a load
    105    (cur-fr-complex-1  DI) ; Current  use of FR  register has variable latency
    106    (cur-fr-complex-2  DI) ; Current  use of FR  register has variable latency
    107    (cur-ccr-complex   SI) ; Current  use of CCR register has variable latency
    108    (cur-acc-mmac      DI) ; Current  use of ACC register was a MMAC category
    109   )
    110   ; Basic unit for instructions with no latency penalties
    111   (unit u-exec "Execution Unit" ()
    112 	1 1 ; issue done
    113 	() ; state
    114 	() ; inputs
    115 	() ; outputs
    116 	() ; profile action (default)
    117 	)
    118   ; Basic integer insn unit
    119   (unit u-integer "Integer Unit" ()
    120 	1 1 ; issue done
    121 	() ; state
    122 	((GRi INT -1) (GRj INT -1)) ; inputs
    123 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
    124 	() ; profile action (default)
    125 	)
    126   ; Integer multiplication unit
    127   (unit u-imul "Integer Multiplication Unit" ()
    128 	1 1 ; issue done
    129 	() ; state
    130 	((GRi INT -1) (GRj INT -1)) ; inputs
    131 	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
    132 	() ; profile action (default)
    133 	)
    134   ; Integer division unit
    135   (unit u-idiv "Integer Division Unit" ()
    136 	1 1 ; issue done
    137 	() ; state
    138 	((GRi INT -1) (GRj INT -1)) ; inputs
    139 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
    140 	() ; profile action (default)
    141 	)
    142   ; Branch unit
    143   (unit u-branch "Branch Unit" ()
    144 	1 1 ; issue done
    145 	() ; state
    146 	((GRi INT -1) (GRj INT -1)
    147 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
    148 	((pc)) ; outputs
    149 	() ; profile action (default)
    150 	)
    151   ; Trap unit
    152   (unit u-trap "Trap Unit" ()
    153 	1 1 ; issue done
    154 	() ; state
    155 	((GRi INT -1) (GRj INT -1)
    156 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
    157 	() ; outputs
    158 	() ; profile action (default)
    159 	)
    160   ; Condition code check unit
    161   (unit u-check "Check Unit" ()
    162 	1 1 ; issue done
    163 	() ; state
    164 	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
    165 	() ; outputs
    166 	() ; profile action (default)
    167 	)
    168   ; Float Arithmetic unit
    169   (unit u-float-arith "Float Arithmetic unit" ()
    170 	1 1 ; issue done
    171 	() ; state
    172 	((FRi INT -1) (FRj INT -1) ; inputs
    173 	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
    174 	((FRk INT -1) (FRdoublek INT -1)) ; outputs
    175 	() ; profile action (default)
    176 	)
    177   ; Float Dual Arithmetic unit
    178   (unit u-float-dual-arith "Float Arithmetic unit" ()
    179 	; This unit has a 2 cycle penalty -- see table 14-14 in the fr550 LSI
    180 	1 3 ; issue done
    181 	() ; state
    182 	((FRi INT -1) (FRj INT -1) ; inputs
    183 	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
    184 	((FRk INT -1) (FRdoublek INT -1)) ; outputs
    185 	() ; profile action (default)
    186 	)
    187   ; Float Div unit
    188   (unit u-float-div "Float Div unit" ()
    189 	1 1 ; issue done
    190 	() ; state
    191 	((FRi INT -1) (FRj INT -1)) ; inputs
    192 	((FRk INT -1)) ; outputs
    193 	() ; profile action (default)
    194 	)
    195   ; Float Square Root unit
    196   (unit u-float-sqrt "Float Square Root unit" ()
    197 	1 1 ; issue done
    198 	() ; state
    199 	((FRj INT -1) (FRdoublej INT -1)) ; inputs
    200 	((FRk INT -1) (FRdoublek INT -1)) ; outputs
    201 	() ; profile action (default)
    202 	)
    203   ; Float Compare unit
    204   (unit u-float-compare "Float Compare unit" ()
    205 	1 1 ; issue done
    206 	() ; state
    207 	((FRi INT -1) (FRj INT -1)
    208 	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
    209 	((FCCi_2 INT -1)) ; outputs
    210 	() ; profile action (default)
    211 	)
    212   ; Dual Float Compare unit
    213   (unit u-float-dual-compare "Float Dual Compare unit" ()
    214 	; This unit has a 2 cycle penalty -- see table 14-14 in the fr550 LSI
    215 	1 3 ; issue done
    216 	() ; state
    217 	((FRi INT -1) (FRj INT -1)) ; inputs
    218 	((FCCi_2 INT -1)) ; outputs
    219 	() ; profile action (default)
    220 	)
    221   ; FR Move to GR unit
    222   (unit u-fr2gr "FR Move to GR Unit" ()
    223 	1 1 ; issue done
    224 	() ; state
    225 	((FRintk INT -1)) ; inputs
    226 	((GRj INT -1)) ; outputs
    227 	() ; profile action (default)
    228 	)
    229   ; GR Move to FR unit
    230   (unit u-gr2fr "GR Move to FR Unit" ()
    231 	1 1 ; issue done
    232 	() ; state
    233 	((GRj INT -1)) ; inputs
    234 	((FRintk INT -1)) ; outputs
    235 	() ; profile action (default)
    236 	)
    237   ; SPR Move to GR unit
    238   (unit u-spr2gr "SPR Move to GR Unit" ()
    239 	1 1 ; issue done
    240 	() ; state
    241 	((spr INT -1)) ; inputs
    242 	((GRj INT -1)) ; outputs
    243 	() ; profile action (default)
    244 	)
    245   ; GR Move to SPR unit
    246   (unit u-gr2spr "GR Move to SPR Unit" ()
    247 	1 1 ; issue done
    248 	() ; state
    249 	((GRj INT -1)) ; inputs
    250 	((spr INT -1)) ; outputs
    251 	() ; profile action (default)
    252 	)
    253   ; GR set half unit
    254   (unit u-set-hilo "GR Set Half" ()
    255 	1 1 ; issue done
    256 	() ; state
    257 	() ; inputs
    258 	((GRkhi INT -1) (GRklo INT -1)) ; outputs
    259 	() ; profile action (default)
    260 	)
    261   ; GR load unit
    262   (unit u-gr-load "GR Load Unit" ()
    263 	1 1 ; issue done
    264 	() ; state
    265 	((GRi INT -1) (GRj INT -1)) ; inputs
    266 	((GRk INT -1) (GRdoublek INT -1)) ; outputs
    267 	() ; profile action (default)
    268 	)
    269   ; GR store unit
    270   (unit u-gr-store "GR Store Unit" ()
    271 	1 1 ; issue done
    272 	() ; state
    273 	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
    274 	() ; outputs
    275 	() ; profile action (default)
    276 	)
    277   ; FR load unit
    278   (unit u-fr-load "FR Load Unit" ()
    279 	1 1 ; issue done
    280 	() ; state
    281 	((GRi INT -1) (GRj INT -1)) ; inputs
    282 	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
    283 	() ; profile action (default)
    284 	)
    285   ; FR store unit
    286   (unit u-fr-store "FR Store Unit" ()
    287 	1 1 ; issue done
    288 	() ; state
    289 	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
    290 	() ; outputs
    291 	() ; profile action (default)
    292 	)
    293   ; Swap unit
    294   (unit u-swap "Swap Unit" ()
    295 	1 1 ; issue done
    296 	() ; state
    297 	((GRi INT -1) (GRj INT -1)) ; inputs
    298 	((GRk INT -1)) ; outputs
    299 	() ; profile action (default)
    300 	)
    301   ; FR Move to FR unit
    302   (unit u-fr2fr "FR Move to FR Unit" ()
    303 	1 1 ; issue done
    304 	() ; state
    305 	((FRi INT -1)) ; inputs
    306 	((FRk INT -1)) ; outputs
    307 	() ; profile action (default)
    308 	)
    309   ; Clrgr unit
    310   (unit u-clrgr "Clrgr Unit" ()
    311 	1 1 ; issue done
    312 	() ; state
    313 	((GRk INT -1)) ; inputs
    314 	() ; outputs
    315 	() ; profile action (default)
    316 	)
    317   ; Clrfr unit
    318   (unit u-clrfr "Clrfr Unit" ()
    319 	1 1 ; issue done
    320 	() ; state
    321 	((FRk INT -1)) ; inputs
    322 	() ; outputs
    323 	() ; profile action (default)
    324 	)
    325   ; Insn cache invalidate unit
    326   (unit u-ici "Insn cache invalidate unit" ()
    327 	1 1 ; issue done
    328 	() ; state
    329 	((GRi INT -1) (GRj INT -1)) ; inputs
    330 	() ; outputs
    331 	() ; profile action (default)
    332 	)
    333   ; Data cache invalidate unit
    334   (unit u-dci "Data cache invalidate unit" ()
    335 	1 1 ; issue done
    336 	() ; state
    337 	((GRi INT -1) (GRj INT -1)) ; inputs
    338 	() ; outputs
    339 	() ; profile action (default)
    340 	)
    341   ; Data cache flush unit
    342   (unit u-dcf "Data cache flush unit" ()
    343 	1 1 ; issue done
    344 	() ; state
    345 	((GRi INT -1) (GRj INT -1)) ; inputs
    346 	() ; outputs
    347 	() ; profile action (default)
    348 	)
    349   ; Insn cache preload unit
    350   (unit u-icpl "Insn cache preload unit" ()
    351 	1 1 ; issue done
    352 	() ; state
    353 	((GRi INT -1) (GRj INT -1)) ; inputs
    354 	() ; outputs
    355 	() ; profile action (default)
    356 	)
    357   ; Data cache preload unit
    358   (unit u-dcpl "Data cache preload unit" ()
    359 	1 1 ; issue done
    360 	() ; state
    361 	((GRi INT -1) (GRj INT -1)) ; inputs
    362 	() ; outputs
    363 	() ; profile action (default)
    364 	)
    365   ; Insn cache unlock unit
    366   (unit u-icul "Insn cache unlock unit" ()
    367 	1 1 ; issue done
    368 	() ; state
    369 	((GRi INT -1) (GRj INT -1)) ; inputs
    370 	() ; outputs
    371 	() ; profile action (default)
    372 	)
    373   ; Data cache unlock unit
    374   (unit u-dcul "Data cache unlock unit" ()
    375 	1 1 ; issue done
    376 	() ; state
    377 	((GRi INT -1) (GRj INT -1)) ; inputs
    378 	() ; outputs
    379 	() ; profile action (default)
    380 	)
    381   ; commit unit
    382   (unit u-commit "Commit Unit" ()
    383 	1 1 ; issue done
    384 	() ; state
    385 	((GRk INT -1) (FRk INT -1)) ; inputs
    386 	() ; outputs
    387 	() ; profile action (default)
    388 	)
    389   ; Float Conversion unit
    390   (unit u-float-convert "Float Conversion unit" ()
    391 	1 1 ; issue done
    392 	() ; state
    393 	((FRj INT -1) (FRintj INT -1) (FRdoublej INT -1)) ; inputs
    394 	((FRk INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; outputs
    395 	() ; profile action (default)
    396 	)
    397   ; Media units
    398   (unit u-media "Media unit" ()
    399 	1 1 ; issue done
    400 	() ; state
    401 	((FRinti INT -1) (FRintj INT -1)) ; inputs
    402 	((FRintk INT -1)) ; outputs
    403 	() ; profile action (default)
    404 	)
    405   (unit u-media-quad "Media-quad unit" ()
    406 	1 1 ; issue done
    407 	() ; state
    408 	((FRintieven INT -1) (FRintjeven INT -1)) ; inputs
    409 	((FRintkeven INT -1)) ; outputs
    410 	() ; profile action (default)
    411 	)
    412   (unit u-media-dual-expand "Media Dual Expand unit" ()
    413 	1 1 ; issue done
    414 	() ; state
    415 	((FRinti INT -1)) ; inputs
    416 	((FRintkeven INT -1)) ; outputs
    417 	() ; profile action (default)
    418 	)
    419   (unit u-media-3-dual "Media-3-dual unit" ()
    420 	1 1 ; issue done
    421 	() ; state
    422 	((FRinti INT -1)) ; inputs
    423 	((FRintk INT -1)) ; outputs
    424 	() ; profile action (default)
    425 	)
    426   (unit u-media-3-acc "Media unit for M-3 using ACC" ()
    427 	1 1 ; issue done
    428 	() ; state
    429 	((FRintj INT -1) (ACC40Si INT -1)) ; inputs
    430 	((FRintk INT -1)) ; outputs
    431 	() ; profile action (default)
    432 	)
    433   (unit u-media-3-acc-dual "Media-3-acc-dual unit" ()
    434 	1 1 ; issue done
    435 	() ; state
    436 	((ACC40Si INT -1)) ; inputs
    437 	((FRintkeven INT -1)) ; outputs
    438 	() ; profile action (default)
    439 	)
    440   (unit u-media-3-wtacc "Media-3-wtacc unit" ()
    441 	1 1 ; issue done
    442 	() ; state
    443 	((FRinti INT -1) (ACC40Sk INT -1)) ; inputs
    444 	() ; outputs
    445 	() ; profile action (default)
    446 	)
    447   (unit u-media-3-mclracc "Media-3-mclracc unit" ()
    448 	1 1 ; issue done
    449 	() ; state
    450 	() ; inputs
    451 	() ; outputs
    452 	() ; profile action (default)
    453 	)
    454   (unit u-media-set "Media set" ()
    455 	1 1 ; issue done
    456 	() ; state
    457 	() ; inputs
    458 	((FRintk INT -1)) ; outputs
    459 	() ; profile action (default)
    460 	)
    461   (unit u-media-4 "Media-4 unit" ()
    462 	1 1 ; issue done
    463 	() ; state
    464 	((FRinti INT -1) (FRintj INT -1)) ; inputs
    465 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
    466 	() ; profile action (default)
    467 	)
    468   (unit u-media-4-acc "Media-4-acc unit" ()
    469 	1 1 ; issue done
    470 	() ; state
    471 	((ACC40Si INT -1)) ; inputs
    472 	((ACC40Sk INT -1)) ; outputs
    473 	() ; profile action (default)
    474 	)
    475   (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
    476 	1 1 ; issue done
    477 	() ; state
    478 	((ACC40Si INT -1)) ; inputs
    479 	((ACC40Sk INT -1)) ; outputs
    480 	() ; profile action (default)
    481 	)
    482   (unit u-media-4-add-sub "Media-4-add-sub unit" ()
    483 	1 1 ; issue done
    484 	() ; state
    485 	((ACC40Si INT -1)) ; inputs
    486 	((ACC40Sk INT -1)) ; outputs
    487 	() ; profile action (default)
    488 	)
    489   (unit u-media-4-add-sub-dual "Media-4-add-sub-dual unit" ()
    490 	1 1 ; issue done
    491 	() ; state
    492 	((ACC40Si INT -1)) ; inputs
    493 	((ACC40Sk INT -1)) ; outputs
    494 	() ; profile action (default)
    495 	)
    496   (unit u-media-4-quad "Media-4-quad unit" ()
    497 	1 1 ; issue done
    498 	() ; state
    499 	((FRintieven INT -1) (FRintjeven INT -1)) ; inputs
    500 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
    501 	() ; profile action (default)
    502 	)
    503 )
    504 
    505 ; FR500 machine.
    506 (define-mach
    507   (name fr500)
    508   (comment "FR500 cpu")
    509   (cpu frvbf)
    510 )
    511 (define-model
    512   (name fr500) (comment "FR500 model") (attrs)
    513   (mach fr500)
    514 
    515   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
    516 
    517   ; `state' is a list of variables for recording model state
    518   (state
    519    ; State items
    520    ; These are all masks with each bit representing one register.
    521    (prev-fpop       DI) ; Previous use of FR register was floating point insn
    522    (prev-media      DI) ; Previous use of FR register was a media insn
    523    (prev-cc-complex DI) ; Previous use of ICC register was not simple
    524    (cur-fpop        DI) ; Current use of FR register was floating point insn
    525    (cur-media       DI) ; Current use of FR register was a media insn
    526    (cur-cc-complex  DI) ; Current use of ICC register was not simple
    527   )
    528   ; Basic unit for instructions with no latency penalties
    529   (unit u-exec "Execution Unit" ()
    530 	1 1 ; issue done
    531 	() ; state
    532 	() ; inputs
    533 	() ; outputs
    534 	() ; profile action (default)
    535 	)
    536   ; Basic integer insn unit
    537   (unit u-integer "Integer Unit" ()
    538 	1 1 ; issue done
    539 	() ; state
    540 	((GRi INT -1) (GRj INT -1)) ; inputs
    541 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
    542 	() ; profile action (default)
    543 	)
    544   ; Integer multiplication unit
    545   (unit u-imul "Integer Multiplication Unit" ()
    546 	1 1 ; issue done
    547 	() ; state
    548 	((GRi INT -1) (GRj INT -1)) ; inputs
    549 	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
    550 	() ; profile action (default)
    551 	)
    552   ; Integer division unit
    553   (unit u-idiv "Integer Division Unit" ()
    554 	1 1 ; issue done
    555 	() ; state
    556 	((GRi INT -1) (GRj INT -1)) ; inputs
    557 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
    558 	() ; profile action (default)
    559 	)
    560   ; Branch unit
    561   (unit u-branch "Branch Unit" ()
    562 	1 1 ; issue done
    563 	() ; state
    564 	((GRi INT -1) (GRj INT -1)
    565 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
    566 	((pc)) ; outputs
    567 	() ; profile action (default)
    568 	)
    569   ; Trap unit
    570   (unit u-trap "Trap Unit" ()
    571 	1 1 ; issue done
    572 	() ; state
    573 	((GRi INT -1) (GRj INT -1)
    574 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
    575 	() ; outputs
    576 	() ; profile action (default)
    577 	)
    578   ; Condition code check unit
    579   (unit u-check "Check Unit" ()
    580 	1 1 ; issue done
    581 	() ; state
    582 	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
    583 	() ; outputs
    584 	() ; profile action (default)
    585 	)
    586   ; Clrgr unit
    587   (unit u-clrgr "Clrgr Unit" ()
    588 	1 1 ; issue done
    589 	() ; state
    590 	((GRk INT -1)) ; inputs
    591 	() ; outputs
    592 	() ; profile action (default)
    593 	)
    594   ; Clrfr unit
    595   (unit u-clrfr "Clrfr Unit" ()
    596 	1 1 ; issue done
    597 	() ; state
    598 	((FRk INT -1)) ; inputs
    599 	() ; outputs
    600 	() ; profile action (default)
    601 	)
    602   ; GR set half unit
    603   (unit u-set-hilo "GR Set Half" ()
    604 	1 1 ; issue done
    605 	() ; state
    606 	() ; inputs
    607 	((GRkhi INT -1) (GRklo INT -1)) ; outputs
    608 	() ; profile action (default)
    609 	)
    610   ; GR load unit -- TODO doesn't handle quad
    611   (unit u-gr-load "GR Load Unit" ()
    612 	1 1 ; issue done
    613 	() ; state
    614 	((GRi INT -1) (GRj INT -1)) ; inputs
    615 	((GRk INT -1) (GRdoublek INT -1)) ; outputs
    616 	() ; profile action (default)
    617 	)
    618   ; GR store unit -- TODO doesn't handle quad
    619   (unit u-gr-store "GR Store Unit" ()
    620 	1 1 ; issue done
    621 	() ; state
    622 	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
    623 	() ; outputs
    624 	() ; profile action (default)
    625 	)
    626   ; GR recovering store unit -- TODO doesn't handle quad
    627   (unit u-gr-r-store "GR Recovering Store Unit" ()
    628 	1 1 ; issue done
    629 	() ; state
    630 	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
    631 	() ; outputs
    632 	() ; profile action (default)
    633 	)
    634   ; FR load unit -- TODO doesn't handle quad
    635   (unit u-fr-load "FR Load Unit" ()
    636 	1 1 ; issue done
    637 	() ; state
    638 	((GRi INT -1) (GRj INT -1)) ; inputs
    639 	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
    640 	() ; profile action (default)
    641 	)
    642   ; FR store unit -- TODO doesn't handle quad
    643   (unit u-fr-store "FR Store Unit" ()
    644 	1 1 ; issue done
    645 	() ; state
    646 	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
    647 	() ; outputs
    648 	() ; profile action (default)
    649 	)
    650   ; FR recovering store unit -- TODO doesn't handle quad
    651   (unit u-fr-r-store "FR Recovering Store Unit" ()
    652 	1 1 ; issue done
    653 	() ; state
    654 	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
    655 	() ; outputs
    656 	() ; profile action (default)
    657 	)
    658   ; Swap unit
    659   (unit u-swap "Swap Unit" ()
    660 	1 1 ; issue done
    661 	() ; state
    662 	((GRi INT -1) (GRj INT -1)) ; inputs
    663 	((GRk INT -1)) ; outputs
    664 	() ; profile action (default)
    665 	)
    666   ; FR Move to FR unit
    667   (unit u-fr2fr "FR Move to FR Unit" ()
    668 	1 1 ; issue done
    669 	() ; state
    670 	((FRi INT -1)) ; inputs
    671 	((FRk INT -1)) ; outputs
    672 	() ; profile action (default)
    673 	)
    674   ; FR Move to GR unit
    675   (unit u-fr2gr "FR Move to GR Unit" ()
    676 	1 1 ; issue done
    677 	() ; state
    678 	((FRintk INT -1)) ; inputs
    679 	((GRj INT -1)) ; outputs
    680 	() ; profile action (default)
    681 	)
    682   ; SPR Move to GR unit
    683   (unit u-spr2gr "SPR Move to GR Unit" ()
    684 	1 1 ; issue done
    685 	() ; state
    686 	((spr INT -1)) ; inputs
    687 	((GRj INT -1)) ; outputs
    688 	() ; profile action (default)
    689 	)
    690   ; GR Move to FR unit
    691   (unit u-gr2fr "GR Move to FR Unit" ()
    692 	1 1 ; issue done
    693 	() ; state
    694 	((GRj INT -1)) ; inputs
    695 	((FRintk INT -1)) ; outputs
    696 	() ; profile action (default)
    697 	)
    698   ; GR Move to SPR unit
    699   (unit u-gr2spr "GR Move to SPR Unit" ()
    700 	1 1 ; issue done
    701 	() ; state
    702 	((GRj INT -1)) ; inputs
    703 	((spr INT -1)) ; outputs
    704 	() ; profile action (default)
    705 	)
    706   ; Float Arithmetic unit
    707   (unit u-float-arith "Float Arithmetic unit" ()
    708 	1 1 ; issue done
    709 	() ; state
    710 	((FRi INT -1) (FRj INT -1) ; inputs
    711 	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
    712 	((FRk INT -1) (FRdoublek INT -1)) ; outputs
    713 	() ; profile action (default)
    714 	)
    715   ; Float Dual Arithmetic unit
    716   (unit u-float-dual-arith "Float Arithmetic unit" ()
    717 	1 1 ; issue done
    718 	() ; state
    719 	((FRi INT -1) (FRj INT -1) ; inputs
    720 	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
    721 	((FRk INT -1) (FRdoublek INT -1)) ; outputs
    722 	() ; profile action (default)
    723 	)
    724   ; Float Div unit
    725   (unit u-float-div "Float Div unit" ()
    726 	1 1 ; issue done
    727 	() ; state
    728 	((FRi INT -1) (FRj INT -1)) ; inputs
    729 	((FRk INT -1)) ; outputs
    730 	() ; profile action (default)
    731 	)
    732   ; Float Square Root unit
    733   (unit u-float-sqrt "Float Square Root unit" ()
    734 	1 1 ; issue done
    735 	() ; state
    736 	((FRj INT -1) (FRdoublej INT -1)) ; inputs
    737 	((FRk INT -1) (FRdoublek INT -1)) ; outputs
    738 	() ; profile action (default)
    739 	)
    740   ; Float Dual Square Root unit
    741   (unit u-float-dual-sqrt "Float Dual Square Root unit" ()
    742 	1 1 ; issue done
    743 	() ; state
    744 	((FRj INT -1)) ; inputs
    745 	((FRk INT -1)) ; outputs
    746 	() ; profile action (default)
    747 	)
    748   ; Float Compare unit
    749   (unit u-float-compare "Float Compare unit" ()
    750 	1 1 ; issue done
    751 	() ; state
    752 	((FRi INT -1) (FRj INT -1)
    753 	 (FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
    754 	((FCCi_2 INT -1)) ; outputs
    755 	() ; profile action (default)
    756 	)
    757   ; Dual Float Compare unit
    758   (unit u-float-dual-compare "Float Dual Compare unit" ()
    759 	1 1 ; issue done
    760 	() ; state
    761 	((FRi INT -1) (FRj INT -1)) ; inputs
    762 	((FCCi_2 INT -1)) ; outputs
    763 	() ; profile action (default)
    764 	)
    765   ; Float Conversion unit
    766   (unit u-float-convert "Float Conversion unit" ()
    767 	1 1 ; issue done
    768 	() ; state
    769 	((FRj INT -1) (FRintj INT -1) (FRdoublej INT -1)) ; inputs
    770 	((FRk INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; outputs
    771 	() ; profile action (default)
    772 	)
    773   ; Dual Float Conversion unit
    774   (unit u-float-dual-convert "Float Dual Conversion unit" ()
    775 	1 1 ; issue done
    776 	() ; state
    777 	((FRj INT -1) (FRintj INT -1)) ; inputs
    778 	((FRk INT -1) (FRintk INT -1)) ; outputs
    779 	() ; profile action (default)
    780 	)
    781   ; Media unit
    782   (unit u-media "Media unit" ()
    783 	1 1 ; issue done
    784 	() ; state
    785 	((FRinti INT -1) (FRintj INT -1) (ACC40Si INT -1) (ACCGi INT -1)) ; inputs
    786 	((FRintk INT -1) (ACC40Sk INT -1) (ACC40Uk INT -1) (ACCGk INT -1)) ; outputs
    787 	() ; profile action (default)
    788 	)
    789   ; Media Quad Arithmetic unit
    790   (unit u-media-quad-arith "Media Quad Arithmetic unit" ()
    791 	1 1 ; issue done
    792 	() ; state
    793 	((FRinti INT -1) (FRintj INT -1)) ; inputs
    794 	((FRintk INT -1)) ; outputs
    795 	() ; profile action (default)
    796 	)
    797   ; Media Dual Multiplication unit
    798   (unit u-media-dual-mul "Media Dual Multiplication unit" ()
    799 	1 1 ; issue done
    800 	() ; state
    801 	((FRinti INT -1) (FRintj INT -1)) ; inputs
    802 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
    803 	() ; profile action (default)
    804 	)
    805   ; Media Quad Multiplication unit
    806   (unit u-media-quad-mul "Media Quad Multiplication unit" ()
    807 	1 1 ; issue done
    808 	() ; state
    809 	((FRinti INT -1) (FRintj INT -1)) ; inputs
    810 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
    811 	() ; profile action (default)
    812 	)
    813   ; Media Quad Complex unit
    814   (unit u-media-quad-complex "Media Quad Complex unit" ()
    815 	1 1 ; issue done
    816 	() ; state
    817 	((FRinti INT -1) (FRintj INT -1)) ; inputs
    818 	((ACC40Sk INT -1)) ; outputs
    819 	() ; profile action (default)
    820 	)
    821   ; Media Dual Expand unit
    822   (unit u-media-dual-expand "Media Dual Expand unit" ()
    823 	1 1 ; issue done
    824 	() ; state
    825 	((FRinti INT -1)) ; inputs
    826 	((FRintk INT -1)) ; outputs
    827 	() ; profile action (default)
    828 	)
    829   ; Media Dual Unpack unit
    830   (unit u-media-dual-unpack "Media Dual Unpack unit" ()
    831 	1 1 ; issue done
    832 	() ; state
    833 	((FRinti INT -1)) ; inputs
    834 	((FRintk INT -1)) ; outputs
    835 	() ; profile action (default)
    836 	)
    837   ; Media Dual byte to half unit
    838   (unit u-media-dual-btoh "Media Byte to byte" ()
    839 	1 1 ; issue done
    840 	() ; state
    841 	((FRintj INT -1)) ; inputs
    842 	((FRintk INT -1)) ; outputs
    843 	() ; profile action (default)
    844 	)
    845   ; Media Dual half to byte unit
    846   (unit u-media-dual-htob "Media Half to byte" ()
    847 	1 1 ; issue done
    848 	() ; state
    849 	((FRintj INT -1)) ; inputs
    850 	((FRintk INT -1)) ; outputs
    851 	() ; profile action (default)
    852 	)
    853   ; Media Dual byte to half unit extended
    854   (unit u-media-dual-btohe "Media Byte to byte extended" ()
    855 	1 1 ; issue done
    856 	() ; state
    857 	((FRintj INT -1)) ; inputs
    858 	((FRintk INT -1)) ; outputs
    859 	() ; profile action (default)
    860 	)
    861   ; Barrier unit
    862   (unit u-barrier "Barrier unit" ()
    863 	1 1 ; issue done
    864 	() ; state
    865 	() ; inputs
    866 	() ; outputs
    867 	() ; profile action (default)
    868 	)
    869   ; Memory Barrier unit
    870   (unit u-membar "Memory Barrier unit" ()
    871 	1 1 ; issue done
    872 	() ; state
    873 	() ; inputs
    874 	() ; outputs
    875 	() ; profile action (default)
    876 	)
    877   ; Insn cache invalidate unit
    878   (unit u-ici "Insn cache invalidate 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 invalidate unit
    886   (unit u-dci "Data cache invalidate unit" ()
    887 	1 1 ; issue done
    888 	() ; state
    889 	((GRi INT -1) (GRj INT -1)) ; inputs
    890 	() ; outputs
    891 	() ; profile action (default)
    892 	)
    893   ; Data cache flush unit
    894   (unit u-dcf "Data cache flush unit" ()
    895 	1 1 ; issue done
    896 	() ; state
    897 	((GRi INT -1) (GRj INT -1)) ; inputs
    898 	() ; outputs
    899 	() ; profile action (default)
    900 	)
    901   ; Insn cache preload unit
    902   (unit u-icpl "Insn cache preload unit" ()
    903 	1 1 ; issue done
    904 	() ; state
    905 	((GRi INT -1) (GRj INT -1)) ; inputs
    906 	() ; outputs
    907 	() ; profile action (default)
    908 	)
    909   ; Data cache preload unit
    910   (unit u-dcpl "Data cache preload unit" ()
    911 	1 1 ; issue done
    912 	() ; state
    913 	((GRi INT -1) (GRj INT -1)) ; inputs
    914 	() ; outputs
    915 	() ; profile action (default)
    916 	)
    917   ; Insn cache unlock unit
    918   (unit u-icul "Insn cache unlock unit" ()
    919 	1 1 ; issue done
    920 	() ; state
    921 	((GRi INT -1) (GRj INT -1)) ; inputs
    922 	() ; outputs
    923 	() ; profile action (default)
    924 	)
    925   ; Data cache unlock unit
    926   (unit u-dcul "Data cache unlock unit" ()
    927 	1 1 ; issue done
    928 	() ; state
    929 	((GRi INT -1) (GRj INT -1)) ; inputs
    930 	() ; outputs
    931 	() ; profile action (default)
    932 	)
    933   ; commit unit
    934   (unit u-commit "Commit Unit" ()
    935 	1 1 ; issue done
    936 	() ; state
    937 	((GRk INT -1) (FRk INT -1)) ; inputs
    938 	() ; outputs
    939 	() ; profile action (default)
    940 	)
    941 )
    942 
    944 ; Tomcat machine. Early version of fr500 machine
    945 (define-mach
    946   (name tomcat)
    947   (comment "Tomcat -- early version of fr500")
    948   (cpu frvbf)
    949 )
    950 (define-model
    951   (name tomcat) (comment "Tomcat model") (attrs)
    952   (mach tomcat)
    953 
    954   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
    955 
    956   ; `state' is a list of variables for recording model state
    957   ; (state)
    958 
    959   (unit u-exec "Execution Unit" ()
    960 	1 1 ; issue done
    961 	() ; state
    962 	() ; inputs
    963 	() ; outputs
    964 	() ; profile action (default)
    965 	)
    966 )
    967 
    969 ; FR400 machine
    970 (define-mach
    971   (name fr400)
    972   (comment "FR400 cpu")
    973   (cpu frvbf)
    974 )
    975 (define-model
    976   (name fr400) (comment "FR400 model") (attrs)
    977   (mach fr400)
    978   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
    979   ; `state' is a list of variables for recording model state
    980   (state
    981    ; State items
    982    ; These are all masks with each bit representing one register.
    983    (prev-fp-load    DI) ; Previous use of FR  register was floating point load
    984    (prev-fr-p4      DI) ; Previous use of FR  register was media unit 4
    985    (prev-fr-p6      DI) ; Previous use of FR  register was media unit 6
    986    (prev-acc-p2     DI) ; Previous use of ACC register was media unit 2
    987    (prev-acc-p4     DI) ; Previous use of ACC register was media unit 4
    988    (cur-fp-load     DI) ; Current  use of FR  register is  floating point load
    989    (cur-fr-p4       DI) ; Current  use of FR  register is  media unit 4
    990    (cur-fr-p6       DI) ; Current  use of FR  register is  media unit 6
    991    (cur-acc-p2      DI) ; Current  use of ACC register is  media unit 2
    992    (cur-acc-p4      DI) ; Current  use of ACC register is  media unit 4
    993   )
    994   (unit u-exec "Execution Unit" ()
    995 	1 1 ; issue done
    996 	() ; state
    997 	() ; inputs
    998 	() ; outputs
    999 	() ; profile action (default)
   1000 	)
   1001   ; Basic integer insn unit
   1002   (unit u-integer "Integer Unit" ()
   1003 	1 1 ; issue done
   1004 	() ; state
   1005 	((GRi INT -1) (GRj INT -1)) ; inputs
   1006 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
   1007 	() ; profile action (default)
   1008 	)
   1009   ; Integer multiplication unit
   1010   (unit u-imul "Integer Multiplication Unit" ()
   1011 	1 1 ; issue done
   1012 	() ; state
   1013 	((GRi INT -1) (GRj INT -1)) ; inputs
   1014 	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
   1015 	() ; profile action (default)
   1016 	)
   1017   ; Integer division unit
   1018   (unit u-idiv "Integer Division Unit" ()
   1019 	1 1 ; issue done
   1020 	() ; state
   1021 	((GRi INT -1) (GRj INT -1)) ; inputs
   1022 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
   1023 	() ; profile action (default)
   1024 	)
   1025   ; Branch unit
   1026   (unit u-branch "Branch Unit" ()
   1027 	1 1 ; issue done
   1028 	() ; state
   1029 	((GRi INT -1) (GRj INT -1)
   1030 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
   1031 	((pc)) ; outputs
   1032 	() ; profile action (default)
   1033 	)
   1034   ; Trap unit
   1035   (unit u-trap "Trap Unit" ()
   1036 	1 1 ; issue done
   1037 	() ; state
   1038 	((GRi INT -1) (GRj INT -1)
   1039 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
   1040 	() ; outputs
   1041 	() ; profile action (default)
   1042 	)
   1043   ; Condition code check unit
   1044   (unit u-check "Check Unit" ()
   1045 	1 1 ; issue done
   1046 	() ; state
   1047 	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
   1048 	() ; outputs
   1049 	() ; profile action (default)
   1050 	)
   1051   ; GR set half unit
   1052   (unit u-set-hilo "GR Set Half" ()
   1053 	1 1 ; issue done
   1054 	() ; state
   1055 	() ; inputs
   1056 	((GRkhi INT -1) (GRklo INT -1)) ; outputs
   1057 	() ; profile action (default)
   1058 	)
   1059   ; GR load unit -- TODO doesn't handle quad
   1060   (unit u-gr-load "GR Load Unit" ()
   1061 	1 1 ; issue done
   1062 	() ; state
   1063 	((GRi INT -1) (GRj INT -1)) ; inputs
   1064 	((GRk INT -1) (GRdoublek INT -1)) ; outputs
   1065 	() ; profile action (default)
   1066 	)
   1067   ; GR store unit -- TODO doesn't handle quad
   1068   (unit u-gr-store "GR Store Unit" ()
   1069 	1 1 ; issue done
   1070 	() ; state
   1071 	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
   1072 	() ; outputs
   1073 	() ; profile action (default)
   1074 	)
   1075   ; FR load unit -- TODO doesn't handle quad
   1076   (unit u-fr-load "FR Load Unit" ()
   1077 	1 1 ; issue done
   1078 	() ; state
   1079 	((GRi INT -1) (GRj INT -1)) ; inputs
   1080 	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
   1081 	() ; profile action (default)
   1082 	)
   1083   ; FR store unit -- TODO doesn't handle quad
   1084   (unit u-fr-store "FR Store Unit" ()
   1085 	1 1 ; issue done
   1086 	() ; state
   1087 	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
   1088 	() ; outputs
   1089 	() ; profile action (default)
   1090 	)
   1091   ; Swap unit
   1092   (unit u-swap "Swap Unit" ()
   1093 	1 1 ; issue done
   1094 	() ; state
   1095 	((GRi INT -1) (GRj INT -1)) ; inputs
   1096 	((GRk INT -1)) ; outputs
   1097 	() ; profile action (default)
   1098 	)
   1099   ; FR Move to GR unit
   1100   (unit u-fr2gr "FR Move to GR Unit" ()
   1101 	1 1 ; issue done
   1102 	() ; state
   1103 	((FRintk INT -1)) ; inputs
   1104 	((GRj INT -1)) ; outputs
   1105 	() ; profile action (default)
   1106 	)
   1107   ; SPR Move to GR unit
   1108   (unit u-spr2gr "SPR Move to GR Unit" ()
   1109 	1 1 ; issue done
   1110 	() ; state
   1111 	((spr INT -1)) ; inputs
   1112 	((GRj INT -1)) ; outputs
   1113 	() ; profile action (default)
   1114 	)
   1115   ; GR Move to FR unit
   1116   (unit u-gr2fr "GR Move to FR Unit" ()
   1117 	1 1 ; issue done
   1118 	() ; state
   1119 	((GRj INT -1)) ; inputs
   1120 	((FRintk INT -1)) ; outputs
   1121 	() ; profile action (default)
   1122 	)
   1123   ; GR Move to SPR unit
   1124   (unit u-gr2spr "GR Move to SPR Unit" ()
   1125 	1 1 ; issue done
   1126 	() ; state
   1127 	((GRj INT -1)) ; inputs
   1128 	((spr INT -1)) ; outputs
   1129 	() ; profile action (default)
   1130 	)
   1131   ; Media unit M1 -- see table 13-8 in the fr400 LSI
   1132   (unit u-media-1 "Media-1 unit" ()
   1133 	1 1 ; issue done
   1134 	() ; state
   1135 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1136 	((FRintk INT -1)) ; outputs
   1137 	() ; profile action (default)
   1138 	)
   1139   (unit u-media-1-quad "Media-1-quad unit" ()
   1140 	1 1 ; issue done
   1141 	() ; state
   1142 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1143 	((FRintk INT -1)) ; outputs
   1144 	() ; profile action (default)
   1145 	)
   1146   (unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
   1147 	1 1 ; issue done
   1148 	() ; state
   1149 	() ; inputs
   1150 	((FRkhi INT -1) (FRklo INT -1)) ; outputs
   1151 	() ; profile action (default)
   1152 	)
   1153   ; Media unit M2 -- see table 13-8 in the fr400 LSI
   1154   (unit u-media-2 "Media-2 unit" ()
   1155 	1 1 ; issue done
   1156 	() ; state
   1157 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1158 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
   1159 	() ; profile action (default)
   1160 	)
   1161   (unit u-media-2-quad "Media-2-quad unit" ()
   1162 	1 1 ; issue done
   1163 	() ; state
   1164 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1165 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
   1166 	() ; profile action (default)
   1167 	)
   1168   (unit u-media-2-acc "Media-2-acc unit" ()
   1169 	1 1 ; issue done
   1170 	() ; state
   1171 	((ACC40Si INT -1)) ; inputs
   1172 	((ACC40Sk INT -1)) ; outputs
   1173 	() ; profile action (default)
   1174 	)
   1175   (unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
   1176 	1 1 ; issue done
   1177 	() ; state
   1178 	((ACC40Si INT -1)) ; inputs
   1179 	((ACC40Sk INT -1)) ; outputs
   1180 	() ; profile action (default)
   1181 	)
   1182   (unit u-media-2-add-sub "Media-2-add-sub unit" ()
   1183 	1 1 ; issue done
   1184 	() ; state
   1185 	((ACC40Si INT -1)) ; inputs
   1186 	((ACC40Sk INT -1)) ; outputs
   1187 	() ; profile action (default)
   1188 	)
   1189   (unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
   1190 	1 1 ; issue done
   1191 	() ; state
   1192 	((ACC40Si INT -1)) ; inputs
   1193 	((ACC40Sk INT -1)) ; outputs
   1194 	() ; profile action (default)
   1195 	)
   1196   ; Media unit M3 -- see table 13-8 in the fr400 LSI
   1197   (unit u-media-3 "Media-3 unit" ()
   1198 	1 1 ; issue done
   1199 	() ; state
   1200 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1201 	((FRintk INT -1)) ; outputs
   1202 	() ; profile action (default)
   1203 	)
   1204   (unit u-media-3-dual "Media-3-dual unit" ()
   1205 	1 1 ; issue done
   1206 	() ; state
   1207 	((FRinti INT -1)) ; inputs
   1208 	((FRintk INT -1)) ; outputs
   1209 	() ; profile action (default)
   1210 	)
   1211   (unit u-media-3-quad "Media-3-quad unit" ()
   1212 	1 1 ; issue done
   1213 	() ; state
   1214 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1215 	((FRintk INT -1)) ; outputs
   1216 	() ; profile action (default)
   1217 	)
   1218   ; Media unit M4 -- see table 13-8 in the fr400 LSI
   1219   (unit u-media-4 "Media-4 unit" ()
   1220 	1 1 ; issue done
   1221 	() ; state
   1222 	((ACC40Si INT -1) (FRintj INT -1)) ; inputs
   1223 	((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
   1224 	() ; profile action (default)
   1225 	)
   1226   (unit u-media-4-accg "Media-4-accg unit" ()
   1227 	1 1 ; issue done
   1228 	() ; state
   1229 	((ACCGi INT -1) (FRinti INT -1)) ; inputs
   1230 	((ACCGk INT -1) (FRintk INT -1)) ; outputs
   1231 	() ; profile action (default)
   1232 	)
   1233   (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
   1234 	1 1 ; issue done
   1235 	() ; state
   1236 	((ACC40Si INT -1)) ; inputs
   1237 	((FRintk INT -1)) ; outputs
   1238 	() ; profile action (default)
   1239 	)
   1240   ; Media unit M6 -- see table 13-8 in the fr400 LSI
   1241   (unit u-media-6 "Media-6 unit" ()
   1242 	1 1 ; issue done
   1243 	() ; state
   1244 	((FRinti INT -1)) ; inputs
   1245 	((FRintk INT -1)) ; outputs
   1246 	() ; profile action (default)
   1247 	)
   1248   ; Media unit M7 -- see table 13-8 in the fr400 LSI
   1249   (unit u-media-7 "Media-1 unit" ()
   1250 	1 1 ; issue done
   1251 	() ; state
   1252 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1253 	((FCCk INT -1)) ; outputs
   1254 	() ; profile action (default)
   1255 	)
   1256   ; Media Dual Expand unit
   1257   (unit u-media-dual-expand "Media Dual Expand unit" ()
   1258 	1 1 ; issue done
   1259 	() ; state
   1260 	((FRinti INT -1)) ; inputs
   1261 	((FRintk INT -1)) ; outputs
   1262 	() ; profile action (default)
   1263 	)
   1264   ; Media Dual half to byte unit
   1265   (unit u-media-dual-htob "Media Half to byte" ()
   1266 	1 1 ; issue done
   1267 	() ; state
   1268 	((FRintj INT -1)) ; inputs
   1269 	((FRintk INT -1)) ; outputs
   1270 	() ; profile action (default)
   1271 	)
   1272   ; Barrier unit
   1273   (unit u-barrier "Barrier unit" ()
   1274 	1 1 ; issue done
   1275 	() ; state
   1276 	() ; inputs
   1277 	() ; outputs
   1278 	() ; profile action (default)
   1279 	)
   1280   ; Memory Barrier unit
   1281   (unit u-membar "Memory Barrier unit" ()
   1282 	1 1 ; issue done
   1283 	() ; state
   1284 	() ; inputs
   1285 	() ; outputs
   1286 	() ; profile action (default)
   1287 	)
   1288   ; Insn cache invalidate unit
   1289   (unit u-ici "Insn cache invalidate unit" ()
   1290 	1 1 ; issue done
   1291 	() ; state
   1292 	((GRi INT -1) (GRj INT -1)) ; inputs
   1293 	() ; outputs
   1294 	() ; profile action (default)
   1295 	)
   1296   ; Data cache invalidate unit
   1297   (unit u-dci "Data cache invalidate unit" ()
   1298 	1 1 ; issue done
   1299 	() ; state
   1300 	((GRi INT -1) (GRj INT -1)) ; inputs
   1301 	() ; outputs
   1302 	() ; profile action (default)
   1303 	)
   1304   ; Data cache flush unit
   1305   (unit u-dcf "Data cache flush unit" ()
   1306 	1 1 ; issue done
   1307 	() ; state
   1308 	((GRi INT -1) (GRj INT -1)) ; inputs
   1309 	() ; outputs
   1310 	() ; profile action (default)
   1311 	)
   1312   ; Insn cache preload unit
   1313   (unit u-icpl "Insn cache preload unit" ()
   1314 	1 1 ; issue done
   1315 	() ; state
   1316 	((GRi INT -1) (GRj INT -1)) ; inputs
   1317 	() ; outputs
   1318 	() ; profile action (default)
   1319 	)
   1320   ; Data cache preload unit
   1321   (unit u-dcpl "Data cache preload unit" ()
   1322 	1 1 ; issue done
   1323 	() ; state
   1324 	((GRi INT -1) (GRj INT -1)) ; inputs
   1325 	() ; outputs
   1326 	() ; profile action (default)
   1327 	)
   1328   ; Insn cache unlock unit
   1329   (unit u-icul "Insn cache unlock unit" ()
   1330 	1 1 ; issue done
   1331 	() ; state
   1332 	((GRi INT -1) (GRj INT -1)) ; inputs
   1333 	() ; outputs
   1334 	() ; profile action (default)
   1335 	)
   1336   ; Data cache unlock unit
   1337   (unit u-dcul "Data cache unlock unit" ()
   1338 	1 1 ; issue done
   1339 	() ; state
   1340 	((GRi INT -1) (GRj INT -1)) ; inputs
   1341 	() ; outputs
   1342 	() ; profile action (default)
   1343 	)
   1344 )
   1345 
   1347 ; FR450 machine
   1348 (define-mach
   1349   (name fr450)
   1350   (comment "FR450 cpu")
   1351   (cpu frvbf)
   1352 )
   1353 (define-model
   1354   (name fr450) (comment "FR450 model") (attrs)
   1355   (mach fr450)
   1356   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
   1357   ; `state' is a list of variables for recording model state
   1358   (state
   1359    ; State items
   1360    ; These are all masks with each bit representing one register.
   1361    (prev-fp-load    DI) ; Previous use of FR  register was floating point load
   1362    (prev-fr-p4      DI) ; Previous use of FR  register was media unit 4
   1363    (prev-fr-p6      DI) ; Previous use of FR  register was media unit 6
   1364    (prev-acc-p2     DI) ; Previous use of ACC register was media unit 2
   1365    (prev-acc-p4     DI) ; Previous use of ACC register was media unit 4
   1366    (cur-fp-load     DI) ; Current  use of FR  register is  floating point load
   1367    (cur-fr-p4       DI) ; Current  use of FR  register is  media unit 4
   1368    (cur-fr-p6       DI) ; Current  use of FR  register is  media unit 6
   1369    (cur-acc-p2      DI) ; Current  use of ACC register is  media unit 2
   1370    (cur-acc-p4      DI) ; Current  use of ACC register is  media unit 4
   1371   )
   1372   (unit u-exec "Execution Unit" ()
   1373 	1 1 ; issue done
   1374 	() ; state
   1375 	() ; inputs
   1376 	() ; outputs
   1377 	() ; profile action (default)
   1378 	)
   1379   ; Basic integer insn unit
   1380   (unit u-integer "Integer Unit" ()
   1381 	1 1 ; issue done
   1382 	() ; state
   1383 	((GRi INT -1) (GRj INT -1)) ; inputs
   1384 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
   1385 	() ; profile action (default)
   1386 	)
   1387   ; Integer multiplication unit
   1388   (unit u-imul "Integer Multiplication Unit" ()
   1389 	1 1 ; issue done
   1390 	() ; state
   1391 	((GRi INT -1) (GRj INT -1)) ; inputs
   1392 	((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
   1393 	() ; profile action (default)
   1394 	)
   1395   ; Integer division unit
   1396   (unit u-idiv "Integer Division Unit" ()
   1397 	1 1 ; issue done
   1398 	() ; state
   1399 	((GRi INT -1) (GRj INT -1)) ; inputs
   1400 	((GRk INT -1) (ICCi_1 INT -1)) ; outputs
   1401 	() ; profile action (default)
   1402 	)
   1403   ; Branch unit
   1404   (unit u-branch "Branch Unit" ()
   1405 	1 1 ; issue done
   1406 	() ; state
   1407 	((GRi INT -1) (GRj INT -1)
   1408 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
   1409 	((pc)) ; outputs
   1410 	() ; profile action (default)
   1411 	)
   1412   ; Trap unit
   1413   (unit u-trap "Trap Unit" ()
   1414 	1 1 ; issue done
   1415 	() ; state
   1416 	((GRi INT -1) (GRj INT -1)
   1417 	 (ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
   1418 	() ; outputs
   1419 	() ; profile action (default)
   1420 	)
   1421   ; Condition code check unit
   1422   (unit u-check "Check Unit" ()
   1423 	1 1 ; issue done
   1424 	() ; state
   1425 	((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
   1426 	() ; outputs
   1427 	() ; profile action (default)
   1428 	)
   1429   ; GR set half unit
   1430   (unit u-set-hilo "GR Set Half" ()
   1431 	1 1 ; issue done
   1432 	() ; state
   1433 	() ; inputs
   1434 	((GRkhi INT -1) (GRklo INT -1)) ; outputs
   1435 	() ; profile action (default)
   1436 	)
   1437   ; GR load unit -- TODO doesn't handle quad
   1438   (unit u-gr-load "GR Load Unit" ()
   1439 	1 1 ; issue done
   1440 	() ; state
   1441 	((GRi INT -1) (GRj INT -1)) ; inputs
   1442 	((GRk INT -1) (GRdoublek INT -1)) ; outputs
   1443 	() ; profile action (default)
   1444 	)
   1445   ; GR store unit -- TODO doesn't handle quad
   1446   (unit u-gr-store "GR Store Unit" ()
   1447 	1 1 ; issue done
   1448 	() ; state
   1449 	((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
   1450 	() ; outputs
   1451 	() ; profile action (default)
   1452 	)
   1453   ; FR load unit -- TODO doesn't handle quad
   1454   (unit u-fr-load "FR Load Unit" ()
   1455 	1 1 ; issue done
   1456 	() ; state
   1457 	((GRi INT -1) (GRj INT -1)) ; inputs
   1458 	((FRintk INT -1) (FRdoublek INT -1)) ; outputs
   1459 	() ; profile action (default)
   1460 	)
   1461   ; FR store unit -- TODO doesn't handle quad
   1462   (unit u-fr-store "FR Store Unit" ()
   1463 	1 1 ; issue done
   1464 	() ; state
   1465 	((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
   1466 	() ; outputs
   1467 	() ; profile action (default)
   1468 	)
   1469   ; Swap unit
   1470   (unit u-swap "Swap Unit" ()
   1471 	1 1 ; issue done
   1472 	() ; state
   1473 	((GRi INT -1) (GRj INT -1)) ; inputs
   1474 	((GRk INT -1)) ; outputs
   1475 	() ; profile action (default)
   1476 	)
   1477   ; FR Move to GR unit
   1478   (unit u-fr2gr "FR Move to GR Unit" ()
   1479 	1 1 ; issue done
   1480 	() ; state
   1481 	((FRintk INT -1)) ; inputs
   1482 	((GRj INT -1)) ; outputs
   1483 	() ; profile action (default)
   1484 	)
   1485   ; SPR Move to GR unit
   1486   (unit u-spr2gr "SPR Move to GR Unit" ()
   1487 	1 1 ; issue done
   1488 	() ; state
   1489 	((spr INT -1)) ; inputs
   1490 	((GRj INT -1)) ; outputs
   1491 	() ; profile action (default)
   1492 	)
   1493   ; GR Move to FR unit
   1494   (unit u-gr2fr "GR Move to FR Unit" ()
   1495 	1 1 ; issue done
   1496 	() ; state
   1497 	((GRj INT -1)) ; inputs
   1498 	((FRintk INT -1)) ; outputs
   1499 	() ; profile action (default)
   1500 	)
   1501   ; GR Move to SPR unit
   1502   (unit u-gr2spr "GR Move to SPR Unit" ()
   1503 	1 1 ; issue done
   1504 	() ; state
   1505 	((GRj INT -1)) ; inputs
   1506 	((spr INT -1)) ; outputs
   1507 	() ; profile action (default)
   1508 	)
   1509   ; Media unit M1 -- see table 14-8 in the fr450 LSI
   1510   (unit u-media-1 "Media-1 unit" ()
   1511 	1 1 ; issue done
   1512 	() ; state
   1513 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1514 	((FRintk INT -1)) ; outputs
   1515 	() ; profile action (default)
   1516 	)
   1517   (unit u-media-1-quad "Media-1-quad unit" ()
   1518 	1 1 ; issue done
   1519 	() ; state
   1520 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1521 	((FRintk INT -1)) ; outputs
   1522 	() ; profile action (default)
   1523 	)
   1524   (unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
   1525 	1 1 ; issue done
   1526 	() ; state
   1527 	() ; inputs
   1528 	((FRkhi INT -1) (FRklo INT -1)) ; outputs
   1529 	() ; profile action (default)
   1530 	)
   1531   ; Media unit M2 -- see table 14-8 in the fr450 LSI
   1532   (unit u-media-2 "Media-2 unit" ()
   1533 	1 1 ; issue done
   1534 	() ; state
   1535 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1536 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
   1537 	() ; profile action (default)
   1538 	)
   1539   (unit u-media-2-quad "Media-2-quad unit" ()
   1540 	1 1 ; issue done
   1541 	() ; state
   1542 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1543 	((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
   1544 	() ; profile action (default)
   1545 	)
   1546   (unit u-media-2-acc "Media-2-acc unit" ()
   1547 	1 1 ; issue done
   1548 	() ; state
   1549 	((ACC40Si INT -1)) ; inputs
   1550 	((ACC40Sk INT -1)) ; outputs
   1551 	() ; profile action (default)
   1552 	)
   1553   (unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
   1554 	1 1 ; issue done
   1555 	() ; state
   1556 	((ACC40Si INT -1)) ; inputs
   1557 	((ACC40Sk INT -1)) ; outputs
   1558 	() ; profile action (default)
   1559 	)
   1560   (unit u-media-2-add-sub "Media-2-add-sub unit" ()
   1561 	1 1 ; issue done
   1562 	() ; state
   1563 	((ACC40Si INT -1)) ; inputs
   1564 	((ACC40Sk INT -1)) ; outputs
   1565 	() ; profile action (default)
   1566 	)
   1567   (unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
   1568 	1 1 ; issue done
   1569 	() ; state
   1570 	((ACC40Si INT -1)) ; inputs
   1571 	((ACC40Sk INT -1)) ; outputs
   1572 	() ; profile action (default)
   1573 	)
   1574   ; Media unit M3 -- see table 14-8 in the fr450 LSI
   1575   (unit u-media-3 "Media-3 unit" ()
   1576 	1 1 ; issue done
   1577 	() ; state
   1578 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1579 	((FRintk INT -1)) ; outputs
   1580 	() ; profile action (default)
   1581 	)
   1582   (unit u-media-3-dual "Media-3-dual unit" ()
   1583 	1 1 ; issue done
   1584 	() ; state
   1585 	((FRinti INT -1)) ; inputs
   1586 	((FRintk INT -1)) ; outputs
   1587 	() ; profile action (default)
   1588 	)
   1589   (unit u-media-3-quad "Media-3-quad unit" ()
   1590 	1 1 ; issue done
   1591 	() ; state
   1592 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1593 	((FRintk INT -1)) ; outputs
   1594 	() ; profile action (default)
   1595 	)
   1596   ; Media unit M4 -- see table 14-8 in the fr450 LSI
   1597   (unit u-media-4 "Media-4 unit" ()
   1598 	1 1 ; issue done
   1599 	() ; state
   1600 	((ACC40Si INT -1) (FRintj INT -1)) ; inputs
   1601 	((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
   1602 	() ; profile action (default)
   1603 	)
   1604   (unit u-media-4-accg "Media-4-accg unit" ()
   1605 	1 1 ; issue done
   1606 	() ; state
   1607 	((ACCGi INT -1) (FRinti INT -1)) ; inputs
   1608 	((ACCGk INT -1) (FRintk INT -1)) ; outputs
   1609 	() ; profile action (default)
   1610 	)
   1611   (unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
   1612 	1 1 ; issue done
   1613 	() ; state
   1614 	((ACC40Si INT -1)) ; inputs
   1615 	((FRintk INT -1)) ; outputs
   1616 	() ; profile action (default)
   1617 	)
   1618   (unit u-media-4-mclracca "Media-4 unit for MCLRACC with #A=1" ()
   1619 	1 1 ; issue done
   1620 	() ; state
   1621 	() ; inputs
   1622 	() ; outputs
   1623 	() ; profile action (default)
   1624 	)
   1625   ; Media unit M6 -- see table 14-8 in the fr450 LSI
   1626   (unit u-media-6 "Media-6 unit" ()
   1627 	1 1 ; issue done
   1628 	() ; state
   1629 	((FRinti INT -1)) ; inputs
   1630 	((FRintk INT -1)) ; outputs
   1631 	() ; profile action (default)
   1632 	)
   1633   ; Media unit M7 -- see table 14-8 in the fr450 LSI
   1634   (unit u-media-7 "Media-1 unit" ()
   1635 	1 1 ; issue done
   1636 	() ; state
   1637 	((FRinti INT -1) (FRintj INT -1)) ; inputs
   1638 	((FCCk INT -1)) ; outputs
   1639 	() ; profile action (default)
   1640 	)
   1641   ; Media Dual Expand unit
   1642   (unit u-media-dual-expand "Media Dual Expand unit" ()
   1643 	1 1 ; issue done
   1644 	() ; state
   1645 	((FRinti INT -1)) ; inputs
   1646 	((FRintk INT -1)) ; outputs
   1647 	() ; profile action (default)
   1648 	)
   1649   ; Media Dual half to byte unit
   1650   (unit u-media-dual-htob "Media Half to byte" ()
   1651 	1 1 ; issue done
   1652 	() ; state
   1653 	((FRintj INT -1)) ; inputs
   1654 	((FRintk INT -1)) ; outputs
   1655 	() ; profile action (default)
   1656 	)
   1657   ; Barrier unit
   1658   (unit u-barrier "Barrier unit" ()
   1659 	1 1 ; issue done
   1660 	() ; state
   1661 	() ; inputs
   1662 	() ; outputs
   1663 	() ; profile action (default)
   1664 	)
   1665   ; Memory Barrier unit
   1666   (unit u-membar "Memory Barrier unit" ()
   1667 	1 1 ; issue done
   1668 	() ; state
   1669 	() ; inputs
   1670 	() ; outputs
   1671 	() ; profile action (default)
   1672 	)
   1673   ; Insn cache invalidate unit
   1674   (unit u-ici "Insn cache invalidate unit" ()
   1675 	1 1 ; issue done
   1676 	() ; state
   1677 	((GRi INT -1) (GRj INT -1)) ; inputs
   1678 	() ; outputs
   1679 	() ; profile action (default)
   1680 	)
   1681   ; Data cache invalidate unit
   1682   (unit u-dci "Data cache invalidate unit" ()
   1683 	1 1 ; issue done
   1684 	() ; state
   1685 	((GRi INT -1) (GRj INT -1)) ; inputs
   1686 	() ; outputs
   1687 	() ; profile action (default)
   1688 	)
   1689   ; Data cache flush unit
   1690   (unit u-dcf "Data cache flush unit" ()
   1691 	1 1 ; issue done
   1692 	() ; state
   1693 	((GRi INT -1) (GRj INT -1)) ; inputs
   1694 	() ; outputs
   1695 	() ; profile action (default)
   1696 	)
   1697   ; Insn cache preload unit
   1698   (unit u-icpl "Insn cache preload unit" ()
   1699 	1 1 ; issue done
   1700 	() ; state
   1701 	((GRi INT -1) (GRj INT -1)) ; inputs
   1702 	() ; outputs
   1703 	() ; profile action (default)
   1704 	)
   1705   ; Data cache preload unit
   1706   (unit u-dcpl "Data cache preload unit" ()
   1707 	1 1 ; issue done
   1708 	() ; state
   1709 	((GRi INT -1) (GRj INT -1)) ; inputs
   1710 	() ; outputs
   1711 	() ; profile action (default)
   1712 	)
   1713   ; Insn cache unlock unit
   1714   (unit u-icul "Insn cache unlock unit" ()
   1715 	1 1 ; issue done
   1716 	() ; state
   1717 	((GRi INT -1) (GRj INT -1)) ; inputs
   1718 	() ; outputs
   1719 	() ; profile action (default)
   1720 	)
   1721   ; Data cache unlock unit
   1722   (unit u-dcul "Data cache unlock unit" ()
   1723 	1 1 ; issue done
   1724 	() ; state
   1725 	((GRi INT -1) (GRj INT -1)) ; inputs
   1726 	() ; outputs
   1727 	() ; profile action (default)
   1728 	)
   1729 )
   1730 
   1732 ; Simple machine - single issue integer machine
   1733 (define-mach
   1734   (name simple)
   1735   (comment "Simple single issue integer cpu")
   1736   (cpu frvbf)
   1737 )
   1738 (define-model
   1739   (name simple) (comment "Simple model") (attrs)
   1740   (mach simple)
   1741   (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
   1742   ; `state' is a list of variables for recording model state
   1743   (state)
   1744   (unit u-exec "Execution Unit" ()
   1745 	1 1 ; issue done
   1746 	() ; state
   1747 	() ; inputs
   1748 	() ; outputs
   1749 	() ; profile action (default)
   1750 	)
   1751 )
   1752 
   1754 ; The instruction fetch/execute cycle.
   1755 ;
   1756 ; This is how to fetch and decode an instruction.
   1757 ; Leave it out for now
   1758 
   1759 ; (define-extract (const SI 0))
   1760 
   1761 ; This is how to execute a decoded instruction.
   1762 ; Leave it out for now
   1763 
   1764 ; (define-execute (const SI 0))
   1765 
   1767 ; An attribute to describe which unit an insn runs in.
   1768 (define-attr
   1769   (for insn)
   1770   (type enum)
   1771   (name UNIT)
   1772   (comment "parallel execution pipeline selection")
   1773   ; The order of declaration is significant. 
   1774   ; See the *_unit_mapping tables in frv.opc
   1775   ; Keep variations on the same unit together.
   1776   ; Keep the '01' variant immediately after the '1' variant in each unit.
   1777   ; Keep the 'ALL' variations immediately after the last numbered variant in each unit.
   1778   (values NIL
   1779 	  I0 I1 I01 I2 I3 IALL
   1780 	  FM0 FM1 FM01 FM2 FM3 FMALL FMLOW
   1781 	  B0 B1 B01
   1782 	  C
   1783 	  MULT-DIV ; multiply/division slotted differently on different machines
   1784 	  IACC     ; iacc multiply     slotted differently on different machines
   1785 	  LOAD     ; loads             slotted differently on different machines
   1786 	  STORE    ; store             slotted differently on different machines
   1787 	  SCAN     ; scan, scani       slotted differently on different machines
   1788 	  DCPL     ; dcpl              slotted differently on different machines
   1789 	  MDUALACC ; media dual acc    slotted differently on different machines
   1790 	  MDCUTSSI ; mdcutssi insn     slotted differently on different machines
   1791 	  MCLRACC-1; mclracc A==1      slotted differently on different machines
   1792 	  NUM_UNITS
   1793   )
   1794 )
   1795 ; Attributes to describe major categories of insns
   1796 (define-attr
   1797   (for insn)
   1798   (type enum)
   1799   (name FR400-MAJOR)
   1800   (comment "fr400 major insn categories")
   1801   ; The order of declaration is significant. Keep variations on the same major
   1802   ; together.
   1803   (values NONE
   1804 	  I-1 I-2 I-3 I-4 I-5
   1805 	  B-1 B-2 B-3 B-4 B-5 B-6
   1806 	  C-1 C-2
   1807 	  M-1 M-2
   1808   )
   1809 )
   1810 (define-attr
   1811   (for insn)
   1812   (type enum)
   1813   (name FR450-MAJOR)
   1814   (comment "fr450 major insn categories")
   1815   ; The order of declaration is significant. Keep variations on the same major
   1816   ; together.
   1817   (values NONE
   1818 	  I-1 I-2 I-3 I-4 I-5
   1819 	  B-1 B-2 B-3 B-4 B-5 B-6
   1820 	  C-1 C-2
   1821 	  M-1 M-2 M-3 M-4 M-5 M-6
   1822   )
   1823 )
   1824 (define-attr
   1825   (for insn)
   1826   (type enum)
   1827   (name FR500-MAJOR)
   1828   (comment "fr500 major insn categories")
   1829   ; The order of declaration is significant. Keep variations on the same major
   1830   ; together.
   1831   (values NONE
   1832 	  I-1 I-2 I-3 I-4 I-5 I-6
   1833 	  B-1 B-2 B-3 B-4 B-5 B-6
   1834 	  C-1 C-2
   1835 	  F-1 F-2 F-3 F-4 F-5 F-6 F-7 F-8
   1836 	  M-1 M-2 M-3 M-4 M-5 M-6 M-7 M-8
   1837   )
   1838 )
   1839 (define-attr
   1840   (for insn)
   1841   (type enum)
   1842   (name FR550-MAJOR)
   1843   (comment "fr550 major insn categories")
   1844   ; The order of declaration is significant. Keep variations on the same major
   1845   ; together.
   1846   (values NONE
   1847 	  I-1 I-2 I-3 I-4 I-5 I-6 I-7 I-8
   1848 	  B-1 B-2 B-3 B-4 B-5 B-6
   1849 	  C-1 C-2
   1850 	  F-1 F-2 F-3 F-4
   1851 	  M-1 M-2 M-3 M-4 M-5
   1852   )
   1853 )
   1854 ; Privileged insn
   1855 (define-attr
   1856   (for insn)
   1857   (type boolean)
   1858   (name PRIVILEGED)
   1859   (comment "insn only allowed in supervisor mode")
   1860 )
   1861 ; Non-Excepting insn
   1862 (define-attr
   1863   (for insn)
   1864   (type boolean)
   1865   (name NON-EXCEPTING)
   1866   (comment "non-excepting insn")
   1867 )
   1868 ; Conditional insn
   1869 (define-attr
   1870   (for insn)
   1871   (type boolean)
   1872   (name CONDITIONAL)
   1873   (comment "conditional insn")
   1874 )
   1875 ; insn accesses FR registers
   1876 (define-attr
   1877   (for insn)
   1878   (type boolean)
   1879   (name FR-ACCESS)
   1880   (comment "insn accesses FR registers")
   1881 )
   1882 ; insn preserves MSR.OVF
   1883 (define-attr
   1884   (for insn)
   1885   (type boolean)
   1886   (name PRESERVE-OVF)
   1887   (comment "Preserve value of MSR.OVF")
   1888 )
   1889 ; "Audio" instruction provided by the fr405 but not the original fr400 core.
   1890 (define-attr
   1891   (for insn)
   1892   (type boolean)
   1893   (name AUDIO)
   1894   (comment "Audio instruction added with FR405")
   1895 )
   1896 ; null attribute -- used as a place holder for where an attribue is required.
   1897 (define-attr
   1898   (for insn)
   1899   (type boolean)
   1900   (name NA)
   1901   (comment "placeholder attribute")
   1902   (attrs META) ; do not define in any generated file for now
   1903 )
   1904 
   1905 ; IDOC attribute for instruction documentation.
   1906 
   1907 (define-attr
   1908   (for insn)
   1909   (type enum)
   1910   (name IDOC)
   1911   (comment "insn kind for documentation")
   1912   (attrs META)
   1913   (values
   1914    (MEM - () "Memory")
   1915    (ALU - () "ALU")
   1916    (FPU - () "FPU")
   1917    (BR - () "Branch")
   1918    (PRIV - () "Priviledged")
   1919    (MISC - () "Miscellaneous")
   1920   )
   1921 )
   1922 
   1924 ; Instruction fields.
   1925 ;
   1926 ; Attributes:
   1927 ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
   1928 ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
   1929 ; RESERVED: bits are not used to decode insn, must be all 0
   1930 (dnf f-pack      "packing bit"                  () 31  1)
   1931 (dnf f-op        "primary opcode"               () 24  7)
   1932 (dnf f-ope1      "extended opcode"              () 11  6)
   1933 (dnf f-ope2      "extended opcode"              ()  9  4)
   1934 (dnf f-ope3      "extended opcode"              () 15  3)
   1935 (dnf f-ope4      "extended opcode"              ()  7  2)
   1936 
   1937 (dnf f-GRi       "source register 1"            () 17  6)
   1938 (dnf f-GRj       "source register 2"            ()  5  6)
   1939 (dnf f-GRk       "destination register"         () 30  6)
   1940 
   1941 (dnf f-FRi       "source register 1"            () 17  6)
   1942 (dnf f-FRj       "source register 2"            ()  5  6)
   1943 (dnf f-FRk       "destination register"         () 30  6)
   1944 
   1945 (dnf f-CPRi      "source register 1"            () 17  6)
   1946 (dnf f-CPRj      "source register 2"            ()  5  6)
   1947 (dnf f-CPRk      "destination register"         () 30  6)
   1948 
   1949 (dnf f-ACCGi     "source register"              () 17  6)
   1950 (dnf f-ACCGk     "destination register"         () 30  6)
   1951 
   1952 (dnf f-ACC40Si   "40 bit signed accumulator"    () 17  6)
   1953 (dnf f-ACC40Ui   "40 bit unsigned accumulator"  () 17  6)
   1954 (dnf f-ACC40Sk   "40 bit accumulator"           () 30  6)
   1955 (dnf f-ACC40Uk   "40 bit accumulator"           () 30  6)
   1956 
   1957 (dnf f-CRi       "source      register"         () 14  3)
   1958 (dnf f-CRj       "source      register"         ()  2  3)
   1959 (dnf f-CRk       "destination register"         () 27  3)
   1960 (dnf f-CCi       "condition   register"         () 11  3)
   1961 
   1962 (df  f-CRj_int   "target cr for ck insns"       () 26  2 UINT
   1963      ((value pc) (sub WI value 4))
   1964      ((value pc) (add WI value 4))
   1965 )
   1966 (dnf f-CRj_float "target cr for fck insns"      () 26  2)
   1967 
   1968 (dnf f-ICCi_1    "condition register"           () 11  2)
   1969 (dnf f-ICCi_2    "condition register"           () 26  2)
   1970 (dnf f-ICCi_3    "condition register"           ()  1  2)
   1971 (dnf f-FCCi_1    "condition register"           () 11  2)
   1972 (dnf f-FCCi_2    "condition register"           () 26  2)
   1973 (dnf f-FCCi_3    "condition register"           ()  1  2)
   1974 (dnf f-FCCk      "condition register"           () 26  2)
   1975 (dnf f-eir       "exception insn register"      () 17  6)
   1976 
   1977 (df  f-s10       "10 bit sign extended"         ()  9 10  INT #f #f)
   1978 (df  f-s12       "12 bit sign extended"         () 11 12  INT #f #f)
   1979 (df  f-d12       "12 bit sign extended"         () 11 12  INT #f #f)
   1980 (df  f-u16       "16 bit unsigned"              () 15 16 UINT #f #f)
   1981 (df  f-s16       "16 bit sign extended"         () 15 16  INT #f #f)
   1982 (df  f-s6        "6  bit   signed"              ()  5  6  INT #f #f)
   1983 (df  f-s6_1      "6  bit   signed"              () 11  6  INT #f #f)
   1984 (df  f-u6        "6  bit unsigned"              ()  5  6 UINT #f #f)
   1985 (df  f-s5        "5  bit   signed"              ()  4  5  INT #f #f)
   1986 
   1987 (df  f-u12-h "upper 6 bits of u12"  () 17 6  INT #f #f)
   1988 (df  f-u12-l "lower 6 bits of u12"  ()  5 6 UINT #f #f)
   1989 (dnmf f-u12   "12 bit signed immediate" () INT
   1990       (f-u12-h f-u12-l)
   1991       (sequence () ; insert
   1992 		(set (ifield f-u12-h) (sra SI (ifield f-u12) 6))
   1993 		(set (ifield f-u12-l) (and (ifield f-u12) #x3f))
   1994 		)
   1995       (sequence () ; extract
   1996 		(set (ifield f-u12) (or (mul (ifield f-u12-h) 64)
   1997 					(ifield f-u12-l)))
   1998 		)
   1999 )
   2000 
   2001 (dnf f-int-cc    "integer  branch conditions"   () 30  4)
   2002 (dnf f-flt-cc    "floating branch conditions"   () 30  4)
   2003 (df  f-cond      "conditional arithmetic"       ()  8  1 UINT #f #f)
   2004 (df  f-ccond     "lr branch condition"          () 12  1 UINT #f #f)
   2005 (df  f-hint      "2 bit branch prediction hint" () 17  2 UINT #f #f)
   2006 (df  f-LI        "link indicator"               () 25  1 UINT #f #f)
   2007 (df  f-lock      "cache lock indicator"         () 25  1 UINT #f #f)
   2008 (df  f-debug     "debug mode indicator"         () 25  1 UINT #f #f)
   2009 (df  f-A         "all accumulator bit"          () 17  1 UINT #f #f)
   2010 (df  f-ae        "cache all entries indicator"  () 25  1 UINT #f #f)
   2011 
   2012 (dnf  f-spr-h "upper 6 bits of spr"  () 30  6)
   2013 (dnf  f-spr-l "lower 6 bits of spr"  () 17  6)
   2014 (dnmf f-spr   "special purpose register" () UINT
   2015       (f-spr-h f-spr-l)
   2016       (sequence () ; insert
   2017 		(set (ifield f-spr-h) (srl (ifield f-spr) (const 6)))
   2018 		(set (ifield f-spr-l) (and (ifield f-spr) (const #x3f)))
   2019 		)
   2020       (sequence () ; extract
   2021 		(set (ifield f-spr) (or (sll (ifield f-spr-h) (const 6))
   2022 					(ifield f-spr-l)))
   2023 		)
   2024 )
   2025 
   2026 (df  f-label16    "18 bit pc relative signed offset" (PCREL-ADDR) 15 16 INT
   2027      ((value pc) (sra WI (sub WI value pc) (const 2)))
   2028      ((value pc) (add WI (mul WI value (const 4)) pc))
   2029 )
   2030 
   2031 (df   f-labelH6   "upper 6  bits of label24"  () 30  6 INT #f #f)
   2032 (dnf  f-labelL18  "lower 18 bits of label24"  () 17 18)
   2033 (dnmf f-label24   "26 bit signed offset"     (PCREL-ADDR) INT
   2034       (f-labelH6 f-labelL18)
   2035       ; insert
   2036       (sequence ()
   2037 		(set (ifield f-labelH6)
   2038 		     (sra WI (sub (ifield f-label24) pc) (const 20)))
   2039 		(set (ifield f-labelL18)
   2040 		     (and (srl (sub (ifield f-label24) pc) (const 2))
   2041 			  (const #x3ffff)))
   2042 		)
   2043       ; extract
   2044       (sequence ()
   2045 		(set (ifield f-label24)
   2046 		     (add (mul (or (mul (ifield f-labelH6) (sll 1 18))
   2047 				   (ifield f-labelL18))
   2048 			       (const 4))
   2049 			  pc)))
   2050 )
   2051 
   2052 (dnf f-LRAE "Load Real Address E flag" () 5 1)
   2053 (dnf f-LRAD "Load Real Address D flag" () 4 1)
   2054 (dnf f-LRAS "Load Real Address S flag" () 3 1)
   2055 
   2056 (dnf f-TLBPRopx "TLB Probe operation number" () 28 3)
   2057 (dnf f-TLBPRL   "TLB Probe L flag" () 25 1)
   2058 
   2059 (dnf f-ICCi_1-null  "null field" (RESERVED) 11  2)
   2060 (dnf f-ICCi_2-null  "null field" (RESERVED) 26  2)
   2061 (dnf f-ICCi_3-null  "null field" (RESERVED)  1  2)
   2062 (dnf f-FCCi_1-null  "null field" (RESERVED) 11  2)
   2063 (dnf f-FCCi_2-null  "null field" (RESERVED) 26  2)
   2064 (dnf f-FCCi_3-null  "null field" (RESERVED)  1  2)
   2065 (dnf f-rs-null      "null field" (RESERVED) 17  6)
   2066 (dnf f-GRi-null     "null field" (RESERVED) 17  6)
   2067 (dnf f-GRj-null     "null field" (RESERVED)  5  6)
   2068 (dnf f-GRk-null     "null field" (RESERVED) 30  6)
   2069 (dnf f-FRi-null     "null field" (RESERVED) 17  6)
   2070 (dnf f-FRj-null     "null field" (RESERVED)  5  6)
   2071 (dnf f-ACCj-null    "null field" (RESERVED)  5  6)
   2072 (dnf f-rd-null      "null field" (RESERVED) 30  6)
   2073 (dnf f-cond-null    "null field" (RESERVED) 30  4)
   2074 (dnf f-ccond-null   "null field" (RESERVED) 12  1)
   2075 (dnf f-s12-null     "null field" (RESERVED) 11 12)
   2076 (dnf f-label16-null "null field" (RESERVED) 15 16)
   2077 (dnf f-misc-null-1  "null field" (RESERVED) 30  5)
   2078 (dnf f-misc-null-2  "null field" (RESERVED) 11  6)
   2079 (dnf f-misc-null-3  "null field" (RESERVED) 11  4)
   2080 (dnf f-misc-null-4  "null field" (RESERVED) 17  2)
   2081 (dnf f-misc-null-5  "null field" (RESERVED) 17 16)
   2082 (dnf f-misc-null-6  "null field" (RESERVED) 30  3)
   2083 (dnf f-misc-null-7  "null field" (RESERVED) 17  3)
   2084 (dnf f-misc-null-8  "null field" (RESERVED)  5  3)
   2085 (dnf f-misc-null-9  "null field" (RESERVED)  5  4)
   2086 (dnf f-misc-null-10 "null field" (RESERVED) 16  5)
   2087 (dnf f-misc-null-11 "null field" (RESERVED)  5  1)
   2088 
   2089 (dnf f-LRA-null     "null field" (RESERVED)  2  3)
   2090 (dnf f-TLBPR-null   "null field" (RESERVED) 30  2)
   2091 
   2092 (dnf f-LI-off      "null field" (RESERVED) 25  1)
   2093 (dnf f-LI-on       "null field" (RESERVED) 25  1)
   2094 
   2095 ; Relocation annotations.
   2096 (dsh h-reloc-ann   "relocation annotation" () (register BI))
   2097 (dnf f-reloc-ann   "relocation annotation" () 0 0)
   2098 
   2099 (define-pmacro (dann xname xcomment xmode xparse xprint)
   2100   (define-operand
   2101     (name xname)
   2102     (comment xcomment)
   2103     (type h-reloc-ann)
   2104     (index f-reloc-ann)
   2105     (mode xmode)
   2106     (handlers (parse xparse) (print xprint))
   2107     )
   2108   )
   2109 
   2110 
   2112 ; Enums.
   2113 
   2114 ; insn-op:
   2115 ; FIXME: should use die macro or some such
   2116 (define-normal-insn-enum insn-op "insn op enums" () OP_ f-op
   2117  (
   2118  "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
   2119  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F"
   2120  "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F"
   2121  "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F"
   2122  "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "4A" "4B" "4C" "4D" "4E" "4F"
   2123  "50" "51" "52" "53" "54" "55" "56" "57" "58" "59" "5A" "5B" "5C" "5D" "5E" "5F"
   2124  "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "6A" "6B" "6C" "6D" "6E" "6F"
   2125  "70" "71" "72" "73" "74" "75" "76" "77" "78" "79" "7A" "7B" "7C" "7D" "7E" "7F"
   2126  )
   2127 )
   2128 
   2129 (define-normal-insn-enum insn-ope1 "insn ope enums" () OPE1_ f-ope1
   2130  (
   2131  "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
   2132  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "1A" "1B" "1C" "1D" "1E" "1F"
   2133  "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "2A" "2B" "2C" "2D" "2E" "2F"
   2134  "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "3A" "3B" "3C" "3D" "3E" "3F"
   2135  )
   2136 )
   2137 
   2138 (define-normal-insn-enum insn-ope2 "insn ope enums" () OPE2_ f-ope2
   2139  (
   2140  "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F"
   2141  )
   2142 )
   2143 
   2144 (define-normal-insn-enum insn-ope3 "insn ope enums" () OPE3_ f-ope3
   2145  (
   2146  "00" "01" "02" "03" "04" "05" "06" "07"
   2147  )
   2148 )
   2149 
   2150 (define-normal-insn-enum insn-ope4 "insn ope enums" () OPE4_ f-ope4
   2151  (
   2152  "0" "1" "2" "3"
   2153  )
   2154 )
   2155 
   2156 ; int-cc: integer branch conditions
   2157 ; FIXME: should use die macro or some such
   2158 (define-normal-insn-enum int-cc "integer branch cond enums" () ICC_ f-int-cc
   2159   (
   2160    "nev" "c"  "v"  "lt" "eq" "ls" "n" "le"
   2161    "ra"  "nc" "nv" "ge" "ne" "hi" "p" "gt"
   2162   )
   2163 )
   2164 
   2165 ; flt-cc: floating-point/media branch conditions
   2166 ; FIXME: should use die macro or some such
   2167 (define-normal-insn-enum flt-cc "float branch cond enums" () FCC_ f-flt-cc
   2168   ("nev" "u" "gt" "ug" "lt" "ul" "lg" "ne"
   2169    "eq" "ue" "ge" "uge" "le" "ule" "o" "ra")
   2170 )
   2171 
   2173 ; Hardware pieces.
   2174 ; These entries list the elements of the raw hardware.
   2175 ; They're also used to provide tables and other elements of the assembly
   2176 ; language.
   2177 (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
   2178 
   2179 ; The PSR. The individual fields are referenced more than the entire
   2180 ; register, so reference them directly. We can assemble the
   2181 ; entire register contents when necessary.
   2182 ;
   2183 (dsh h-psr_imple "PSR.IMPLE"   () (register UQI))
   2184 (dsh h-psr_ver   "PSR.VER"     () (register UQI))
   2185 (dsh h-psr_ice   "PSR.ICE bit" () (register BI))
   2186 (dsh h-psr_nem   "PSR.NEM bit" () (register BI))
   2187 (dsh h-psr_cm    "PSR.CM  bit" () (register BI))
   2188 (dsh h-psr_be    "PSR.BE  bit" () (register BI))
   2189 (dsh h-psr_esr   "PSR.ESR bit" () (register BI))
   2190 (dsh h-psr_ef    "PSR.EF  bit" () (register BI))
   2191 (dsh h-psr_em    "PSR.EM  bit" () (register BI))
   2192 (dsh h-psr_pil   "PSR.PIL    " () (register UQI))
   2193 (dsh h-psr_ps    "PSR.PS  bit" () (register BI))
   2194 (dsh h-psr_et    "PSR.ET  bit" () (register BI))
   2195 
   2196 ; PSR.S requires special handling because the shadow registers (SR0-SR4) must
   2197 ; be switched with GR4-GR7 when changing from user to supervisor mode or
   2198 ; vice-versa.
   2199 (define-hardware
   2200   (name h-psr_s)
   2201   (comment "PSR.S bit")
   2202   (attrs)
   2203   (type register BI)
   2204   (get)
   2205   (set (newval) (c-call VOID "@cpu@_h_psr_s_set_handler" newval))
   2206 )
   2207 
   2208 ; The TBR. The individual bits are referenced more than the entire
   2209 ; register, so reference them directly. We can assemble the
   2210 ; entire register contents when necessary.
   2211 ;
   2212 (dsh h-tbr_tba "TBR.TBA" () (register UWI))
   2213 (dsh h-tbr_tt  "TBR.TT"  () (register UQI))
   2214 
   2215 ; The BPSR. The individual bits are referenced more than the entire
   2216 ; register, so reference them directly. We can assemble the
   2217 ; entire register contents when necessary.
   2218 ;
   2219 (dsh h-bpsr_bs   "PSR.S   bit" () (register BI))
   2220 (dsh h-bpsr_bet  "PSR.ET  bit" () (register BI))
   2221 
   2222 ; General registers
   2223 ;
   2224 (define-keyword
   2225   (name gr-names)
   2226   (print-name h-gr)
   2227   (prefix "")
   2228   (values
   2229    (sp 1) (fp 2)
   2230    (gr0   0)(gr1   1)(gr2   2)(gr3   3)(gr4   4)(gr5   5)(gr6   6)(gr7   7)
   2231    (gr8   8)(gr9   9)(gr10 10)(gr11 11)(gr12 12)(gr13 13)(gr14 14)(gr15 15)
   2232    (gr16 16)(gr17 17)(gr18 18)(gr19 19)(gr20 20)(gr21 21)(gr22 22)(gr23 23)
   2233    (gr24 24)(gr25 25)(gr26 26)(gr27 27)(gr28 28)(gr29 29)(gr30 30)(gr31 31)
   2234    (gr32 32)(gr33 33)(gr34 34)(gr35 35)(gr36 36)(gr37 37)(gr38 38)(gr39 39)
   2235    (gr40 40)(gr41 41)(gr42 42)(gr43 43)(gr44 44)(gr45 45)(gr46 46)(gr47 47)
   2236    (gr48 48)(gr49 49)(gr50 50)(gr51 51)(gr52 52)(gr53 53)(gr54 54)(gr55 55)
   2237    (gr56 56)(gr57 57)(gr58 58)(gr59 59)(gr60 60)(gr61 61)(gr62 62)(gr63 63)
   2238   )
   2239 )
   2240 
   2241 (define-hardware
   2242   (name h-gr)
   2243   (comment "general registers")
   2244   (attrs PROFILE)
   2245   (type register USI (64))
   2246   (indices extern-keyword gr-names)
   2247   (get (index) (c-call WI "@cpu@_h_gr_get_handler" index))
   2248   (set (index newval) (c-call VOID "@cpu@_h_gr_set_handler" index newval))
   2249 )
   2250 
   2251 ; General Registers as double words
   2252 ; These registers are shadowed onto h-gr
   2253 (define-hardware
   2254   (name h-gr_double)
   2255   (comment "general registers as double words")
   2256   (attrs PROFILE VIRTUAL)
   2257   (type register DI (32))
   2258   ; FIXME: Need constraint to prohibit odd numbers.
   2259   (indices extern-keyword gr-names)
   2260   (get (index)
   2261        (c-call DI "@cpu@_h_gr_double_get_handler" index))
   2262   (set (index newval)
   2263        (c-call VOID "@cpu@_h_gr_double_set_handler" index newval))
   2264 )
   2265 
   2266 ; General Registers as high and low half words
   2267 ; These registers are shadowed onto h-gr
   2268 (define-hardware
   2269   (name h-gr_hi)
   2270   (comment "general registers as high half word")
   2271   (attrs PROFILE VIRTUAL)
   2272   (type register UHI (64))
   2273   (indices extern-keyword gr-names)
   2274   (get (index) (c-call UHI "@cpu@_h_gr_hi_get_handler" index))
   2275   (set (index newval) (c-call VOID "@cpu@_h_gr_hi_set_handler" index newval))
   2276 )
   2277 (define-hardware
   2278   (name h-gr_lo)
   2279   (comment "general registers as low half word")
   2280   (attrs PROFILE VIRTUAL)
   2281   (type register UHI (64))
   2282   (indices extern-keyword gr-names)
   2283   (get (index) (c-call UHI "@cpu@_h_gr_lo_get_handler" index))
   2284   (set (index newval) (c-call VOID "@cpu@_h_gr_lo_set_handler" index newval))
   2285 )
   2286 
   2287 ; Floating Point Registers
   2288 (define-keyword
   2289   (name fr-names)
   2290   (print-name h-fr)
   2291   (prefix "")
   2292   (values
   2293    (fr0   0)(fr1   1)(fr2   2)(fr3   3)(fr4   4)(fr5   5)(fr6   6)(fr7   7)
   2294    (fr8   8)(fr9   9)(fr10 10)(fr11 11)(fr12 12)(fr13 13)(fr14 14)(fr15 15)
   2295    (fr16 16)(fr17 17)(fr18 18)(fr19 19)(fr20 20)(fr21 21)(fr22 22)(fr23 23)
   2296    (fr24 24)(fr25 25)(fr26 26)(fr27 27)(fr28 28)(fr29 29)(fr30 30)(fr31 31)
   2297    (fr32 32)(fr33 33)(fr34 34)(fr35 35)(fr36 36)(fr37 37)(fr38 38)(fr39 39)
   2298    (fr40 40)(fr41 41)(fr42 42)(fr43 43)(fr44 44)(fr45 45)(fr46 46)(fr47 47)
   2299    (fr48 48)(fr49 49)(fr50 50)(fr51 51)(fr52 52)(fr53 53)(fr54 54)(fr55 55)
   2300    (fr56 56)(fr57 57)(fr58 58)(fr59 59)(fr60 60)(fr61 61)(fr62 62)(fr63 63)
   2301   )
   2302 )
   2303 
   2304 (define-hardware
   2305   (name h-fr)
   2306   (comment "floating point registers")
   2307   (attrs PROFILE)
   2308   (type register SF (64))
   2309   (indices extern-keyword fr-names)
   2310   (get (index) (c-call SF "@cpu@_h_fr_get_handler" index))
   2311   (set (index newval) (c-call VOID "@cpu@_h_fr_set_handler" index newval))
   2312 )
   2313 
   2314 ; Floating Point Registers as double precision
   2315 ; These registers are shadowed onto h-fr
   2316 
   2317 (define-hardware
   2318   (name h-fr_double)
   2319   (comment "floating point registers as double precision")
   2320   (attrs PROFILE VIRTUAL)
   2321   (type register DF (32))
   2322   ; FIXME: Need constraint to prohibit odd numbers.
   2323   (indices extern-keyword fr-names)
   2324   (get (index)
   2325        (c-call DF "@cpu@_h_fr_double_get_handler" index))
   2326   (set (index newval)
   2327        (c-call VOID "@cpu@_h_fr_double_set_handler" index newval))
   2328 )
   2329 
   2330 ; Floating Point Registers as integer words.
   2331 ; These registers are shadowed onto h-fr
   2332 
   2333 (define-hardware
   2334   (name h-fr_int)
   2335   (comment "floating point registers as integers")
   2336   (attrs PROFILE VIRTUAL)
   2337   (type register USI (64))
   2338   (indices extern-keyword fr-names)
   2339   (get (index)
   2340        (c-call USI "@cpu@_h_fr_int_get_handler" index))
   2341   (set (index newval)
   2342        (c-call VOID "@cpu@_h_fr_int_set_handler" index newval))
   2343 )
   2344 
   2345 ; Floating Point Registers as high and low half words
   2346 ; These registers are shadowed onto h-fr
   2347 (define-hardware
   2348   (name h-fr_hi)
   2349   (comment "floating point registers as unsigned high half word")
   2350   (attrs PROFILE VIRTUAL)
   2351   (type register UHI (64))
   2352   (indices extern-keyword fr-names)
   2353   (get (regno) (srl (reg h-fr_int regno) 16))
   2354   (set (regno newval) (set (reg h-fr_int regno)
   2355 			   (or (and (reg h-fr_int regno) #xffff)
   2356 			       (sll newval 16))))
   2357 )
   2358 (define-hardware
   2359   (name h-fr_lo)
   2360   (comment "floating point registers as unsigned low half word")
   2361   (attrs PROFILE VIRTUAL)
   2362   (type register UHI (64))
   2363   (indices extern-keyword fr-names)
   2364   (get (regno) (and (reg h-fr_int regno) #xffff))
   2365   (set (regno newval) (set (reg h-fr_int regno)
   2366 			   (or (and (reg h-fr_int regno) #xffff0000)
   2367 			       (and newval #xffff))))
   2368 )
   2369 
   2370 ; Floating Point Registers as unsigned bytes
   2371 ; These registers are shadowed onto h-fr
   2372 (define-hardware
   2373   (name h-fr_0)
   2374   (comment "floating point registers as unsigned byte 0")
   2375   (attrs PROFILE VIRTUAL)
   2376   (type register UHI (64))
   2377   (indices extern-keyword fr-names)
   2378   (get (regno) (and (reg h-fr_int regno) #xff))
   2379   (set (regno newval)
   2380        (sequence ()
   2381 		 (if (gt USI newval #xff)
   2382 		     (set newval #xff))
   2383 		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xffffff00)
   2384 					   newval))))
   2385 )
   2386 (define-hardware
   2387   (name h-fr_1)
   2388   (comment "floating point registers as unsigned byte 1")
   2389   (attrs PROFILE VIRTUAL)
   2390   (type register UHI (64))
   2391   (indices extern-keyword fr-names)
   2392   (get (regno) (and (srl (reg h-fr_int regno) 8) #xff))
   2393   (set (regno newval)
   2394        (sequence ()
   2395 		 (if (gt USI newval #xff)
   2396 		     (set newval #xff))
   2397 		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xffff00ff) 
   2398 					   (sll newval 8)))))
   2399 )
   2400 (define-hardware
   2401   (name h-fr_2)
   2402   (comment "floating point registers as unsigned byte 2")
   2403   (attrs PROFILE VIRTUAL)
   2404   (type register UHI (64))
   2405   (indices extern-keyword fr-names)
   2406   (get (regno) (and (srl (reg h-fr_int regno) 16) #xff))
   2407   (set (regno newval)
   2408        (sequence ()
   2409 		 (if (gt USI newval #xff)
   2410 		     (set newval #xff))
   2411 		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #xff00ffff) 
   2412 					   (sll newval 16)))))
   2413 )
   2414 (define-hardware
   2415   (name h-fr_3)
   2416   (comment "floating point registers as unsigned byte 3")
   2417   (attrs PROFILE VIRTUAL)
   2418   (type register UHI (64))
   2419   (indices extern-keyword fr-names)
   2420   (get (regno) (and (srl (reg h-fr_int regno) 24) #xff))
   2421   (set (regno newval)
   2422        (sequence ()
   2423 		 (if (gt USI newval #xff)
   2424 		     (set newval #xff))
   2425 		 (set (reg h-fr_int regno) (or (and (reg h-fr_int regno) #x00ffffff) 
   2426 					   (sll newval 24)))))
   2427 )
   2428 ; Coprocessor Registers
   2429 ;
   2430 (define-keyword
   2431   (name cpr-names)
   2432   (print-name h-cpr)
   2433   (prefix "")
   2434   (values
   2435 (cpr0   0)(cpr1   1)(cpr2   2)(cpr3   3)(cpr4   4)(cpr5   5)(cpr6   6)(cpr7   7)
   2436 (cpr8   8)(cpr9   9)(cpr10 10)(cpr11 11)(cpr12 12)(cpr13 13)(cpr14 14)(cpr15 15)
   2437 (cpr16 16)(cpr17 17)(cpr18 18)(cpr19 19)(cpr20 20)(cpr21 21)(cpr22 22)(cpr23 23)
   2438 (cpr24 24)(cpr25 25)(cpr26 26)(cpr27 27)(cpr28 28)(cpr29 29)(cpr30 30)(cpr31 31)
   2439 (cpr32 32)(cpr33 33)(cpr34 34)(cpr35 35)(cpr36 36)(cpr37 37)(cpr38 38)(cpr39 39)
   2440 (cpr40 40)(cpr41 41)(cpr42 42)(cpr43 43)(cpr44 44)(cpr45 45)(cpr46 46)(cpr47 47)
   2441 (cpr48 48)(cpr49 49)(cpr50 50)(cpr51 51)(cpr52 52)(cpr53 53)(cpr54 54)(cpr55 55)
   2442 (cpr56 56)(cpr57 57)(cpr58 58)(cpr59 59)(cpr60 60)(cpr61 61)(cpr62 62)(cpr63 63)
   2443   )
   2444 )
   2445 
   2446 (define-hardware
   2447   (name h-cpr)
   2448   (comment "coprocessor registers")
   2449   (attrs PROFILE (MACH frv))
   2450   (type register WI (64))
   2451   (indices extern-keyword cpr-names)
   2452 )
   2453 
   2454 ; Coprocessor Registers as double words
   2455 ; These registers are shadowed onto h-cpr
   2456 (define-hardware
   2457   (name h-cpr_double)
   2458   (comment "coprocessor registers as double words")
   2459   (attrs PROFILE VIRTUAL (MACH frv))
   2460   (type register DI (32))
   2461   ; FIXME: Need constraint to prohibit odd numbers.
   2462   (indices extern-keyword cpr-names)
   2463   (get (index)
   2464        (c-call DI "@cpu@_h_cpr_double_get_handler" index))
   2465   (set (index newval)
   2466        (c-call VOID "@cpu@_h_cpr_double_set_handler" index newval))
   2467 )
   2468 
   2469 ; Special Purpose Registers
   2470 ;
   2471 (define-keyword
   2472   (name spr-names)
   2473   (print-name h-spr)
   2474   (prefix "")
   2475   (values
   2476    (psr        0) (pcsr       1) (bpcsr      2) (tbr        3) (bpsr       4)
   2477 
   2478    (hsr0      16) (hsr1      17) (hsr2      18) (hsr3      19)
   2479    (hsr4      20) (hsr5      21) (hsr6      22) (hsr7      23)
   2480    (hsr8      24) (hsr9      25) (hsr10     26) (hsr11     27)
   2481    (hsr12     28) (hsr13     29) (hsr14     30) (hsr15     31)
   2482    (hsr16     32) (hsr17     33) (hsr18     34) (hsr19     35)
   2483    (hsr20     36) (hsr21     37) (hsr22     38) (hsr23     39)
   2484    (hsr24     40) (hsr25     41) (hsr26     42) (hsr27     43)
   2485    (hsr28     44) (hsr29     45) (hsr30     46) (hsr31     47)
   2486    (hsr32     48) (hsr33     49) (hsr34     50) (hsr35     51)
   2487    (hsr36     52) (hsr37     53) (hsr38     54) (hsr39     55)
   2488    (hsr40     56) (hsr41     57) (hsr42     58) (hsr43     59)
   2489    (hsr44     60) (hsr45     61) (hsr46     62) (hsr47     63)
   2490    (hsr48     64) (hsr49     65) (hsr50     66) (hsr51     67)
   2491    (hsr52     68) (hsr53     69) (hsr54     70) (hsr55     71)
   2492    (hsr56     72) (hsr57     73) (hsr58     74) (hsr59     75)
   2493    (hsr60     76) (hsr61     77) (hsr62     78) (hsr63     79)
   2494 
   2495    (ccr      256) (cccr     263) (lr       272) (lcr      273) (iacc0h   280) (iacc0l   281) (isr      288)
   2496 
   2497    (neear0   352) (neear1   353) (neear2   354) (neear3   355)
   2498    (neear4   356) (neear5   357) (neear6   358) (neear7   359)
   2499    (neear8   360) (neear9   361) (neear10  362) (neear11  363)
   2500    (neear12  364) (neear13  365) (neear14  366) (neear15  367)
   2501    (neear16  368) (neear17  369) (neear18  370) (neear19  371)
   2502    (neear20  372) (neear21  373) (neear22  374) (neear23  375)
   2503    (neear24  376) (neear25  377) (neear26  378) (neear27  379)
   2504    (neear28  380) (neear29  381) (neear30  382) (neear31  383)
   2505 
   2506    (nesr0    384) (nesr1    385) (nesr2    386) (nesr3    387)
   2507    (nesr4    388) (nesr5    389) (nesr6    390) (nesr7    391)
   2508    (nesr8    392) (nesr9    393) (nesr10   394) (nesr11   395)
   2509    (nesr12   396) (nesr13   397) (nesr14   398) (nesr15   399)
   2510    (nesr16   400) (nesr17   401) (nesr18   402) (nesr19   403)
   2511    (nesr20   404) (nesr21   405) (nesr22   406) (nesr23   407)
   2512    (nesr24   408) (nesr25   409) (nesr26   410) (nesr27   411)
   2513    (nesr28   412) (nesr29   413) (nesr30   414) (nesr31   415)
   2514 
   2515    (necr     416)
   2516 
   2517    (gner0    432) (gner1    433)
   2518 
   2519    (fner0    434) (fner1    435)
   2520 
   2521    (epcr0    512) (epcr1    513) (epcr2    514) (epcr3    515)
   2522    (epcr4    516) (epcr5    517) (epcr6    518) (epcr7    519)
   2523    (epcr8    520) (epcr9    521) (epcr10   522) (epcr11   523)
   2524    (epcr12   524) (epcr13   525) (epcr14   526) (epcr15   527)
   2525    (epcr16   528) (epcr17   529) (epcr18   530) (epcr19   531)
   2526    (epcr20   532) (epcr21   533) (epcr22   534) (epcr23   535)
   2527    (epcr24   536) (epcr25   537) (epcr26   538) (epcr27   539)
   2528    (epcr28   540) (epcr29   541) (epcr30   542) (epcr31   543)
   2529    (epcr32   544) (epcr33   545) (epcr34   546) (epcr35   547)
   2530    (epcr36   548) (epcr37   549) (epcr38   550) (epcr39   551)
   2531    (epcr40   552) (epcr41   553) (epcr42   554) (epcr43   555)
   2532    (epcr44   556) (epcr45   557) (epcr46   558) (epcr47   559)
   2533    (epcr48   560) (epcr49   561) (epcr50   562) (epcr51   563)
   2534    (epcr52   564) (epcr53   565) (epcr54   566) (epcr55   567)
   2535    (epcr56   568) (epcr57   569) (epcr58   570) (epcr59   571)
   2536    (epcr60   572) (epcr61   573) (epcr62   574) (epcr63   575)
   2537 
   2538    (esr0     576) (esr1     577) (esr2     578) (esr3     579)
   2539    (esr4     580) (esr5     581) (esr6     582) (esr7     583)
   2540    (esr8     584) (esr9     585) (esr10    586) (esr11    587)
   2541    (esr12    588) (esr13    589) (esr14    590) (esr15    591)
   2542    (esr16    592) (esr17    593) (esr18    594) (esr19    595)
   2543    (esr20    596) (esr21    597) (esr22    598) (esr23    599)
   2544    (esr24    600) (esr25    601) (esr26    602) (esr27    603)
   2545    (esr28    604) (esr29    605) (esr30    606) (esr31    607)
   2546    (esr32    608) (esr33    609) (esr34    610) (esr35    611)
   2547    (esr36    612) (esr37    613) (esr38    614) (esr39    615)
   2548    (esr40    616) (esr41    617) (esr42    618) (esr43    619)
   2549    (esr44    620) (esr45    621) (esr46    622) (esr47    623)
   2550    (esr48    624) (esr49    625) (esr50    626) (esr51    627)
   2551    (esr52    628) (esr53    629) (esr54    630) (esr55    631)
   2552    (esr56    632) (esr57    633) (esr58    634) (esr59    635)
   2553    (esr60    636) (esr61    637) (esr62    638) (esr63    639)
   2554 
   2555    (eir0     640) (eir1     641) (eir2     642) (eir3     643)
   2556    (eir4     644) (eir5     645) (eir6     646) (eir7     647)
   2557    (eir8     648) (eir9     649) (eir10    650) (eir11    651)
   2558    (eir12    652) (eir13    653) (eir14    654) (eir15    655)
   2559    (eir16    656) (eir17    657) (eir18    658) (eir19    659)
   2560    (eir20    660) (eir21    661) (eir22    662) (eir23    663)
   2561    (eir24    664) (eir25    665) (eir26    666) (eir27    667)
   2562    (eir28    668) (eir29    669) (eir30    670) (eir31    671)
   2563 
   2564    (esfr0    672) (esfr1    673)
   2565 
   2566    (sr0      768) (sr1      769) (sr2      770) (sr3      771) 
   2567 
   2568    (scr0     832) (scr1     833) (scr2     834) (scr3     835)
   2569 
   2570    (fsr0    1024) (fsr1    1025) (fsr2    1026) (fsr3    1027)
   2571    (fsr4    1028) (fsr5    1029) (fsr6    1030) (fsr7    1031)
   2572    (fsr8    1032) (fsr9    1033) (fsr10   1034) (fsr11   1035)
   2573    (fsr12   1036) (fsr13   1037) (fsr14   1038) (fsr15   1039)
   2574    (fsr16   1040) (fsr17   1041) (fsr18   1042) (fsr19   1043)
   2575    (fsr20   1044) (fsr21   1045) (fsr22   1046) (fsr23   1047)
   2576    (fsr24   1048) (fsr25   1049) (fsr26   1050) (fsr27   1051)
   2577    (fsr28   1052) (fsr29   1053) (fsr30   1054) (fsr31   1055)
   2578    (fsr32   1056) (fsr33   1057) (fsr34   1058) (fsr35   1059)
   2579    (fsr36   1060) (fsr37   1061) (fsr38   1062) (fsr39   1063)
   2580    (fsr40   1064) (fsr41   1065) (fsr42   1066) (fsr43   1067)
   2581    (fsr44   1068) (fsr45   1069) (fsr46   1070) (fsr47   1071)
   2582    (fsr48   1072) (fsr49   1073) (fsr50   1074) (fsr51   1075)
   2583    (fsr52   1076) (fsr53   1077) (fsr54   1078) (fsr55   1079)
   2584    (fsr56   1080) (fsr57   1081) (fsr58   1082) (fsr59   1083)
   2585    (fsr60   1084) (fsr61   1085) (fsr62   1086) (fsr63   1087)
   2586 
   2587    ; FQ0-FQ31 are 64 bit registers.
   2588    ; These names allow access to the upper 32 bits of the FQ registers.
   2589    (fqop0   1088) (fqop1   1090) (fqop2   1092) (fqop3   1094) 
   2590    (fqop4   1096) (fqop5   1098) (fqop6   1100) (fqop7   1102) 
   2591    (fqop8   1104) (fqop9   1106) (fqop10  1108) (fqop11  1110) 
   2592    (fqop12  1112) (fqop13  1114) (fqop14  1116) (fqop15  1118) 
   2593    (fqop16  1120) (fqop17  1122) (fqop18  1124) (fqop19  1126) 
   2594    (fqop20  1128) (fqop21  1130) (fqop22  1132) (fqop23  1134) 
   2595    (fqop24  1136) (fqop25  1138) (fqop26  1140) (fqop27  1142) 
   2596    (fqop28  1144) (fqop29  1146) (fqop30  1148) (fqop31  1150) 
   2597    ; These names allow access to the lower 32 bits of the FQ registers.
   2598    (fqst0   1089) (fqst1   1091) (fqst2   1093) (fqst3   1095) 
   2599    (fqst4   1097) (fqst5   1099) (fqst6   1101) (fqst7   1103) 
   2600    (fqst8   1105) (fqst9   1107) (fqst10  1109) (fqst11  1111) 
   2601    (fqst12  1113) (fqst13  1115) (fqst14  1117) (fqst15  1119) 
   2602    (fqst16  1121) (fqst17  1123) (fqst18  1125) (fqst19  1127) 
   2603    (fqst20  1129) (fqst21  1131) (fqst22  1133) (fqst23  1135) 
   2604    (fqst24  1137) (fqst25  1139) (fqst26  1141) (fqst27  1143) 
   2605    (fqst28  1145) (fqst29  1147) (fqst30  1149) (fqst31  1151) 
   2606    ; These also access the lower 32 bits of the FQ registers.
   2607    ; These are not accessible as spr registers (see LSI appendix - section 13.4)
   2608 ;  (fq0     1089) (fq1     1091) (fq2     1093) (fq3     1095) 
   2609 ;  (fq4     1097) (fq5     1099) (fq6     1101) (fq7     1103) 
   2610 ;  (fq8     1105) (fq9     1107) (fq10    1109) (fq11    1111) 
   2611 ;  (fq12    1113) (fq13    1115) (fq14    1117) (fq15    1119) 
   2612 ;  (fq16    1121) (fq17    1123) (fq18    1125) (fq19    1127) 
   2613 ;  (fq20    1129) (fq21    1131) (fq22    1133) (fq23    1135) 
   2614 ;  (fq24    1137) (fq25    1139) (fq26    1141) (fq27    1143) 
   2615 ;  (fq28    1145) (fq29    1147) (fq30    1149) (fq31    1151) 
   2616 
   2617    (mcilr0  1272) (mcilr1  1273)
   2618 
   2619    (msr0    1280) (msr1    1281) (msr2    1282) (msr3    1283)
   2620    (msr4    1284) (msr5    1285) (msr6    1286) (msr7    1287)
   2621    (msr8    1288) (msr9    1289) (msr10   1290) (msr11   1291)
   2622    (msr12   1292) (msr13   1293) (msr14   1294) (msr15   1295)
   2623    (msr16   1296) (msr17   1297) (msr18   1298) (msr19   1299)
   2624    (msr20   1300) (msr21   1301) (msr22   1302) (msr23   1303)
   2625    (msr24   1304) (msr25   1305) (msr26   1306) (msr27   1307)
   2626    (msr28   1308) (msr29   1309) (msr30   1310) (msr31   1311)
   2627    (msr32   1312) (msr33   1313) (msr34   1314) (msr35   1315)
   2628    (msr36   1316) (msr37   1317) (msr38   1318) (msr39   1319)
   2629    (msr40   1320) (msr41   1321) (msr42   1322) (msr43   1323)
   2630    (msr44   1324) (msr45   1325) (msr46   1326) (msr47   1327)
   2631    (msr48   1328) (msr49   1329) (msr50   1330) (msr51   1331)
   2632    (msr52   1332) (msr53   1333) (msr54   1334) (msr55   1335)
   2633    (msr56   1336) (msr57   1337) (msr58   1338) (msr59   1339)
   2634    (msr60   1340) (msr61   1341) (msr62   1342) (msr63   1343)
   2635 
   2636    ; MQ0-MQ31 are 64 bit registers.
   2637    ; These names allow access to the upper 32 bits of the MQ registers.
   2638    (mqop0   1344) (mqop1   1346) (mqop2   1348) (mqop3   1350) 
   2639    (mqop4   1352) (mqop5   1354) (mqop6   1356) (mqop7   1358) 
   2640    (mqop8   1360) (mqop9   1362) (mqop10  1364) (mqop11  1366) 
   2641    (mqop12  1368) (mqop13  1370) (mqop14  1372) (mqop15  1374) 
   2642    (mqop16  1376) (mqop17  1378) (mqop18  1380) (mqop19  1382) 
   2643    (mqop20  1384) (mqop21  1386) (mqop22  1388) (mqop23  1390) 
   2644    (mqop24  1392) (mqop25  1394) (mqop26  1396) (mqop27  1398) 
   2645    (mqop28  1400) (mqop29  1402) (mqop30  1404) (mqop31  1406) 
   2646    ; These names allow access to the lower 32 bits of the MQ registers.
   2647    (mqst0   1345) (mqst1   1347) (mqst2   1349) (mqst3   1351) 
   2648    (mqst4   1353) (mqst5   1355) (mqst6   1357) (mqst7   1359) 
   2649    (mqst8   1361) (mqst9   1363) (mqst10  1365) (mqst11  1367) 
   2650    (mqst12  1369) (mqst13  1371) (mqst14  1373) (mqst15  1375) 
   2651    (mqst16  1377) (mqst17  1379) (mqst18  1381) (mqst19  1383) 
   2652    (mqst20  1385) (mqst21  1387) (mqst22  1389) (mqst23  1391) 
   2653    (mqst24  1393) (mqst25  1395) (mqst26  1397) (mqst27  1399) 
   2654    (mqst28  1401) (mqst29  1403) (mqst30  1405) (mqst31  1407) 
   2655    ; These also access the lower 32 bits of the MQ registers.
   2656    ; These are not accessible as spr registers (see LSI appendix - section 13.4)
   2657 ;  (mq0     1345) (mq1     1347) (mq2     1349) (mq3     1351) 
   2658 ;  (mq4     1353) (mq5     1355) (mq6     1357) (mq7     1359) 
   2659 ;  (mq8     1361) (mq9     1363) (mq10    1365) (mq11    1367) 
   2660 ;  (mq12    1369) (mq13    1371) (mq14    1373) (mq15    1375) 
   2661 ;  (mq16    1377) (mq17    1379) (mq18    1381) (mq19    1383) 
   2662 ;  (mq20    1385) (mq21    1387) (mq22    1389) (mq23    1391) 
   2663 ;  (mq24    1393) (mq25    1395) (mq26    1397) (mq27    1399) 
   2664 ;  (mq28    1401) (mq29    1403) (mq30    1405) (mq31    1407) 
   2665 
   2666    ; These are not accessible as spr registers (see LSI appendix - section 13.4)
   2667 ;  (acc0    1408) (acc1    1409) (acc2    1410) (acc3    1411)
   2668 ;  (acc4    1412) (acc5    1413) (acc6    1414) (acc7    1415)
   2669 ;  (acc8    1416) (acc9    1417) (acc10   1418) (acc11   1419)
   2670 ;  (acc12   1420) (acc13   1421) (acc14   1422) (acc15   1423)
   2671 ;  (acc16   1424) (acc17   1425) (acc18   1426) (acc19   1427)
   2672 ;  (acc20   1428) (acc21   1429) (acc22   1430) (acc23   1431)
   2673 ;  (acc24   1432) (acc25   1433) (acc26   1434) (acc27   1435)
   2674 ;  (acc28   1436) (acc29   1437) (acc30   1438) (acc31   1439)
   2675 ;  (acc32   1440) (acc33   1441) (acc34   1442) (acc35   1443)
   2676 ;  (acc36   1444) (acc37   1445) (acc38   1446) (acc39   1447)
   2677 ;  (acc40   1448) (acc41   1449) (acc42   1450) (acc43   1451)
   2678 ;  (acc44   1452) (acc45   1453) (acc46   1454) (acc47   1455)
   2679 ;  (acc48   1456) (acc49   1457) (acc50   1458) (acc51   1459)
   2680 ;  (acc52   1460) (acc53   1461) (acc54   1462) (acc55   1463)
   2681 ;  (acc56   1464) (acc57   1465) (acc58   1466) (acc59   1467)
   2682 ;  (acc60   1468) (acc61   1469) (acc62   1470) (acc63   1471)
   2683 
   2684 ;  (accg0   1472) (accg1   1473) (accg2   1474) (accg3   1475)
   2685 ;  (accg4   1476) (accg5   1477) (accg6   1478) (accg7   1479)
   2686 ;  (accg8   1480) (accg9   1481) (accg10  1482) (accg11  1483)
   2687 ;  (accg12  1484) (accg13  1485) (accg14  1486) (accg15  1487)
   2688 ;  (accg16  1488) (accg17  1489) (accg18  1490) (accg19  1491)
   2689 ;  (accg20  1492) (accg21  1493) (accg22  1494) (accg23  1495)
   2690 ;  (accg24  1496) (accg25  1497) (accg26  1498) (accg27  1499)
   2691 ;  (accg28  1500) (accg29  1501) (accg30  1502) (accg31  1503)
   2692 ;  (accg32  1504) (accg33  1505) (accg34  1506) (accg35  1507)
   2693 ;  (accg36  1508) (accg37  1509) (accg38  1510) (accg39  1511)
   2694 ;  (accg40  1512) (accg41  1513) (accg42  1514) (accg43  1515)
   2695 ;  (accg44  1516) (accg45  1517) (accg46  1518) (accg47  1519)
   2696 ;  (accg48  1520) (accg49  1521) (accg50  1522) (accg51  1523)
   2697 ;  (accg52  1524) (accg53  1525) (accg54  1526) (accg55  1527)
   2698 ;  (accg56  1528) (accg57  1529) (accg58  1530) (accg59  1531)
   2699 ;  (accg60  1532) (accg61  1533) (accg62  1534) (accg63  1535)
   2700 
   2701    (ear0    1536) (ear1    1537) (ear2    1538) (ear3    1539)
   2702    (ear4    1540) (ear5    1541) (ear6    1542) (ear7    1543)
   2703    (ear8    1544) (ear9    1545) (ear10   1546) (ear11   1547)
   2704    (ear12   1548) (ear13   1549) (ear14   1550) (ear15   1551)
   2705    (ear16   1552) (ear17   1553) (ear18   1554) (ear19   1555)
   2706    (ear20   1556) (ear21   1557) (ear22   1558) (ear23   1559)
   2707    (ear24   1560) (ear25   1561) (ear26   1562) (ear27   1563)
   2708    (ear28   1564) (ear29   1565) (ear30   1566) (ear31   1567)
   2709    (ear32   1568) (ear33   1569) (ear34   1570) (ear35   1571)
   2710    (ear36   1572) (ear37   1573) (ear38   1574) (ear39   1575)
   2711    (ear40   1576) (ear41   1577) (ear42   1578) (ear43   1579)
   2712    (ear44   1580) (ear45   1581) (ear46   1582) (ear47   1583)
   2713    (ear48   1584) (ear49   1585) (ear50   1586) (ear51   1587)
   2714    (ear52   1588) (ear53   1589) (ear54   1590) (ear55   1591)
   2715    (ear56   1592) (ear57   1593) (ear58   1594) (ear59   1595)
   2716    (ear60   1596) (ear61   1597) (ear62   1598) (ear63   1599)
   2717 
   2718    (edr0    1600) (edr1    1601) (edr2    1602) (edr3    1603)
   2719    (edr4    1604) (edr5    1605) (edr6    1606) (edr7    1607)
   2720    (edr8    1608) (edr9    1609) (edr10   1610) (edr11   1611)
   2721    (edr12   1612) (edr13   1613) (edr14   1614) (edr15   1615)
   2722    (edr16   1616) (edr17   1617) (edr18   1618) (edr19   1619)
   2723    (edr20   1620) (edr21   1621) (edr22   1622) (edr23   1623)
   2724    (edr24   1624) (edr25   1625) (edr26   1626) (edr27   1627)
   2725    (edr28   1628) (edr29   1629) (edr30   1630) (edr31   1631)
   2726    (edr32   1632) (edr33   1636) (edr34   1634) (edr35   1635)
   2727    (edr36   1636) (edr37   1637) (edr38   1638) (edr39   1639)
   2728    (edr40   1640) (edr41   1641) (edr42   1642) (edr43   1643)
   2729    (edr44   1644) (edr45   1645) (edr46   1646) (edr47   1647)
   2730    (edr48   1648) (edr49   1649) (edr50   1650) (edr51   1651)
   2731    (edr52   1652) (edr53   1653) (edr54   1654) (edr55   1655)
   2732    (edr56   1656) (edr57   1657) (edr58   1658) (edr59   1659)
   2733    (edr60   1660) (edr61   1661) (edr62   1662) (edr63   1663)
   2734 
   2735    (iamlr0  1664) (iamlr1  1665) (iamlr2  1666) (iamlr3  1667)
   2736    (iamlr4  1668) (iamlr5  1669) (iamlr6  1670) (iamlr7  1671)
   2737    (iamlr8  1672) (iamlr9  1673) (iamlr10 1674) (iamlr11 1675)
   2738    (iamlr12 1676) (iamlr13 1677) (iamlr14 1678) (iamlr15 1679)
   2739    (iamlr16 1680) (iamlr17 1681) (iamlr18 1682) (iamlr19 1683)
   2740    (iamlr20 1684) (iamlr21 1685) (iamlr22 1686) (iamlr23 1687)
   2741    (iamlr24 1688) (iamlr25 1689) (iamlr26 1690) (iamlr27 1691)
   2742    (iamlr28 1692) (iamlr29 1693) (iamlr30 1694) (iamlr31 1695)
   2743    (iamlr32 1696) (iamlr33 1697) (iamlr34 1698) (iamlr35 1699)
   2744    (iamlr36 1700) (iamlr37 1701) (iamlr38 1702) (iamlr39 1703)
   2745    (iamlr40 1704) (iamlr41 1705) (iamlr42 1706) (iamlr43 1707)
   2746    (iamlr44 1708) (iamlr45 1709) (iamlr46 1710) (iamlr47 1711)
   2747    (iamlr48 1712) (iamlr49 1713) (iamlr50 1714) (iamlr51 1715)
   2748    (iamlr52 1716) (iamlr53 1717) (iamlr54 1718) (iamlr55 1719)
   2749    (iamlr56 1720) (iamlr57 1721) (iamlr58 1722) (iamlr59 1723)
   2750    (iamlr60 1724) (iamlr61 1725) (iamlr62 1726) (iamlr63 1727)
   2751 
   2752    (iampr0  1728) (iampr1  1729) (iampr2  1730) (iampr3  1731)
   2753    (iampr4  1732) (iampr5  1733) (iampr6  1734) (iampr7  1735)
   2754    (iampr8  1736) (iampr9  1737) (iampr10 1738) (iampr11 1739)
   2755    (iampr12 1740) (iampr13 1741) (iampr14 1742) (iampr15 1743)
   2756    (iampr16 1744) (iampr17 1745) (iampr18 1746) (iampr19 1747)
   2757    (iampr20 1748) (iampr21 1749) (iampr22 1750) (iampr23 1751)
   2758    (iampr24 1752) (iampr25 1753) (iampr26 1754) (iampr27 1755)
   2759    (iampr28 1756) (iampr29 1757) (iampr30 1758) (iampr31 1759)
   2760    (iampr32 1760) (iampr33 1761) (iampr34 1762) (iampr35 1763)
   2761    (iampr36 1764) (iampr37 1765) (iampr38 1766) (iampr39 1767)
   2762    (iampr40 1768) (iampr41 1769) (iampr42 1770) (iampr43 1771)
   2763    (iampr44 1772) (iampr45 1773) (iampr46 1774) (iampr47 1775)
   2764    (iampr48 1776) (iampr49 1777) (iampr50 1778) (iampr51 1779)
   2765    (iampr52 1780) (iampr53 1781) (iampr54 1782) (iampr55 1783)
   2766    (iampr56 1784) (iampr57 1785) (iampr58 1786) (iampr59 1787)
   2767    (iampr60 1788) (iampr61 1789) (iampr62 1790) (iampr63 1791)
   2768 
   2769    (damlr0  1792) (damlr1  1793) (damlr2  1794) (damlr3  1795)
   2770    (damlr4  1796) (damlr5  1797) (damlr6  1798) (damlr7  1799)
   2771    (damlr8  1800) (damlr9  1801) (damlr10 1802) (damlr11 1803)
   2772    (damlr12 1804) (damlr13 1805) (damlr14 1806) (damlr15 1807)
   2773    (damlr16 1808) (damlr17 1809) (damlr18 1810) (damlr19 1811)
   2774    (damlr20 1812) (damlr21 1813) (damlr22 1814) (damlr23 1815)
   2775    (damlr24 1816) (damlr25 1817) (damlr26 1818) (damlr27 1819)
   2776    (damlr28 1820) (damlr29 1821) (damlr30 1822) (damlr31 1823)
   2777    (damlr32 1824) (damlr33 1825) (damlr34 1826) (damlr35 1827)
   2778    (damlr36 1828) (damlr37 1829) (damlr38 1830) (damlr39 1831)
   2779    (damlr40 1832) (damlr41 1833) (damlr42 1834) (damlr43 1835)
   2780    (damlr44 1836) (damlr45 1837) (damlr46 1838) (damlr47 1839)
   2781    (damlr48 1840) (damlr49 1841) (damlr50 1842) (damlr51 1843)
   2782    (damlr52 1844) (damlr53 1845) (damlr54 1846) (damlr55 1847)
   2783    (damlr56 1848) (damlr57 1849) (damlr58 1850) (damlr59 1851)
   2784    (damlr60 1852) (damlr61 1853) (damlr62 1854) (damlr63 1855)
   2785 
   2786    (dampr0  1856) (dampr1  1857) (dampr2  1858) (dampr3  1859)
   2787    (dampr4  1860) (dampr5  1861) (dampr6  1862) (dampr7  1863)
   2788    (dampr8  1864) (dampr9  1865) (dampr10 1866) (dampr11 1867)
   2789    (dampr12 1868) (dampr13 1869) (dampr14 1870) (dampr15 1871)
   2790    (dampr16 1872) (dampr17 1873) (dampr18 1874) (dampr19 1875)
   2791    (dampr20 1876) (dampr21 1877) (dampr22 1878) (dampr23 1879)
   2792    (dampr24 1880) (dampr25 1881) (dampr26 1882) (dampr27 1883)
   2793    (dampr28 1884) (dampr29 1885) (dampr30 1886) (dampr31 1887)
   2794    (dampr32 1888) (dampr33 1889) (dampr34 1890) (dampr35 1891)
   2795    (dampr36 1892) (dampr37 1893) (dampr38 1894) (dampr39 1895)
   2796    (dampr40 1896) (dampr41 1897) (dampr42 1898) (dampr43 1899)
   2797    (dampr44 1900) (dampr45 1901) (dampr46 1902) (dampr47 1903)
   2798    (dampr48 1904) (dampr49 1905) (dampr50 1906) (dampr51 1907)
   2799    (dampr52 1908) (dampr53 1909) (dampr54 1910) (dampr55 1911)
   2800    (dampr56 1912) (dampr57 1913) (dampr58 1914) (dampr59 1915)
   2801    (dampr60 1916) (dampr61 1917) (dampr62 1918) (dampr63 1919)
   2802 
   2803    (amcr    1920) (stbar   1921) (mmcr    1922)
   2804    (iamvr1  1925) (damvr1  1927)
   2805    (cxnr    1936) (ttbr    1937) (tplr    1938) (tppr    1939)
   2806    (tpxr    1940)
   2807    (timerh  1952) (timerl  1953) (timerd  1954)
   2808    (dcr     2048) (brr     2049) (nmar    2050) (btbr    2051)
   2809 
   2810    (ibar0   2052) (ibar1   2053) (ibar2   2054) (ibar3   2055)
   2811    (dbar0   2056) (dbar1   2057) (dbar2   2058) (dbar3   2059)
   2812 
   2813    (dbdr00  2060) (dbdr01  2061) (dbdr02  2062) (dbdr03  2063)
   2814    (dbdr10  2064) (dbdr11  2065) (dbdr12  2066) (dbdr13  2067)
   2815    (dbdr20  2068) (dbdr21  2069) (dbdr22  2070) (dbdr23  2071)
   2816    (dbdr30  2072) (dbdr31  2073) (dbdr32  2074) (dbdr33  2075)
   2817 
   2818    (dbmr00  2076) (dbmr01  2077) (dbmr02  2078) (dbmr03  2079)
   2819    (dbmr10  2080) (dbmr11  2081) (dbmr12  2082) (dbmr13  2083)
   2820    (dbmr20  2084) (dbmr21  2085) (dbmr22  2086) (dbmr23  2087)
   2821    (dbmr30  2088) (dbmr31  2089) (dbmr32  2090) (dbmr33  2091)
   2822 
   2823    (cpcfr   2304) (cpcr    2305) (cpsr    2306) (cptr    2307)
   2824    (cphsr0  2308) (cphsr1  2309) (cpesr0  2320) (cpesr1  2321)
   2825    (cpemr0  2322) (cpemr1  2323) 
   2826 
   2827    (iperr0  2324) (iperr1  2325) (ipjsr   2326) (ipjrr   2327)
   2828    (ipcsr0  2336) (ipcsr1  2337) (ipcwer0 2338) (ipcwer1 2339)
   2829    (ipcwr   2340)
   2830 
   2831    (mbhsr   2352) (mbssr   2353) (mbrsr   2354) (mbsdr   2355)
   2832    (mbrdr   2356) (mbsmr   2357) (mbstr0  2359) (mbstr1  2360)
   2833 
   2834    (slpr    2368) (sldr    2369) (slhsr   2370) (sltr    2371)
   2835    (slwr    2372)
   2836 
   2837    (ihsr8   3848) (ihsr9   3849) (ihsr10  3850)
   2838   )
   2839 )
   2840 
   2841 (define-hardware
   2842   (name h-spr)
   2843   (comment "special purpose registers")
   2844   (attrs PROFILE)
   2845   (type register UWI (4096))
   2846   (indices extern-keyword spr-names)
   2847   (get (index) (c-call UWI "@cpu@_h_spr_get_handler" index))
   2848   (set (index newval) (c-call VOID "@cpu@_h_spr_set_handler" index newval))
   2849 )
   2850 
   2851 (define-pmacro (spr-pcsr)  (reg h-spr   1))
   2852 (define-pmacro (spr-bpcsr) (reg h-spr   2))
   2853 (define-pmacro (spr-lr)    (reg h-spr 272))
   2854 (define-pmacro (spr-lcr)   (reg h-spr 273))
   2855 (define-pmacro (spr-iacc0h) (reg h-spr 280))
   2856 (define-pmacro (spr-iacc0l) (reg h-spr 281))
   2857 (define-pmacro (spr-sr0)   (reg h-spr 768))
   2858 (define-pmacro (spr-sr1)   (reg h-spr 769))
   2859 (define-pmacro (spr-sr2)   (reg h-spr 770))
   2860 (define-pmacro (spr-sr3)   (reg h-spr 771))
   2861 
   2862 ; Accumulator guard. Actually a subset of the SPR registers, but those SPRs
   2863 ; are read-only in most insns. This hardware element is used by those insns
   2864 ; which have direct access (mwtaccg, mrdaccg).
   2865 (define-keyword
   2866   (name accg-names)
   2867   (print-name h-accg)
   2868   (prefix "")
   2869   (values
   2870    (accg0   0)(accg1   1)(accg2   2)(accg3   3)
   2871    (accg4   4)(accg5   5)(accg6   6)(accg7   7)
   2872    (accg8   8)(accg9   9)(accg10 10)(accg11 11)
   2873    (accg12 12)(accg13 13)(accg14 14)(accg15 15)
   2874    (accg16 16)(accg17 17)(accg18 18)(accg19 19)
   2875    (accg20 20)(accg21 21)(accg22 22)(accg23 23)
   2876    (accg24 24)(accg25 25)(accg26 26)(accg27 27)
   2877    (accg28 28)(accg29 29)(accg30 30)(accg31 31)
   2878    (accg32 32)(accg33 33)(accg34 34)(accg35 35)
   2879    (accg36 36)(accg37 37)(accg38 38)(accg39 39)
   2880    (accg40 40)(accg41 41)(accg42 42)(accg43 43)
   2881    (accg44 44)(accg45 45)(accg46 46)(accg47 47)
   2882    (accg48 48)(accg49 49)(accg50 50)(accg51 51)
   2883    (accg52 52)(accg53 53)(accg54 54)(accg55 55)
   2884    (accg56 56)(accg57 57)(accg58 58)(accg59 59)
   2885    (accg60 60)(accg61 61)(accg62 62)(accg63 63)
   2886   )
   2887 )
   2888 
   2889 (define-hardware
   2890   (name h-accg)
   2891   (comment "accumulator guard")
   2892   (attrs PROFILE VIRTUAL)
   2893   (type register UWI (64))
   2894   (indices extern-keyword accg-names)
   2895   (get (index)
   2896        (and (reg h-spr (add index 1472)) #xff))
   2897   (set (index newval)
   2898        (set (raw-reg UWI h-spr (add index 1472)) (and newval #xff)))
   2899 )
   2900 
   2901 ; 40 bit accumulator. Composed of ACCG and ACC registers concatenated, but
   2902 ; referenced more often as the composed 40 bits.
   2903 (define-keyword
   2904   (name acc-names)
   2905   (print-name h-acc40)
   2906   (prefix "")
   2907   (values
   2908 (acc0   0)(acc1   1)(acc2   2)(acc3   3)(acc4   4)(acc5   5)(acc6   6)(acc7   7)
   2909 (acc8   8)(acc9   9)(acc10 10)(acc11 11)(acc12 12)(acc13 13)(acc14 14)(acc15 15)
   2910 (acc16 16)(acc17 17)(acc18 18)(acc19 19)(acc20 20)(acc21 21)(acc22 22)(acc23 23)
   2911 (acc24 24)(acc25 25)(acc26 26)(acc27 27)(acc28 28)(acc29 29)(acc30 30)(acc31 31)
   2912 (acc32 32)(acc33 33)(acc34 34)(acc35 35)(acc36 36)(acc37 37)(acc38 38)(acc39 39)
   2913 (acc40 40)(acc41 41)(acc42 42)(acc43 43)(acc44 44)(acc45 45)(acc46 46)(acc47 47)
   2914 (acc48 48)(acc49 49)(acc50 50)(acc51 51)(acc52 52)(acc53 53)(acc54 54)(acc55 55)
   2915 (acc56 56)(acc57 57)(acc58 58)(acc59 59)(acc60 60)(acc61 61)(acc62 62)(acc63 63)
   2916   )
   2917 )
   2918 
   2919 (define-hardware
   2920   (name h-acc40S)
   2921   (comment "40 bit signed accumulator")
   2922   (attrs PROFILE VIRTUAL)
   2923   (type register DI (64))
   2924   (indices extern-keyword acc-names)
   2925   ; The accumlator is made up of two 32 bit registers, accgi/acci.
   2926   ; We want to extract this as a combined 40 signed bits
   2927   (get (index)
   2928        (or DI
   2929 	   (sll  DI (ext DI (trunc QI (reg h-spr (add index 1472))))
   2930 		 32)
   2931 	   (zext DI (reg h-spr (add index 1408)))))
   2932   ; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
   2933   ; on ACC and ACCG registers
   2934   (set (index newval)
   2935        (sequence ()
   2936 		 (c-call VOID "frv_check_spr_write_access" (add index 1408))
   2937 		 (set (raw-reg UWI h-spr
   2938 			       (add index 1472)) (and (srl newval 32) #xff))
   2939 		 (set (raw-reg UWI h-spr
   2940 			       (add index 1408)) (trunc USI newval))))
   2941 )
   2942 
   2943 (define-hardware
   2944   (name h-acc40U)
   2945   (comment "40 bit unsigned accumulator")
   2946   (attrs PROFILE VIRTUAL)
   2947   (type register DI (64))
   2948   (indices extern-keyword acc-names)
   2949   ; The accumlator is made up of two 32 bit registers, accgi/acci.
   2950   ; We want to extract this as a combined 40 unsigned bits
   2951   (get (index)
   2952        (or DI
   2953 	   (sll  DI (zext DI (reg h-spr (add index 1472))) 32)
   2954 	   (zext DI (reg h-spr (add index 1408)))))
   2955   ; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
   2956   ; on ACC and ACCG registers
   2957   (set (index newval)
   2958        (sequence ()
   2959 		 (c-call VOID "frv_check_spr_write_access" (add index 1408))
   2960 		 (set (raw-reg UWI h-spr
   2961 			       (add index 1472)) (and (srl newval 32) #xff))
   2962 		 (set (raw-reg UWI h-spr
   2963 			       (add index 1408)) (trunc USI newval))))
   2964 )
   2965 ; 64-bit signed accumulator.  Composed of iacc0h and iacc0l registers
   2966 ; concatenated, but referenced more often as the composed 64 bits.
   2967 (define-keyword
   2968   ; This is totally hokey -- I have to have an index!
   2969   (name iacc0-names)
   2970   (print-name h-iacc0)
   2971   (prefix "")
   2972   (values (iacc0 0))
   2973 )
   2974 
   2975 (define-hardware
   2976   (name h-iacc0)
   2977   (comment "64 bit signed accumulator")
   2978   (attrs PROFILE VIRTUAL (MACH fr400,fr450))
   2979   (type register DI (1))
   2980   (indices extern-keyword iacc0-names)
   2981   ; The single 64-bit integer accumulator is made up of two 32 bit
   2982   ; registers, iacc0h and iacc0l.  We want to extract this as a
   2983   ; combined 64 signed bits.
   2984   (get (idx) (or DI (sll DI (ext DI (spr-iacc0h)) 32) (zext DI (spr-iacc0l))))
   2985   (set (idx newval)
   2986        (sequence ()
   2987 		 (set (spr-iacc0h) (trunc SI (srl newval 32)))
   2988 		 (set (spr-iacc0l) (trunc SI newval))))
   2989 )
   2990 
   2991 ; Integer condition code registers (CCR)
   2992 ;
   2993 ; The individual sub registers bits of the CCR are referenced more often than
   2994 ; the entire register so set them directly. We can assemble the
   2995 ; entire register when necessary.
   2996 ;
   2997 (define-keyword
   2998   (name iccr-names)
   2999   (print-name h-iccr)
   3000   (prefix "")
   3001   (values (icc0 0) (icc1 1) (icc2 2) (icc3 3))
   3002 )
   3003 
   3004 (define-hardware
   3005   (name h-iccr)
   3006   (comment "Integer condition code registers")
   3007   (attrs PROFILE)
   3008   (type register UQI (4))
   3009   (indices extern-keyword iccr-names)
   3010 )
   3011 
   3012 ; Floating point condition code registers (CCR)
   3013 ;
   3014 ; The individual sub registers bits of the CCR are referenced more often than
   3015 ; the entire register so set them directly. We can assemble the
   3016 ; entire register when necessary.
   3017 ;
   3018 (define-keyword
   3019   (name fccr-names)
   3020   (print-name h-fccr)
   3021   (prefix "")
   3022   (values (fcc0 0) (fcc1 1) (fcc2 2) (fcc3 3))
   3023 )
   3024 
   3025 (define-hardware
   3026   (name h-fccr)
   3027   (comment "Floating point condition code registers")
   3028   (attrs PROFILE)
   3029   (type register UQI (4))
   3030   (indices extern-keyword fccr-names)
   3031 )
   3032 
   3033 ; C condition code registers (CCCR)
   3034 ;
   3035 (define-keyword
   3036   (name cccr-names)
   3037   (print-name h-cccr)
   3038   (prefix "")
   3039   (values (cc0 0) (cc1 1) (cc2 2) (cc3 3) (cc4 4) (cc5 5) (cc6 6) (cc7 7))
   3040 )
   3041 
   3042 (define-hardware
   3043   (name h-cccr)
   3044   (comment "Condition code registers")
   3045   (attrs PROFILE)
   3046   (type register UQI (8))
   3047   (indices extern-keyword cccr-names)
   3048 )
   3049 
   3051 ; Dummy hardware used to define packing bit on insns
   3052 ;
   3053 (define-hardware
   3054   (name h-pack)
   3055   (comment "Packing bit dummy hardware")
   3056   (type immediate (UINT 1))
   3057   (values keyword "" (("" 1) (".p" 0) (".P" 0)))
   3058 )
   3059 ; Dummy hardware used to define hint field for branches always taken
   3060 ;
   3061 (define-hardware
   3062   (name h-hint-taken)
   3063   (comment "Branch taken hint dummy hardware")
   3064   (type immediate (UINT 1))
   3065   ; The order of these is important. We want '2' to get written by default,
   3066   ; but we also want the docoder/disassembler to allow the values '0', '1' and
   3067   ; '3'.
   3068   (values keyword "" (("" 2) ("" 0) ("" 1) ("" 3)))
   3069 )
   3070 ; Dummy hardware used to define hint field for branches never taken
   3071 ;
   3072 (define-hardware
   3073   (name h-hint-not-taken)
   3074   (comment "Branch not taken hint dummy hardware")
   3075   (type immediate (UINT 1))
   3076   ; The order of these is important. We want '0' to get written by default,
   3077   ; but we also want the docoder/disassembler to allow the values '1', '2' and
   3078   ; '3'.
   3079   (values keyword "" (("" 0) ("" 1) ("" 2) ("" 3)))
   3080 )
   3081 
   3083 ; Instruction Operands.
   3084 ; These entries provide a layer between the assembler and the raw hardware
   3085 ; description, and are used to refer to hardware elements in the semantic
   3086 ; code.  Usually there's a bit of over-specification, but in more complicated
   3087 ; instruction sets there isn't.
   3088 
   3089 ; FRV specific operand attributes:
   3090 
   3091 (define-attr
   3092   (for operand)
   3093   (type boolean)
   3094   (name HASH-PREFIX)
   3095   (comment "immediates have an optional '#' prefix")
   3096 )
   3097 
   3098 ; ??? Convention says this should be o-sr, but then the insn definitions
   3099 ; should refer to o-sr which is clumsy.  The "o-" could be implicit, but
   3100 ; then it should be implicit for all the symbols here, but then there would
   3101 ; be confusion between (f-)simm8 and (h-)simm8.
   3102 ; So for now the rule is exactly as it appears here.
   3103 
   3104 ; dnmop: define-normal-mode-operand: temporary, pending potential removal
   3105 ; of modes from h/w.
   3106 (define-pmacro (dnmop xname xcomment xattrs xtype xindex xmode)
   3107   (define-operand
   3108     (name xname)
   3109     (comment xcomment)
   3110     (.splice attrs (.unsplice xattrs))
   3111     (type xtype)
   3112     (index xindex)
   3113     (mode xmode)
   3114     )
   3115 )
   3116 
   3117 ; dnpmop: define-normal-parsed-mode-operand: Normal mode operand with parse handler
   3118 (define-pmacro (dnpmop xname xcomment xattrs xtype xindex xmode xparse)
   3119   (define-operand
   3120     (name xname)
   3121     (comment xcomment)
   3122     (.splice attrs (.unsplice xattrs))
   3123     (type xtype)
   3124     (index xindex)
   3125     (mode xmode)
   3126     (handlers (parse xparse))
   3127     )
   3128 )
   3129 
   3130 (dnop  pack "packing bit" () h-pack f-pack)
   3131 
   3132 (dnmop GRi        "source register 1"      () h-gr        f-GRi  SI)
   3133 (dnmop GRj        "source register 2"      () h-gr        f-GRj  SI)
   3134 (dnmop GRk        "destination register"   () h-gr        f-GRk  SI)
   3135 (dnmop GRkhi      "destination register"   () h-gr_hi     f-GRk  UHI)
   3136 (dnmop GRklo      "destination register"   () h-gr_lo     f-GRk  UHI)
   3137 (dnpmop GRdoublek "destination register"   () h-gr_double f-GRk  DI "even_register")
   3138 (dnmop ACC40Si    "signed accumulator"     () h-acc40S    f-ACC40Si DI)
   3139 (dnmop ACC40Ui    "unsigned accumulator"   () h-acc40U    f-ACC40Ui UDI)
   3140 (dnmop ACC40Sk    "target accumulator"     () h-acc40S    f-ACC40Sk DI)
   3141 (dnmop ACC40Uk    "target accumulator"     () h-acc40U    f-ACC40Uk UDI)
   3142 (dnmop ACCGi      "source register"        () h-accg      f-ACCGi   UWI)
   3143 (dnmop ACCGk      "target register"        () h-accg      f-ACCGk   UWI)
   3144 
   3145 (dnmop CPRi       "source register"        ((MACH frv)) h-cpr        f-CPRi SI)
   3146 (dnmop CPRj       "source register"        ((MACH frv)) h-cpr        f-CPRj SI)
   3147 (dnmop CPRk       "destination register"   ((MACH frv)) h-cpr        f-CPRk SI)
   3148 (dnpmop CPRdoublek "destination register"  ((MACH frv)) h-cpr_double f-CPRk DI "even_register")
   3149 
   3150 ; floating point operands
   3151 (dnmop FRinti    "source register 1"      () h-fr_int    f-FRi SI)
   3152 (dnmop FRintj    "source register 2"      () h-fr_int    f-FRj SI)
   3153 (dnmop FRintk    "target register"        () h-fr_int    f-FRk SI)
   3154 (dnmop FRi       "source register 1"      () h-fr        f-FRi SF)
   3155 (dnmop FRj       "source register 2"      () h-fr        f-FRj SF)
   3156 (dnmop FRk       "destination register"   () h-fr        f-FRk SF)
   3157 (dnmop FRkhi     "destination register"   () h-fr_hi     f-FRk UHI)
   3158 (dnmop FRklo     "destination register"   () h-fr_lo     f-FRk UHI)
   3159 (dnpmop FRdoublei "source register 1"     () h-fr_double f-FRi DF "even_register")
   3160 (dnpmop FRdoublej "source register 2"     () h-fr_double f-FRj DF "even_register")
   3161 (dnpmop FRdoublek "target register"       () h-fr_double f-FRk DF "even_register")
   3162 
   3163 (dnop CRi       "source register 1"       () h-cccr f-CRi)
   3164 (dnop CRj       "source register 2"       () h-cccr f-CRj)
   3165 (dnop CRj_int   "destination register"    () h-cccr f-CRj_int)
   3166 (dnop CRj_float "destination register"    () h-cccr f-CRj_float)
   3167 (dnop CRk       "destination register"    () h-cccr f-CRk)
   3168 (dnop CCi       "condition   register"    () h-cccr f-CCi)
   3169 
   3170 (dnop ICCi_1  "condition   register"      () h-iccr f-ICCi_1)
   3171 (dnop ICCi_2  "condition   register"      () h-iccr f-ICCi_2)
   3172 (dnop ICCi_3  "condition   register"      () h-iccr f-ICCi_3)
   3173 (dnop FCCi_1  "condition   register"      () h-fccr f-FCCi_1)
   3174 (dnop FCCi_2  "condition   register"      () h-fccr f-FCCi_2)
   3175 (dnop FCCi_3  "condition   register"      () h-fccr f-FCCi_3)
   3176 (dnop FCCk    "condition   register"      () h-fccr f-FCCk)
   3177 
   3178 (dnop eir     "exception insn reg"        () h-uint f-eir)
   3179 (dnop s10     "10 bit signed immediate"   (HASH-PREFIX) h-sint f-s10)
   3180 (dnop u16     "16 bit unsigned immediate" (HASH-PREFIX) h-uint f-u16)
   3181 (dnop s16     "16 bit signed   immediate" (HASH-PREFIX) h-sint f-s16)
   3182 (dnop s6      "6  bit signed   immediate" (HASH-PREFIX) h-sint f-s6)
   3183 (dnop s6_1    "6  bit signed   immediate" (HASH-PREFIX) h-sint f-s6_1)
   3184 (dnop u6      "6  bit unsigned immediate" (HASH-PREFIX) h-uint f-u6)
   3185 (dnop s5      "5  bit signed   immediate" (HASH-PREFIX) h-sint f-s5)
   3186 (dnop cond    "conditional arithmetic"    (HASH-PREFIX) h-uint f-cond)
   3187 (dnop ccond   "lr branch condition"       (HASH-PREFIX) h-uint f-ccond)
   3188 (dnop hint    "2 bit branch predictor"    (HASH-PREFIX) h-uint f-hint)
   3189 (dnop hint_taken "2 bit branch predictor"     () h-hint-taken     f-hint)
   3190 (dnop hint_not_taken "2 bit branch predictor" () h-hint-not-taken f-hint)
   3191 
   3192 (dnop LI      "link indicator"            () h-uint f-LI)
   3193 (dnop lock    "cache lock indicator"      (HASH-PREFIX) h-uint f-lock)
   3194 (dnop debug   "debug mode indicator"      (HASH-PREFIX) h-uint f-debug)
   3195 (dnop ae      "all entries indicator"     (HASH-PREFIX) h-uint f-ae)
   3196 
   3197 (dnop label16  "18 bit pc relative address" () h-iaddr f-label16)
   3198 
   3199 (dnop LRAE "Load Real Address E flag" () h-uint f-LRAE)
   3200 (dnop LRAD "Load Real Address D flag" () h-uint f-LRAD)
   3201 (dnop LRAS "Load Real Address S flag" () h-uint f-LRAS)
   3202 
   3203 (dnop TLBPRopx "TLB Probe operation number" () h-uint f-TLBPRopx)
   3204 (dnop TLBPRL   "TLB Probe L flag"           () h-uint f-TLBPRL)
   3205 
   3206 (define-operand
   3207   (name A0)
   3208   (comment "A==0 operand of mclracc")
   3209   (attrs)
   3210   (type h-uint)
   3211   (index f-A)
   3212   (mode USI)
   3213   (handlers (parse "A0"))
   3214 )
   3215 
   3216 (define-operand
   3217   (name A1)
   3218   (comment "A==1 operand of mclracc")
   3219   (attrs)
   3220   (type h-uint)
   3221   (index f-A)
   3222   (mode USI)
   3223   (handlers (parse "A1"))
   3224 )
   3225 
   3226 (define-operand
   3227   (name FRintieven)
   3228   (comment "(even) source register 1")
   3229   (attrs)
   3230   (type h-fr_int)
   3231   (index f-FRi)
   3232   (mode SI)
   3233   (handlers (parse "even_register"))
   3234 )
   3235 
   3236 (define-operand
   3237   (name FRintjeven)
   3238   (comment "(even) source register 2")
   3239   (attrs)
   3240   (type h-fr_int)
   3241   (index f-FRj)
   3242   (mode SI)
   3243   (handlers (parse "even_register"))
   3244 )
   3245 
   3246 (define-operand
   3247   (name FRintkeven)
   3248   (comment "(even) target register")
   3249   (attrs)
   3250   (type h-fr_int)
   3251   (index f-FRk)
   3252   (mode SI)
   3253   (handlers (parse "even_register"))
   3254 )
   3255 
   3256 (define-operand
   3257   (name d12)
   3258   (comment "12 bit signed immediate")
   3259   (attrs)
   3260   (type h-sint)
   3261   (index f-d12)
   3262   (handlers (parse "d12"))
   3263 )
   3264 
   3265 (define-operand
   3266   (name s12)
   3267   (comment "12 bit signed immediate")
   3268   (attrs HASH-PREFIX)
   3269   (type h-sint)
   3270   (index f-d12)
   3271   (handlers (parse "s12"))
   3272 )
   3273 
   3274 (define-operand
   3275   (name u12)
   3276   (comment "12 bit signed immediate")
   3277   (attrs HASH-PREFIX)
   3278   (type h-sint)
   3279   (index f-u12)
   3280   (handlers (parse "u12"))
   3281 )
   3282 
   3283 (define-operand 
   3284   (name spr)
   3285   (comment "special purpose register")
   3286   (attrs)
   3287   (type  h-spr)
   3288   (index f-spr)
   3289   (handlers (parse "spr") (print "spr"))
   3290 )
   3291 
   3292 (define-operand
   3293   (name ulo16)
   3294   (comment "16 bit unsigned immediate, for #lo()")
   3295   (attrs)
   3296   (type h-uint)
   3297   (index f-u16)
   3298   (handlers (parse "ulo16") (print "lo"))
   3299 )
   3300 
   3301 (define-operand
   3302   (name slo16)
   3303   (comment "16 bit unsigned immediate, for #lo()")
   3304   (attrs)
   3305   (type h-sint)
   3306   (index f-s16)
   3307   (handlers (parse "uslo16") (print "lo"))
   3308 )
   3309 
   3310 (define-operand
   3311   (name uhi16)
   3312   (comment "16 bit unsigned immediate, for #hi()")
   3313   (attrs)
   3314   (type h-uint)
   3315   (index f-u16)
   3316   (handlers (parse "uhi16") (print "hi"))
   3317 )
   3318 
   3319 (define-operand
   3320   (name label24)
   3321   (comment "26 bit pc relative address")
   3322   (attrs)
   3323   (type h-iaddr)
   3324   (index f-label24)
   3325   (mode SI)
   3326   (handlers (parse "call_label"))
   3327 )
   3328 
   3329 ; operands representing hardware
   3330 ;
   3331 (dnop psr_esr "PSR.ESR bit" (SEM-ONLY) h-psr_esr f-nil)
   3332 (dnop psr_s   "PSR.S   bit" (SEM-ONLY) h-psr_s   f-nil)
   3333 (dnop psr_ps  "PSR.PS  bit" (SEM-ONLY) h-psr_ps  f-nil)
   3334 (dnop psr_et  "PSR.ET  bit" (SEM-ONLY) h-psr_et  f-nil)
   3335 
   3336 (dnop bpsr_bs  "BPSR.BS  bit" (SEM-ONLY) h-bpsr_bs  f-nil)
   3337 (dnop bpsr_bet "BPSR.BET bit" (SEM-ONLY) h-bpsr_bet f-nil)
   3338 
   3339 (dnop tbr_tba "TBR.TBA" (SEM-ONLY) h-tbr_tba f-nil)
   3340 (dnop tbr_tt  "TBR.TT"  (SEM-ONLY) h-tbr_tt  f-nil)
   3341 
   3342 ; Null operands
   3343 ;
   3344 (define-pmacro (ICCi_1-null)  (f-ICCi_1-null 0))
   3345 (define-pmacro (ICCi_2-null)  (f-ICCi_2-null 0))
   3346 (define-pmacro (ICCi_3-null)  (f-ICCi_3-null 0))
   3347 (define-pmacro (FCCi_1-null)  (f-FCCi_1-null 0))
   3348 (define-pmacro (FCCi_2-null)  (f-FCCi_2-null 0))
   3349 (define-pmacro (FCCi_3-null)  (f-FCCi_3-null 0))
   3350 (define-pmacro (rs-null)      (f-rs-null     0))
   3351 (define-pmacro (GRi-null)     (f-GRi-null    0))
   3352 (define-pmacro (GRj-null)     (f-GRj-null    0))
   3353 (define-pmacro (GRk-null)     (f-GRk-null    0))
   3354 (define-pmacro (FRi-null)     (f-FRi-null    0))
   3355 (define-pmacro (FRj-null)     (f-FRj-null    0))
   3356 (define-pmacro (ACCj-null)    (f-ACCj-null   0))
   3357 (define-pmacro (rd-null)      (f-rd-null     0))
   3358 (define-pmacro (cond-null)    (f-cond-null   0))
   3359 (define-pmacro (ccond-null)   (f-ccond-null  0))
   3360 (define-pmacro (s12-null)     (f-s12-null    0))
   3361 (define-pmacro (label16-null) (f-label16-null 0))
   3362 (define-pmacro (misc-null-1)  (f-misc-null-1 0))
   3363 (define-pmacro (misc-null-2)  (f-misc-null-2 0))
   3364 (define-pmacro (misc-null-3)  (f-misc-null-3 0))
   3365 (define-pmacro (misc-null-4)  (f-misc-null-4 0))
   3366 (define-pmacro (misc-null-5)  (f-misc-null-5 0))
   3367 (define-pmacro (misc-null-6)  (f-misc-null-6 0))
   3368 (define-pmacro (misc-null-7)  (f-misc-null-7 0))
   3369 (define-pmacro (misc-null-8)  (f-misc-null-8 0))
   3370 (define-pmacro (misc-null-9)  (f-misc-null-9 0))
   3371 (define-pmacro (misc-null-10) (f-misc-null-10 0))
   3372 (define-pmacro (misc-null-11) (f-misc-null-11 0))
   3373 
   3374 (define-pmacro (LRA-null)     (f-LRA-null 0))
   3375 (define-pmacro (TLBPR-null)   (f-TLBPR-null 0))
   3376 
   3377 (define-pmacro (LI-on)       (f-LI-on  1))
   3378 (define-pmacro (LI-off)      (f-LI-off 0))
   3379 
   3381 ; Instruction definitions.
   3382 ;
   3383 ; Notes:
   3384 ; - dni is short for "define-normal-instruction"
   3385 ; - Macros are used to represent each insn format. These should be used as much
   3386 ;   as possible unless an insn has exceptional behaviour
   3387 ;
   3388 
   3389 ; Commonly used Macros
   3390 ;
   3391 ; Specific registers
   3392 ;
   3393 
   3394 ; Integer condition code manipulation
   3395 ;
   3396 (define-pmacro (set-z-and-n icc x)
   3397   (if (eq x 0)
   3398       (set icc (or (and icc #x7) #x4))
   3399       (if (lt x 0)
   3400 	  (set icc (or (and icc #xb) #x8))
   3401 	  (set icc (and icc #x3))))
   3402 )
   3403 
   3404 (define-pmacro (set-n icc val)
   3405   (if (eq val 0)
   3406       (set icc (and icc #x7))
   3407       (set icc (or  icc #x8)))
   3408 )
   3409 
   3410 (define-pmacro (set-z icc val)
   3411   (if (eq val 0)
   3412       (set icc (and icc #xb))
   3413       (set icc (or  icc #x4)))
   3414 )
   3415 
   3416 (define-pmacro (set-v icc val)
   3417   (if (eq val 0)
   3418       (set icc (and icc #xd))
   3419       (set icc (or  icc #x2)))
   3420 )
   3421 
   3422 (define-pmacro (set-c icc val)
   3423   (if (eq val 0)
   3424       (set icc (and icc #xe))
   3425       (set icc (or  icc #x1)))
   3426 )
   3427 
   3428 (define-pmacro (nbit icc)
   3429   (trunc BI (srl (and icc #x8) 3))
   3430 )
   3431 
   3432 (define-pmacro (zbit icc)
   3433   (trunc BI (srl (and icc #x4) 2))
   3434 )
   3435 
   3436 (define-pmacro (vbit icc)
   3437   (trunc BI (srl (and icc #x2) 1))
   3438 )
   3439 
   3440 (define-pmacro (cbit icc)
   3441   (trunc BI (and icc #x1))
   3442 )
   3443 
   3444 (define-pmacro (ebit icc)
   3445   (trunc BI (srl (and icc #x8) 3))
   3446 )
   3447 
   3448 (define-pmacro (lbit icc)
   3449   (trunc BI (srl (and icc #x4) 2))
   3450 )
   3451 
   3452 (define-pmacro (gbit icc)
   3453   (trunc BI (srl (and icc #x2) 1))
   3454 )
   3455 
   3456 (define-pmacro (ubit icc)
   3457   (trunc BI (and icc #x1))
   3458 )
   3459 
   3460 ; FRV insns
   3461 ;
   3462 ;
   3463 ; Format: INT, Logic, Shift r-r
   3464 ;
   3465 (define-pmacro (int-logic-r-r name operation op ope comment)
   3466   (dni name
   3467        (comment)
   3468        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3469 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3470        (.str name "$pack $GRi,$GRj,$GRk")
   3471        (+ pack GRk op GRi (ICCi_1-null) ope GRj)
   3472        (set GRk (operation GRi GRj))
   3473        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3474 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3475   )
   3476 )
   3477 
   3478 (int-logic-r-r add  add   OP_00 OPE2_00 "add reg/reg")
   3479 (int-logic-r-r sub  sub   OP_00 OPE2_04 "sub reg/reg")
   3480 (int-logic-r-r and  and   OP_01 OPE2_00 "and reg/reg")
   3481 (int-logic-r-r or   or    OP_01 OPE2_02 "or  reg/reg")
   3482 (int-logic-r-r xor  xor   OP_01 OPE2_04 "xor reg/reg")
   3483 
   3484 (dni not
   3485      ("not")
   3486      ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3487       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3488      ("not$pack $GRj,$GRk")
   3489      (+ pack GRk OP_01 (rs-null) (ICCi_1-null) OPE2_06 GRj)
   3490      (set GRk (inv GRj))
   3491      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3492       (fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3493 )
   3494 
   3495 (dni sdiv
   3496      "signed division"
   3497      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3498       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3499      "sdiv$pack $GRi,$GRj,$GRk"
   3500      (+ pack GRk OP_00 GRi (ICCi_1-null) OPE2_0E GRj)
   3501      (sequence ()
   3502 	       (c-call VOID "@cpu@_signed_integer_divide"
   3503 		       GRi GRj (index-of GRk) 0)
   3504 	       (clobber GRk))
   3505      ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
   3506       (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   3507 )
   3508 
   3509 (dni nsdiv
   3510      "non excepting signed division"
   3511      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
   3512       (MACH simple,tomcat,fr500,fr550,frv))
   3513      "nsdiv$pack $GRi,$GRj,$GRk"
   3514      (+ pack GRk OP_01 GRi (ICCi_1-null) OPE2_0E GRj)
   3515      (sequence ()
   3516 	       (c-call VOID "@cpu@_signed_integer_divide"
   3517 		       GRi GRj (index-of GRk) 1)
   3518 	       (clobber GRk))
   3519      ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   3520 )
   3521 
   3522 (dni udiv
   3523      "unsigned division reg/reg"
   3524      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3525       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3526      "udiv$pack $GRi,$GRj,$GRk"
   3527      (+ pack GRk OP_00 GRi (ICCi_1-null) OPE2_0F GRj)
   3528      (sequence ()
   3529 	       (c-call VOID "@cpu@_unsigned_integer_divide"
   3530 		       GRi GRj (index-of GRk) 0)
   3531 	       (clobber GRk))
   3532      ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
   3533       (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   3534 )
   3535 
   3536 (dni nudiv
   3537      "non excepting unsigned division"
   3538      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
   3539       (MACH simple,tomcat,fr500,fr550,frv))
   3540      "nudiv$pack $GRi,$GRj,$GRk"
   3541      (+ pack GRk OP_01 GRi (ICCi_1-null) OPE2_0F GRj)
   3542      (sequence ()
   3543 	       (c-call VOID "@cpu@_unsigned_integer_divide"
   3544 		       GRi GRj (index-of GRk) 1)
   3545 	       (clobber GRk))
   3546      ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   3547 )
   3548 
   3549 ; Multiplication
   3550 ;
   3551 (define-pmacro (multiply-r-r name signop op ope comment)
   3552   (dni name
   3553        (comment)
   3554        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3555 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3556        (.str name "$pack $GRi,$GRj,$GRdoublek")
   3557        (+ pack GRdoublek op GRi (ICCi_1-null) ope GRj) 
   3558        (set GRdoublek (mul DI (signop DI GRi) (signop DI GRj)))
   3559        ((fr400 (unit u-imul)) (fr450 (unit u-imul))
   3560 	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
   3561   )
   3562 )
   3563 
   3564 (multiply-r-r smul ext  OP_00 OPE2_08 "signed   multiply reg/reg")
   3565 (multiply-r-r umul zext OP_00 OPE2_0A "unsigned multiply reg/reg")
   3566 
   3567 ; Multiplication with integer accumulator IACC
   3568 ;
   3569 
   3570 (define-pmacro (iacc-set value) 
   3571   (set (reg h-iacc0 0) value))
   3572 
   3573 (define-pmacro (iacc-add value) 
   3574   (set (reg h-iacc0 0)
   3575        (cond DI
   3576 	     ((andif (andif (gt value 0) (gt (reg h-iacc0 0) 0))
   3577 		     (lt (sub DI #x7fffffffffffffff value) (reg h-iacc0 0)))
   3578 	      ; Positive overflow
   3579 	      (const DI #x7fffffffffffffff))
   3580 	     ((andif (andif (lt value 0) (lt (reg h-iacc0 0) 0))
   3581 		     (gt (sub DI #x8000000000000000 value) (reg h-iacc0 0)))
   3582 	      ; Negative overflow
   3583 	      (const DI #x8000000000000000))
   3584 	     (else
   3585 	      (add DI (reg h-iacc0 0) value))))
   3586 )
   3587 
   3588 (define-pmacro (iacc-sub value) 
   3589   (set (reg h-iacc0 0)
   3590        (cond DI
   3591 	     ((andif (andif (lt value 0) (gt (reg h-iacc0 0) 0))
   3592 		     (lt (add DI #x7fffffffffffffff value) (reg h-iacc0 0)))
   3593 	      ; Positive overflow
   3594 	      (const DI #x7fffffffffffffff))
   3595 	     ((andif (andif (gt value 0) (lt (reg h-iacc0 0) 0))
   3596 		     (gt (add DI #x8000000000000000 value) (reg h-iacc0 0)))
   3597 	      ; Negative overflow
   3598 	      (const DI #x8000000000000000))
   3599 	     (else
   3600 	      (sub DI (reg h-iacc0 0) value))))
   3601 )
   3602 
   3603 (define-pmacro (iacc-multiply-r-r name operation op ope comment)
   3604   (dni name
   3605        (comment)
   3606        ((UNIT IACC) (MACH fr400,fr450)
   3607 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
   3608        (.str name "$pack $GRi,$GRj")
   3609        (+ pack (rd-null) op GRi ope GRj)
   3610        ((.sym iacc- operation) (mul DI (ext DI GRi) (ext DI GRj)))
   3611        ((fr400 (unit u-integer)) (fr450 (unit u-integer)))
   3612   )
   3613 )
   3614 
   3615 (iacc-multiply-r-r smu   set OP_46 OPE1_05 "Signed multiply     reg/reg/iacc")
   3616 (iacc-multiply-r-r smass add OP_46 OPE1_06 "Signed multiply/add reg/reg/iacc")
   3617 (iacc-multiply-r-r smsss sub OP_46 OPE1_07 "Signed multiply/sub reg/reg/iacc")
   3618 
   3619 (define-pmacro (int-shift-r-r name op ope comment)
   3620   (dni name
   3621        (comment)
   3622        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3623 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3624        (.str name "$pack $GRi,$GRj,$GRk")
   3625        (+ pack GRk op GRi (ICCi_1-null) ope GRj)
   3626        (set GRk (name GRi (and GRj #x1f)))
   3627        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3628 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3629   )
   3630 )
   3631 
   3632 (int-shift-r-r sll OP_01 OPE2_08 "shift left  logical reg/reg")
   3633 (int-shift-r-r srl OP_01 OPE2_0A "shift right logical reg/reg")
   3634 (int-shift-r-r sra OP_01 OPE2_0C "shift right arith   reg/reg")
   3635 
   3636 (dni slass
   3637      "shift left arith reg/reg with saturation"
   3638      ((UNIT IALL) (MACH fr400,fr450)
   3639       (FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
   3640      "slass$pack $GRi,$GRj,$GRk"
   3641      (+ pack GRk OP_46 GRi OPE1_02 GRj)
   3642      (set GRk (c-call SI "@cpu@_shift_left_arith_saturate" GRi GRj))
   3643      ()
   3644 )
   3645 
   3646 (dni scutss
   3647      "Integer accumulator cut with saturation"
   3648      ((UNIT I0) (MACH fr400,fr450)
   3649       (FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
   3650      "scutss$pack $GRj,$GRk"
   3651      (+ pack GRk OP_46 (rs-null) OPE1_04 GRj)
   3652      (set GRk (c-call SI "@cpu@_iacc_cut" (reg h-iacc0 0) GRj))
   3653      ()
   3654 )
   3655 
   3656 (define-pmacro (scan-semantics arg1 arg2 targ)
   3657   (sequence ((WI tmp1) (WI tmp2))
   3658 	    (set tmp1 arg1)
   3659 	    (set tmp2 (sra arg2 1))
   3660 	    (set targ (c-call WI "@cpu@_scan_result" (xor tmp1 tmp2))))
   3661 )
   3662 
   3663 (dni scan
   3664      "scan"
   3665      ((UNIT SCAN) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3666       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3667      "scan$pack $GRi,$GRj,$GRk"
   3668      (+ pack GRk OP_0B GRi (ICCi_1-null) OPE2_00 GRj)
   3669      (scan-semantics GRi GRj GRk)
   3670      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3671       (fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3672 )
   3673 
   3674 ; Format: conditional INT, Logic, Shift r-r
   3675 ;
   3676 (define-pmacro (conditional-int-logic name operation op ope comment)
   3677   (dni name
   3678        (comment)
   3679        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3680 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3681        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
   3682        (+ pack GRk op GRi CCi cond ope GRj)
   3683        (if (eq CCi (or cond 2))
   3684 	   (set GRk (operation GRi GRj)))
   3685        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3686 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3687   )
   3688 )
   3689 
   3690 (conditional-int-logic cadd  add  OP_58 OPE4_0 "conditional add")
   3691 (conditional-int-logic csub  sub  OP_58 OPE4_1 "conditional sub")
   3692 (conditional-int-logic cand  and  OP_5A OPE4_0 "conditional and")
   3693 (conditional-int-logic cor   or   OP_5A OPE4_1 "conditional or")
   3694 (conditional-int-logic cxor  xor  OP_5A OPE4_2 "conditional xor")
   3695 
   3696 (dni cnot
   3697      "conditional not"
   3698      ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3699       (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3700      "cnot$pack $GRj,$GRk,$CCi,$cond"
   3701      (+ pack GRk OP_5A (rs-null) CCi cond OPE4_3 GRj)
   3702      (if (eq CCi (or cond 2))
   3703 	 (set GRk (inv GRj)))
   3704      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3705       (fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3706 )
   3707 
   3708 (dni csmul
   3709      "conditional signed multiply"
   3710      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3711       (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3712      "csmul$pack $GRi,$GRj,$GRdoublek,$CCi,$cond"
   3713      (+ pack GRdoublek OP_58 GRi CCi cond OPE4_2 GRj)
   3714      (if (eq CCi (or cond 2))
   3715 	 (set GRdoublek (mul DI (ext DI GRi) (ext DI GRj))))
   3716      ((fr400 (unit u-imul)) (fr450 (unit u-imul))
   3717       (fr500 (unit u-imul)) (fr550 (unit u-imul)))
   3718 )
   3719 
   3720 (dni csdiv
   3721      "conditional signed division"
   3722      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3723       (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3724      "csdiv$pack $GRi,$GRj,$GRk,$CCi,$cond"
   3725      (+ pack GRk OP_58 GRi CCi cond OPE4_3 GRj)
   3726      (if (eq CCi (or cond 2))
   3727 	 (sequence ()
   3728 		   (c-call VOID "@cpu@_signed_integer_divide"
   3729 			   GRi GRj (index-of GRk) 0)
   3730 		   (clobber GRk)))
   3731      ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
   3732       (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   3733 )
   3734 
   3735 (dni cudiv
   3736      "conditional unsigned division"
   3737      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3738       (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3739      "cudiv$pack $GRi,$GRj,$GRk,$CCi,$cond"
   3740      (+ pack GRk OP_59 GRi CCi cond OPE4_3 GRj)
   3741      (if (eq CCi (or cond 2))
   3742 	 (sequence ()
   3743 		   (c-call VOID "@cpu@_unsigned_integer_divide"
   3744 			   GRi GRj (index-of GRk) 0)
   3745 		   (clobber GRk)))
   3746      ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
   3747       (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   3748 )
   3749 
   3750 (define-pmacro (conditional-shift name operation op ope comment)
   3751   (dni name
   3752        (comment)
   3753        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3754 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3755        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
   3756        (+ pack GRk op GRi CCi cond ope GRj)
   3757        (if (eq CCi (or cond 2))
   3758 	   (set GRk (operation GRi (and GRj #x1f))))
   3759        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3760 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3761   )
   3762 )
   3763 
   3764 (conditional-shift csll sll OP_5C OPE4_0 "conditional shift left  logical")
   3765 (conditional-shift csrl srl OP_5C OPE4_1 "conditional shift right logical")
   3766 (conditional-shift csra sra OP_5C OPE4_2 "conditional shift right arith")
   3767 
   3768 (dni cscan
   3769      "conditional scan"
   3770      ((UNIT SCAN) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3771       (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3772      "cscan$pack $GRi,$GRj,$GRk,$CCi,$cond"
   3773      (+ pack GRk OP_65 GRi CCi cond OPE4_3 GRj)
   3774      (if (eq CCi (or cond 2))
   3775 	 (scan-semantics GRi GRj GRk))
   3776      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3777       (fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3778 )
   3779 
   3780 ; Format: INT, Logic, Shift, cc r-r
   3781 ;
   3782 (define-pmacro (int-arith-cc-semantics operation icc)
   3783   (sequence ((BI tmp) (QI cc) (SI result))
   3784 	    (set cc icc)
   3785 	    (set tmp ((.sym operation -oflag) GRi GRj (const 0)))
   3786 	    (set-v cc tmp)
   3787 	    (set tmp ((.sym operation -cflag) GRi GRj (const 0)))
   3788 	    (set-c cc tmp)
   3789 	    (set result (operation GRi GRj))
   3790 	    (set-z-and-n cc result)
   3791 	    (set GRk result)
   3792 	    (set icc cc))
   3793 )
   3794 
   3795 (define-pmacro (int-arith-cc-r-r name operation op ope comment)
   3796   (dni name
   3797        (comment)
   3798        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3799 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3800        (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
   3801        (+ pack GRk op GRi ICCi_1 ope GRj)
   3802        (int-arith-cc-semantics operation ICCi_1)
   3803        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3804 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3805   )
   3806 )
   3807 
   3808 (int-arith-cc-r-r addcc add OP_00 OPE2_01 "add reg/reg, set icc")
   3809 (int-arith-cc-r-r subcc sub OP_00 OPE2_05 "sub reg/reg, set icc")
   3810 
   3811 (define-pmacro (int-logic-cc-semantics op icc)
   3812   (sequence ((SI tmp))
   3813 	    (set tmp (op GRi GRj))
   3814 	    (set GRk tmp)
   3815 	    (set-z-and-n icc tmp))
   3816 )
   3817 
   3818 (define-pmacro (int-logic-cc-r-r name op ope comment)
   3819   (dni (.sym name cc)
   3820        (comment)
   3821        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3822 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3823        (.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
   3824        (+ pack GRk op GRi ICCi_1 ope GRj)
   3825        (int-logic-cc-semantics name ICCi_1)
   3826        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3827 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3828   )
   3829 )
   3830 
   3831 (int-logic-cc-r-r and OP_01 OPE2_01 "and reg/reg, set icc")
   3832 (int-logic-cc-r-r or  OP_01 OPE2_03 "or  reg/reg, set icc")
   3833 (int-logic-cc-r-r xor OP_01 OPE2_05 "xor reg/reg, set icc")
   3834 
   3835 (define-pmacro (int-shift-cc-semantics op l-r icc)
   3836   (sequence ((WI shift) (SI tmp) (QI cc))
   3837 	    (set shift (and GRj #x1f))
   3838 	    (set cc (c-call QI (.str "@cpu@_set_icc_for_shift_" l-r)
   3839 			    GRi shift icc))
   3840 	    (set tmp (op GRi shift))
   3841 	    (set GRk tmp)
   3842 	    (set-z-and-n cc tmp)
   3843 	    (set icc cc))
   3844 )
   3845 
   3846 (define-pmacro (int-shift-cc-r-r name l-r op ope comment)
   3847   (dni (.sym name cc)
   3848        (comment)
   3849        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3850 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3851        (.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
   3852        (+ pack GRk op GRi ICCi_1 ope GRj)
   3853        (int-shift-cc-semantics name l-r ICCi_1)
   3854        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3855 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3856   )
   3857 )
   3858 
   3859 (int-shift-cc-r-r sll left  OP_01 OPE2_09 "shift left  logical reg/reg,set icc")
   3860 (int-shift-cc-r-r srl right OP_01 OPE2_0B "shift right logical reg/reg,set icc")
   3861 (int-shift-cc-r-r sra right OP_01 OPE2_0D "shift right arith   reg/reg,set icc")
   3862 
   3863 (define-pmacro (multiply-cc-semantics signop arg1 arg2 targ icc)
   3864   (sequence ((DI tmp) (QI cc))
   3865 	    (set cc icc)
   3866 	    (set tmp (mul DI (signop DI arg1) (signop DI arg2)))
   3867 	    (set-n cc (srl DI tmp 63))
   3868 	    (set-z cc (eq tmp 0))
   3869 	    (set targ tmp)
   3870 	    (set icc cc))
   3871 )
   3872 
   3873 (define-pmacro (multiply-cc-r-r name signop op ope comment)
   3874   (dni name
   3875        (comment)
   3876        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3877 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3878        (.str name "$pack $GRi,$GRj,$GRdoublek,$ICCi_1")
   3879        (+ pack GRdoublek op GRi ICCi_1 ope GRj)
   3880        (multiply-cc-semantics signop GRi GRj GRdoublek ICCi_1)
   3881        ((fr400 (unit u-imul)) (fr450 (unit u-imul))
   3882 	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
   3883   )
   3884 )
   3885 
   3886 (multiply-cc-r-r smulcc ext  OP_00 OPE2_09 "signed   multiply reg/reg")
   3887 (multiply-cc-r-r umulcc zext OP_00 OPE2_0B "unsigned multiply reg/reg")
   3888 
   3889 
   3890 ; Format: conditional INT, Logic, Shift, cc r-r
   3891 ;
   3892 (define-pmacro (conditional-int-arith-cc name operation op ope comment)
   3893   (dni name
   3894        (comment)
   3895        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3896 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3897        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
   3898        (+ pack GRk op GRi CCi cond ope GRj)
   3899        (if (eq CCi (or cond 2))
   3900 	   (int-arith-cc-semantics operation
   3901 				   (reg h-iccr (and (index-of CCi) 3))))
   3902        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3903 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3904   )
   3905 )
   3906 
   3907 (conditional-int-arith-cc caddcc add OP_59 OPE4_0 "add, set icc")
   3908 (conditional-int-arith-cc csubcc sub OP_59 OPE4_1 "sub, set icc")
   3909 
   3910 (dni csmulcc
   3911      "conditional signed multiply and set condition code"
   3912      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   3913       (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3914      "csmulcc$pack $GRi,$GRj,$GRdoublek,$CCi,$cond"
   3915      (+ pack GRdoublek OP_59 GRi CCi cond OPE4_2 GRj)
   3916      (if (eq CCi (or cond 2))
   3917 	 (multiply-cc-semantics ext GRi GRj GRdoublek
   3918 				(reg h-iccr (and (index-of CCi) 3))))
   3919      ((fr400 (unit u-imul)) (fr450 (unit u-imul))
   3920       (fr500 (unit u-imul)) (fr550 (unit u-imul)))
   3921 )
   3922 
   3923 (define-pmacro (conditional-int-logic-cc name operation op ope comment)
   3924   (dni name
   3925        (comment)
   3926        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3927 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3928        (.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
   3929        (+ pack GRk op GRi CCi cond ope GRj)
   3930        (if (eq CCi (or cond 2))
   3931 	   (int-logic-cc-semantics operation
   3932 				   (reg h-iccr (and (index-of CCi) 3))))
   3933        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3934 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3935   )
   3936 )
   3937 
   3938 (conditional-int-logic-cc candcc and OP_5B OPE4_0 "conditional and, set icc")
   3939 (conditional-int-logic-cc corcc  or  OP_5B OPE4_1 "conditional or , set icc")
   3940 (conditional-int-logic-cc cxorcc xor OP_5B OPE4_2 "conditional xor, set icc")
   3941 
   3942 (define-pmacro (conditional-int-shift-cc name l-r op ope comment)
   3943   (dni (.sym c name cc)
   3944        (comment)
   3945        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3946 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   3947        (.str (.sym c name cc) "$pack $GRi,$GRj,$GRk,$CCi,$cond")
   3948        (+ pack GRk op GRi CCi cond ope GRj)
   3949        (if (eq CCi (or cond 2))
   3950 	   (int-shift-cc-semantics name l-r
   3951 				   (reg h-iccr (and (index-of CCi) 3))))
   3952        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3953 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3954   )
   3955 )
   3956 
   3957 (conditional-int-shift-cc sll left  OP_5D OPE4_0 "shift left  logical, set icc")
   3958 (conditional-int-shift-cc srl right OP_5D OPE4_1 "shift right logical, set icc")
   3959 (conditional-int-shift-cc sra right OP_5D OPE4_2 "shift right arith  , set icc")
   3960 
   3961 ; Add and subtract with carry
   3962 ;
   3963 (define-pmacro (int-arith-x-r-r name operation op ope comment)
   3964   (dni name
   3965        (comment)
   3966        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3967 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3968        (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
   3969        (+ pack GRk op GRi ICCi_1 ope GRj)
   3970        (set GRk ((.sym operation c) GRi GRj (cbit ICCi_1)))
   3971        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3972 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3973   )
   3974 )
   3975 
   3976 (int-arith-x-r-r addx add OP_00 OPE2_02 "Add reg/reg, with carry")
   3977 (int-arith-x-r-r subx sub OP_00 OPE2_06 "Sub reg/reg, with carry")
   3978 
   3979 (define-pmacro (int-arith-x-cc-r-r name operation op ope comment)
   3980   (dni name
   3981        (comment)
   3982        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   3983 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   3984        (.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
   3985        (+ pack GRk op GRi ICCi_1 ope GRj)
   3986        (sequence ((WI tmp) (QI cc))
   3987 		 (set cc ICCi_1)
   3988 		 (set tmp ((.sym operation c) GRi GRj (cbit cc)))
   3989 		 (set-v cc ((.sym operation -oflag) GRi GRj (cbit cc)))
   3990 		 (set-c cc ((.sym operation -cflag) GRi GRj (cbit cc)))
   3991 		 (set-z-and-n cc tmp)
   3992 		 (set GRk tmp)
   3993 		 (set ICCi_1 cc))
   3994        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   3995 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   3996   )
   3997 )
   3998 
   3999 (int-arith-x-cc-r-r addxcc add OP_00 OPE2_03 "Add reg/reg, use/set carry")
   4000 (int-arith-x-cc-r-r subxcc sub OP_00 OPE2_07 "Sub reg/reg, use/set carry")
   4001 ; Add and subtract with saturation
   4002 ;
   4003 (define-pmacro (int-arith-ss-r-r name operation op ope comment)
   4004   (dni name
   4005        (comment)
   4006        ((UNIT IALL) (MACH fr400,fr450)
   4007 	(FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
   4008        (.str name "$pack $GRi,$GRj,$GRk")
   4009        (+ pack GRk op GRi ope GRj)
   4010        (sequence ()
   4011 		 (set GRk (operation GRi GRj))
   4012 		 (if ((.sym operation -oflag) GRi GRj (const 0))
   4013 					; Overflow, saturate.
   4014 					; Sign of result will be
   4015 					; same as sign of first operand.
   4016 		     (set GRk
   4017 			  (cond SI
   4018 				((gt GRi 0) (const #x7fffffff))
   4019 				((lt GRi 0) (const #x80000000))
   4020 				(else (const 0)))))
   4021        )
   4022        ((fr400 (unit u-integer)) (fr450 (unit u-integer)))
   4023   )
   4024 )
   4025 
   4026 (int-arith-ss-r-r addss add OP_46 OPE1_00 "add reg/reg, with saturation")
   4027 (int-arith-ss-r-r subss sub OP_46 OPE1_01 "sub reg/reg, with saturation")
   4028 
   4029 ; Format: INT, Logic, Shift r-simm
   4030 ;
   4031 (define-pmacro (int-logic-r-simm name operation op comment)
   4032   (dni name
   4033        (comment)
   4034        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4035 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4036        (.str name "$pack $GRi,$s12,$GRk")
   4037        (+ pack GRk op GRi s12)
   4038        (set GRk (operation GRi s12))
   4039        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4040 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4041   )
   4042 )
   4043 
   4044 (int-logic-r-simm addi  add   OP_10 "add reg/immed")
   4045 (int-logic-r-simm subi  sub   OP_14 "sub reg/immed")
   4046 (int-logic-r-simm andi  and   OP_20 "and reg/immed")
   4047 (int-logic-r-simm ori   or    OP_22 "or  reg/immed")
   4048 (int-logic-r-simm xori  xor   OP_24 "xor reg/immed")
   4049 
   4050 (dni sdivi
   4051      "signed division reg/immed"
   4052      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   4053       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4054      "sdivi$pack $GRi,$s12,$GRk"
   4055      (+ pack GRk OP_1E GRi s12)
   4056      (sequence ()
   4057 	       (c-call VOID "@cpu@_signed_integer_divide"
   4058 		       GRi s12 (index-of GRk) 0)
   4059 	       (clobber GRk))
   4060      ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
   4061       (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   4062 )
   4063 
   4064 (dni nsdivi
   4065      "non excepting signed division reg/immed"
   4066      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
   4067       (MACH simple,tomcat,fr500,fr550,frv))
   4068      "nsdivi$pack $GRi,$s12,$GRk"
   4069      (+ pack GRk OP_2E GRi s12)
   4070      (sequence ()
   4071 	       (c-call VOID "@cpu@_signed_integer_divide"
   4072 		       GRi s12 (index-of GRk) 1)
   4073 	       (clobber GRk))
   4074      ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   4075 )
   4076 
   4077 (dni udivi
   4078      "unsigned division reg/immed"
   4079      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   4080       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4081      "udivi$pack $GRi,$s12,$GRk"
   4082      (+ pack GRk OP_1F GRi s12)
   4083      (sequence ()
   4084 	       (c-call VOID "@cpu@_unsigned_integer_divide"
   4085 		       GRi s12 (index-of GRk) 0)
   4086 	       (clobber GRk))
   4087      ((fr400 (unit u-idiv)) (fr450 (unit u-idiv))
   4088       (fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   4089 )
   4090 
   4091 (dni nudivi
   4092      "non excepting unsigned division reg/immed"
   4093      ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2) NON-EXCEPTING
   4094       (MACH simple,tomcat,fr500,fr550,frv))
   4095      "nudivi$pack $GRi,$s12,$GRk"
   4096      (+ pack GRk OP_2F GRi s12)
   4097      (sequence ()
   4098 	       (c-call VOID "@cpu@_unsigned_integer_divide"
   4099 		       GRi s12 (index-of GRk) 1)
   4100 	       (clobber GRk))
   4101      ((fr500 (unit u-idiv)) (fr550 (unit u-idiv)))
   4102 )
   4103 
   4104 (define-pmacro (multiply-r-simm name signop op comment)
   4105   (dni name
   4106        (comment)
   4107        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   4108 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4109        (.str name "$pack $GRi,$s12,$GRdoublek")
   4110        (+ pack GRdoublek op GRi s12)
   4111        (set GRdoublek (mul DI (signop DI GRi) (signop DI s12)))
   4112        ((fr400 (unit u-imul)) (fr450 (unit u-imul))
   4113 	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
   4114   )
   4115 )
   4116 
   4117 (multiply-r-simm smuli ext  OP_18 "signed   multiply reg/immed")
   4118 (multiply-r-simm umuli zext OP_1A "unsigned multiply reg/immed")
   4119 
   4120 (define-pmacro (int-shift-r-simm name op comment)
   4121   (dni (.sym name i)
   4122        (comment)
   4123        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4124 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4125        (.str (.sym name i) "$pack $GRi,$s12,$GRk")
   4126        (+ pack GRk op GRi s12)
   4127        (set GRk (name GRi (and s12 #x1f)))
   4128        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4129 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4130   )
   4131 )
   4132 
   4133 (int-shift-r-simm sll OP_28 "shift left  logical reg/immed")
   4134 (int-shift-r-simm srl OP_2A "shift right logical reg/immed")
   4135 (int-shift-r-simm sra OP_2C "shift right arith   reg/immed")
   4136 
   4137 (dni scani
   4138      "scan immediate"
   4139      ((UNIT SCAN) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4140       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4141      "scani$pack $GRi,$s12,$GRk"
   4142      (+ pack GRk OP_47 GRi s12)
   4143      (scan-semantics GRi s12 GRk)
   4144      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4145       (fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4146 )
   4147 
   4148 ; Format: INT, Logic, Shift cc r-simm
   4149 ;
   4150 (define-pmacro (int-arith-cc-r-simm name operation op comment)
   4151   (dni name
   4152        (comment)
   4153        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4154 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4155        (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
   4156        (+ pack GRk op GRi ICCi_1 s10)
   4157        (sequence ((BI tmp) (QI cc) (SI result))
   4158 		 (set cc ICCi_1)
   4159 		 (set tmp ((.sym operation -oflag) GRi s10 (const 0)))
   4160 		 (set-v cc tmp)
   4161 		 (set tmp ((.sym operation -cflag) GRi s10 (const 0)))
   4162 		 (set-c cc tmp)
   4163 		 (set result (operation GRi s10))
   4164 		 (set-z-and-n cc result)
   4165 		 (set GRk result)
   4166 		 (set ICCi_1 cc))
   4167        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4168 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4169   )
   4170 )
   4171 
   4172 (int-arith-cc-r-simm addicc add OP_11 "add reg/immed, set icc")
   4173 (int-arith-cc-r-simm subicc sub OP_15 "sub reg/immed, set icc")
   4174 
   4175 (define-pmacro (int-logic-cc-r-simm name op comment)
   4176   (dni (.sym name icc)
   4177        (comment)
   4178        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4179 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4180        (.str (.sym name icc) "$pack $GRi,$s10,$GRk,$ICCi_1")
   4181        (+ pack GRk op GRi ICCi_1 s10)
   4182        (sequence ((SI tmp))
   4183 		 (set tmp (name GRi s10))
   4184 		 (set GRk tmp)
   4185 		 (set-z-and-n ICCi_1 tmp))
   4186        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4187 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4188   )
   4189 )
   4190 
   4191 (int-logic-cc-r-simm and  OP_21 "and reg/immed, set icc")
   4192 (int-logic-cc-r-simm or   OP_23 "or  reg/immed, set icc")
   4193 (int-logic-cc-r-simm xor  OP_25 "xor reg/immed, set icc")
   4194 
   4195 (define-pmacro (multiply-cc-r-simm name signop op comment)
   4196   (dni name
   4197        (comment)
   4198        ((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
   4199 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4200        (.str name "$pack $GRi,$s10,$GRdoublek,$ICCi_1")
   4201        (+ pack GRdoublek op GRi ICCi_1 s10)
   4202        (multiply-cc-semantics signop GRi s10 GRdoublek ICCi_1)
   4203        ((fr400 (unit u-imul)) (fr450 (unit u-imul))
   4204 	(fr500 (unit u-imul)) (fr550 (unit u-imul)))
   4205   )
   4206 )
   4207 
   4208 (multiply-cc-r-simm smulicc ext  OP_19 "signed   multiply reg/immed")
   4209 (multiply-cc-r-simm umulicc zext OP_1B "unsigned multiply reg/immed")
   4210 
   4211 (define-pmacro (int-shift-cc-r-simm name l-r op comment)
   4212   (dni (.sym name icc)
   4213        (comment)
   4214        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4215 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4216        (.str (.sym name icc) "$pack $GRi,$s10,$GRk,$ICCi_1")
   4217        (+ pack GRk op GRi ICCi_1 s10)
   4218        (sequence ((WI shift) (SI tmp) (QI cc))
   4219 		 (set shift (and s10 #x1f))
   4220 		 (set cc (c-call QI (.str "@cpu@_set_icc_for_shift_" l-r)
   4221 				 GRi shift ICCi_1))
   4222 		 (set tmp (name GRi shift))
   4223 		 (set GRk tmp)
   4224 		 (set-z-and-n cc tmp)
   4225 		 (set ICCi_1 cc))
   4226        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4227 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4228   )
   4229 )
   4230 
   4231 (int-shift-cc-r-simm sll left  OP_29 "shift left  logical reg/immed, set icc")
   4232 (int-shift-cc-r-simm srl right OP_2B "shift right logical reg/immed, set icc")
   4233 (int-shift-cc-r-simm sra right OP_2D "shift right arith   reg/immed, set icc")
   4234 
   4235 (define-pmacro (int-arith-x-r-simm name operation op comment)
   4236   (dni name
   4237        (comment)
   4238        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4239 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4240        (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
   4241        (+ pack GRk op GRi ICCi_1 s10)
   4242        (set GRk ((.sym operation c) GRi s10 (cbit ICCi_1)))
   4243        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4244 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4245   )
   4246 )
   4247 
   4248 (int-arith-x-r-simm addxi add OP_12 "Add reg/immed, with carry")
   4249 (int-arith-x-r-simm subxi sub OP_16 "Sub reg/immed, with carry")
   4250 
   4251 (define-pmacro (int-arith-x-cc-r-simm name operation op comment)
   4252   (dni name
   4253        (comment)
   4254        ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4255 	(FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4256        (.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
   4257        (+ pack GRk op GRi ICCi_1 s10)
   4258        (sequence ((WI tmp) (QI cc))
   4259 		 (set cc ICCi_1)
   4260 		 (set tmp ((.sym operation c) GRi s10 (cbit cc)))
   4261 		 (set-v cc ((.sym operation -oflag) GRi s10 (cbit cc)))
   4262 		 (set-c cc ((.sym operation -cflag) GRi s10 (cbit cc)))
   4263 		 (set-z-and-n cc tmp)
   4264 		 (set GRk tmp)
   4265 		 (set ICCi_1 cc))
   4266        ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4267 	(fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4268   )
   4269 )
   4270 
   4271 (int-arith-x-cc-r-simm addxicc add OP_13 "Add reg/immed, with carry")
   4272 (int-arith-x-cc-r-simm subxicc sub OP_17 "Sub reg/immed, with carry")
   4273 
   4274 ; Byte compare insns
   4275 
   4276 (dni cmpb
   4277      "Compare bytes"
   4278      ((UNIT IALL) (MACH fr400,fr450,fr550) (FR550-MAJOR I-1)
   4279       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4280      "cmpb$pack $GRi,$GRj,$ICCi_1"
   4281      (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0C GRj)
   4282      (sequence ((QI cc))
   4283 	       (set cc 0)
   4284 	       (set-n cc (eq (and GRi #xff000000) (and GRj #xff000000)))
   4285 	       (set-z cc (eq (and GRi #x00ff0000) (and GRj #x00ff0000)))
   4286 	       (set-v cc (eq (and GRi #x0000ff00) (and GRj #x0000ff00)))
   4287 	       (set-c cc (eq (and GRi #x000000ff) (and GRj #x000000ff)))
   4288 	       (set ICCi_1 cc))
   4289      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4290       (fr550 (unit u-integer)))
   4291 )
   4292 
   4293 (dni cmpba
   4294      "OR of Compare bytes"
   4295      ((UNIT IALL) (MACH fr400,fr450,fr550) (FR550-MAJOR I-1)
   4296       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4297      "cmpba$pack $GRi,$GRj,$ICCi_1"
   4298      (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0D GRj)
   4299      (sequence ((QI cc))
   4300 	       (set cc 0)
   4301 	       (set-c cc
   4302 		      (orif (eq (and GRi #xff000000) (and GRj #xff000000))
   4303 			    (orif (eq (and GRi #x00ff0000) (and GRj #x00ff0000))
   4304 				  (orif (eq (and GRi #x0000ff00)
   4305 					    (and GRj #x0000ff00))
   4306 					 (eq (and GRi #x000000ff)
   4307 					    (and GRj #x000000ff))))))
   4308 	       (set ICCi_1 cc))
   4309      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4310       (fr550 (unit u-integer)))
   4311 )
   4312 
   4313 ; Format: Load immediate
   4314 ;
   4315 (dni setlo
   4316      "set low order bits"
   4317      ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4318       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4319      "setlo$pack $ulo16,$GRklo"
   4320      (+ pack GRk OP_3D (misc-null-4) u16)
   4321      (set GRklo u16)
   4322      ((fr400 (unit u-set-hilo)) (fr450 (unit u-set-hilo))
   4323       (fr500 (unit u-set-hilo)) (fr550 (unit u-set-hilo)))
   4324 )
   4325 
   4326 (dni sethi
   4327      "set high order bits"
   4328      ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4329       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4330      "sethi$pack $uhi16,$GRkhi"
   4331      (+ pack GRkhi OP_3E (misc-null-4) u16)
   4332      (set GRkhi u16)
   4333      ((fr400 (unit u-set-hilo)) (fr450 (unit u-set-hilo))
   4334       (fr500 (unit u-set-hilo)) (fr550 (unit u-set-hilo)))
   4335 )
   4336 
   4337 (dni setlos
   4338      "set low order bits and extend sign"
   4339      ((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
   4340       (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   4341      "setlos$pack $slo16,$GRk"
   4342      (+ pack GRk OP_3F (misc-null-4) s16)
   4343      (set GRk s16)
   4344      ((fr400 (unit u-integer)) (fr450 (unit u-integer))
   4345       (fr500 (unit u-integer)) (fr550 (unit u-integer)))
   4346 )
   4347 
   4348 (define-pmacro (load-gr-r name mode op ope comment ann)
   4349   (dni name
   4350        (comment)
   4351        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4352 	(FR400-MAJOR I-2) (FR450-MAJOR I-2))
   4353        (.str name "$pack " ann "($GRi,$GRj),$GRk")
   4354        (+ pack GRk op GRi ope GRj)
   4355        (set GRk (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
   4356        ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4357 	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4358   )
   4359 )
   4360 
   4361 (dann ldann "ld annotation" SI "ld_annotation" "at")
   4362 
   4363 (load-gr-r ldsb   QI OP_02 OPE1_00 "Load   signed byte" "@")
   4364 (load-gr-r ldub  UQI OP_02 OPE1_01 "Load unsigned byte" "@")
   4365 (load-gr-r ldsh   HI OP_02 OPE1_02 "Load   signed half" "@")
   4366 (load-gr-r lduh  UHI OP_02 OPE1_03 "Load unsigned half" "@")
   4367 (load-gr-r ld     SI OP_02 OPE1_04 "Load          word" "$ldann")
   4368 
   4369 (define-pmacro (load-fr-r name mode op ope comment)
   4370   (dni name
   4371        (comment)
   4372        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4373 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) FR-ACCESS)
   4374        (.str name "$pack @($GRi,$GRj),$FRintk")
   4375        (+ pack FRintk op GRi ope GRj)
   4376        (set FRintk (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
   4377        ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4378 	(fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4379   )
   4380 )
   4381 
   4382 (load-fr-r ldbf UQI OP_02 OPE1_08 "Load byte   float")
   4383 (load-fr-r ldhf UHI OP_02 OPE1_09 "Load half   float")
   4384 (load-fr-r ldf   SI OP_02 OPE1_0A "Load word   float")
   4385 
   4386 (define-pmacro (load-cpr-r name mode op ope reg attr comment)
   4387   (dni name
   4388        (comment)
   4389        ((UNIT LOAD) (FR500-MAJOR I-2) attr)
   4390        (.str name "$pack @($GRi,$GRj),$" reg "k")
   4391        (+ pack (.sym reg k) op GRi ope GRj)
   4392        (set (.sym reg k)
   4393 	    (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj)))
   4394        ()
   4395   )
   4396 )
   4397 
   4398 (load-cpr-r ldc SI OP_02 OPE1_0D CPR (MACH frv) "Load coprocessor word")
   4399 
   4400 ; These correspond to enumerators in frv-sim.h
   4401 (define-pmacro (ne-UQI-size) 0)
   4402 (define-pmacro (ne-QI-size)  1)
   4403 (define-pmacro (ne-UHI-size) 2)
   4404 (define-pmacro (ne-HI-size)  3)
   4405 (define-pmacro (ne-SI-size)  4)
   4406 (define-pmacro (ne-DI-size)  5)
   4407 (define-pmacro (ne-XI-size)  6)
   4408 
   4409 (define-pmacro (ne-load-semantics base dispix targ idisp size is_float action)
   4410   (sequence ((BI do_op))
   4411 	    (set do_op
   4412 		 (c-call BI "@cpu@_check_non_excepting_load"
   4413 			  (index-of base) dispix (index-of targ)
   4414 			  idisp size is_float))
   4415 	    (if do_op action))
   4416 )
   4417 
   4418 (define-pmacro (ne-load-gr-r name mode op ope size comment)
   4419   (dni name
   4420        (comment)
   4421        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING
   4422 	(MACH simple,tomcat,fr500,fr550,frv))
   4423        (.str name "$pack @($GRi,$GRj),$GRk")
   4424        (+ pack GRk op GRi ope GRj)
   4425        (ne-load-semantics GRi (index-of GRj) GRk 0 size 0
   4426 			  (set GRk
   4427 			       (c-call mode (.str "@cpu@_read_mem_" mode)
   4428 				       pc (add GRi GRj))))
   4429        ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4430   )
   4431 )
   4432 
   4433 (ne-load-gr-r nldsb  QI OP_02 OPE1_20 (ne-QI-size)  "Load   signed byte")
   4434 (ne-load-gr-r nldub UQI OP_02 OPE1_21 (ne-UQI-size) "Load unsigned byte")
   4435 (ne-load-gr-r nldsh  HI OP_02 OPE1_22 (ne-HI-size)  "Load   signed half")
   4436 (ne-load-gr-r nlduh UHI OP_02 OPE1_23 (ne-UHI-size) "Load unsigned half")
   4437 (ne-load-gr-r nld    SI OP_02 OPE1_24 (ne-SI-size)  "Load          word")
   4438 
   4439 (define-pmacro (ne-load-fr-r name mode op ope size comment)
   4440   (dni name
   4441        (comment)
   4442        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
   4443 	(MACH simple,tomcat,fr500,fr550,frv))
   4444        (.str name "$pack @($GRi,$GRj),$FRintk")
   4445        (+ pack FRintk op GRi ope GRj)
   4446        (ne-load-semantics GRi (index-of GRj) FRintk 0 size 1
   4447 			  (set FRintk
   4448 			       (c-call mode (.str "@cpu@_read_mem_" mode)
   4449 				       pc (add GRi GRj))))
   4450        ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4451   )
   4452 )
   4453 
   4454 (ne-load-fr-r nldbf UQI OP_02 OPE1_28 (ne-UQI-size) "Load byte float")
   4455 (ne-load-fr-r nldhf UHI OP_02 OPE1_29 (ne-UHI-size) "Load half float")
   4456 (ne-load-fr-r nldf   SI OP_02 OPE1_2A (ne-SI-size)  "Load word float")
   4457 
   4458 ; Semantics for a load-double insn
   4459 ;
   4460 (define-pmacro (load-double-semantics not_gr mode regtype address arg)
   4461   (if (orif not_gr (ne (index-of (.sym regtype doublek)) 0))
   4462       (sequence ()
   4463 		(set address (add GRi arg))
   4464 		(set (.sym regtype doublek)
   4465 		     (c-call mode (.str "@cpu@_read_mem_" mode) pc address))))
   4466 )
   4467 
   4468 (define-pmacro (load-double-r-r
   4469 		name not_gr mode op ope regtype attr profile comment ann)
   4470   (dni name
   4471        (comment)
   4472        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4473 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
   4474        (.str name "$pack " ann "($GRi,$GRj),$" regtype "doublek")
   4475        (+ pack (.sym regtype doublek) op GRi ope GRj)
   4476        (sequence ((WI address))
   4477 		 (load-double-semantics not_gr mode regtype address GRj))
   4478        profile
   4479   )
   4480 )
   4481 
   4482 (dann lddann "ldd annotation" SI "ldd_annotation" "at")
   4483 
   4484 (load-double-r-r ldd  0 DI OP_02 OPE1_05 GR  NA
   4485 		 ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load)) 
   4486 		  (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4487 		 "Load double word" "$lddann")
   4488 (load-double-r-r lddf 1 DF OP_02 OPE1_0B FR  FR-ACCESS
   4489 		 ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4490 		  (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4491 		 "Load double float" "@")
   4492 (load-double-r-r lddc 1 DI OP_02 OPE1_0E CPR (MACH frv) ()
   4493 		 "Load coprocessor double" "@")
   4494 
   4495 (define-pmacro (ne-load-double-r-r
   4496 		name not_gr mode op ope regtype size is_float attr profile
   4497 		comment)
   4498   (dni name
   4499        (comment)
   4500        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING attr
   4501 	(MACH simple,tomcat,fr500,fr550,frv))
   4502        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
   4503        (+ pack (.sym regtype doublek) op GRi ope GRj)
   4504        (sequence ((WI address))
   4505 		 (ne-load-semantics GRi (index-of GRj) (.sym regtype doublek)
   4506 				    0 size is_float
   4507 				    (load-double-semantics not_gr mode
   4508 							   regtype
   4509 							   address GRj)))
   4510        profile
   4511   )
   4512 )
   4513 
   4514 (ne-load-double-r-r nldd  0 DI OP_02 OPE1_25 GR (ne-DI-size) 0 NA
   4515 		    ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load double   word")
   4516 (ne-load-double-r-r nlddf 1 DF OP_02 OPE1_2B FR (ne-DI-size) 1 FR-ACCESS
   4517 		    ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load double float")
   4518 
   4519 ; Semantics for a load-quad insn
   4520 ;
   4521 (define-pmacro (load-quad-semantics regtype address arg)
   4522   (sequence ()
   4523 	    (set address (add GRi arg))
   4524 	    (c-call VOID (.str "@cpu@_load_quad_" regtype)
   4525 		    pc address (index-of (.sym regtype k))))
   4526 )
   4527 
   4528 (define-pmacro (load-quad-r-r name op ope regtype attr profile comment)
   4529   (dni name
   4530        (comment)
   4531        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
   4532        (.str name "$pack @($GRi,$GRj),$" regtype "k")
   4533        (+ pack (.sym regtype k) op GRi ope GRj)
   4534        (sequence ((WI address))
   4535 		 (load-quad-semantics regtype address GRj))
   4536        ; TODO regtype-k not referenced for profiling
   4537        profile
   4538   )
   4539 )
   4540 
   4541 (load-quad-r-r ldq  OP_02 OPE1_06 GR    NA        ((fr500 (unit u-gr-load)))
   4542 	       "Load quad word")
   4543 (load-quad-r-r ldqf OP_02 OPE1_0C FRint FR-ACCESS ((fr500 (unit u-fr-load)))
   4544 	       "Load quad float")
   4545 (load-quad-r-r ldqc OP_02 OPE1_0F CPR   NA        () "Load coprocessor quad")
   4546 
   4547 (define-pmacro (ne-load-quad-r-r
   4548 		name op ope regtype size is_float attr profile comment)
   4549   (dni name
   4550        (comment)
   4551        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING attr)
   4552        (.str name "$pack @($GRi,$GRj),$" regtype "k")
   4553        (+ pack (.sym regtype k) op GRi ope GRj)
   4554        (sequence ((WI address))
   4555 		 (ne-load-semantics GRi (index-of GRj) (.sym regtype k)
   4556 				    0 size is_float
   4557 				    (load-quad-semantics regtype address GRj)))
   4558        ; TODO regtype-k not referenced for profiling
   4559        profile
   4560   )
   4561 )
   4562 
   4563 (ne-load-quad-r-r nldq  OP_02 OPE1_26 GR    (ne-XI-size) 0 NA
   4564 		  ((fr500 (unit u-gr-load))) "Load quad word")
   4565 (ne-load-quad-r-r nldqf OP_02 OPE1_2C FRint (ne-XI-size) 1 FR-ACCESS
   4566 		  ((fr500 (unit u-fr-load))) "Load quad float")
   4567 
   4568 (define-pmacro (load-gr-u-semantics mode)
   4569   (sequence ((UWI address))
   4570 	    (set address (add GRi GRj))
   4571 	    (set GRk (c-call mode (.str "@cpu@_read_mem_" mode) pc address))
   4572 	    (if (ne (index-of GRi) (index-of GRk))
   4573 		(sequence ()
   4574 			  (set GRi address)
   4575 			  (c-call VOID "@cpu@_force_update"))))
   4576 )
   4577 
   4578 (define-pmacro (load-gr-u name mode op ope comment)
   4579   (dni name
   4580        (comment)
   4581        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4582 	(FR400-MAJOR I-2) (FR450-MAJOR I-2))
   4583        (.str name "$pack @($GRi,$GRj),$GRk")
   4584        (+ pack GRk op GRi ope GRj)
   4585        (load-gr-u-semantics mode)
   4586        ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4587 	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4588   )
   4589 )
   4590 
   4591 (load-gr-u ldsbu   QI OP_02 OPE1_10 "Load   signed byte, update index")
   4592 (load-gr-u ldubu  UQI OP_02 OPE1_11 "Load unsigned byte, update index")
   4593 (load-gr-u ldshu   HI OP_02 OPE1_12 "Load   signed half, update index")
   4594 (load-gr-u lduhu  UHI OP_02 OPE1_13 "Load unsigned half, update index")
   4595 (load-gr-u ldu     SI OP_02 OPE1_14 "Load          word, update index")
   4596 
   4597 (define-pmacro (ne-load-gr-u name mode op ope size comment)
   4598   (dni name
   4599        (comment)
   4600        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING
   4601 	(MACH simple,tomcat,fr500,fr550,frv))
   4602        (.str name "$pack @($GRi,$GRj),$GRk")
   4603        (+ pack GRk op GRi ope GRj)
   4604        (ne-load-semantics GRi (index-of GRj) GRk 0 size 0 (load-gr-u-semantics mode))
   4605        ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4606   )
   4607 )
   4608 
   4609 (ne-load-gr-u nldsbu  QI OP_02 OPE1_30 (ne-QI-size)  "Load   signed byte, update index")
   4610 (ne-load-gr-u nldubu UQI OP_02 OPE1_31 (ne-UQI-size) "Load unsigned byte, update index")
   4611 (ne-load-gr-u nldshu  HI OP_02 OPE1_32 (ne-HI-size)  "Load   signed half, update index")
   4612 (ne-load-gr-u nlduhu UHI OP_02 OPE1_33 (ne-UHI-size) "Load unsigned half, update index")
   4613 (ne-load-gr-u nldu    SI OP_02 OPE1_34 (ne-SI-size)  "Load          word, update index")
   4614 
   4615 (define-pmacro (load-non-gr-u-semantics mode regtype)
   4616   (sequence ((UWI address))
   4617 	    (set address (add GRi GRj))
   4618 	    (set (.sym regtype k)
   4619 		 (c-call mode (.str "@cpu@_read_mem_" mode) pc address))
   4620 	    (set GRi address)
   4621 	    (c-call VOID "@cpu@_force_update"))
   4622 )
   4623 
   4624 (define-pmacro (load-fr-u name mode op ope comment)
   4625   (dni name
   4626        (comment)
   4627        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4628 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) FR-ACCESS)
   4629        (.str name "$pack @($GRi,$GRj),$FRintk")
   4630        (+ pack FRintk op GRi ope GRj)
   4631        (load-non-gr-u-semantics mode FRint)
   4632        ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4633 	(fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4634   )
   4635 )
   4636 
   4637 (load-fr-u ldbfu  UQI OP_02 OPE1_18 "Load byte float, update index")
   4638 (load-fr-u ldhfu  UHI OP_02 OPE1_19 "Load half float, update index")
   4639 (load-fr-u ldfu    SI OP_02 OPE1_1A "Load word float, update index")
   4640 
   4641 (define-pmacro (load-cpr-u name mode op ope comment)
   4642   (dni name
   4643        (comment)
   4644        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
   4645        (.str name "$pack @($GRi,$GRj),$CPRk")
   4646        (+ pack CPRk op GRi ope GRj)
   4647        (load-non-gr-u-semantics mode CPR)
   4648        ()
   4649   )
   4650 )
   4651 
   4652 (load-cpr-u ldcu SI OP_02 OPE1_1D "Load coprocessor word float,update index")
   4653 
   4654 (define-pmacro (ne-load-non-gr-u name mode op ope regtype size comment)
   4655   (dni name
   4656        (comment)
   4657        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
   4658 	(MACH simple,tomcat,fr500,fr550,frv))
   4659        (.str name "$pack @($GRi,$GRj),$" regtype "k")
   4660        (+ pack (.sym regtype k) op GRi ope GRj)
   4661        (ne-load-semantics GRi (index-of GRj) (.sym regtype k) 0 size 1
   4662 			  (load-non-gr-u-semantics mode regtype))
   4663        ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4664   )
   4665 )
   4666 
   4667 (ne-load-non-gr-u nldbfu UQI OP_02 OPE1_38 FRint (ne-UQI-size) "Load byte float, update index")
   4668 (ne-load-non-gr-u nldhfu UHI OP_02 OPE1_39 FRint (ne-UHI-size) "Load half float, update index")
   4669 (ne-load-non-gr-u nldfu   SI OP_02 OPE1_3A FRint (ne-SI-size)  "Load word float, update index")
   4670 
   4671 (define-pmacro (load-double-gr-u-semantics)
   4672   (sequence ((WI address))
   4673 	    (load-double-semantics 0 DI GR address GRj)
   4674 	    (if (ne (index-of GRi) (index-of GRdoublek))
   4675 		(sequence ()
   4676 			  (set GRi address)
   4677 			  (c-call VOID "@cpu@_force_update"))))
   4678 )
   4679 
   4680 (define-pmacro (load-double-gr-u name op ope comment)
   4681   (dni name
   4682        (comment)
   4683        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4684 	(FR400-MAJOR I-2) (FR450-MAJOR I-2))
   4685        (.str name "$pack @($GRi,$GRj),$GRdoublek")
   4686        (+ pack GRdoublek op GRi ope GRj)
   4687        (load-double-gr-u-semantics)
   4688        ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4689 	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4690   )
   4691 )
   4692 
   4693 (load-double-gr-u lddu  OP_02 OPE1_15 "Load double word, update index")
   4694 
   4695 (define-pmacro (ne-load-double-gr-u name op ope size comment)
   4696   (dni name
   4697        (comment)
   4698        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING
   4699 	(MACH simple,tomcat,fr500,fr550,frv))
   4700        (.str name "$pack @($GRi,$GRj),$GRdoublek")
   4701        (+ pack GRdoublek op GRi ope GRj)
   4702        (ne-load-semantics GRi (index-of GRj) GRdoublek 0 size 0
   4703 			  (load-double-gr-u-semantics))
   4704        ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4705 
   4706   )
   4707 )
   4708 
   4709 (ne-load-double-gr-u nlddu OP_02 OPE1_35 (ne-DI-size) "Load double word, update index")
   4710 
   4711 (define-pmacro (load-double-non-gr-u-semantics mode regtype)
   4712   (sequence ((WI address))
   4713 	    (load-double-semantics 1 mode regtype address GRj)
   4714 	    (set GRi address)
   4715 	    (c-call VOID "@cpu@_force_update"))
   4716 )
   4717 
   4718 (define-pmacro (load-double-non-gr-u
   4719 		name mode op ope regtype attr profile comment)
   4720   (dni name
   4721        (comment)
   4722        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4723 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
   4724        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
   4725        (+ pack (.sym regtype doublek) op GRi ope GRj)
   4726        (load-double-non-gr-u-semantics mode regtype)
   4727        profile
   4728   )
   4729 )
   4730 
   4731 (load-double-non-gr-u lddfu DF OP_02 OPE1_1B FR  FR-ACCESS
   4732 		      ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4733 		       (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4734 		      "Load double float, update index")
   4735 (load-double-non-gr-u lddcu DI OP_02 OPE1_1E CPR (MACH frv)
   4736 		      () "Load coprocessor double float, update index")
   4737 
   4738 (define-pmacro (ne-load-double-non-gr-u name mode op ope regtype size comment)
   4739   (dni name
   4740        (comment)
   4741        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING FR-ACCESS
   4742 	(MACH simple,tomcat,fr500,fr550,frv))
   4743        (.str name "$pack @($GRi,$GRj),$" regtype "doublek")
   4744        (+ pack (.sym regtype doublek) op GRi ope GRj)
   4745        (ne-load-semantics GRi (index-of GRj) (.sym regtype doublek) 0 size 1
   4746 			  (load-double-non-gr-u-semantics mode regtype))
   4747        ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4748   )
   4749 )
   4750 
   4751 (ne-load-double-non-gr-u nlddfu DF OP_02 OPE1_3B FR (ne-DI-size) "Load double float, update index")
   4752 
   4753 (define-pmacro (load-quad-gr-u-semantics)
   4754   (sequence ((WI address))
   4755 	    (load-quad-semantics GR address GRj)
   4756 	    (if (ne (index-of GRi) (index-of GRk))
   4757 		(sequence ()
   4758 			  (set GRi address)
   4759 			  (c-call VOID "@cpu@_force_update"))))
   4760 )
   4761 
   4762 (define-pmacro (load-quad-gr-u name op ope comment)
   4763   (dni name
   4764        (comment)
   4765        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
   4766        (.str name "$pack @($GRi,$GRj),$GRk")
   4767        (+ pack GRk op GRi ope GRj)
   4768        (load-quad-gr-u-semantics)
   4769        ; TODO - GRk not referenced here for profiling
   4770        ((fr500 (unit u-gr-load)))
   4771   )
   4772 )
   4773 
   4774 (load-quad-gr-u ldqu  OP_02 OPE1_16 "Load quad word, update index")
   4775 
   4776 (define-pmacro (ne-load-quad-gr-u name op ope size comment)
   4777   (dni name
   4778        (comment)
   4779        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING)
   4780        (.str name "$pack @($GRi,$GRj),$GRk")
   4781        (+ pack GRk op GRi ope GRj)
   4782        (ne-load-semantics GRi (index-of GRj) GRk 0 size 0
   4783 			  (load-quad-gr-u-semantics))
   4784        ; TODO - GRk not referenced here for profiling
   4785        ((fr500 (unit u-gr-load)))
   4786   )
   4787 )
   4788 
   4789 (ne-load-quad-gr-u nldqu OP_02 OPE1_36 (ne-XI-size) "Load quad word, update index")
   4790 
   4791 (define-pmacro (load-quad-non-gr-u-semantics regtype)
   4792   (sequence ((WI address))
   4793 	    (load-quad-semantics regtype address GRj)
   4794 	    (set GRi address)
   4795 	    (c-call VOID "@cpu@_force_update"))
   4796 )
   4797 
   4798 (define-pmacro (load-quad-non-gr-u name op ope regtype attr profile comment)
   4799   (dni name
   4800        (comment)
   4801        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
   4802        (.str name "$pack @($GRi,$GRj),$" regtype "k")
   4803        (+ pack (.sym regtype k) op GRi ope GRj)
   4804        (load-quad-non-gr-u-semantics regtype)
   4805        profile
   4806   )
   4807 )
   4808 
   4809 (load-quad-non-gr-u ldqfu OP_02 OPE1_1C FRint FR-ACCESS
   4810 		    ((fr500 (unit u-fr-load))) "Load quad float, update index")
   4811 (load-quad-non-gr-u ldqcu OP_02 OPE1_1F CPR   NA
   4812 		    () "Load coprocessor quad word, update index")
   4813 
   4814 (define-pmacro (ne-load-quad-non-gr-u name op ope regtype size comment)
   4815   (dni name
   4816        (comment)
   4817        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING FR-ACCESS)
   4818        (.str name "$pack @($GRi,$GRj),$" regtype "k")
   4819        (+ pack (.sym regtype k) op GRi ope GRj)
   4820        (ne-load-semantics GRi (index-of GRj) (.sym regtype k) 0 size 1
   4821 			  (load-quad-non-gr-u-semantics regtype))
   4822        ((fr500 (unit u-fr-load)))
   4823   )
   4824 )
   4825 
   4826 (ne-load-quad-non-gr-u nldqfu OP_02 OPE1_3C FRint (ne-XI-size) "Load quad float,update index")
   4827 
   4828 (define-pmacro (load-r-simm name mode op regtype attr profile comment)
   4829   (dni name
   4830        (comment)
   4831        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4832 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
   4833        (.str name "$pack @($GRi,$d12),$" regtype "k")
   4834        (+ pack (.sym regtype k) op GRi d12)
   4835        (set (.sym regtype k)
   4836 	    (c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi d12)))
   4837        profile
   4838   )
   4839 )
   4840 
   4841 (load-r-simm ldsbi  QI OP_30 GR NA
   4842 	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4843 	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4844 	     "Load   signed byte")
   4845 (load-r-simm ldshi  HI OP_31 GR NA
   4846 	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4847 	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4848 	     "Load   signed half")
   4849 (load-r-simm ldi    SI OP_32 GR NA
   4850 	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4851 	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4852 	     "Load          word")
   4853 (load-r-simm ldubi UQI OP_35 GR NA
   4854 	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4855 	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4856 	     "Load unsigned byte")
   4857 (load-r-simm lduhi UHI OP_36 GR NA
   4858 	     ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4859 	      (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4860 	     "Load unsigned half")
   4861 
   4862 (load-r-simm ldbfi UQI OP_38 FRint FR-ACCESS
   4863 	     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4864 	      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4865 	     "Load byte float")
   4866 (load-r-simm ldhfi UHI OP_39 FRint FR-ACCESS
   4867 	     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4868 	      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4869 	     "Load half float")
   4870 (load-r-simm ldfi   SI OP_3A FRint FR-ACCESS
   4871 	     ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4872 	      (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4873 	     "Load word float")
   4874 
   4875 (define-pmacro (ne-load-r-simm
   4876 		name mode op regtype size is_float attr profile comment)
   4877   (dni name
   4878        (comment)
   4879        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING attr
   4880 	(MACH simple,tomcat,fr500,fr550,frv))
   4881        (.str name "$pack @($GRi,$d12),$" regtype "k")
   4882        (+ pack (.sym regtype k) op GRi d12)
   4883        (ne-load-semantics GRi -1 (.sym regtype k) d12 size is_float
   4884 			  (set (.sym regtype k)
   4885 			       (c-call mode (.str "@cpu@_read_mem_" mode)
   4886 				       pc (add GRi d12))))
   4887        profile
   4888   )
   4889 )
   4890 
   4891 (ne-load-r-simm nldsbi  QI OP_40 GR (ne-QI-size)  0 NA
   4892 		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load   signed byte")
   4893 (ne-load-r-simm nldubi UQI OP_41 GR (ne-UQI-size) 0 NA
   4894 		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load unsigned byte")
   4895 (ne-load-r-simm nldshi  HI OP_42 GR (ne-HI-size)  0 NA
   4896 		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load   signed half")
   4897 (ne-load-r-simm nlduhi UHI OP_43 GR (ne-UHI-size) 0 NA
   4898 		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load unsigned half")
   4899 (ne-load-r-simm nldi    SI OP_44 GR (ne-SI-size)  0 NA
   4900 		((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load          word")
   4901 
   4902 (ne-load-r-simm nldbfi UQI OP_48 FRint (ne-UQI-size) 1 FR-ACCESS
   4903 		((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load byte float")
   4904 (ne-load-r-simm nldhfi UHI OP_49 FRint (ne-UHI-size) 1 FR-ACCESS
   4905 		((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load half float")
   4906 (ne-load-r-simm nldfi   SI OP_4A FRint (ne-SI-size)  1 FR-ACCESS
   4907 		((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load word float")
   4908 
   4909 (define-pmacro (load-double-r-simm
   4910 		name not_gr mode op regtype attr profile comment)
   4911   (dni name
   4912        (comment)
   4913        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   4914 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) attr)
   4915        (.str name "$pack @($GRi,$d12),$" regtype "doublek")
   4916        (+ pack (.sym regtype doublek) op GRi d12)
   4917        (sequence ((WI address))
   4918 		 (load-double-semantics not_gr mode regtype address d12))
   4919        profile
   4920   )
   4921 )
   4922 
   4923 (load-double-r-simm lddi  0 DI OP_33 GR NA
   4924 		    ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   4925 		     (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   4926 		    "Load double word")
   4927 (load-double-r-simm lddfi 1 DF OP_3B FR FR-ACCESS
   4928 		    ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   4929 		     (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   4930 		    "Load double float")
   4931 
   4932 (define-pmacro (ne-load-double-r-simm
   4933 		name not_gr mode op regtype size is_float attr profile comment)
   4934   (dni name
   4935        (comment)
   4936        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2) NON-EXCEPTING attr
   4937 	(MACH simple,tomcat,fr500,fr550,frv))
   4938        (.str name "$pack @($GRi,$d12),$" regtype "doublek")
   4939        (+ pack (.sym regtype doublek) op GRi d12)
   4940        (sequence ((WI address))
   4941 		 (ne-load-semantics GRi -1 (.sym regtype doublek)
   4942 				    d12 size is_float
   4943 				    (load-double-semantics not_gr mode
   4944 							   regtype
   4945 							   address d12)))
   4946        profile
   4947   )
   4948 )
   4949 
   4950 (ne-load-double-r-simm nlddi  0 DI OP_45 GR (ne-DI-size) 0 NA
   4951 		       ((fr500 (unit u-gr-load)) (fr550 (unit u-gr-load))) "Load double word")
   4952 (ne-load-double-r-simm nlddfi 1 DF OP_4B FR (ne-DI-size) 1 FR-ACCESS
   4953 		       ((fr500 (unit u-fr-load)) (fr550 (unit u-fr-load))) "Load double float")
   4954 
   4955 (define-pmacro (load-quad-r-simm name op regtype attr profile comment)
   4956   (dni name
   4957        (comment)
   4958        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) attr)
   4959        (.str name "$pack @($GRi,$d12),$" regtype "k")
   4960        (+ pack (.sym regtype k) op GRi d12)
   4961        (sequence ((WI address))
   4962 		 (load-quad-semantics regtype address d12))
   4963        profile
   4964   )
   4965 )
   4966 
   4967 (load-quad-r-simm ldqi  OP_34 GR    NA
   4968 		  ((fr500 (unit u-gr-load))) "Load quad word")
   4969 (load-quad-r-simm ldqfi OP_3C FRint FR-ACCESS
   4970 		  ((fr500 (unit u-fr-load))) "Load quad float")
   4971 
   4972 (define-pmacro (ne-load-quad-r-simm
   4973 		name op regtype size is_float attr profile comment)
   4974   (dni name
   4975        (comment)
   4976        ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING attr)
   4977        (.str name "$pack @($GRi,$d12),$" regtype "k")
   4978        (+ pack (.sym regtype k) op GRi d12)
   4979        (sequence ((WI address))
   4980 		 (ne-load-semantics GRi -1 (.sym regtype k) d12 size is_float
   4981 				    (load-quad-semantics regtype address d12)))
   4982        profile
   4983   )
   4984 )
   4985 
   4986 (ne-load-quad-r-simm nldqfi OP_4C FRint (ne-XI-size) 1 FR-ACCESS
   4987 		     ((fr500 (unit u-fr-load))) "Load quad float")
   4988 
   4989 (define-pmacro (store-r-r name mode op ope reg attr profile comment)
   4990   (dni name
   4991        (comment)
   4992        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   4993 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
   4994        (.str name "$pack $" reg "k,@($GRi,$GRj)")
   4995        (+ pack (.sym reg k) op GRi ope GRj)
   4996        (c-call VOID (.str "@cpu@_write_mem_" mode)
   4997 	       pc (add GRi GRj) (.sym reg k))
   4998        profile
   4999   )
   5000 )
   5001 
   5002 (store-r-r stb   QI OP_03 OPE1_00 GR NA
   5003 	   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5004 	    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5005 	   "Store unsigned byte")
   5006 (store-r-r sth   HI OP_03 OPE1_01 GR NA
   5007 	   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5008 	    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5009 	   "Store unsigned half")
   5010 (store-r-r st    SI OP_03 OPE1_02 GR NA
   5011 	   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5012 	    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5013 	   "Store          word")
   5014 
   5015 (store-r-r stbf  QI OP_03 OPE1_08 FRint FR-ACCESS
   5016 	   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5017 	    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5018 	   "Store byte float")
   5019 (store-r-r sthf  HI OP_03 OPE1_09 FRint FR-ACCESS
   5020 	   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5021 	    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5022 	   "Store half float")
   5023 (store-r-r stf   SI OP_03 OPE1_0A FRint FR-ACCESS
   5024 	   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5025 	    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5026 	   "Store word float")
   5027 
   5028 (store-r-r stc   SI OP_03 OPE1_25 CPR (MACH frv) () "Store coprocessor word")
   5029 
   5030 ; Semantics for a store-double insn
   5031 ;
   5032 (define-pmacro (store-double-semantics mode regtype address arg)
   5033   (sequence ()
   5034 	    (set address (add GRi arg))
   5035 	    (c-call VOID (.str "@cpu@_write_mem_" mode)
   5036 		    pc address (.sym regtype doublek)))
   5037 )
   5038 
   5039 (define-pmacro (store-double-r-r name mode op ope regtype attr profile comment)
   5040   (dni name
   5041        (comment)
   5042        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5043 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
   5044        (.str name "$pack $" regtype "doublek,@($GRi,$GRj)")
   5045        (+ pack (.sym regtype doublek) op GRi ope GRj)
   5046        (sequence ((WI address))
   5047 		 (store-double-semantics mode regtype address GRj))
   5048        profile
   5049   )
   5050 )
   5051 
   5052 (store-double-r-r std  DI OP_03 OPE1_03 GR  NA
   5053 		  ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5054 		   (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5055 		  "Store double word")
   5056 (store-double-r-r stdf DF OP_03 OPE1_0B FR  FR-ACCESS
   5057 		  ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5058 		   (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5059 		  "Store double float")
   5060 
   5061 (store-double-r-r stdc DI OP_03 OPE1_26 CPR (MACH frv)
   5062 		  () "Store coprocessor double word")
   5063 
   5064 ; Semantics for a store-quad insn
   5065 ;
   5066 (define-pmacro (store-quad-semantics regtype address arg)
   5067   (sequence ()
   5068 	    (set address (add GRi arg))
   5069 	    (c-call VOID (.str "@cpu@_store_quad_" regtype)
   5070 		     pc address (index-of (.sym regtype k))))
   5071 )
   5072 
   5073 (define-pmacro (store-quad-r-r name op ope regtype attr profile comment)
   5074   (dni name
   5075        (comment)
   5076        ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) attr)
   5077        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
   5078        (+ pack (.sym regtype k) op GRi ope GRj)
   5079        (sequence ((WI address))
   5080 		 (store-quad-semantics regtype address GRj))
   5081        profile
   5082   )
   5083 )
   5084 
   5085 (store-quad-r-r stq   OP_03 OPE1_04 GR    NA
   5086 		((fr500 (unit u-gr-store))) "Store quad word")
   5087 (store-quad-r-r stqf  OP_03 OPE1_0C FRint FR-ACCESS
   5088 		((fr500 (unit u-fr-store)))
   5089 		"Store quad float")
   5090 (store-quad-r-r stqc  OP_03 OPE1_27 CPR   NA
   5091 		() "Store coprocessor quad word")
   5092 
   5093 (define-pmacro (store-r-r-u name mode op ope regtype attr profile comment)
   5094   (dni name
   5095        (comment)
   5096        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5097 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
   5098        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
   5099        (+ pack (.sym regtype k) op GRi ope GRj)
   5100        (sequence ((UWI address))
   5101 		 (set address (add GRi GRj))
   5102 		 (c-call VOID (.str "@cpu@_write_mem_" mode)
   5103 			 pc address (.sym regtype k))
   5104 		 (set GRi address))
   5105        profile
   5106   )
   5107 )
   5108 
   5109 (store-r-r-u stbu  QI OP_03 OPE1_10 GR NA
   5110 	     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5111 	      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5112 	     "Store unsigned byte, update index")
   5113 (store-r-r-u sthu  HI OP_03 OPE1_11 GR NA
   5114 	     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5115 	      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5116 	     "Store unsigned half, update index")
   5117 (store-r-r-u stu   WI OP_03 OPE1_12 GR NA
   5118 	     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5119 	      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5120 	     "Store          word, update index")
   5121 
   5122 (store-r-r-u stbfu QI OP_03 OPE1_18 FRint FR-ACCESS
   5123 	     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5124 	      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5125 	     "Store byte float, update index")
   5126 (store-r-r-u sthfu HI OP_03 OPE1_19 FRint FR-ACCESS
   5127 	     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5128 	      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5129 	     "Store half float, update index")
   5130 (store-r-r-u stfu  SI OP_03 OPE1_1A FRint FR-ACCESS
   5131 	     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5132 	      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5133 	     "Store word float, update index")
   5134 
   5135 (store-r-r-u stcu  SI OP_03 OPE1_2D CPR (MACH frv) ()
   5136 	     "Store coprocessor word, update index")
   5137 
   5138 (define-pmacro (store-double-r-r-u
   5139 		name mode op ope regtype attr profile comment)
   5140   (dni name
   5141        (comment)
   5142        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5143 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
   5144        (.str name "$pack $" regtype "doublek,@($GRi,$GRj)")
   5145        (+ pack (.sym regtype doublek) op GRi ope GRj)
   5146        (sequence ((WI address))
   5147 		 (store-double-semantics mode regtype address GRj)
   5148 		 (set GRi address))
   5149        profile
   5150   )
   5151 )
   5152 
   5153 (store-double-r-r-u stdu  DI OP_03 OPE1_13 GR  NA
   5154 		    ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5155 		     (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5156 		    "Store double word, update index")
   5157 (store-double-r-r-u stdfu DF OP_03 OPE1_1B FR  FR-ACCESS
   5158 		    ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5159 		     (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5160 		    "Store double float,update index")
   5161 (store-double-r-r-u stdcu DI OP_03 OPE1_2E CPR (MACH frv) ()
   5162 		    "Store coprocessor double word, update index")
   5163 
   5164 (define-pmacro (store-quad-r-r-u name op ope regtype attr profile comment)
   5165   (dni name
   5166        (comment)
   5167        ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) attr)
   5168        (.str name "$pack $" regtype "k,@($GRi,$GRj)")
   5169        (+ pack (.sym regtype k) op GRi ope GRj)
   5170        (sequence ((WI address))
   5171 		 (store-quad-semantics regtype address GRj)
   5172 		 (set GRi address))
   5173        profile
   5174   )
   5175 )
   5176 
   5177 (store-quad-r-r-u stqu  OP_03 OPE1_14 GR    NA
   5178 		  ((fr500 (unit u-gr-store)))
   5179 		  "Store quad word, update index")
   5180 (store-quad-r-r-u stqfu OP_03 OPE1_1C FRint FR-ACCESS
   5181 		  ((fr500 (unit u-fr-store)))
   5182 		  "Store quad float, update index")
   5183 (store-quad-r-r-u stqcu OP_03 OPE1_2F CPR   NA ()
   5184 		  "Store coprocessor quad   word, update index")
   5185 
   5186 (define-pmacro (conditional-load name mode op ope regtype profile comment)
   5187   (dni name
   5188        (comment)
   5189        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   5190 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL)
   5191        (.str name "$pack @($GRi,$GRj),$" regtype "k,$CCi,$cond")
   5192        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
   5193        (if (eq CCi (or cond 2))
   5194 	   (set (.sym regtype k)
   5195 		(c-call mode (.str "@cpu@_read_mem_" mode) pc (add GRi GRj))))
   5196        profile
   5197   )
   5198 )
   5199 
   5200 (conditional-load cldsb  QI OP_5E OPE4_0 GR
   5201 		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5202 		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5203 		  "Load   signed byte")
   5204 (conditional-load cldub UQI OP_5E OPE4_1 GR
   5205 		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5206 		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5207 		  "Load unsigned byte")
   5208 (conditional-load cldsh  HI OP_5E OPE4_2 GR
   5209 		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5210 		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5211 		  "Load   signed half")
   5212 (conditional-load clduh UHI OP_5E OPE4_3 GR
   5213 		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5214 		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5215 		  "Load unsigned half")
   5216 (conditional-load cld    SI OP_5F OPE4_0 GR
   5217 		  ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5218 		   (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5219 		  "Load          word")
   5220 
   5221 (conditional-load cldbf UQI OP_60 OPE4_0 FRint
   5222 		  ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   5223 		   (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   5224 		  "Load byte float")
   5225 (conditional-load cldhf UHI OP_60 OPE4_1 FRint
   5226 		  ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   5227 		   (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   5228 		  "Load half float")
   5229 (conditional-load cldf   SI OP_60 OPE4_2 FRint
   5230 		  ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   5231 		   (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   5232 		  "Load word float")
   5233 
   5234 (define-pmacro (conditional-load-double
   5235 		name not_gr mode op ope regtype attr profile comment)
   5236   (dni name
   5237        (comment)
   5238        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   5239 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL attr)
   5240        (.str name "$pack @($GRi,$GRj),$" regtype "doublek,$CCi,$cond")
   5241        (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
   5242        (if (eq CCi (or cond 2))
   5243 	   (sequence ((WI address))
   5244 		     (load-double-semantics not_gr mode regtype address GRj)))
   5245        profile
   5246   )
   5247 )
   5248 
   5249 (conditional-load-double cldd  0 DI OP_5F OPE4_1 GR NA
   5250 			 ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5251 			  (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5252 			 "Load double word")
   5253 (conditional-load-double clddf 1 DF OP_60 OPE4_3 FR FR-ACCESS
   5254 			 ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5255 			  (fr500 (unit u-gr-load)) (fr550 (unit u-fr-load)))
   5256 			 "Load double float")
   5257 
   5258 (dni cldq
   5259      "conditional load quad integer"
   5260      ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) CONDITIONAL)
   5261      "cldq$pack @($GRi,$GRj),$GRk,$CCi,$cond"
   5262      (+ pack GRk OP_5F GRi CCi cond OPE4_2 GRj)
   5263      (if (eq CCi (or cond 2))
   5264 	 (sequence ((WI address))
   5265 		   (load-quad-semantics GR address GRj)))
   5266      ((fr500 (unit u-gr-load)))
   5267 )
   5268 
   5269 (define-pmacro (conditional-load-gr-u name mode op ope comment)
   5270   (dni name
   5271        (comment)
   5272        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   5273 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL)
   5274        (.str name "$pack @($GRi,$GRj),$GRk,$CCi,$cond")
   5275        (+ pack GRk op GRi CCi  cond ope GRj)
   5276        (if (eq CCi (or cond 2))
   5277 	   (sequence ((WI address))
   5278 		     (set address (add GRi GRj))
   5279 		     (set GRk
   5280 			  (c-call mode (.str "@cpu@_read_mem_" mode)
   5281 				  pc address))
   5282 		     (if (ne (index-of GRi) (index-of GRk))
   5283 			 (set GRi address))))
   5284        ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5285 	(fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5286   )
   5287 )
   5288 
   5289 (conditional-load-gr-u cldsbu  QI OP_61 OPE4_0 "Load   signed byte, update")
   5290 (conditional-load-gr-u cldubu UQI OP_61 OPE4_1 "Load unsigned byte, update")
   5291 (conditional-load-gr-u cldshu  HI OP_61 OPE4_2 "Load   signed half, update")
   5292 (conditional-load-gr-u clduhu UHI OP_61 OPE4_3 "Load unsigned half, update")
   5293 (conditional-load-gr-u cldu    SI OP_62 OPE4_0 "Load          word, update")
   5294 
   5295 (define-pmacro (conditional-load-non-gr-u name mode op ope regtype comment)
   5296   (dni name
   5297        (comment)
   5298        ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   5299 	(FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL FR-ACCESS)
   5300        (.str name "$pack @($GRi,$GRj),$" regtype "k,$CCi,$cond")
   5301        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
   5302        (if (eq CCi (or cond 2))
   5303 	   (sequence ((WI address))
   5304 		     (set address (add GRi GRj))
   5305 		     (set (.sym regtype k)
   5306 			  (c-call mode (.str "@cpu@_read_mem_" mode)
   5307 				  pc address))
   5308 		     (set GRi address)))
   5309        ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   5310 	(fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   5311   )
   5312 )
   5313 
   5314 (conditional-load-non-gr-u cldbfu UQI OP_63 OPE4_0 FRint "Load byte float, update")
   5315 (conditional-load-non-gr-u cldhfu UHI OP_63 OPE4_1 FRint "Load half float, update")
   5316 (conditional-load-non-gr-u cldfu   SI OP_63 OPE4_2 FRint "Load word float, update")
   5317 
   5318 
   5319 (dni clddu
   5320      "Load double word,  update"
   5321      ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   5322       (FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL)
   5323      "clddu$pack @($GRi,$GRj),$GRdoublek,$CCi,$cond"
   5324      (+ pack GRdoublek OP_62 GRi CCi cond OPE4_1 GRj)
   5325      (if (eq CCi (or cond 2))
   5326 	 (sequence ((WI address))
   5327 		   (load-double-semantics 0 DI GR address GRj)
   5328 		   (if (ne (index-of GRi) (index-of GRdoublek))
   5329 		       (set GRi address))))
   5330      ((fr400 (unit u-gr-load)) (fr450 (unit u-gr-load))
   5331       (fr500 (unit u-gr-load)) (fr550 (unit u-gr-load)))
   5332 )
   5333 
   5334 (dni clddfu
   5335      "Load double float, update"
   5336      ((UNIT LOAD) (FR550-MAJOR I-3) (FR500-MAJOR I-2)
   5337       (FR400-MAJOR I-2) (FR450-MAJOR I-2) CONDITIONAL FR-ACCESS)
   5338      "clddfu$pack @($GRi,$GRj),$FRdoublek,$CCi,$cond"
   5339      (+ pack FRdoublek OP_63 GRi CCi cond OPE4_3 GRj)
   5340      (if (eq CCi (or cond 2))
   5341 	 (sequence ((WI address))
   5342 		   (load-double-semantics 1 DF FR address GRj)
   5343 		   (set GRi address)))
   5344      ((fr400 (unit u-fr-load)) (fr450 (unit u-fr-load))
   5345       (fr500 (unit u-fr-load)) (fr550 (unit u-fr-load)))
   5346 )
   5347 
   5348 (dni cldqu
   5349      "conditional load quad integer and update index"
   5350      ((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) CONDITIONAL)
   5351      "cldqu$pack @($GRi,$GRj),$GRk,$CCi,$cond"
   5352      (+ pack GRk OP_62 GRi CCi cond OPE4_2 GRj)
   5353      (if (eq CCi (or cond 2))
   5354 	 (sequence ((WI address))
   5355 		   (load-quad-semantics GR address GRj)
   5356 		   (if (ne (index-of GRi) (index-of GRk))
   5357 		       (set GRi address))))
   5358      ((fr500 (unit u-gr-load)))
   5359 )
   5360 
   5361 (define-pmacro (conditional-store name mode op ope regtype profile comment)
   5362   (dni name
   5363        (comment)
   5364        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5365 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL)
   5366        (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
   5367        (+ pack (.sym regtype k) op GRi CCi cond ope GRj)
   5368        (if (eq CCi (or cond 2))
   5369 	   (c-call VOID (.str "@cpu@_write_mem_" mode)
   5370 		   pc (add GRi GRj) (.sym regtype k)))
   5371        profile
   5372   )
   5373 )
   5374 
   5375 (conditional-store cstb  QI OP_64 OPE4_0 GR
   5376 		   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5377 		    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5378 		   "Store unsigned byte")
   5379 (conditional-store csth  HI OP_64 OPE4_1 GR
   5380 		   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5381 		    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5382 		   "Store unsigned half")
   5383 (conditional-store cst   SI OP_64 OPE4_2 GR
   5384 		   ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5385 		    (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5386 		   "Store          word")
   5387 
   5388 (conditional-store cstbf QI OP_66 OPE4_0 FRint
   5389 		   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5390 		    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5391 		   "Store byte float")
   5392 (conditional-store csthf HI OP_66 OPE4_1 FRint
   5393 		   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5394 		    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5395 		   "Store half float")
   5396 (conditional-store cstf  SI OP_66 OPE4_2 FRint
   5397 		   ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5398 		    (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5399 		   "Store word float")
   5400 
   5401 (define-pmacro (conditional-store-double
   5402 		name mode op ope regtype attr profile comment)
   5403   (dni name
   5404        (comment)
   5405        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5406 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL attr)
   5407        (.str name "$pack $" regtype "doublek,@($GRi,$GRj),$CCi,$cond")
   5408        (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
   5409        (if (eq CCi (or cond 2))
   5410 	   (sequence ((WI address))
   5411 		     (store-double-semantics mode regtype address GRj)))
   5412        profile
   5413   )
   5414 )
   5415 
   5416 (conditional-store-double cstd  DI OP_64 OPE4_3 GR NA
   5417 			  ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5418 			   (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5419 			  "Store double word")
   5420 (conditional-store-double cstdf DF OP_66 OPE4_3 FR FR-ACCESS
   5421 			  ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5422 			   (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5423 			  "Store double float")
   5424 
   5425 (dni cstq
   5426      "conditionally store quad word"
   5427      ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) CONDITIONAL)
   5428      "cstq$pack $GRk,@($GRi,$GRj),$CCi,$cond"
   5429      (+ pack GRk OP_65 GRi CCi cond OPE4_0 GRj)
   5430      (if (eq CCi (or cond 2))
   5431 	 (sequence ((WI address))
   5432 		   (store-quad-semantics GR address GRj)))
   5433      ((fr500 (unit u-gr-store)))
   5434 )
   5435 
   5436 (define-pmacro (conditional-store-u
   5437 		name mode op ope regtype attr profile comment)
   5438   (dni name
   5439        (comment)
   5440        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5441 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL attr)
   5442        (.str name "$pack $" regtype "k,@($GRi,$GRj),$CCi,$cond")
   5443        (+ pack (.sym regtype k) op GRi CCi  cond ope GRj)
   5444        (if (eq CCi (or cond 2))
   5445 	   (sequence ((WI address))
   5446 		     (set address (add GRi GRj))
   5447 		     (c-call VOID (.str "@cpu@_write_mem_" mode)
   5448 			     pc address (.sym regtype k))
   5449 		     (set GRi address)))
   5450        profile
   5451   )
   5452 )
   5453 
   5454 (conditional-store-u cstbu QI OP_67 OPE4_0 GR NA
   5455 		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5456 		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5457 		     "Store unsigned byte, update index")
   5458 (conditional-store-u csthu HI OP_67 OPE4_1 GR NA
   5459 		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5460 		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5461 		     "Store unsigned half, update index")
   5462 (conditional-store-u cstu  SI OP_67 OPE4_2 GR NA
   5463 		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5464 		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5465 		     "Store          word, update index")
   5466 
   5467 (conditional-store-u cstbfu QI OP_68 OPE4_0 FRint FR-ACCESS
   5468 		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5469 		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5470 		     "Store byte float, update index")
   5471 (conditional-store-u csthfu HI OP_68 OPE4_1 FRint FR-ACCESS
   5472 		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5473 		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5474 		     "Store half float, update index")
   5475 (conditional-store-u cstfu  SI OP_68 OPE4_2 FRint FR-ACCESS
   5476 		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5477 		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5478 		     "Store word float, update index")
   5479 
   5480 (define-pmacro (conditional-store-double-u
   5481 		name mode op ope regtype attr profile comment)
   5482   (dni name
   5483        (comment)
   5484        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5485 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) CONDITIONAL attr)
   5486        (.str name "$pack $" regtype "doublek,@($GRi,$GRj),$CCi,$cond")
   5487        (+ pack (.sym regtype doublek) op GRi CCi  cond ope GRj)
   5488        (if (eq CCi (or cond 2))
   5489 	   (sequence ((WI address))
   5490 		     (store-double-semantics mode regtype address GRj)
   5491 		     (set GRi address)))
   5492        profile
   5493   )
   5494 )
   5495 
   5496 (conditional-store-double-u cstdu  DI OP_67 OPE4_3 GR NA
   5497 			    ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5498 			     (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5499 			    "Store double word, update index")
   5500 (conditional-store-double-u cstdfu DF OP_68 OPE4_3 FR FR-ACCESS
   5501 			    ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5502 			     (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5503 			    "Store double float, update index")
   5504 
   5505 (define-pmacro (store-r-simm name mode op regtype attr profile comment)
   5506   (dni name
   5507        (comment)
   5508        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5509 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
   5510        (.str name "$pack $" regtype "k,@($GRi,$d12)")
   5511        (+ pack (.sym regtype k) op GRi d12)
   5512        (c-call VOID (.str "@cpu@_write_mem_" mode)
   5513 	       pc (add GRi d12) (.sym regtype k))
   5514        profile
   5515   )
   5516 )
   5517 
   5518 (store-r-simm stbi QI OP_50 GR NA
   5519 	      ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5520 	       (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5521 	      "Store unsigned byte")
   5522 (store-r-simm sthi HI OP_51 GR NA
   5523 	      ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5524 	       (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5525 	      "Store unsigned half")
   5526 (store-r-simm sti  SI OP_52 GR NA
   5527 	      ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5528 	       (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5529 	      "Store          word")
   5530 
   5531 (store-r-simm stbfi QI OP_4E FRint FR-ACCESS
   5532 	      ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5533 	       (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5534 	      "Store byte float")
   5535 (store-r-simm sthfi HI OP_4F FRint FR-ACCESS
   5536 	      ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5537 	       (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5538 	      "Store half float")
   5539 (store-r-simm stfi  SI OP_55 FRint FR-ACCESS
   5540 	      ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5541 	       (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5542 	      "Store word float")
   5543 
   5544 (define-pmacro (store-double-r-simm name mode op regtype attr profile comment)
   5545   (dni name
   5546        (comment)
   5547        ((UNIT STORE) (FR550-MAJOR I-4) (FR500-MAJOR I-3)
   5548 	(FR400-MAJOR I-3) (FR450-MAJOR I-3) attr)
   5549        (.str name "$pack $" regtype "doublek,@($GRi,$d12)")
   5550        (+ pack (.sym regtype doublek) op GRi d12)
   5551        (sequence ((WI address))
   5552 		 (store-double-semantics mode regtype address d12))
   5553        profile
   5554   )
   5555 )
   5556 
   5557 (store-double-r-simm stdi  DI OP_53 GR NA
   5558 		     ((fr400 (unit u-gr-store)) (fr450 (unit u-gr-store))
   5559 		      (fr500 (unit u-gr-store)) (fr550 (unit u-gr-store)))
   5560 		     "Store double word")
   5561 (store-double-r-simm stdfi DF OP_56 FR FR-ACCESS
   5562 		     ((fr400 (unit u-fr-store)) (fr450 (unit u-fr-store))
   5563 		      (fr500 (unit u-fr-store)) (fr550 (unit u-fr-store)))
   5564 		     "Store double float")
   5565 
   5566 (define-pmacro (store-quad-r-simm name op regtype attr profile comment)
   5567   (dni name
   5568        (comment)
   5569        ((UNIT STORE) (FR500-MAJOR I-3) (MACH frv) attr)
   5570        (.str name "$pack $" regtype "k,@($GRi,$d12)")
   5571        (+ pack (.sym regtype k) op GRi d12)
   5572        (sequence ((WI address))
   5573 		 (store-quad-semantics regtype address d12))
   5574        profile
   5575   )
   5576 )
   5577 
   5578 (store-quad-r-simm stqi  OP_54 GR    NA ((fr500 (unit u-gr-store)))
   5579 		   "Store quad word")
   5580 (store-quad-r-simm stqfi OP_57 FRint FR-ACCESS ()
   5581 		   "Store quad float")
   5582 
   5583 (define-pmacro (swap-semantics base offset arg)
   5584   (sequence ((WI tmp) (WI address))
   5585 	    (set tmp arg)
   5586 	    (set address (add base offset))
   5587 	    (c-call VOID "@cpu@_check_swap_address" address)
   5588 	    (set arg (c-call WI "@cpu@_read_mem_WI" pc address))
   5589 	    (c-call VOID "@cpu@_write_mem_WI" pc address tmp))
   5590 )
   5591 
   5592 (dni swap
   5593      "Swap contents of memory with GR"
   5594      ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   5595       (FR400-MAJOR C-2) (FR450-MAJOR C-2))
   5596      "swap$pack @($GRi,$GRj),$GRk"
   5597      (+ pack GRk OP_03 GRi OPE1_05 GRj)
   5598      (swap-semantics GRi GRj GRk)
   5599      ((fr400 (unit u-swap)) (fr450 (unit u-swap))
   5600       (fr500 (unit u-swap)) (fr550 (unit u-swap)))
   5601 )
   5602 
   5603 (dni "swapi"
   5604      "Swap contents of memory with GR"
   5605      ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   5606       (FR400-MAJOR C-2) (FR450-MAJOR C-2))
   5607      ("swapi$pack @($GRi,$d12),$GRk")
   5608      (+ pack GRk OP_4D GRi d12)
   5609      (swap-semantics GRi d12 GRk)
   5610      ((fr400 (unit u-swap)) (fr450 (unit u-swap))
   5611       (fr500 (unit u-swap)) (fr550 (unit u-swap)))
   5612 )
   5613 
   5614 (dni cswap
   5615      "Conditionally swap contents of memory with GR"
   5616      ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   5617       (FR400-MAJOR C-2) (FR450-MAJOR C-2) CONDITIONAL)
   5618      "cswap$pack @($GRi,$GRj),$GRk,$CCi,$cond"
   5619      (+ pack GRk OP_65 GRi CCi cond OPE4_2 GRj)
   5620      (if (eq CCi (or cond 2))
   5621 	 (swap-semantics GRi GRj GRk))
   5622      ((fr400 (unit u-swap)) (fr450 (unit u-swap))
   5623       (fr500 (unit u-swap)) (fr550 (unit u-swap)))
   5624 )
   5625 
   5626 (define-pmacro (register-transfer
   5627 		name op ope reg_src reg_targ pipe attrs	profile comment)
   5628   (dni name
   5629        (comment)
   5630        (.splice (UNIT pipe) (.unsplice attrs))
   5631        (.str name "$pack $" reg_src ",$" reg_targ)
   5632        (+ pack reg_targ op (rs-null) ope reg_src)
   5633        (set reg_targ reg_src)
   5634        profile
   5635   )
   5636 )
   5637 
   5638 (register-transfer movgf OP_03 OPE1_15
   5639 		   GRj FRintk I0
   5640 		   ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5641 		    (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
   5642 		   ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
   5643 		    (fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
   5644 		   "transfer gr to fr")
   5645 (register-transfer movfg OP_03 OPE1_0D
   5646 		   FRintk GRj I0
   5647 		   ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5648 		    (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
   5649 		   ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
   5650 		    (fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
   5651 		   "transfer fr to gr")
   5652 
   5653 (define-pmacro (nextreg hw r offset) (reg hw (add (index-of r) offset)))
   5654 
   5655 (define-pmacro (register-transfer-double-from-gr-semantics cond)
   5656   (if cond
   5657       (if (eq (index-of GRj) 0)
   5658 	  (sequence ()
   5659 		    (set FRintk 0)
   5660 		    (set (nextreg h-fr_int FRintk 1) 0))
   5661 	  (sequence ()
   5662 		    (set FRintk GRj)
   5663 		    (set (nextreg h-fr_int FRintk 1) (nextreg h-gr GRj 1)))))
   5664 )
   5665 
   5666 (dni movgfd
   5667      "move GR for FR double"
   5668      ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5669       (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
   5670      "movgfd$pack $GRj,$FRintk"
   5671      (+ pack FRintk OP_03 (rs-null) OPE1_16 GRj)
   5672      (register-transfer-double-from-gr-semantics 1)
   5673      ; TODO -- doesn't handle second register in the pair
   5674      ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
   5675       (fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
   5676 )
   5677 
   5678 (define-pmacro (register-transfer-double-to-gr-semantics cond)
   5679   (if (andif (ne (index-of GRj) 0) cond)
   5680       (sequence ()
   5681 		(set GRj FRintk)
   5682 		(set (nextreg h-gr GRj 1) (nextreg h-fr_int FRintk 1))))
   5683 )
   5684 
   5685 (dni movfgd
   5686      "move FR for GR double"
   5687      ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5688       (FR400-MAJOR I-4) (FR450-MAJOR I-4) FR-ACCESS)
   5689      "movfgd$pack $FRintk,$GRj"
   5690      (+ pack FRintk OP_03 (rs-null) OPE1_0E GRj)
   5691      (register-transfer-double-to-gr-semantics 1)
   5692      ; TODO -- doesn't handle second register in the pair
   5693      ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
   5694       (fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
   5695 )
   5696 
   5697 (dni movgfq
   5698      "move GR for FR quad"
   5699      ((UNIT I0) (FR500-MAJOR I-4) (MACH frv) FR-ACCESS)
   5700      "movgfq$pack $GRj,$FRintk"
   5701      (+ pack FRintk OP_03 (rs-null) OPE1_17 GRj)
   5702      (if (eq (index-of GRj) 0)
   5703 	 (sequence ()
   5704 		   (set FRintk 0)
   5705 		   (set (reg h-fr_int (add (index-of FRintk) 1)) 0)
   5706 		   (set (reg h-fr_int (add (index-of FRintk) 2)) 0)
   5707 		   (set (reg h-fr_int (add (index-of FRintk) 3)) 0))
   5708 	 (sequence ()
   5709 		   (set FRintk GRj)
   5710 		   (set (reg h-fr_int (add (index-of FRintk) 1))
   5711 			(reg h-gr (add (index-of GRj)    1)))
   5712 		   (set (reg h-fr_int (add (index-of FRintk) 2))
   5713 			(reg h-gr (add (index-of GRj)    2)))
   5714 		   (set (reg h-fr_int (add (index-of FRintk) 3))
   5715 			(reg h-gr (add (index-of GRj)    3)))))
   5716      ()
   5717 )
   5718 
   5719 (dni movfgq
   5720      "move FR for GR quad"
   5721      ((UNIT I0) (FR500-MAJOR I-4) (MACH frv) FR-ACCESS)
   5722      "movfgq$pack $FRintk,$GRj"
   5723      (+ pack FRintk OP_03 (rs-null) OPE1_0F GRj)
   5724      (if (ne (index-of GRj) 0)
   5725 	 (sequence ()
   5726 		   (set GRj FRintk)
   5727 		   (set (reg h-gr (add (index-of GRj)    1))
   5728 			(reg h-fr_int (add (index-of FRintk) 1)))
   5729 		   (set (reg h-gr (add (index-of GRj)    2))
   5730 			(reg h-fr_int (add (index-of FRintk) 2)))
   5731 		   (set (reg h-gr (add (index-of GRj)    3))
   5732 			(reg h-fr_int (add (index-of FRintk) 3)))))
   5733      ()
   5734 )
   5735 
   5736 (define-pmacro (conditional-register-transfer
   5737 		name op ope reg_src reg_targ pipe attrs	profile comment)
   5738   (dni name
   5739        (comment)
   5740        (.splice (UNIT pipe) CONDITIONAL FR-ACCESS (.unsplice attrs))
   5741        (.str name "$pack $" reg_src ",$" reg_targ ",$CCi,$cond")
   5742        (+ pack reg_targ op (rs-null) CCi cond ope reg_src)
   5743        (if (eq CCi (or cond 2))
   5744 	   (set reg_targ reg_src))
   5745        profile
   5746   )
   5747 )
   5748 
   5749 (conditional-register-transfer cmovgf OP_69 OPE4_0 GRj FRintk I0
   5750 			       ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5751 				(FR400-MAJOR I-4) (FR450-MAJOR I-4))
   5752 			       ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
   5753 				(fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
   5754 			       "transfer gr to fr")
   5755 (conditional-register-transfer cmovfg OP_69 OPE4_2 FRintk GRj I0
   5756 			       ((FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5757 				(FR400-MAJOR I-4) (FR450-MAJOR I-4))
   5758 			       ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
   5759 				(fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
   5760 			       "transfer fr to gr")
   5761 
   5762 
   5763 (dni cmovgfd
   5764      "Conditional move GR to FR double"
   5765      ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5766       (FR400-MAJOR I-4) (FR450-MAJOR I-4) CONDITIONAL FR-ACCESS)
   5767      "cmovgfd$pack $GRj,$FRintk,$CCi,$cond"
   5768      (+ pack FRintk OP_69 (rs-null) CCi cond OPE4_1 GRj)
   5769      (register-transfer-double-from-gr-semantics (eq CCi (or cond 2)))
   5770      ; TODO -- doesn't handle extra registers in double
   5771      ((fr400 (unit u-gr2fr)) (fr450 (unit u-gr2fr))
   5772       (fr500 (unit u-gr2fr)) (fr550 (unit u-gr2fr)))
   5773 )
   5774 
   5775 (dni cmovfgd
   5776      "Conditional move FR to GR double"
   5777      ((UNIT I0) (FR500-MAJOR I-4) (FR550-MAJOR I-5)
   5778       (FR400-MAJOR I-4) (FR450-MAJOR I-4) CONDITIONAL FR-ACCESS)
   5779      "cmovfgd$pack $FRintk,$GRj,$CCi,$cond"
   5780      (+ pack FRintk OP_69 (rs-null) CCi cond OPE4_3 GRj)
   5781      (register-transfer-double-to-gr-semantics (eq CCi (or cond 2)))
   5782      ; TODO -- doesn't handle second register in the pair
   5783      ((fr400 (unit u-fr2gr)) (fr450 (unit u-fr2gr))
   5784       (fr500 (unit u-fr2gr)) (fr550 (unit u-fr2gr)))
   5785 )
   5786 
   5787 (define-pmacro (register-transfer-spr
   5788 		name op ope reg_src reg_targ unitname comment)
   5789   (dni name
   5790        (comment)
   5791        ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   5792 	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
   5793        (.str name "$pack $" reg_src ",$" reg_targ)
   5794        (+ pack reg_targ op ope reg_src)
   5795        (set reg_targ reg_src)
   5796        ((fr400 (unit unitname)) (fr450 (unit unitname))
   5797 	(fr500 (unit unitname)) (fr550 (unit unitname)))
   5798   )
   5799 )
   5800 
   5801 (register-transfer-spr movgs OP_03 OPE1_06 GRj spr u-gr2spr "transfer gr->spr")
   5802 (register-transfer-spr movsg OP_03 OPE1_07 spr GRj u-spr2gr "transfer spr->gr")
   5803 
   5804 ; Integer Branch Conditions
   5805 (define-pmacro (Inev cc) (const BI 0))
   5806 (define-pmacro (Ira  cc) (const BI 1))
   5807 (define-pmacro (Ieq  cc) (     zbit cc))
   5808 (define-pmacro (Ine  cc) (not (zbit cc)))
   5809 (define-pmacro (Ile  cc) (     orif (zbit cc) (xor (nbit cc) (vbit cc))))
   5810 (define-pmacro (Igt  cc) (not (orif (zbit cc) (xor (nbit cc) (vbit cc)))))
   5811 (define-pmacro (Ilt  cc) (     xor  (nbit cc) (vbit cc)))
   5812 (define-pmacro (Ige  cc) (not (xor  (nbit cc) (vbit cc))))
   5813 (define-pmacro (Ils  cc) (     orif (cbit cc) (zbit cc)))
   5814 (define-pmacro (Ihi  cc) (not (orif (cbit cc) (zbit cc))))
   5815 (define-pmacro (Ic   cc) (     cbit cc))
   5816 (define-pmacro (Inc  cc) (not (cbit cc)))
   5817 (define-pmacro (In   cc) (     nbit cc))
   5818 (define-pmacro (Ip   cc) (not (nbit cc)))
   5819 (define-pmacro (Iv   cc) (     vbit cc))
   5820 (define-pmacro (Inv  cc) (not (vbit cc)))
   5821 
   5822 ; Float Branch Conditions
   5823 (define-pmacro (Fnev cc) (const BI 0))
   5824 (define-pmacro (Fra  cc) (const BI 1))
   5825 (define-pmacro (Fne  cc) (orif (lbit cc) (orif (gbit cc) (ubit cc))))
   5826 (define-pmacro (Feq  cc) (ebit cc))
   5827 (define-pmacro (Flg  cc) (orif (lbit cc) (gbit cc)))
   5828 (define-pmacro (Fue  cc) (orif (ebit cc) (ubit cc)))
   5829 (define-pmacro (Ful  cc) (orif (lbit cc) (ubit cc)))
   5830 (define-pmacro (Fge  cc) (orif (ebit cc) (gbit cc)))
   5831 (define-pmacro (Flt  cc) (lbit cc))
   5832 (define-pmacro (Fuge cc) (orif (ebit cc) (orif (gbit cc) (ubit cc))))
   5833 (define-pmacro (Fug  cc) (orif (gbit cc) (ubit cc)))
   5834 (define-pmacro (Fle  cc) (orif (ebit cc) (lbit cc)))
   5835 (define-pmacro (Fgt  cc) (gbit cc))
   5836 (define-pmacro (Fule cc) (orif (ebit cc) (orif (lbit cc) (ubit cc))))
   5837 (define-pmacro (Fu   cc) (ubit cc))
   5838 (define-pmacro (Fo   cc) (orif (ebit cc) (orif (lbit cc) (gbit cc))))
   5839 
   5840 (define-pmacro (conditional-branch-i prefix cc op cond comment)
   5841   (dni (.sym prefix cc)
   5842        (comment)
   5843        ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
   5844 	(FR400-MAJOR B-1) (FR450-MAJOR B-1))
   5845        (.str (.sym prefix cc) "$pack $ICCi_2,$hint,$label16")
   5846        (+ pack (.sym ICC_ cc) ICCi_2 op hint label16)
   5847        (sequence ()
   5848 		 (c-call VOID "@cpu@_model_branch" label16 hint)
   5849 		 (if (cond ICCi_2)
   5850 		     (set pc label16)))
   5851        ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5852 	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5853   )
   5854 )
   5855 
   5856 (dni bra
   5857      "integer branch equal"
   5858       ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
   5859        (FR400-MAJOR B-1) (FR450-MAJOR B-1))
   5860       "bra$pack $hint_taken$label16"
   5861       (+ pack ICC_ra (ICCi_2-null) OP_06 hint_taken label16)
   5862       (sequence ()
   5863 		(c-call VOID "@cpu@_model_branch" label16 hint_taken)
   5864 		(set pc label16))
   5865       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5866        (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5867 )
   5868 
   5869 (dni bno
   5870      "integer branch never"
   5871       ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
   5872        (FR400-MAJOR B-1) (FR450-MAJOR B-1))
   5873       "bno$pack$hint_not_taken"
   5874       (+ pack ICC_nev (ICCi_2-null) OP_06 hint_not_taken (label16-null))
   5875       (c-call VOID "@cpu@_model_branch" label16 hint_not_taken)
   5876       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5877        (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5878 )
   5879 
   5880 (conditional-branch-i b eq  OP_06 Ieq  "integer branch equal")
   5881 (conditional-branch-i b ne  OP_06 Ine  "integer branch not equal")
   5882 (conditional-branch-i b le  OP_06 Ile  "integer branch less or equal")
   5883 (conditional-branch-i b gt  OP_06 Igt  "integer branch greater")
   5884 (conditional-branch-i b lt  OP_06 Ilt  "integer branch less")
   5885 (conditional-branch-i b ge  OP_06 Ige  "integer branch greater or equal")
   5886 (conditional-branch-i b ls  OP_06 Ils  "integer branch less or equal unsigned")
   5887 (conditional-branch-i b hi  OP_06 Ihi  "integer branch greater unsigned")
   5888 (conditional-branch-i b c   OP_06 Ic   "integer branch carry set")
   5889 (conditional-branch-i b nc  OP_06 Inc  "integer branch carry clear")
   5890 (conditional-branch-i b n   OP_06 In   "integer branch negative")
   5891 (conditional-branch-i b p   OP_06 Ip   "integer branch positive")
   5892 (conditional-branch-i b v   OP_06 Iv   "integer branch overflow set")
   5893 (conditional-branch-i b nv  OP_06 Inv  "integer branch overflow clear")
   5894 
   5895 (define-pmacro (conditional-branch-f prefix cc op cond comment)
   5896   (dni (.sym prefix cc)
   5897        (comment)
   5898        ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
   5899 	(FR400-MAJOR B-1) (FR450-MAJOR B-1) FR-ACCESS)
   5900        (.str (.sym prefix cc) "$pack $FCCi_2,$hint,$label16")
   5901        (+ pack (.sym FCC_ cc) FCCi_2 op hint label16)
   5902        (sequence ()
   5903 		 (c-call VOID "@cpu@_model_branch" label16 hint)
   5904 		 (if (cond FCCi_2) (set pc label16)))
   5905        ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5906 	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5907   )
   5908 )
   5909 
   5910 (dni fbra
   5911      "float branch equal"
   5912       ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
   5913        (FR400-MAJOR B-1) (FR450-MAJOR B-1) FR-ACCESS)
   5914       "fbra$pack $hint_taken$label16"
   5915       (+ pack FCC_ra (FCCi_2-null) OP_07 hint_taken label16)
   5916       (sequence ()
   5917 		(c-call VOID "@cpu@_model_branch" label16 hint_taken)
   5918 		(set pc label16))
   5919       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5920        (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5921 )
   5922 
   5923 (dni fbno
   5924      "float branch never"
   5925       ((UNIT B01) (FR500-MAJOR B-1) (FR550-MAJOR B-1)
   5926        (FR400-MAJOR B-1) (FR450-MAJOR B-1) FR-ACCESS)
   5927       "fbno$pack$hint_not_taken"
   5928       (+ pack FCC_nev (FCCi_2-null) OP_07 hint_not_taken (label16-null))
   5929       (c-call VOID "@cpu@_model_branch" label16 hint_not_taken)
   5930       ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5931        (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5932 )
   5933 
   5934 (conditional-branch-f fb ne  OP_07 Fne  "float branch not equal")
   5935 (conditional-branch-f fb eq  OP_07 Feq  "float branch equal")
   5936 (conditional-branch-f fb lg  OP_07 Flg  "float branch less or greater")
   5937 (conditional-branch-f fb ue  OP_07 Fue  "float branch unordered or equal")
   5938 (conditional-branch-f fb ul  OP_07 Ful  "float branch unordered or less")
   5939 (conditional-branch-f fb ge  OP_07 Fge  "float branch greater or equal")
   5940 (conditional-branch-f fb lt  OP_07 Flt  "float branch less")
   5941 (conditional-branch-f fb uge OP_07 Fuge "float branch unordered, greater,equal")
   5942 (conditional-branch-f fb ug  OP_07 Fug  "float branch unordered or greater")
   5943 (conditional-branch-f fb le  OP_07 Fle  "float branch less or equal")
   5944 (conditional-branch-f fb gt  OP_07 Fgt  "float branch greater")
   5945 (conditional-branch-f fb ule OP_07 Fule "float branch unordered, less or equal")
   5946 (conditional-branch-f fb u   OP_07 Fu   "float branch unordered")
   5947 (conditional-branch-f fb o   OP_07 Fo   "float branch ordered")
   5948 
   5949 (define-pmacro (ctrlr-branch-semantics cond ccond)
   5950   (sequence ((SI tmp))
   5951 	    (set tmp (sub (spr-lcr) 1))
   5952 	    (set (spr-lcr) tmp)
   5953 	    (if cond
   5954 		(if (eq ccond 0)
   5955 		    (if (ne tmp 0)
   5956 			(set pc (spr-lr)))
   5957 		    (if (eq tmp 0)
   5958 			(set pc (spr-lr))))))
   5959 )
   5960 
   5961 (dni bctrlr
   5962      "LCR conditional branch to lr"
   5963      ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
   5964       (FR400-MAJOR B-2) (FR450-MAJOR B-2))
   5965      ("bctrlr$pack $ccond,$hint")
   5966      (+ pack (cond-null) (ICCi_2-null) OP_0E hint OPE3_01 ccond (s12-null))
   5967      (sequence ()
   5968 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
   5969 	       (ctrlr-branch-semantics (const BI 1) ccond))
   5970      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5971       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5972 )
   5973 
   5974 (define-pmacro (conditional-branch-cclr prefix cc i-f op ope cond attr comment)
   5975   (dni (.sym prefix cc lr)
   5976        (comment)
   5977        ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
   5978 	(FR400-MAJOR B-3) (FR450-MAJOR B-3) attr)
   5979        (.str (.sym prefix cc lr) "$pack $" i-f "CCi_2,$hint")
   5980        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op hint ope
   5981 	  (ccond-null) (s12-null))
   5982        (sequence ()
   5983 		 (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
   5984 		 (if (cond (.sym i-f CCi_2)) (set pc (spr-lr))))
   5985        ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   5986 	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
   5987   )
   5988 )
   5989 
   5990 (dni bralr
   5991      "integer cclr branch always"
   5992      ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
   5993       (FR400-MAJOR B-3) (FR450-MAJOR B-3))
   5994      "bralr$pack$hint_taken"
   5995      (+ pack ICC_ra (ICCi_2-null) OP_0E hint_taken OPE3_02 (ccond-null) (s12-null))
   5996      (sequence ()
   5997 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
   5998 	       (set pc (spr-lr)))
   5999      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6000       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6001 )
   6002 
   6003 (dni bnolr
   6004      "integer cclr branch never"
   6005      ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
   6006       (FR400-MAJOR B-3) (FR450-MAJOR B-3))
   6007      "bnolr$pack$hint_not_taken"
   6008      (+ pack ICC_nev (ICCi_2-null) OP_0E hint_not_taken OPE3_02 (ccond-null) (s12-null))
   6009      (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
   6010      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6011       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6012 )
   6013 
   6014 (conditional-branch-cclr b eq  I OP_0E OPE3_02 Ieq  NA "integer cclr branch equal")
   6015 (conditional-branch-cclr b ne  I OP_0E OPE3_02 Ine  NA "integer cclr branch not equal")
   6016 (conditional-branch-cclr b le  I OP_0E OPE3_02 Ile  NA "integer cclr branch less or equal")
   6017 (conditional-branch-cclr b gt  I OP_0E OPE3_02 Igt  NA "integer cclr branch greater")
   6018 (conditional-branch-cclr b lt  I OP_0E OPE3_02 Ilt  NA "integer cclr branch less")
   6019 (conditional-branch-cclr b ge  I OP_0E OPE3_02 Ige  NA "integer cclr branch greater or equal")
   6020 (conditional-branch-cclr b ls  I OP_0E OPE3_02 Ils  NA "integer cclr branch less or equal unsigned")
   6021 (conditional-branch-cclr b hi  I OP_0E OPE3_02 Ihi  NA "integer cclr branch greater unsigned")
   6022 (conditional-branch-cclr b c   I OP_0E OPE3_02 Ic   NA "integer cclr branch carry set")
   6023 (conditional-branch-cclr b nc  I OP_0E OPE3_02 Inc  NA "integer cclr branch carry clear")
   6024 (conditional-branch-cclr b n   I OP_0E OPE3_02 In   NA "integer cclr branch negative")
   6025 (conditional-branch-cclr b p   I OP_0E OPE3_02 Ip   NA "integer cclr branch positive")
   6026 (conditional-branch-cclr b v   I OP_0E OPE3_02 Iv   NA "integer cclr branch overflow set")
   6027 (conditional-branch-cclr b nv  I OP_0E OPE3_02 Inv  NA "integer cclr branch overflow clear")
   6028 
   6029 (dni fbralr
   6030      "float cclr branch always"
   6031      ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
   6032       (FR400-MAJOR B-3) (FR450-MAJOR B-3) FR-ACCESS)
   6033      "fbralr$pack$hint_taken"
   6034      (+ pack FCC_ra (FCCi_2-null) OP_0E hint_taken OPE3_06 (ccond-null) (s12-null))
   6035      (sequence ()
   6036 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
   6037 	       (set pc (spr-lr)))
   6038      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6039       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6040 )
   6041 
   6042 (dni fbnolr
   6043      "float cclr branch never"
   6044      ((UNIT B01) (FR500-MAJOR B-3) (FR550-MAJOR B-3)
   6045       (FR400-MAJOR B-3) (FR450-MAJOR B-3) FR-ACCESS)
   6046      "fbnolr$pack$hint_not_taken"
   6047      (+ pack FCC_nev (FCCi_2-null) OP_0E hint_not_taken OPE3_06 (ccond-null) (s12-null))
   6048      (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
   6049      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6050       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6051 )
   6052 
   6053 (conditional-branch-cclr fb eq  F OP_0E OPE3_06 Feq  FR-ACCESS "float cclr branch equal")
   6054 (conditional-branch-cclr fb ne  F OP_0E OPE3_06 Fne  FR-ACCESS "float cclr branch not equal")
   6055 (conditional-branch-cclr fb lg  F OP_0E OPE3_06 Flg  FR-ACCESS "float branch less or greater")
   6056 (conditional-branch-cclr fb ue  F OP_0E OPE3_06 Fue  FR-ACCESS "float branch unordered or equal")
   6057 (conditional-branch-cclr fb ul  F OP_0E OPE3_06 Ful  FR-ACCESS "float branch unordered or less")
   6058 (conditional-branch-cclr fb ge  F OP_0E OPE3_06 Fge  FR-ACCESS "float branch greater or equal")
   6059 (conditional-branch-cclr fb lt  F OP_0E OPE3_06 Flt  FR-ACCESS "float branch less")
   6060 (conditional-branch-cclr fb uge F OP_0E OPE3_06 Fuge FR-ACCESS "float branch unordered, greater, equal")
   6061 (conditional-branch-cclr fb ug  F OP_0E OPE3_06 Fug  FR-ACCESS "float branch unordered or greater")
   6062 (conditional-branch-cclr fb le  F OP_0E OPE3_06 Fle  FR-ACCESS "float branch less or equal")
   6063 (conditional-branch-cclr fb gt  F OP_0E OPE3_06 Fgt  FR-ACCESS "float branch greater")
   6064 (conditional-branch-cclr fb ule F OP_0E OPE3_06 Fule FR-ACCESS "float branch unordered, less or equal")
   6065 (conditional-branch-cclr fb u   F OP_0E OPE3_06 Fu   FR-ACCESS "float branch unordered")
   6066 (conditional-branch-cclr fb o   F OP_0E OPE3_06 Fo   FR-ACCESS "float branch ordered")
   6067 
   6068 (define-pmacro (conditional-branch-ctrlr prefix cc i-f op ope cond attr comment)
   6069   (dni (.sym prefix cc lr)
   6070        (comment)
   6071        ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
   6072 	(FR400-MAJOR B-2) (FR450-MAJOR B-2) attr)
   6073        (.str (.sym prefix cc lr) "$pack $" i-f "CCi_2,$ccond,$hint")
   6074        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op hint ope ccond (s12-null))
   6075        (sequence ()
   6076 		 (c-call VOID "@cpu@_model_branch" (spr-lr) hint)
   6077 		 (ctrlr-branch-semantics (cond (.sym i-f CCi_2)) ccond))
   6078        ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6079 	(fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6080   )
   6081 )
   6082 
   6083 (dni bcralr
   6084      "integer ctrlr branch always"
   6085      ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
   6086       (FR400-MAJOR B-2) (FR450-MAJOR B-2))
   6087      "bcralr$pack $ccond$hint_taken"
   6088      (+ pack ICC_ra (ICCi_2-null) OP_0E hint_taken OPE3_03 ccond (s12-null))
   6089      (sequence ()
   6090 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
   6091 	       (ctrlr-branch-semantics (const BI 1) ccond))
   6092      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6093       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6094 )
   6095 
   6096 (dni bcnolr
   6097      "integer ctrlr branch never"
   6098      ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
   6099       (FR400-MAJOR B-2) (FR450-MAJOR B-2))
   6100      "bcnolr$pack$hint_not_taken"
   6101      (+ pack ICC_nev (ICCi_2-null) OP_0E hint_not_taken OPE3_03 (ccond-null) (s12-null))
   6102      (sequence ()
   6103 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
   6104 	       (ctrlr-branch-semantics (const BI 0) ccond))
   6105      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6106       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6107 )
   6108 
   6109 (conditional-branch-ctrlr bc eq  I OP_0E OPE3_03 Ieq  NA "integer ctrlr branch equal")
   6110 (conditional-branch-ctrlr bc ne  I OP_0E OPE3_03 Ine  NA "integer ctrlr branch not equal")
   6111 (conditional-branch-ctrlr bc le  I OP_0E OPE3_03 Ile  NA "integer ctrlr branch less equal")
   6112 (conditional-branch-ctrlr bc gt  I OP_0E OPE3_03 Igt  NA "integer ctrlr branch greater")
   6113 (conditional-branch-ctrlr bc lt  I OP_0E OPE3_03 Ilt  NA "integer ctrlr branch less")
   6114 (conditional-branch-ctrlr bc ge  I OP_0E OPE3_03 Ige  NA "integer ctrlr branch greater equal")
   6115 (conditional-branch-ctrlr bc ls  I OP_0E OPE3_03 Ils  NA "integer ctrlr branch less equal unsigned")
   6116 (conditional-branch-ctrlr bc hi  I OP_0E OPE3_03 Ihi  NA "integer ctrlr branch greater unsigned")
   6117 (conditional-branch-ctrlr bc c   I OP_0E OPE3_03 Ic   NA "integer ctrlr branch carry set")
   6118 (conditional-branch-ctrlr bc nc  I OP_0E OPE3_03 Inc  NA "integer ctrlr branch carry clear")
   6119 (conditional-branch-ctrlr bc n   I OP_0E OPE3_03 In   NA "integer ctrlr branch negative")
   6120 (conditional-branch-ctrlr bc p   I OP_0E OPE3_03 Ip   NA "integer ctrlr branch positive")
   6121 (conditional-branch-ctrlr bc v   I OP_0E OPE3_03 Iv   NA "integer ctrlr branch overflow set")
   6122 (conditional-branch-ctrlr bc nv  I OP_0E OPE3_03 Inv  NA "integer ctrlr branch overflow clear")
   6123 
   6124 (dni fcbralr
   6125      "float ctrlr branch always"
   6126      ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
   6127       (FR400-MAJOR B-2) (FR450-MAJOR B-2) FR-ACCESS)
   6128      "fcbralr$pack $ccond$hint_taken"
   6129      (+ pack FCC_ra (FCCi_2-null) OP_0E hint_taken OPE3_07 ccond (s12-null))
   6130      (sequence ()
   6131 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_taken)
   6132 	       (ctrlr-branch-semantics (const BI 1) ccond))
   6133      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6134       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6135 )
   6136 
   6137 (dni fcbnolr
   6138      "float ctrlr branch never"
   6139      ((UNIT B0) (FR500-MAJOR B-2) (FR550-MAJOR B-2)
   6140       (FR400-MAJOR B-2) (FR450-MAJOR B-2) FR-ACCESS)
   6141      "fcbnolr$pack$hint_not_taken"
   6142      (+ pack FCC_nev (FCCi_2-null) OP_0E hint_not_taken OPE3_07 (ccond-null) (s12-null))
   6143      (sequence ()
   6144 	       (c-call VOID "@cpu@_model_branch" (spr-lr) hint_not_taken)
   6145 	       (ctrlr-branch-semantics (const BI 0) ccond))
   6146      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6147       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6148 )
   6149 
   6150 (conditional-branch-ctrlr fcb eq  F OP_0E OPE3_07 Feq  FR-ACCESS "float cclr branch equal")
   6151 (conditional-branch-ctrlr fcb ne  F OP_0E OPE3_07 Fne  FR-ACCESS "float cclr branch not equal")
   6152 (conditional-branch-ctrlr fcb lg  F OP_0E OPE3_07 Flg  FR-ACCESS "float branch less or greater")
   6153 (conditional-branch-ctrlr fcb ue  F OP_0E OPE3_07 Fue  FR-ACCESS "float branch unordered or equal")
   6154 (conditional-branch-ctrlr fcb ul  F OP_0E OPE3_07 Ful  FR-ACCESS "float branch unordered or less")
   6155 (conditional-branch-ctrlr fcb ge  F OP_0E OPE3_07 Fge  FR-ACCESS "float branch greater or equal")
   6156 (conditional-branch-ctrlr fcb lt  F OP_0E OPE3_07 Flt  FR-ACCESS "float branch less")
   6157 (conditional-branch-ctrlr fcb uge F OP_0E OPE3_07 Fuge FR-ACCESS "float branch unordered, greater, equal")
   6158 (conditional-branch-ctrlr fcb ug  F OP_0E OPE3_07 Fug  FR-ACCESS "float branch unordered or greater")
   6159 (conditional-branch-ctrlr fcb le  F OP_0E OPE3_07 Fle  FR-ACCESS "float branch less or equal")
   6160 (conditional-branch-ctrlr fcb gt  F OP_0E OPE3_07 Fgt  FR-ACCESS "float branch greater")
   6161 (conditional-branch-ctrlr fcb ule F OP_0E OPE3_07 Fule FR-ACCESS "float branch unordered, less or equal")
   6162 (conditional-branch-ctrlr fcb u   F OP_0E OPE3_07 Fu   FR-ACCESS "float branch unordered")
   6163 (conditional-branch-ctrlr fcb o   F OP_0E OPE3_07 Fo   FR-ACCESS "float branch ordered")
   6164 
   6165 (define-pmacro (jump-and-link-semantics base offset LI)
   6166   (sequence ()
   6167 	    (if (eq LI 1)
   6168 		(c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1))
   6169 	    ; Target address gets aligned here
   6170 	    (set pc (and (add base offset) #xfffffffc))
   6171 	    (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
   6172 )
   6173 
   6174 (dni jmpl
   6175      "jump and link"
   6176      ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
   6177       (FR400-MAJOR I-5) (FR450-MAJOR I-5))
   6178      "jmpl$pack @($GRi,$GRj)"
   6179      (+ pack (misc-null-1) (LI-off) OP_0C GRi (misc-null-2) GRj)
   6180      (jump-and-link-semantics GRi GRj LI)
   6181      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6182       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6183 )
   6184 
   6185 (dann callann "call annotation" SI "call_annotation" "at")
   6186 
   6187 (dni calll
   6188      "call and link"
   6189      ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
   6190       (FR400-MAJOR I-5) (FR450-MAJOR I-5))
   6191      "calll$pack $callann($GRi,$GRj)"
   6192      (+ pack (misc-null-1) (LI-on) OP_0C GRi (misc-null-2) GRj)
   6193      (jump-and-link-semantics GRi GRj LI)
   6194      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6195       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6196 )
   6197 
   6198 (dni jmpil
   6199      "jump immediate and link"
   6200      ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
   6201       (FR400-MAJOR I-5) (FR450-MAJOR I-5))
   6202      "jmpil$pack @($GRi,$s12)"
   6203      (+ pack (misc-null-1) (LI-off) OP_0D GRi s12)
   6204      (jump-and-link-semantics GRi s12 LI)
   6205      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6206       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6207 )
   6208 
   6209 (dni callil
   6210      "call immediate and link"
   6211      ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
   6212       (FR400-MAJOR I-5) (FR450-MAJOR I-5))
   6213      "callil$pack @($GRi,$s12)"
   6214      (+ pack (misc-null-1) (LI-on) OP_0D GRi s12)
   6215      (jump-and-link-semantics GRi s12 LI)
   6216      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6217       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6218 )
   6219 
   6220 (dni call
   6221      "call and link"
   6222      ((UNIT B0) (FR500-MAJOR B-4) (FR550-MAJOR B-4)
   6223       (FR400-MAJOR B-4) (FR450-MAJOR B-4))
   6224      "call$pack $label24"
   6225      (+ pack OP_0F label24)
   6226      (sequence ()
   6227 	       (c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1)
   6228 	       (set pc label24)
   6229 	       (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
   6230      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6231       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6232 )
   6233 
   6234 (dni rett
   6235     "return from trap"
   6236     ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   6237      (FR400-MAJOR C-2) (FR450-MAJOR C-2) PRIVILEGED)
   6238     "rett$pack $debug"
   6239     (+ pack (misc-null-1) debug OP_05 (rs-null) (s12-null))
   6240     ; frv_rett handles operating vs user mode
   6241     (sequence ()
   6242 	      (set pc (c-call UWI "frv_rett" pc debug))
   6243 	      (c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
   6244     ()
   6245 )
   6246 
   6247 (dni rei
   6248      "run exception instruction"
   6249      ((UNIT C) (FR500-MAJOR C-1) (MACH frv) PRIVILEGED)
   6250      "rei$pack $eir"
   6251      (+ pack (rd-null) OP_37 eir (s12-null))
   6252      (nop) ; for now
   6253      ()
   6254 )
   6255 
   6256 (define-pmacro (trap-semantics cond base offset)
   6257   (if cond
   6258       (sequence ()
   6259 		; This is defered to frv_itrap because for the breakpoint
   6260 		; case we want to change as little of the machine state as
   6261 		; possible.
   6262 		;
   6263 		; PCSR=PC
   6264 		; PSR.PS=PSR.S
   6265 		; PSR.ET=0
   6266 		; if PSR.ESR==1
   6267 		;   SR0 through SR3=GR4 through GR7
   6268 		; TBR.TT=0x80 + ((GRi + s12) & 0x7f)
   6269 		; PC=TBR
   6270 		; We still should indicate what is modified by this insn.
   6271 		(clobber (spr-pcsr))
   6272 		(clobber psr_ps)
   6273 		(clobber psr_et)
   6274 		(clobber tbr_tt)
   6275 		(if (ne psr_esr (const 0))
   6276 		    (sequence ()
   6277 			      (clobber (spr-sr0))
   6278 			      (clobber (spr-sr1))
   6279 			      (clobber (spr-sr2))
   6280 			      (clobber (spr-sr3))))
   6281 		; frv_itrap handles operating vs user mode
   6282 		(c-call VOID "frv_itrap" pc base offset)))
   6283 )
   6284 
   6285 (define-pmacro (trap-r prefix cc i-f op ope cond attr comment)
   6286   (dni (.sym prefix cc)
   6287        (comment)
   6288        ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6289 	(FR400-MAJOR C-1) (FR450-MAJOR C-1) attr)
   6290        (.str (.sym prefix cc) "$pack $" i-f "CCi_2,$GRi,$GRj")
   6291        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op GRi (misc-null-3) ope GRj)
   6292        (trap-semantics (cond (.sym i-f CCi_2)) GRi GRj)
   6293        ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6294 	(fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6295   )
   6296 )
   6297 
   6298 (dni tra
   6299      "integer trap always"
   6300      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6301       (FR400-MAJOR C-1) (FR450-MAJOR C-1))
   6302      "tra$pack $GRi,$GRj"
   6303      (+ pack ICC_ra (ICCi_2-null) OP_04 GRi (misc-null-3) OPE4_0 GRj)
   6304      (trap-semantics (const BI 1) GRi GRj)
   6305      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6306       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6307 )
   6308 
   6309 (dni tno
   6310      "integer trap never"
   6311      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6312       (FR400-MAJOR C-1) (FR450-MAJOR C-1))
   6313      "tno$pack"
   6314      (+ pack ICC_nev (ICCi_2-null) OP_04 (GRi-null) (misc-null-3) OPE4_0 (GRj-null))
   6315      (trap-semantics (const BI 0) GRi GRj)
   6316      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6317       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6318 )
   6319 
   6320 (trap-r t eq  I OP_04 OPE4_0 Ieq  NA "integer trap equal")
   6321 (trap-r t ne  I OP_04 OPE4_0 Ine  NA "integer trap not equal")
   6322 (trap-r t le  I OP_04 OPE4_0 Ile  NA "integer trap less or equal")
   6323 (trap-r t gt  I OP_04 OPE4_0 Igt  NA "integer trap greater")
   6324 (trap-r t lt  I OP_04 OPE4_0 Ilt  NA "integer trap less")
   6325 (trap-r t ge  I OP_04 OPE4_0 Ige  NA "integer trap greater or equal")
   6326 (trap-r t ls  I OP_04 OPE4_0 Ils  NA "integer trap less or equal unsigned")
   6327 (trap-r t hi  I OP_04 OPE4_0 Ihi  NA "integer trap greater unsigned")
   6328 (trap-r t c   I OP_04 OPE4_0 Ic   NA "integer trap carry set")
   6329 (trap-r t nc  I OP_04 OPE4_0 Inc  NA "integer trap carry clear")
   6330 (trap-r t n   I OP_04 OPE4_0 In   NA "integer trap negative")
   6331 (trap-r t p   I OP_04 OPE4_0 Ip   NA "integer trap positive")
   6332 (trap-r t v   I OP_04 OPE4_0 Iv   NA "integer trap overflow set")
   6333 (trap-r t nv  I OP_04 OPE4_0 Inv  NA "integer trap overflow clear")
   6334 
   6335 (dni ftra
   6336      "float trap always"
   6337      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6338       (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
   6339      "ftra$pack $GRi,$GRj"
   6340      (+ pack FCC_ra (FCCi_2-null) OP_04 GRi (misc-null-3) OPE4_1 GRj)
   6341      (trap-semantics (const BI 1) GRi GRj)
   6342      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6343       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6344 )
   6345 
   6346 (dni ftno
   6347      "flost trap never"
   6348      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6349       (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
   6350      "ftno$pack"
   6351      (+ pack FCC_nev (FCCi_2-null) OP_04 (GRi-null) (misc-null-3) OPE4_1 (GRj-null))
   6352      (trap-semantics (const BI 0) GRi GRj)
   6353      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6354       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6355 )
   6356 
   6357 (trap-r ft ne  F OP_04 OPE4_1 Fne  FR-ACCESS "float trap not equal")
   6358 (trap-r ft eq  F OP_04 OPE4_1 Feq  FR-ACCESS "float trap equal")
   6359 (trap-r ft lg  F OP_04 OPE4_1 Flg  FR-ACCESS "float trap greater or less")
   6360 (trap-r ft ue  F OP_04 OPE4_1 Fue  FR-ACCESS "float trap unordered or equal")
   6361 (trap-r ft ul  F OP_04 OPE4_1 Ful  FR-ACCESS "float trap unordered or less")
   6362 (trap-r ft ge  F OP_04 OPE4_1 Fge  FR-ACCESS "float trap greater or equal")
   6363 (trap-r ft lt  F OP_04 OPE4_1 Flt  FR-ACCESS "float trap less")
   6364 (trap-r ft uge F OP_04 OPE4_1 Fuge FR-ACCESS "float trap unordered greater or equal")
   6365 (trap-r ft ug  F OP_04 OPE4_1 Fug  FR-ACCESS "float trap unordered or greater")
   6366 (trap-r ft le  F OP_04 OPE4_1 Fle  FR-ACCESS "float trap less or equal")
   6367 (trap-r ft gt  F OP_04 OPE4_1 Fgt  FR-ACCESS "float trap greater")
   6368 (trap-r ft ule F OP_04 OPE4_1 Fule FR-ACCESS "float trap unordered less or equal")
   6369 (trap-r ft u   F OP_04 OPE4_1 Fu   FR-ACCESS "float trap unordered")
   6370 (trap-r ft o   F OP_04 OPE4_1 Fo   FR-ACCESS "float trap ordered")
   6371 
   6372 (define-pmacro (trap-immed prefix cc i-f op cond attr comment)
   6373   (dni (.sym prefix cc)
   6374        (comment)
   6375        ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6376 	(FR400-MAJOR C-1) (FR450-MAJOR C-1) attr)
   6377        (.str (.sym prefix cc) "$pack $" i-f "CCi_2,$GRi,$s12")
   6378        (+ pack (.sym i-f CC_ cc) (.sym i-f CCi_2) op GRi s12)
   6379        (trap-semantics (cond (.sym i-f CCi_2)) GRi s12)
   6380        ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6381 	(fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6382   )
   6383 )
   6384 
   6385 (dni tira
   6386      "integer trap always"
   6387      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6388       (FR400-MAJOR C-1) (FR450-MAJOR C-1))
   6389      "tira$pack $GRi,$s12"
   6390      (+ pack ICC_ra (ICCi_2-null) OP_1C GRi s12)
   6391      (trap-semantics (const BI 1) GRi s12)
   6392      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6393       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6394 )
   6395 
   6396 (dni tino
   6397      "integer trap never"
   6398      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6399       (FR400-MAJOR C-1) (FR450-MAJOR C-1))
   6400      "tino$pack"
   6401      (+ pack ICC_nev (ICCi_2-null) OP_1C (GRi-null) (s12-null))
   6402      (trap-semantics (const BI 0) GRi s12)
   6403      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6404       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6405 )
   6406 
   6407 (trap-immed ti eq  I OP_1C Ieq  NA "integer trap equal")
   6408 (trap-immed ti ne  I OP_1C Ine  NA "integer trap not equal")
   6409 (trap-immed ti le  I OP_1C Ile  NA "integer trap less or equal")
   6410 (trap-immed ti gt  I OP_1C Igt  NA "integer trap greater")
   6411 (trap-immed ti lt  I OP_1C Ilt  NA "integer trap less")
   6412 (trap-immed ti ge  I OP_1C Ige  NA "integer trap greater or equal")
   6413 (trap-immed ti ls  I OP_1C Ils  NA "integer trap less or equal unsigned")
   6414 (trap-immed ti hi  I OP_1C Ihi  NA "integer trap greater unsigned")
   6415 (trap-immed ti c   I OP_1C Ic   NA "integer trap carry set")
   6416 (trap-immed ti nc  I OP_1C Inc  NA "integer trap carry clear")
   6417 (trap-immed ti n   I OP_1C In   NA "integer trap negative")
   6418 (trap-immed ti p   I OP_1C Ip   NA "integer trap positive")
   6419 (trap-immed ti v   I OP_1C Iv   NA "integer trap overflow set")
   6420 (trap-immed ti nv  I OP_1C Inv  NA "integer trap overflow clear")
   6421 
   6422 (dni ftira
   6423      "float trap always"
   6424      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6425       (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
   6426      "ftira$pack $GRi,$s12"
   6427      (+ pack FCC_ra (ICCi_2-null) OP_1D GRi s12)
   6428      (trap-semantics (const BI 1) GRi s12)
   6429      ((fr400 (unit u-trap))
   6430       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6431 )
   6432 
   6433 (dni ftino
   6434      "float trap never"
   6435      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6436       (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
   6437      "ftino$pack"
   6438      (+ pack FCC_nev (FCCi_2-null) OP_1D (GRi-null) (s12-null))
   6439      (trap-semantics (const BI 0) GRi s12)
   6440      ((fr400 (unit u-trap)) (fr450 (unit u-trap))
   6441       (fr500 (unit u-trap)) (fr550 (unit u-trap)))
   6442 )
   6443 
   6444 (trap-immed fti ne  F OP_1D Fne  FR-ACCESS "float trap not equal")
   6445 (trap-immed fti eq  F OP_1D Feq  FR-ACCESS "float trap equal")
   6446 (trap-immed fti lg  F OP_1D Flg  FR-ACCESS "float trap greater or less")
   6447 (trap-immed fti ue  F OP_1D Fue  FR-ACCESS "float trap unordered or equal")
   6448 (trap-immed fti ul  F OP_1D Ful  FR-ACCESS "float trap unordered or less")
   6449 (trap-immed fti ge  F OP_1D Fge  FR-ACCESS "float trap greater or equal")
   6450 (trap-immed fti lt  F OP_1D Flt  FR-ACCESS "float trap less")
   6451 (trap-immed fti uge F OP_1D Fuge FR-ACCESS "float trap unordered greater or equal")
   6452 (trap-immed fti ug  F OP_1D Fug  FR-ACCESS "float trap unordered or greater")
   6453 (trap-immed fti le  F OP_1D Fle  FR-ACCESS "float trap less or equal")
   6454 (trap-immed fti gt  F OP_1D Fgt  FR-ACCESS "float trap greater")
   6455 (trap-immed fti ule F OP_1D Fule FR-ACCESS "float trap unordered less or equal")
   6456 (trap-immed fti u   F OP_1D Fu   FR-ACCESS "float trap unordered")
   6457 (trap-immed fti o   F OP_1D Fo   FR-ACCESS "float trap ordered")
   6458 
   6459 (dni break
   6460      "break trap"
   6461      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6462       (FR400-MAJOR C-1) (FR450-MAJOR C-1))
   6463      "break$pack"
   6464      (+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_3 (GRj-null))
   6465      (sequence ()
   6466 	       ; This is defered to frv_break because for the breakpoint
   6467 	       ; case we want to change as little of the machine state as
   6468 	       ; possible.
   6469 	       ;
   6470 	       ; BPCSR=PC
   6471 	       ; BPSR.BS=PSR.S
   6472 	       ; BPSR.BET=PSR.ET
   6473 	       ; PSR.S=1
   6474 	       ; PSR.ET=0
   6475 	       ; TBR.TT=0xff
   6476 	       ; PC=TBR
   6477 	       ; We still should indicate what is modified by this insn.
   6478 	       (clobber (spr-bpcsr))
   6479 	       (clobber bpsr_bs)
   6480 	       (clobber bpsr_bet)
   6481 	       (clobber psr_s)
   6482 	       (clobber psr_et)
   6483 	       (clobber tbr_tt)
   6484 	       (c-call VOID "frv_break"))
   6485      ()
   6486 )
   6487 
   6488 (dni mtrap
   6489      "media trap"
   6490      ((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
   6491       (FR400-MAJOR C-1) (FR450-MAJOR C-1) FR-ACCESS)
   6492      "mtrap$pack"
   6493      (+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_2 (GRj-null))
   6494      (c-call VOID "frv_mtrap")
   6495      ()
   6496 )
   6497 
   6498 (define-pmacro (condition-code-logic name operation ope comment)
   6499   (dni name
   6500        (comment)
   6501        ((UNIT B01) (FR500-MAJOR B-6) (FR550-MAJOR B-6)
   6502 	(FR400-MAJOR B-6) (FR450-MAJOR B-6))
   6503        (.str name "$pack $CRi,$CRj,$CRk")
   6504        (+ pack (misc-null-6) CRk OP_0A (misc-null-7) CRi ope (misc-null-8) CRj)
   6505        (set CRk (c-call UQI "@cpu@_cr_logic" operation CRi CRj))
   6506        ()
   6507   )
   6508 )
   6509 (define-pmacro (op-andcr)   0)
   6510 (define-pmacro (op-orcr)    1)
   6511 (define-pmacro (op-xorcr)   2)
   6512 (define-pmacro (op-nandcr)  3)
   6513 (define-pmacro (op-norcr)   4)
   6514 (define-pmacro (op-andncr)  5)
   6515 (define-pmacro (op-orncr)   6)
   6516 (define-pmacro (op-nandncr) 7)
   6517 (define-pmacro (op-norncr)  8)
   6518 
   6519 (define-pmacro (cr-true)  3)
   6520 (define-pmacro (cr-false) 2)
   6521 (define-pmacro (cr-undefined) 0)
   6522 
   6523 (condition-code-logic andcr   (op-andcr)   OPE1_08 "and   condition code regs")
   6524 (condition-code-logic orcr    (op-orcr)    OPE1_09 "or    condition code regs")
   6525 (condition-code-logic xorcr   (op-xorcr)   OPE1_0A "xor   condition code regs")
   6526 (condition-code-logic nandcr  (op-nandcr)  OPE1_0C "nand  condition code regs")
   6527 (condition-code-logic norcr   (op-norcr)   OPE1_0D "nor   condition code regs")
   6528 (condition-code-logic andncr  (op-andncr)  OPE1_10 "andn  condition code regs")
   6529 (condition-code-logic orncr   (op-orncr)   OPE1_11 "orn   condition code regs")
   6530 (condition-code-logic nandncr (op-nandncr) OPE1_14 "nandn condition code regs")
   6531 (condition-code-logic norncr  (op-norncr)  OPE1_15 "norn  condition code regs")
   6532 
   6533 (dni notcr
   6534      ("not cccr register")
   6535      ((UNIT B01) (FR500-MAJOR B-6) (FR550-MAJOR B-6)
   6536       (FR400-MAJOR B-6) (FR450-MAJOR B-6))
   6537      (.str notcr "$pack $CRj,$CRk")
   6538      (+ pack (misc-null-6) CRk OP_0A (rs-null) OPE1_0B (misc-null-8) CRj)
   6539      (set CRk (xor CRj 1))
   6540      ()
   6541 )
   6542 
   6543 (define-pmacro (check-semantics cond cr)
   6544   (if cond (set cr (cr-true)) (set cr (cr-false)))
   6545 )
   6546 
   6547 (define-pmacro (check-int-condition-code prefix cc op cond comment)
   6548   (dni (.sym prefix cc)
   6549        (comment)
   6550        ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6551 	(FR400-MAJOR B-5) (FR450-MAJOR B-5))
   6552        (.str (.sym prefix cc) "$pack $ICCi_3,$CRj_int")
   6553        (+ pack (.sym ICC_ cc) CRj_int op (misc-null-5) ICCi_3)
   6554        (check-semantics (cond ICCi_3) CRj_int)
   6555        ((fr400 (unit u-check)) (fr450 (unit u-check))
   6556 	(fr500 (unit u-check)) (fr550 (unit u-check)))
   6557   )
   6558 )
   6559 
   6560 (dni ckra
   6561      "check integer cc always"
   6562      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6563       (FR400-MAJOR B-5) (FR450-MAJOR B-5))
   6564      "ckra$pack $CRj_int"
   6565      (+ pack ICC_ra CRj_int OP_08 (misc-null-5) (ICCi_3-null))
   6566      (check-semantics (const BI 1) CRj_int)
   6567      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6568       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6569 )
   6570 
   6571 (dni ckno
   6572      "check integer cc never"
   6573      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6574       (FR400-MAJOR B-5) (FR450-MAJOR B-5))
   6575      "ckno$pack $CRj_int"
   6576      (+ pack ICC_nev CRj_int OP_08 (misc-null-5) (ICCi_3-null))
   6577      (check-semantics (const BI 0) CRj_int)
   6578      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6579       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6580 )
   6581 
   6582 (check-int-condition-code ck eq  OP_08 Ieq  "check integer cc equal")
   6583 (check-int-condition-code ck ne  OP_08 Ine  "check integer cc not equal")
   6584 (check-int-condition-code ck le  OP_08 Ile  "check integer cc less or equal")
   6585 (check-int-condition-code ck gt  OP_08 Igt  "check integer cc greater")
   6586 (check-int-condition-code ck lt  OP_08 Ilt  "check integer cc less")
   6587 (check-int-condition-code ck ge  OP_08 Ige  "check integer cc greater or equal")
   6588 (check-int-condition-code ck ls  OP_08 Ils  "check integer cc less or equal unsigned")
   6589 (check-int-condition-code ck hi  OP_08 Ihi  "check integer cc greater unsigned")
   6590 (check-int-condition-code ck c   OP_08 Ic   "check integer cc carry set")
   6591 (check-int-condition-code ck nc  OP_08 Inc  "check integer cc carry clear")
   6592 (check-int-condition-code ck n   OP_08 In   "check integer cc negative")
   6593 (check-int-condition-code ck p   OP_08 Ip   "check integer cc positive")
   6594 (check-int-condition-code ck v   OP_08 Iv   "check integer cc overflow set")
   6595 (check-int-condition-code ck nv  OP_08 Inv  "check integer cc overflow clear")
   6596 
   6597 (define-pmacro (check-float-condition-code prefix cc op cond comment)
   6598   (dni (.sym prefix cc)
   6599        (comment)
   6600        ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6601 	(FR400-MAJOR B-5) (FR450-MAJOR B-5) FR-ACCESS)
   6602        (.str (.sym prefix cc) "$pack $FCCi_3,$CRj_float")
   6603        (+ pack (.sym FCC_ cc) CRj_float op (misc-null-5) FCCi_3)
   6604        (check-semantics (cond FCCi_3) CRj_float)
   6605        ((fr400 (unit u-check)) (fr450 (unit u-check))
   6606 	(fr500 (unit u-check)) (fr550 (unit u-check)))
   6607   )
   6608 )
   6609 
   6610 (dni fckra
   6611      "check float cc always"
   6612      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6613       (FR400-MAJOR B-5) (FR450-MAJOR B-5) FR-ACCESS)
   6614      "fckra$pack $CRj_float"
   6615      (+ pack FCC_ra CRj_float OP_09 (misc-null-5) FCCi_3)
   6616      (check-semantics (const BI 1) CRj_float)
   6617      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6618       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6619 )
   6620 
   6621 (dni fckno
   6622      "check float cc never"
   6623      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6624       (FR400-MAJOR B-5) (FR450-MAJOR B-5) FR-ACCESS)
   6625      "fckno$pack $CRj_float"
   6626      (+ pack FCC_nev CRj_float OP_09 (misc-null-5) FCCi_3)
   6627      (check-semantics (const BI 0) CRj_float)
   6628      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6629       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6630 )
   6631 
   6632 (check-float-condition-code fck ne  OP_09 Fne  "check float cc not equal")
   6633 (check-float-condition-code fck eq  OP_09 Feq  "check float cc equal")
   6634 (check-float-condition-code fck lg  OP_09 Flg  "check float cc greater or less")
   6635 (check-float-condition-code fck ue  OP_09 Fue  "check float cc unordered or equal")
   6636 (check-float-condition-code fck ul  OP_09 Ful  "check float cc unordered or less")
   6637 (check-float-condition-code fck ge  OP_09 Fge  "check float cc greater or equal")
   6638 (check-float-condition-code fck lt  OP_09 Flt  "check float cc less")
   6639 (check-float-condition-code fck uge OP_09 Fuge "check float cc unordered greater or equal")
   6640 (check-float-condition-code fck ug  OP_09 Fug  "check float cc unordered or greater")
   6641 (check-float-condition-code fck le  OP_09 Fle  "check float cc less or equal")
   6642 (check-float-condition-code fck gt  OP_09 Fgt  "check float cc greater")
   6643 (check-float-condition-code fck ule OP_09 Fule "check float cc unordered less or equal")
   6644 (check-float-condition-code fck u   OP_09 Fu   "check float cc unordered")
   6645 (check-float-condition-code fck o   OP_09 Fo   "check float cc ordered")
   6646 
   6647 (define-pmacro (conditional-check-int-condition-code prefix cc op ope test comment)
   6648   (dni (.sym prefix cc)
   6649        (comment)
   6650        ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6651 	(FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL)
   6652        (.str (.sym prefix cc) "$pack $ICCi_3,$CRj_int,$CCi,$cond")
   6653        (+ pack (.sym ICC_ cc) CRj_int op (rs-null) CCi cond ope
   6654 	  (misc-null-9) ICCi_3)
   6655        (if (eq CCi (or cond 2))
   6656 	   (check-semantics (test ICCi_3) CRj_int)
   6657 	   (set CRj_int (cr-undefined)))
   6658        ((fr400 (unit u-check)) (fr450 (unit u-check))
   6659 	(fr500 (unit u-check)) (fr550 (unit u-check)))
   6660   )
   6661 )
   6662 
   6663 (dni cckra
   6664      "conditional check integer cc always"
   6665      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6666       (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL)
   6667      "cckra$pack $CRj_int,$CCi,$cond"
   6668      (+ pack ICC_ra CRj_int OP_6A (rs-null) CCi cond OPE4_0
   6669 	(misc-null-9) (ICCi_3-null))
   6670      (if (eq CCi (or cond 2))
   6671 	 (check-semantics (const BI 1) CRj_int)
   6672 	 (set CRj_int (cr-undefined)))
   6673      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6674       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6675 )
   6676 
   6677 (dni cckno
   6678      "conditional check integer cc never"
   6679      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6680       (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL)
   6681      "cckno$pack $CRj_int,$CCi,$cond"
   6682      (+ pack ICC_nev CRj_int OP_6A (rs-null) CCi cond OPE4_0
   6683 	(misc-null-9) (ICCi_3-null))
   6684      (if (eq CCi (or cond 2))
   6685 	 (check-semantics (const BI 0) CRj_int)
   6686 	 (set CRj_int (cr-undefined)))
   6687      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6688       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6689 )
   6690 
   6691 (conditional-check-int-condition-code cck eq  OP_6A OPE4_0 Ieq  "check integer cc equal")
   6692 (conditional-check-int-condition-code cck ne  OP_6A OPE4_0 Ine  "check integer cc not equal")
   6693 (conditional-check-int-condition-code cck le  OP_6A OPE4_0 Ile  "check integer cc less or equal")
   6694 (conditional-check-int-condition-code cck gt  OP_6A OPE4_0 Igt  "check integer cc greater")
   6695 (conditional-check-int-condition-code cck lt  OP_6A OPE4_0 Ilt  "check integer cc less")
   6696 (conditional-check-int-condition-code cck ge  OP_6A OPE4_0 Ige  "check integer cc greater or equal")
   6697 (conditional-check-int-condition-code cck ls  OP_6A OPE4_0 Ils  "check integer cc less or equal unsigned")
   6698 (conditional-check-int-condition-code cck hi  OP_6A OPE4_0 Ihi  "check integer cc greater unsigned")
   6699 (conditional-check-int-condition-code cck c   OP_6A OPE4_0 Ic   "check integer cc carry set")
   6700 (conditional-check-int-condition-code cck nc  OP_6A OPE4_0 Inc  "check integer cc carry clear")
   6701 (conditional-check-int-condition-code cck n   OP_6A OPE4_0 In   "check integer cc negative")
   6702 (conditional-check-int-condition-code cck p   OP_6A OPE4_0 Ip   "check integer cc positive")
   6703 (conditional-check-int-condition-code cck v   OP_6A OPE4_0 Iv   "check integer cc overflow set")
   6704 (conditional-check-int-condition-code cck nv  OP_6A OPE4_0 Inv  "check integer cc overflow clear")
   6705 
   6706 (define-pmacro (conditional-check-float-condition-code prefix cc op ope test comment)
   6707   (dni (.sym prefix cc)
   6708        (comment)
   6709        ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6710 	(FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL FR-ACCESS)
   6711        (.str (.sym prefix cc) "$pack $FCCi_3,$CRj_float,$CCi,$cond")
   6712        (+ pack (.sym FCC_ cc) CRj_float op (rs-null) CCi cond ope
   6713 	  (misc-null-9) FCCi_3)
   6714        (if (eq CCi (or cond 2))
   6715 	   (check-semantics (test FCCi_3) CRj_float)
   6716 	   (set CRj_float (cr-undefined)))
   6717        ((fr400 (unit u-check)) (fr450 (unit u-check))
   6718 	(fr500 (unit u-check)) (fr550 (unit u-check)))
   6719   )
   6720 )
   6721 
   6722 (dni cfckra
   6723      "conditional check float cc always"
   6724      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6725       (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL FR-ACCESS)
   6726      "cfckra$pack $CRj_float,$CCi,$cond"
   6727      (+ pack FCC_ra CRj_float OP_6A (rs-null) CCi cond OPE4_1
   6728 	(misc-null-9) (FCCi_3-null))
   6729      (if (eq CCi (or cond 2))
   6730 	 (check-semantics (const BI 1) CRj_float)
   6731 	 (set CRj_float (cr-undefined)))
   6732      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6733       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6734 )
   6735 
   6736 (dni cfckno
   6737      "conditional check float cc never"
   6738      ((UNIT B01) (FR500-MAJOR B-5) (FR550-MAJOR B-5)
   6739       (FR400-MAJOR B-5) (FR450-MAJOR B-5) CONDITIONAL FR-ACCESS)
   6740      "cfckno$pack $CRj_float,$CCi,$cond"
   6741      (+ pack FCC_nev CRj_float OP_6A (rs-null) CCi cond OPE4_1
   6742 	(misc-null-9) (FCCi_3-null))
   6743      (if (eq CCi (or cond 2))
   6744 	 (check-semantics (const BI 0) CRj_float)
   6745 	 (set CRj_float (cr-undefined)))
   6746      ((fr400 (unit u-check)) (fr450 (unit u-check))
   6747       (fr500 (unit u-check)) (fr550 (unit u-check)))
   6748 )
   6749 
   6750 (conditional-check-float-condition-code cfck ne  OP_6A OPE4_1 Fne  "check float cc not equal")
   6751 (conditional-check-float-condition-code cfck eq  OP_6A OPE4_1 Feq  "check float cc equal")
   6752 (conditional-check-float-condition-code cfck lg  OP_6A OPE4_1 Flg  "check float cc greater or less")
   6753 (conditional-check-float-condition-code cfck ue  OP_6A OPE4_1 Fue  "check float cc unordered or equal")
   6754 (conditional-check-float-condition-code cfck ul  OP_6A OPE4_1 Ful  "check float cc unordered or less")
   6755 (conditional-check-float-condition-code cfck ge  OP_6A OPE4_1 Fge  "check float cc greater or equal")
   6756 (conditional-check-float-condition-code cfck lt  OP_6A OPE4_1 Flt  "check float cc less")
   6757 (conditional-check-float-condition-code cfck uge OP_6A OPE4_1 Fuge "check float cc unordered greater or equal")
   6758 (conditional-check-float-condition-code cfck ug  OP_6A OPE4_1 Fug  "check float cc unordered or greater")
   6759 (conditional-check-float-condition-code cfck le  OP_6A OPE4_1 Fle  "check float cc less or equal")
   6760 (conditional-check-float-condition-code cfck gt  OP_6A OPE4_1 Fgt  "check float cc greater")
   6761 (conditional-check-float-condition-code cfck ule OP_6A OPE4_1 Fule "check float cc unordered less or equal")
   6762 (conditional-check-float-condition-code cfck u   OP_6A OPE4_1 Fu   "check float cc unordered")
   6763 (conditional-check-float-condition-code cfck o   OP_6A OPE4_1 Fo   "check float cc ordered")
   6764 
   6765 (dni cjmpl
   6766      "conditional jump and link"
   6767      ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
   6768       (FR400-MAJOR I-5) (FR450-MAJOR I-5) CONDITIONAL)
   6769      "cjmpl$pack @($GRi,$GRj),$CCi,$cond"
   6770      (+ pack (misc-null-1) (LI-off) OP_6A GRi CCi cond OPE4_2 GRj)
   6771      (if (eq CCi (or cond 2))
   6772 	 (jump-and-link-semantics GRi GRj LI))
   6773      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6774       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6775 )
   6776 
   6777 (dni ccalll
   6778      "conditional call and link"
   6779      ((UNIT I0) (FR500-MAJOR I-5) (FR550-MAJOR I-6)
   6780       (FR400-MAJOR I-5) (FR450-MAJOR I-5) CONDITIONAL)
   6781      "ccalll$pack @($GRi,$GRj),$CCi,$cond"
   6782      (+ pack (misc-null-1) (LI-on) OP_6A GRi CCi cond OPE4_2 GRj)
   6783      (if (eq CCi (or cond 2))
   6784 	 (jump-and-link-semantics GRi GRj LI))
   6785      ((fr400 (unit u-branch)) (fr450 (unit u-branch))
   6786       (fr500 (unit u-branch)) (fr550 (unit u-branch)))
   6787 )
   6788 
   6789 (define-pmacro (cache-invalidate name cache all op ope profile comment)
   6790   (dni name
   6791        (comment)
   6792        ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   6793 	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
   6794        (.str name "$pack @($GRi,$GRj)")
   6795        (+ pack (rd-null) op GRi ope GRj)
   6796        (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) all)
   6797        profile
   6798   )
   6799 )
   6800 
   6801 (cache-invalidate ici insn 0 OP_03 OPE1_38
   6802 		  ((fr400 (unit u-ici)) (fr450 (unit u-ici))
   6803 		   (fr500 (unit u-ici)) (fr550 (unit u-ici)))
   6804 		  "invalidate insn cache")
   6805 (cache-invalidate dci data 0 OP_03 OPE1_3C
   6806 		  ((fr400 (unit u-dci)) (fr450 (unit u-dci))
   6807 		   (fr500 (unit u-dci)) (fr550 (unit u-dci)))
   6808 		  "invalidate data cache")
   6809 
   6810 (define-pmacro (cache-invalidate-entry name cache op ope profile comment)
   6811   (dni name
   6812        (comment)
   6813        ((UNIT C) (MACH fr400,fr450,fr550) (FR550-MAJOR C-2)
   6814 	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
   6815        (.str name "$pack @($GRi,$GRj),$ae")
   6816        (+ pack (misc-null-1) ae op GRi ope GRj)
   6817        (if (eq ae 0)
   6818 	   (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) -1) ; Invalid ae setting for this insn
   6819 	   (c-call VOID (.str "@cpu@_" cache "_cache_invalidate") (add GRi GRj) ae))
   6820        profile
   6821   )
   6822 )
   6823 
   6824 (cache-invalidate-entry icei insn OP_03 OPE1_39
   6825 			((fr400 (unit u-ici)) (fr450 (unit u-ici))
   6826 			 (fr550 (unit u-ici)))
   6827 			"invalidate insn cache entry")
   6828 (cache-invalidate-entry dcei data OP_03 OPE1_3A
   6829 			((fr400 (unit u-dci)) (fr450 (unit u-dci))
   6830 			 (fr550 (unit u-dci)))
   6831 			"invalidate data cache entry")
   6832 
   6833 (dni dcf
   6834      "Data cache flush"
   6835      ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   6836       (FR400-MAJOR C-2) (FR450-MAJOR C-2))
   6837      "dcf$pack @($GRi,$GRj)"
   6838      (+ pack (rd-null) OP_03 GRi OPE1_3D GRj)
   6839      (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) 0)
   6840      ((fr400 (unit u-dcf)) (fr450 (unit u-dcf))
   6841       (fr500 (unit u-dcf)) (fr550 (unit u-dcf)))
   6842 )
   6843 
   6844 (dni dcef
   6845      "Data cache entry flush"
   6846      ((UNIT C) (MACH fr400,fr450,fr550) (FR550-MAJOR C-2)
   6847       (FR400-MAJOR C-2) (FR450-MAJOR C-2))
   6848      "dcef$pack @($GRi,$GRj),$ae"
   6849      (+ pack (misc-null-1) ae OP_03 GRi OPE1_3B GRj)
   6850      (if (eq ae 0)
   6851 	 (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) -1)
   6852 	 (c-call VOID "@cpu@_data_cache_flush" (add GRi GRj) ae))
   6853      ((fr400 (unit u-dcf)) (fr450 (unit u-dcf)) (fr550 (unit u-dcf)))
   6854 )
   6855 
   6856 (define-pmacro (write-TLB name insn op ope comment)
   6857   (dni name
   6858        (comment)
   6859        ((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
   6860        (.str insn "$pack $GRk,@($GRi,$GRj)")
   6861        (+ pack GRk op GRi ope GRj)
   6862        (nop) ; for now
   6863        ()
   6864   )
   6865 )
   6866 
   6867 (write-TLB witlb witlb OP_03 OPE1_32 "write for insn TLB")
   6868 (write-TLB wdtlb wdtlb OP_03 OPE1_36 "write for data TLB")
   6869 
   6870 (define-pmacro (invalidate-TLB name insn op ope comment)
   6871   (dni name
   6872        (comment)
   6873        ((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
   6874        (.str insn "$pack @($GRi,$GRj)")
   6875        (+ pack (rd-null) op GRi ope GRj)
   6876        (nop) ; for now
   6877        ()
   6878   )
   6879 )
   6880 
   6881 (invalidate-TLB itlbi itlbi OP_03 OPE1_33 "invalidate insn TLB")
   6882 (invalidate-TLB dtlbi dtlbi OP_03 OPE1_37 "invalidate data TLB")
   6883 
   6884 (define-pmacro (cache-preload name cache pipe attrs op ope profile comment)
   6885   (dni name
   6886        (comment)
   6887        (.splice (UNIT pipe) (FR500-MAJOR C-2)
   6888 		(FR400-MAJOR C-2) (.unsplice attrs))
   6889        (.str name "$pack $GRi,$GRj,$lock")
   6890        (+ pack (misc-null-1) lock op GRi ope GRj)
   6891        (c-call VOID (.str "@cpu@_" cache "_cache_preload") GRi GRj lock)
   6892        profile
   6893   )
   6894 )
   6895 
   6896 (cache-preload icpl insn C ((FR550-MAJOR C-2) (FR450-MAJOR C-2)) OP_03 OPE1_30
   6897 	       ((fr400 (unit u-icpl)) (fr450 (unit u-icpl)) 
   6898 		(fr500 (unit u-icpl)) (fr550 (unit u-icpl)))
   6899 	       "preload insn cache")
   6900 (cache-preload dcpl data DCPL ((FR550-MAJOR I-8) (FR450-MAJOR I-2)) OP_03 OPE1_34
   6901 	       ((fr400 (unit u-dcpl)) (fr450 (unit u-dcpl))
   6902 		(fr500 (unit u-dcpl)) (fr550 (unit u-dcpl)))
   6903 	       "preload data cache")
   6904 
   6905 (define-pmacro (cache-unlock name cache op ope profile comment)
   6906   (dni name
   6907        (comment)
   6908        ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   6909 	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
   6910        (.str name "$pack $GRi")
   6911        (+ pack (rd-null) op GRi ope (GRj-null))
   6912        (c-call VOID (.str "@cpu@_" cache "_cache_unlock") GRi)
   6913        profile
   6914   )
   6915 )
   6916 
   6917 (cache-unlock icul insn OP_03 OPE1_31
   6918 	      ((fr400 (unit u-icul)) (fr450 (unit u-icul))
   6919 	       (fr500 (unit u-icul)) (fr550 (unit u-icul)))
   6920 	      "unlock insn cache")
   6921 (cache-unlock dcul data OP_03 OPE1_35
   6922 	      ((fr400 (unit u-dcul)) (fr450 (unit u-dcul))
   6923 	       (fr500 (unit u-dcul)) (fr550 (unit u-dcul)))
   6924 	      "unlock data cache")
   6925 
   6926 (define-pmacro (barrier name insn op ope profile comment)
   6927   (dni name
   6928        (comment)
   6929        ((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
   6930 	(FR400-MAJOR C-2) (FR450-MAJOR C-2))
   6931        (.str insn "$pack")
   6932        (+ pack (rd-null) op (rs-null) ope (GRj-null))
   6933        (nop) ; sufficient implementation
   6934        profile
   6935   )
   6936 )
   6937 
   6938 (barrier bar    bar    OP_03 OPE1_3E
   6939 	 ((fr400 (unit u-barrier)) (fr450 (unit u-barrier))
   6940 	  (fr500 (unit u-barrier)))
   6941 	 "barrier")
   6942 (barrier membar membar OP_03 OPE1_3F
   6943 	 ((fr400 (unit u-membar)) (fr450 (unit u-membar))
   6944 	  (fr500 (unit u-membar)))
   6945 	 "memory barrier")
   6946 
   6947 ; Load real address instructions
   6948 (define-pmacro (load-real-address name insn what op ope)
   6949   (dni name
   6950        (.str "Load real address of " what)
   6951        ((UNIT C) (FR450-MAJOR C-2) (MACH fr450))
   6952        (.str insn "$pack $GRi,$GRk,$LRAE,$LRAD,$LRAS")
   6953        (+ pack GRk op GRi ope LRAE LRAD LRAS (LRA-null))
   6954        (nop) ; not simulated
   6955        ()
   6956   )
   6957 )
   6958 
   6959 (load-real-address lrai "lrai" "instruction" OP_03 OPE1_20)
   6960 (load-real-address lrad "lrad" "data" OP_03 OPE1_21)
   6961 
   6962 (dni tlbpr
   6963      "TLB Probe"
   6964      ((UNIT C) (FR450-MAJOR C-2) (MACH fr450))
   6965      "tlbpr$pack $GRi,$GRj,$TLBPRopx,$TLBPRL"
   6966      (+ pack (TLBPR-null) TLBPRopx TLBPRL OP_03 GRi OPE1_24 GRj)
   6967      (nop) ; not simulated
   6968      ()
   6969 )
   6970 
   6971 ; Coprocessor operations
   6972 (define-pmacro (cop-op num op)
   6973   (dni (.sym cop num)
   6974        "Coprocessor operation"
   6975        ((UNIT C) (FR500-MAJOR C-2) (MACH frv))
   6976        (.str "cop" num "$pack $s6_1,$CPRi,$CPRj,$CPRk")
   6977        (+ pack CPRk op CPRi s6_1 CPRj)
   6978        (nop) ; sufficient implementation
   6979        ()
   6980   )
   6981 )
   6982 
   6983 (cop-op 1 OP_7E)
   6984 (cop-op 2 OP_7F)
   6985 
   6986 (define-pmacro (clear-ne-flag-semantics target_index is_float)
   6987   (c-call VOID "@cpu@_clear_ne_flags" target_index is_float)
   6988 )
   6989 
   6990 (define-pmacro (clear-ne-flag-r name op ope reg is_float attr profile comment)
   6991   (dni name
   6992        (comment)
   6993        ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH simple,tomcat,fr500,fr550,frv) attr)
   6994        (.str name "$pack $" reg "k")
   6995        (+ pack (.sym reg k) op (rs-null) ope (GRj-null))
   6996        (sequence ()
   6997 		 ; hack to get this referenced for profiling
   6998 		 (c-raw-call VOID "frv_ref_SI" (.sym reg k))
   6999 		 (clear-ne-flag-semantics (index-of (.sym reg k)) is_float))
   7000        profile
   7001   )
   7002 )
   7003 
   7004 (clear-ne-flag-r clrgr OP_0A OPE1_00 GR 0 NA
   7005 		 ((fr500 (unit u-clrgr)) (fr550 (unit u-clrgr)))
   7006 		 "Clear GR NE flag")
   7007 (clear-ne-flag-r clrfr OP_0A OPE1_02 FR 1 FR-ACCESS
   7008 		 ((fr500 (unit u-clrfr)) (fr550 (unit u-clrfr)))
   7009 		 "Clear FR NE flag")
   7010 
   7011 (define-pmacro (clear-ne-flag-all name op ope is_float attr profile comment)
   7012   (dni name
   7013        (comment)
   7014        ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH simple,tomcat,fr500,fr550,frv) attr)
   7015        (.str name "$pack")
   7016        (+ pack (rd-null) op (rs-null) ope (GRj-null))
   7017        (clear-ne-flag-semantics -1 is_float)
   7018        profile
   7019   )
   7020 )
   7021 
   7022 (clear-ne-flag-all clrga OP_0A OPE1_01 0 NA
   7023 		 ((fr500 (unit u-clrgr)) (fr550 (unit u-clrgr)))
   7024 		   "Clear GR NE flag ALL")
   7025 (clear-ne-flag-all clrfa OP_0A OPE1_03 1 FR-ACCESS
   7026 		 ((fr500 (unit u-clrfr)) (fr550 (unit u-clrfr)))
   7027 		   "Clear FR NE flag ALL")
   7028 
   7029 (define-pmacro (commit-semantics target_index is_float)
   7030   (c-call VOID "@cpu@_commit" target_index is_float)
   7031 )
   7032 
   7033 (define-pmacro (commit-r name op ope reg is_float attr comment)
   7034   (dni name
   7035        (comment)
   7036        ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH frv,fr500,fr550) attr)
   7037        (.str name "$pack $" reg "k")
   7038        (+ pack (.sym reg k) op (rs-null) ope (GRj-null))
   7039        (commit-semantics (index-of (.sym reg k)) is_float)
   7040        ((fr500 (unit u-commit)) (fr550 (unit u-commit)))
   7041   )
   7042 )
   7043 
   7044 (commit-r commitgr OP_0A OPE1_04 GR 0 NA        "commit exceptions, specific GR")
   7045 (commit-r commitfr OP_0A OPE1_06 FR 1 FR-ACCESS "commit exceptions, specific FR")
   7046 
   7047 (define-pmacro (commit name op ope is_float attr comment)
   7048   (dni name
   7049        (comment)
   7050        ((UNIT I01) (FR500-MAJOR I-6) (FR550-MAJOR I-7) (MACH frv,fr500,fr550) attr)
   7051        (.str name "$pack")
   7052        (+ pack (rd-null) op (rs-null) ope (GRj-null))
   7053        (commit-semantics -1 is_float)
   7054        ((fr500 (unit u-commit)) (fr550 (unit u-commit)))
   7055   )
   7056 )
   7057 
   7058 (commit commitga OP_0A OPE1_05 0 NA        "commit exceptions, any GR")
   7059 (commit commitfa OP_0A OPE1_07 1 FR-ACCESS "commit exceptions, any FR")
   7060 
   7061 (define-pmacro (floating-point-conversion
   7062 		name op ope conv mode src targ attr comment)
   7063   (dni name
   7064        (comment)
   7065        (.splice (UNIT FMALL) (FR500-MAJOR F-1) (.unsplice attr))
   7066        (.str name "$pack $" src ",$" targ)
   7067        (+ pack targ op (rs-null) ope src)
   7068        (set targ (conv mode FPCONV-DEFAULT src))
   7069        ((fr500 (unit u-float-convert)) (fr550 (unit u-float-convert)))
   7070   )
   7071 )
   7072 
   7073 (floating-point-conversion fitos OP_79 OPE1_00 float SF FRintj FRk
   7074 			   ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7075 			   "Convert Integer to Single")
   7076 (floating-point-conversion fstoi OP_79 OPE1_01 fix   SI FRj FRintk
   7077 			   ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7078 			   "Convert Single  to Integer")
   7079 (floating-point-conversion fitod OP_7A OPE1_00 float DF FRintj FRdoublek
   7080 			   ((MACH frv))
   7081 			   "Convert Integer to Double")
   7082 (floating-point-conversion fdtoi OP_7A OPE1_01 fix   SI FRdoublej FRintk
   7083 			   ((MACH frv))
   7084 			   "Convert Double to Integer")
   7085 
   7086 (define-pmacro (floating-point-dual-conversion
   7087 		name op ope conv mode src src_hw targ targ_hw attr comment)
   7088   (dni name
   7089        (comment)
   7090        ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1) attr)
   7091        (.str name "$pack $" src ",$" targ)
   7092        (+ pack targ op (rs-null) ope src)
   7093        (sequence ()
   7094 		 (set targ (conv mode FPCONV-DEFAULT src))
   7095 		 (set (nextreg targ_hw targ 1)
   7096 		      (conv mode FPCONV-DEFAULT (nextreg src_hw src 1))))
   7097        ((fr500 (unit u-float-dual-convert)))
   7098   )
   7099 )
   7100 
   7101 (floating-point-dual-conversion fditos OP_79 OPE1_10 float SF FRintj h-fr_int FRk h-fr NA "Dual Convert Integer to Single")
   7102 (floating-point-dual-conversion fdstoi OP_79 OPE1_11 fix   SI FRj h-fr FRintk h-fr_int NA "Dual Convert Single  to Integer")
   7103 
   7104 (define-pmacro (ne-floating-point-dual-conversion
   7105 		name op ope conv mode src src_hw targ targ_hw attr comment)
   7106   (dni name
   7107        (comment)
   7108        ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1) NON-EXCEPTING attr)
   7109        (.str name "$pack $" src ",$" targ)
   7110        (+ pack targ op (rs-null) ope src)
   7111        (sequence ()
   7112 		 (c-call VOID "@cpu@_set_ne_index" (index-of targ))
   7113 		 (set targ (conv mode FPCONV-DEFAULT src))
   7114 		 (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 1))
   7115 		 (set (nextreg targ_hw targ 1)
   7116 		      (conv mode FPCONV-DEFAULT (nextreg src_hw src 1))))
   7117        ((fr500 (unit u-float-dual-convert)))
   7118   )
   7119 )
   7120 
   7121 (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")
   7122 (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")
   7123 
   7124 (define-pmacro (conditional-floating-point-conversion
   7125 		name op ope conv mode src targ comment)
   7126   (dni name
   7127        (comment)
   7128        ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7129        (.str name "$pack $" src ",$" targ ",$CCi,$cond")
   7130        (+ pack targ op (rs-null) CCi cond ope src)
   7131        (if (eq CCi (or cond 2))
   7132 	   (set targ (conv mode FPCONV-DEFAULT src)))
   7133        ((fr500 (unit u-float-convert)) (fr550 (unit u-float-convert)))
   7134   )
   7135 )
   7136 
   7137 (conditional-floating-point-conversion cfitos OP_6B OPE4_0 float SF FRintj FRk "Conditional convert Integer to Single")
   7138 (conditional-floating-point-conversion cfstoi OP_6B OPE4_1 fix   SI FRj FRintk "Conditional convert Single to Integer")
   7139 
   7140 (define-pmacro (ne-floating-point-conversion 
   7141 		name op ope conv mode src targ comment)
   7142   (dni name
   7143        (comment)
   7144        ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7145        (.str name "$pack $" src ",$" targ)
   7146        (+ pack targ op (rs-null) ope src)
   7147        (sequence ()
   7148 		 (c-call VOID "@cpu@_set_ne_index" (index-of targ))
   7149 		 (set targ (conv mode FPCONV-DEFAULT src)))
   7150        ((fr500 (unit u-float-convert)) (fr550 (unit u-float-convert)))
   7151   )
   7152 )
   7153 
   7154 (ne-floating-point-conversion nfitos OP_79 OPE1_20 float SF FRintj FRk "NE convert Integer to Single")
   7155 (ne-floating-point-conversion nfstoi OP_79 OPE1_21 fix   SI FRj FRintk "NE convert Single to Integer")
   7156 
   7157 (register-transfer fmovs OP_79 OPE1_02
   7158 		   FRj FRk FMALL
   7159 		   ((FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7160 		   ((fr500 (unit u-fr2fr)))
   7161 		   "Move Single Float")
   7162 (register-transfer fmovd OP_7A OPE1_02
   7163 		   ; TODO -- unit doesn't handle extra register
   7164 		   FRdoublej FRdoublek FM01
   7165 		   ((FR500-MAJOR F-1) (MACH frv))
   7166 		   ((fr500 (unit u-fr2fr)) (fr550 (unit u-fr2fr)))
   7167 		   "Move Double Float")
   7168 
   7169 (dni fdmovs
   7170      "Dual move single float"
   7171      ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1))
   7172      "fdmovs$pack $FRj,$FRk"
   7173      (+ pack FRk OP_79 (rs-null) OPE1_12 FRj)
   7174      (sequence ()
   7175 	       (set FRk FRj)
   7176 	       (set (nextreg h-fr FRk 1) (nextreg h-fr FRj 1)))
   7177      ; TODO -- unit doesn't handle extra register
   7178      ((fr500 (unit u-fr2fr)))
   7179 )
   7180 
   7181 (conditional-register-transfer cfmovs OP_6C OPE4_0 FRj FRk FMALL
   7182 			       ((FR500-MAJOR F-1) (FR550-MAJOR F-2)
   7183 				(MACH simple,tomcat,fr500,fr550,frv))
   7184 			       ((fr500 (unit u-fr2fr)) (fr550 (unit u-fr2fr)))
   7185 			       "Conditional move Single Float")
   7186 
   7187 (define-pmacro (floating-point-neg name src targ op ope attr comment)
   7188   (dni name
   7189        (comment)
   7190        (.splice (UNIT FMALL) (FR500-MAJOR F-1) (.unsplice attr))
   7191        (.str name "$pack $" src ",$" targ)
   7192        (+ pack src op (rs-null) ope targ)
   7193        (set targ (neg src))
   7194        ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7195   )
   7196 )
   7197 
   7198 (floating-point-neg fnegs FRj FRk OP_79 OPE1_03 ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv)) "Floating point negate, single")
   7199 (floating-point-neg fnegd FRdoublej FRdoublek OP_7A OPE1_03 ((MACH frv)) "Floating point negate, double")
   7200 
   7201 (dni fdnegs
   7202      "Floating point dual negate, single"
   7203      ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1))
   7204      "fdnegs$pack $FRj,$FRk"
   7205      (+ pack FRk OP_79 (rs-null) OPE1_13 FRj)
   7206      (sequence ()
   7207 	       (set FRk (neg FRj))
   7208 	       (set (nextreg h-fr FRk 1) (neg (nextreg h-fr FRj 1))))
   7209      ((fr500 (unit u-float-dual-arith)))
   7210 )
   7211 
   7212 (dni cfnegs
   7213      "Conditional floating point negate, single"
   7214      ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7215      "cfnegs$pack $FRj,$FRk,$CCi,$cond"
   7216      (+ pack FRj OP_6C (rs-null) CCi cond OPE4_1 FRk)
   7217      (if (eq CCi (or cond 2))
   7218 	 (set FRk (neg FRj)))
   7219      ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7220 )
   7221 
   7222 (define-pmacro (float-abs name src targ op ope attr comment)
   7223   (dni name
   7224        (comment)
   7225        (.splice (UNIT FMALL) (FR500-MAJOR F-1) (.unsplice attr))
   7226        (.str name "$pack $" src ",$" targ )
   7227        (+ pack targ op (rs-null) ope src)
   7228        (set targ (abs src))
   7229        ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7230   )
   7231 )
   7232 
   7233 (float-abs fabss FRj FRk OP_79 OPE1_04 ((FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv)) "Float absolute value, single")
   7234 (float-abs fabsd FRdoublej FRdoublek OP_7A OPE1_04 ((MACH frv)) "Float absolute value, double")
   7235 
   7236 (dni fdabss
   7237      "Floating point dual absolute value, single"
   7238      ((MACH frv) (UNIT FMALL) (FR500-MAJOR F-1))
   7239      "fdabss$pack $FRj,$FRk"
   7240      (+ pack FRk OP_79 (rs-null) OPE1_14 FRj)
   7241      (sequence ()
   7242 	       (set FRk (abs FRj))
   7243 	       (set (nextreg h-fr FRk 1) (abs (nextreg h-fr FRj 1))))
   7244      ((fr500 (unit u-float-dual-arith)))
   7245 )
   7246 
   7247 (dni cfabss
   7248      "Conditional floating point absolute value, single"
   7249      ((UNIT FMALL) (FR500-MAJOR F-1) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7250      "cfabss$pack $FRj,$FRk,$CCi,$cond"
   7251      (+ pack FRj OP_6C (rs-null) CCi cond OPE4_2 FRk)
   7252      (if (eq CCi (or cond 2))
   7253 	 (set FRk (abs FRj)))
   7254      ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7255 )
   7256 
   7257 (dni fsqrts
   7258      "Square root single"
   7259      ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
   7260      "fsqrts$pack $FRj,$FRk"
   7261      (+ pack FRk OP_79 (rs-null) OPE1_05 FRj)
   7262      (set FRk (sqrt SF FRj))
   7263      ((fr500 (unit u-float-sqrt)) (fr550 (unit u-float-sqrt)))
   7264 )
   7265 
   7266 (dni fdsqrts
   7267      "Dual square root single"
   7268      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-4))
   7269      "fdsqrts$pack $FRj,$FRk"
   7270      (+ pack FRk OP_79 (rs-null) OPE1_15 FRj)
   7271      (sequence ()
   7272 	       (set FRk (sqrt SF FRj))
   7273 	       (set (nextreg h-fr FRk 1) (sqrt (nextreg h-fr FRj 1))))
   7274      ((fr500 (unit u-float-dual-sqrt)))
   7275 )
   7276 
   7277 (dni nfdsqrts
   7278      "Non excepting Dual square root single"
   7279      ((MACH frv) (UNIT FM01) (FR500-MAJOR F-4) NON-EXCEPTING)
   7280      "nfdsqrts$pack $FRj,$FRk"
   7281      (+ pack FRk OP_79 (rs-null) OPE1_35 FRj)
   7282      (sequence ()
   7283 	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7284 	       (set FRk (sqrt SF FRj))
   7285 	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
   7286 	       (set (nextreg h-fr FRk 1) (sqrt (nextreg h-fr FRj 1))))
   7287      ((fr500 (unit u-float-dual-sqrt)))
   7288 )
   7289 
   7290 (dni fsqrtd
   7291      "Square root double"
   7292      ((UNIT FM01) (FR500-MAJOR F-4) (MACH frv))
   7293      "fsqrtd$pack $FRdoublej,$FRdoublek"
   7294      (+ pack FRdoublek OP_7A (rs-null) OPE1_05 FRdoublej)
   7295      (set FRdoublek (sqrt DF FRdoublej))
   7296      ((fr500 (unit u-float-sqrt)))
   7297 )
   7298 
   7299 (dni cfsqrts
   7300      "Conditional square root single"
   7301      ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
   7302      "cfsqrts$pack $FRj,$FRk,$CCi,$cond"
   7303      (+ pack FRk OP_6E (rs-null) CCi cond OPE4_2 FRj)
   7304      (if (eq CCi (or cond 2))
   7305 	 (set FRk (sqrt SF FRj)))
   7306      ((fr500 (unit u-float-sqrt)) (fr550 (unit u-float-sqrt)))
   7307 )
   7308 
   7309 (dni nfsqrts
   7310      "Non exception square root, single"
   7311      ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
   7312      "nfsqrts$pack $FRj,$FRk"
   7313      (+ pack FRk OP_79 (rs-null) OPE1_25 FRj)
   7314      (sequence ()
   7315 	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7316 	       (set FRk (sqrt SF FRj)))
   7317      ((fr500 (unit u-float-sqrt)) (fr550 (unit u-float-sqrt)))
   7318 )
   7319 
   7320 (define-pmacro (float-binary-op-s name pipe attr operation op ope comment)
   7321   (dni name
   7322        (comment)
   7323        (.splice (UNIT pipe) (MACH simple,tomcat,fr500,fr550,frv) (.unsplice attr))
   7324        (.str name "$pack $FRi,$FRj,$FRk")
   7325        (+ pack FRk op FRi ope FRj)
   7326        (set FRk (operation FRi FRj))
   7327        ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7328   )
   7329 )
   7330 
   7331 (float-binary-op-s fadds FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) add OP_79 OPE1_06 "add single float")
   7332 (float-binary-op-s fsubs FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) sub OP_79 OPE1_07 "sub single float")
   7333 (float-binary-op-s fmuls FM01  ((FR500-MAJOR F-3) (FR550-MAJOR F-3)) mul OP_79 OPE1_08 "mul single float")
   7334 
   7335 (dni fdivs
   7336      "div single float"
   7337      ((UNIT FM01) (FR500-MAJOR F-4) (FR550-MAJOR F-3) (MACH simple,tomcat,fr500,fr550,frv))
   7338      "fdivs$pack $FRi,$FRj,$FRk"
   7339      (+ pack FRk OP_79 FRi OPE1_09 FRj)
   7340      (set FRk (div FRi FRj))
   7341      ((fr500 (unit u-float-div))
   7342       (fr550 (unit u-float-div)))
   7343 )
   7344 
   7345 (define-pmacro (float-binary-op-d name operation op ope major comment)
   7346   (dni name
   7347        (comment)
   7348        ((UNIT FMALL) (FR500-MAJOR major) (MACH frv))
   7349        (.str name "$pack $FRdoublei,$FRdoublej,$FRdoublek")
   7350        (+ pack FRdoublek op FRdoublei ope FRdoublej)
   7351        (set FRdoublek (operation FRdoublei FRdoublej))
   7352        ((fr500 (unit u-float-arith)))
   7353   )
   7354 )
   7355 
   7356 (float-binary-op-d faddd add OP_7A OPE1_06 F-2 "add double float")
   7357 (float-binary-op-d fsubd sub OP_7A OPE1_07 F-2 "sub double float")
   7358 (float-binary-op-d fmuld mul OP_7A OPE1_08 F-3 "mul double float")
   7359 (float-binary-op-d fdivd div OP_7A OPE1_09 F-4 "div double float")
   7360 
   7361 (define-pmacro (conditional-float-binary-op name pipe attr operation op ope profile comment)
   7362   (dni name
   7363        (comment)
   7364        (.splice (UNIT pipe) (MACH simple,tomcat,fr500,fr550,frv)
   7365 		(.unsplice attr))
   7366        (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
   7367        (+ pack FRk op FRi CCi cond ope FRj)
   7368        (if (eq CCi (or cond 2))
   7369 	   (set FRk (operation FRi FRj)))
   7370        profile
   7371   )
   7372 )
   7373 
   7374 (conditional-float-binary-op cfadds FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) add OP_6D OPE4_0
   7375 			     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7376 			     "cond add single")
   7377 (conditional-float-binary-op cfsubs FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) sub OP_6D OPE4_1
   7378 			     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7379 			     "cond sub single")
   7380 (conditional-float-binary-op cfmuls FM01  ((FR500-MAJOR F-3) (FR550-MAJOR F-3)) mul OP_6E OPE4_0
   7381 			     ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7382 			     "cond mul single")
   7383 (conditional-float-binary-op cfdivs FM01  ((FR500-MAJOR F-4) (FR550-MAJOR F-3)) div OP_6E OPE4_1
   7384 			     ((fr500 (unit u-float-div)) (fr550 (unit u-float-div)))
   7385 			     "cond div single")
   7386 
   7387 (define-pmacro (ne-float-binary-op name pipe attr operation op ope profile comment)
   7388   (dni name
   7389        (comment)
   7390        (.splice (UNIT pipe) (MACH simple,tomcat,fr500,fr550,frv)
   7391 		(.unsplice attr))
   7392        (.str name "$pack $FRi,$FRj,$FRk")
   7393        (+ pack FRk op FRi ope FRj)
   7394        (sequence ()
   7395 		 (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7396 		 (set FRk (operation FRi FRj)))
   7397        profile
   7398   )
   7399 )
   7400 
   7401 (ne-float-binary-op nfadds FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) add OP_79 OPE1_26
   7402 		    ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7403 		    "ne add single")
   7404 (ne-float-binary-op nfsubs FMALL ((FR500-MAJOR F-2) (FR550-MAJOR F-2)) sub OP_79 OPE1_27
   7405 		    ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7406 		    "ne sub single")
   7407 (ne-float-binary-op nfmuls FM01  ((FR500-MAJOR F-3) (FR550-MAJOR F-3)) mul OP_79 OPE1_28
   7408 		    ((fr500 (unit u-float-arith)) (fr550 (unit u-float-arith)))
   7409 		    "ne mul single")
   7410 (ne-float-binary-op nfdivs FM01  ((FR500-MAJOR F-4) (FR550-MAJOR F-3)) div OP_79 OPE1_29
   7411 		    ((fr500 (unit u-float-div)) (fr550 (unit u-float-div)))
   7412 		    "ne div single")
   7413 
   7414 (define-pmacro (fcc-eq) 8)
   7415 (define-pmacro (fcc-lt) 4)
   7416 (define-pmacro (fcc-gt) 2)
   7417 (define-pmacro (fcc-uo) 1)
   7418 
   7419 (define-pmacro (compare-and-set-fcc arg1 arg2 fcc)
   7420   (if (gt arg1 arg2)
   7421       (set fcc (fcc-gt))
   7422       (if (eq arg1 arg2)
   7423 	  (set fcc (fcc-eq))
   7424 	  (if (lt arg1 arg2)
   7425 	      (set fcc (fcc-lt))
   7426 	      (set fcc (fcc-uo)))))
   7427 )
   7428 
   7429 (dni fcmps
   7430      "compare single float"
   7431      ((UNIT FMALL) (FR500-MAJOR F-2) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7432      "fcmps$pack $FRi,$FRj,$FCCi_2"
   7433      (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_0A FRj)
   7434      (compare-and-set-fcc FRi FRj FCCi_2)
   7435      ((fr500 (unit u-float-compare)) (fr550 (unit u-float-compare)))
   7436 )
   7437 
   7438 (dni fcmpd
   7439      "compare double float"
   7440      ((UNIT FMALL) (FR500-MAJOR F-2) (MACH frv))
   7441      "fcmpd$pack $FRdoublei,$FRdoublej,$FCCi_2"
   7442      (+ pack (cond-null) FCCi_2 OP_7A FRdoublei OPE1_0A FRdoublej)
   7443      (compare-and-set-fcc FRdoublei FRdoublej FCCi_2)
   7444      ((fr500 (unit u-float-compare)))
   7445 )
   7446 
   7447 (dni cfcmps
   7448      "Conditional compare single, float"
   7449      ((UNIT FMALL) (FR500-MAJOR F-2) (FR550-MAJOR F-2) (MACH simple,tomcat,fr500,fr550,frv))
   7450      "cfcmps$pack $FRi,$FRj,$FCCi_2,$CCi,$cond"
   7451      (+ pack (cond-null) FCCi_2 OP_6D FRi CCi cond OPE4_2 FRj)
   7452      (if (eq CCi (or cond 2))
   7453 	 (compare-and-set-fcc FRi FRj FCCi_2))
   7454      ((fr500 (unit u-float-compare)) (fr550 (unit u-float-compare)))
   7455 )
   7456 
   7457 (dni fdcmps
   7458      "float dual compare single"
   7459      ((UNIT FMALL) (FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
   7460      "fdcmps$pack $FRi,$FRj,$FCCi_2"
   7461      (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_1A FRj)
   7462      (sequence ()
   7463 	       (compare-and-set-fcc FRi FRj FCCi_2)
   7464 	       (compare-and-set-fcc (nextreg h-fr FRi 1) (nextreg h-fr FRj 1)
   7465 				    (nextreg h-fccr FCCi_2 1)))
   7466      ((fr500 (unit u-float-dual-compare)) (fr550 (unit u-float-dual-compare)))
   7467 )
   7468 
   7469 (define-pmacro (float-mul-with-add name add_sub arg1 arg2 targ op ope comment)
   7470   (dni name
   7471        (comment)
   7472        ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv))
   7473        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
   7474        (+ pack targ op arg1 ope arg2)
   7475        (set targ (add_sub (mul arg1 arg2) targ))
   7476        ((fr500 (unit u-float-dual-arith)))
   7477   )
   7478 )
   7479 
   7480 (float-mul-with-add fmadds add FRi FRj FRk OP_79 OPE1_0B "mul with add, single")
   7481 (float-mul-with-add fmsubs sub FRi FRj FRk OP_79 OPE1_0C "mul with sub, single")
   7482 
   7483 (float-mul-with-add fmaddd add FRdoublei FRdoublej FRdoublek OP_7A OPE1_0B "mul with add, double")
   7484 (float-mul-with-add fmsubd sub FRdoublei FRdoublej FRdoublek OP_7A OPE1_0C "mul with sub, double")
   7485 
   7486 (dni fdmadds
   7487      "Float dual multiply with add"
   7488      ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv))
   7489      "fdmadds$pack $FRi,$FRj,$FRk"
   7490      (+ pack FRk OP_79 FRi OPE1_1B FRj)
   7491      (sequence ()
   7492 	       (set FRk (add (mul FRi FRj) FRk))
   7493 	       (set (nextreg h-fr FRk 1)
   7494 		    (add (mul (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))
   7495 			 (nextreg h-fr FRk 1))))
   7496      ; TODO dual registers not referenced for profiling
   7497      ((fr500 (unit u-float-dual-arith)))
   7498 )
   7499 
   7500 (dni nfdmadds
   7501      "Non excepting float dual multiply with add"
   7502      ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv))
   7503      "nfdmadds$pack $FRi,$FRj,$FRk"
   7504      (+ pack FRk OP_79 FRi OPE1_3B FRj)
   7505      (sequence ()
   7506 	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7507 	       (set FRk (add (mul FRi FRj) FRk))
   7508 	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
   7509 	       (set (nextreg h-fr FRk 1)
   7510 		    (add (mul (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))
   7511 			 (nextreg h-fr FRk 1))))
   7512      ; TODO dual registers not referenced for profiling
   7513      ((fr500 (unit u-float-dual-arith)))
   7514 )
   7515 
   7516 (define-pmacro (conditional-float-mul-with-add
   7517 		name add_sub arg1 arg2 targ op ope comment)
   7518   (dni name
   7519        (comment)
   7520        ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv) CONDITIONAL)
   7521        (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
   7522        (+ pack FRk op FRi CCi cond ope FRj)
   7523        (if (eq CCi (or cond 2))
   7524 	   (set targ (add_sub (mul arg1 arg2) targ)))
   7525        ((fr500 (unit u-float-dual-arith)))
   7526   )
   7527 )
   7528 
   7529 (conditional-float-mul-with-add cfmadds add FRi FRj FRk OP_6F OPE4_0 "conditional mul with add, single")
   7530 (conditional-float-mul-with-add cfmsubs sub FRi FRj FRk OP_6F OPE4_1 "conditional mul with sub, single")
   7531 
   7532 (define-pmacro (ne-float-mul-with-add name add_sub arg1 arg2 targ op ope comment)
   7533   (dni name
   7534        (comment)
   7535        ((UNIT FMALL) (FR500-MAJOR F-5) (MACH frv) NON-EXCEPTING)
   7536        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
   7537        (+ pack targ op arg1 ope arg2)
   7538        (sequence ()
   7539 		 (c-call VOID "@cpu@_set_ne_index" (index-of targ))
   7540 		 (set targ (add_sub (mul arg1 arg2) targ)))
   7541        ((fr500 (unit u-float-dual-arith)))
   7542   )
   7543 )
   7544 
   7545 (ne-float-mul-with-add nfmadds add FRi FRj FRk OP_79 OPE1_2B "non excepting mul with add, single")
   7546 (ne-float-mul-with-add nfmsubs sub FRi FRj FRk OP_79 OPE1_2C "non excepting mul with sub, single")
   7547 
   7548 (define-pmacro (float-parallel-mul-add-semantics cond add_sub arg1 arg2 targ)
   7549   (if cond
   7550       (sequence ()
   7551 		(set targ (mul arg1 arg2))
   7552 		(set (nextreg h-fr targ 1)
   7553 		     (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))))
   7554 )
   7555 
   7556 (define-pmacro (float-parallel-mul-add
   7557 		name add_sub arg1 arg2 targ op ope comment)
   7558   (dni name
   7559        (comment)
   7560        ((UNIT FM01) (FR500-MAJOR F-5) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
   7561        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
   7562        (+ pack targ op arg1 ope arg2)
   7563        (float-parallel-mul-add-semantics 1 add_sub arg1 arg2 targ)
   7564        ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7565   )
   7566 )
   7567 
   7568 (float-parallel-mul-add fmas add FRi FRj FRk OP_79 OPE1_0E "parallel mul/add, single")
   7569 (float-parallel-mul-add fmss sub FRi FRj FRk OP_79 OPE1_0F "parallel mul/sub, single")
   7570 
   7571 (define-pmacro (float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
   7572   (sequence ()
   7573 	    (set targ (mul arg1 arg2))
   7574 	    (set (nextreg h-fr targ 1)
   7575 		 (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))
   7576 	    (set (nextreg h-fr targ 2)
   7577 		 (mul (nextreg h-fr arg1 2)	(nextreg h-fr arg2 2)))
   7578 	    (set (nextreg h-fr targ 3)
   7579 		 (add_sub (nextreg h-fr arg1 3) (nextreg h-fr arg2 3))))
   7580 )
   7581 
   7582 (define-pmacro (float-dual-parallel-mul-add
   7583 		name add_sub arg1 arg2 targ op ope comment)
   7584   (dni name
   7585        (comment)
   7586        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
   7587        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
   7588        (+ pack targ op arg1 ope arg2)
   7589        (float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
   7590        ()
   7591   )
   7592 )
   7593 
   7594 (float-dual-parallel-mul-add fdmas add FRi FRj FRk OP_79 OPE1_1C "dual parallel mul/add, single")
   7595 (float-dual-parallel-mul-add fdmss sub FRi FRj FRk OP_79 OPE1_1D "dual parallel mul/sub, single")
   7596 
   7597 (define-pmacro (ne-float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
   7598   (sequence ()
   7599 	    (c-call VOID "@cpu@_set_ne_index" (index-of targ))
   7600 	    (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 1))
   7601 	    (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 2))
   7602 	    (c-call VOID "@cpu@_set_ne_index" (add (index-of targ) 3))
   7603 	    (set targ (mul arg1 arg2))
   7604 	    (set (nextreg h-fr targ 1)
   7605 		 (add_sub (nextreg h-fr arg1 1) (nextreg h-fr arg2 1)))
   7606 	    (set (nextreg h-fr targ 2)
   7607 		 (mul (nextreg h-fr arg1 2)	(nextreg h-fr arg2 2)))
   7608 	    (set (nextreg h-fr targ 3)
   7609 		 (add_sub (nextreg h-fr arg1 3) (nextreg h-fr arg2 3))))
   7610 )
   7611 
   7612 (define-pmacro (ne-float-dual-parallel-mul-add
   7613 		name add_sub arg1 arg2 targ op ope comment)
   7614   (dni name
   7615        (comment)
   7616        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
   7617        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
   7618        (+ pack targ op arg1 ope arg2)
   7619        (ne-float-dual-parallel-mul-add-semantics add_sub arg1 arg2 targ)
   7620        ()
   7621   )
   7622 )
   7623 
   7624 (ne-float-dual-parallel-mul-add nfdmas add FRi FRj FRk OP_79 OPE1_3C "non excepting dual parallel mul/add, single")
   7625 (ne-float-dual-parallel-mul-add nfdmss sub FRi FRj FRk OP_79 OPE1_3D "non excepting dual parallel mul/sub, single")
   7626 
   7627 (define-pmacro (conditional-float-parallel-mul-add name add_sub op ope comment)
   7628   (dni name
   7629        (comment)
   7630        ((UNIT FM01) (FR500-MAJOR F-5) (FR550-MAJOR F-4) CONDITIONAL (MACH simple,tomcat,fr500,fr550,frv))
   7631        (.str name "$pack $FRi,$FRj,$FRk,$CCi,$cond")
   7632        (+ pack FRk op FRi CCi cond ope FRj)
   7633        (float-parallel-mul-add-semantics (eq CCi (or cond 2))
   7634 					 add_sub FRi FRj FRk)
   7635        ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7636   )
   7637 )
   7638 
   7639 (conditional-float-parallel-mul-add cfmas add OP_6F OPE4_2 "conditional parallel mul/add, single")
   7640 (conditional-float-parallel-mul-add cfmss sub OP_6F OPE4_3 "conditional parallel mul/sub, single")
   7641 
   7642 (define-pmacro (float-parallel-mul-add-double-semantics add_sub arg1 arg2 targ)
   7643   (sequence ()
   7644 	    (set targ (ftrunc SF FPCONV-DEFAULT
   7645 			      (mul DF
   7646 				   (fext DF FPCONV-DEFAULT arg1)
   7647 				   (fext DF FPCONV-DEFAULT arg2))))
   7648 	    (set (nextreg h-fr targ 1)
   7649 		 (ftrunc SF FPCONV-DEFAULT
   7650 			 (add_sub DF
   7651 				  (fext DF FPCONV-DEFAULT (nextreg h-fr arg1 1))
   7652 				  (fext DF FPCONV-DEFAULT (nextreg h-fr arg2 1))))))
   7653 )
   7654 
   7655 (define-pmacro (float-parallel-mul-add-double
   7656 		name add_sub arg1 arg2 targ op ope comment)
   7657   (dni name
   7658        (comment)
   7659        ((UNIT FM01) (FR500-MAJOR F-5) (MACH frv))
   7660        (.str name "$pack $" arg1 ",$" arg2 ",$" targ)
   7661        (+ pack targ op arg1 ope arg2)
   7662        (float-parallel-mul-add-double-semantics add_sub arg1 arg2 targ)
   7663        ()
   7664   )
   7665 )
   7666 
   7667 (float-parallel-mul-add-double fmad add FRi FRj FRk OP_7A OPE1_0E "parallel mul/add, double")
   7668 (float-parallel-mul-add-double fmsd sub FRi FRj FRk OP_7A OPE1_0F "parallel mul/sub, double")
   7669 
   7670 (define-pmacro (ne-float-parallel-mul-add name add_sub op ope comment)
   7671   (dni name
   7672        (comment)
   7673        ((UNIT FM01) (FR500-MAJOR F-5) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
   7674        (.str name "$pack $FRi,$FRj,$FRk")
   7675        (+ pack FRk op FRi ope FRj)
   7676        (sequence ()
   7677 		 (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7678 		 (set FRk (mul FRi FRj))
   7679 		 (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
   7680 		 (set (nextreg h-fr FRk 1)
   7681 		      (add_sub (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
   7682        ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7683   )
   7684 )
   7685 
   7686 (ne-float-parallel-mul-add nfmas add OP_79 OPE1_2E "ne parallel mul/add,single")
   7687 (ne-float-parallel-mul-add nfmss sub OP_79 OPE1_2F "ne parallel mul/sub,single")
   7688 
   7689 (define-pmacro (float-dual-arith name attr oper1 oper2 op ope comment)
   7690   (dni name
   7691        (comment)
   7692        (.splice (UNIT FM01) (.unsplice attr))
   7693        (.str name "$pack $FRi,$FRj,$FRk")
   7694        (+ pack FRk op FRi ope FRj)
   7695        (sequence ()
   7696 		 (set FRk (oper1 FRi FRj))
   7697 		 (set (nextreg h-fr FRk 1)
   7698 		      (oper2 (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
   7699        ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7700   )
   7701 )
   7702 
   7703 (float-dual-arith fdadds ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add add OP_79 OPE1_16 "dual add, single")
   7704 (float-dual-arith fdsubs ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) sub sub OP_79 OPE1_17 "dual sub, single")
   7705 (float-dual-arith fdmuls ((FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) mul mul OP_79 OPE1_18 "dual mul, single")
   7706 (float-dual-arith fddivs ((FR500-MAJOR F-7) (MACH frv))                           div div OP_79 OPE1_19 "dual div,single")
   7707 (float-dual-arith fdsads ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add sub OP_79 OPE1_1E "dual add/sub, single")
   7708 
   7709 (dni fdmulcs
   7710      "Float dual cross multiply single"
   7711      ((UNIT FM01) (FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
   7712      "fdmulcs$pack $FRi,$FRj,$FRk"
   7713      (+ pack FRk OP_79 FRi OPE1_1F FRj)
   7714      (sequence ()
   7715 	       (set FRk (mul FRi (nextreg h-fr FRj 1)))
   7716 	       (set (nextreg h-fr FRk 1) (mul (nextreg h-fr FRi 1) FRj)))
   7717      ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7718 )
   7719 
   7720 (dni nfdmulcs
   7721      "NE float dual cross multiply single"
   7722      ((UNIT FM01) (FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv))
   7723      "nfdmulcs$pack $FRi,$FRj,$FRk"
   7724      (+ pack FRk OP_79 FRi OPE1_3F FRj)
   7725      (sequence ()
   7726 	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7727 	       (set FRk (mul FRi (nextreg h-fr FRj 1)))
   7728 	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
   7729 	       (set (nextreg h-fr FRk 1) (mul (nextreg h-fr FRi 1) FRj)))
   7730      ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7731 )
   7732 
   7733 (define-pmacro (ne-float-dual-arith name attr oper1 oper2 op ope comment)
   7734   (dni name
   7735        (comment)
   7736        (.splice (UNIT FM01) (.unsplice attr))
   7737        (.str name "$pack $FRi,$FRj,$FRk")
   7738        (+ pack FRk op FRi ope FRj)
   7739        (sequence ()
   7740 		 (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7741 		 (set FRk (oper1 FRi FRj))
   7742 		 (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
   7743 		 (set (nextreg h-fr FRk 1)
   7744 		      (oper2 (nextreg h-fr FRi 1) (nextreg h-fr FRj 1))))
   7745        ((fr500 (unit u-float-dual-arith)) (fr550 (unit u-float-dual-arith)))
   7746   )
   7747 )
   7748 
   7749 (ne-float-dual-arith nfdadds ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add add OP_79 OPE1_36 "ne dual add, single")
   7750 (ne-float-dual-arith nfdsubs ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) sub sub OP_79 OPE1_37 "ne dual sub, single")
   7751 (ne-float-dual-arith nfdmuls ((FR500-MAJOR F-7) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) mul mul OP_79 OPE1_38 "ne dual mul, single")
   7752 (ne-float-dual-arith nfddivs ((FR500-MAJOR F-7) (MACH frv))                           div div OP_79 OPE1_39 "ne dual div,single")
   7753 (ne-float-dual-arith nfdsads ((FR500-MAJOR F-6) (FR550-MAJOR F-4) (MACH simple,tomcat,fr500,fr550,frv)) add sub OP_79 OPE1_3E "ne dual add/sub, single")
   7754 
   7755 (dni nfdcmps
   7756      "non-excepting dual float compare"
   7757      ((UNIT FM01) (FR500-MAJOR F-6) (MACH simple,tomcat,frv))
   7758      "nfdcmps$pack $FRi,$FRj,$FCCi_2"
   7759      (+ pack (cond-null) FCCi_2 OP_79 FRi OPE1_3A FRj)
   7760      (sequence ()
   7761 	       (c-call VOID "@cpu@_set_ne_index" (index-of FRk))
   7762 	       (compare-and-set-fcc FRi FRj FCCi_2)
   7763 	       (c-call VOID "@cpu@_set_ne_index" (add (index-of FRk) 1))
   7764 	       (compare-and-set-fcc (nextreg h-fr FRi 1) (nextreg h-fr FRj 1)
   7765 				    (nextreg h-fccr FCCi_2 1)))
   7766      ((fr500 (unit u-float-dual-compare)))
   7767 )
   7768 
   7769 ; Media Instructions
   7770 ;
   7771 (define-pmacro (halfword hilo arg offset)
   7772   (reg (.sym h-fr_ hilo) (add (index-of arg) offset)))
   7773 
   7774 (dni mhsetlos
   7775      "Media set lower signed 12 bits"
   7776      ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
   7777       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7778      "mhsetlos$pack $u12,$FRklo"
   7779      (+ pack FRklo OP_78 OPE1_20 u12)
   7780      (set FRklo u12)
   7781      ((fr400 (unit u-media-hilo)) (fr450 (unit u-media-hilo))
   7782       (fr550 (unit u-media-set (out FRintk FRklo))))
   7783 )
   7784 
   7785 (dni mhsethis
   7786      "Media set upper signed 12 bits"
   7787      ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
   7788       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7789      "mhsethis$pack $u12,$FRkhi"
   7790      (+ pack FRkhi OP_78 OPE1_22 u12)
   7791      (set FRkhi u12)
   7792      ((fr400 (unit u-media-hilo)) (fr450 (unit u-media-hilo))
   7793       (fr550 (unit u-media-set (out FRintk FRkhi))))
   7794 )
   7795 
   7796 (dni mhdsets
   7797      "Media dual set halfword signed 12 bits"
   7798      ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
   7799       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7800      "mhdsets$pack $u12,$FRintk"
   7801      (+ pack FRintk OP_78 OPE1_24 u12)
   7802      (sequence ()
   7803 	       ; hack to get FRintk passed to modelling functions
   7804 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   7805 	       (set (halfword hi FRintk 0) u12)
   7806 	       (set (halfword lo FRintk 0) u12))
   7807      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   7808       (fr550 (unit u-media-set)))
   7809 )
   7810 
   7811 (define-pmacro (set-5-semantics target value)
   7812   (sequence ((HI tmp))
   7813 	    (set tmp target)
   7814 	    (set tmp (and tmp #x07ff))
   7815 	    (set tmp (or tmp (sll (and s5 #x1f) 11)))
   7816 	    (set target tmp))
   7817 )
   7818 
   7819 (define-pmacro (media-set-5 name hilo op ope comment)
   7820   (dni name
   7821        (comment)
   7822        ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
   7823 	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7824        (.str name "$pack $s5,$FRk" hilo)
   7825        (+ pack (.sym FRk hilo) op (FRi-null) ope (misc-null-11) s5)
   7826        (set-5-semantics (.sym FRk hilo) s5)
   7827        ((fr400 (unit u-media-hilo)) (fr450 (unit u-media-hilo))
   7828 	(fr550 (unit u-media-set (out FRintk (.sym FRk hilo)))))
   7829   )
   7830 )
   7831 
   7832 (media-set-5 mhsetloh lo OP_78 OPE1_21 "Media set upper 5 bits lo")
   7833 (media-set-5 mhsethih hi OP_78 OPE1_23 "Media set upper 5 bits hi")
   7834 
   7835 (dni mhdseth
   7836      "Media dual set halfword upper 5 bits"
   7837      ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-5)
   7838       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7839      "mhdseth$pack $s5,$FRintk"
   7840      (+ pack FRintk OP_78 (FRi-null) OPE1_25 (misc-null-11) s5)
   7841      (sequence ()
   7842 	       ; hack to get FRintk passed to modelling functions
   7843 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   7844 	       (set-5-semantics (halfword hi FRintk 0) s5)
   7845 	       (set-5-semantics (halfword lo FRintk 0) s5))
   7846      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   7847       (fr550 (unit u-media-set)))
   7848 )
   7849 
   7850 (define-pmacro (media-logic-r-r name operation op ope comment)
   7851   (dni name
   7852        (comment)
   7853        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   7854 	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7855        (.str name "$pack $FRinti,$FRintj,$FRintk")
   7856        (+ pack FRintk op FRinti ope FRintj)
   7857        (set FRintk (operation FRinti FRintj))
   7858        ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   7859 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   7860   )
   7861 )
   7862 
   7863 (media-logic-r-r mand and OP_7B OPE1_00 "and reg/reg")
   7864 (media-logic-r-r mor  or  OP_7B OPE1_01 "or  reg/reg")
   7865 (media-logic-r-r mxor xor OP_7B OPE1_02 "xor reg/reg")
   7866 
   7867 (define-pmacro (conditional-media-logic name operation op ope comment)
   7868   (dni name
   7869        (comment)
   7870        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   7871 	(FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
   7872        (.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
   7873        (+ pack FRintk op FRinti CCi cond ope FRintj)
   7874        (if (eq CCi (or cond 2))
   7875 	   (set FRintk (operation FRinti FRintj)))
   7876        ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   7877 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   7878   )
   7879 )
   7880 
   7881 (conditional-media-logic cmand and OP_70 OPE4_0 "conditional and reg/reg")
   7882 (conditional-media-logic cmor  or  OP_70 OPE4_1 "conditional or  reg/reg")
   7883 (conditional-media-logic cmxor xor OP_70 OPE4_2 "conditional xor reg/reg")
   7884 
   7885 (dni mnot
   7886      ("mnot")
   7887      ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   7888       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7889      ("mnot$pack $FRintj,$FRintk")
   7890      (+ pack FRintk OP_7B (rs-null) OPE1_03 FRintj)
   7891      (set FRintk (inv FRintj))
   7892      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   7893       (fr500 (unit u-media)) (fr550 (unit u-media)))
   7894 )
   7895 
   7896 (dni cmnot
   7897      ("cmnot")
   7898      ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   7899       (FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
   7900      ("cmnot$pack $FRintj,$FRintk,$CCi,$cond")
   7901      (+ pack FRintk OP_70 (rs-null) CCi cond OPE4_3 FRintj)
   7902      (if (eq CCi (or cond 2))
   7903 	 (set FRintk (inv FRintj)))
   7904      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   7905       (fr500 (unit u-media)) (fr550 (unit u-media)))
   7906 )
   7907 
   7908 (define-pmacro (media-rotate-r-r name operation op ope comment)
   7909   (dni name
   7910        (comment)
   7911        ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   7912 	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
   7913        (.str name "$pack $FRinti,$u6,$FRintk")
   7914        (+ pack FRintk op FRinti ope u6)
   7915        (set FRintk (operation FRinti (and u6 #x1f)))
   7916        ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   7917 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   7918   )
   7919 )
   7920 
   7921 (media-rotate-r-r mrotli rol OP_7B OPE1_04 "rotate left reg/reg")
   7922 (media-rotate-r-r mrotri ror OP_7B OPE1_05 "rotate right reg/reg")
   7923 
   7924 (define-pmacro (media-cut-r-r name arg op ope comment)
   7925   (dni name
   7926        (comment)
   7927        ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   7928 	(FR400-MAJOR M-2) (FR450-MAJOR M-2))
   7929        (.str name "$pack $FRinti,$" arg ",$FRintk")
   7930        (+ pack FRintk op FRinti ope arg)
   7931        (set FRintk (c-call SI "@cpu@_cut" FRinti (nextreg h-fr_int FRinti 1) arg))
   7932        ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   7933 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   7934   )
   7935 )
   7936 
   7937 (media-cut-r-r mwcut  FRintj OP_7B OPE1_06 "media cut")
   7938 (media-cut-r-r mwcuti u6     OP_7B OPE1_07 "media cut")
   7939 
   7940 (define-pmacro (media-cut-acc name arg op ope fr450-major comment)
   7941   (dni name
   7942        (comment)
   7943        ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   7944 	(FR400-MAJOR M-1) (FR450-MAJOR fr450-major))
   7945        (.str name "$pack $ACC40Si,$" arg ",$FRintk")
   7946        (+ pack FRintk op ACC40Si ope arg)
   7947        (set FRintk (c-call SI "@cpu@_media_cut" ACC40Si arg))
   7948        ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
   7949 	(fr500 (unit u-media)) (fr550 (unit u-media-3-acc)))
   7950   )
   7951 )
   7952 
   7953 (media-cut-acc mcut  FRintj OP_7B OPE1_2C M-1 "media accumulator cut reg")
   7954 (media-cut-acc mcuti s6     OP_7B OPE1_2E M-5 "media accumulator cut immed")
   7955 
   7956 (define-pmacro (media-cut-acc-ss name arg op ope fr450-major comment)
   7957   (dni name
   7958        (comment)
   7959        ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   7960 	(FR400-MAJOR M-1) (FR450-MAJOR fr450-major))
   7961        (.str name "$pack $ACC40Si,$" arg ",$FRintk")
   7962        (+ pack FRintk op ACC40Si ope arg)
   7963        (set FRintk (c-call SI "@cpu@_media_cut_ss" ACC40Si arg))
   7964        ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
   7965 	(fr500 (unit u-media)) (fr550 (unit u-media-3-acc)))
   7966   )
   7967 )
   7968 
   7969 (media-cut-acc-ss mcutss  FRintj OP_7B OPE1_2D M-1 "media accumulator cut reg with saturation")
   7970 (media-cut-acc-ss mcutssi s6     OP_7B OPE1_2F M-5 "media accumulator cut immed with saturation")
   7971 
   7972 ; Dual Media Instructions
   7973 ;
   7974 (define-pmacro (register-unaligned register alignment)
   7975   (and (index-of register) (sub alignment 1))
   7976 )
   7977 
   7978 (dni mdcutssi
   7979      "Media dual cut with signed saturation"
   7980      ((UNIT MDCUTSSI) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
   7981       (FR400-MAJOR M-2) (FR450-MAJOR M-6))
   7982      "mdcutssi$pack $ACC40Si,$s6,$FRintkeven"
   7983      (+ pack FRintkeven OP_78 ACC40Si OPE1_0E s6)
   7984      (if (register-unaligned ACC40Si 2)
   7985 	 (c-call VOID "@cpu@_media_acc_not_aligned")
   7986 	 (if (register-unaligned FRintkeven 2)
   7987 	     (c-call VOID "@cpu@_media_register_not_aligned")
   7988 	     (sequence ()
   7989 		       (set FRintkeven (c-call SI "@cpu@_media_cut_ss" ACC40Si s6))
   7990 		       (set (nextreg h-fr_int FRintkeven 1)
   7991 			    (c-call SI "@cpu@_media_cut_ss"
   7992 				    (nextreg h-acc40S ACC40Si 1) s6)))))
   7993      ((fr400 (unit u-media-4-acc-dual
   7994 		   (out FRintk FRintkeven)))
   7995       (fr450 (unit u-media-4-acc-dual
   7996 		   (out FRintk FRintkeven)))
   7997       (fr550 (unit u-media-3-acc-dual)))
   7998 )
   7999 
   8000 ; The (add (xxxx) (mul arg 0)) is a hack to get a reference to arg generated
   8001 ; so it will be passed to the unit modelers.   YUCK!!!!!
   8002 (define-pmacro (extract-hilo reg1 off1 reg2 off2 arg1hi arg1lo arg2hi arg2lo)
   8003   (sequence ()
   8004 	    (set arg1hi (add (halfword hi reg1 off1) (mul reg1 0)))
   8005 	    (set arg1lo (add (halfword lo reg1 off1) (mul reg1 0)))
   8006 	    (set arg2hi (add (halfword hi reg2 off2) (mul reg2 0)))
   8007 	    (set arg2lo (add (halfword lo reg2 off2) (mul reg2 0))))
   8008 )
   8009 
   8010 (dni maveh
   8011      "Media dual average"
   8012      ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8013       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8014      "maveh$pack $FRinti,$FRintj,$FRintk"
   8015      (+ pack FRintk OP_7B FRinti OPE1_08 FRintj)
   8016      (set FRintk (c-call SI "@cpu@_media_average" FRinti FRintj))
   8017      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   8018       (fr500 (unit u-media)) (fr550 (unit u-media)))
   8019 )
   8020 
   8021 (define-pmacro (media-dual-shift name operation op ope profile comment)
   8022   (dni name
   8023        (comment)
   8024        ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   8025 	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8026        (.str name "$pack $FRinti,$u6,$FRintk")
   8027        (+ pack FRintk op FRinti ope u6)
   8028        (sequence ()
   8029 		 ; hack to get these referenced for profiling
   8030 		 (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
   8031 		 (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   8032 		 (set (halfword hi FRintk 0)
   8033 		      (operation (halfword hi FRinti 0) (and u6 #xf)))
   8034 		 (set (halfword lo FRintk 0)
   8035 		      (operation (halfword lo FRinti 0) (and u6 #xf))))
   8036        profile
   8037   )
   8038 )
   8039 
   8040 (media-dual-shift msllhi sll OP_7B OPE1_09
   8041 		  ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   8042 		   (fr500 (unit u-media)) (fr550 (unit u-media)))
   8043 		  "Media dual shift left  logical")
   8044 (media-dual-shift msrlhi srl OP_7B OPE1_0A
   8045 		  ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   8046 		   (fr500 (unit u-media)) (fr550 (unit u-media)))
   8047 		  "Media dual shift right logical")
   8048 (media-dual-shift msrahi sra OP_7B OPE1_0B
   8049 		  ((fr400 (unit u-media-6)) (fr450 (unit u-media-6))
   8050 		   (fr500 (unit u-media)) (fr550 (unit u-media)))
   8051 		  "Media dual shift right arithmetic")
   8052 
   8053 (define-pmacro (media-dual-word-rotate-r-r name operation op ope comment)
   8054   (dni name
   8055        (comment)
   8056        ((UNIT FMLOW) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
   8057 	(FR400-MAJOR M-2) (FR450-MAJOR M-2))
   8058        (.str name "$pack $FRintieven,$s6,$FRintkeven")
   8059        (+ pack FRintkeven op FRintieven ope s6)
   8060        (if (orif (register-unaligned FRintieven 2)
   8061 		 (register-unaligned FRintkeven 2))
   8062 	   (c-call VOID "@cpu@_media_register_not_aligned")
   8063 	   (sequence ()
   8064 		     (set FRintkeven (operation FRintieven (and s6 #x1f)))
   8065 		     (set (nextreg h-fr_int FRintkeven 1)
   8066 			  (operation (nextreg h-fr_int FRintieven 1)
   8067 				     (and s6 #x1f)))))
   8068        ((fr400 (unit u-media-3-quad
   8069 		     (in  FRinti FRintieven)
   8070 		     (out FRintk FRintkeven))) 
   8071 	(fr450 (unit u-media-3-quad
   8072 		     (in  FRinti FRintieven)
   8073 		     (out FRintk FRintkeven)))
   8074 	(fr550 (unit u-media-quad)))
   8075   )
   8076 )
   8077 
   8078 (media-dual-word-rotate-r-r mdrotli rol OP_78 OPE1_0B "rotate left reg/reg")
   8079 
   8080 (dni mcplhi
   8081      "Media bit concatenate, halfword"
   8082      ((UNIT FMLOW) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
   8083       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   8084      "mcplhi$pack $FRinti,$u6,$FRintk"
   8085      (+ pack FRintk OP_78 FRinti OPE1_0C u6)
   8086      (sequence ((HI arg1) (HI arg2) (HI shift))
   8087 	       (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
   8088 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   8089 	       (set shift (and u6 #xf))
   8090 	       (set arg1 (sll (halfword hi FRinti 0) shift))
   8091 	       (if (ne shift 0)
   8092 		   (sequence ()
   8093 			     (set arg2 (halfword hi FRinti 1))
   8094 			     (set arg2 (srl HI (sll HI arg2 (sub 15 shift))
   8095 					    (sub 15 shift)))
   8096 			     (set arg1 (or HI arg1 arg2))))
   8097 	       (set (halfword hi FRintk 0) arg1))
   8098      ((fr400 (unit u-media-3-dual)) (fr450 (unit u-media-3-dual))
   8099       (fr550 (unit u-media-3-dual)))
   8100 )
   8101 
   8102 (dni mcpli
   8103      "Media bit concatenate, word"
   8104      ((UNIT FMLOW) (MACH fr400,fr450,fr550) (FR550-MAJOR M-3)
   8105       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   8106      "mcpli$pack $FRinti,$u6,$FRintk"
   8107      (+ pack FRintk OP_78 FRinti OPE1_0D u6)
   8108      (sequence ((SI tmp) (SI shift))
   8109 	       (set shift (and u6 #x1f))
   8110 	       (set tmp (sll FRinti shift))
   8111 	       (if (ne shift 0)
   8112 		   (sequence ((SI tmp1))
   8113 			     (set tmp1 (srl (sll (nextreg h-fr_int FRinti 1)
   8114 						 (sub 31 shift))
   8115 					    (sub 31 shift)))
   8116 			     (set tmp (or tmp tmp1))))
   8117 	       (set FRintk tmp))
   8118      ((fr400 (unit u-media-3-dual)) (fr450 (unit u-media-3-dual))
   8119       (fr550 (unit u-media-3-dual)))
   8120 )
   8121 
   8122 (define-pmacro (saturate arg max min result)
   8123   (if (gt arg max)
   8124       (set result max)
   8125       (if (lt arg min)
   8126 	  (set result min)
   8127 	  (set result arg)))
   8128 )
   8129 
   8130 (dni msaths
   8131      "Media dual saturation signed"
   8132      ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8133       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8134      "msaths$pack $FRinti,$FRintj,$FRintk"
   8135      (+ pack FRintk OP_7B FRinti OPE1_0C FRintj)
   8136      (sequence ((HI argihi) (HI argilo) (HI argjhi) (HI argjlo))
   8137 	       (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
   8138 	       (saturate argihi argjhi (inv argjhi) (halfword hi FRintk 0))
   8139 	       (saturate argilo argjlo (inv argjlo) (halfword lo FRintk 0)))
   8140      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   8141       (fr500 (unit u-media)) (fr550 (unit u-media)))
   8142 )
   8143 
   8144 (dni mqsaths
   8145      "Media quad saturation signed"
   8146      ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-2)
   8147       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   8148      "mqsaths$pack $FRintieven,$FRintjeven,$FRintkeven"
   8149      (+ pack FRintkeven OP_78 FRintieven OPE1_0F FRintjeven)
   8150      (if (orif (register-unaligned FRintieven 2)
   8151 	       (orif (register-unaligned FRintjeven 2)
   8152 		     (register-unaligned FRintkeven 2)))
   8153 	 (c-call VOID "@cpu@_media_register_not_aligned")
   8154 	 (sequence ((HI argihi) (HI argilo) (HI argjhi) (HI argjlo))
   8155 		   ; hack to get FRintkeven referenced as a target for profiling
   8156 		   (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   8157 		   (extract-hilo FRintieven 0 FRintjeven 0 argihi argilo argjhi argjlo)
   8158 		   (saturate argihi argjhi (inv argjhi) (halfword hi FRintkeven 0))
   8159 		   (saturate argilo argjlo (inv argjlo) (halfword lo FRintkeven 0))
   8160 		   (extract-hilo FRintieven 1 FRintjeven 1 argihi argilo argjhi argjlo)
   8161 		   (saturate argihi argjhi (inv argjhi) (halfword hi FRintkeven 1))
   8162 		   (saturate argilo argjlo (inv argjlo) (halfword lo FRintkeven 1))))
   8163      ((fr400 (unit u-media-1-quad
   8164 		   (in  FRinti FRintieven)
   8165 		   (in  FRintj FRintjeven)
   8166 		   (out FRintk FRintkeven)))
   8167       (fr450 (unit u-media-1-quad
   8168 		   (in  FRinti FRintieven)
   8169 		   (in  FRintj FRintjeven)
   8170 		   (out FRintk FRintkeven)))
   8171       (fr550 (unit u-media-quad)))
   8172 )
   8173 
   8174 (define-pmacro (saturate-unsigned arg max result)
   8175   (if (gt arg max)
   8176       (set result max)
   8177       (set result arg))
   8178 )
   8179 
   8180 (dni msathu
   8181      "Media dual saturation unsigned"
   8182      ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8183       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8184      "msathu$pack $FRinti,$FRintj,$FRintk"
   8185      (+ pack FRintk OP_7B FRinti OPE1_0D FRintj)
   8186      (sequence ((UHI argihi) (UHI argilo) (UHI argjhi) (UHI argjlo))
   8187 	       (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
   8188 	       (saturate-unsigned argihi argjhi (halfword hi FRintk 0))
   8189 	       (saturate-unsigned argilo argjlo (halfword lo FRintk 0)))
   8190      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   8191       (fr500 (unit u-media)) (fr550 (unit u-media)))
   8192 )
   8193 
   8194 (define-pmacro (media-dual-compare name mode op ope comment)
   8195   (dni name
   8196        (comment)
   8197        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8198 	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8199        (.str name "$pack $FRinti,$FRintj,$FCCk")
   8200        (+ pack (cond-null) FCCk op FRinti ope FRintj)
   8201        (if (register-unaligned FCCk 2)
   8202 	   (c-call VOID "@cpu@_media_cr_not_aligned")
   8203 	   (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   8204 		     (extract-hilo FRinti 0 FRintj 0
   8205 				   argihi argilo argjhi argjlo)
   8206 		     (compare-and-set-fcc argihi argjhi FCCk)
   8207 		     (compare-and-set-fcc argilo argjlo (nextreg h-fccr FCCk 1))))
   8208        ; TODO - doesn't handle second FCC
   8209        ((fr400 (unit u-media-7)) (fr450 (unit u-media-7))
   8210 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   8211   )
   8212 )
   8213 
   8214 (media-dual-compare mcmpsh HI  OP_7B OPE1_0E "Media dual compare signed")
   8215 (media-dual-compare mcmpuh UHI OP_7B OPE1_0F "Media dual compare unsigned")
   8216 
   8217 ; Bits for the MSR.SIE field
   8218 (define-pmacro (msr-sie-nil)      0)
   8219 (define-pmacro (msr-sie-fri-hi)   8)
   8220 (define-pmacro (msr-sie-fri-lo)   4)
   8221 (define-pmacro (msr-sie-fri-1-hi) 2)
   8222 (define-pmacro (msr-sie-fri-1-lo) 1)
   8223 (define-pmacro (msr-sie-acci)     8)
   8224 (define-pmacro (msr-sie-acci-1)   4)
   8225 (define-pmacro (msr-sie-acci-2)   2)
   8226 (define-pmacro (msr-sie-acci-3)   1)
   8227 
   8228 (define-pmacro (saturate-v arg max min sie result)
   8229   (if (gt DI arg max)
   8230       (sequence ()
   8231 		(set result max)
   8232 		(c-call VOID "@cpu@_media_overflow" sie))
   8233       (if (lt DI arg min)
   8234 	  (sequence ()
   8235 		    (set result min)
   8236 		    (c-call VOID "@cpu@_media_overflow" sie))
   8237 	  (set result arg)))
   8238 )
   8239 
   8240 (dni mabshs
   8241      "Media dual absolute value, halfword"
   8242      ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-2)
   8243       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8244      "mabshs$pack $FRintj,$FRintk"
   8245      (+ pack FRintk OP_78 (FRi-null) OPE1_0A FRintj)
   8246      (sequence ((HI arghi) (HI arglo))
   8247 	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
   8248 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   8249 	       (set arghi (halfword hi FRintj 0))
   8250 	       (set arglo (halfword lo FRintj 0))
   8251 	       ; We extend the argument before the abs operation so we can
   8252 	       ; notice -32768 overflowing as 32768.
   8253 	       (saturate-v (abs (ext DI arghi)) 32767 -32768 (msr-sie-fri-hi)
   8254 			   (halfword hi FRintk 0))
   8255 	       (saturate-v (abs (ext DI arglo)) 32767 -32768 (msr-sie-fri-lo)
   8256 			   (halfword lo FRintk 0)))
   8257      ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   8258       (fr550 (unit u-media)))
   8259 )
   8260 
   8261 ; How to extend from a mode to get the intended signedness.
   8262 (define-pmacro (DI-ext-HI x) (ext DI x))
   8263 (define-pmacro (DI-ext-UHI x) (zext DI x))
   8264 (define-pmacro (DI-ext-DI x) x)
   8265 
   8266 (define-pmacro (media-arith-sat-semantics
   8267 		operation arg1 arg2 res mode max min sie)
   8268   (sequence ((DI tmp))
   8269 	    ; Make sure we saturate at max/min against a value that is
   8270 	    ; sign- or zero-extended appropriately from "mode".
   8271 	    (set tmp (operation DI
   8272 		      ((.sym DI-ext- mode) arg1) ((.sym DI-ext- mode) arg2)))
   8273 	    (saturate-v tmp max min sie res))
   8274 )
   8275 
   8276 (define-pmacro (media-dual-arith-sat-semantics operation mode max min)
   8277   (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   8278 	    (extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
   8279 	    (media-arith-sat-semantics operation argihi argjhi
   8280 				       (halfword hi FRintk 0) mode max min
   8281 				       (msr-sie-fri-hi))
   8282 	    (media-arith-sat-semantics operation argilo argjlo
   8283 				       (halfword lo FRintk 0) mode max min
   8284 				       (msr-sie-fri-lo)))
   8285 )
   8286 
   8287 (define-pmacro (media-dual-arith-sat name operation mode max min op ope comment)
   8288   (dni name
   8289        (comment)
   8290        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8291 	(FR400-MAJOR M-1) (FR450-MAJOR M-1))
   8292        (.str name "$pack $FRinti,$FRintj,$FRintk")
   8293        (+ pack FRintk op FRinti ope FRintj)
   8294        (media-dual-arith-sat-semantics operation mode max min)
   8295        ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   8296 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   8297   )
   8298 )
   8299 
   8300 (media-dual-arith-sat maddhss add  HI 32767 -32768 OP_7B OPE1_10 "Media dual add signed with saturation")
   8301 (media-dual-arith-sat maddhus add UHI 65535      0 OP_7B OPE1_11 "Media dual add unsigned with saturation")
   8302 
   8303 (media-dual-arith-sat msubhss sub  HI 32767 -32768 OP_7B OPE1_12 "Media dual sub signed with saturation")
   8304 (media-dual-arith-sat msubhus sub UHI 65535      0 OP_7B OPE1_13 "Media dual sub unsigned with saturation")
   8305 
   8306 (define-pmacro (conditional-media-dual-arith-sat
   8307 		name operation mode max min op ope comment)
   8308   (dni name
   8309        (comment)
   8310        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8311 	(FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
   8312        (.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
   8313        (+ pack FRintk op FRinti CCi cond ope FRintj)
   8314        (if (eq CCi (or cond 2))
   8315 	   (media-dual-arith-sat-semantics operation mode max min))
   8316        ((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
   8317 	(fr500 (unit u-media)) (fr550 (unit u-media)))
   8318   )
   8319 )
   8320 
   8321 (conditional-media-dual-arith-sat cmaddhss add  HI 32767 -32768 OP_71 OPE4_0 "Conditional Media dual add signed with saturation")
   8322 (conditional-media-dual-arith-sat cmaddhus add UHI 65535      0 OP_71 OPE4_1 "Conditional Media dual add unsigned with saturation")
   8323 
   8324 (conditional-media-dual-arith-sat cmsubhss sub  HI 32767 -32768 OP_71 OPE4_2 "Conditional Media dual sub signed with saturation")
   8325 (conditional-media-dual-arith-sat cmsubhus sub UHI 65535      0 OP_71 OPE4_3 "Conditional Media dual sub unsigned with saturation")
   8326 
   8327 (define-pmacro (media-quad-arith-sat-semantics cond operation mode max min)
   8328   (if (orif (register-unaligned FRintieven 2)
   8329 	    (orif (register-unaligned FRintjeven 2)
   8330 		  (register-unaligned FRintkeven 2)))
   8331       (c-call VOID "@cpu@_media_register_not_aligned")
   8332       (if cond
   8333 	  (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   8334 		    ; hack to get FRintkeven referenced as a target for profiling
   8335 		    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   8336 		    (extract-hilo FRintieven 0 FRintjeven 0
   8337 				  argihi argilo argjhi argjlo)
   8338 		    (media-arith-sat-semantics operation argihi argjhi
   8339 					       (halfword hi FRintkeven 0) mode
   8340 					       max min (msr-sie-fri-hi))
   8341 		    (media-arith-sat-semantics operation argilo argjlo
   8342 					       (halfword lo FRintkeven 0) mode
   8343 					       max min (msr-sie-fri-lo))
   8344 		    (extract-hilo FRintieven 1 FRintjeven 1
   8345 				  argihi argilo argjhi argjlo)
   8346 		    (media-arith-sat-semantics operation argihi argjhi
   8347 					       (halfword hi FRintkeven 1) mode
   8348 					       max min	(msr-sie-fri-1-hi))
   8349 		    (media-arith-sat-semantics operation argilo argjlo
   8350 					       (halfword lo FRintkeven 1) mode
   8351 					       max min (msr-sie-fri-1-lo)))))
   8352 )
   8353 
   8354 (define-pmacro (media-quad-arith-sat name operation mode max min op ope comment)
   8355   (dni name
   8356        (comment)
   8357        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8358 	(FR400-MAJOR M-2) (FR450-MAJOR M-2))
   8359        (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
   8360        (+ pack FRintkeven op FRintieven ope FRintjeven)
   8361        (media-quad-arith-sat-semantics 1 operation mode max min)
   8362        ((fr400 (unit u-media-1-quad
   8363 		     (in  FRinti FRintieven)
   8364 		     (in  FRintj FRintjeven)
   8365 		     (out FRintk FRintkeven)))
   8366 	(fr450 (unit u-media-1-quad
   8367 		     (in  FRinti FRintieven)
   8368 		     (in  FRintj FRintjeven)
   8369 		     (out FRintk FRintkeven)))
   8370 	(fr500 (unit u-media-quad-arith
   8371 		     (in  FRinti FRintieven)
   8372 		     (in  FRintj FRintjeven)
   8373 		     (out FRintk FRintkeven))) (fr550 (unit u-media-quad)))
   8374   )
   8375 )
   8376 
   8377 (media-quad-arith-sat mqaddhss add  HI 32767 -32768 OP_7B OPE1_18 "Media quad add signed with saturation")
   8378 (media-quad-arith-sat mqaddhus add UHI 65535      0 OP_7B OPE1_19 "Media quad add unsigned with saturation")
   8379 
   8380 (media-quad-arith-sat mqsubhss sub  HI 32767 -32768 OP_7B OPE1_1A "Media quad sub signed with saturation")
   8381 (media-quad-arith-sat mqsubhus sub UHI 65535      0 OP_7B OPE1_1B "Media quad sub unsigned with saturation")
   8382 
   8383 (define-pmacro (conditional-media-quad-arith-sat
   8384 		name operation mode max min op ope comment)
   8385   (dni name
   8386        (comment)
   8387        ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
   8388 	(FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
   8389        (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven,$CCi,$cond")
   8390        (+ pack FRintkeven op FRintieven CCi cond ope FRintjeven)
   8391        (media-quad-arith-sat-semantics (eq CCi (or cond 2))
   8392 				       operation mode max min)
   8393        ((fr400 (unit u-media-1-quad
   8394 		     (in  FRinti FRintieven)
   8395 		     (in  FRintj FRintjeven)
   8396 		     (out FRintk FRintkeven)))
   8397 	(fr450 (unit u-media-1-quad
   8398 		     (in  FRinti FRintieven)
   8399 		     (in  FRintj FRintjeven)
   8400 		     (out FRintk FRintkeven)))
   8401 	(fr500 (unit u-media-quad-arith
   8402 		     (in  FRinti FRintieven)
   8403 		     (in  FRintj FRintjeven)
   8404 		     (out FRintk FRintkeven))) (fr550 (unit u-media-quad)))
   8405   )
   8406 )
   8407 
   8408 (conditional-media-quad-arith-sat cmqaddhss add  HI 32767 -32768 OP_73 OPE4_0 "Conditional Media quad add signed with saturation")
   8409 (conditional-media-quad-arith-sat cmqaddhus add UHI 65535      0 OP_73 OPE4_1 "Conditional Media quad add unsigned with saturation")
   8410 
   8411 (conditional-media-quad-arith-sat cmqsubhss sub  HI 32767 -32768 OP_73 OPE4_2 "Conditional Media quad sub signed with saturation")
   8412 (conditional-media-quad-arith-sat cmqsubhus sub UHI 65535      0 OP_73 OPE4_3 "Conditional Media quad sub unsigned with saturation")
   8413 
   8414 ;; Return A if |A| > |B| and B is positive.  Return -A if |A| > |B| and
   8415 ;; B is negative, saturating 0x8000 as 0x7fff.  Return 0 otherwise.
   8416 (define-pmacro (media-low-clear-semantics a b)
   8417   (cond HI
   8418 	((le UHI (abs a) (abs b)) 0)
   8419 	((le HI 0 b) a)
   8420 	((eq HI a -32768) 32767)
   8421 	(else (neg a))))
   8422 
   8423 ;; Return A if -|B| < A < |B|.  Return -B if A <= -|B|, saturating 0x8000
   8424 ;; as 0x7fff.  Return B if A >= |B|.
   8425 (define-pmacro (media-scope-limit-semantics a b)
   8426   (cond HI
   8427 	((andif (gt HI b -32768)
   8428 		(ge HI a (abs b))) b)
   8429 	((gt HI a (neg (abs b))) a)
   8430 	((eq HI b -32768) 32767)
   8431 	(else (neg b))))
   8432 
   8433 (define-pmacro (media-quad-limit name operation op ope comment)
   8434   (dni name
   8435        comment
   8436        ((UNIT FM0) (MACH fr450) (FR450-MAJOR M-2))
   8437        (.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
   8438        (+ pack FRintkeven op FRintieven ope FRintjeven)
   8439        (if (orif (register-unaligned FRintieven 2)
   8440 		 (orif (register-unaligned FRintjeven 2)
   8441 		       (register-unaligned FRintkeven 2)))
   8442 	   (c-call VOID "@cpu@_media_register_not_aligned")
   8443 	   (sequence ((HI a1) (HI a2) (HI a3) (HI a4)
   8444 		      (HI b1) (HI b2) (HI b3) (HI b4))
   8445 		     ; hack to get FRintkeven referenced as a target
   8446 		     ; for profiling
   8447 		     (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   8448 		     (extract-hilo FRintieven 0 FRintjeven 0 a1 a2 b1 b2)
   8449 		     (extract-hilo FRintieven 1 FRintjeven 1 a3 a4 b3 b4)
   8450 		     (set (halfword hi FRintkeven 0) (operation a1 b1))
   8451 		     (set (halfword lo FRintkeven 0) (operation a2 b2))
   8452 		     (set (halfword hi FRintkeven 1) (operation a3 b3))
   8453 		     (set (halfword lo FRintkeven 1) (operation a4 b4))))
   8454        ((fr450 (unit u-media-1-quad
   8455 		     (in  FRinti FRintieven)
   8456 		     (in  FRintj FRintjeven)
   8457 		     (out FRintk FRintkeven))))
   8458   )
   8459 )
   8460 
   8461 (media-quad-limit mqlclrhs media-low-clear-semantics OP_78 OPE1_10
   8462 		  "Media quad low clear")
   8463 (media-quad-limit mqlmths media-scope-limit-semantics OP_78 OPE1_14
   8464 		  "Media quad scope limitation")
   8465 
   8466 (define-pmacro (media-quad-shift name operation op ope comment)
   8467   (dni name
   8468        (comment)
   8469        ((UNIT FM0) (MACH fr450) (FR450-MAJOR M-2))
   8470        (.str name "$pack $FRintieven,$u6,$FRintkeven")
   8471        (+ pack FRintkeven op FRintieven ope u6)
   8472        (if (orif (register-unaligned FRintieven 2)
   8473 		 (register-unaligned FRintkeven 2))
   8474 	   (c-call VOID "@cpu@_media_register_not_aligned")
   8475 	   (sequence ()
   8476 		     ; hack to get these referenced for profiling
   8477 		     (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
   8478 		     (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   8479 		     (set (halfword hi FRintkeven 0)
   8480 			  (operation HI (halfword hi FRintieven 0)
   8481 					(and u6 #xf)))
   8482 		     (set (halfword lo FRintkeven 0)
   8483 			  (operation HI (halfword lo FRintieven 0)
   8484 					(and u6 #xf)))
   8485 		     (set (halfword hi FRintkeven 1)
   8486 			  (operation HI (halfword hi FRintieven 1)
   8487 					(and u6 #xf)))
   8488 		     (set (halfword lo FRintkeven 1)
   8489 			  (operation HI (halfword lo FRintieven 1)
   8490 					(and u6 #xf)))))
   8491        ((fr450 (unit u-media-3-quad
   8492 		     (in  FRinti FRintieven)
   8493 		     (in  FRintj FRintieven)
   8494 		     (out FRintk FRintkeven))))
   8495   )
   8496 )
   8497 
   8498 (media-quad-shift mqsllhi sll OP_78 OPE1_11 "Media quad left shift")
   8499 (media-quad-shift mqsrahi sra OP_78 OPE1_13 "Media quad right shift")
   8500 
   8501 (define-pmacro (media-acc-arith-sat name operation mode max min op ope comment)
   8502   (dni name
   8503        (comment)
   8504        ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   8505 	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
   8506        (.str name "$pack $ACC40Si,$ACC40Sk")
   8507        (+ pack ACC40Sk op ACC40Si ope (ACCj-null))
   8508        (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
   8509 	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   8510 	       (if (register-unaligned ACC40Si 2)
   8511 		   (c-call VOID "@cpu@_media_acc_not_aligned")
   8512 		   (media-arith-sat-semantics operation ACC40Si
   8513 					      (nextreg h-acc40S ACC40Si 1)
   8514 					      ACC40Sk mode max min (msr-sie-acci)))))
   8515        ((fr400 (unit u-media-2-acc)) (fr450 (unit u-media-2-acc))
   8516 	(fr550 (unit u-media-4-acc)))
   8517   )
   8518 )
   8519 
   8520 (media-acc-arith-sat maddaccs add DI #x7fffffffff (inv DI #x7fffffffff)
   8521 		     OP_78 OPE1_04 "Media accumulator addition")
   8522 (media-acc-arith-sat msubaccs sub DI #x7fffffffff (inv DI #x7fffffffff)
   8523 		     OP_78 OPE1_05 "Media accumulator subtraction")
   8524 
   8525 (define-pmacro (media-dual-acc-arith-sat name operation mode max min op ope
   8526 					 comment)
   8527   (dni name
   8528        (comment)
   8529        ((UNIT MDUALACC) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   8530 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   8531        (.str name "$pack $ACC40Si,$ACC40Sk")
   8532        (+ pack ACC40Sk op ACC40Si ope (ACCj-null))
   8533        (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
   8534 	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   8535 	       (if (register-unaligned ACC40Si 4)
   8536 		   (c-call VOID "@cpu@_media_acc_not_aligned")
   8537 		   (if (register-unaligned ACC40Sk 2)
   8538 		       (c-call VOID "@cpu@_media_acc_not_aligned")
   8539 		       (sequence ()
   8540 				 (media-arith-sat-semantics operation ACC40Si
   8541 							    (nextreg h-acc40S ACC40Si 1)
   8542 							    ACC40Sk mode max min
   8543 							    (msr-sie-acci))
   8544 				 (media-arith-sat-semantics operation
   8545 							    (nextreg h-acc40S ACC40Si 2)
   8546 							    (nextreg h-acc40S ACC40Si 3)
   8547 							    (nextreg h-acc40S ACC40Sk 1)
   8548 							    mode max min
   8549 							    (msr-sie-acci-1)))))))
   8550        ((fr400 (unit u-media-2-acc-dual)) (fr450 (unit u-media-2-acc-dual))
   8551 	(fr550 (unit u-media-4-acc-dual)))
   8552   )
   8553 )
   8554 
   8555 (media-dual-acc-arith-sat mdaddaccs add DI #x7fffffffff (inv DI #x7fffffffff)
   8556 			  OP_78 OPE1_06 "Media accumulator addition")
   8557 (media-dual-acc-arith-sat mdsubaccs sub DI #x7fffffffff (inv DI #x7fffffffff)
   8558 			  OP_78 OPE1_07 "Media accumulator subtraction")
   8559 
   8560 (dni masaccs
   8561      "Media add and subtract signed accumulator with saturation"
   8562        ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   8563 	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
   8564        "masaccs$pack $ACC40Si,$ACC40Sk"
   8565        (+ pack ACC40Sk OP_78 ACC40Si OPE1_08 (ACCj-null))
   8566        (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
   8567 	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   8568 	       (if (register-unaligned ACC40Si 2)
   8569 		   (c-call VOID "@cpu@_media_acc_not_aligned")
   8570 		   (if (register-unaligned ACC40Sk 2)
   8571 		       (c-call VOID "@cpu@_media_acc_not_aligned")
   8572 		       (sequence ()
   8573 				 (media-arith-sat-semantics add ACC40Si
   8574 							    (nextreg h-acc40S ACC40Si 1)
   8575 							    ACC40Sk DI
   8576 							    #x7fffffffff
   8577 							    (inv DI #x7fffffffff)
   8578 							    (msr-sie-acci))
   8579 				 (media-arith-sat-semantics sub ACC40Si
   8580 							    (nextreg h-acc40S ACC40Si 1)
   8581 							    (nextreg h-acc40S ACC40Sk 1)
   8582 							    DI
   8583 							    #x7fffffffff
   8584 							    (inv DI #x7fffffffff)
   8585 							    (msr-sie-acci-1)))))))
   8586        ((fr400 (unit u-media-2-add-sub)) (fr450 (unit u-media-2-add-sub))
   8587 	(fr550 (unit u-media-4-add-sub)))
   8588   )
   8589 
   8590 (dni mdasaccs
   8591      "Media add and subtract signed accumulator with saturation"
   8592        ((UNIT MDUALACC) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   8593 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   8594        "mdasaccs$pack $ACC40Si,$ACC40Sk"
   8595        (+ pack ACC40Sk OP_78 ACC40Si OPE1_09 (ACCj-null))
   8596        (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Si))
   8597 	   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   8598 	       (if (register-unaligned ACC40Si 4)
   8599 		   (c-call VOID "@cpu@_media_acc_not_aligned")
   8600 		   (if (register-unaligned ACC40Sk 4)
   8601 		       (c-call VOID "@cpu@_media_acc_not_aligned")
   8602 		       (sequence ()
   8603 				 (media-arith-sat-semantics add ACC40Si
   8604 							    (nextreg h-acc40S ACC40Si 1)
   8605 							    ACC40Sk DI
   8606 							    #x7fffffffff
   8607 							    (inv DI #x7fffffffff)
   8608 							    (msr-sie-acci))
   8609 				 (media-arith-sat-semantics sub ACC40Si
   8610 							    (nextreg h-acc40S ACC40Si 1)
   8611 							    (nextreg h-acc40S ACC40Sk 1)
   8612 							    DI
   8613 							    #x7fffffffff
   8614 							    (inv DI #x7fffffffff)
   8615 							    (msr-sie-acci-1))
   8616 				 (media-arith-sat-semantics add
   8617 							    (nextreg h-acc40S ACC40Si 2)
   8618 							    (nextreg h-acc40S ACC40Si 3)
   8619 							    (nextreg h-acc40S ACC40Sk 2)
   8620 							    DI
   8621 							    #x7fffffffff
   8622 							    (inv DI #x7fffffffff)
   8623 							    (msr-sie-acci-2))
   8624 				 (media-arith-sat-semantics sub
   8625 							    (nextreg h-acc40S ACC40Si 2)
   8626 							    (nextreg h-acc40S ACC40Si 3)
   8627 							    (nextreg h-acc40S ACC40Sk 3)
   8628 							    DI
   8629 							    #x7fffffffff
   8630 							    (inv DI #x7fffffffff)
   8631 							    (msr-sie-acci-3)))))))
   8632        ((fr400 (unit u-media-2-add-sub-dual))
   8633 	(fr450 (unit u-media-2-add-sub-dual))
   8634 	(fr550 (unit u-media-4-add-sub-dual)))
   8635   )
   8636 
   8637 (define-pmacro (media-multiply-semantics conv arg1 arg2 res)
   8638   (set res (mul DI (conv DI arg1) (conv DI arg2)))
   8639 )
   8640 
   8641 (define-pmacro (media-dual-multiply-semantics cond mode conv rhs1 rhs2)
   8642   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   8643       (if (register-unaligned ACC40Sk 2)
   8644 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   8645 	  (if cond
   8646 	      (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   8647 			(extract-hilo FRinti 0 FRintj 0
   8648 				      argihi argilo argjhi argjlo)
   8649 			(media-multiply-semantics conv argihi rhs1 ACC40Sk)
   8650 			(media-multiply-semantics conv argilo rhs2
   8651 						  (nextreg h-acc40S ACC40Sk 1))))))
   8652 )
   8653 
   8654 (define-pmacro (media-dual-multiply name mode conv rhs1 rhs2 op ope comment)
   8655   (dni name
   8656        (comment)
   8657        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8658 	(FR400-MAJOR M-1) (FR450-MAJOR M-3) PRESERVE-OVF)
   8659        (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
   8660        (+ pack ACC40Sk op FRinti ope FRintj)
   8661        (media-dual-multiply-semantics 1 mode conv rhs1 rhs2)
   8662        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   8663 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   8664   )
   8665 )
   8666 
   8667 (media-dual-multiply mmulhs  HI ext  argjhi argjlo OP_7B OPE1_14 "Media dual multiply signed")
   8668 (media-dual-multiply mmulhu UHI zext argjhi argjlo OP_7B OPE1_15 "Media dual multiply unsigned")
   8669 
   8670 (media-dual-multiply mmulxhs  HI ext  argjlo argjhi OP_7B OPE1_28 "Media dual cross multiply signed")
   8671 (media-dual-multiply mmulxhu UHI zext argjlo argjhi OP_7B OPE1_29 "Media dual cross multiply unsigned")
   8672 
   8673 (define-pmacro (conditional-media-dual-multiply
   8674 		name mode conv rhs1 rhs2 op ope comment)
   8675   (dni name
   8676        (comment)
   8677        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8678 	(FR400-MAJOR M-1) (FR450-MAJOR M-3)
   8679 	PRESERVE-OVF CONDITIONAL)
   8680        (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
   8681        (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
   8682        (media-dual-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
   8683        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   8684 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   8685   )
   8686 )
   8687 
   8688 (conditional-media-dual-multiply cmmulhs  HI ext  argjhi argjlo OP_72 OPE4_0 "Conditional Media dual multiply signed")
   8689 (conditional-media-dual-multiply cmmulhu UHI zext argjhi argjlo OP_72 OPE4_1 "Conditional Media dual multiply unsigned")
   8690 
   8691 (define-pmacro (media-quad-multiply-semantics cond mode conv rhs1 rhs2)
   8692   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   8693       (if (register-unaligned ACC40Sk 4)
   8694 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   8695 	  (if (orif (register-unaligned FRintieven 2)
   8696 		    (register-unaligned FRintjeven 2))
   8697 	      (c-call VOID "@cpu@_media_register_not_aligned")
   8698 	      (if cond
   8699 		  (sequence ((mode argihi) (mode argilo)
   8700 			     (mode argjhi) (mode argjlo))
   8701 			    (extract-hilo FRintieven 0 FRintjeven 0
   8702 					  argihi argilo argjhi argjlo)
   8703 			    (media-multiply-semantics conv argihi rhs1 ACC40Sk)
   8704 			    (media-multiply-semantics conv argilo rhs2
   8705 						      (nextreg h-acc40S ACC40Sk 1))
   8706 			    (extract-hilo FRintieven 1 FRintjeven 1
   8707 					  argihi argilo argjhi argjlo)
   8708 			    (media-multiply-semantics conv argihi rhs1
   8709 						      (nextreg h-acc40S ACC40Sk 2))
   8710 			    (media-multiply-semantics conv argilo rhs2
   8711 						      (nextreg h-acc40S ACC40Sk 3)))))))
   8712 )
   8713 
   8714 (define-pmacro (media-quad-multiply name mode conv rhs1 rhs2 op ope comment)
   8715   (dni name
   8716        (comment)
   8717        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8718 	(FR400-MAJOR M-2) (FR450-MAJOR M-4) PRESERVE-OVF)
   8719        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
   8720        (+ pack ACC40Sk op FRintieven ope FRintjeven)
   8721        (media-quad-multiply-semantics 1 mode conv rhs1 rhs2) 
   8722        ((fr400 (unit u-media-2-quad
   8723 		     (in  FRinti FRintieven)
   8724 		     (in  FRintj FRintjeven)))
   8725 	(fr450 (unit u-media-2-quad
   8726 		     (in  FRinti FRintieven)
   8727 		     (in  FRintj FRintjeven)))
   8728 	(fr500 (unit u-media-quad-mul
   8729 		     (in  FRinti FRintieven)
   8730 		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
   8731   )
   8732 )
   8733 
   8734 (media-quad-multiply mqmulhs  HI ext  argjhi argjlo OP_7B OPE1_1C "Media quad multiply signed")
   8735 (media-quad-multiply mqmulhu UHI zext argjhi argjlo OP_7B OPE1_1D "Media quad multiply unsigned")
   8736 
   8737 (media-quad-multiply mqmulxhs  HI ext  argjlo argjhi OP_7B OPE1_2A "Media quad cross multiply signed")
   8738 (media-quad-multiply mqmulxhu UHI zext argjlo argjhi OP_7B OPE1_2B "Media quad cross multiply unsigned")
   8739 
   8740 (define-pmacro (conditional-media-quad-multiply
   8741 		name mode conv rhs1 rhs2 op ope comment)
   8742   (dni name
   8743        (comment)
   8744        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8745 	(FR400-MAJOR M-2) (FR450-MAJOR M-4)
   8746 	PRESERVE-OVF CONDITIONAL)
   8747        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk,$CCi,$cond")
   8748        (+ pack ACC40Sk op FRintieven CCi cond ope FRintjeven)
   8749        (media-quad-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
   8750        ((fr400 (unit u-media-2-quad
   8751 		     (in  FRinti FRintieven)
   8752 		     (in  FRintj FRintjeven)))
   8753 	(fr450 (unit u-media-2-quad
   8754 		     (in  FRinti FRintieven)
   8755 		     (in  FRintj FRintjeven)))
   8756 	(fr500 (unit u-media-quad-mul
   8757 		     (in  FRinti FRintieven)
   8758 		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
   8759   )
   8760 )
   8761 
   8762 (conditional-media-quad-multiply cmqmulhs  HI ext  argjhi argjlo OP_74 OPE4_0 "Conditional Media quad multiply signed")
   8763 (conditional-media-quad-multiply cmqmulhu UHI zext argjhi argjlo OP_74 OPE4_1 "Conditional Media quad multiply unsigned")
   8764 
   8765 (define-pmacro (media-multiply-acc-semantics 
   8766 		conv arg1 addop arg2 res max min sie)
   8767   (sequence ((DI tmp))
   8768 	    (set tmp (addop res (mul DI (conv DI arg1) (conv DI arg2))))
   8769 	    (saturate-v tmp max min sie res))
   8770 )
   8771 
   8772 (define-pmacro (media-dual-multiply-acc-semantics
   8773 		cond mode conv addop rhw res max min)
   8774   (if (c-call SI "@cpu@_check_acc_range" (index-of res))
   8775       (if (register-unaligned res 2)
   8776 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   8777 	  (if cond
   8778 	      (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   8779 			(extract-hilo FRinti 0 FRintj 0
   8780 				      argihi argilo argjhi argjlo)
   8781 			(media-multiply-acc-semantics conv argihi addop argjhi
   8782 						      res
   8783 						      max min (msr-sie-acci))
   8784 			(media-multiply-acc-semantics conv argilo addop argjlo
   8785 						      (nextreg rhw res 1)
   8786 						      max min (msr-sie-acci-1))))))
   8787 )
   8788 
   8789 (define-pmacro (media-dual-multiply-acc
   8790 		name mode conv addop rhw res max min op ope comment)
   8791   (dni name
   8792        (comment)
   8793        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8794 	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
   8795        (.str name "$pack $FRinti,$FRintj,$" res)
   8796        (+ pack res op FRinti ope FRintj)
   8797        (media-dual-multiply-acc-semantics 1 mode conv addop rhw res max min)
   8798        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   8799 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   8800   )
   8801 )
   8802 
   8803 (media-dual-multiply-acc mmachs HI ext add h-acc40S ACC40Sk
   8804 			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
   8805 			 OP_7B OPE1_16
   8806 			 "Media dual multiply and accumulate signed")
   8807 
   8808 (media-dual-multiply-acc mmachu UHI zext add h-acc40U ACC40Uk
   8809 			 (const DI #xffffffffff) (const DI 0)
   8810 			 OP_7B OPE1_17
   8811 			 "Media dual multiply and accumulate unsigned")
   8812 
   8813 (media-dual-multiply-acc mmrdhs HI ext sub h-acc40S ACC40Sk
   8814 			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
   8815 			 OP_7B OPE1_30
   8816 			 "Media dual multiply and reduce signed")
   8817 
   8818 (media-dual-multiply-acc mmrdhu UHI zext sub h-acc40U ACC40Uk
   8819 			 (const DI #xffffffffff) (const DI 0)
   8820 			 OP_7B OPE1_31
   8821 			 "Media dual multiply and reduce unsigned")
   8822 
   8823 (define-pmacro (conditional-media-dual-multiply-acc
   8824 		name mode conv addop rhw res max min op ope comment)
   8825   (dni name
   8826        (comment)
   8827        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8828 	(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
   8829        (.str name "$pack $FRinti,$FRintj,$" res ",$CCi,$cond")
   8830        (+ pack res op FRinti CCi cond ope FRintj)
   8831        (media-dual-multiply-acc-semantics (eq CCi (or cond 2))
   8832 					  mode conv addop rhw res max min)
   8833        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   8834 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   8835   )
   8836 )
   8837 
   8838 (conditional-media-dual-multiply-acc cmmachs HI ext add h-acc40S ACC40Sk
   8839 			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
   8840 			 OP_72 OPE4_2
   8841 			 "Conditional Media dual multiply and accumulate signed")
   8842 
   8843 (conditional-media-dual-multiply-acc cmmachu UHI zext add  h-acc40U ACC40Uk
   8844 			 (const DI #xffffffffff) (const DI 0)
   8845 			 OP_72 OPE4_3
   8846 			 "Conditional Media dual multiply and accumulate unsigned")
   8847 
   8848 (define-pmacro (media-quad-multiply-acc-semantics
   8849 		cond mode conv addop rhw res max min)
   8850   (if (c-call SI "@cpu@_check_acc_range" (index-of res))
   8851       (if (register-unaligned res 4)
   8852 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   8853 	  (if (orif (register-unaligned FRintieven 2)
   8854 		    (register-unaligned FRintjeven 2))
   8855 	      (c-call VOID "@cpu@_media_register_not_aligned")
   8856 	      (if cond
   8857 		  (sequence ((mode argihi) (mode argilo)
   8858 			     (mode argjhi) (mode argjlo))
   8859 			    (extract-hilo FRintieven 0 FRintjeven 0
   8860 					  argihi argilo argjhi argjlo)
   8861 			    (media-multiply-acc-semantics conv argihi addop argjhi
   8862 							  res
   8863 							  max min (msr-sie-acci))
   8864 			    (media-multiply-acc-semantics conv argilo addop argjlo
   8865 							  (nextreg rhw res 1)
   8866 							  max min (msr-sie-acci-1))
   8867 			    (extract-hilo FRintieven 1 FRintjeven 1
   8868 					  argihi argilo argjhi argjlo)
   8869 			    (media-multiply-acc-semantics conv argihi addop argjhi
   8870 							  (nextreg rhw res 2)
   8871 							  max min (msr-sie-acci-2))
   8872 			    (media-multiply-acc-semantics conv argilo addop argjlo
   8873 							  (nextreg rhw res 3)
   8874 							  max min
   8875 							  (msr-sie-acci-3)))))))
   8876 )
   8877 
   8878 (define-pmacro (media-quad-multiply-acc
   8879 		name mode conv addop rhw res max min op ope comment)
   8880   (dni name
   8881        (comment)
   8882        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8883 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   8884        (.str name "$pack $FRintieven,$FRintjeven,$" res)
   8885        (+ pack res op FRintieven ope FRintjeven)
   8886        (media-quad-multiply-acc-semantics 1 mode conv addop rhw res max min)
   8887        ((fr400 (unit u-media-2-quad
   8888 		     (in  FRinti FRintieven)
   8889 		     (in  FRintj FRintjeven)))
   8890 	(fr450 (unit u-media-2-quad
   8891 		     (in  FRinti FRintieven)
   8892 		     (in  FRintj FRintjeven)))
   8893 	(fr500 (unit u-media-quad-mul
   8894 		     (in  FRinti FRintieven)
   8895 		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
   8896   )
   8897 )
   8898 
   8899 (media-quad-multiply-acc mqmachs HI ext add h-acc40S ACC40Sk
   8900 			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
   8901 			 OP_7B OPE1_1E
   8902 			 "Media quad multiply and accumulate signed")
   8903 
   8904 (media-quad-multiply-acc mqmachu UHI zext add h-acc40U ACC40Uk
   8905 			 (const DI #xffffffffff) (const DI 0)
   8906 			 OP_7B OPE1_1F
   8907 			 "Media quad multiply and accumulate unsigned")
   8908 
   8909 (define-pmacro (conditional-media-quad-multiply-acc
   8910 		name mode conv addop rhw res max min op ope comment)
   8911   (dni name
   8912        (comment)
   8913        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   8914 	(FR400-MAJOR M-2) (FR450-MAJOR M-4) CONDITIONAL)
   8915        (.str name "$pack $FRintieven,$FRintjeven,$" res ",$CCi,$cond")
   8916        (+ pack res op FRintieven CCi cond ope FRintjeven)
   8917        (media-quad-multiply-acc-semantics (eq CCi (or cond 2))
   8918 					  mode conv addop rhw res max min)
   8919        ((fr400 (unit u-media-2-quad
   8920 		     (in  FRinti FRintieven)
   8921 		     (in  FRintj FRintjeven)))
   8922 	(fr450 (unit u-media-2-quad
   8923 		     (in  FRinti FRintieven)
   8924 		     (in  FRintj FRintjeven)))
   8925 	(fr500 (unit u-media-quad-mul
   8926 		     (in  FRinti FRintieven)
   8927 		     (in  FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
   8928   )
   8929 )
   8930 
   8931 (conditional-media-quad-multiply-acc cmqmachs HI ext add h-acc40S ACC40Sk
   8932 			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
   8933 			 OP_74 OPE4_2
   8934 			 "Conditional Media quad multiply and accumulate signed")
   8935 
   8936 (conditional-media-quad-multiply-acc cmqmachu UHI zext add h-acc40U ACC40Uk
   8937 			 (const DI #xffffffffff) (const DI 0)
   8938 			 OP_74 OPE4_3
   8939 			 "Conditional media quad multiply and accumulate unsigned")
   8940 
   8941 (define-pmacro (media-quad-multiply-cross-acc-semantics
   8942 		cond mode conv addop rhw res max min)
   8943   (if (c-call SI "@cpu@_check_acc_range" (index-of res))
   8944       (if (register-unaligned res 4)
   8945 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   8946 	  (if (orif (register-unaligned FRintieven 2)
   8947 		    (register-unaligned FRintjeven 2))
   8948 	      (c-call VOID "@cpu@_media_register_not_aligned")
   8949 	      (if cond
   8950 		  (sequence ((mode argihi) (mode argilo)
   8951 			     (mode argjhi) (mode argjlo))
   8952 			    (extract-hilo FRintieven 0 FRintjeven 0
   8953 					  argihi argilo argjhi argjlo)
   8954 			    (media-multiply-acc-semantics conv argihi addop argjhi
   8955 							  (nextreg rhw res 2)
   8956 							  max min (msr-sie-acci-2))
   8957 			    (media-multiply-acc-semantics conv argilo addop argjlo
   8958 							  (nextreg rhw res 3)
   8959 							  max min (msr-sie-acci-3))
   8960 			    (extract-hilo FRintieven 1 FRintjeven 1
   8961 					  argihi argilo argjhi argjlo)
   8962 			    (media-multiply-acc-semantics conv argihi addop argjhi
   8963 							  res
   8964 							  max min (msr-sie-acci))
   8965 			    (media-multiply-acc-semantics conv argilo addop argjlo
   8966 							  (nextreg rhw res 1)
   8967 							  max min
   8968 							  (msr-sie-acci-1)))))))
   8969 )
   8970 
   8971 (define-pmacro (media-quad-multiply-cross-acc
   8972 		name mode conv addop rhw res max min op ope comment)
   8973   (dni name
   8974        (comment)
   8975        ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   8976 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   8977        (.str name "$pack $FRintieven,$FRintjeven,$" res)
   8978        (+ pack res op FRintieven ope FRintjeven)
   8979        (media-quad-multiply-cross-acc-semantics 1 mode conv addop rhw res
   8980 						max min)
   8981        ((fr400 (unit u-media-2-quad
   8982 		     (in  FRinti FRintieven)
   8983 		     (in  FRintj FRintjeven)))
   8984 	(fr450 (unit u-media-2-quad
   8985 		     (in  FRinti FRintieven)
   8986 		     (in  FRintj FRintjeven)))
   8987 	(fr550 (unit u-media-4-quad)))
   8988   )
   8989 )
   8990 
   8991 (media-quad-multiply-cross-acc mqxmachs HI ext add h-acc40S ACC40Sk
   8992 			 (const DI #x7fffffffff) (const DI #xffffff8000000000)
   8993 			 OP_78 OPE1_00
   8994 			 "Media quad multiply and cross accumulate signed")
   8995 
   8996 (define-pmacro (media-quad-cross-multiply-cross-acc-semantics
   8997 		cond mode conv addop rhw res max min)
   8998   (if (c-call SI "@cpu@_check_acc_range" (index-of res))
   8999       (if (register-unaligned res 4)
   9000 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   9001 	  (if (orif (register-unaligned FRintieven 2)
   9002 		    (register-unaligned FRintjeven 2))
   9003 	      (c-call VOID "@cpu@_media_register_not_aligned")
   9004 	      (if cond
   9005 		  (sequence ((mode argihi) (mode argilo)
   9006 			     (mode argjhi) (mode argjlo))
   9007 			    (extract-hilo FRintieven 0 FRintjeven 0
   9008 					  argihi argilo argjhi argjlo)
   9009 			    (media-multiply-acc-semantics conv argihi addop argjlo
   9010 							  (nextreg rhw res 2)
   9011 							  max min (msr-sie-acci-2))
   9012 			    (media-multiply-acc-semantics conv argilo addop argjhi
   9013 							  (nextreg rhw res 3)
   9014 							  max min (msr-sie-acci-3))
   9015 			    (extract-hilo FRintieven 1 FRintjeven 1
   9016 					  argihi argilo argjhi argjlo)
   9017 			    (media-multiply-acc-semantics conv argihi addop argjlo
   9018 							  res
   9019 							  max min (msr-sie-acci))
   9020 			    (media-multiply-acc-semantics conv argilo addop argjhi
   9021 							  (nextreg rhw res 1)
   9022 							  max min
   9023 							  (msr-sie-acci-1)))))))
   9024 )
   9025 
   9026 (define-pmacro (media-quad-cross-multiply-cross-acc
   9027 		name mode conv addop rhw res max min op ope comment)
   9028   (dni name
   9029        (comment)
   9030        ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   9031 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   9032        (.str name "$pack $FRintieven,$FRintjeven,$" res)
   9033        (+ pack res op FRintieven ope FRintjeven)
   9034        (media-quad-cross-multiply-cross-acc-semantics 1 mode conv addop rhw res
   9035 						      max min)
   9036        ((fr400 (unit u-media-2-quad
   9037 		     (in  FRinti FRintieven)
   9038 		     (in  FRintj FRintjeven)))
   9039 	(fr450 (unit u-media-2-quad
   9040 		     (in  FRinti FRintieven)
   9041 		     (in  FRintj FRintjeven)))
   9042 	(fr550 (unit u-media-4-quad)))
   9043   )
   9044 )
   9045 
   9046 (media-quad-cross-multiply-cross-acc mqxmacxhs HI ext add h-acc40S ACC40Sk
   9047 			(const DI #x7fffffffff) (const DI #xffffff8000000000)
   9048 			OP_78 OPE1_01
   9049 			"Media quad cross multiply and cross accumulate signed")
   9050 
   9051 (define-pmacro (media-quad-cross-multiply-acc-semantics
   9052 		cond mode conv addop rhw res max min)
   9053   (if (c-call SI "@cpu@_check_acc_range" (index-of res))
   9054       (if (register-unaligned res 4)
   9055 	  (c-call VOID "@cpu@_media_acc_not_aligned")
   9056 	  (if (orif (register-unaligned FRintieven 2)
   9057 		    (register-unaligned FRintjeven 2))
   9058 	      (c-call VOID "@cpu@_media_register_not_aligned")
   9059 	      (if cond
   9060 		  (sequence ((mode argihi) (mode argilo)
   9061 			     (mode argjhi) (mode argjlo))
   9062 			    (extract-hilo FRintieven 0 FRintjeven 0
   9063 					  argihi argilo argjhi argjlo)
   9064 			    (media-multiply-acc-semantics conv argihi addop argjlo
   9065 							  res
   9066 							  max min (msr-sie-acci))
   9067 			    (media-multiply-acc-semantics conv argilo addop argjhi
   9068 							  (nextreg rhw res 1)
   9069 							  max min (msr-sie-acci-1))
   9070 			    (extract-hilo FRintieven 1 FRintjeven 1
   9071 					  argihi argilo argjhi argjlo)
   9072 			    (media-multiply-acc-semantics conv argihi addop argjlo
   9073 							  (nextreg rhw res 2)
   9074 							  max min (msr-sie-acci-2))
   9075 			    (media-multiply-acc-semantics conv argilo addop argjhi
   9076 							  (nextreg rhw res 3)
   9077 							  max min
   9078 							  (msr-sie-acci-3)))))))
   9079 )
   9080 
   9081 (define-pmacro (media-quad-cross-multiply-acc
   9082 		name mode conv addop rhw res max min op ope comment)
   9083   (dni name
   9084        (comment)
   9085        ((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
   9086 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   9087        (.str name "$pack $FRintieven,$FRintjeven,$" res)
   9088        (+ pack res op FRintieven ope FRintjeven)
   9089        (media-quad-cross-multiply-acc-semantics 1 mode conv addop rhw res
   9090 						max min)
   9091        ((fr400 (unit u-media-2-quad
   9092 		     (in FRinti FRintieven)
   9093 		     (in FRintj FRintjeven)))
   9094 	(fr450 (unit u-media-2-quad
   9095 		     (in FRinti FRintieven)
   9096 		     (in FRintj FRintjeven)))
   9097 	(fr550 (unit u-media-4-quad)))
   9098   )
   9099 )
   9100 
   9101 (media-quad-cross-multiply-acc mqmacxhs HI ext add h-acc40S ACC40Sk
   9102 			(const DI #x7fffffffff) (const DI #xffffff8000000000)
   9103 			OP_78 OPE1_02
   9104 			"Media quad cross multiply and accumulate signed")
   9105 
   9106 (define-pmacro (media-complex-semantics
   9107 		conv lhs1 rhs1 lhs2 rhs2 res max min sie)
   9108   (sequence ((DI tmp1) (DI tmp2))
   9109 	    (media-multiply-semantics conv lhs1 rhs1 tmp1)
   9110 	    (media-multiply-semantics conv lhs2 rhs2 tmp2)
   9111 	    (set tmp1 (sub tmp1 tmp2))
   9112 	    (saturate-v tmp1 max min sie res))
   9113 )
   9114 
   9115 (define-pmacro (media-complex-semantics-i
   9116 		conv lhs1 rhs1 lhs2 rhs2 res max min sie)
   9117   (sequence ((DI tmp1) (DI tmp2))
   9118 	    (media-multiply-semantics conv lhs1 rhs1 tmp1)
   9119 	    (media-multiply-semantics conv lhs2 rhs2 tmp2)
   9120 	    (set tmp1 (add tmp1 tmp2))
   9121 	    (saturate-v tmp1 max min sie res))
   9122 )
   9123 
   9124 (define-pmacro (media-dual-complex-semantics mode conv rhs1 rhs2 max min)
   9125   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   9126       (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   9127 		(extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
   9128 		(media-complex-semantics conv argihi rhs1 argilo rhs2 ACC40Sk
   9129 					 max min (msr-sie-acci))))
   9130 )
   9131 
   9132 (define-pmacro (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
   9133   (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   9134       (sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
   9135 		(extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
   9136 		(media-complex-semantics-i conv argihi rhs1 argilo rhs2 ACC40Sk
   9137 					   max min (msr-sie-acci))))
   9138 )
   9139 
   9140 (define-pmacro (media-dual-complex
   9141 		name mode conv rhs1 rhs2 max min op ope comment)
   9142   (dni name
   9143        (comment)
   9144        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   9145 	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
   9146        (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
   9147        (+ pack ACC40Sk op FRinti ope FRintj)
   9148        (media-dual-complex-semantics mode conv rhs1 rhs2 max min)
   9149        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   9150 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   9151   )
   9152 )
   9153 
   9154 (define-pmacro (media-dual-complex-i
   9155 		name mode conv rhs1 rhs2 max min op ope comment)
   9156   (dni name
   9157        (comment)
   9158        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   9159 	(FR400-MAJOR M-1) (FR450-MAJOR M-3))
   9160        (.str name "$pack $FRinti,$FRintj,$ACC40Sk")
   9161        (+ pack ACC40Sk op FRinti ope FRintj)
   9162        (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
   9163        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   9164 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   9165   )
   9166 )
   9167 
   9168 (media-dual-complex mcpxrs HI ext argjhi argjlo
   9169 		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
   9170 		    OP_7B OPE1_20
   9171 		    "Media dual complex real signed with saturation")
   9172 
   9173 (media-dual-complex mcpxru UHI zext argjhi argjlo
   9174 		    (const DI #xffffffffff) (const DI 0)
   9175 		    OP_7B OPE1_21
   9176 		    "Media dual complex real unsigned with saturation")
   9177 
   9178 (media-dual-complex-i mcpxis HI ext argjlo argjhi
   9179 		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
   9180 		    OP_7B OPE1_22
   9181 		    "Media dual complex imaginary signed with saturation")
   9182 
   9183 (media-dual-complex-i mcpxiu UHI zext argjlo argjhi
   9184 		    (const DI #xffffffffff) (const DI 0)
   9185 		    OP_7B OPE1_23
   9186 		    "Media dual complex imaginary unsigned with saturation")
   9187 
   9188 (define-pmacro (conditional-media-dual-complex
   9189 		name mode conv rhs1 rhs2 max min op ope comment)
   9190   (dni name
   9191        (comment)
   9192        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   9193 	(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
   9194        (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
   9195        (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
   9196        (if (eq CCi (or cond 2))
   9197 	   (media-dual-complex-semantics mode conv rhs1 rhs2 max min))
   9198        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   9199 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   9200   )
   9201 )
   9202 
   9203 (define-pmacro (conditional-media-dual-complex-i
   9204 		name mode conv rhs1 rhs2 max min op ope comment)
   9205   (dni name
   9206        (comment)
   9207        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   9208 	(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
   9209        (.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
   9210        (+ pack ACC40Sk op FRinti CCi cond ope FRintj)
   9211        (if (eq CCi (or cond 2))
   9212 	   (media-dual-complex-semantics-i mode conv rhs1 rhs2 max min))
   9213        ((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
   9214 	(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
   9215   )
   9216 )
   9217 
   9218 (conditional-media-dual-complex cmcpxrs HI ext argjhi argjlo
   9219 		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
   9220 		    OP_75 OPE4_0
   9221 		    "Conditional Media dual complex real signed with saturation")
   9222 
   9223 (conditional-media-dual-complex cmcpxru UHI zext argjhi argjlo
   9224 		    (const DI #xffffffffff) (const DI 0)
   9225 		    OP_75 OPE4_1
   9226 		    "Conditional Media dual complex real unsigned with saturation")
   9227 
   9228 (conditional-media-dual-complex-i cmcpxis HI ext argjlo argjhi
   9229 		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
   9230 		    OP_75 OPE4_2
   9231 		    "Conditional Media dual complex imaginary signed with saturation")
   9232 
   9233 (conditional-media-dual-complex-i cmcpxiu UHI zext argjlo argjhi
   9234 		    (const DI #xffffffffff) (const DI 0)
   9235 		    OP_75 OPE4_3
   9236 		    "Conditional Media dual complex imaginary unsigned with saturation")
   9237 
   9238 (define-pmacro (media-quad-complex
   9239 		name mode conv rhs1 rhs2 max min op ope comment)
   9240   (dni name
   9241        (comment)
   9242        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   9243 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   9244        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
   9245        (+ pack ACC40Sk op FRintieven ope FRintjeven)
   9246        (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   9247 	   (if (register-unaligned ACC40Sk 2)
   9248 	       (c-call VOID "@cpu@_media_acc_not_aligned")
   9249 	       (if (orif (register-unaligned FRintieven 2)
   9250 			 (register-unaligned FRintjeven 2))
   9251 		   (c-call VOID "@cpu@_media_register_not_aligned")
   9252 		   (sequence ((mode argihi) (mode argilo)
   9253 			      (mode argjhi) (mode argjlo))
   9254 			     (extract-hilo FRintieven 0 FRintjeven 0
   9255 					   argihi argilo argjhi argjlo)
   9256 			     (media-complex-semantics conv argihi rhs1 argilo rhs2
   9257 						      ACC40Sk
   9258 						      max min (msr-sie-acci))
   9259 			     (extract-hilo FRintieven 1 FRintjeven 1
   9260 					   argihi argilo argjhi argjlo)
   9261 			     (media-complex-semantics conv argihi rhs1 argilo rhs2
   9262 						      (nextreg h-acc40S ACC40Sk 1)
   9263 						      max min (msr-sie-acci-1))))))
   9264        ((fr400 (unit u-media-2-quad
   9265 		     (in FRinti FRintieven)
   9266 		     (in FRintj FRintjeven)))
   9267 	(fr450 (unit u-media-2-quad
   9268 		     (in FRinti FRintieven)
   9269 		     (in FRintj FRintjeven)))
   9270 	(fr500 (unit u-media-quad-complex
   9271 		     (in FRinti FRintieven)
   9272 		     (in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
   9273   )
   9274 )
   9275 
   9276 (define-pmacro (media-quad-complex-i
   9277 		name mode conv rhs1 rhs2 max min op ope comment)
   9278   (dni name
   9279        (comment)
   9280        ((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
   9281 	(FR400-MAJOR M-2) (FR450-MAJOR M-4))
   9282        (.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
   9283        (+ pack ACC40Sk op FRintieven ope FRintjeven)
   9284        (if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
   9285 	   (if (register-unaligned ACC40Sk 2)
   9286 	       (c-call VOID "@cpu@_media_acc_not_aligned")
   9287 	       (if (orif (register-unaligned FRintieven 2)
   9288 			 (register-unaligned FRintjeven 2))
   9289 		   (c-call VOID "@cpu@_media_register_not_aligned")
   9290 		   (sequence ((mode argihi) (mode argilo)
   9291 			      (mode argjhi) (mode argjlo))
   9292 			     (extract-hilo FRintieven 0 FRintjeven 0
   9293 					   argihi argilo argjhi argjlo)
   9294 			     (media-complex-semantics-i conv argihi rhs1 argilo rhs2
   9295 							ACC40Sk
   9296 							max min (msr-sie-acci))
   9297 			     (extract-hilo FRintieven 1 FRintjeven 1
   9298 					   argihi argilo argjhi argjlo)
   9299 			     (media-complex-semantics-i conv argihi rhs1 argilo rhs2
   9300 							(nextreg h-acc40S ACC40Sk 1)
   9301 							max min (msr-sie-acci-1))))))
   9302        ((fr400 (unit u-media-2-quad
   9303 		     (in FRinti FRintieven)
   9304 		     (in FRintj FRintjeven)))
   9305 	(fr450 (unit u-media-2-quad
   9306 		     (in FRinti FRintieven)
   9307 		     (in FRintj FRintjeven)))
   9308 	(fr500 (unit u-media-quad-complex
   9309 		     (in FRinti FRintieven)
   9310 		     (in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
   9311   )
   9312 )
   9313 
   9314 (media-quad-complex mqcpxrs HI ext argjhi argjlo
   9315 		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
   9316 		    OP_7B OPE1_24
   9317 		    "Media quad complex real signed with saturation")
   9318 
   9319 (media-quad-complex mqcpxru UHI zext argjhi argjlo
   9320 		    (const DI #xffffffffff) (const DI 0)
   9321 		    OP_7B OPE1_25
   9322 		    "Media quad complex real unsigned with saturation")
   9323 
   9324 (media-quad-complex-i mqcpxis HI ext argjlo argjhi
   9325 		    (const DI #x7fffffffff) (const DI #xffffff8000000000)
   9326 		    OP_7B OPE1_26
   9327 		    "Media quad complex imaginary signed with saturation")
   9328 
   9329 (media-quad-complex-i mqcpxiu UHI zext argjlo argjhi
   9330 		    (const DI #xffffffffff) (const DI 0)
   9331 		    OP_7B OPE1_27
   9332 		    "Media quad complex imaginary unsigned with saturation")
   9333 
   9334 (define-pmacro (media-pack src1 src2 targ offset)
   9335   (sequence ()
   9336 	    (set (halfword hi targ offset) (halfword lo src1 offset))
   9337 	    (set (halfword lo targ offset) (halfword lo src2 offset)))
   9338 )
   9339 
   9340 (define-pmacro (media-expand-halfword-to-word-semantics cond)
   9341   (if cond
   9342       (sequence ((UHI tmp))
   9343 		(if (and u6 1)
   9344 		    (set tmp (halfword lo FRinti 0))
   9345 		    (set tmp (halfword hi FRinti 0)))
   9346 		(set (halfword hi FRintk 0) tmp)
   9347 		(set (halfword lo FRintk 0) tmp)))
   9348 )
   9349 
   9350 (dni mexpdhw
   9351      "Media expand halfword to word"
   9352      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9353       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   9354      "mexpdhw$pack $FRinti,$u6,$FRintk"
   9355      (+ pack FRintk OP_7B FRinti OPE1_32 u6)
   9356      (media-expand-halfword-to-word-semantics 1)
   9357      ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   9358       (fr500 (unit u-media)) (fr550 (unit u-media)))
   9359 )
   9360 
   9361 (dni cmexpdhw
   9362      "Conditional media expand halfword to word"
   9363      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9364       (FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
   9365      "cmexpdhw$pack $FRinti,$u6,$FRintk,$CCi,$cond"
   9366      (+ pack FRintk OP_76 FRinti CCi cond OPE4_2 u6)
   9367      (media-expand-halfword-to-word-semantics (eq CCi (or cond 2)))
   9368      ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   9369       (fr500 (unit u-media)) (fr550 (unit u-media)))
   9370 )
   9371 
   9372 (define-pmacro (media-expand-halfword-to-double-semantics cond)
   9373   (if (register-unaligned FRintkeven 2)
   9374       (c-call VOID "@cpu@_media_register_not_aligned")
   9375       (if cond
   9376 	  (sequence ((UHI tmp))
   9377 		    ; a hack to get FRintkeven referenced for profiling
   9378 		    (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   9379 		    (if (and u6 1)
   9380 			(set tmp (halfword lo FRinti 0))
   9381 			(set tmp (halfword hi FRinti 0)))
   9382 		    (set (halfword hi FRintkeven 0) tmp)
   9383 		    (set (halfword lo FRintkeven 0) tmp)
   9384 		    (set (halfword hi FRintkeven 1) tmp)
   9385 		    (set (halfword lo FRintkeven 1) tmp))))
   9386 )
   9387 
   9388 (dni mexpdhd
   9389      "Media expand halfword to double"
   9390      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9391       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   9392      "mexpdhd$pack $FRinti,$u6,$FRintkeven"
   9393      (+ pack FRintkeven OP_7B FRinti OPE1_33 u6)
   9394      (media-expand-halfword-to-double-semantics 1)
   9395      ((fr400 (unit u-media-dual-expand
   9396 		   (out FRintk FRintkeven)))
   9397       (fr450 (unit u-media-dual-expand
   9398 		   (out FRintk FRintkeven)))
   9399       (fr500 (unit u-media-dual-expand
   9400 		   (out FRintk FRintkeven)))
   9401       (fr550 (unit u-media-dual-expand)))
   9402 )
   9403 
   9404 (dni cmexpdhd
   9405      "Conditional media expand halfword to double"
   9406      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9407       (FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
   9408      "cmexpdhd$pack $FRinti,$u6,$FRintkeven,$CCi,$cond"
   9409      (+ pack FRintkeven OP_76 FRinti CCi cond OPE4_3 u6)
   9410      (media-expand-halfword-to-double-semantics (eq CCi (or cond 2)))
   9411      ((fr400 (unit u-media-dual-expand
   9412 		   (out FRintk FRintkeven)))
   9413       (fr450 (unit u-media-dual-expand
   9414 		   (out FRintk FRintkeven)))
   9415       (fr500 (unit u-media-dual-expand
   9416 		   (out FRintk FRintkeven)))
   9417       (fr550 (unit u-media-dual-expand)))
   9418 )
   9419 
   9420 (dni mpackh
   9421      "Media halfword pack"
   9422      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9423       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   9424      "mpackh$pack $FRinti,$FRintj,$FRintk"
   9425      (+ pack FRintk OP_7B FRinti OPE1_34 FRintj)
   9426      (media-pack FRinti FRintj FRintk 0)
   9427      ((fr400 (unit u-media-3)) (fr450 (unit u-media-3))
   9428       (fr500 (unit u-media)) (fr550 (unit u-media)))
   9429 )
   9430 
   9431 (dni mdpackh
   9432      "Media dual pack"
   9433      ((UNIT FM01) (FR500-MAJOR M-5) (FR550-MAJOR M-3)
   9434       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   9435      "mdpackh$pack $FRintieven,$FRintjeven,$FRintkeven"
   9436      (+ pack FRintkeven OP_7B FRintieven OPE1_36 FRintjeven)
   9437      (if (orif (register-unaligned FRintieven 2)
   9438 	       (orif (register-unaligned FRintjeven 2)
   9439 		     (register-unaligned FRintkeven 2)))
   9440 	 (c-call VOID "@cpu@_media_register_not_aligned")
   9441 	 (sequence ()
   9442 		   ; hack to get these referenced for profiling
   9443 		   (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
   9444 		   (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
   9445 		   (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   9446 		   (media-pack FRintieven FRintjeven FRintkeven 0)
   9447 		   (media-pack FRintieven FRintjeven FRintkeven 1)))
   9448      ((fr400 (unit u-media-3-quad
   9449 		   (in  FRinti FRintieven)
   9450 		   (in  FRintj FRintjeven)
   9451 		   (out FRintk FRintkeven)))
   9452       (fr450 (unit u-media-3-quad
   9453 		   (in  FRinti FRintieven)
   9454 		   (in  FRintj FRintjeven)
   9455 		   (out FRintk FRintkeven)))
   9456       (fr500 (unit u-media-quad-arith
   9457 		   (in  FRinti FRintieven)
   9458 		   (in  FRintj FRintjeven)
   9459 		   (out FRintk FRintkeven)))
   9460       (fr550 (unit u-media-quad)))
   9461 )
   9462 
   9463 (define-pmacro (media-unpack src soff targ toff)
   9464   (sequence ()
   9465 	    (set (halfword hi targ toff) (halfword hi src soff))
   9466 	    (set (halfword lo targ toff) (halfword hi src soff))
   9467 	    (set (halfword hi targ (add toff 1)) (halfword lo src soff))
   9468 	    (set (halfword lo targ (add toff 1)) (halfword lo src soff)))
   9469 )
   9470 
   9471 (dni munpackh
   9472      "Media halfword unpack"
   9473      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9474       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   9475      "munpackh$pack $FRinti,$FRintkeven"
   9476      (+ pack FRintkeven OP_7B FRinti OPE1_35 (FRj-null))
   9477      (if (register-unaligned FRintkeven 2)
   9478 	 (c-call VOID "@cpu@_media_register_not_aligned")
   9479 	 (sequence ()
   9480 		   ; hack to get these referenced for profiling
   9481 		   (set FRinti (c-raw-call SI "frv_ref_SI" FRinti))
   9482 		   (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   9483 		   (media-unpack FRinti 0 FRintkeven 0)))
   9484      ((fr400 (unit u-media-dual-expand
   9485 		   (out FRintk FRintkeven)))
   9486       (fr450 (unit u-media-dual-expand
   9487 		   (out FRintk FRintkeven)))
   9488       (fr500 (unit u-media-dual-expand
   9489 		   (out FRintk FRintkeven)))
   9490       (fr550 (unit u-media-dual-expand)))
   9491 )
   9492 
   9493 (dni mdunpackh
   9494      "Media dual unpack"
   9495      ((UNIT FM01) (FR500-MAJOR M-7) (MACH simple,tomcat,frv))
   9496      "mdunpackh$pack $FRintieven,$FRintk"
   9497      (+ pack FRintk OP_7B FRintieven OPE1_37 (FRj-null))
   9498      (if (orif (register-unaligned FRintieven 2) (register-unaligned FRintk 4))
   9499 	 (c-call VOID "@cpu@_media_register_not_aligned")
   9500 	 (sequence ()
   9501 		   ; hack to get these referenced for profiling
   9502 		   (set FRintieven (c-raw-call SI "frv_ref_SI" FRintieven))
   9503 		   (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   9504 		   (media-unpack FRintieven 0 FRintk 0)
   9505 		   (media-unpack FRintieven 1 FRintk 2)))
   9506      ((fr500 (unit u-media-dual-unpack
   9507 		   (in FRinti FRintieven))))
   9508 )
   9509 
   9510 (define-pmacro (ubyte num arg offset)
   9511   (reg (.sym h-fr_ num) (add (index-of arg) offset)))
   9512 
   9513 (define-pmacro (mbtoh-semantics cond)
   9514   (if (register-unaligned FRintkeven 2)
   9515       (c-call VOID "@cpu@_media_register_not_aligned")
   9516       (if cond
   9517 	  (sequence ()
   9518 		    (set (halfword hi FRintkeven 0) (ubyte 3 FRintj 0))
   9519 		    (set (halfword lo FRintkeven 0) (ubyte 2 FRintj 0))
   9520 		    (set (halfword hi FRintkeven 1) (ubyte 1 FRintj 0))
   9521 		    (set (halfword lo FRintkeven 1) (ubyte 0 FRintj 0)))))
   9522 )
   9523 
   9524 (dni mbtoh
   9525      "Media convert byte to halfword"
   9526      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9527       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   9528      "mbtoh$pack $FRintj,$FRintkeven"
   9529      (+ pack FRintkeven OP_7B (FRi-null) OPE1_38 FRintj)
   9530      (sequence ()
   9531 	       ; hack to get these referenced for profiling
   9532 	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
   9533 	       (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   9534 	       (mbtoh-semantics 1))
   9535      ((fr400 (unit u-media-dual-expand
   9536 		   (out FRintk FRintkeven)))
   9537       (fr450 (unit u-media-dual-expand
   9538 		   (out FRintk FRintkeven)))
   9539       (fr500 (unit u-media-dual-btoh
   9540 		   (out FRintk FRintkeven)))
   9541       (fr550 (unit u-media-dual-expand)))
   9542 )
   9543 
   9544 (dni cmbtoh
   9545      "Conditional media convert byte to halfword"
   9546      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9547       (FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
   9548      "cmbtoh$pack $FRintj,$FRintkeven,$CCi,$cond"
   9549      (+ pack FRintkeven OP_77 (FRi-null) CCi cond OPE4_0 FRintj)
   9550      (sequence ()
   9551 	       ; hack to get these referenced for profiling
   9552 	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
   9553 	       (set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
   9554 	       (mbtoh-semantics (eq CCi (or cond 2))))
   9555      ((fr400 (unit u-media-dual-expand
   9556 		   (out FRintk FRintkeven)))
   9557       (fr450 (unit u-media-dual-expand
   9558 		   (out FRintk FRintkeven)))
   9559       (fr500 (unit u-media-dual-btoh
   9560 		   (out FRintk FRintkeven)))
   9561       (fr550 (unit u-media-dual-expand
   9562 		   (in FRinti FRintj))))
   9563 )
   9564 
   9565 (define-pmacro (mhtob-semantics cond)
   9566   (if (register-unaligned FRintjeven 2)
   9567       (c-call VOID "@cpu@_media_register_not_aligned")
   9568       (if cond
   9569 	  (sequence ()
   9570 		    (set (ubyte 3 FRintk 0) (halfword hi FRintjeven 0))
   9571 		    (set (ubyte 2 FRintk 0) (halfword lo FRintjeven 0))
   9572 		    (set (ubyte 1 FRintk 0) (halfword hi FRintjeven 1))
   9573 		    (set (ubyte 0 FRintk 0) (halfword lo FRintjeven 1)))))
   9574 )
   9575 
   9576 (dni mhtob
   9577      "Media convert halfword to byte"
   9578      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9579       (FR400-MAJOR M-2) (FR450-MAJOR M-2))
   9580      "mhtob$pack $FRintjeven,$FRintk"
   9581      (+ pack FRintk OP_7B (FRi-null) OPE1_39 FRintjeven)
   9582      (sequence ()
   9583 	       ; hack to get these referenced for profiling
   9584 	       (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
   9585 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   9586 	       (mhtob-semantics 1))
   9587      ((fr400 (unit u-media-dual-htob
   9588 		   (in FRintj FRintjeven)))
   9589       (fr450 (unit u-media-dual-htob
   9590 		   (in FRintj FRintjeven)))
   9591       (fr500 (unit u-media-dual-htob
   9592 		   (in FRintj FRintjeven)))
   9593       (fr550 (unit u-media-3-dual
   9594 		   (in FRinti FRintjeven))))
   9595 )
   9596 
   9597 (dni cmhtob
   9598      "Conditional media convert halfword to byte"
   9599      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9600       (FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
   9601      "cmhtob$pack $FRintjeven,$FRintk,$CCi,$cond"
   9602      (+ pack FRintk OP_77 (FRi-null) CCi cond OPE4_1 FRintjeven)
   9603      (sequence ()
   9604 	       ; hack to get these referenced for profiling
   9605 	       (set FRintjeven (c-raw-call SI "frv_ref_SI" FRintjeven))
   9606 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   9607 	       (mhtob-semantics (eq CCi (or cond 2))))
   9608      ((fr400 (unit u-media-dual-htob
   9609 		   (in FRintj FRintjeven)))
   9610       (fr450 (unit u-media-dual-htob
   9611 		   (in FRintj FRintjeven)))
   9612       (fr500 (unit u-media-dual-htob
   9613 		   (in FRintj FRintjeven)))
   9614       (fr550 (unit u-media-3-dual
   9615 		   (in FRinti FRintjeven))))
   9616 )
   9617 
   9618 (define-pmacro (mbtohe-semantics cond)
   9619   (if (register-unaligned FRintk 4)
   9620       (c-call VOID "@cpu@_media_register_not_aligned")
   9621       (if cond
   9622 	  (sequence ()
   9623 		    (set (halfword hi FRintk 0) (ubyte 3 FRintj 0))
   9624 		    (set (halfword lo FRintk 0) (ubyte 3 FRintj 0))
   9625 		    (set (halfword hi FRintk 1) (ubyte 2 FRintj 0))
   9626 		    (set (halfword lo FRintk 1) (ubyte 2 FRintj 0))
   9627 		    (set (halfword hi FRintk 2) (ubyte 1 FRintj 0))
   9628 		    (set (halfword lo FRintk 2) (ubyte 1 FRintj 0))
   9629 		    (set (halfword hi FRintk 3) (ubyte 0 FRintj 0))
   9630 		    (set (halfword lo FRintk 3) (ubyte 0 FRintj 0)))))
   9631 )
   9632 
   9633 (dni mbtohe
   9634      "Media convert byte to halfword extended"
   9635      ((UNIT FM01) (FR500-MAJOR M-7) (MACH simple,tomcat,frv))
   9636      "mbtohe$pack $FRintj,$FRintk"
   9637      (+ pack FRintk OP_7B (FRi-null) OPE1_3A FRintj)
   9638      (sequence ()
   9639 	       ; hack to get these referenced for profiling
   9640 	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
   9641 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   9642 	       (mbtohe-semantics 1))
   9643      ((fr500 (unit u-media-dual-btohe)))
   9644 )
   9645 
   9646 (dni cmbtohe
   9647      "Conditional media convert byte to halfword extended"
   9648      ((UNIT FM01) (FR500-MAJOR M-7) CONDITIONAL (MACH simple,tomcat,frv))
   9649      "cmbtohe$pack $FRintj,$FRintk,$CCi,$cond"
   9650      (+ pack FRintk OP_77 (FRi-null) CCi cond OPE4_2 FRintj)
   9651      (sequence ()
   9652 	       ; hack to get these referenced for profiling
   9653 	       (set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
   9654 	       (set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
   9655 	       (mbtohe-semantics (eq CCi (or cond 2))))
   9656      ((fr500 (unit u-media-dual-btohe)))
   9657 )
   9658 
   9659 ; Media NOP
   9660 ; A special case of mclracc
   9661 (dni mnop "Media nop"
   9662      ((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-1)
   9663       (FR400-MAJOR M-1) (FR450-MAJOR M-1))
   9664      "mnop$pack"
   9665      (+ pack (f-ACC40Sk 63) OP_7B (f-A 1) (misc-null-10) OPE1_3B (FRj-null))
   9666      (nop)
   9667      ()
   9668 )
   9669 
   9670 ; mclracc with #A==0
   9671 (dni mclracc-0
   9672      "Media clear accumulator(s)"
   9673      ((UNIT FM01) (FR500-MAJOR M-3) (FR550-MAJOR M-3)
   9674       (FR400-MAJOR M-1) (FR450-MAJOR M-3))
   9675      "mclracc$pack $ACC40Sk,$A0"
   9676      (+ pack ACC40Sk OP_7B (f-A 0) (misc-null-10) OPE1_3B (FRj-null))
   9677      (c-call VOID "@cpu@_clear_accumulators" (index-of ACC40Sk) 0)
   9678      ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
   9679       (fr500 (unit u-media)) (fr550 (unit u-media-3-mclracc)))
   9680 )
   9681 
   9682 ; mclracc with #A==1
   9683 (dni mclracc-1
   9684      "Media clear accumulator(s)"
   9685      ((UNIT MCLRACC-1) (FR500-MAJOR M-6) (FR550-MAJOR M-3)
   9686       (FR400-MAJOR M-2) (FR450-MAJOR M-4))
   9687      "mclracc$pack $ACC40Sk,$A1"
   9688      (+ pack ACC40Sk OP_7B (f-A 1) (misc-null-10) OPE1_3B (FRj-null))
   9689      (c-call VOID "@cpu@_clear_accumulators" (index-of ACC40Sk) 1)
   9690      ((fr400 (unit u-media-4)) (fr450 (unit u-media-4-mclracca))
   9691       (fr500 (unit u-media)) (fr550 (unit u-media-3-mclracc)))
   9692 )
   9693 
   9694 (dni mrdacc
   9695      "Media read accumulator"
   9696      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9697       (FR400-MAJOR M-1) (FR450-MAJOR M-5))
   9698      "mrdacc$pack $ACC40Si,$FRintk"
   9699      (+ pack FRintk OP_7B ACC40Si OPE1_3C (FRj-null))
   9700      (set FRintk ACC40Si)
   9701      ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
   9702       (fr500 (unit u-media)) (fr550 (unit u-media-3-acc)))
   9703 )
   9704 
   9705 (dni mrdaccg
   9706      "Media read accumulator guard"
   9707      ((UNIT FM01) (FR500-MAJOR M-2) (FR550-MAJOR M-3)
   9708       (FR400-MAJOR M-1) (FR450-MAJOR M-5))
   9709      "mrdaccg$pack $ACCGi,$FRintk"
   9710      (+ pack FRintk OP_7B ACCGi OPE1_3E (FRj-null))
   9711      (set FRintk ACCGi)
   9712      ((fr400 (unit u-media-4-accg)) (fr450 (unit u-media-4-accg))
   9713       (fr500 (unit u-media)) (fr550 (unit u-media-3-acc (in ACC40Si ACCGi))))
   9714 )
   9715 
   9716 (dni mwtacc
   9717      "Media write accumulator"
   9718      ((UNIT FM01) (FR500-MAJOR M-3) (FR550-MAJOR M-3)
   9719       (FR400-MAJOR M-1) (FR450-MAJOR M-3))
   9720      "mwtacc$pack $FRinti,$ACC40Sk"
   9721      (+ pack ACC40Sk OP_7B FRinti OPE1_3D (FRj-null))
   9722      (set ACC40Sk (or (and ACC40Sk (const DI #xffffffff00000000))
   9723 		     FRinti))
   9724      ((fr400 (unit u-media-4)) (fr450 (unit u-media-4))
   9725       (fr500 (unit u-media)) (fr550 (unit u-media-3-wtacc)))
   9726 )
   9727 
   9728 (dni mwtaccg
   9729      "Media write accumulator guard"
   9730      ((UNIT FM01) (FR500-MAJOR M-3) (FR550-MAJOR M-3)
   9731       (FR400-MAJOR M-1) (FR450-MAJOR M-3))
   9732      "mwtaccg$pack $FRinti,$ACCGk"
   9733      (+ pack ACCGk OP_7B FRinti OPE1_3F (FRj-null))
   9734      (sequence ()
   9735 	       ; hack to get these referenced for profiling
   9736 	       (c-raw-call VOID "frv_ref_SI" ACCGk)
   9737 	       (set ACCGk FRinti))
   9738      ((fr400 (unit u-media-4-accg)) (fr450 (unit u-media-4-accg))
   9739       (fr500 (unit u-media)) (fr550 (unit u-media-3-wtacc (in ACC40Sk ACCGk))))
   9740 )
   9741 
   9742 (define-pmacro (media-cop num op)
   9743   (dni (.sym mcop num)
   9744        "Media custom instruction"
   9745        ((UNIT FM01) (FR500-MAJOR M-1) (MACH frv))
   9746        (.str "mcop" num "$pack $FRi,$FRj,$FRk")
   9747        (+ pack FRk op FRi OPE1_00 FRj)
   9748        (c-call VOID "@cpu@_media_cop" num)
   9749        ()
   9750   )
   9751 )
   9752 
   9753 (media-cop 1 OP_7C)
   9754 (media-cop 2 OP_7D)
   9755 
   9756 ; nop
   9757 ; A nop is defined to be a "ori gr0,0,gr0"
   9758 ; This needn't be a macro-insn, but making it one greatly simplifies decode.c
   9759 ; On the other hand spending a little time in the decoder is often worth it.
   9760 ;
   9761 (dnmi nop "nop"
   9762      ((UNIT IALL) (FR500-MAJOR I-1) (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   9763      "nop$pack"
   9764      (emit ori pack (GRi 0) (s12 0) (GRk 0))
   9765 )
   9766 
   9767 ; Floating point NOP
   9768 (dni fnop
   9769      "Floating point nop"
   9770      ((UNIT FMALL) (FR500-MAJOR F-8) (FR550-MAJOR F-1) (MACH simple,tomcat,fr500,fr550,frv))
   9771      "fnop$pack"
   9772      (+ pack (rd-null) OP_79 (FRi-null) OPE1_0D (FRj-null))
   9773      (nop)
   9774      ()
   9775 )
   9776 
   9777 ; A return instruction
   9778 (dnmi ret "return"
   9779       (NO-DIS (UNIT B01) (FR500-MAJOR B-3)
   9780 	      (FR400-MAJOR B-3) (FR450-MAJOR B-3))
   9781       "ret$pack"
   9782       (emit bralr pack (hint_taken 2))
   9783 )
   9784 
   9785 (dnmi cmp "compare"
   9786       (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
   9787 	      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   9788       "cmp$pack $GRi,$GRj,$ICCi_1"
   9789       (emit subcc pack GRi GRj (GRk 0) ICCi_1)
   9790 )
   9791 
   9792 (dnmi cmpi "compare immediate"
   9793       (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
   9794 	      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   9795       "cmpi$pack $GRi,$s10,$ICCi_1"
   9796       (emit subicc pack GRi s10 (GRk 0) ICCi_1)
   9797 )
   9798 
   9799 (dnmi ccmp "conditional compare"
   9800       (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
   9801 	      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   9802       "ccmp$pack $GRi,$GRj,$CCi,$cond"
   9803       (emit csubcc pack GRi GRj (GRk 0) CCi cond)
   9804 )
   9805 
   9806 (dnmi mov "move"
   9807       (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
   9808 	      (FR400-MAJOR I-1) (FR450-MAJOR I-1))
   9809       "mov$pack $GRi,$GRk"
   9810       (emit ori pack GRi (s12 0) GRk)
   9811 )   
   9812 
   9813 (dnmi cmov "conditional move"
   9814       (NO-DIS (UNIT IALL) (FR500-MAJOR I-1)
   9815 	      (FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
   9816       "cmov$pack $GRi,$GRk,$CCi,$cond"
   9817       (emit cor pack GRi (GRj 0) GRk CCi cond)
   9818 )   
   9819