; Fujitsu FRV opcode support, for GNU Binutils. -*- Scheme -*-
;
; Copyright 2000, 2001, 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
;
; Contributed by Red Hat Inc; developed under contract from Fujitsu.
;
; This file is part of the GNU Binutils.
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
; MA 02110-1301, USA.
(include "simplify.inc")
; define-arch must appear first
(define-arch
(name frv) ; name of cpu architecture
(comment "Fujitsu FRV")
(insn-lsb0? #t)
(machs frv fr550 fr500 fr450 fr400 tomcat simple)
(isas frv)
)
(define-isa
(name frv)
(base-insn-bitsize 32)
; Initial bitnumbers to decode insns by.
(decode-assist (24 23 22 21 20 19 18))
(liw-insns 1) ; The frv fetches up to 1 insns at a time.
(parallel-insns 8) ; The frv executes up to 8 insns at a time.
)
; Cpu family definitions.
;
(define-cpu
; cpu names must be distinct from the architecture name and machine names.
; The "b" suffix stands for "base" and is the convention.
; The "f" suffix stands for "family" and is the convention.
(name frvbf)
(comment "Fujitsu FRV base family")
(endian big)
(word-bitsize 32)
)
(pipeline all "" () ((fetch) (decode) (execute) (writeback)))
; `state' is a list of variables for recording model state
(state
; State items
; These are all masks with each bit representing one register.
(prev-fpop DI) ; Previous use of FR register was floating point insn
(prev-media DI) ; Previous use of FR register was a media insn
(prev-cc-complex DI) ; Previous use of ICC register was not simple
(cur-fpop DI) ; Current use of FR register was floating point insn
(cur-media DI) ; Current use of FR register was a media insn
(cur-cc-complex DI) ; Current use of ICC register was not simple
)
; Basic unit for instructions with no latency penalties
(unit u-exec "Execution Unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Basic integer insn unit
(unit u-integer "Integer Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Integer multiplication unit
(unit u-imul "Integer Multiplication Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Integer division unit
(unit u-idiv "Integer Division Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Branch unit
(unit u-branch "Branch Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)
(ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
((pc)) ; outputs
() ; profile action (default)
)
; Trap unit
(unit u-trap "Trap Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)
(ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Condition code check unit
(unit u-check "Check Unit" ()
1 1 ; issue done
() ; state
((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Clrgr unit
(unit u-clrgr "Clrgr Unit" ()
1 1 ; issue done
() ; state
((GRk INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Clrfr unit
(unit u-clrfr "Clrfr Unit" ()
1 1 ; issue done
() ; state
((FRk INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; GR set half unit
(unit u-set-hilo "GR Set Half" ()
1 1 ; issue done
() ; state
() ; inputs
((GRkhi INT -1) (GRklo INT -1)) ; outputs
() ; profile action (default)
)
; GR load unit -- TODO doesn't handle quad
(unit u-gr-load "GR Load Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (GRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; GR store unit -- TODO doesn't handle quad
(unit u-gr-store "GR Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; GR recovering store unit -- TODO doesn't handle quad
(unit u-gr-r-store "GR Recovering Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; FR load unit -- TODO doesn't handle quad
(unit u-fr-load "FR Load Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((FRintk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; FR store unit -- TODO doesn't handle quad
(unit u-fr-store "FR Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; FR recovering store unit -- TODO doesn't handle quad
(unit u-fr-r-store "FR Recovering Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Swap unit
(unit u-swap "Swap Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1)) ; outputs
() ; profile action (default)
)
; FR Move to FR unit
(unit u-fr2fr "FR Move to FR Unit" ()
1 1 ; issue done
() ; state
((FRi INT -1)) ; inputs
((FRk INT -1)) ; outputs
() ; profile action (default)
)
; FR Move to GR unit
(unit u-fr2gr "FR Move to GR Unit" ()
1 1 ; issue done
() ; state
((FRintk INT -1)) ; inputs
((GRj INT -1)) ; outputs
() ; profile action (default)
)
; SPR Move to GR unit
(unit u-spr2gr "SPR Move to GR Unit" ()
1 1 ; issue done
() ; state
((spr INT -1)) ; inputs
((GRj INT -1)) ; outputs
() ; profile action (default)
)
; GR Move to FR unit
(unit u-gr2fr "GR Move to FR Unit" ()
1 1 ; issue done
() ; state
((GRj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; GR Move to SPR unit
(unit u-gr2spr "GR Move to SPR Unit" ()
1 1 ; issue done
() ; state
((GRj INT -1)) ; inputs
((spr INT -1)) ; outputs
() ; profile action (default)
)
; Float Arithmetic unit
(unit u-float-arith "Float Arithmetic unit" ()
1 1 ; issue done
() ; state
((FRi INT -1) (FRj INT -1) ; inputs
(FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
((FRk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; Float Dual Arithmetic unit
(unit u-float-dual-arith "Float Arithmetic unit" ()
1 1 ; issue done
() ; state
((FRi INT -1) (FRj INT -1) ; inputs
(FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
((FRk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; Float Div unit
(unit u-float-div "Float Div unit" ()
1 1 ; issue done
() ; state
((FRi INT -1) (FRj INT -1)) ; inputs
((FRk INT -1)) ; outputs
() ; profile action (default)
)
; Float Square Root unit
(unit u-float-sqrt "Float Square Root unit" ()
1 1 ; issue done
() ; state
((FRj INT -1) (FRdoublej INT -1)) ; inputs
((FRk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; Float Dual Square Root unit
(unit u-float-dual-sqrt "Float Dual Square Root unit" ()
1 1 ; issue done
() ; state
((FRj INT -1)) ; inputs
((FRk INT -1)) ; outputs
() ; profile action (default)
)
; Float Compare unit
(unit u-float-compare "Float Compare unit" ()
1 1 ; issue done
() ; state
((FRi INT -1) (FRj INT -1)
(FRdoublei INT -1) (FRdoublej INT -1)) ; inputs
((FCCi_2 INT -1)) ; outputs
() ; profile action (default)
)
; Dual Float Compare unit
(unit u-float-dual-compare "Float Dual Compare unit" ()
1 1 ; issue done
() ; state
((FRi INT -1) (FRj INT -1)) ; inputs
((FCCi_2 INT -1)) ; outputs
() ; profile action (default)
)
; Float Conversion unit
(unit u-float-convert "Float Conversion unit" ()
1 1 ; issue done
() ; state
((FRj INT -1) (FRintj INT -1) (FRdoublej INT -1)) ; inputs
((FRk INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; Dual Float Conversion unit
(unit u-float-dual-convert "Float Dual Conversion unit" ()
1 1 ; issue done
() ; state
((FRj INT -1) (FRintj INT -1)) ; inputs
((FRk INT -1) (FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit
(unit u-media "Media unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1) (ACC40Si INT -1) (ACCGi INT -1)) ; inputs
((FRintk INT -1) (ACC40Sk INT -1) (ACC40Uk INT -1) (ACCGk INT -1)) ; outputs
() ; profile action (default)
)
; Media Quad Arithmetic unit
(unit u-media-quad-arith "Media Quad Arithmetic unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual Multiplication unit
(unit u-media-dual-mul "Media Dual Multiplication unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
() ; profile action (default)
)
; Media Quad Multiplication unit
(unit u-media-quad-mul "Media Quad Multiplication unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
() ; profile action (default)
)
; Media Quad Complex unit
(unit u-media-quad-complex "Media Quad Complex unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual Expand unit
(unit u-media-dual-expand "Media Dual Expand unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual Unpack unit
(unit u-media-dual-unpack "Media Dual Unpack unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual byte to half unit
(unit u-media-dual-btoh "Media Byte to byte" ()
1 1 ; issue done
() ; state
((FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual half to byte unit
(unit u-media-dual-htob "Media Half to byte" ()
1 1 ; issue done
() ; state
((FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual byte to half unit extended
(unit u-media-dual-btohe "Media Byte to byte extended" ()
1 1 ; issue done
() ; state
((FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Barrier unit
(unit u-barrier "Barrier unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Memory Barrier unit
(unit u-membar "Memory Barrier unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache invalidate unit
(unit u-ici "Insn cache invalidate unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache invalidate unit
(unit u-dci "Data cache invalidate unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache flush unit
(unit u-dcf "Data cache flush unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache preload unit
(unit u-icpl "Insn cache preload unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache preload unit
(unit u-dcpl "Data cache preload unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache unlock unit
(unit u-icul "Insn cache unlock unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache unlock unit
(unit u-dcul "Data cache unlock unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; commit unit
(unit u-commit "Commit Unit" ()
1 1 ; issue done
() ; state
((GRk INT -1) (FRk INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
)
; Tomcat machine. Early version of fr500 machine
(define-mach
(name tomcat)
(comment "Tomcat -- early version of fr500")
(cpu frvbf)
)
(define-model
(name tomcat) (comment "Tomcat model") (attrs)
(mach tomcat)
(pipeline all "" () ((fetch) (decode) (execute) (writeback)))
; `state' is a list of variables for recording model state
; (state)
; FR400 machine
(define-mach
(name fr400)
(comment "FR400 cpu")
(cpu frvbf)
)
(define-model
(name fr400) (comment "FR400 model") (attrs)
(mach fr400)
(pipeline all "" () ((fetch) (decode) (execute) (writeback)))
; `state' is a list of variables for recording model state
(state
; State items
; These are all masks with each bit representing one register.
(prev-fp-load DI) ; Previous use of FR register was floating point load
(prev-fr-p4 DI) ; Previous use of FR register was media unit 4
(prev-fr-p6 DI) ; Previous use of FR register was media unit 6
(prev-acc-p2 DI) ; Previous use of ACC register was media unit 2
(prev-acc-p4 DI) ; Previous use of ACC register was media unit 4
(cur-fp-load DI) ; Current use of FR register is floating point load
(cur-fr-p4 DI) ; Current use of FR register is media unit 4
(cur-fr-p6 DI) ; Current use of FR register is media unit 6
(cur-acc-p2 DI) ; Current use of ACC register is media unit 2
(cur-acc-p4 DI) ; Current use of ACC register is media unit 4
)
(unit u-exec "Execution Unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Basic integer insn unit
(unit u-integer "Integer Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Integer multiplication unit
(unit u-imul "Integer Multiplication Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Integer division unit
(unit u-idiv "Integer Division Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Branch unit
(unit u-branch "Branch Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)
(ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
((pc)) ; outputs
() ; profile action (default)
)
; Trap unit
(unit u-trap "Trap Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)
(ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Condition code check unit
(unit u-check "Check Unit" ()
1 1 ; issue done
() ; state
((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; GR set half unit
(unit u-set-hilo "GR Set Half" ()
1 1 ; issue done
() ; state
() ; inputs
((GRkhi INT -1) (GRklo INT -1)) ; outputs
() ; profile action (default)
)
; GR load unit -- TODO doesn't handle quad
(unit u-gr-load "GR Load Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (GRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; GR store unit -- TODO doesn't handle quad
(unit u-gr-store "GR Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; FR load unit -- TODO doesn't handle quad
(unit u-fr-load "FR Load Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((FRintk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; FR store unit -- TODO doesn't handle quad
(unit u-fr-store "FR Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Swap unit
(unit u-swap "Swap Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1)) ; outputs
() ; profile action (default)
)
; FR Move to GR unit
(unit u-fr2gr "FR Move to GR Unit" ()
1 1 ; issue done
() ; state
((FRintk INT -1)) ; inputs
((GRj INT -1)) ; outputs
() ; profile action (default)
)
; SPR Move to GR unit
(unit u-spr2gr "SPR Move to GR Unit" ()
1 1 ; issue done
() ; state
((spr INT -1)) ; inputs
((GRj INT -1)) ; outputs
() ; profile action (default)
)
; GR Move to FR unit
(unit u-gr2fr "GR Move to FR Unit" ()
1 1 ; issue done
() ; state
((GRj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; GR Move to SPR unit
(unit u-gr2spr "GR Move to SPR Unit" ()
1 1 ; issue done
() ; state
((GRj INT -1)) ; inputs
((spr INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M1 -- see table 13-8 in the fr400 LSI
(unit u-media-1 "Media-1 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-1-quad "Media-1-quad unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
1 1 ; issue done
() ; state
() ; inputs
((FRkhi INT -1) (FRklo INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M2 -- see table 13-8 in the fr400 LSI
(unit u-media-2 "Media-2 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-quad "Media-2-quad unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-acc "Media-2-acc unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-add-sub "Media-2-add-sub unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M3 -- see table 13-8 in the fr400 LSI
(unit u-media-3 "Media-3 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-3-dual "Media-3-dual unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-3-quad "Media-3-quad unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M4 -- see table 13-8 in the fr400 LSI
(unit u-media-4 "Media-4 unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-4-accg "Media-4-accg unit" ()
1 1 ; issue done
() ; state
((ACCGi INT -1) (FRinti INT -1)) ; inputs
((ACCGk INT -1) (FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M6 -- see table 13-8 in the fr400 LSI
(unit u-media-6 "Media-6 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M7 -- see table 13-8 in the fr400 LSI
(unit u-media-7 "Media-1 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FCCk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual Expand unit
(unit u-media-dual-expand "Media Dual Expand unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual half to byte unit
(unit u-media-dual-htob "Media Half to byte" ()
1 1 ; issue done
() ; state
((FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Barrier unit
(unit u-barrier "Barrier unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Memory Barrier unit
(unit u-membar "Memory Barrier unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache invalidate unit
(unit u-ici "Insn cache invalidate unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache invalidate unit
(unit u-dci "Data cache invalidate unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache flush unit
(unit u-dcf "Data cache flush unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache preload unit
(unit u-icpl "Insn cache preload unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache preload unit
(unit u-dcpl "Data cache preload unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache unlock unit
(unit u-icul "Insn cache unlock unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache unlock unit
(unit u-dcul "Data cache unlock unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
)
; FR450 machine
(define-mach
(name fr450)
(comment "FR450 cpu")
(cpu frvbf)
)
(define-model
(name fr450) (comment "FR450 model") (attrs)
(mach fr450)
(pipeline all "" () ((fetch) (decode) (execute) (writeback)))
; `state' is a list of variables for recording model state
(state
; State items
; These are all masks with each bit representing one register.
(prev-fp-load DI) ; Previous use of FR register was floating point load
(prev-fr-p4 DI) ; Previous use of FR register was media unit 4
(prev-fr-p6 DI) ; Previous use of FR register was media unit 6
(prev-acc-p2 DI) ; Previous use of ACC register was media unit 2
(prev-acc-p4 DI) ; Previous use of ACC register was media unit 4
(cur-fp-load DI) ; Current use of FR register is floating point load
(cur-fr-p4 DI) ; Current use of FR register is media unit 4
(cur-fr-p6 DI) ; Current use of FR register is media unit 6
(cur-acc-p2 DI) ; Current use of ACC register is media unit 2
(cur-acc-p4 DI) ; Current use of ACC register is media unit 4
)
(unit u-exec "Execution Unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Basic integer insn unit
(unit u-integer "Integer Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Integer multiplication unit
(unit u-imul "Integer Multiplication Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRdoublek INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Integer division unit
(unit u-idiv "Integer Division Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (ICCi_1 INT -1)) ; outputs
() ; profile action (default)
)
; Branch unit
(unit u-branch "Branch Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)
(ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
((pc)) ; outputs
() ; profile action (default)
)
; Trap unit
(unit u-trap "Trap Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)
(ICCi_2 INT -1) (FCCi_2 INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Condition code check unit
(unit u-check "Check Unit" ()
1 1 ; issue done
() ; state
((ICCi_3 INT -1) (FCCi_3 INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; GR set half unit
(unit u-set-hilo "GR Set Half" ()
1 1 ; issue done
() ; state
() ; inputs
((GRkhi INT -1) (GRklo INT -1)) ; outputs
() ; profile action (default)
)
; GR load unit -- TODO doesn't handle quad
(unit u-gr-load "GR Load Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1) (GRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; GR store unit -- TODO doesn't handle quad
(unit u-gr-store "GR Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (GRk INT -1) (GRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; FR load unit -- TODO doesn't handle quad
(unit u-fr-load "FR Load Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((FRintk INT -1) (FRdoublek INT -1)) ; outputs
() ; profile action (default)
)
; FR store unit -- TODO doesn't handle quad
(unit u-fr-store "FR Store Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1) (FRintk INT -1) (FRdoublek INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Swap unit
(unit u-swap "Swap Unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
((GRk INT -1)) ; outputs
() ; profile action (default)
)
; FR Move to GR unit
(unit u-fr2gr "FR Move to GR Unit" ()
1 1 ; issue done
() ; state
((FRintk INT -1)) ; inputs
((GRj INT -1)) ; outputs
() ; profile action (default)
)
; SPR Move to GR unit
(unit u-spr2gr "SPR Move to GR Unit" ()
1 1 ; issue done
() ; state
((spr INT -1)) ; inputs
((GRj INT -1)) ; outputs
() ; profile action (default)
)
; GR Move to FR unit
(unit u-gr2fr "GR Move to FR Unit" ()
1 1 ; issue done
() ; state
((GRj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; GR Move to SPR unit
(unit u-gr2spr "GR Move to SPR Unit" ()
1 1 ; issue done
() ; state
((GRj INT -1)) ; inputs
((spr INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M1 -- see table 14-8 in the fr450 LSI
(unit u-media-1 "Media-1 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-1-quad "Media-1-quad unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-hilo "Media-hilo unit -- a variation of the Media-1 unit" ()
1 1 ; issue done
() ; state
() ; inputs
((FRkhi INT -1) (FRklo INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M2 -- see table 14-8 in the fr450 LSI
(unit u-media-2 "Media-2 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-quad "Media-2-quad unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (ACC40Uk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-acc "Media-2-acc unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-acc-dual "Media-2-acc-dual unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-add-sub "Media-2-add-sub unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-2-add-sub-dual "Media-2-add-sub-dual unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((ACC40Sk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M3 -- see table 14-8 in the fr450 LSI
(unit u-media-3 "Media-3 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-3-dual "Media-3-dual unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-3-quad "Media-3-quad unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M4 -- see table 14-8 in the fr450 LSI
(unit u-media-4 "Media-4 unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1) (FRintj INT -1)) ; inputs
((ACC40Sk INT -1) (FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-4-accg "Media-4-accg unit" ()
1 1 ; issue done
() ; state
((ACCGi INT -1) (FRinti INT -1)) ; inputs
((ACCGk INT -1) (FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-4-acc-dual "Media-4-acc-dual unit" ()
1 1 ; issue done
() ; state
((ACC40Si INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
(unit u-media-4-mclracca "Media-4 unit for MCLRACC with #A=1" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Media unit M6 -- see table 14-8 in the fr450 LSI
(unit u-media-6 "Media-6 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media unit M7 -- see table 14-8 in the fr450 LSI
(unit u-media-7 "Media-1 unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1) (FRintj INT -1)) ; inputs
((FCCk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual Expand unit
(unit u-media-dual-expand "Media Dual Expand unit" ()
1 1 ; issue done
() ; state
((FRinti INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Media Dual half to byte unit
(unit u-media-dual-htob "Media Half to byte" ()
1 1 ; issue done
() ; state
((FRintj INT -1)) ; inputs
((FRintk INT -1)) ; outputs
() ; profile action (default)
)
; Barrier unit
(unit u-barrier "Barrier unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Memory Barrier unit
(unit u-membar "Memory Barrier unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache invalidate unit
(unit u-ici "Insn cache invalidate unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache invalidate unit
(unit u-dci "Data cache invalidate unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache flush unit
(unit u-dcf "Data cache flush unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache preload unit
(unit u-icpl "Insn cache preload unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache preload unit
(unit u-dcpl "Data cache preload unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Insn cache unlock unit
(unit u-icul "Insn cache unlock unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
; Data cache unlock unit
(unit u-dcul "Data cache unlock unit" ()
1 1 ; issue done
() ; state
((GRi INT -1) (GRj INT -1)) ; inputs
() ; outputs
() ; profile action (default)
)
)
; Simple machine - single issue integer machine
(define-mach
(name simple)
(comment "Simple single issue integer cpu")
(cpu frvbf)
)
(define-model
(name simple) (comment "Simple model") (attrs)
(mach simple)
(pipeline all "" () ((fetch) (decode) (execute) (writeback)))
; `state' is a list of variables for recording model state
(state)
(unit u-exec "Execution Unit" ()
1 1 ; issue done
() ; state
() ; inputs
() ; outputs
() ; profile action (default)
)
)
; The instruction fetch/execute cycle.
;
; This is how to fetch and decode an instruction.
; Leave it out for now
; (define-extract (const SI 0))
; This is how to execute a decoded instruction.
; Leave it out for now
; (define-execute (const SI 0))
; An attribute to describe which unit an insn runs in.
(define-attr
(for insn)
(type enum)
(name UNIT)
(comment "parallel execution pipeline selection")
; The order of declaration is significant.
; See the *_unit_mapping tables in frv.opc
; Keep variations on the same unit together.
; Keep the '01' variant immediately after the '1' variant in each unit.
; Keep the 'ALL' variations immediately after the last numbered variant in each unit.
(values NIL
I0 I1 I01 I2 I3 IALL
FM0 FM1 FM01 FM2 FM3 FMALL FMLOW
B0 B1 B01
C
MULT-DIV ; multiply/division slotted differently on different machines
IACC ; iacc multiply slotted differently on different machines
LOAD ; loads slotted differently on different machines
STORE ; store slotted differently on different machines
SCAN ; scan, scani slotted differently on different machines
DCPL ; dcpl slotted differently on different machines
MDUALACC ; media dual acc slotted differently on different machines
MDCUTSSI ; mdcutssi insn slotted differently on different machines
MCLRACC-1; mclracc A==1 slotted differently on different machines
NUM_UNITS
)
)
; Attributes to describe major categories of insns
(define-attr
(for insn)
(type enum)
(name FR400-MAJOR)
(comment "fr400 major insn categories")
; The order of declaration is significant. Keep variations on the same major
; together.
(values NONE
I-1 I-2 I-3 I-4 I-5
B-1 B-2 B-3 B-4 B-5 B-6
C-1 C-2
M-1 M-2
)
)
(define-attr
(for insn)
(type enum)
(name FR450-MAJOR)
(comment "fr450 major insn categories")
; The order of declaration is significant. Keep variations on the same major
; together.
(values NONE
I-1 I-2 I-3 I-4 I-5
B-1 B-2 B-3 B-4 B-5 B-6
C-1 C-2
M-1 M-2 M-3 M-4 M-5 M-6
)
)
(define-attr
(for insn)
(type enum)
(name FR500-MAJOR)
(comment "fr500 major insn categories")
; The order of declaration is significant. Keep variations on the same major
; together.
(values NONE
I-1 I-2 I-3 I-4 I-5 I-6
B-1 B-2 B-3 B-4 B-5 B-6
C-1 C-2
F-1 F-2 F-3 F-4 F-5 F-6 F-7 F-8
M-1 M-2 M-3 M-4 M-5 M-6 M-7 M-8
)
)
(define-attr
(for insn)
(type enum)
(name FR550-MAJOR)
(comment "fr550 major insn categories")
; The order of declaration is significant. Keep variations on the same major
; together.
(values NONE
I-1 I-2 I-3 I-4 I-5 I-6 I-7 I-8
B-1 B-2 B-3 B-4 B-5 B-6
C-1 C-2
F-1 F-2 F-3 F-4
M-1 M-2 M-3 M-4 M-5
)
)
; Privileged insn
(define-attr
(for insn)
(type boolean)
(name PRIVILEGED)
(comment "insn only allowed in supervisor mode")
)
; Non-Excepting insn
(define-attr
(for insn)
(type boolean)
(name NON-EXCEPTING)
(comment "non-excepting insn")
)
; Conditional insn
(define-attr
(for insn)
(type boolean)
(name CONDITIONAL)
(comment "conditional insn")
)
; insn accesses FR registers
(define-attr
(for insn)
(type boolean)
(name FR-ACCESS)
(comment "insn accesses FR registers")
)
; insn preserves MSR.OVF
(define-attr
(for insn)
(type boolean)
(name PRESERVE-OVF)
(comment "Preserve value of MSR.OVF")
)
; "Audio" instruction provided by the fr405 but not the original fr400 core.
(define-attr
(for insn)
(type boolean)
(name AUDIO)
(comment "Audio instruction added with FR405")
)
; null attribute -- used as a place holder for where an attribue is required.
(define-attr
(for insn)
(type boolean)
(name NA)
(comment "placeholder attribute")
(attrs META) ; do not define in any generated file for now
)
(df f-CRj_int "target cr for ck insns" () 26 2 UINT
((value pc) (sub WI value 4))
((value pc) (add WI value 4))
)
(dnf f-CRj_float "target cr for fck insns" () 26 2)
(df f-label16 "18 bit pc relative signed offset" (PCREL-ADDR) 15 16 INT
((value pc) (sra WI (sub WI value pc) (const 2)))
((value pc) (add WI (mul WI value (const 4)) pc))
)
; int-cc: integer branch conditions
; FIXME: should use die macro or some such
(define-normal-insn-enum int-cc "integer branch cond enums" () ICC_ f-int-cc
(
"nev" "c" "v" "lt" "eq" "ls" "n" "le"
"ra" "nc" "nv" "ge" "ne" "hi" "p" "gt"
)
)
; flt-cc: floating-point/media branch conditions
; FIXME: should use die macro or some such
(define-normal-insn-enum flt-cc "float branch cond enums" () FCC_ f-flt-cc
("nev" "u" "gt" "ug" "lt" "ul" "lg" "ne"
"eq" "ue" "ge" "uge" "le" "ule" "o" "ra")
)
; Hardware pieces.
; These entries list the elements of the raw hardware.
; They're also used to provide tables and other elements of the assembly
; language.
(dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
; The PSR. The individual fields are referenced more than the entire
; register, so reference them directly. We can assemble the
; entire register contents when necessary.
;
(dsh h-psr_imple "PSR.IMPLE" () (register UQI))
(dsh h-psr_ver "PSR.VER" () (register UQI))
(dsh h-psr_ice "PSR.ICE bit" () (register BI))
(dsh h-psr_nem "PSR.NEM bit" () (register BI))
(dsh h-psr_cm "PSR.CM bit" () (register BI))
(dsh h-psr_be "PSR.BE bit" () (register BI))
(dsh h-psr_esr "PSR.ESR bit" () (register BI))
(dsh h-psr_ef "PSR.EF bit" () (register BI))
(dsh h-psr_em "PSR.EM bit" () (register BI))
(dsh h-psr_pil "PSR.PIL " () (register UQI))
(dsh h-psr_ps "PSR.PS bit" () (register BI))
(dsh h-psr_et "PSR.ET bit" () (register BI))
; PSR.S requires special handling because the shadow registers (SR0-SR4) must
; be switched with GR4-GR7 when changing from user to supervisor mode or
; vice-versa.
(define-hardware
(name h-psr_s)
(comment "PSR.S bit")
(attrs)
(type register BI)
(get)
(set (newval) (c-call VOID "@cpu@_h_psr_s_set_handler" newval))
)
; The TBR. The individual bits are referenced more than the entire
; register, so reference them directly. We can assemble the
; entire register contents when necessary.
;
(dsh h-tbr_tba "TBR.TBA" () (register UWI))
(dsh h-tbr_tt "TBR.TT" () (register UQI))
; The BPSR. The individual bits are referenced more than the entire
; register, so reference them directly. We can assemble the
; entire register contents when necessary.
;
(dsh h-bpsr_bs "PSR.S bit" () (register BI))
(dsh h-bpsr_bet "PSR.ET bit" () (register BI))
; General Registers as double words
; These registers are shadowed onto h-gr
(define-hardware
(name h-gr_double)
(comment "general registers as double words")
(attrs PROFILE VIRTUAL)
(type register DI (32))
; FIXME: Need constraint to prohibit odd numbers.
(indices extern-keyword gr-names)
(get (index)
(c-call DI "@cpu@_h_gr_double_get_handler" index))
(set (index newval)
(c-call VOID "@cpu@_h_gr_double_set_handler" index newval))
)
; General Registers as high and low half words
; These registers are shadowed onto h-gr
(define-hardware
(name h-gr_hi)
(comment "general registers as high half word")
(attrs PROFILE VIRTUAL)
(type register UHI (64))
(indices extern-keyword gr-names)
(get (index) (c-call UHI "@cpu@_h_gr_hi_get_handler" index))
(set (index newval) (c-call VOID "@cpu@_h_gr_hi_set_handler" index newval))
)
(define-hardware
(name h-gr_lo)
(comment "general registers as low half word")
(attrs PROFILE VIRTUAL)
(type register UHI (64))
(indices extern-keyword gr-names)
(get (index) (c-call UHI "@cpu@_h_gr_lo_get_handler" index))
(set (index newval) (c-call VOID "@cpu@_h_gr_lo_set_handler" index newval))
)
(define-hardware
(name h-acc40S)
(comment "40 bit signed accumulator")
(attrs PROFILE VIRTUAL)
(type register DI (64))
(indices extern-keyword acc-names)
; The accumlator is made up of two 32 bit registers, accgi/acci.
; We want to extract this as a combined 40 signed bits
(get (index)
(or DI
(sll DI (ext DI (trunc QI (reg h-spr (add index 1472))))
32)
(zext DI (reg h-spr (add index 1408)))))
; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
; on ACC and ACCG registers
(set (index newval)
(sequence ()
(c-call VOID "frv_check_spr_write_access" (add index 1408))
(set (raw-reg UWI h-spr
(add index 1472)) (and (srl newval 32) #xff))
(set (raw-reg UWI h-spr
(add index 1408)) (trunc USI newval))))
)
(define-hardware
(name h-acc40U)
(comment "40 bit unsigned accumulator")
(attrs PROFILE VIRTUAL)
(type register UDI (64))
(indices extern-keyword acc-names)
; The accumlator is made up of two 32 bit registers, accgi/acci.
; We want to extract this as a combined 40 unsigned bits
(get (index)
(or DI
(sll DI (zext DI (reg h-spr (add index 1472))) 32)
(zext DI (reg h-spr (add index 1408)))))
; Bits 40-63 are not written. raw-reg is used to bypass read-only restrictions
; on ACC and ACCG registers
(set (index newval)
(sequence ()
(c-call VOID "frv_check_spr_write_access" (add index 1408))
(set (raw-reg UWI h-spr
(add index 1472)) (and (srl newval 32) #xff))
(set (raw-reg UWI h-spr
(add index 1408)) (trunc USI newval))))
)
; 64-bit signed accumulator. Composed of iacc0h and iacc0l registers
; concatenated, but referenced more often as the composed 64 bits.
(define-keyword
; This is totally hokey -- I have to have an index!
(name iacc0-names)
(print-name h-iacc0)
(prefix "")
(values (iacc0 0))
)
(define-hardware
(name h-iacc0)
(comment "64 bit signed accumulator")
(attrs PROFILE VIRTUAL (MACH fr400,fr450))
(type register DI (1))
(indices extern-keyword iacc0-names)
; The single 64-bit integer accumulator is made up of two 32 bit
; registers, iacc0h and iacc0l. We want to extract this as a
; combined 64 signed bits.
(get (idx) (or DI (sll DI (ext DI (spr-iacc0h)) 32) (zext DI (spr-iacc0l))))
(set (idx newval)
(sequence ()
(set (spr-iacc0h) (trunc SI (srl newval 32)))
(set (spr-iacc0l) (trunc SI newval))))
)
; Integer condition code registers (CCR)
;
; The individual sub registers bits of the CCR are referenced more often than
; the entire register so set them directly. We can assemble the
; entire register when necessary.
;
(define-keyword
(name iccr-names)
(print-name h-iccr)
(prefix "")
(values (icc0 0) (icc1 1) (icc2 2) (icc3 3))
)
; Floating point condition code registers (CCR)
;
; The individual sub registers bits of the CCR are referenced more often than
; the entire register so set them directly. We can assemble the
; entire register when necessary.
;
(define-keyword
(name fccr-names)
(print-name h-fccr)
(prefix "")
(values (fcc0 0) (fcc1 1) (fcc2 2) (fcc3 3))
)
; Dummy hardware used to define packing bit on insns
;
(define-hardware
(name h-pack)
(comment "Packing bit dummy hardware")
(type immediate (UINT 1))
(values keyword "" (("" 1) (".p" 0) (".P" 0)))
)
; Dummy hardware used to define hint field for branches always taken
;
(define-hardware
(name h-hint-taken)
(comment "Branch taken hint dummy hardware")
(type immediate (UINT 1))
; The order of these is important. We want '2' to get written by default,
; but we also want the docoder/disassembler to allow the values '0', '1' and
; '3'.
(values keyword "" (("" 2) ("" 0) ("" 1) ("" 3)))
)
; Dummy hardware used to define hint field for branches never taken
;
(define-hardware
(name h-hint-not-taken)
(comment "Branch not taken hint dummy hardware")
(type immediate (UINT 1))
; The order of these is important. We want '0' to get written by default,
; but we also want the docoder/disassembler to allow the values '1', '2' and
; '3'.
(values keyword "" (("" 0) ("" 1) ("" 2) ("" 3)))
)
; Instruction Operands.
; These entries provide a layer between the assembler and the raw hardware
; description, and are used to refer to hardware elements in the semantic
; code. Usually there's a bit of over-specification, but in more complicated
; instruction sets there isn't.
; FRV specific operand attributes:
(define-attr
(for operand)
(type boolean)
(name HASH-PREFIX)
(comment "immediates have an optional '#' prefix")
)
; ??? Convention says this should be o-sr, but then the insn definitions
; should refer to o-sr which is clumsy. The "o-" could be implicit, but
; then it should be implicit for all the symbols here, but then there would
; be confusion between (f-)simm8 and (h-)simm8.
; So for now the rule is exactly as it appears here.
(dnop label16 "18 bit pc relative address" () h-iaddr f-label16)
(dnop LRAE "Load Real Address E flag" () h-uint f-LRAE)
(dnop LRAD "Load Real Address D flag" () h-uint f-LRAD)
(dnop LRAS "Load Real Address S flag" () h-uint f-LRAS)
; Instruction definitions.
;
; Notes:
; - dni is short for "define-normal-instruction"
; - Macros are used to represent each insn format. These should be used as much
; as possible unless an insn has exceptional behaviour
;
(define-pmacro (int-logic-cc-r-r name op ope comment)
(dni (.sym name cc)
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
(+ pack GRk op GRi ICCi_1 ope GRj)
(int-logic-cc-semantics name ICCi_1)
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(int-logic-cc-r-r and OP_01 OPE2_01 "and reg/reg, set icc")
(int-logic-cc-r-r or OP_01 OPE2_03 "or reg/reg, set icc")
(int-logic-cc-r-r xor OP_01 OPE2_05 "xor reg/reg, set icc")
(define-pmacro (int-shift-cc-r-r name l-r op ope comment)
(dni (.sym name cc)
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str (.sym name cc) "$pack $GRi,$GRj,$GRk,$ICCi_1")
(+ pack GRk op GRi ICCi_1 ope GRj)
(int-shift-cc-semantics name l-r ICCi_1)
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(int-shift-cc-r-r sll left OP_01 OPE2_09 "shift left logical reg/reg,set icc")
(int-shift-cc-r-r srl right OP_01 OPE2_0B "shift right logical reg/reg,set icc")
(int-shift-cc-r-r sra right OP_01 OPE2_0D "shift right arith reg/reg,set icc")
(define-pmacro (multiply-cc-semantics signop arg1 arg2 targ icc)
(sequence ((DI tmp) (QI cc))
(set cc icc)
(set tmp (mul DI (signop DI arg1) (signop DI arg2)))
(set-n cc (srl DI tmp 63))
(set-z cc (eq tmp 0))
(set targ tmp)
(set icc cc))
)
(define-pmacro (conditional-int-logic-cc name operation op ope comment)
(dni name
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
(.str name "$pack $GRi,$GRj,$GRk,$CCi,$cond")
(+ pack GRk op GRi CCi cond ope GRj)
(if (eq CCi (or cond 2))
(int-logic-cc-semantics operation
(reg h-iccr (and (index-of CCi) 3))))
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(conditional-int-logic-cc candcc and OP_5B OPE4_0 "conditional and, set icc")
(conditional-int-logic-cc corcc or OP_5B OPE4_1 "conditional or , set icc")
(conditional-int-logic-cc cxorcc xor OP_5B OPE4_2 "conditional xor, set icc")
(define-pmacro (conditional-int-shift-cc name l-r op ope comment)
(dni (.sym c name cc)
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1) CONDITIONAL)
(.str (.sym c name cc) "$pack $GRi,$GRj,$GRk,$CCi,$cond")
(+ pack GRk op GRi CCi cond ope GRj)
(if (eq CCi (or cond 2))
(int-shift-cc-semantics name l-r
(reg h-iccr (and (index-of CCi) 3))))
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(conditional-int-shift-cc sll left OP_5D OPE4_0 "shift left logical, set icc")
(conditional-int-shift-cc srl right OP_5D OPE4_1 "shift right logical, set icc")
(conditional-int-shift-cc sra right OP_5D OPE4_2 "shift right arith , set icc")
; Add and subtract with carry
;
(define-pmacro (int-arith-x-r-r name operation op ope comment)
(dni name
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
(+ pack GRk op GRi ICCi_1 ope GRj)
(set GRk ((.sym operation c) GRi GRj (cbit ICCi_1)))
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(int-arith-x-r-r addx add OP_00 OPE2_02 "Add reg/reg, with carry")
(int-arith-x-r-r subx sub OP_00 OPE2_06 "Sub reg/reg, with carry")
(define-pmacro (int-arith-x-cc-r-r name operation op ope comment)
(dni name
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str name "$pack $GRi,$GRj,$GRk,$ICCi_1")
(+ pack GRk op GRi ICCi_1 ope GRj)
(sequence ((WI tmp) (QI cc))
(set cc ICCi_1)
(set tmp ((.sym operation c) GRi GRj (cbit cc)))
(set-v cc ((.sym operation -oflag) GRi GRj (cbit cc)))
(set-c cc ((.sym operation -cflag) GRi GRj (cbit cc)))
(set-z-and-n cc tmp)
(set GRk tmp)
(set ICCi_1 cc))
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(int-arith-x-cc-r-r addxcc add OP_00 OPE2_03 "Add reg/reg, use/set carry")
(int-arith-x-cc-r-r subxcc sub OP_00 OPE2_07 "Sub reg/reg, use/set carry")
; Add and subtract with saturation
;
(define-pmacro (int-arith-ss-r-r name operation op ope comment)
(dni name
(comment)
((UNIT IALL) (MACH fr400,fr450)
(FR400-MAJOR I-1) (FR450-MAJOR I-1) AUDIO)
(.str name "$pack $GRi,$GRj,$GRk")
(+ pack GRk op GRi ope GRj)
(sequence ()
(set GRk (operation GRi GRj))
(if ((.sym operation -oflag) GRi GRj (const 0))
; Overflow, saturate.
; Sign of result will be
; same as sign of first operand.
(set GRk
(cond SI
((gt GRi 0) (const #x7fffffff))
((lt GRi 0) (const #x80000000))
(else (const 0)))))
)
((fr400 (unit u-integer)) (fr450 (unit u-integer)))
)
)
(int-arith-ss-r-r addss add OP_46 OPE1_00 "add reg/reg, with saturation")
(int-arith-ss-r-r subss sub OP_46 OPE1_01 "sub reg/reg, with saturation")
(int-logic-cc-r-simm and OP_21 "and reg/immed, set icc")
(int-logic-cc-r-simm or OP_23 "or reg/immed, set icc")
(int-logic-cc-r-simm xor OP_25 "xor reg/immed, set icc")
(define-pmacro (multiply-cc-r-simm name signop op comment)
(dni name
(comment)
((UNIT MULT-DIV) (FR500-MAJOR I-1) (FR550-MAJOR I-2)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str name "$pack $GRi,$s10,$GRdoublek,$ICCi_1")
(+ pack GRdoublek op GRi ICCi_1 s10)
(multiply-cc-semantics signop GRi s10 GRdoublek ICCi_1)
((fr400 (unit u-imul)) (fr450 (unit u-imul))
(fr500 (unit u-imul)) (fr550 (unit u-imul)))
)
)
(int-shift-cc-r-simm sll left OP_29 "shift left logical reg/immed, set icc")
(int-shift-cc-r-simm srl right OP_2B "shift right logical reg/immed, set icc")
(int-shift-cc-r-simm sra right OP_2D "shift right arith reg/immed, set icc")
(define-pmacro (int-arith-x-r-simm name operation op comment)
(dni name
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
(+ pack GRk op GRi ICCi_1 s10)
(set GRk ((.sym operation c) GRi s10 (cbit ICCi_1)))
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(int-arith-x-r-simm addxi add OP_12 "Add reg/immed, with carry")
(int-arith-x-r-simm subxi sub OP_16 "Sub reg/immed, with carry")
(define-pmacro (int-arith-x-cc-r-simm name operation op comment)
(dni name
(comment)
((UNIT IALL) (FR500-MAJOR I-1) (FR550-MAJOR I-1)
(FR400-MAJOR I-1) (FR450-MAJOR I-1))
(.str name "$pack $GRi,$s10,$GRk,$ICCi_1")
(+ pack GRk op GRi ICCi_1 s10)
(sequence ((WI tmp) (QI cc))
(set cc ICCi_1)
(set tmp ((.sym operation c) GRi s10 (cbit cc)))
(set-v cc ((.sym operation -oflag) GRi s10 (cbit cc)))
(set-c cc ((.sym operation -cflag) GRi s10 (cbit cc)))
(set-z-and-n cc tmp)
(set GRk tmp)
(set ICCi_1 cc))
((fr400 (unit u-integer)) (fr450 (unit u-integer))
(fr500 (unit u-integer)) (fr550 (unit u-integer)))
)
)
(int-arith-x-cc-r-simm addxicc add OP_13 "Add reg/immed, with carry")
(int-arith-x-cc-r-simm subxicc sub OP_17 "Sub reg/immed, with carry")
(define-pmacro (load-quad-gr-u name op ope comment)
(dni name
(comment)
((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv))
(.str name "$pack @($GRi,$GRj),$GRk")
(+ pack GRk op GRi ope GRj)
(load-quad-gr-u-semantics)
; TODO - GRk not referenced here for profiling
((fr500 (unit u-gr-load)))
)
)
(load-quad-gr-u ldqu OP_02 OPE1_16 "Load quad word, update index")
(define-pmacro (ne-load-quad-gr-u name op ope size comment)
(dni name
(comment)
((UNIT LOAD) (FR500-MAJOR I-2) (MACH frv) NON-EXCEPTING)
(.str name "$pack @($GRi,$GRj),$GRk")
(+ pack GRk op GRi ope GRj)
(ne-load-semantics GRi (index-of GRj) GRk 0 size 0
(load-quad-gr-u-semantics))
; TODO - GRk not referenced here for profiling
((fr500 (unit u-gr-load)))
)
)
(ne-load-quad-gr-u nldqu OP_02 OPE1_36 (ne-XI-size) "Load quad word, update index")
(conditional-branch-i b eq OP_06 Ieq "integer branch equal")
(conditional-branch-i b ne OP_06 Ine "integer branch not equal")
(conditional-branch-i b le OP_06 Ile "integer branch less or equal")
(conditional-branch-i b gt OP_06 Igt "integer branch greater")
(conditional-branch-i b lt OP_06 Ilt "integer branch less")
(conditional-branch-i b ge OP_06 Ige "integer branch greater or equal")
(conditional-branch-i b ls OP_06 Ils "integer branch less or equal unsigned")
(conditional-branch-i b hi OP_06 Ihi "integer branch greater unsigned")
(conditional-branch-i b c OP_06 Ic "integer branch carry set")
(conditional-branch-i b nc OP_06 Inc "integer branch carry clear")
(conditional-branch-i b n OP_06 In "integer branch negative")
(conditional-branch-i b p OP_06 Ip "integer branch positive")
(conditional-branch-i b v OP_06 Iv "integer branch overflow set")
(conditional-branch-i b nv OP_06 Inv "integer branch overflow clear")
(conditional-branch-cclr b eq I OP_0E OPE3_02 Ieq NA "integer cclr branch equal")
(conditional-branch-cclr b ne I OP_0E OPE3_02 Ine NA "integer cclr branch not equal")
(conditional-branch-cclr b le I OP_0E OPE3_02 Ile NA "integer cclr branch less or equal")
(conditional-branch-cclr b gt I OP_0E OPE3_02 Igt NA "integer cclr branch greater")
(conditional-branch-cclr b lt I OP_0E OPE3_02 Ilt NA "integer cclr branch less")
(conditional-branch-cclr b ge I OP_0E OPE3_02 Ige NA "integer cclr branch greater or equal")
(conditional-branch-cclr b ls I OP_0E OPE3_02 Ils NA "integer cclr branch less or equal unsigned")
(conditional-branch-cclr b hi I OP_0E OPE3_02 Ihi NA "integer cclr branch greater unsigned")
(conditional-branch-cclr b c I OP_0E OPE3_02 Ic NA "integer cclr branch carry set")
(conditional-branch-cclr b nc I OP_0E OPE3_02 Inc NA "integer cclr branch carry clear")
(conditional-branch-cclr b n I OP_0E OPE3_02 In NA "integer cclr branch negative")
(conditional-branch-cclr b p I OP_0E OPE3_02 Ip NA "integer cclr branch positive")
(conditional-branch-cclr b v I OP_0E OPE3_02 Iv NA "integer cclr branch overflow set")
(conditional-branch-cclr b nv I OP_0E OPE3_02 Inv NA "integer cclr branch overflow clear")
(conditional-branch-cclr fb eq F OP_0E OPE3_06 Feq FR-ACCESS "float cclr branch equal")
(conditional-branch-cclr fb ne F OP_0E OPE3_06 Fne FR-ACCESS "float cclr branch not equal")
(conditional-branch-cclr fb lg F OP_0E OPE3_06 Flg FR-ACCESS "float branch less or greater")
(conditional-branch-cclr fb ue F OP_0E OPE3_06 Fue FR-ACCESS "float branch unordered or equal")
(conditional-branch-cclr fb ul F OP_0E OPE3_06 Ful FR-ACCESS "float branch unordered or less")
(conditional-branch-cclr fb ge F OP_0E OPE3_06 Fge FR-ACCESS "float branch greater or equal")
(conditional-branch-cclr fb lt F OP_0E OPE3_06 Flt FR-ACCESS "float branch less")
(conditional-branch-cclr fb uge F OP_0E OPE3_06 Fuge FR-ACCESS "float branch unordered, greater, equal")
(conditional-branch-cclr fb ug F OP_0E OPE3_06 Fug FR-ACCESS "float branch unordered or greater")
(conditional-branch-cclr fb le F OP_0E OPE3_06 Fle FR-ACCESS "float branch less or equal")
(conditional-branch-cclr fb gt F OP_0E OPE3_06 Fgt FR-ACCESS "float branch greater")
(conditional-branch-cclr fb ule F OP_0E OPE3_06 Fule FR-ACCESS "float branch unordered, less or equal")
(conditional-branch-cclr fb u F OP_0E OPE3_06 Fu FR-ACCESS "float branch unordered")
(conditional-branch-cclr fb o F OP_0E OPE3_06 Fo FR-ACCESS "float branch ordered")
(conditional-branch-ctrlr bc eq I OP_0E OPE3_03 Ieq NA "integer ctrlr branch equal")
(conditional-branch-ctrlr bc ne I OP_0E OPE3_03 Ine NA "integer ctrlr branch not equal")
(conditional-branch-ctrlr bc le I OP_0E OPE3_03 Ile NA "integer ctrlr branch less equal")
(conditional-branch-ctrlr bc gt I OP_0E OPE3_03 Igt NA "integer ctrlr branch greater")
(conditional-branch-ctrlr bc lt I OP_0E OPE3_03 Ilt NA "integer ctrlr branch less")
(conditional-branch-ctrlr bc ge I OP_0E OPE3_03 Ige NA "integer ctrlr branch greater equal")
(conditional-branch-ctrlr bc ls I OP_0E OPE3_03 Ils NA "integer ctrlr branch less equal unsigned")
(conditional-branch-ctrlr bc hi I OP_0E OPE3_03 Ihi NA "integer ctrlr branch greater unsigned")
(conditional-branch-ctrlr bc c I OP_0E OPE3_03 Ic NA "integer ctrlr branch carry set")
(conditional-branch-ctrlr bc nc I OP_0E OPE3_03 Inc NA "integer ctrlr branch carry clear")
(conditional-branch-ctrlr bc n I OP_0E OPE3_03 In NA "integer ctrlr branch negative")
(conditional-branch-ctrlr bc p I OP_0E OPE3_03 Ip NA "integer ctrlr branch positive")
(conditional-branch-ctrlr bc v I OP_0E OPE3_03 Iv NA "integer ctrlr branch overflow set")
(conditional-branch-ctrlr bc nv I OP_0E OPE3_03 Inv NA "integer ctrlr branch overflow clear")
(conditional-branch-ctrlr fcb eq F OP_0E OPE3_07 Feq FR-ACCESS "float cclr branch equal")
(conditional-branch-ctrlr fcb ne F OP_0E OPE3_07 Fne FR-ACCESS "float cclr branch not equal")
(conditional-branch-ctrlr fcb lg F OP_0E OPE3_07 Flg FR-ACCESS "float branch less or greater")
(conditional-branch-ctrlr fcb ue F OP_0E OPE3_07 Fue FR-ACCESS "float branch unordered or equal")
(conditional-branch-ctrlr fcb ul F OP_0E OPE3_07 Ful FR-ACCESS "float branch unordered or less")
(conditional-branch-ctrlr fcb ge F OP_0E OPE3_07 Fge FR-ACCESS "float branch greater or equal")
(conditional-branch-ctrlr fcb lt F OP_0E OPE3_07 Flt FR-ACCESS "float branch less")
(conditional-branch-ctrlr fcb uge F OP_0E OPE3_07 Fuge FR-ACCESS "float branch unordered, greater, equal")
(conditional-branch-ctrlr fcb ug F OP_0E OPE3_07 Fug FR-ACCESS "float branch unordered or greater")
(conditional-branch-ctrlr fcb le F OP_0E OPE3_07 Fle FR-ACCESS "float branch less or equal")
(conditional-branch-ctrlr fcb gt F OP_0E OPE3_07 Fgt FR-ACCESS "float branch greater")
(conditional-branch-ctrlr fcb ule F OP_0E OPE3_07 Fule FR-ACCESS "float branch unordered, less or equal")
(conditional-branch-ctrlr fcb u F OP_0E OPE3_07 Fu FR-ACCESS "float branch unordered")
(conditional-branch-ctrlr fcb o F OP_0E OPE3_07 Fo FR-ACCESS "float branch ordered")
(define-pmacro (jump-and-link-semantics base offset LI)
(sequence ()
(if (eq LI 1)
(c-call VOID "@cpu@_set_write_next_vliw_addr_to_LR" 1))
; Target address gets aligned here
(set pc (and (add base offset) #xfffffffc))
(c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
)
(dni rett
"return from trap"
((UNIT C) (FR500-MAJOR C-2) (FR550-MAJOR C-2)
(FR400-MAJOR C-2) (FR450-MAJOR C-2) PRIVILEGED)
"rett$pack $debug"
(+ pack (misc-null-1) debug OP_05 (rs-null) (s12-null))
; frv_rett handles operating vs user mode
(sequence ()
(set pc (c-call UWI "frv_rett" pc debug))
(c-call VOID "@cpu@_model_branch" pc #x2)) ; hint branch taken
()
)
(dni rei
"run exception instruction"
((UNIT C) (FR500-MAJOR C-1) (MACH frv) PRIVILEGED)
"rei$pack $eir"
(+ pack (rd-null) OP_37 eir (s12-null))
(nop) ; for now
()
)
(define-pmacro (trap-semantics cond base offset)
(if cond
(sequence ()
; This is defered to frv_itrap because for the breakpoint
; case we want to change as little of the machine state as
; possible.
;
; PCSR=PC
; PSR.PS=PSR.S
; PSR.ET=0
; if PSR.ESR==1
; SR0 through SR3=GR4 through GR7
; TBR.TT=0x80 + ((GRi + s12) & 0x7f)
; PC=TBR
; We still should indicate what is modified by this insn.
(clobber (spr-pcsr))
(clobber psr_ps)
(clobber psr_et)
(clobber tbr_tt)
(if (ne psr_esr (const 0))
(sequence ()
(clobber (spr-sr0))
(clobber (spr-sr1))
(clobber (spr-sr2))
(clobber (spr-sr3))))
; frv_itrap handles operating vs user mode
(c-call VOID "frv_itrap" pc base offset)))
)
(trap-r t eq I OP_04 OPE4_0 Ieq NA "integer trap equal")
(trap-r t ne I OP_04 OPE4_0 Ine NA "integer trap not equal")
(trap-r t le I OP_04 OPE4_0 Ile NA "integer trap less or equal")
(trap-r t gt I OP_04 OPE4_0 Igt NA "integer trap greater")
(trap-r t lt I OP_04 OPE4_0 Ilt NA "integer trap less")
(trap-r t ge I OP_04 OPE4_0 Ige NA "integer trap greater or equal")
(trap-r t ls I OP_04 OPE4_0 Ils NA "integer trap less or equal unsigned")
(trap-r t hi I OP_04 OPE4_0 Ihi NA "integer trap greater unsigned")
(trap-r t c I OP_04 OPE4_0 Ic NA "integer trap carry set")
(trap-r t nc I OP_04 OPE4_0 Inc NA "integer trap carry clear")
(trap-r t n I OP_04 OPE4_0 In NA "integer trap negative")
(trap-r t p I OP_04 OPE4_0 Ip NA "integer trap positive")
(trap-r t v I OP_04 OPE4_0 Iv NA "integer trap overflow set")
(trap-r t nv I OP_04 OPE4_0 Inv NA "integer trap overflow clear")
(trap-r ft ne F OP_04 OPE4_1 Fne FR-ACCESS "float trap not equal")
(trap-r ft eq F OP_04 OPE4_1 Feq FR-ACCESS "float trap equal")
(trap-r ft lg F OP_04 OPE4_1 Flg FR-ACCESS "float trap greater or less")
(trap-r ft ue F OP_04 OPE4_1 Fue FR-ACCESS "float trap unordered or equal")
(trap-r ft ul F OP_04 OPE4_1 Ful FR-ACCESS "float trap unordered or less")
(trap-r ft ge F OP_04 OPE4_1 Fge FR-ACCESS "float trap greater or equal")
(trap-r ft lt F OP_04 OPE4_1 Flt FR-ACCESS "float trap less")
(trap-r ft uge F OP_04 OPE4_1 Fuge FR-ACCESS "float trap unordered greater or equal")
(trap-r ft ug F OP_04 OPE4_1 Fug FR-ACCESS "float trap unordered or greater")
(trap-r ft le F OP_04 OPE4_1 Fle FR-ACCESS "float trap less or equal")
(trap-r ft gt F OP_04 OPE4_1 Fgt FR-ACCESS "float trap greater")
(trap-r ft ule F OP_04 OPE4_1 Fule FR-ACCESS "float trap unordered less or equal")
(trap-r ft u F OP_04 OPE4_1 Fu FR-ACCESS "float trap unordered")
(trap-r ft o F OP_04 OPE4_1 Fo FR-ACCESS "float trap ordered")
(trap-immed ti eq I OP_1C Ieq NA "integer trap equal")
(trap-immed ti ne I OP_1C Ine NA "integer trap not equal")
(trap-immed ti le I OP_1C Ile NA "integer trap less or equal")
(trap-immed ti gt I OP_1C Igt NA "integer trap greater")
(trap-immed ti lt I OP_1C Ilt NA "integer trap less")
(trap-immed ti ge I OP_1C Ige NA "integer trap greater or equal")
(trap-immed ti ls I OP_1C Ils NA "integer trap less or equal unsigned")
(trap-immed ti hi I OP_1C Ihi NA "integer trap greater unsigned")
(trap-immed ti c I OP_1C Ic NA "integer trap carry set")
(trap-immed ti nc I OP_1C Inc NA "integer trap carry clear")
(trap-immed ti n I OP_1C In NA "integer trap negative")
(trap-immed ti p I OP_1C Ip NA "integer trap positive")
(trap-immed ti v I OP_1C Iv NA "integer trap overflow set")
(trap-immed ti nv I OP_1C Inv NA "integer trap overflow clear")
(trap-immed fti ne F OP_1D Fne FR-ACCESS "float trap not equal")
(trap-immed fti eq F OP_1D Feq FR-ACCESS "float trap equal")
(trap-immed fti lg F OP_1D Flg FR-ACCESS "float trap greater or less")
(trap-immed fti ue F OP_1D Fue FR-ACCESS "float trap unordered or equal")
(trap-immed fti ul F OP_1D Ful FR-ACCESS "float trap unordered or less")
(trap-immed fti ge F OP_1D Fge FR-ACCESS "float trap greater or equal")
(trap-immed fti lt F OP_1D Flt FR-ACCESS "float trap less")
(trap-immed fti uge F OP_1D Fuge FR-ACCESS "float trap unordered greater or equal")
(trap-immed fti ug F OP_1D Fug FR-ACCESS "float trap unordered or greater")
(trap-immed fti le F OP_1D Fle FR-ACCESS "float trap less or equal")
(trap-immed fti gt F OP_1D Fgt FR-ACCESS "float trap greater")
(trap-immed fti ule F OP_1D Fule FR-ACCESS "float trap unordered less or equal")
(trap-immed fti u F OP_1D Fu FR-ACCESS "float trap unordered")
(trap-immed fti o F OP_1D Fo FR-ACCESS "float trap ordered")
(dni break
"break trap"
((UNIT C) (FR500-MAJOR C-1) (FR550-MAJOR C-1)
(FR400-MAJOR C-1) (FR450-MAJOR C-1))
"break$pack"
(+ pack (rd-null) OP_04 (rs-null) (misc-null-3) OPE4_3 (GRj-null))
(sequence ()
; This is defered to frv_break because for the breakpoint
; case we want to change as little of the machine state as
; possible.
;
; BPCSR=PC
; BPSR.BS=PSR.S
; BPSR.BET=PSR.ET
; PSR.S=1
; PSR.ET=0
; TBR.TT=0xff
; PC=TBR
; We still should indicate what is modified by this insn.
(clobber (spr-bpcsr))
(clobber bpsr_bs)
(clobber bpsr_bet)
(clobber psr_s)
(clobber psr_et)
(clobber tbr_tt)
(c-call VOID "frv_break"))
()
)
(check-int-condition-code ck eq OP_08 Ieq "check integer cc equal")
(check-int-condition-code ck ne OP_08 Ine "check integer cc not equal")
(check-int-condition-code ck le OP_08 Ile "check integer cc less or equal")
(check-int-condition-code ck gt OP_08 Igt "check integer cc greater")
(check-int-condition-code ck lt OP_08 Ilt "check integer cc less")
(check-int-condition-code ck ge OP_08 Ige "check integer cc greater or equal")
(check-int-condition-code ck ls OP_08 Ils "check integer cc less or equal unsigned")
(check-int-condition-code ck hi OP_08 Ihi "check integer cc greater unsigned")
(check-int-condition-code ck c OP_08 Ic "check integer cc carry set")
(check-int-condition-code ck nc OP_08 Inc "check integer cc carry clear")
(check-int-condition-code ck n OP_08 In "check integer cc negative")
(check-int-condition-code ck p OP_08 Ip "check integer cc positive")
(check-int-condition-code ck v OP_08 Iv "check integer cc overflow set")
(check-int-condition-code ck nv OP_08 Inv "check integer cc overflow clear")
(check-float-condition-code fck ne OP_09 Fne "check float cc not equal")
(check-float-condition-code fck eq OP_09 Feq "check float cc equal")
(check-float-condition-code fck lg OP_09 Flg "check float cc greater or less")
(check-float-condition-code fck ue OP_09 Fue "check float cc unordered or equal")
(check-float-condition-code fck ul OP_09 Ful "check float cc unordered or less")
(check-float-condition-code fck ge OP_09 Fge "check float cc greater or equal")
(check-float-condition-code fck lt OP_09 Flt "check float cc less")
(check-float-condition-code fck uge OP_09 Fuge "check float cc unordered greater or equal")
(check-float-condition-code fck ug OP_09 Fug "check float cc unordered or greater")
(check-float-condition-code fck le OP_09 Fle "check float cc less or equal")
(check-float-condition-code fck gt OP_09 Fgt "check float cc greater")
(check-float-condition-code fck ule OP_09 Fule "check float cc unordered less or equal")
(check-float-condition-code fck u OP_09 Fu "check float cc unordered")
(check-float-condition-code fck o OP_09 Fo "check float cc ordered")
(conditional-check-int-condition-code cck eq OP_6A OPE4_0 Ieq "check integer cc equal")
(conditional-check-int-condition-code cck ne OP_6A OPE4_0 Ine "check integer cc not equal")
(conditional-check-int-condition-code cck le OP_6A OPE4_0 Ile "check integer cc less or equal")
(conditional-check-int-condition-code cck gt OP_6A OPE4_0 Igt "check integer cc greater")
(conditional-check-int-condition-code cck lt OP_6A OPE4_0 Ilt "check integer cc less")
(conditional-check-int-condition-code cck ge OP_6A OPE4_0 Ige "check integer cc greater or equal")
(conditional-check-int-condition-code cck ls OP_6A OPE4_0 Ils "check integer cc less or equal unsigned")
(conditional-check-int-condition-code cck hi OP_6A OPE4_0 Ihi "check integer cc greater unsigned")
(conditional-check-int-condition-code cck c OP_6A OPE4_0 Ic "check integer cc carry set")
(conditional-check-int-condition-code cck nc OP_6A OPE4_0 Inc "check integer cc carry clear")
(conditional-check-int-condition-code cck n OP_6A OPE4_0 In "check integer cc negative")
(conditional-check-int-condition-code cck p OP_6A OPE4_0 Ip "check integer cc positive")
(conditional-check-int-condition-code cck v OP_6A OPE4_0 Iv "check integer cc overflow set")
(conditional-check-int-condition-code cck nv OP_6A OPE4_0 Inv "check integer cc overflow clear")
(conditional-check-float-condition-code cfck ne OP_6A OPE4_1 Fne "check float cc not equal")
(conditional-check-float-condition-code cfck eq OP_6A OPE4_1 Feq "check float cc equal")
(conditional-check-float-condition-code cfck lg OP_6A OPE4_1 Flg "check float cc greater or less")
(conditional-check-float-condition-code cfck ue OP_6A OPE4_1 Fue "check float cc unordered or equal")
(conditional-check-float-condition-code cfck ul OP_6A OPE4_1 Ful "check float cc unordered or less")
(conditional-check-float-condition-code cfck ge OP_6A OPE4_1 Fge "check float cc greater or equal")
(conditional-check-float-condition-code cfck lt OP_6A OPE4_1 Flt "check float cc less")
(conditional-check-float-condition-code cfck uge OP_6A OPE4_1 Fuge "check float cc unordered greater or equal")
(conditional-check-float-condition-code cfck ug OP_6A OPE4_1 Fug "check float cc unordered or greater")
(conditional-check-float-condition-code cfck le OP_6A OPE4_1 Fle "check float cc less or equal")
(conditional-check-float-condition-code cfck gt OP_6A OPE4_1 Fgt "check float cc greater")
(conditional-check-float-condition-code cfck ule OP_6A OPE4_1 Fule "check float cc unordered less or equal")
(conditional-check-float-condition-code cfck u OP_6A OPE4_1 Fu "check float cc unordered")
(conditional-check-float-condition-code cfck o OP_6A OPE4_1 Fo "check float cc ordered")
(define-pmacro (write-TLB name insn op ope comment)
(dni name
(comment)
((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
(.str insn "$pack $GRk,@($GRi,$GRj)")
(+ pack GRk op GRi ope GRj)
(nop) ; for now
()
)
)
(write-TLB witlb witlb OP_03 OPE1_32 "write for insn TLB")
(write-TLB wdtlb wdtlb OP_03 OPE1_36 "write for data TLB")
(define-pmacro (invalidate-TLB name insn op ope comment)
(dni name
(comment)
((UNIT C) (FR500-MAJOR C-2) (MACH frv) PRIVILEGED)
(.str insn "$pack @($GRi,$GRj)")
(+ pack (rd-null) op GRi ope GRj)
(nop) ; for now
()
)
)
; Load real address instructions
(define-pmacro (load-real-address name insn what op ope)
(dni name
(.str "Load real address of " what)
((UNIT C) (FR450-MAJOR C-2) (MACH fr450))
(.str insn "$pack $GRi,$GRk,$LRAE,$LRAD,$LRAS")
(+ pack GRk op GRi ope LRAE LRAD LRAS (LRA-null))
(nop) ; not simulated
()
)
)
(floating-point-dual-conversion fditos OP_79 OPE1_10 float SF FRintj h-fr_int FRk h-fr NA "Dual Convert Integer to Single")
(floating-point-dual-conversion fdstoi OP_79 OPE1_11 fix SI FRj h-fr FRintk h-fr_int NA "Dual Convert Single to Integer")
; The (add (xxxx) (mul arg 0)) is a hack to get a reference to arg generated
; so it will be passed to the unit modelers. YUCK!!!!!
(define-pmacro (extract-hilo reg1 off1 reg2 off2 arg1hi arg1lo arg2hi arg2lo)
(sequence ()
(set arg1hi (add (halfword hi reg1 off1) (mul reg1 0)))
(set arg1lo (add (halfword lo reg1 off1) (mul reg1 0)))
(set arg2hi (add (halfword hi reg2 off2) (mul reg2 0)))
(set arg2lo (add (halfword lo reg2 off2) (mul reg2 0))))
)
(define-pmacro (saturate-v arg max min sie result)
(if (gt DI arg max)
(sequence ()
(set result max)
(c-call VOID "@cpu@_media_overflow" sie))
(if (lt DI arg min)
(sequence ()
(set result min)
(c-call VOID "@cpu@_media_overflow" sie))
(set result arg)))
)
(dni mabshs
"Media dual absolute value, halfword"
((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-2)
(FR400-MAJOR M-1) (FR450-MAJOR M-1))
"mabshs$pack $FRintj,$FRintk"
(+ pack FRintk OP_78 (FRi-null) OPE1_0A FRintj)
(sequence ((HI arghi) (HI arglo))
(set FRintj (c-raw-call SI "frv_ref_SI" FRintj))
(set FRintk (c-raw-call SI "frv_ref_SI" FRintk))
(set arghi (halfword hi FRintj 0))
(set arglo (halfword lo FRintj 0))
; We extend the argument before the abs operation so we can
; notice -32768 overflowing as 32768.
(saturate-v (abs (ext DI arghi)) 32767 -32768 (msr-sie-fri-hi)
(halfword hi FRintk 0))
(saturate-v (abs (ext DI arglo)) 32767 -32768 (msr-sie-fri-lo)
(halfword lo FRintk 0)))
((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
(fr550 (unit u-media)))
)
; How to extend from a mode to get the intended signedness.
(define-pmacro (DI-ext-HI x) (ext DI x))
(define-pmacro (DI-ext-UHI x) (zext DI x))
(define-pmacro (DI-ext-DI x) x)
(define-pmacro (media-arith-sat-semantics
operation arg1 arg2 res mode max min sie)
(sequence ((DI tmp))
; Make sure we saturate at max/min against a value that is
; sign- or zero-extended appropriately from "mode".
(set tmp (operation DI
((.sym DI-ext- mode) arg1) ((.sym DI-ext- mode) arg2)))
(saturate-v tmp max min sie res))
)
(define-pmacro (media-dual-arith-sat-semantics operation mode max min)
(sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
(extract-hilo FRinti 0 FRintj 0 argihi argilo argjhi argjlo)
(media-arith-sat-semantics operation argihi argjhi
(halfword hi FRintk 0) mode max min
(msr-sie-fri-hi))
(media-arith-sat-semantics operation argilo argjlo
(halfword lo FRintk 0) mode max min
(msr-sie-fri-lo)))
)
(define-pmacro (media-dual-arith-sat name operation mode max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
(FR400-MAJOR M-1) (FR450-MAJOR M-1))
(.str name "$pack $FRinti,$FRintj,$FRintk")
(+ pack FRintk op FRinti ope FRintj)
(media-dual-arith-sat-semantics operation mode max min)
((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
(fr500 (unit u-media)) (fr550 (unit u-media)))
)
)
(media-dual-arith-sat maddhss add HI 32767 -32768 OP_7B OPE1_10 "Media dual add signed with saturation")
(media-dual-arith-sat maddhus add UHI 65535 0 OP_7B OPE1_11 "Media dual add unsigned with saturation")
(media-dual-arith-sat msubhss sub HI 32767 -32768 OP_7B OPE1_12 "Media dual sub signed with saturation")
(media-dual-arith-sat msubhus sub UHI 65535 0 OP_7B OPE1_13 "Media dual sub unsigned with saturation")
(define-pmacro (conditional-media-dual-arith-sat
name operation mode max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
(FR400-MAJOR M-1) (FR450-MAJOR M-1) CONDITIONAL)
(.str name "$pack $FRinti,$FRintj,$FRintk,$CCi,$cond")
(+ pack FRintk op FRinti CCi cond ope FRintj)
(if (eq CCi (or cond 2))
(media-dual-arith-sat-semantics operation mode max min))
((fr400 (unit u-media-1)) (fr450 (unit u-media-1))
(fr500 (unit u-media)) (fr550 (unit u-media)))
)
)
(conditional-media-dual-arith-sat cmaddhss add HI 32767 -32768 OP_71 OPE4_0 "Conditional Media dual add signed with saturation")
(conditional-media-dual-arith-sat cmaddhus add UHI 65535 0 OP_71 OPE4_1 "Conditional Media dual add unsigned with saturation")
(conditional-media-dual-arith-sat cmsubhss sub HI 32767 -32768 OP_71 OPE4_2 "Conditional Media dual sub signed with saturation")
(conditional-media-dual-arith-sat cmsubhus sub UHI 65535 0 OP_71 OPE4_3 "Conditional Media dual sub unsigned with saturation")
(define-pmacro (media-quad-arith-sat-semantics cond operation mode max min)
(if (orif (register-unaligned FRintieven 2)
(orif (register-unaligned FRintjeven 2)
(register-unaligned FRintkeven 2)))
(c-call VOID "@cpu@_media_register_not_aligned")
(if cond
(sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
; hack to get FRintkeven referenced as a target for profiling
(set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-arith-sat-semantics operation argihi argjhi
(halfword hi FRintkeven 0) mode
max min (msr-sie-fri-hi))
(media-arith-sat-semantics operation argilo argjlo
(halfword lo FRintkeven 0) mode
max min (msr-sie-fri-lo))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-arith-sat-semantics operation argihi argjhi
(halfword hi FRintkeven 1) mode
max min (msr-sie-fri-1-hi))
(media-arith-sat-semantics operation argilo argjlo
(halfword lo FRintkeven 1) mode
max min (msr-sie-fri-1-lo)))))
)
(define-pmacro (media-quad-arith-sat name operation mode max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
(FR400-MAJOR M-2) (FR450-MAJOR M-2))
(.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
(+ pack FRintkeven op FRintieven ope FRintjeven)
(media-quad-arith-sat-semantics 1 operation mode max min)
((fr400 (unit u-media-1-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven)))
(fr450 (unit u-media-1-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven)))
(fr500 (unit u-media-quad-arith
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven))) (fr550 (unit u-media-quad)))
)
)
(media-quad-arith-sat mqaddhss add HI 32767 -32768 OP_7B OPE1_18 "Media quad add signed with saturation")
(media-quad-arith-sat mqaddhus add UHI 65535 0 OP_7B OPE1_19 "Media quad add unsigned with saturation")
(media-quad-arith-sat mqsubhss sub HI 32767 -32768 OP_7B OPE1_1A "Media quad sub signed with saturation")
(media-quad-arith-sat mqsubhus sub UHI 65535 0 OP_7B OPE1_1B "Media quad sub unsigned with saturation")
(define-pmacro (conditional-media-quad-arith-sat
name operation mode max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-1) (FR550-MAJOR M-2)
(FR400-MAJOR M-2) (FR450-MAJOR M-2) CONDITIONAL)
(.str name "$pack $FRintieven,$FRintjeven,$FRintkeven,$CCi,$cond")
(+ pack FRintkeven op FRintieven CCi cond ope FRintjeven)
(media-quad-arith-sat-semantics (eq CCi (or cond 2))
operation mode max min)
((fr400 (unit u-media-1-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven)))
(fr450 (unit u-media-1-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven)))
(fr500 (unit u-media-quad-arith
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven))) (fr550 (unit u-media-quad)))
)
)
(conditional-media-quad-arith-sat cmqaddhss add HI 32767 -32768 OP_73 OPE4_0 "Conditional Media quad add signed with saturation")
(conditional-media-quad-arith-sat cmqaddhus add UHI 65535 0 OP_73 OPE4_1 "Conditional Media quad add unsigned with saturation")
(conditional-media-quad-arith-sat cmqsubhss sub HI 32767 -32768 OP_73 OPE4_2 "Conditional Media quad sub signed with saturation")
(conditional-media-quad-arith-sat cmqsubhus sub UHI 65535 0 OP_73 OPE4_3 "Conditional Media quad sub unsigned with saturation")
;; Return A if |A| > |B| and B is positive. Return -A if |A| > |B| and
;; B is negative, saturating 0x8000 as 0x7fff. Return 0 otherwise.
(define-pmacro (media-low-clear-semantics a b)
(cond HI
((le UHI (abs a) (abs b)) 0)
((le HI 0 b) a)
((eq HI a -32768) 32767)
(else (neg a))))
;; Return A if -|B| < A < |B|. Return -B if A <= -|B|, saturating 0x8000
;; as 0x7fff. Return B if A >= |B|.
(define-pmacro (media-scope-limit-semantics a b)
(cond HI
((andif (gt HI b -32768)
(ge HI a (abs b))) b)
((gt HI a (neg (abs b))) a)
((eq HI b -32768) 32767)
(else (neg b))))
(define-pmacro (media-quad-limit name operation op ope comment)
(dni name
comment
((UNIT FM0) (MACH fr450) (FR450-MAJOR M-2))
(.str name "$pack $FRintieven,$FRintjeven,$FRintkeven")
(+ pack FRintkeven op FRintieven ope FRintjeven)
(if (orif (register-unaligned FRintieven 2)
(orif (register-unaligned FRintjeven 2)
(register-unaligned FRintkeven 2)))
(c-call VOID "@cpu@_media_register_not_aligned")
(sequence ((HI a1) (HI a2) (HI a3) (HI a4)
(HI b1) (HI b2) (HI b3) (HI b4))
; hack to get FRintkeven referenced as a target
; for profiling
(set FRintkeven (c-raw-call SI "frv_ref_SI" FRintkeven))
(extract-hilo FRintieven 0 FRintjeven 0 a1 a2 b1 b2)
(extract-hilo FRintieven 1 FRintjeven 1 a3 a4 b3 b4)
(set (halfword hi FRintkeven 0) (operation a1 b1))
(set (halfword lo FRintkeven 0) (operation a2 b2))
(set (halfword hi FRintkeven 1) (operation a3 b3))
(set (halfword lo FRintkeven 1) (operation a4 b4))))
((fr450 (unit u-media-1-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)
(out FRintk FRintkeven))))
)
)
(define-pmacro (conditional-media-quad-multiply
name mode conv rhs1 rhs2 op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4)
PRESERVE-OVF CONDITIONAL)
(.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk,$CCi,$cond")
(+ pack ACC40Sk op FRintieven CCi cond ope FRintjeven)
(media-quad-multiply-semantics (eq CCi (or cond 2)) mode conv rhs1 rhs2)
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr500 (unit u-media-quad-mul
(in FRinti FRintieven)
(in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
)
)
(conditional-media-quad-multiply cmqmulhs HI ext argjhi argjlo OP_74 OPE4_0 "Conditional Media quad multiply signed")
(conditional-media-quad-multiply cmqmulhu UHI zext argjhi argjlo OP_74 OPE4_1 "Conditional Media quad multiply unsigned")
(define-pmacro (media-multiply-acc-semantics
conv arg1 addop arg2 res max min sie)
(sequence ((DI tmp))
(set tmp (addop res (mul DI (conv DI arg1) (conv DI arg2))))
(saturate-v tmp max min sie res))
)
(define-pmacro (media-dual-multiply-acc-semantics
cond mode conv addop rhw res max min)
(if (c-call SI "@cpu@_check_acc_range" (index-of res))
(if (register-unaligned res 2)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if cond
(sequence ((mode argihi) (mode argilo) (mode argjhi) (mode argjlo))
(extract-hilo FRinti 0 FRintj 0
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjhi
res
max min (msr-sie-acci))
(media-multiply-acc-semantics conv argilo addop argjlo
(nextreg rhw res 1)
max min (msr-sie-acci-1))))))
)
(define-pmacro (media-dual-multiply-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-1) (FR450-MAJOR M-3))
(.str name "$pack $FRinti,$FRintj,$" res)
(+ pack res op FRinti ope FRintj)
(media-dual-multiply-acc-semantics 1 mode conv addop rhw res max min)
((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
)
)
(media-dual-multiply-acc mmachs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_16
"Media dual multiply and accumulate signed")
(media-dual-multiply-acc mmachu UHI zext add h-acc40U ACC40Uk
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_17
"Media dual multiply and accumulate unsigned")
(media-dual-multiply-acc mmrdhs HI ext sub h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_30
"Media dual multiply and reduce signed")
(media-dual-multiply-acc mmrdhu UHI zext sub h-acc40U ACC40Uk
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_31
"Media dual multiply and reduce unsigned")
(define-pmacro (conditional-media-dual-multiply-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
(.str name "$pack $FRinti,$FRintj,$" res ",$CCi,$cond")
(+ pack res op FRinti CCi cond ope FRintj)
(media-dual-multiply-acc-semantics (eq CCi (or cond 2))
mode conv addop rhw res max min)
((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
)
)
(conditional-media-dual-multiply-acc cmmachs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_72 OPE4_2
"Conditional Media dual multiply and accumulate signed")
(conditional-media-dual-multiply-acc cmmachu UHI zext add h-acc40U ACC40Uk
(const DI #xffffffffff) (const DI 0)
OP_72 OPE4_3
"Conditional Media dual multiply and accumulate unsigned")
(define-pmacro (media-quad-multiply-acc-semantics
cond mode conv addop rhw res max min)
(if (c-call SI "@cpu@_check_acc_range" (index-of res))
(if (register-unaligned res 4)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if (orif (register-unaligned FRintieven 2)
(register-unaligned FRintjeven 2))
(c-call VOID "@cpu@_media_register_not_aligned")
(if cond
(sequence ((mode argihi) (mode argilo)
(mode argjhi) (mode argjlo))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjhi
res
max min (msr-sie-acci))
(media-multiply-acc-semantics conv argilo addop argjlo
(nextreg rhw res 1)
max min (msr-sie-acci-1))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjhi
(nextreg rhw res 2)
max min (msr-sie-acci-2))
(media-multiply-acc-semantics conv argilo addop argjlo
(nextreg rhw res 3)
max min
(msr-sie-acci-3)))))))
)
(define-pmacro (media-quad-multiply-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4))
(.str name "$pack $FRintieven,$FRintjeven,$" res)
(+ pack res op FRintieven ope FRintjeven)
(media-quad-multiply-acc-semantics 1 mode conv addop rhw res max min)
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr500 (unit u-media-quad-mul
(in FRinti FRintieven)
(in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
)
)
(media-quad-multiply-acc mqmachs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_1E
"Media quad multiply and accumulate signed")
(media-quad-multiply-acc mqmachu UHI zext add h-acc40U ACC40Uk
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_1F
"Media quad multiply and accumulate unsigned")
(define-pmacro (conditional-media-quad-multiply-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4) CONDITIONAL)
(.str name "$pack $FRintieven,$FRintjeven,$" res ",$CCi,$cond")
(+ pack res op FRintieven CCi cond ope FRintjeven)
(media-quad-multiply-acc-semantics (eq CCi (or cond 2))
mode conv addop rhw res max min)
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr500 (unit u-media-quad-mul
(in FRinti FRintieven)
(in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
)
)
(conditional-media-quad-multiply-acc cmqmachs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_74 OPE4_2
"Conditional Media quad multiply and accumulate signed")
(conditional-media-quad-multiply-acc cmqmachu UHI zext add h-acc40U ACC40Uk
(const DI #xffffffffff) (const DI 0)
OP_74 OPE4_3
"Conditional media quad multiply and accumulate unsigned")
(define-pmacro (media-quad-multiply-cross-acc-semantics
cond mode conv addop rhw res max min)
(if (c-call SI "@cpu@_check_acc_range" (index-of res))
(if (register-unaligned res 4)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if (orif (register-unaligned FRintieven 2)
(register-unaligned FRintjeven 2))
(c-call VOID "@cpu@_media_register_not_aligned")
(if cond
(sequence ((mode argihi) (mode argilo)
(mode argjhi) (mode argjlo))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjhi
(nextreg rhw res 2)
max min (msr-sie-acci-2))
(media-multiply-acc-semantics conv argilo addop argjlo
(nextreg rhw res 3)
max min (msr-sie-acci-3))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjhi
res
max min (msr-sie-acci))
(media-multiply-acc-semantics conv argilo addop argjlo
(nextreg rhw res 1)
max min
(msr-sie-acci-1)))))))
)
(define-pmacro (media-quad-multiply-cross-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4))
(.str name "$pack $FRintieven,$FRintjeven,$" res)
(+ pack res op FRintieven ope FRintjeven)
(media-quad-multiply-cross-acc-semantics 1 mode conv addop rhw res
max min)
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr550 (unit u-media-4-quad)))
)
)
(media-quad-multiply-cross-acc mqxmachs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_78 OPE1_00
"Media quad multiply and cross accumulate signed")
(define-pmacro (media-quad-cross-multiply-cross-acc-semantics
cond mode conv addop rhw res max min)
(if (c-call SI "@cpu@_check_acc_range" (index-of res))
(if (register-unaligned res 4)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if (orif (register-unaligned FRintieven 2)
(register-unaligned FRintjeven 2))
(c-call VOID "@cpu@_media_register_not_aligned")
(if cond
(sequence ((mode argihi) (mode argilo)
(mode argjhi) (mode argjlo))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjlo
(nextreg rhw res 2)
max min (msr-sie-acci-2))
(media-multiply-acc-semantics conv argilo addop argjhi
(nextreg rhw res 3)
max min (msr-sie-acci-3))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjlo
res
max min (msr-sie-acci))
(media-multiply-acc-semantics conv argilo addop argjhi
(nextreg rhw res 1)
max min
(msr-sie-acci-1)))))))
)
(define-pmacro (media-quad-cross-multiply-cross-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4))
(.str name "$pack $FRintieven,$FRintjeven,$" res)
(+ pack res op FRintieven ope FRintjeven)
(media-quad-cross-multiply-cross-acc-semantics 1 mode conv addop rhw res
max min)
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr550 (unit u-media-4-quad)))
)
)
(media-quad-cross-multiply-cross-acc mqxmacxhs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_78 OPE1_01
"Media quad cross multiply and cross accumulate signed")
(define-pmacro (media-quad-cross-multiply-acc-semantics
cond mode conv addop rhw res max min)
(if (c-call SI "@cpu@_check_acc_range" (index-of res))
(if (register-unaligned res 4)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if (orif (register-unaligned FRintieven 2)
(register-unaligned FRintjeven 2))
(c-call VOID "@cpu@_media_register_not_aligned")
(if cond
(sequence ((mode argihi) (mode argilo)
(mode argjhi) (mode argjlo))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjlo
res
max min (msr-sie-acci))
(media-multiply-acc-semantics conv argilo addop argjhi
(nextreg rhw res 1)
max min (msr-sie-acci-1))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-multiply-acc-semantics conv argihi addop argjlo
(nextreg rhw res 2)
max min (msr-sie-acci-2))
(media-multiply-acc-semantics conv argilo addop argjhi
(nextreg rhw res 3)
max min
(msr-sie-acci-3)))))))
)
(define-pmacro (media-quad-cross-multiply-acc
name mode conv addop rhw res max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (MACH fr400,fr450,fr550) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4))
(.str name "$pack $FRintieven,$FRintjeven,$" res)
(+ pack res op FRintieven ope FRintjeven)
(media-quad-cross-multiply-acc-semantics 1 mode conv addop rhw res
max min)
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr550 (unit u-media-4-quad)))
)
)
(media-quad-cross-multiply-acc mqmacxhs HI ext add h-acc40S ACC40Sk
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_78 OPE1_02
"Media quad cross multiply and accumulate signed")
(define-pmacro (media-complex-semantics
conv lhs1 rhs1 lhs2 rhs2 res max min sie)
(sequence ((DI tmp1) (DI tmp2))
(media-multiply-semantics conv lhs1 rhs1 tmp1)
(media-multiply-semantics conv lhs2 rhs2 tmp2)
(set tmp1 (sub tmp1 tmp2))
(saturate-v tmp1 max min sie res))
)
(define-pmacro (media-complex-semantics-i
conv lhs1 rhs1 lhs2 rhs2 res max min sie)
(sequence ((DI tmp1) (DI tmp2))
(media-multiply-semantics conv lhs1 rhs1 tmp1)
(media-multiply-semantics conv lhs2 rhs2 tmp2)
(set tmp1 (add tmp1 tmp2))
(saturate-v tmp1 max min sie res))
)
(define-pmacro (media-dual-complex
name mode conv rhs1 rhs2 max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-1) (FR450-MAJOR M-3))
(.str name "$pack $FRinti,$FRintj,$ACC40Sk")
(+ pack ACC40Sk op FRinti ope FRintj)
(media-dual-complex-semantics mode conv rhs1 rhs2 max min)
((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
)
)
(define-pmacro (media-dual-complex-i
name mode conv rhs1 rhs2 max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-1) (FR450-MAJOR M-3))
(.str name "$pack $FRinti,$FRintj,$ACC40Sk")
(+ pack ACC40Sk op FRinti ope FRintj)
(media-dual-complex-semantics-i mode conv rhs1 rhs2 max min)
((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
)
)
(media-dual-complex mcpxrs HI ext argjhi argjlo
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_20
"Media dual complex real signed with saturation")
(media-dual-complex mcpxru UHI zext argjhi argjlo
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_21
"Media dual complex real unsigned with saturation")
(media-dual-complex-i mcpxis HI ext argjlo argjhi
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_22
"Media dual complex imaginary signed with saturation")
(media-dual-complex-i mcpxiu UHI zext argjlo argjhi
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_23
"Media dual complex imaginary unsigned with saturation")
(define-pmacro (conditional-media-dual-complex
name mode conv rhs1 rhs2 max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
(.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
(+ pack ACC40Sk op FRinti CCi cond ope FRintj)
(if (eq CCi (or cond 2))
(media-dual-complex-semantics mode conv rhs1 rhs2 max min))
((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
)
)
(define-pmacro (conditional-media-dual-complex-i
name mode conv rhs1 rhs2 max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-1) (FR450-MAJOR M-3) CONDITIONAL)
(.str name "$pack $FRinti,$FRintj,$ACC40Sk,$CCi,$cond")
(+ pack ACC40Sk op FRinti CCi cond ope FRintj)
(if (eq CCi (or cond 2))
(media-dual-complex-semantics-i mode conv rhs1 rhs2 max min))
((fr400 (unit u-media-2)) (fr450 (unit u-media-2))
(fr500 (unit u-media-dual-mul)) (fr550 (unit u-media-4)))
)
)
(conditional-media-dual-complex cmcpxrs HI ext argjhi argjlo
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_75 OPE4_0
"Conditional Media dual complex real signed with saturation")
(conditional-media-dual-complex cmcpxru UHI zext argjhi argjlo
(const DI #xffffffffff) (const DI 0)
OP_75 OPE4_1
"Conditional Media dual complex real unsigned with saturation")
(conditional-media-dual-complex-i cmcpxis HI ext argjlo argjhi
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_75 OPE4_2
"Conditional Media dual complex imaginary signed with saturation")
(conditional-media-dual-complex-i cmcpxiu UHI zext argjlo argjhi
(const DI #xffffffffff) (const DI 0)
OP_75 OPE4_3
"Conditional Media dual complex imaginary unsigned with saturation")
(define-pmacro (media-quad-complex
name mode conv rhs1 rhs2 max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4))
(.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
(+ pack ACC40Sk op FRintieven ope FRintjeven)
(if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
(if (register-unaligned ACC40Sk 2)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if (orif (register-unaligned FRintieven 2)
(register-unaligned FRintjeven 2))
(c-call VOID "@cpu@_media_register_not_aligned")
(sequence ((mode argihi) (mode argilo)
(mode argjhi) (mode argjlo))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-complex-semantics conv argihi rhs1 argilo rhs2
ACC40Sk
max min (msr-sie-acci))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-complex-semantics conv argihi rhs1 argilo rhs2
(nextreg h-acc40S ACC40Sk 1)
max min (msr-sie-acci-1))))))
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr500 (unit u-media-quad-complex
(in FRinti FRintieven)
(in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
)
)
(define-pmacro (media-quad-complex-i
name mode conv rhs1 rhs2 max min op ope comment)
(dni name
(comment)
((UNIT FMALL) (FR500-MAJOR M-4) (FR550-MAJOR M-4)
(FR400-MAJOR M-2) (FR450-MAJOR M-4))
(.str name "$pack $FRintieven,$FRintjeven,$ACC40Sk")
(+ pack ACC40Sk op FRintieven ope FRintjeven)
(if (c-call SI "@cpu@_check_acc_range" (index-of ACC40Sk))
(if (register-unaligned ACC40Sk 2)
(c-call VOID "@cpu@_media_acc_not_aligned")
(if (orif (register-unaligned FRintieven 2)
(register-unaligned FRintjeven 2))
(c-call VOID "@cpu@_media_register_not_aligned")
(sequence ((mode argihi) (mode argilo)
(mode argjhi) (mode argjlo))
(extract-hilo FRintieven 0 FRintjeven 0
argihi argilo argjhi argjlo)
(media-complex-semantics-i conv argihi rhs1 argilo rhs2
ACC40Sk
max min (msr-sie-acci))
(extract-hilo FRintieven 1 FRintjeven 1
argihi argilo argjhi argjlo)
(media-complex-semantics-i conv argihi rhs1 argilo rhs2
(nextreg h-acc40S ACC40Sk 1)
max min (msr-sie-acci-1))))))
((fr400 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr450 (unit u-media-2-quad
(in FRinti FRintieven)
(in FRintj FRintjeven)))
(fr500 (unit u-media-quad-complex
(in FRinti FRintieven)
(in FRintj FRintjeven))) (fr550 (unit u-media-4-quad)))
)
)
(media-quad-complex mqcpxrs HI ext argjhi argjlo
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_24
"Media quad complex real signed with saturation")
(media-quad-complex mqcpxru UHI zext argjhi argjlo
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_25
"Media quad complex real unsigned with saturation")
(media-quad-complex-i mqcpxis HI ext argjlo argjhi
(const DI #x7fffffffff) (const DI #xffffff8000000000)
OP_7B OPE1_26
"Media quad complex imaginary signed with saturation")
(media-quad-complex-i mqcpxiu UHI zext argjlo argjhi
(const DI #xffffffffff) (const DI 0)
OP_7B OPE1_27
"Media quad complex imaginary unsigned with saturation")
(define-pmacro (media-pack src1 src2 targ offset)
(sequence ()
(set (halfword hi targ offset) (halfword lo src1 offset))
(set (halfword lo targ offset) (halfword lo src2 offset)))
)
(define-pmacro (media-expand-halfword-to-word-semantics cond)
(if cond
(sequence ((UHI tmp))
(if (and u6 1)
(set tmp (halfword lo FRinti 0))
(set tmp (halfword hi FRinti 0)))
(set (halfword hi FRintk 0) tmp)
(set (halfword lo FRintk 0) tmp)))
)
; nop
; A nop is defined to be a "ori gr0,0,gr0"
; This needn't be a macro-insn, but making it one greatly simplifies decode.c
; On the other hand spending a little time in the decoder is often worth it.
;
(dnmi nop "nop"
((UNIT IALL) (FR500-MAJOR I-1) (FR400-MAJOR I-1) (FR450-MAJOR I-1))
"nop$pack"
(emit ori pack (GRi 0) (s12 0) (GRk 0))
)