1a2e2270fSchristos; Toshiba MeP Media Engine architecture description. -*- Scheme -*- 2a2e2270fSchristos; Copyright 2011 Free Software Foundation, Inc. 3a2e2270fSchristos; 4a2e2270fSchristos; Contributed by Red Hat Inc; 5a2e2270fSchristos; 6a2e2270fSchristos; This file is part of the GNU Binutils. 7a2e2270fSchristos; 8a2e2270fSchristos; This program is free software; you can redistribute it and/or modify 9a2e2270fSchristos; it under the terms of the GNU General Public License as published by 10a2e2270fSchristos; the Free Software Foundation; either version 3 of the License, or 11a2e2270fSchristos; (at your option) any later version. 12a2e2270fSchristos; 13a2e2270fSchristos; This program is distributed in the hope that it will be useful, 14a2e2270fSchristos; but WITHOUT ANY WARRANTY; without even the implied warranty of 15a2e2270fSchristos; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16a2e2270fSchristos; GNU General Public License for more details. 17a2e2270fSchristos; 18a2e2270fSchristos; You should have received a copy of the GNU General Public License 19a2e2270fSchristos; along with this program; if not, write to the Free Software 20a2e2270fSchristos; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 21a2e2270fSchristos; MA 02110-1301, USA. 22a2e2270fSchristos 23a2e2270fSchristos(include "simplify.inc") 24a2e2270fSchristos 25a2e2270fSchristos(define-pmacro isa-enum () 26a2e2270fSchristos (isas mep 27a2e2270fSchristos; begin-isa-enum 28a2e2270fSchristos ext_core1 ext_cop1_16 ext_cop1_32 ext_cop1_48 ext_cop1_64 29a2e2270fSchristos; end-isa-enum 30a2e2270fSchristos ) 31a2e2270fSchristos) 32a2e2270fSchristos 33a2e2270fSchristos(define-arch 34a2e2270fSchristos (name mep) 35a2e2270fSchristos (comment "Toshiba MeP Media Engine") 36a2e2270fSchristos (insn-lsb0? #f) ;; work around cgen limitation 37a2e2270fSchristos (machs mep h1 c5) 38a2e2270fSchristos isa-enum 39a2e2270fSchristos) 40a2e2270fSchristos 41a2e2270fSchristos(define-isa 42a2e2270fSchristos (name mep) 43a2e2270fSchristos (comment "MeP core instruction set") 44a2e2270fSchristos (default-insn-word-bitsize 32) 45a2e2270fSchristos (default-insn-bitsize 32) 46a2e2270fSchristos (base-insn-bitsize 32) 47a2e2270fSchristos) 48a2e2270fSchristos 49a2e2270fSchristos; begin-isas 50a2e2270fSchristos(define-isa 51a2e2270fSchristos (name ext_core1) 52a2e2270fSchristos (comment "MeP core extension instruction set") 53a2e2270fSchristos (default-insn-word-bitsize 32) 54a2e2270fSchristos (default-insn-bitsize 32) 55a2e2270fSchristos (base-insn-bitsize 32) 56a2e2270fSchristos) 57a2e2270fSchristos 58a2e2270fSchristos(define-isa 59a2e2270fSchristos (name ext_cop1_16) 60a2e2270fSchristos (comment "MeP coprocessor instruction set") 61a2e2270fSchristos (default-insn-word-bitsize 32) 62a2e2270fSchristos (default-insn-bitsize 32) 63a2e2270fSchristos (base-insn-bitsize 32) 64a2e2270fSchristos) 65a2e2270fSchristos 66a2e2270fSchristos(define-isa 67a2e2270fSchristos (name ext_cop1_32) 68a2e2270fSchristos (comment "MeP coprocessor instruction set") 69a2e2270fSchristos (default-insn-word-bitsize 32) 70a2e2270fSchristos (default-insn-bitsize 32) 71a2e2270fSchristos (base-insn-bitsize 32) 72a2e2270fSchristos) 73a2e2270fSchristos 74a2e2270fSchristos(define-isa 75a2e2270fSchristos (name ext_cop1_48) 76a2e2270fSchristos (comment "MeP coprocessor instruction set") 77a2e2270fSchristos (default-insn-word-bitsize 32) 78a2e2270fSchristos (default-insn-bitsize 32) 79a2e2270fSchristos (base-insn-bitsize 32) 80a2e2270fSchristos) 81a2e2270fSchristos 82a2e2270fSchristos(define-isa 83a2e2270fSchristos (name ext_cop1_64) 84a2e2270fSchristos (comment "MeP coprocessor instruction set") 85a2e2270fSchristos (default-insn-word-bitsize 32) 86a2e2270fSchristos (default-insn-bitsize 32) 87a2e2270fSchristos (base-insn-bitsize 32) 88a2e2270fSchristos) 89a2e2270fSchristos 90a2e2270fSchristos(define-pmacro all-mep-isas () (ISA mep,ext_core1,ext_cop1_16,ext_cop1_32,ext_cop1_48,ext_cop1_64)) 91a2e2270fSchristos 92a2e2270fSchristos(define-pmacro all-mep-core-isas () (ISA mep,ext_core1,ext_cop1_32)) 93a2e2270fSchristos 94a2e2270fSchristos(define-pmacro all-core-isa-list () mep,ext_core1) 95a2e2270fSchristos; end-isas 96a2e2270fSchristos 97a2e2270fSchristos(define-cpu 98a2e2270fSchristos (name mepf) 99a2e2270fSchristos (comment "MeP family") 100a2e2270fSchristos (endian either) 101a2e2270fSchristos (insn-chunk-bitsize 16) 102a2e2270fSchristos (word-bitsize 32) 103a2e2270fSchristos) 104a2e2270fSchristos 105a2e2270fSchristos(define-mach 106a2e2270fSchristos (name mep) 107a2e2270fSchristos (comment "MeP media engine") 108a2e2270fSchristos (cpu mepf) 109a2e2270fSchristos isa-enum 110a2e2270fSchristos) 111a2e2270fSchristos 112a2e2270fSchristos(define-mach 113a2e2270fSchristos (name h1) 114a2e2270fSchristos (comment "H1 media engine") 115a2e2270fSchristos (cpu mepf) 116a2e2270fSchristos isa-enum 117a2e2270fSchristos) 118a2e2270fSchristos 119a2e2270fSchristos(define-mach 120a2e2270fSchristos (name c5) 121a2e2270fSchristos (comment "C5 media engine") 122a2e2270fSchristos (cpu mepf) 123a2e2270fSchristos isa-enum 124a2e2270fSchristos) 125a2e2270fSchristos 126a2e2270fSchristos(define-model 127a2e2270fSchristos (name mep) 128a2e2270fSchristos (comment "MeP media engine processor") 129a2e2270fSchristos (mach c5) ; mach gets changed by MeP-Integrator 130a2e2270fSchristos 131a2e2270fSchristos (unit u-exec "execution unit" () 132a2e2270fSchristos 1 1 ; issue done 133a2e2270fSchristos () () () ()) 134a2e2270fSchristos 135a2e2270fSchristos ; Branch unit 136a2e2270fSchristos (unit u-branch "Branch Unit" () 137a2e2270fSchristos 0 0 ; issue done 138a2e2270fSchristos () ; state 139a2e2270fSchristos () ; inputs 140a2e2270fSchristos ((pc)) ; outputs 141a2e2270fSchristos () ; profile action (default) 142a2e2270fSchristos ) 143a2e2270fSchristos 144a2e2270fSchristos ; Multiply unit 145a2e2270fSchristos (unit u-multiply "Multiply Unit" () 146a2e2270fSchristos 0 0 ; issue done 147a2e2270fSchristos () ; state 148a2e2270fSchristos () ; inputs 149a2e2270fSchristos () ; outputs 150a2e2270fSchristos () ; profile action (default) 151a2e2270fSchristos ) 152a2e2270fSchristos 153a2e2270fSchristos ; Divide unit 154a2e2270fSchristos (unit u-divide "Divide Unit" () 155a2e2270fSchristos 0 0 ; issue done 156a2e2270fSchristos () ; state 157a2e2270fSchristos () ; inputs 158a2e2270fSchristos () ; outputs 159a2e2270fSchristos () ; profile action (default) 160a2e2270fSchristos ) 161a2e2270fSchristos 162a2e2270fSchristos ; Stcb unit 163a2e2270fSchristos (unit u-stcb "stcb Unit" () 164a2e2270fSchristos 0 0 ; issue done 165a2e2270fSchristos () ; state 166a2e2270fSchristos () ; inputs 167a2e2270fSchristos () ; outputs 168a2e2270fSchristos () ; profile action (default) 169a2e2270fSchristos ) 170a2e2270fSchristos 171a2e2270fSchristos ; Ldcb unit 172a2e2270fSchristos (unit u-ldcb "ldcb Unit" () 173a2e2270fSchristos 0 0 ; issue done 174a2e2270fSchristos () ; state 175a2e2270fSchristos () ; inputs 176a2e2270fSchristos () ; outputs 177a2e2270fSchristos () ; profile action (default) 178a2e2270fSchristos ) 179a2e2270fSchristos 180a2e2270fSchristos ; Load gpr unit 181a2e2270fSchristos (unit u-load-gpr "Load into GPR Unit" () 182a2e2270fSchristos 0 0 ; issue done 183a2e2270fSchristos () ; state 184a2e2270fSchristos () ; inputs 185a2e2270fSchristos ((loadreg INT -1)) ; outputs 186a2e2270fSchristos () ; profile action (default) 187a2e2270fSchristos ) 188a2e2270fSchristos 189a2e2270fSchristos (unit u-ldcb-gpr "Ldcb into GPR Unit" () 190a2e2270fSchristos 0 0 ; issue done 191a2e2270fSchristos () ; state 192a2e2270fSchristos () ; inputs 193a2e2270fSchristos ((loadreg INT -1)) ; outputs 194a2e2270fSchristos () ; profile action (default) 195a2e2270fSchristos ) 196a2e2270fSchristos 197a2e2270fSchristos ; Multiply into GPR unit 198a2e2270fSchristos (unit u-mul-gpr "Multiply into GPR Unit" () 199a2e2270fSchristos 0 0 ; issue done 200a2e2270fSchristos () ; state 201a2e2270fSchristos () ; inputs 202a2e2270fSchristos ((resultreg INT -1)) ; outputs 203a2e2270fSchristos () ; profile action (default) 204a2e2270fSchristos ) 205a2e2270fSchristos 206a2e2270fSchristos ; Use gpr unit -- stalls if GPR not ready 207a2e2270fSchristos (unit u-use-gpr "Use GPR Unit" () 208a2e2270fSchristos 0 0 ; issue done 209a2e2270fSchristos () ; state 210a2e2270fSchristos ((usereg INT -1)) ; inputs 211a2e2270fSchristos () ; outputs 212a2e2270fSchristos () ; profile action (default) 213a2e2270fSchristos ) 214a2e2270fSchristos 215a2e2270fSchristos ; Use ctrl-reg unit -- stalls if CTRL-REG not ready 216a2e2270fSchristos (unit u-use-ctrl-reg "Use CTRL-REG Unit" () 217a2e2270fSchristos 0 0 ; issue done 218a2e2270fSchristos () ; state 219a2e2270fSchristos ((usereg INT -1)) ; inputs 220a2e2270fSchristos () ; outputs 221a2e2270fSchristos () ; profile action (default) 222a2e2270fSchristos ) 223a2e2270fSchristos 224a2e2270fSchristos ; Store ctrl-reg unit -- stalls if CTRL-REG not ready 225a2e2270fSchristos (unit u-store-ctrl-reg "Store CTRL-REG Unit" () 226a2e2270fSchristos 0 0 ; issue done 227a2e2270fSchristos () ; state 228a2e2270fSchristos () ; inputs 229a2e2270fSchristos ((storereg INT -1)) ; outputs 230a2e2270fSchristos () ; profile action (default) 231a2e2270fSchristos ) 232a2e2270fSchristos) 233a2e2270fSchristos 234a2e2270fSchristos; Hardware elements. 235a2e2270fSchristos 236a2e2270fSchristos(dnh h-pc "program counter" (PC PROFILE all-mep-isas) (pc) () () ()) 237a2e2270fSchristos 238a2e2270fSchristos(define-hardware 239a2e2270fSchristos (name h-gpr) 240a2e2270fSchristos (comment "General purpose registers") 241a2e2270fSchristos (attrs all-mep-isas CACHE-ADDR PROFILE) 242a2e2270fSchristos (type register SI (16)) 243a2e2270fSchristos (indices keyword "$" 244a2e2270fSchristos (("0" 0) ("1" 1) ("2" 2) ("3" 3) ("4" 4) ("5" 5) 245a2e2270fSchristos ("6" 6) ("7" 7) ("8" 8) ("9" 9) ("10" 10) ("11" 11) 246a2e2270fSchristos ; "$8" is the preferred name for register 8, but "$tp", "$gp" 247a2e2270fSchristos ; and "$sp" are preferred for their respective registers. 248a2e2270fSchristos (fp 8) (tp 13) (gp 14) (sp 15) 249a2e2270fSchristos ("12" 12) ("13" 13) ("14" 14) ("15" 15))) 250a2e2270fSchristos) 251a2e2270fSchristos 252a2e2270fSchristos(define-hardware 253a2e2270fSchristos (name h-csr) 254a2e2270fSchristos (comment "Control/special registers") 255a2e2270fSchristos (attrs all-mep-isas PROFILE) 256a2e2270fSchristos (type register SI (32)) 257a2e2270fSchristos (indices keyword "$" 258a2e2270fSchristos ((pc 0) (lp 1) (sar 2) (rpb 4) (rpe 5) (rpc 6) 259a2e2270fSchristos (hi 7) (lo 8) (mb0 12) (me0 13) (mb1 14) (me1 15) 260a2e2270fSchristos (psw 16) (id 17) (tmp 18) (epc 19) (exc 20) (cfg 21) 261a2e2270fSchristos (npc 23) (dbg 24) (depc 25) (opt 26) (rcfg 27) (ccfg 28) 262a2e2270fSchristos; begin-extra-csr-registers 263a2e2270fSchristos (vid 22) 264a2e2270fSchristos; end-extra-csr-registers 265a2e2270fSchristos )) 266a2e2270fSchristos (get (index) (c-call SI "cgen_get_csr_value" index)) 267a2e2270fSchristos (set (index newval) (c-call VOID "cgen_set_csr_value" index newval)) 268a2e2270fSchristos) 269a2e2270fSchristos 270a2e2270fSchristos(define-pmacro (-reg-pair n) ((.sym n) n)) 271a2e2270fSchristos(define-hardware 272a2e2270fSchristos (name h-cr64) 273a2e2270fSchristos (comment "64-bit coprocessor registers") 274a2e2270fSchristos (attrs all-mep-isas) 275a2e2270fSchristos ; This assumes that the data path of the co-pro is 64 bits. 276a2e2270fSchristos (type register DI (32)) 277a2e2270fSchristos (indices keyword "$c" (.map -reg-pair (.iota 32))) 278a2e2270fSchristos (set (index newval) (c-call VOID "h_cr64_queue_set" index newval)) 279a2e2270fSchristos) 280a2e2270fSchristos(define-hardware 281a2e2270fSchristos (name h-cr64-w) 282a2e2270fSchristos (comment "64-bit coprocessor registers, pending writes") 283a2e2270fSchristos (attrs all-mep-isas) 284a2e2270fSchristos ; This assumes that the data path of the co-pro is 64 bits. 285a2e2270fSchristos (type register DI (32)) 286a2e2270fSchristos) 287a2e2270fSchristos 288a2e2270fSchristos(define-hardware 289a2e2270fSchristos (name h-cr) 290a2e2270fSchristos (comment "32-bit coprocessor registers") 291a2e2270fSchristos (attrs all-mep-isas VIRTUAL) 292a2e2270fSchristos (type register SI (32)) 293a2e2270fSchristos (indices keyword "$c" (.map -reg-pair (.iota 32))) 294a2e2270fSchristos (set (index newval) (c-call VOID "h_cr64_set" index (ext DI newval))) 295a2e2270fSchristos (get (index) (trunc SI (c-call DI "h_cr64_get" index))) 296a2e2270fSchristos) 297a2e2270fSchristos 298a2e2270fSchristos;; Given a coprocessor control register number N, expand to a 299a2e2270fSchristos;; name/index pair: ($ccrN N) 300a2e2270fSchristos(define-pmacro (-ccr-reg-pair n) ((.sym "$ccr" n) n)) 301a2e2270fSchristos 302a2e2270fSchristos(define-hardware 303a2e2270fSchristos (name h-ccr) 304a2e2270fSchristos (comment "Coprocessor control registers") 305a2e2270fSchristos (attrs all-mep-isas) 306a2e2270fSchristos (type register SI (64)) 307a2e2270fSchristos (indices keyword "" (.map -ccr-reg-pair (.iota 64))) 308a2e2270fSchristos (set (index newval) (c-call VOID "h_ccr_queue_set" index newval)) 309a2e2270fSchristos) 310a2e2270fSchristos(define-hardware 311a2e2270fSchristos (name h-ccr-w) 312a2e2270fSchristos (comment "Coprocessor control registers, pending writes") 313a2e2270fSchristos (attrs all-mep-isas) 314a2e2270fSchristos (type register SI (64)) 315a2e2270fSchristos) 316a2e2270fSchristos 317a2e2270fSchristos 318a2e2270fSchristos; Instruction fields. Bit numbering reversed. 319a2e2270fSchristos 320a2e2270fSchristos; Conventions: 321a2e2270fSchristos; 322a2e2270fSchristos; N = number of bits in value 323a2e2270fSchristos; A = alignment (2 or 4, omit for 1) 324a2e2270fSchristos; B = leftmost (i.e. closest to zero) bit position 325a2e2270fSchristos; 326a2e2270fSchristos; -- Generic Fields (f-*) -- 327a2e2270fSchristos; N number of bits in *value* (1-24) 328a2e2270fSchristos; [us] signed vs unsigned 329a2e2270fSchristos; B position of left-most bit (4-16) 330a2e2270fSchristos; aA opt. alignment (2=drop 1 lsb, 4=drop 2 lsbs, etc) 331a2e2270fSchristos; n opt. for noncontiguous fields 332a2e2270fSchristos; f-foo-{hi,lo} msb/lsb parts of field f-foo 333a2e2270fSchristos; 334a2e2270fSchristos; -- Operands -- 335a2e2270fSchristos; pcrelNaA PC-relative branch target (signed) 336a2e2270fSchristos; pcabsNaA Absolute branch target (unsigned) 337a2e2270fSchristos; 338a2e2270fSchristos; [us]dispNaA [un]signed displacement 339a2e2270fSchristos; [us]immN [un]signed immediate value 340a2e2270fSchristos; addrNaA absolute address (unsigned) 341a2e2270fSchristos; 342a2e2270fSchristos; Additional prefixes may be used for special cases. 343a2e2270fSchristos 344a2e2270fSchristos(dnf f-major "major opcode" (all-mep-core-isas) 0 4) 345a2e2270fSchristos 346a2e2270fSchristos(dnf f-rn "register n" (all-mep-core-isas) 4 4) 347a2e2270fSchristos(dnf f-rn3 "register 0-7" (all-mep-core-isas) 5 3) 348a2e2270fSchristos(dnf f-rm "register m" (all-mep-core-isas) 8 4) 349a2e2270fSchristos(dnf f-rl "register l" (all-mep-core-isas) 12 4) 350a2e2270fSchristos(dnf f-sub2 "sub opcode (2 bits)" (all-mep-core-isas) 14 2) 351a2e2270fSchristos(dnf f-sub3 "sub opcode (3 bits)" (all-mep-core-isas) 13 3) 352a2e2270fSchristos(dnf f-sub4 "sub opcode (4 bits)" (all-mep-core-isas) 12 4) 353a2e2270fSchristos(dnf f-ext "extended field" (all-mep-core-isas) 16 8) 354a2e2270fSchristos(dnf f-ext4 "extended field 16:4" (all-mep-core-isas) 16 4) 355a2e2270fSchristos(dnf f-ext62 "extended field 20:2" (all-mep-core-isas) 20 2) 356a2e2270fSchristos(dnf f-crn "copro register n" (all-mep-core-isas) 4 4) 357a2e2270fSchristos 358a2e2270fSchristos(df f-csrn-hi "cr hi 1u15" (all-mep-core-isas) 15 1 UINT #f #f) 359a2e2270fSchristos(df f-csrn-lo "cr lo 4u8" (all-mep-core-isas) 8 4 UINT #f #f) 360a2e2270fSchristos(define-multi-ifield 361a2e2270fSchristos (name f-csrn) 362a2e2270fSchristos (comment "control reg") 363a2e2270fSchristos (attrs all-mep-core-isas) 364a2e2270fSchristos (mode UINT) 365a2e2270fSchristos (subfields f-csrn-hi f-csrn-lo) 366a2e2270fSchristos (insert (sequence () 367a2e2270fSchristos (set (ifield f-csrn-lo) (and (ifield f-csrn) #xf)) 368a2e2270fSchristos (set (ifield f-csrn-hi) (srl (ifield f-csrn) 4)))) 369a2e2270fSchristos (extract (set (ifield f-csrn) 370a2e2270fSchristos (or (sll (ifield f-csrn-hi) 4) (ifield f-csrn-lo)))) 371a2e2270fSchristos ) 372a2e2270fSchristos 373a2e2270fSchristos(df f-crnx-hi "crx hi 1u28" (all-mep-core-isas) 28 1 UINT #f #f) 374a2e2270fSchristos(df f-crnx-lo "crx lo 4u4" (all-mep-core-isas) 4 4 UINT #f #f) 375a2e2270fSchristos(define-multi-ifield 376a2e2270fSchristos (name f-crnx) 377a2e2270fSchristos (comment "copro register n (0-31)") 378a2e2270fSchristos (attrs all-mep-core-isas) 379a2e2270fSchristos (mode UINT) 380a2e2270fSchristos (subfields f-crnx-hi f-crnx-lo) 381a2e2270fSchristos (insert (sequence () 382a2e2270fSchristos (set (ifield f-crnx-lo) (and (ifield f-crnx) #xf)) 383a2e2270fSchristos (set (ifield f-crnx-hi) (srl (ifield f-crnx) 4)))) 384a2e2270fSchristos (extract (set (ifield f-crnx) 385a2e2270fSchristos (or (sll (ifield f-crnx-hi) 4) (ifield f-crnx-lo)))) 386a2e2270fSchristos ) 387a2e2270fSchristos 388a2e2270fSchristos; Miscellaneous fields. 389a2e2270fSchristos 390a2e2270fSchristos(define-pmacro (dnfb n) 391a2e2270fSchristos (dnf (.sym f- n) (.str "bit " n) (all-mep-isas) n 1)) 392a2e2270fSchristos 393a2e2270fSchristos; Define small fields used throughout the instruction set description. 394a2e2270fSchristos; Each field (eg. `f-N') is at single bit field at position N. 395a2e2270fSchristos 396a2e2270fSchristos(dnfb 0) 397a2e2270fSchristos(dnfb 1) 398a2e2270fSchristos(dnfb 2) 399a2e2270fSchristos(dnfb 3) 400a2e2270fSchristos(dnfb 4) 401a2e2270fSchristos(dnfb 5) 402a2e2270fSchristos(dnfb 6) 403a2e2270fSchristos(dnfb 7) 404a2e2270fSchristos(dnfb 8) 405a2e2270fSchristos(dnfb 9) 406a2e2270fSchristos(dnfb 10) 407a2e2270fSchristos(dnfb 11) 408a2e2270fSchristos(dnfb 12) 409a2e2270fSchristos(dnfb 13) 410a2e2270fSchristos(dnfb 14) 411a2e2270fSchristos(dnfb 15) 412a2e2270fSchristos(dnfb 16) 413a2e2270fSchristos(dnfb 17) 414a2e2270fSchristos(dnfb 18) 415a2e2270fSchristos(dnfb 19) 416a2e2270fSchristos(dnfb 20) 417a2e2270fSchristos(dnfb 21) 418a2e2270fSchristos(dnfb 22) 419a2e2270fSchristos(dnfb 23) 420a2e2270fSchristos(dnfb 24) 421a2e2270fSchristos(dnfb 25) 422a2e2270fSchristos(dnfb 26) 423a2e2270fSchristos(dnfb 27) 424a2e2270fSchristos(dnfb 28) 425a2e2270fSchristos(dnfb 29) 426a2e2270fSchristos(dnfb 30) 427a2e2270fSchristos(dnfb 31) 428a2e2270fSchristos 429a2e2270fSchristos; Branch/Jump target addresses 430a2e2270fSchristos 431a2e2270fSchristos(df f-8s8a2 "pc-rel addr (8 bits)" (all-mep-core-isas PCREL-ADDR) 8 7 INT 432a2e2270fSchristos ((value pc) (sra SI (sub SI value pc) 1)) 433*8dffb485Schristos ((value pc) (add SI (mul SI value 2) pc))) 434a2e2270fSchristos 435a2e2270fSchristos(df f-12s4a2 "pc-rel addr (12 bits)" (all-mep-core-isas PCREL-ADDR) 4 11 INT 436a2e2270fSchristos ((value pc) (sra SI (sub SI value pc) 1)) 437*8dffb485Schristos ((value pc) (add SI (mul SI value 2) pc))) 438a2e2270fSchristos 439a2e2270fSchristos(df f-17s16a2 "pc-rel addr (17 bits)" (all-mep-core-isas PCREL-ADDR) 16 16 INT 440a2e2270fSchristos ((value pc) (sra SI (sub SI value pc) 1)) 441*8dffb485Schristos ((value pc) (add SI (mul SI value 2) pc))) 442a2e2270fSchristos 443a2e2270fSchristos(df f-24s5a2n-hi "24s5a2n hi 16s16" (all-mep-core-isas PCREL-ADDR) 16 16 INT #f #f) 444a2e2270fSchristos(df f-24s5a2n-lo "24s5a2n lo 7s5a2" (all-mep-core-isas PCREL-ADDR) 5 7 UINT #f #f) 445a2e2270fSchristos(define-multi-ifield 446a2e2270fSchristos (name f-24s5a2n) 447a2e2270fSchristos (comment "pc-rel addr (24 bits align 2)") 448a2e2270fSchristos (attrs all-mep-core-isas PCREL-ADDR) 449a2e2270fSchristos (mode INT) 450a2e2270fSchristos (subfields f-24s5a2n-hi f-24s5a2n-lo) 451a2e2270fSchristos (insert (sequence () 452a2e2270fSchristos (set (ifield f-24s5a2n) 453a2e2270fSchristos (sub (ifield f-24s5a2n) pc)) 454a2e2270fSchristos (set (ifield f-24s5a2n-lo) 455a2e2270fSchristos (srl (and (ifield f-24s5a2n) #xfe) 1)) 456a2e2270fSchristos (set (ifield f-24s5a2n-hi) 457a2e2270fSchristos (sra INT (ifield f-24s5a2n) 8)))) 458a2e2270fSchristos (extract (set (ifield f-24s5a2n) 459*8dffb485Schristos (add SI (or (mul (ifield f-24s5a2n-hi) 256) 460a2e2270fSchristos (sll (ifield f-24s5a2n-lo) 1)) 461a2e2270fSchristos pc))) 462a2e2270fSchristos ) 463a2e2270fSchristos 464a2e2270fSchristos(df f-24u5a2n-hi "24u5a2n hi 16u16" (all-mep-core-isas) 16 16 UINT #f #f) 465a2e2270fSchristos(df f-24u5a2n-lo "24u5a2n lo 7u5a2" (all-mep-core-isas) 5 7 UINT #f #f) 466a2e2270fSchristos(define-multi-ifield 467a2e2270fSchristos (name f-24u5a2n) 468a2e2270fSchristos (comment "abs jump target (24 bits, alignment 2)") 469a2e2270fSchristos (attrs all-mep-core-isas ABS-ADDR) 470a2e2270fSchristos (mode UINT) 471a2e2270fSchristos (subfields f-24u5a2n-hi f-24u5a2n-lo) 472a2e2270fSchristos (insert (sequence () 473a2e2270fSchristos (set (ifield f-24u5a2n-lo) 474a2e2270fSchristos (srl (and (ifield f-24u5a2n) #xff) 1)) 475a2e2270fSchristos (set (ifield f-24u5a2n-hi) 476a2e2270fSchristos (srl (ifield f-24u5a2n) 8)) 477a2e2270fSchristos )) 478a2e2270fSchristos (extract (set (ifield f-24u5a2n) 479a2e2270fSchristos (or (sll (ifield f-24u5a2n-hi) 8) 480a2e2270fSchristos (sll (ifield f-24u5a2n-lo) 1)))) 481a2e2270fSchristos ) 482a2e2270fSchristos 483a2e2270fSchristos; Displacement fields. 484a2e2270fSchristos 485a2e2270fSchristos(df f-2u6 "SAR offset (2 bits)" (all-mep-core-isas) 6 2 UINT #f #f) 486a2e2270fSchristos(df f-7u9 "tp-rel b (7 bits)" (all-mep-core-isas) 9 7 UINT #f #f) 487a2e2270fSchristos(df f-7u9a2 "tp-rel h (7 bits)" (all-mep-core-isas) 9 6 UINT 488a2e2270fSchristos ((value pc) (srl SI value 1)) 489*8dffb485Schristos ((value pc) (mul SI value 2))) 490a2e2270fSchristos(df f-7u9a4 "tp/sp-rel w (7 bits)" (all-mep-core-isas) 9 5 UINT 491a2e2270fSchristos ((value pc) (srl SI value 2)) 492a2e2270fSchristos ((value pc) (sll SI value 2))) 493a2e2270fSchristos(df f-16s16 "general 16-bit s-val" (all-mep-core-isas) 16 16 INT #f #f) 494a2e2270fSchristos 495a2e2270fSchristos; Immediate fields. 496a2e2270fSchristos 497a2e2270fSchristos(df f-2u10 "swi level (2 bits)" (all-mep-core-isas) 10 2 UINT #f #f) 498a2e2270fSchristos(df f-3u5 "bit offset (3 bits)" (all-mep-core-isas) 5 3 UINT #f #f) 499a2e2270fSchristos(df f-4u8 "bCC const (4 bits)" (all-mep-core-isas) 8 4 UINT #f #f) 500a2e2270fSchristos(df f-5u8 "slt & shifts (5 bits)" (all-mep-core-isas) 8 5 UINT #f #f) 501a2e2270fSchristos(df f-5u24 "clip immediate (5 bits)" (all-mep-core-isas) 24 5 UINT #f #f) 502a2e2270fSchristos(df f-6s8 "add immediate (6 bits)" (all-mep-core-isas) 8 6 INT #f #f) 503a2e2270fSchristos(df f-8s8 "add imm (8 bits)" (all-mep-core-isas) 8 8 INT #f #f) 504a2e2270fSchristos(df f-16u16 "general 16-bit u-val" (all-mep-core-isas) 16 16 UINT #f #f) 505a2e2270fSchristos(df f-12u16 "cmov fixed 1" (all-mep-core-isas) 16 12 UINT #f #f) 506a2e2270fSchristos(df f-3u29 "cmov fixed 2" (all-mep-core-isas) 29 3 UINT #f #f) 507a2e2270fSchristos 508a2e2270fSchristos 509a2e2270fSchristos; These are all for the coprocessor opcodes 510a2e2270fSchristos 511a2e2270fSchristos; The field is like IJKiiiiiii where I and J are toggled if K is set, 512a2e2270fSchristos; for compatibility with older cores. 513a2e2270fSchristos(define-pmacro (compute-cdisp10 val) 514a2e2270fSchristos (cond SI 515a2e2270fSchristos ((and SI (cond SI ((and SI val #x80) (xor SI val #x300)) (else val)) #x200) 516a2e2270fSchristos (sub (cond SI ((and SI val #x80) (xor SI val #x300)) (else val)) #x400)) 517a2e2270fSchristos (else 518a2e2270fSchristos (cond SI ((and SI val #x80) (xor SI val #x300)) (else val))) 519a2e2270fSchristos ) 520a2e2270fSchristos ) 521a2e2270fSchristos(define-pmacro (extend-cdisp10 val) 522a2e2270fSchristos (cond SI 523a2e2270fSchristos ((and SI (compute-cdisp10 val) #x200) 524a2e2270fSchristos (sub (and SI (compute-cdisp10 val) #x3ff) #x400)) 525a2e2270fSchristos (else 526a2e2270fSchristos (and SI (compute-cdisp10 val) #x3ff)) 527a2e2270fSchristos ) 528a2e2270fSchristos ) 529a2e2270fSchristos 530a2e2270fSchristos(df f-cdisp10 "cop imm10" (all-mep-core-isas) 22 10 INT 531a2e2270fSchristos ((value pc) (extend-cdisp10 value)) 532a2e2270fSchristos ((value pc) (extend-cdisp10 value)) 533a2e2270fSchristos ) 534a2e2270fSchristos 535a2e2270fSchristos; Non-contiguous fields. 536a2e2270fSchristos 537a2e2270fSchristos(df f-24u8a4n-hi "24u8a4n hi 16u16" (all-mep-core-isas) 16 16 UINT #f #f) 538a2e2270fSchristos(df f-24u8a4n-lo "24u8a4n lo 8u8a4" (all-mep-core-isas) 8 6 UINT #f #f) 539a2e2270fSchristos(define-multi-ifield 540a2e2270fSchristos (name f-24u8a4n) 541a2e2270fSchristos (comment "absolute 24-bit address") 542a2e2270fSchristos (attrs all-mep-core-isas) 543a2e2270fSchristos (mode UINT) 544a2e2270fSchristos (subfields f-24u8a4n-hi f-24u8a4n-lo) 545a2e2270fSchristos (insert (sequence () 546a2e2270fSchristos (set (ifield f-24u8a4n-hi) (srl (ifield f-24u8a4n) 8)) 547a2e2270fSchristos (set (ifield f-24u8a4n-lo) (srl (and (ifield f-24u8a4n) #xfc) 2)))) 548a2e2270fSchristos (extract (set (ifield f-24u8a4n) 549a2e2270fSchristos (or (sll (ifield f-24u8a4n-hi) 8) 550a2e2270fSchristos (sll (ifield f-24u8a4n-lo) 2)))) 551a2e2270fSchristos ) 552a2e2270fSchristos 553a2e2270fSchristos(df f-24u8n-hi "24u8n hi 16u16" (all-mep-core-isas) 16 16 UINT #f #f) 554a2e2270fSchristos(df f-24u8n-lo "24u8n lo 8u8" (all-mep-core-isas) 8 8 UINT #f #f) 555a2e2270fSchristos(define-multi-ifield 556a2e2270fSchristos (name f-24u8n) 557a2e2270fSchristos (comment "24-bit constant") 558a2e2270fSchristos (attrs all-mep-core-isas) 559a2e2270fSchristos (mode UINT) 560a2e2270fSchristos (subfields f-24u8n-hi f-24u8n-lo) 561a2e2270fSchristos (insert (sequence () 562a2e2270fSchristos (set (ifield f-24u8n-hi) (srl (ifield f-24u8n) 8)) 563a2e2270fSchristos (set (ifield f-24u8n-lo) (and (ifield f-24u8n) #xff)))) 564a2e2270fSchristos (extract (set (ifield f-24u8n) 565a2e2270fSchristos (or (sll (ifield f-24u8n-hi) 8) 566a2e2270fSchristos (ifield f-24u8n-lo)))) 567a2e2270fSchristos ) 568a2e2270fSchristos 569a2e2270fSchristos(df f-24u4n-hi "24u4n hi 8u4" (all-mep-core-isas) 4 8 UINT #f #f) 570a2e2270fSchristos(df f-24u4n-lo "24u4n lo 16u16" (all-mep-core-isas) 16 16 UINT #f #f) 571a2e2270fSchristos(define-multi-ifield 572a2e2270fSchristos (name f-24u4n) 573a2e2270fSchristos (comment "coprocessor code") 574a2e2270fSchristos (attrs all-mep-core-isas) 575a2e2270fSchristos (mode UINT) 576a2e2270fSchristos (subfields f-24u4n-hi f-24u4n-lo) 577a2e2270fSchristos (insert (sequence () 578a2e2270fSchristos (set (ifield f-24u4n-hi) (srl (ifield f-24u4n) 16)) 579a2e2270fSchristos (set (ifield f-24u4n-lo) (and (ifield f-24u4n) #xffff)))) 580a2e2270fSchristos (extract (set (ifield f-24u4n) 581a2e2270fSchristos (or (sll (ifield f-24u4n-hi) 16) 582a2e2270fSchristos (ifield f-24u4n-lo)))) 583a2e2270fSchristos ) 584a2e2270fSchristos 585a2e2270fSchristos(define-multi-ifield 586a2e2270fSchristos (name f-callnum) 587a2e2270fSchristos (comment "system call number field") 588a2e2270fSchristos (attrs all-mep-core-isas) 589a2e2270fSchristos (mode UINT) 590a2e2270fSchristos (subfields f-5 f-6 f-7 f-11) 591a2e2270fSchristos (insert (sequence () 592a2e2270fSchristos (set (ifield f-5) (and (srl (ifield f-callnum) 3) 1)) 593a2e2270fSchristos (set (ifield f-6) (and (srl (ifield f-callnum) 2) 1)) 594a2e2270fSchristos (set (ifield f-7) (and (srl (ifield f-callnum) 1) 1)) 595a2e2270fSchristos (set (ifield f-11) (and (ifield f-callnum) 1)))) 596a2e2270fSchristos (extract (set (ifield f-callnum) 597a2e2270fSchristos (or (sll (ifield f-5) 3) 598a2e2270fSchristos (or (sll (ifield f-6) 2) 599a2e2270fSchristos (or (sll (ifield f-7) 1) 600a2e2270fSchristos (ifield f-11)))))) 601a2e2270fSchristos ) 602a2e2270fSchristos 603a2e2270fSchristos(df f-ccrn-hi "ccrn hi 2u28" (all-mep-core-isas) 28 2 UINT #f #f) 604a2e2270fSchristos(df f-ccrn-lo "ccrn lo 4u4" (all-mep-core-isas) 4 4 UINT #f #f) 605a2e2270fSchristos(define-multi-ifield 606a2e2270fSchristos (name f-ccrn) 607a2e2270fSchristos (comment "Coprocessor register number field") 608a2e2270fSchristos (attrs all-mep-core-isas) 609a2e2270fSchristos (mode UINT) 610a2e2270fSchristos (subfields f-ccrn-hi f-ccrn-lo) 611a2e2270fSchristos (insert (sequence () 612a2e2270fSchristos (set (ifield f-ccrn-hi) (and (srl (ifield f-ccrn) 4) #x3)) 613a2e2270fSchristos (set (ifield f-ccrn-lo) (and (ifield f-ccrn) #xf)))) 614a2e2270fSchristos (extract (set (ifield f-ccrn) 615a2e2270fSchristos (or (sll (ifield f-ccrn-hi) 4) 616a2e2270fSchristos (ifield f-ccrn-lo)))) 617a2e2270fSchristos ) 618a2e2270fSchristos 619a2e2270fSchristos; Operands. 620a2e2270fSchristos 621a2e2270fSchristos;; Only LABEL, REGNUM, FMAX_FLOAT and FMAX_INT are now relevant for correct 622a2e2270fSchristos;; operation. The others are mostly kept for backwards compatibility, 623a2e2270fSchristos;; although they do affect the dummy prototypes in 624a2e2270fSchristos;; gcc/config/mep/intrinsics.h. 625a2e2270fSchristos(define-attr 626a2e2270fSchristos (type enum) 627a2e2270fSchristos (for operand) 628a2e2270fSchristos (name CDATA) 629a2e2270fSchristos (comment "datatype to use for C intrinsics mapping") 630a2e2270fSchristos (values LABEL REGNUM FMAX_FLOAT FMAX_INT 631a2e2270fSchristos POINTER LONG ULONG SHORT USHORT CHAR UCHAR CP_DATA_BUS_INT) 632a2e2270fSchristos (default LONG)) 633a2e2270fSchristos 634a2e2270fSchristos(define-attr 635a2e2270fSchristos (type enum) 636a2e2270fSchristos (for insn) 637a2e2270fSchristos (name CPTYPE) 638a2e2270fSchristos (comment "datatype to use for coprocessor values") 639a2e2270fSchristos (values CP_DATA_BUS_INT VECT V2SI V4HI V8QI V2USI V4UHI V8UQI) 640a2e2270fSchristos (default CP_DATA_BUS_INT)) 641a2e2270fSchristos 642a2e2270fSchristos(define-attr 643a2e2270fSchristos (type enum) 644a2e2270fSchristos (for insn) 645a2e2270fSchristos (name CRET) 646a2e2270fSchristos ;; VOID - all arguments are passed as parameters; if any are written, pointers to them are passed. 647a2e2270fSchristos ;; FIRST - the first argument is the return value. 648a2e2270fSchristos ;; FIRSTCOPY - the first argument is the return value, but a copy is also the first parameter. 649a2e2270fSchristos (values VOID FIRST FIRSTCOPY) 650a2e2270fSchristos (default VOID) 651a2e2270fSchristos (comment "Insn's intrinsic returns void, or the first argument rather than (or in addition to) passing it.")) 652a2e2270fSchristos 653a2e2270fSchristos(define-attr 654a2e2270fSchristos (type integer) 655a2e2270fSchristos (for operand) 656a2e2270fSchristos (name ALIGN) 657a2e2270fSchristos (comment "alignment of immediate operands") 658a2e2270fSchristos (default 1)) 659a2e2270fSchristos 660a2e2270fSchristos(define-attr 661a2e2270fSchristos (for operand) 662a2e2270fSchristos (type boolean) 663a2e2270fSchristos (name RELOC_IMPLIES_OVERFLOW) 664a2e2270fSchristos (comment "Operand should not be considered as a candidate for relocs")) 665a2e2270fSchristos 666a2e2270fSchristos(define-attr 667a2e2270fSchristos (for hardware) 668a2e2270fSchristos (type boolean) 669a2e2270fSchristos (name IS_FLOAT) 670a2e2270fSchristos (comment "Register contains a floating point value")) 671a2e2270fSchristos 672a2e2270fSchristos(define-pmacro (dpop name commment attrib hwr field func) 673a2e2270fSchristos (define-full-operand name comment attrib 674a2e2270fSchristos hwr DFLT field ((parse func)) () ())) 675a2e2270fSchristos(define-pmacro (dprp name commment attrib hwr field pafunc prfunc) 676a2e2270fSchristos (define-full-operand name comment attrib 677a2e2270fSchristos hwr DFLT field ((parse pafunc) (print prfunc)) () ())) 678a2e2270fSchristos 679a2e2270fSchristos(dnop r0 "register 0" (all-mep-core-isas) h-gpr 0) 680a2e2270fSchristos(dnop rn "register Rn" (all-mep-core-isas) h-gpr f-rn) 681a2e2270fSchristos(dnop rm "register Rm" (all-mep-core-isas) h-gpr f-rm) 682a2e2270fSchristos(dnop rl "register Rl" (all-mep-core-isas) h-gpr f-rl) 683a2e2270fSchristos(dnop rn3 "register 0-7" (all-mep-core-isas) h-gpr f-rn3) 684a2e2270fSchristos 685a2e2270fSchristos;; Variants of RM/RN with different CDATA attributes. See comment above 686a2e2270fSchristos;; CDATA for more details. 687a2e2270fSchristos 688a2e2270fSchristos(dnop rma "register Rm holding pointer" (all-mep-core-isas (CDATA POINTER)) h-gpr f-rm) 689a2e2270fSchristos 690a2e2270fSchristos(dnop rnc "register Rn holding char" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn) 691a2e2270fSchristos(dnop rnuc "register Rn holding unsigned char" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn) 692a2e2270fSchristos(dnop rns "register Rn holding short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn) 693a2e2270fSchristos(dnop rnus "register Rn holding unsigned short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn) 694a2e2270fSchristos(dnop rnl "register Rn holding long" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn) 695a2e2270fSchristos(dnop rnul "register Rn holding unsigned long" (all-mep-core-isas (CDATA ULONG)) h-gpr f-rn) 696a2e2270fSchristos 697a2e2270fSchristos(dnop rn3c "register 0-7 holding unsigned char" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3) 698a2e2270fSchristos(dnop rn3uc "register 0-7 holding byte" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3) 699a2e2270fSchristos(dnop rn3s "register 0-7 holding unsigned short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3) 700a2e2270fSchristos(dnop rn3us "register 0-7 holding short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3) 701a2e2270fSchristos(dnop rn3l "register 0-7 holding unsigned long" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3) 702a2e2270fSchristos(dnop rn3ul "register 0-7 holding long" (all-mep-core-isas (CDATA ULONG)) h-gpr f-rn3) 703a2e2270fSchristos 704a2e2270fSchristos 705a2e2270fSchristos(dnop lp "link pointer" (all-mep-core-isas) h-csr 1) 706a2e2270fSchristos(dnop sar "shift amount register" (all-mep-core-isas) h-csr 2) 707a2e2270fSchristos(dnop hi "high result" (all-mep-core-isas) h-csr 7) 708a2e2270fSchristos(dnop lo "low result" (all-mep-core-isas) h-csr 8) 709a2e2270fSchristos(dnop mb0 "modulo begin register 0" (all-mep-core-isas) h-csr 12) 710a2e2270fSchristos(dnop me0 "modulo end register 0" (all-mep-core-isas) h-csr 13) 711a2e2270fSchristos(dnop mb1 "modulo begin register 1" (all-mep-core-isas) h-csr 14) 712a2e2270fSchristos(dnop me1 "modulo end register 1" (all-mep-core-isas) h-csr 15) 713a2e2270fSchristos(dnop psw "program status word" (all-mep-core-isas) h-csr 16) 714a2e2270fSchristos(dnop epc "exception prog counter" (all-mep-core-isas) h-csr 19) 715a2e2270fSchristos(dnop exc "exception cause" (all-mep-core-isas) h-csr 20) 716a2e2270fSchristos(dnop npc "nmi program counter" (all-mep-core-isas) h-csr 23) 717a2e2270fSchristos(dnop dbg "debug register" (all-mep-core-isas) h-csr 24) 718a2e2270fSchristos(dnop depc "debug exception pc" (all-mep-core-isas) h-csr 25) 719a2e2270fSchristos(dnop opt "option register" (all-mep-core-isas) h-csr 26) 720a2e2270fSchristos(dnop r1 "register 1" (all-mep-core-isas) h-gpr 1) 721a2e2270fSchristos(dnop tp "tiny data area pointer" (all-mep-core-isas) h-gpr 13) 722a2e2270fSchristos(dnop sp "stack pointer" (all-mep-core-isas) h-gpr 15) 723a2e2270fSchristos(dprp tpr "TP register" (all-mep-core-isas) h-gpr 13 "tpreg" "tpreg") 724a2e2270fSchristos(dprp spr "SP register" (all-mep-core-isas) h-gpr 15 "spreg" "spreg") 725a2e2270fSchristos 726a2e2270fSchristos(define-full-operand 727a2e2270fSchristos csrn "control/special register" (all-mep-core-isas (CDATA REGNUM)) h-csr 728a2e2270fSchristos DFLT f-csrn ((parse "csrn")) () () 729a2e2270fSchristos) 730a2e2270fSchristos 731a2e2270fSchristos(dnop csrn-idx "control/special reg idx" (all-mep-core-isas) h-uint f-csrn) 732a2e2270fSchristos(dnop crn64 "copro Rn (64-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr64 f-crn) 733a2e2270fSchristos(dnop crn "copro Rn (32-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr f-crn) 734a2e2270fSchristos(dnop crnx64 "copro Rn (0-31, 64-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr64 f-crnx) 735a2e2270fSchristos(dnop crnx "copro Rn (0-31, 32-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr f-crnx) 736a2e2270fSchristos(dnop ccrn "copro control reg CCRn" (all-mep-core-isas (CDATA REGNUM)) h-ccr f-ccrn) 737a2e2270fSchristos(dnop cccc "copro flags" (all-mep-core-isas) h-uint f-rm) 738a2e2270fSchristos 739a2e2270fSchristos(dprp pcrel8a2 "pc-rel addr (8 bits)" (all-mep-core-isas (CDATA LABEL) RELAX) h-sint f-8s8a2 "mep_align" "address") 740a2e2270fSchristos(dprp pcrel12a2 "pc-rel addr (12 bits)" (all-mep-core-isas (CDATA LABEL) RELAX) h-sint f-12s4a2 "mep_align" "address") 741a2e2270fSchristos(dprp pcrel17a2 "pc-rel addr (17 bits)" (all-mep-core-isas (CDATA LABEL) RELAX) h-sint f-17s16a2 "mep_align" "address") 742a2e2270fSchristos(dprp pcrel24a2 "pc-rel addr (24 bits)" (all-mep-core-isas (CDATA LABEL)) h-sint f-24s5a2n "mep_align" "address") 743a2e2270fSchristos(dprp pcabs24a2 "pc-abs addr (24 bits)" (all-mep-core-isas (CDATA LABEL)) h-uint f-24u5a2n "mep_alignu" "address") 744a2e2270fSchristos 745a2e2270fSchristos(dpop sdisp16 "displacement (16 bits)" (all-mep-core-isas) h-sint f-16s16 "signed16") 746a2e2270fSchristos(dpop simm16 "signed imm (16 bits)" (all-mep-core-isas) h-sint f-16s16 "signed16") 747a2e2270fSchristos(dpop uimm16 "unsigned imm (16 bits)" (all-mep-core-isas) h-uint f-16u16 "unsigned16") 748a2e2270fSchristos(dnop code16 "uci/dsp code (16 bits)" (all-mep-core-isas) h-uint f-16u16) 749a2e2270fSchristos 750a2e2270fSchristos(dnop udisp2 "SSARB addend (2 bits)" (all-mep-core-isas) h-sint f-2u6) 751a2e2270fSchristos(dnop uimm2 "interrupt (2 bits)" (all-mep-core-isas) h-uint f-2u10) 752a2e2270fSchristos 753a2e2270fSchristos(dnop simm6 "add const (6 bits)" (all-mep-core-isas) h-sint f-6s8) 754a2e2270fSchristos(dnop simm8 "mov const (8 bits)" (all-mep-core-isas RELOC_IMPLIES_OVERFLOW) 755a2e2270fSchristos h-sint f-8s8) 756a2e2270fSchristos 757a2e2270fSchristos(dpop addr24a4 "sw/lw addr (24 bits)" (all-mep-core-isas (ALIGN 4)) h-uint f-24u8a4n "mep_alignu") 758a2e2270fSchristos(dnop code24 "coprocessor code" (all-mep-core-isas) h-uint f-24u4n) 759a2e2270fSchristos 760a2e2270fSchristos(dnop callnum "system call number" (all-mep-core-isas) h-uint f-callnum) 761a2e2270fSchristos(dnop uimm3 "bit immediate (3 bits)" (all-mep-core-isas) h-uint f-3u5) 762a2e2270fSchristos(dnop uimm4 "bCC const (4 bits)" (all-mep-core-isas) h-uint f-4u8) 763a2e2270fSchristos(dnop uimm5 "bit/shift val (5 bits)" (all-mep-core-isas) h-uint f-5u8) 764a2e2270fSchristos 765a2e2270fSchristos(dpop udisp7 "tp-rel b (7 bits)" (all-mep-core-isas) h-uint f-7u9 "unsigned7") 766a2e2270fSchristos(dpop udisp7a2 "tp-rel h (7 bits)" (all-mep-core-isas (ALIGN 2)) h-uint f-7u9a2 "unsigned7") 767a2e2270fSchristos(dpop udisp7a4 "tp/sp-rel w (7 bits)" (all-mep-core-isas (ALIGN 4)) h-uint f-7u9a4 "unsigned7") 768a2e2270fSchristos(dpop uimm7a4 "sp w-addend (7 bits)" (all-mep-core-isas (ALIGN 4)) h-uint f-7u9a4 "mep_alignu") 769a2e2270fSchristos 770a2e2270fSchristos(dnop uimm24 "immediate (24 bits)" (all-mep-core-isas) h-uint f-24u8n) 771a2e2270fSchristos 772a2e2270fSchristos(dnop cimm4 "cache immed'te (4 bits)" (all-mep-core-isas) h-uint f-rn) 773a2e2270fSchristos(dnop cimm5 "clip immediate (5 bits)" (all-mep-core-isas) h-uint f-5u24) 774a2e2270fSchristos 775a2e2270fSchristos(dpop cdisp10 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10") 776a2e2270fSchristos(dpop cdisp10a2 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10") 777a2e2270fSchristos(dpop cdisp10a4 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10") 778a2e2270fSchristos(dpop cdisp10a8 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10") 779a2e2270fSchristos 780a2e2270fSchristos; Special operand representing the various ways that the literal zero can be 781a2e2270fSchristos; specified. 782a2e2270fSchristos(define-full-operand 783a2e2270fSchristos zero "Zero operand" (all-mep-core-isas) h-sint DFLT f-nil 784a2e2270fSchristos ((parse "zero")) () () 785a2e2270fSchristos) 786a2e2270fSchristos 787a2e2270fSchristos; Attributes. 788a2e2270fSchristos 789a2e2270fSchristos(define-attr 790a2e2270fSchristos (for insn) 791a2e2270fSchristos (type boolean) 792a2e2270fSchristos (name OPTIONAL_BIT_INSN) 793a2e2270fSchristos (comment "optional bit manipulation instruction")) 794a2e2270fSchristos 795a2e2270fSchristos(define-attr 796a2e2270fSchristos (for insn) 797a2e2270fSchristos (type boolean) 798a2e2270fSchristos (name OPTIONAL_MUL_INSN) 799a2e2270fSchristos (comment "optional 32-bit multiply instruction")) 800a2e2270fSchristos 801a2e2270fSchristos(define-attr 802a2e2270fSchristos (for insn) 803a2e2270fSchristos (type boolean) 804a2e2270fSchristos (name OPTIONAL_DIV_INSN) 805a2e2270fSchristos (comment "optional 32-bit divide instruction")) 806a2e2270fSchristos 807a2e2270fSchristos(define-attr 808a2e2270fSchristos (for insn) 809a2e2270fSchristos (type boolean) 810a2e2270fSchristos (name OPTIONAL_DEBUG_INSN) 811a2e2270fSchristos (comment "optional debug instruction")) 812a2e2270fSchristos 813a2e2270fSchristos(define-attr 814a2e2270fSchristos (for insn) 815a2e2270fSchristos (type boolean) 816a2e2270fSchristos (name OPTIONAL_LDZ_INSN) 817a2e2270fSchristos (comment "optional leading zeroes instruction")) 818a2e2270fSchristos 819a2e2270fSchristos(define-attr 820a2e2270fSchristos (for insn) 821a2e2270fSchristos (type boolean) 822a2e2270fSchristos (name OPTIONAL_ABS_INSN) 823a2e2270fSchristos (comment "optional absolute difference instruction")) 824a2e2270fSchristos 825a2e2270fSchristos(define-attr 826a2e2270fSchristos (for insn) 827a2e2270fSchristos (type boolean) 828a2e2270fSchristos (name OPTIONAL_AVE_INSN) 829a2e2270fSchristos (comment "optional average instruction")) 830a2e2270fSchristos 831a2e2270fSchristos(define-attr 832a2e2270fSchristos (for insn) 833a2e2270fSchristos (type boolean) 834a2e2270fSchristos (name OPTIONAL_MINMAX_INSN) 835a2e2270fSchristos (comment "optional min/max instruction")) 836a2e2270fSchristos 837a2e2270fSchristos(define-attr 838a2e2270fSchristos (for insn) 839a2e2270fSchristos (type boolean) 840a2e2270fSchristos (name OPTIONAL_CLIP_INSN) 841a2e2270fSchristos (comment "optional clipping instruction")) 842a2e2270fSchristos 843a2e2270fSchristos(define-attr 844a2e2270fSchristos (for insn) 845a2e2270fSchristos (type boolean) 846a2e2270fSchristos (name OPTIONAL_SAT_INSN) 847a2e2270fSchristos (comment "optional saturation instruction")) 848a2e2270fSchristos 849a2e2270fSchristos(define-attr 850a2e2270fSchristos (for insn) 851a2e2270fSchristos (type boolean) 852a2e2270fSchristos (name OPTIONAL_UCI_INSN) 853a2e2270fSchristos (comment "optional UCI instruction")) 854a2e2270fSchristos 855a2e2270fSchristos(define-attr 856a2e2270fSchristos (for insn) 857a2e2270fSchristos (type boolean) 858a2e2270fSchristos (name OPTIONAL_DSP_INSN) 859a2e2270fSchristos (comment "optional DSP instruction")) 860a2e2270fSchristos 861a2e2270fSchristos(define-attr 862a2e2270fSchristos (for insn) 863a2e2270fSchristos (type boolean) 864a2e2270fSchristos (name OPTIONAL_CP_INSN) 865a2e2270fSchristos (comment "optional coprocessor-related instruction")) 866a2e2270fSchristos 867a2e2270fSchristos(define-attr 868a2e2270fSchristos (for insn) 869a2e2270fSchristos (type boolean) 870a2e2270fSchristos (name OPTIONAL_CP64_INSN) 871a2e2270fSchristos (comment "optional coprocessor-related 64 data bit instruction")) 872a2e2270fSchristos 873a2e2270fSchristos(define-attr 874a2e2270fSchristos (for insn) 875a2e2270fSchristos (type boolean) 876a2e2270fSchristos (name OPTIONAL_VLIW64) 877a2e2270fSchristos (comment "optional vliw64 mode (vliw32 is default)")) 878a2e2270fSchristos 879a2e2270fSchristos(define-attr 880a2e2270fSchristos (for insn) 881a2e2270fSchristos (type enum) 882a2e2270fSchristos (name STALL) 883a2e2270fSchristos (attrs META) 884a2e2270fSchristos (values NONE SHIFTI INT2 LOAD STORE LDC STC LDCB STCB SSARB FSFT RET 885a2e2270fSchristos ADVCK MUL MULR DIV) 886a2e2270fSchristos (default NONE) 887a2e2270fSchristos (comment "gcc stall attribute")) 888a2e2270fSchristos 889a2e2270fSchristos(define-attr 890a2e2270fSchristos (for insn) 891a2e2270fSchristos (type string) 892a2e2270fSchristos (name INTRINSIC) 893a2e2270fSchristos (attrs META) 894a2e2270fSchristos (comment "gcc intrinsic name")) 895a2e2270fSchristos 896a2e2270fSchristos(define-attr 897a2e2270fSchristos (for insn) 898a2e2270fSchristos (type enum) 899a2e2270fSchristos (name SLOT) 900a2e2270fSchristos (attrs META) 901a2e2270fSchristos (values NONE C3 V1 V3 P0S P0 P1) 902a2e2270fSchristos (default NONE) 903a2e2270fSchristos (comment "coprocessor slot type")) 904a2e2270fSchristos 905a2e2270fSchristos(define-attr 906a2e2270fSchristos (for insn) 907a2e2270fSchristos (type boolean) 908a2e2270fSchristos (name MAY_TRAP) 909a2e2270fSchristos (comment "instruction may generate an exception")) 910a2e2270fSchristos 911a2e2270fSchristos; Attributes for scheduling restrictions in vliw mode 912a2e2270fSchristos 913a2e2270fSchristos(define-attr 914a2e2270fSchristos (for insn) 915a2e2270fSchristos (type boolean) 916a2e2270fSchristos (name VLIW_ALONE) 917a2e2270fSchristos (comment "instruction can be scheduled alone in vliw mode")) 918a2e2270fSchristos 919a2e2270fSchristos(define-attr 920a2e2270fSchristos (for insn) 921a2e2270fSchristos (type boolean) 922a2e2270fSchristos (name VLIW_NO_CORE_NOP) 923a2e2270fSchristos (comment "there is no corresponding nop core instruction")) 924a2e2270fSchristos 925a2e2270fSchristos(define-attr 926a2e2270fSchristos (for insn) 927a2e2270fSchristos (type boolean) 928a2e2270fSchristos (name VLIW_NO_COP_NOP) 929a2e2270fSchristos (comment "there is no corresponding nop coprocessor instruction")) 930a2e2270fSchristos 931a2e2270fSchristos(define-attr 932a2e2270fSchristos (for insn) 933a2e2270fSchristos (type boolean) 934a2e2270fSchristos (name VLIW64_NO_MATCHING_NOP) 935a2e2270fSchristos (comment "there is no corresponding nop coprocessor instruction")) 936a2e2270fSchristos(define-attr 937a2e2270fSchristos (for insn) 938a2e2270fSchristos (type boolean) 939a2e2270fSchristos (name VLIW32_NO_MATCHING_NOP) 940a2e2270fSchristos (comment "there is no corresponding nop coprocessor instruction")) 941a2e2270fSchristos 942a2e2270fSchristos(define-attr 943a2e2270fSchristos (for insn) 944a2e2270fSchristos (type boolean) 945a2e2270fSchristos (name VOLATILE) 946a2e2270fSchristos (comment "Insn is volatile.")) 947a2e2270fSchristos 948a2e2270fSchristos(define-attr 949a2e2270fSchristos (for insn) 950a2e2270fSchristos (type integer) 951a2e2270fSchristos (name LATENCY) 952a2e2270fSchristos (comment "The latency of this insn, used for scheduling as an intrinsic in gcc") 953a2e2270fSchristos (default 0)) 954a2e2270fSchristos 955a2e2270fSchristos; The MeP config tool will edit this. 956a2e2270fSchristos(define-attr 957a2e2270fSchristos (type enum) 958a2e2270fSchristos (for insn) 959a2e2270fSchristos (name CONFIG) 960a2e2270fSchristos (values NONE ; config-attr-start 961a2e2270fSchristos default 962a2e2270fSchristos ) ; config-attr-end 963a2e2270fSchristos) 964a2e2270fSchristos 965a2e2270fSchristos 966a2e2270fSchristos; Enumerations. 967a2e2270fSchristos 968a2e2270fSchristos(define-normal-insn-enum major "major opcodes" (all-mep-core-isas) MAJ_ 969a2e2270fSchristos f-major 970a2e2270fSchristos (.map .str (.iota 16)) 971a2e2270fSchristos) 972a2e2270fSchristos 973a2e2270fSchristos 974a2e2270fSchristos(define-pmacro (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming isa) 975a2e2270fSchristos (define-insn 976a2e2270fSchristos (name xname) 977a2e2270fSchristos (comment xcomment) 978a2e2270fSchristos (.splice attrs (.unsplice xattrs) (ISA isa)) 979a2e2270fSchristos (syntax xsyntax) 980a2e2270fSchristos (format xformat) 981a2e2270fSchristos (semantics xsemantics) 982a2e2270fSchristos (.splice timing (.unsplice xtiming)) 983a2e2270fSchristos ) 984a2e2270fSchristos) 985a2e2270fSchristos 986a2e2270fSchristos(define-pmacro (dnmi-isa xname xcomment xattrs xsyntax xemit isa) 987a2e2270fSchristos (dnmi xname xcomment (.splice (.unsplice xattrs) (ISA isa)) xsyntax xemit) 988a2e2270fSchristos) 989a2e2270fSchristos 990a2e2270fSchristos; For making profiling calls and dynamic configuration 991a2e2270fSchristos(define-pmacro (cg-profile caller callee) 992a2e2270fSchristos (c-call "cg_profile" caller callee) 993a2e2270fSchristos) 994a2e2270fSchristos; For dynamic configuration only 995a2e2270fSchristos(define-pmacro (cg-profile-jump caller callee) 996a2e2270fSchristos (c-call "cg_profile_jump" caller callee) 997a2e2270fSchristos) 998a2e2270fSchristos 999a2e2270fSchristos; For defining Core Instructions 1000a2e2270fSchristos(define-pmacro (dnci xname xcomment xattrs xsyntax xformat xsemantics xtiming) 1001a2e2270fSchristos (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming all-core-isa-list) 1002a2e2270fSchristos) 1003a2e2270fSchristos(define-pmacro (dncmi xname xcomment xattrs xsyntax xemit) 1004a2e2270fSchristos (dnmi-isa xname xcomment xattrs xsyntax xemit all-core-isa-list) 1005a2e2270fSchristos) 1006a2e2270fSchristos 1007a2e2270fSchristos; For defining Coprocessor Instructions 1008a2e2270fSchristos;(define-pmacro (dncpi xname xcomment xattrs xsyntax xformat xsemantics xtiming) (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming cop) 1009a2e2270fSchristos;) 1010a2e2270fSchristos 1011a2e2270fSchristos;; flag setting macro 1012a2e2270fSchristos(define-pmacro (set-bit xop xbitnum xval) 1013a2e2270fSchristos (set xop (or 1014a2e2270fSchristos (and xop (inv (sll 1 xbitnum))) 1015a2e2270fSchristos (and (sll 1 xbitnum) (sll xval xbitnum))))) 1016a2e2270fSchristos 1017a2e2270fSchristos;; some flags we commonly use in vliw reasoning / mode-switching etc. 1018a2e2270fSchristos(define-pmacro (get-opt.vliw64) (and (srl opt 6) 1)) 1019a2e2270fSchristos(define-pmacro (get-opt.vliw32) (and (srl opt 5) 1)) 1020a2e2270fSchristos(define-pmacro (get-rm.lsb) (and rm 1)) 1021a2e2270fSchristos(define-pmacro (get-psw.om) (and (srl psw 12) 1)) 1022a2e2270fSchristos(define-pmacro (get-psw.nmi) (and (srl psw 9) 1)) 1023a2e2270fSchristos(define-pmacro (get-psw.iep) (and (srl psw 1) 1)) 1024a2e2270fSchristos(define-pmacro (get-psw.ump) (and (srl psw 3) 1)) 1025a2e2270fSchristos(define-pmacro (get-epc.etom) (and epc 1)) 1026a2e2270fSchristos(define-pmacro (get-npc.ntom) (and npc 1)) 1027a2e2270fSchristos(define-pmacro (get-lp.ltom) (and lp 1)) 1028a2e2270fSchristos 1029a2e2270fSchristos(define-pmacro (set-psw.om zval) (set-bit (raw-reg h-csr 16) 12 zval)) 1030a2e2270fSchristos(define-pmacro (set-psw.nmi zval) (set-bit (raw-reg h-csr 16) 9 zval)) 1031a2e2270fSchristos(define-pmacro (set-psw.umc zval) (set-bit (raw-reg h-csr 16) 2 zval)) 1032a2e2270fSchristos(define-pmacro (set-psw.iec zval) (set-bit (raw-reg h-csr 16) 0 zval)) 1033a2e2270fSchristos(define-pmacro (set-rpe.elr zval) (set-bit (raw-reg h-csr 5) 0 zval)) 1034a2e2270fSchristos 1035a2e2270fSchristos 1036a2e2270fSchristos;; the "3 way switch" depending on our current operating mode and vliw status flags 1037a2e2270fSchristos(define-pmacro (core-vliw-switch core-rtl vliw32-rtl vliw64-rtl) 1038a2e2270fSchristos (cond 1039a2e2270fSchristos ((andif (get-psw.om) (get-opt.vliw64)) vliw64-rtl) 1040a2e2270fSchristos ((andif (get-psw.om) (get-opt.vliw32)) vliw32-rtl) 1041a2e2270fSchristos (else core-rtl))) 1042a2e2270fSchristos 1043a2e2270fSchristos;; the varying-pcrel idiom 1044a2e2270fSchristos(define-pmacro (set-vliw-modified-pcrel-offset xtarg xa xb xc) 1045a2e2270fSchristos (core-vliw-switch (set xtarg (add pc xa)) 1046a2e2270fSchristos (set xtarg (add pc xb)) 1047a2e2270fSchristos (set xtarg (add pc xc)))) 1048a2e2270fSchristos 1049a2e2270fSchristos;; the increasing-alignment idiom in branch displacements 1050a2e2270fSchristos(define-pmacro (set-vliw-alignment-modified xtarg zaddr) 1051a2e2270fSchristos (core-vliw-switch (set xtarg (and zaddr (inv 1))) 1052a2e2270fSchristos (set xtarg (and zaddr (inv 3))) 1053a2e2270fSchristos (set xtarg (and zaddr (inv 7))))) 1054a2e2270fSchristos 1055a2e2270fSchristos;; the increasing-alignment idiom in option-only form 1056a2e2270fSchristos(define-pmacro (set-vliw-aliignment-modified-by-option xtarg zaddr) 1057a2e2270fSchristos (if (get-opt.vliw32) 1058a2e2270fSchristos (set xtarg (and zaddr (inv 3))) 1059a2e2270fSchristos (set xtarg (and zaddr (inv 7))))) 1060a2e2270fSchristos 1061a2e2270fSchristos 1062a2e2270fSchristos 1063a2e2270fSchristos; pmacros needed for coprocessor modulo addressing. 1064a2e2270fSchristos 1065a2e2270fSchristos; Taken from supplement ``The operation of the modulo addressing'' in 1066a2e2270fSchristos; Toshiba documentation rev 2.2, p. 34. 1067a2e2270fSchristos 1068a2e2270fSchristos(define-pmacro (compute-mask0) 1069a2e2270fSchristos (sequence SI ((SI temp)) 1070a2e2270fSchristos (set temp (or mb0 me0)) 1071a2e2270fSchristos (srl (const SI -1) (c-call SI "do_ldz" temp)))) 1072a2e2270fSchristos 1073a2e2270fSchristos(define-pmacro (mod0 immed) 1074a2e2270fSchristos (sequence SI ((SI modulo-mask)) 1075a2e2270fSchristos (set modulo-mask (compute-mask0)) 1076a2e2270fSchristos (if SI (eq (and rma modulo-mask) me0) 1077a2e2270fSchristos (or (and rma (inv modulo-mask)) mb0) 1078a2e2270fSchristos (add rma (ext SI immed))))) 1079a2e2270fSchristos 1080a2e2270fSchristos(define-pmacro (compute-mask1) 1081a2e2270fSchristos (sequence SI ((SI temp)) 1082a2e2270fSchristos (set temp (or mb1 me1)) 1083a2e2270fSchristos (srl (const SI -1) (c-call SI "do_ldz" temp)))) 1084a2e2270fSchristos 1085a2e2270fSchristos(define-pmacro (mod1 immed) 1086a2e2270fSchristos (sequence SI ((SI modulo-mask)) 1087a2e2270fSchristos (set modulo-mask (compute-mask1)) 1088a2e2270fSchristos (if SI (eq (and rma modulo-mask) me1) 1089a2e2270fSchristos (or (and rma (inv modulo-mask)) mb1) 1090a2e2270fSchristos (add rma (ext SI immed))))) 1091a2e2270fSchristos 1092a2e2270fSchristos 1093a2e2270fSchristos; Instructions. 1094a2e2270fSchristos 1095a2e2270fSchristos; A pmacro for use in semantic bodies of unimplemented insns. 1096a2e2270fSchristos(define-pmacro (unimp mnemonic) (nop)) 1097a2e2270fSchristos 1098a2e2270fSchristos; Core specific instructions 1099a2e2270fSchristos; (include "mep-h1.cpu") ; -- exposed by MeP-Integrator 1100a2e2270fSchristos(include "mep-c5.cpu") ; -- exposed by MeP-Integrator 1101a2e2270fSchristos 1102a2e2270fSchristos; Load/store instructions. 1103a2e2270fSchristos 1104a2e2270fSchristos(dnci sb "store byte (register indirect)" ((STALL STORE)) 1105a2e2270fSchristos "sb $rnc,($rma)" 1106a2e2270fSchristos (+ MAJ_0 rnc rma (f-sub4 8)) 1107a2e2270fSchristos (sequence () 1108a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 1109a2e2270fSchristos (set (mem UQI rma) (and rnc #xff))) 1110a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rnc)) 1111a2e2270fSchristos (unit u-use-gpr (in usereg rma)) 1112a2e2270fSchristos (unit u-exec)))) 1113a2e2270fSchristos 1114a2e2270fSchristos(dnci sh "store half-word (register indirect)" ((STALL STORE)) 1115a2e2270fSchristos "sh $rns,($rma)" 1116a2e2270fSchristos (+ MAJ_0 rns rma (f-sub4 9)) 1117a2e2270fSchristos (sequence () 1118a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv 1))) 1119a2e2270fSchristos (set (mem UHI (and rma (inv 1))) (and rns #xffff))) 1120a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rns)) 1121a2e2270fSchristos (unit u-use-gpr (in usereg rma)) 1122a2e2270fSchristos (unit u-exec)))) 1123a2e2270fSchristos 1124a2e2270fSchristos(dnci sw "store word (register indirect)" ((STALL STORE)) 1125a2e2270fSchristos "sw $rnl,($rma)" 1126a2e2270fSchristos (+ MAJ_0 rnl rma (f-sub4 10)) 1127a2e2270fSchristos (sequence () 1128a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv 3))) 1129a2e2270fSchristos (set (mem USI (and rma (inv 3))) rnl)) 1130a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rnl)) 1131a2e2270fSchristos (unit u-use-gpr (in usereg rma)) 1132a2e2270fSchristos (unit u-exec)))) 1133a2e2270fSchristos 1134a2e2270fSchristos(dnci lb "load byte (register indirect)" ((STALL LOAD) (LATENCY 2)) 1135a2e2270fSchristos "lb $rnc,($rma)" 1136a2e2270fSchristos (+ MAJ_0 rnc rma (f-sub4 12)) 1137a2e2270fSchristos (set rnc (ext SI (mem QI rma))) 1138a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1139a2e2270fSchristos (unit u-exec) 1140a2e2270fSchristos (unit u-load-gpr (out loadreg rnc))))) 1141a2e2270fSchristos 1142a2e2270fSchristos(dnci lh "load half-word (register indirect)" ((STALL LOAD) (LATENCY 2)) 1143a2e2270fSchristos "lh $rns,($rma)" 1144a2e2270fSchristos (+ MAJ_0 rns rma (f-sub4 13)) 1145a2e2270fSchristos (set rns (ext SI (mem HI (and rma (inv 1))))) 1146a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1147a2e2270fSchristos (unit u-exec) 1148a2e2270fSchristos (unit u-load-gpr (out loadreg rns))))) 1149a2e2270fSchristos 1150a2e2270fSchristos(dnci lw "load word (register indirect)" ((STALL LOAD) (LATENCY 2)) 1151a2e2270fSchristos "lw $rnl,($rma)" 1152a2e2270fSchristos (+ MAJ_0 rnl rma (f-sub4 14)) 1153a2e2270fSchristos (set rnl (mem SI (and rma (inv 3)))) 1154a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1155a2e2270fSchristos (unit u-exec) 1156a2e2270fSchristos (unit u-load-gpr (out loadreg rnl))))) 1157a2e2270fSchristos 1158a2e2270fSchristos(dnci lbu "load unsigned byte (register indirect)" ((STALL LOAD) (LATENCY 2)) 1159a2e2270fSchristos "lbu $rnuc,($rma)" 1160a2e2270fSchristos (+ MAJ_0 rnuc rma (f-sub4 11)) 1161a2e2270fSchristos (set rnuc (zext SI (mem UQI rma))) 1162a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1163a2e2270fSchristos (unit u-exec) 1164a2e2270fSchristos (unit u-load-gpr (out loadreg rnuc))))) 1165a2e2270fSchristos 1166a2e2270fSchristos(dnci lhu "load unsigned half-word (register indirect)" ((STALL LOAD) (LATENCY 2)) 1167a2e2270fSchristos "lhu $rnus,($rma)" 1168a2e2270fSchristos (+ MAJ_0 rnus rma (f-sub4 15)) 1169a2e2270fSchristos (set rnus (zext SI (mem UHI (and rma (inv 1))))) 1170a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1171a2e2270fSchristos (unit u-exec) 1172a2e2270fSchristos (unit u-load-gpr (out loadreg rnus))))) 1173a2e2270fSchristos 1174a2e2270fSchristos(dnci sw-sp "store word (sp relative)" ((STALL STORE)) 1175a2e2270fSchristos "sw $rnl,$udisp7a4($spr)" 1176a2e2270fSchristos (+ MAJ_4 rnl (f-8 0) udisp7a4 (f-sub2 2)) 1177a2e2270fSchristos (sequence () 1178a2e2270fSchristos (c-call VOID "check_write_to_text" (and (add udisp7a4 sp) (inv 3))) 1179a2e2270fSchristos (set (mem SI (and (add udisp7a4 sp) (inv 3))) rnl)) 1180a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rnl)) 1181a2e2270fSchristos (unit u-use-gpr (in usereg sp)) 1182a2e2270fSchristos (unit u-exec)))) 1183a2e2270fSchristos 1184a2e2270fSchristos 1185a2e2270fSchristos(dnci lw-sp "load word (sp relative)" ((STALL LOAD) (LATENCY 2)) 1186a2e2270fSchristos "lw $rnl,$udisp7a4($spr)" 1187a2e2270fSchristos (+ MAJ_4 rnl (f-8 0) udisp7a4 (f-sub2 3)) 1188a2e2270fSchristos (set rnl (mem SI (and (add udisp7a4 sp) (inv 3)))) 1189a2e2270fSchristos ((mep (unit u-use-gpr (in usereg sp)) 1190a2e2270fSchristos (unit u-exec) 1191a2e2270fSchristos (unit u-load-gpr (out loadreg rnl))))) 1192a2e2270fSchristos 1193a2e2270fSchristos(dnci sb-tp "store byte (tp relative)" ((STALL STORE)) 1194a2e2270fSchristos "sb $rn3c,$udisp7($tpr)" 1195a2e2270fSchristos (+ MAJ_8 (f-4 0) rn3c (f-8 0) udisp7) 1196a2e2270fSchristos (sequence () 1197a2e2270fSchristos (c-call VOID "check_write_to_text" (add (zext SI udisp7) tp)) 1198a2e2270fSchristos (set (mem QI (add (zext SI udisp7) tp)) (and rn3c #xff))) 1199a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn3c)) 1200a2e2270fSchristos (unit u-use-gpr (in usereg tp)) 1201a2e2270fSchristos (unit u-exec)))) 1202a2e2270fSchristos 1203a2e2270fSchristos(dnci sh-tp "store half-word (tp relative)" ((STALL STORE)) 1204a2e2270fSchristos "sh $rn3s,$udisp7a2($tpr)" 1205a2e2270fSchristos (+ MAJ_8 (f-4 0) rn3s (f-8 1) udisp7a2 (f-15 0)) 1206a2e2270fSchristos (sequence () 1207a2e2270fSchristos (c-call VOID "check_write_to_text" (and (add (zext SI udisp7a2) tp) (inv 1))) 1208a2e2270fSchristos (set (mem HI (and (add (zext SI udisp7a2) tp) (inv 1))) (and rn3s #xffff))) 1209a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn3s)) 1210a2e2270fSchristos (unit u-use-gpr (in usereg tp)) 1211a2e2270fSchristos (unit u-exec)))) 1212a2e2270fSchristos 1213a2e2270fSchristos(dnci sw-tp "store word (tp relative)" ((STALL STORE)) 1214a2e2270fSchristos "sw $rn3l,$udisp7a4($tpr)" 1215a2e2270fSchristos (+ MAJ_4 (f-4 0) rn3l (f-8 1) udisp7a4 (f-sub2 2)) 1216a2e2270fSchristos (sequence () 1217a2e2270fSchristos (c-call VOID "check_write_to_text" (and (add (zext SI udisp7a4) tp) (inv 3))) 1218a2e2270fSchristos (set (mem SI (and (add (zext SI udisp7a4) tp) (inv 3))) rn3l)) 1219a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn3l)) 1220a2e2270fSchristos (unit u-use-gpr (in usereg tp)) 1221a2e2270fSchristos (unit u-exec)))) 1222a2e2270fSchristos 1223a2e2270fSchristos(dnci lb-tp "load byte (tp relative)" ((STALL LOAD) (LATENCY 2)) 1224a2e2270fSchristos "lb $rn3c,$udisp7($tpr)" 1225a2e2270fSchristos (+ MAJ_8 (f-4 1) rn3c (f-8 0) udisp7) 1226a2e2270fSchristos (set rn3c (ext SI (mem QI (add (zext SI udisp7) tp)))) 1227a2e2270fSchristos ((mep (unit u-use-gpr (in usereg tp)) 1228a2e2270fSchristos (unit u-exec) 1229a2e2270fSchristos (unit u-load-gpr (out loadreg rn3c))))) 1230a2e2270fSchristos 1231a2e2270fSchristos(dnci lh-tp "load half-word (tp relative)" ((STALL LOAD) (LATENCY 2)) 1232a2e2270fSchristos "lh $rn3s,$udisp7a2($tpr)" 1233a2e2270fSchristos (+ MAJ_8 (f-4 1) rn3s (f-8 1) udisp7a2 (f-15 0)) 1234a2e2270fSchristos (set rn3s (ext SI (mem HI (and (add (zext SI udisp7a2) tp) (inv 1))))) 1235a2e2270fSchristos ((mep (unit u-use-gpr (in usereg tp)) 1236a2e2270fSchristos (unit u-exec) 1237a2e2270fSchristos (unit u-load-gpr (out loadreg rn3s))))) 1238a2e2270fSchristos 1239a2e2270fSchristos(dnci lw-tp "load word (tp relative)" ((STALL LOAD) (LATENCY 2)) 1240a2e2270fSchristos "lw $rn3l,$udisp7a4($tpr)" 1241a2e2270fSchristos (+ MAJ_4 (f-4 0) rn3l (f-8 1) udisp7a4 (f-sub2 3)) 1242a2e2270fSchristos (set rn3l (mem SI (and (add (zext SI udisp7a4) tp) (inv 3)))) 1243a2e2270fSchristos ((mep (unit u-use-gpr (in usereg tp)) 1244a2e2270fSchristos (unit u-exec) 1245a2e2270fSchristos (unit u-load-gpr (out loadreg rn3l))))) 1246a2e2270fSchristos 1247a2e2270fSchristos(dnci lbu-tp "load unsigned byte (tp relative)" ((STALL LOAD) (LATENCY 2)) 1248a2e2270fSchristos "lbu $rn3uc,$udisp7($tpr)" 1249a2e2270fSchristos (+ MAJ_4 (f-4 1) rn3uc (f-8 1) udisp7) 1250a2e2270fSchristos (set rn3uc (zext SI (mem QI (add (zext SI udisp7) tp)))) 1251a2e2270fSchristos ((mep (unit u-use-gpr (in usereg tp)) 1252a2e2270fSchristos (unit u-exec) 1253a2e2270fSchristos (unit u-load-gpr (out loadreg rn3uc))))) 1254a2e2270fSchristos 1255a2e2270fSchristos(dnci lhu-tp "load unsigned half-word (tp relative)" ((STALL LOAD) (LATENCY 2)) 1256a2e2270fSchristos "lhu $rn3us,$udisp7a2($tpr)" 1257a2e2270fSchristos (+ MAJ_8 (f-4 1) rn3us (f-8 1) udisp7a2 (f-15 1)) 1258a2e2270fSchristos (set rn3us (zext SI (mem HI (and (add (zext SI udisp7a2) tp) (inv 1))))) 1259a2e2270fSchristos ((mep (unit u-use-gpr (in usereg tp)) 1260a2e2270fSchristos (unit u-exec) 1261a2e2270fSchristos (unit u-load-gpr (out loadreg rn3us))))) 1262a2e2270fSchristos 1263a2e2270fSchristos(dnci sb16 "store byte (16 bit displacement)" ((STALL STORE)) 1264a2e2270fSchristos "sb $rnc,$sdisp16($rma)" 1265a2e2270fSchristos (+ MAJ_12 rnc rma (f-sub4 8) sdisp16) 1266a2e2270fSchristos (sequence () 1267a2e2270fSchristos (c-call VOID "check_write_to_text" (add rma (ext SI sdisp16))) 1268a2e2270fSchristos (set (mem QI (add rma (ext SI sdisp16))) (and rnc #xff))) 1269a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rnc)) 1270a2e2270fSchristos (unit u-use-gpr (in usereg rma)) 1271a2e2270fSchristos (unit u-exec)))) 1272a2e2270fSchristos 1273a2e2270fSchristos(dnci sh16 "store half-word (16 bit displacement)" ((STALL STORE)) 1274a2e2270fSchristos "sh $rns,$sdisp16($rma)" 1275a2e2270fSchristos (+ MAJ_12 rns rma (f-sub4 9) sdisp16) 1276a2e2270fSchristos (sequence () 1277a2e2270fSchristos (c-call VOID "check_write_to_text" (and (add rma (ext SI sdisp16)) (inv 1))) 1278a2e2270fSchristos (set (mem HI (and (add rma (ext SI sdisp16)) (inv 1))) (and rns #xffff))) 1279a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rns)) 1280a2e2270fSchristos (unit u-use-gpr (in usereg rma)) 1281a2e2270fSchristos (unit u-exec)))) 1282a2e2270fSchristos 1283a2e2270fSchristos(dnci sw16 "store word (16 bit displacement)" ((STALL STORE)) 1284a2e2270fSchristos "sw $rnl,$sdisp16($rma)" 1285a2e2270fSchristos (+ MAJ_12 rnl rma (f-sub4 10) sdisp16) 1286a2e2270fSchristos (sequence () 1287a2e2270fSchristos (c-call "check_write_to_text" (and (add rma (ext SI sdisp16)) (inv 3))) 1288a2e2270fSchristos (set (mem SI (and (add rma (ext SI sdisp16)) (inv 3))) rnl)) 1289a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rnl)) 1290a2e2270fSchristos (unit u-use-gpr (in usereg rma)) 1291a2e2270fSchristos (unit u-exec)))) 1292a2e2270fSchristos 1293a2e2270fSchristos(dnci lb16 "load byte (16 bit displacement)" ((STALL LOAD) (LATENCY 2)) 1294a2e2270fSchristos "lb $rnc,$sdisp16($rma)" 1295a2e2270fSchristos (+ MAJ_12 rnc rma (f-sub4 12) sdisp16) 1296a2e2270fSchristos (set rnc (ext SI (mem QI (add rma (ext SI sdisp16))))) 1297a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1298a2e2270fSchristos (unit u-exec) 1299a2e2270fSchristos (unit u-load-gpr (out loadreg rnc))))) 1300a2e2270fSchristos 1301a2e2270fSchristos(dnci lh16 "load half-word (16 bit displacement)" ((STALL LOAD) (LATENCY 2)) 1302a2e2270fSchristos "lh $rns,$sdisp16($rma)" 1303a2e2270fSchristos (+ MAJ_12 rns rma (f-sub4 13) sdisp16) 1304a2e2270fSchristos (set rns (ext SI (mem HI (and (add rma (ext SI sdisp16)) (inv 1))))) 1305a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1306a2e2270fSchristos (unit u-exec) 1307a2e2270fSchristos (unit u-load-gpr (out loadreg rns))))) 1308a2e2270fSchristos 1309a2e2270fSchristos(dnci lw16 "load word (16 bit displacement)" ((STALL LOAD) (LATENCY 2)) 1310a2e2270fSchristos "lw $rnl,$sdisp16($rma)" 1311a2e2270fSchristos (+ MAJ_12 rnl rma (f-sub4 14) sdisp16) 1312a2e2270fSchristos (set rnl (mem SI (and (add rma (ext SI sdisp16)) (inv 3)))) 1313a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1314a2e2270fSchristos (unit u-exec) 1315a2e2270fSchristos (unit u-load-gpr (out loadreg rnl))))) 1316a2e2270fSchristos 1317a2e2270fSchristos(dnci lbu16 "load unsigned byte (16 bit displacement)" ((STALL LOAD) (LATENCY 2)) 1318a2e2270fSchristos "lbu $rnuc,$sdisp16($rma)" 1319a2e2270fSchristos (+ MAJ_12 rnuc rma (f-sub4 11) sdisp16) 1320a2e2270fSchristos (set rnuc (zext SI (mem QI (add rma (ext SI sdisp16))))) 1321a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1322a2e2270fSchristos (unit u-exec) 1323a2e2270fSchristos (unit u-load-gpr (out loadreg rnuc))))) 1324a2e2270fSchristos 1325a2e2270fSchristos(dnci lhu16 "load unsigned half-word (16 bit displacement)" ((STALL LOAD) (LATENCY 2)) 1326a2e2270fSchristos "lhu $rnus,$sdisp16($rma)" 1327a2e2270fSchristos (+ MAJ_12 rnus rma (f-sub4 15) sdisp16) 1328a2e2270fSchristos (set rnus (zext SI (mem HI (and (add rma (ext SI sdisp16)) (inv 1))))) 1329a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 1330a2e2270fSchristos (unit u-exec) 1331a2e2270fSchristos (unit u-load-gpr (out loadreg rnus))))) 1332a2e2270fSchristos 1333a2e2270fSchristos(dnci sw24 "store word (24 bit absolute addressing)" ((STALL STORE)) 1334a2e2270fSchristos "sw $rnl,($addr24a4)" 1335a2e2270fSchristos (+ MAJ_14 rnl addr24a4 (f-sub2 2)) 1336a2e2270fSchristos (sequence () 1337a2e2270fSchristos (c-call VOID "check_write_to_text" (zext SI addr24a4)) 1338a2e2270fSchristos (set (mem SI (zext SI addr24a4)) rnl)) 1339a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rnl)) 1340a2e2270fSchristos (unit u-exec)))) 1341a2e2270fSchristos 1342a2e2270fSchristos(dnci lw24 "load word (24 bit absolute addressing)" ((STALL LOAD) (LATENCY 2)) 1343a2e2270fSchristos "lw $rnl,($addr24a4)" 1344a2e2270fSchristos (+ MAJ_14 rnl addr24a4 (f-sub2 3)) 1345a2e2270fSchristos (set rnl (mem SI (zext SI addr24a4))) 1346a2e2270fSchristos ((mep (unit u-exec) 1347a2e2270fSchristos (unit u-load-gpr (out loadreg rnl))))) 1348a2e2270fSchristos 1349a2e2270fSchristos 1350a2e2270fSchristos; Extension instructions. 1351a2e2270fSchristos 1352a2e2270fSchristos(dnci extb "sign extend byte" () 1353a2e2270fSchristos "extb $rn" 1354a2e2270fSchristos (+ MAJ_1 rn (f-rm 0) (f-sub4 13)) 1355a2e2270fSchristos (set rn (ext SI (and QI rn #xff))) 1356a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1357a2e2270fSchristos (unit u-exec)))) 1358a2e2270fSchristos 1359a2e2270fSchristos(dnci exth "sign extend half-word" () 1360a2e2270fSchristos "exth $rn" 1361a2e2270fSchristos (+ MAJ_1 rn (f-rm 2) (f-sub4 13)) 1362a2e2270fSchristos (set rn (ext SI (and HI rn #xffff))) 1363a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1364a2e2270fSchristos (unit u-exec)))) 1365a2e2270fSchristos 1366a2e2270fSchristos(dnci extub "zero extend byte" () 1367a2e2270fSchristos "extub $rn" 1368a2e2270fSchristos (+ MAJ_1 rn (f-rm 8) (f-sub4 13)) 1369a2e2270fSchristos (set rn (zext SI (and rn #xff))) 1370a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1371a2e2270fSchristos (unit u-exec)))) 1372a2e2270fSchristos 1373a2e2270fSchristos(dnci extuh "zero extend half-word" () 1374a2e2270fSchristos "extuh $rn" 1375a2e2270fSchristos (+ MAJ_1 rn (f-rm 10) (f-sub4 13)) 1376a2e2270fSchristos (set rn (zext SI (and rn #xffff))) 1377a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1378a2e2270fSchristos (unit u-exec)))) 1379a2e2270fSchristos 1380a2e2270fSchristos 1381a2e2270fSchristos; Shift amount manipulation instructions. 1382a2e2270fSchristos 1383a2e2270fSchristos(dnci ssarb "set sar to bytes" ((STALL SSARB) VOLATILE) 1384a2e2270fSchristos "ssarb $udisp2($rm)" 1385a2e2270fSchristos (+ MAJ_1 (f-4 0) (f-5 0) udisp2 rm (f-sub4 12)) 1386a2e2270fSchristos (if (c-call BI "big_endian_p") 1387a2e2270fSchristos (set sar (zext SI (mul (and (add udisp2 rm) 3) 8))) 1388a2e2270fSchristos (set sar (sub 32 (zext SI (mul (and (add udisp2 rm) 3) 8))))) 1389a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1390a2e2270fSchristos (unit u-exec)))) 1391a2e2270fSchristos 1392a2e2270fSchristos 1393a2e2270fSchristos; Move instructions. 1394a2e2270fSchristos 1395a2e2270fSchristos(dnci mov "move" () 1396a2e2270fSchristos "mov $rn,$rm" 1397a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 0)) 1398a2e2270fSchristos (set rn rm) 1399a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1400a2e2270fSchristos (unit u-exec)))) 1401a2e2270fSchristos 1402a2e2270fSchristos(dnci movi8 "move 8-bit immediate" () 1403a2e2270fSchristos "mov $rn,$simm8" 1404a2e2270fSchristos (+ MAJ_5 rn simm8) 1405a2e2270fSchristos (set rn (ext SI simm8)) 1406a2e2270fSchristos ()) 1407a2e2270fSchristos 1408a2e2270fSchristos(dnci movi16 "move 16-bit immediate" () 1409a2e2270fSchristos "mov $rn,$simm16" 1410a2e2270fSchristos (+ MAJ_12 rn (f-rm 0) (f-sub4 1) simm16) 1411a2e2270fSchristos (set rn (ext SI simm16)) 1412a2e2270fSchristos ()) 1413a2e2270fSchristos 1414a2e2270fSchristos(dnci movu24 "move 24-bit unsigned immediate" () 1415a2e2270fSchristos "movu $rn3,$uimm24" 1416a2e2270fSchristos (+ MAJ_13 (f-4 0) rn3 uimm24) 1417a2e2270fSchristos (set rn3 (zext SI uimm24)) 1418a2e2270fSchristos ()) 1419a2e2270fSchristos 1420a2e2270fSchristos(dnci movu16 "move 16-bit unsigned immediate" () 1421a2e2270fSchristos "movu $rn,$uimm16" 1422a2e2270fSchristos (+ MAJ_12 rn (f-rm 1) (f-sub4 1) uimm16) 1423a2e2270fSchristos (set rn (zext SI uimm16)) 1424a2e2270fSchristos ()) 1425a2e2270fSchristos 1426a2e2270fSchristos(dnci movh "move high 16-bit immediate" () 1427a2e2270fSchristos "movh $rn,$uimm16" 1428a2e2270fSchristos (+ MAJ_12 rn (f-rm 2) (f-sub4 1) uimm16) 1429a2e2270fSchristos (set rn (sll uimm16 16)) 1430a2e2270fSchristos ()) 1431a2e2270fSchristos 1432a2e2270fSchristos 1433a2e2270fSchristos; Arithmetic instructions. 1434a2e2270fSchristos 1435a2e2270fSchristos(dnci add3 "add three registers" () 1436a2e2270fSchristos "add3 $rl,$rn,$rm" 1437a2e2270fSchristos (+ MAJ_9 rn rm rl) 1438a2e2270fSchristos (set rl (add rn rm)) 1439a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1440a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1441a2e2270fSchristos (unit u-exec)))) 1442a2e2270fSchristos 1443a2e2270fSchristos(dnci add "add" () 1444a2e2270fSchristos "add $rn,$simm6" 1445a2e2270fSchristos (+ MAJ_6 rn simm6 (f-sub2 0)) 1446a2e2270fSchristos (set rn (add rn (ext SI simm6))) 1447a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1448a2e2270fSchristos (unit u-exec)))) 1449a2e2270fSchristos 1450a2e2270fSchristos(dnci add3i "add two registers and immediate" () 1451a2e2270fSchristos "add3 $rn,$spr,$uimm7a4" 1452a2e2270fSchristos (+ MAJ_4 rn (f-8 0) uimm7a4 (f-sub2 0)) 1453a2e2270fSchristos (set rn (add sp (zext SI uimm7a4))) 1454a2e2270fSchristos ((mep (unit u-use-gpr (in usereg sp)) 1455a2e2270fSchristos (unit u-exec)))) 1456a2e2270fSchristos 1457a2e2270fSchristos(dnci advck3 "add overflow check" ((STALL ADVCK)) 1458a2e2270fSchristos "advck3 \\$0,$rn,$rm" 1459a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 7)) 1460a2e2270fSchristos (if (add-oflag rn rm 0) 1461a2e2270fSchristos (set r0 1) 1462a2e2270fSchristos (set r0 0)) 1463a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1464a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1465a2e2270fSchristos (unit u-exec)))) 1466a2e2270fSchristos 1467a2e2270fSchristos(dnci sub "subtract" () 1468a2e2270fSchristos "sub $rn,$rm" 1469a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 4)) 1470a2e2270fSchristos (set rn (sub rn rm)) 1471a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1472a2e2270fSchristos (unit u-use-gpr (in usereg rm))))) 1473a2e2270fSchristos 1474a2e2270fSchristos(dnci sbvck3 "subtraction overflow check" ((STALL ADVCK)) 1475a2e2270fSchristos "sbvck3 \\$0,$rn,$rm" 1476a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 5)) 1477a2e2270fSchristos (if (sub-oflag rn rm 0) 1478a2e2270fSchristos (set r0 1) 1479a2e2270fSchristos (set r0 0)) 1480a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1481a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1482a2e2270fSchristos (unit u-exec)))) 1483a2e2270fSchristos 1484a2e2270fSchristos(dnci neg "negate" () 1485a2e2270fSchristos "neg $rn,$rm" 1486a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 1)) 1487a2e2270fSchristos (set rn (neg rm)) 1488a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1489a2e2270fSchristos (unit u-exec)))) 1490a2e2270fSchristos 1491a2e2270fSchristos(dnci slt3 "set if less than" () 1492a2e2270fSchristos "slt3 \\$0,$rn,$rm" 1493a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 2)) 1494a2e2270fSchristos (if (lt rn rm) 1495a2e2270fSchristos (set r0 1) 1496a2e2270fSchristos (set r0 0)) 1497a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1498a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1499a2e2270fSchristos (unit u-exec)))) 1500a2e2270fSchristos 1501a2e2270fSchristos(dnci sltu3 "set less than unsigned" () 1502a2e2270fSchristos "sltu3 \\$0,$rn,$rm" 1503a2e2270fSchristos (+ MAJ_0 rn rm (f-sub4 3)) 1504a2e2270fSchristos (if (ltu rn rm) 1505a2e2270fSchristos (set r0 1) 1506a2e2270fSchristos (set r0 0)) 1507a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1508a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1509a2e2270fSchristos (unit u-exec)))) 1510a2e2270fSchristos 1511a2e2270fSchristos(dnci slt3i "set if less than immediate" () 1512a2e2270fSchristos "slt3 \\$0,$rn,$uimm5" 1513a2e2270fSchristos (+ MAJ_6 rn uimm5 (f-sub3 1)) 1514a2e2270fSchristos (if (lt rn (zext SI uimm5)) 1515a2e2270fSchristos (set r0 1) 1516a2e2270fSchristos (set r0 0)) 1517a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1518a2e2270fSchristos (unit u-exec)))) 1519a2e2270fSchristos 1520a2e2270fSchristos(dnci sltu3i "set if less than unsigned immediate" () 1521a2e2270fSchristos "sltu3 \\$0,$rn,$uimm5" 1522a2e2270fSchristos (+ MAJ_6 rn uimm5 (f-sub3 5)) 1523a2e2270fSchristos (if (ltu rn (zext SI uimm5)) 1524a2e2270fSchristos (set r0 1) 1525a2e2270fSchristos (set r0 0)) 1526a2e2270fSchristos ()) 1527a2e2270fSchristos 1528a2e2270fSchristos(dnci sl1ad3 "shift left one and add" ((STALL INT2)) 1529a2e2270fSchristos "sl1ad3 \\$0,$rn,$rm" 1530a2e2270fSchristos (+ MAJ_2 rn rm (f-sub4 6)) 1531a2e2270fSchristos (set r0 (add (sll rn 1) rm)) 1532a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1533a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1534a2e2270fSchristos (unit u-exec)))) 1535a2e2270fSchristos 1536a2e2270fSchristos(dnci sl2ad3 "shift left two and add" ((STALL INT2)) 1537a2e2270fSchristos "sl2ad3 \\$0,$rn,$rm" 1538a2e2270fSchristos (+ MAJ_2 rn rm (f-sub4 7)) 1539a2e2270fSchristos (set r0 (add (sll rn 2) rm)) 1540a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1541a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1542a2e2270fSchristos (unit u-exec)))) 1543a2e2270fSchristos 1544a2e2270fSchristos(dnci add3x "three operand add (extended)" () 1545a2e2270fSchristos "add3 $rn,$rm,$simm16" 1546a2e2270fSchristos (+ MAJ_12 rn rm (f-sub4 0) simm16) 1547a2e2270fSchristos (set rn (add rm (ext SI simm16))) 1548a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1549a2e2270fSchristos (unit u-exec)))) 1550a2e2270fSchristos 1551a2e2270fSchristos(dnci slt3x "set if less than (extended)" () 1552a2e2270fSchristos "slt3 $rn,$rm,$simm16" 1553a2e2270fSchristos (+ MAJ_12 rn rm (f-sub4 2) simm16) 1554a2e2270fSchristos (if (lt rm (ext SI simm16)) 1555a2e2270fSchristos (set rn 1) 1556a2e2270fSchristos (set rn 0)) 1557a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1558a2e2270fSchristos (unit u-exec)))) 1559a2e2270fSchristos 1560a2e2270fSchristos(dnci sltu3x "set if less than unsigned (extended)" () 1561a2e2270fSchristos "sltu3 $rn,$rm,$uimm16" 1562a2e2270fSchristos (+ MAJ_12 rn rm (f-sub4 3) uimm16) 1563a2e2270fSchristos (if (ltu rm (zext SI uimm16)) 1564a2e2270fSchristos (set rn 1) 1565a2e2270fSchristos (set rn 0)) 1566a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1567a2e2270fSchristos (unit u-exec)))) 1568a2e2270fSchristos 1569a2e2270fSchristos 1570a2e2270fSchristos; Logical instructions. 1571a2e2270fSchristos 1572a2e2270fSchristos(dnci or "bitwise or" () 1573a2e2270fSchristos "or $rn,$rm" 1574a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 0)) 1575a2e2270fSchristos (set rn (or rn rm)) 1576a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1577a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1578a2e2270fSchristos (unit u-exec)))) 1579a2e2270fSchristos 1580a2e2270fSchristos(dnci and "bitwise and" () 1581a2e2270fSchristos "and $rn,$rm" 1582a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 1)) 1583a2e2270fSchristos (set rn (and rn rm)) 1584a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1585a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1586a2e2270fSchristos (unit u-exec)))) 1587a2e2270fSchristos 1588a2e2270fSchristos(dnci xor "bitwise exclusive or" () 1589a2e2270fSchristos "xor $rn,$rm" 1590a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 2)) 1591a2e2270fSchristos (set rn (xor rn rm)) 1592a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1593a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1594a2e2270fSchristos (unit u-exec)))) 1595a2e2270fSchristos 1596a2e2270fSchristos(dnci nor "bitwise negated or" () 1597a2e2270fSchristos "nor $rn,$rm" 1598a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 3)) 1599a2e2270fSchristos (set rn (inv (or rn rm))) 1600a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1601a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1602a2e2270fSchristos (unit u-exec)))) 1603a2e2270fSchristos 1604a2e2270fSchristos(dnci or3 "or three operand" () 1605a2e2270fSchristos "or3 $rn,$rm,$uimm16" 1606a2e2270fSchristos (+ MAJ_12 rn rm (f-sub4 4) uimm16) 1607a2e2270fSchristos (set rn (or rm (zext SI uimm16))) 1608a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1609a2e2270fSchristos (unit u-exec)))) 1610a2e2270fSchristos 1611a2e2270fSchristos(dnci and3 "and three operand" () 1612a2e2270fSchristos "and3 $rn,$rm,$uimm16" 1613a2e2270fSchristos (+ MAJ_12 rn rm (f-sub4 5) uimm16) 1614a2e2270fSchristos (set rn (and rm (zext SI uimm16))) 1615a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1616a2e2270fSchristos (unit u-exec)))) 1617a2e2270fSchristos 1618a2e2270fSchristos(dnci xor3 "exclusive or three operand" () 1619a2e2270fSchristos "xor3 $rn,$rm,$uimm16" 1620a2e2270fSchristos (+ MAJ_12 rn rm (f-sub4 6) uimm16) 1621a2e2270fSchristos (set rn (xor rm (zext SI uimm16))) 1622a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1623a2e2270fSchristos (unit u-exec)))) 1624a2e2270fSchristos 1625a2e2270fSchristos 1626a2e2270fSchristos; Shift instructions. 1627a2e2270fSchristos 1628a2e2270fSchristos(dnci sra "shift right arithmetic" ((STALL INT2)) 1629a2e2270fSchristos "sra $rn,$rm" 1630a2e2270fSchristos (+ MAJ_2 rn rm (f-sub4 13)) 1631a2e2270fSchristos (set rn (sra rn (and rm #x1f))) 1632a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1633a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1634a2e2270fSchristos (unit u-exec)))) 1635a2e2270fSchristos 1636a2e2270fSchristos(dnci srl "shift right logical" ((STALL INT2)) 1637a2e2270fSchristos "srl $rn,$rm" 1638a2e2270fSchristos (+ MAJ_2 rn rm (f-sub4 12)) 1639a2e2270fSchristos (set rn (srl rn (and rm #x1f))) 1640a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1641a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1642a2e2270fSchristos (unit u-exec)))) 1643a2e2270fSchristos 1644a2e2270fSchristos(dnci sll "shift left logical" ((STALL INT2)) 1645a2e2270fSchristos "sll $rn,$rm" 1646a2e2270fSchristos (+ MAJ_2 rn rm (f-sub4 14)) 1647a2e2270fSchristos (set rn (sll rn (and rm #x1f))) 1648a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1649a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1650a2e2270fSchristos (unit u-exec)))) 1651a2e2270fSchristos 1652a2e2270fSchristos(dnci srai "shift right arithmetic (immediate)" ((STALL SHIFTI)) 1653a2e2270fSchristos "sra $rn,$uimm5" 1654a2e2270fSchristos (+ MAJ_6 rn uimm5 (f-sub3 3)) 1655a2e2270fSchristos (set rn (sra rn uimm5)) 1656a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1657a2e2270fSchristos (unit u-exec)))) 1658a2e2270fSchristos 1659a2e2270fSchristos(dnci srli "shift right logical (immediate)" ((STALL SHIFTI)) 1660a2e2270fSchristos "srl $rn,$uimm5" 1661a2e2270fSchristos (+ MAJ_6 rn uimm5 (f-sub3 2)) 1662a2e2270fSchristos (set rn (srl rn uimm5)) 1663a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1664a2e2270fSchristos (unit u-exec)))) 1665a2e2270fSchristos 1666a2e2270fSchristos(dnci slli "shift left logical (immediate)" ((STALL SHIFTI)) 1667a2e2270fSchristos "sll $rn,$uimm5" 1668a2e2270fSchristos (+ MAJ_6 rn uimm5 (f-sub3 6)) 1669a2e2270fSchristos (set rn (sll rn uimm5)) 1670a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1671a2e2270fSchristos (unit u-exec)))) 1672a2e2270fSchristos 1673a2e2270fSchristos(dnci sll3 "three-register shift left logical" ((STALL INT2)) 1674a2e2270fSchristos "sll3 \\$0,$rn,$uimm5" 1675a2e2270fSchristos (+ MAJ_6 rn uimm5 (f-sub3 7)) 1676a2e2270fSchristos (set r0 (sll rn uimm5)) 1677a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1678a2e2270fSchristos (unit u-exec)))) 1679a2e2270fSchristos 1680a2e2270fSchristos(dnci fsft "field shift" ((STALL FSFT) VOLATILE) 1681a2e2270fSchristos "fsft $rn,$rm" 1682a2e2270fSchristos (+ MAJ_2 rn rm (f-sub4 15)) 1683a2e2270fSchristos (sequence ((DI temp) (QI shamt)) 1684a2e2270fSchristos (set shamt (and sar #x3f)) 1685a2e2270fSchristos (set temp (sll (or (sll (zext DI rn) 32) (zext DI rm)) shamt)) 1686a2e2270fSchristos (set rn (subword SI (srl temp 32) 1))) 1687a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1688a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1689a2e2270fSchristos (unit u-exec)))) 1690a2e2270fSchristos 1691a2e2270fSchristos 1692a2e2270fSchristos; Branch/jump instructions. 1693a2e2270fSchristos 1694a2e2270fSchristos(dnci bra "branch" (RELAXABLE) 1695a2e2270fSchristos "bra $pcrel12a2" 1696a2e2270fSchristos (+ MAJ_11 pcrel12a2 (f-15 0)) 1697a2e2270fSchristos (set-vliw-alignment-modified pc pcrel12a2) 1698a2e2270fSchristos ((mep (unit u-branch) 1699a2e2270fSchristos (unit u-exec)))) 1700a2e2270fSchristos 1701a2e2270fSchristos(dnci beqz "branch if equal zero" (RELAXABLE) 1702a2e2270fSchristos "beqz $rn,$pcrel8a2" 1703a2e2270fSchristos (+ MAJ_10 rn pcrel8a2 (f-15 0)) 1704a2e2270fSchristos (if (eq rn 0) 1705a2e2270fSchristos (set-vliw-alignment-modified pc pcrel8a2)) 1706a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1707a2e2270fSchristos (unit u-exec) 1708a2e2270fSchristos (unit u-branch)))) 1709a2e2270fSchristos 1710a2e2270fSchristos(dnci bnez "branch if not equal zero" (RELAXABLE) 1711a2e2270fSchristos "bnez $rn,$pcrel8a2" 1712a2e2270fSchristos (+ MAJ_10 rn pcrel8a2 (f-15 1)) 1713a2e2270fSchristos (if (ne rn 0) 1714a2e2270fSchristos (set-vliw-alignment-modified pc pcrel8a2)) 1715a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1716a2e2270fSchristos (unit u-exec) 1717a2e2270fSchristos (unit u-branch)))) 1718a2e2270fSchristos 1719a2e2270fSchristos(dnci beqi "branch equal immediate" (RELAXABLE) 1720a2e2270fSchristos "beqi $rn,$uimm4,$pcrel17a2" 1721a2e2270fSchristos (+ MAJ_14 rn uimm4 (f-sub4 0) pcrel17a2) 1722a2e2270fSchristos (if (eq rn (zext SI uimm4)) 1723a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2)) 1724a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1725a2e2270fSchristos (unit u-exec) 1726a2e2270fSchristos (unit u-branch)))) 1727a2e2270fSchristos 1728a2e2270fSchristos(dnci bnei "branch not equal immediate" (RELAXABLE) 1729a2e2270fSchristos "bnei $rn,$uimm4,$pcrel17a2" 1730a2e2270fSchristos (+ MAJ_14 rn uimm4 (f-sub4 4) pcrel17a2) 1731a2e2270fSchristos (if (ne rn (zext SI uimm4)) 1732a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2)) 1733a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1734a2e2270fSchristos (unit u-exec) 1735a2e2270fSchristos (unit u-branch)))) 1736a2e2270fSchristos 1737a2e2270fSchristos(dnci blti "branch less than immediate" (RELAXABLE) 1738a2e2270fSchristos "blti $rn,$uimm4,$pcrel17a2" 1739a2e2270fSchristos (+ MAJ_14 rn uimm4 (f-sub4 12) pcrel17a2) 1740a2e2270fSchristos (if (lt rn (zext SI uimm4)) 1741a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2)) 1742a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1743a2e2270fSchristos (unit u-exec) 1744a2e2270fSchristos (unit u-branch)))) 1745a2e2270fSchristos 1746a2e2270fSchristos(dnci bgei "branch greater than immediate" (RELAXABLE) 1747a2e2270fSchristos "bgei $rn,$uimm4,$pcrel17a2" 1748a2e2270fSchristos (+ MAJ_14 rn uimm4 (f-sub4 8) pcrel17a2) 1749a2e2270fSchristos (if (ge rn (zext SI uimm4)) 1750a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2)) 1751a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1752a2e2270fSchristos (unit u-exec) 1753a2e2270fSchristos (unit u-branch)))) 1754a2e2270fSchristos 1755a2e2270fSchristos(dnci beq "branch equal" () 1756a2e2270fSchristos "beq $rn,$rm,$pcrel17a2" 1757a2e2270fSchristos (+ MAJ_14 rn rm (f-sub4 1) pcrel17a2) 1758a2e2270fSchristos (if (eq rn rm) 1759a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2)) 1760a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1761a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1762a2e2270fSchristos (unit u-exec) 1763a2e2270fSchristos (unit u-branch)))) 1764a2e2270fSchristos 1765a2e2270fSchristos(dnci bne "branch not equal" () 1766a2e2270fSchristos "bne $rn,$rm,$pcrel17a2" 1767a2e2270fSchristos (+ MAJ_14 rn rm (f-sub4 5) pcrel17a2) 1768a2e2270fSchristos (if (ne rn rm) 1769a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2)) 1770a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1771a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 1772a2e2270fSchristos (unit u-exec) 1773a2e2270fSchristos (unit u-branch)))) 1774a2e2270fSchristos 1775a2e2270fSchristos(dnci bsr12 "branch to subroutine (12 bit displacement)" (RELAXABLE) 1776a2e2270fSchristos "bsr $pcrel12a2" 1777a2e2270fSchristos (+ MAJ_11 pcrel12a2 (f-15 1)) 1778a2e2270fSchristos (sequence () 1779a2e2270fSchristos (cg-profile pc pcrel12a2) 1780a2e2270fSchristos (set-vliw-modified-pcrel-offset lp 2 4 8) 1781a2e2270fSchristos (set-vliw-alignment-modified pc pcrel12a2)) 1782a2e2270fSchristos ((mep (unit u-exec) 1783a2e2270fSchristos (unit u-branch)))) 1784a2e2270fSchristos 1785a2e2270fSchristos(dnci bsr24 "branch to subroutine (24 bit displacement)" () 1786a2e2270fSchristos "bsr $pcrel24a2" 1787a2e2270fSchristos (+ MAJ_13 (f-4 1) (f-sub4 9) pcrel24a2) 1788a2e2270fSchristos (sequence () 1789a2e2270fSchristos (cg-profile pc pcrel24a2) 1790a2e2270fSchristos (set-vliw-modified-pcrel-offset lp 4 4 8) 1791a2e2270fSchristos (set-vliw-alignment-modified pc pcrel24a2)) 1792a2e2270fSchristos ((mep (unit u-exec) 1793a2e2270fSchristos (unit u-branch)))) 1794a2e2270fSchristos 1795a2e2270fSchristos(dnci jmp "jump" () 1796a2e2270fSchristos "jmp $rm" 1797a2e2270fSchristos (+ MAJ_1 (f-rn 0) rm (f-sub4 14)) 1798a2e2270fSchristos (sequence () 1799a2e2270fSchristos (if (eq (get-psw.om) 0) 1800a2e2270fSchristos ;; core mode 1801a2e2270fSchristos (if (get-rm.lsb) 1802a2e2270fSchristos (sequence () 1803a2e2270fSchristos (set-psw.om 1) ;; enter VLIW mode 1804a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc rm)) 1805a2e2270fSchristos (set pc (and rm (inv 1)))) 1806a2e2270fSchristos ;; VLIW mode 1807a2e2270fSchristos (if (get-rm.lsb) 1808a2e2270fSchristos (sequence () 1809a2e2270fSchristos (set-psw.om 0) ;; enter core mode 1810a2e2270fSchristos (set pc (and rm (inv 1)))) 1811a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc rm))) 1812a2e2270fSchristos (cg-profile-jump pc rm)) 1813a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1814a2e2270fSchristos (unit u-exec) 1815a2e2270fSchristos (unit u-branch)))) 1816a2e2270fSchristos 1817a2e2270fSchristos(dnci jmp24 "jump (24 bit target)" () 1818a2e2270fSchristos "jmp $pcabs24a2" 1819a2e2270fSchristos (+ MAJ_13 (f-4 1) (f-sub4 8) pcabs24a2) 1820a2e2270fSchristos (sequence () 1821a2e2270fSchristos (set-vliw-alignment-modified pc (or (and pc #xf0000000) pcabs24a2)) 1822a2e2270fSchristos (cg-profile-jump pc pcabs24a2)) 1823a2e2270fSchristos ((mep (unit u-exec) 1824a2e2270fSchristos (unit u-branch)))) 1825a2e2270fSchristos 1826a2e2270fSchristos(dnci jsr "jump to subroutine" () 1827a2e2270fSchristos "jsr $rm" 1828a2e2270fSchristos (+ MAJ_1 (f-rn 0) rm (f-sub4 15)) 1829a2e2270fSchristos (sequence () 1830a2e2270fSchristos (cg-profile pc rm) 1831a2e2270fSchristos (set-vliw-modified-pcrel-offset lp 2 4 8) 1832a2e2270fSchristos (set-vliw-alignment-modified pc rm)) 1833a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 1834a2e2270fSchristos (unit u-exec) 1835a2e2270fSchristos (unit u-branch)))) 1836a2e2270fSchristos 1837a2e2270fSchristos(dnci ret "return from subroutine" ((STALL RET)) 1838a2e2270fSchristos "ret" 1839a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 0) (f-sub4 2)) 1840a2e2270fSchristos (sequence () 1841a2e2270fSchristos (if (eq (get-psw.om) 0) 1842a2e2270fSchristos ;; core mode 1843a2e2270fSchristos (if (get-lp.ltom) ;; link-pointer "toggle mode" bit 1844a2e2270fSchristos (sequence () 1845a2e2270fSchristos (set-psw.om 1) ;; enter VLIW mode 1846a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc lp)) 1847a2e2270fSchristos (set pc (and lp (inv 1)))) 1848a2e2270fSchristos ;; VLIW mode 1849a2e2270fSchristos (if (get-lp.ltom) ;; link-pointer "toggle mode" bit 1850a2e2270fSchristos (sequence () 1851a2e2270fSchristos (set-psw.om 0) ;; enter VLIW mode 1852a2e2270fSchristos (set pc (and lp (inv 1)))) 1853a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc lp))) 1854a2e2270fSchristos (c-call VOID "notify_ret" pc)) 1855a2e2270fSchristos ((mep (unit u-exec) 1856a2e2270fSchristos (unit u-branch)))) 1857a2e2270fSchristos 1858a2e2270fSchristos 1859a2e2270fSchristos; Repeat instructions. 1860a2e2270fSchristos 1861a2e2270fSchristos(dnci repeat "repeat specified repeat block" () 1862a2e2270fSchristos "repeat $rn,$pcrel17a2" 1863a2e2270fSchristos (+ MAJ_14 rn (f-rm 0) (f-sub4 9) pcrel17a2) 1864a2e2270fSchristos (sequence () 1865a2e2270fSchristos (set-vliw-modified-pcrel-offset (reg h-csr 4) 4 4 8) 1866a2e2270fSchristos (set-vliw-alignment-modified (reg h-csr 5) pcrel17a2) 1867a2e2270fSchristos (set (reg h-csr 6) rn)) 1868a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1869a2e2270fSchristos (unit u-exec)))) 1870a2e2270fSchristos 1871a2e2270fSchristos(dnci erepeat "endless repeat" () 1872a2e2270fSchristos "erepeat $pcrel17a2" 1873a2e2270fSchristos (+ MAJ_14 (f-rn 0) (f-rm 1) (f-sub4 9) pcrel17a2) 1874a2e2270fSchristos (sequence () 1875a2e2270fSchristos (set-vliw-modified-pcrel-offset (reg h-csr 4) 4 4 8) 1876a2e2270fSchristos (set-vliw-alignment-modified (reg h-csr 5) pcrel17a2) 1877a2e2270fSchristos (set-rpe.elr 1) 1878a2e2270fSchristos ; rpc may be undefined for erepeat 1879a2e2270fSchristos ; use 1 to trigger repeat logic in the sim's main loop 1880a2e2270fSchristos (set (reg h-csr 6) 1)) 1881a2e2270fSchristos ()) 1882a2e2270fSchristos 1883a2e2270fSchristos 1884a2e2270fSchristos; Control instructions. 1885a2e2270fSchristos 1886a2e2270fSchristos;; special store variants 1887a2e2270fSchristos 1888a2e2270fSchristos(dnci stc_lp "store to control register lp" ((STALL STC)) 1889a2e2270fSchristos "stc $rn,\\$lp" 1890a2e2270fSchristos (+ MAJ_7 rn (f-csrn-lo 1) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 0)) 1891a2e2270fSchristos (set lp rn) 1892a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1893a2e2270fSchristos (unit u-store-ctrl-reg (out storereg lp)) 1894a2e2270fSchristos (unit u-exec)))) 1895a2e2270fSchristos 1896a2e2270fSchristos(dnci stc_hi "store to control register hi" ((STALL STC)) 1897a2e2270fSchristos "stc $rn,\\$hi" 1898a2e2270fSchristos (+ MAJ_7 rn (f-csrn-lo 7) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 0)) 1899a2e2270fSchristos (set hi rn) 1900a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1901a2e2270fSchristos (unit u-store-ctrl-reg (out storereg hi)) 1902a2e2270fSchristos (unit u-exec)))) 1903a2e2270fSchristos 1904a2e2270fSchristos(dnci stc_lo "store to control register lo" ((STALL STC)) 1905a2e2270fSchristos "stc $rn,\\$lo" 1906a2e2270fSchristos (+ MAJ_7 rn (f-csrn-lo 8) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 0)) 1907a2e2270fSchristos (set lo rn) 1908a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1909a2e2270fSchristos (unit u-store-ctrl-reg (out storereg lo)) 1910a2e2270fSchristos (unit u-exec)))) 1911a2e2270fSchristos 1912a2e2270fSchristos;; general store 1913a2e2270fSchristos 1914a2e2270fSchristos(dnci stc "store to control register" (VOLATILE (STALL STC)) 1915a2e2270fSchristos "stc $rn,$csrn" 1916a2e2270fSchristos (+ MAJ_7 rn csrn (f-12 1) (f-13 0) (f-14 0)) 1917a2e2270fSchristos (set csrn rn) 1918a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 1919a2e2270fSchristos (unit u-store-ctrl-reg (out storereg csrn)) 1920a2e2270fSchristos (unit u-exec)))) 1921a2e2270fSchristos 1922a2e2270fSchristos;; special load variants 1923a2e2270fSchristos 1924a2e2270fSchristos(dnci ldc_lp "load from control register lp" ((STALL LDC)) 1925a2e2270fSchristos "ldc $rn,\\$lp" 1926a2e2270fSchristos (+ MAJ_7 rn (f-csrn-lo 1) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 1)) 1927a2e2270fSchristos (set rn lp) 1928a2e2270fSchristos ((mep (unit u-use-ctrl-reg (in usereg lp)) 1929a2e2270fSchristos (unit u-exec) 1930a2e2270fSchristos (unit u-load-gpr (out loadreg rn))))) 1931a2e2270fSchristos 1932a2e2270fSchristos 1933a2e2270fSchristos(dnci ldc_hi "load from control register hi" ((STALL LDC)) 1934a2e2270fSchristos "ldc $rn,\\$hi" 1935a2e2270fSchristos (+ MAJ_7 rn (f-csrn-lo 7) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 1)) 1936a2e2270fSchristos (set rn hi) 1937a2e2270fSchristos ((mep (unit u-use-ctrl-reg (in usereg hi)) 1938a2e2270fSchristos (unit u-exec) 1939a2e2270fSchristos (unit u-load-gpr (out loadreg rn))))) 1940a2e2270fSchristos 1941a2e2270fSchristos(dnci ldc_lo "load from control register lo" ((STALL LDC)) 1942a2e2270fSchristos "ldc $rn,\\$lo" 1943a2e2270fSchristos (+ MAJ_7 rn (f-csrn-lo 8) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 1)) 1944a2e2270fSchristos (set rn lo) 1945a2e2270fSchristos ((mep (unit u-use-ctrl-reg (in usereg lo)) 1946a2e2270fSchristos (unit u-exec) 1947a2e2270fSchristos (unit u-load-gpr (out loadreg rn))))) 1948a2e2270fSchristos 1949a2e2270fSchristos;; general load 1950a2e2270fSchristos 1951a2e2270fSchristos(dnci ldc "load from control register" (VOLATILE (STALL LDC) (LATENCY 2)) 1952a2e2270fSchristos "ldc $rn,$csrn" 1953a2e2270fSchristos (+ MAJ_7 rn csrn (f-12 1) (f-13 0) (f-14 1)) 1954a2e2270fSchristos (if (eq (ifield f-csrn) 0) 1955a2e2270fSchristos ;; loading from the pc 1956a2e2270fSchristos (set-vliw-modified-pcrel-offset rn 2 4 8) 1957a2e2270fSchristos ;; loading from something else 1958a2e2270fSchristos (set rn csrn)) 1959a2e2270fSchristos ((mep (unit u-use-ctrl-reg (in usereg csrn)) 1960a2e2270fSchristos (unit u-exec) 1961a2e2270fSchristos (unit u-load-gpr (out loadreg rn))))) 1962a2e2270fSchristos 1963a2e2270fSchristos(dnci di "disable interrupt" (VOLATILE) 1964a2e2270fSchristos "di" 1965a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 0) (f-sub4 0)) 1966a2e2270fSchristos ; clear psw.iec 1967a2e2270fSchristos (set psw (sll (srl psw 1) 1)) 1968a2e2270fSchristos ()) 1969a2e2270fSchristos 1970a2e2270fSchristos(dnci ei "enable interrupt" (VOLATILE) 1971a2e2270fSchristos "ei" 1972a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 0)) 1973a2e2270fSchristos ; set psw.iec 1974a2e2270fSchristos (set psw (or psw 1)) 1975a2e2270fSchristos ()) 1976a2e2270fSchristos 1977a2e2270fSchristos(dnci reti "return from interrupt" ((STALL RET)) 1978a2e2270fSchristos "reti" 1979a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 2)) 1980a2e2270fSchristos (if (eq (get-psw.om) 0) 1981a2e2270fSchristos ;; core operation mode 1982a2e2270fSchristos (if (get-psw.nmi) 1983a2e2270fSchristos ;; return from NMI 1984a2e2270fSchristos (if (get-npc.ntom) 1985a2e2270fSchristos ;; return in VLIW operation mode 1986a2e2270fSchristos (sequence () 1987a2e2270fSchristos (set-psw.om 1) 1988a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc npc) 1989a2e2270fSchristos (set-psw.nmi 0)) 1990a2e2270fSchristos ;; return in core mode 1991a2e2270fSchristos (sequence () 1992a2e2270fSchristos (set pc (and npc (inv 1))) 1993a2e2270fSchristos (set-psw.nmi 0))) 1994a2e2270fSchristos ;; return from non-NMI 1995a2e2270fSchristos (if (get-epc.etom) 1996a2e2270fSchristos ;; return in VLIW mode 1997a2e2270fSchristos (sequence () 1998a2e2270fSchristos (set-psw.om 1) 1999a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc epc) 2000a2e2270fSchristos (set-psw.umc (get-psw.ump)) 2001a2e2270fSchristos (set-psw.iec (get-psw.iep))) 2002a2e2270fSchristos ;; return in core mode 2003a2e2270fSchristos (sequence () 2004a2e2270fSchristos (set pc (and epc (inv 1))) 2005a2e2270fSchristos (set-psw.umc (get-psw.ump)) 2006a2e2270fSchristos (set-psw.iec (get-psw.iep))))) 2007a2e2270fSchristos ;; VLIW operation mode 2008a2e2270fSchristos ;; xxx undefined 2009a2e2270fSchristos (nop)) 2010a2e2270fSchristos ((mep (unit u-exec) 2011a2e2270fSchristos (unit u-branch)))) 2012a2e2270fSchristos 2013a2e2270fSchristos(dnci halt "halt pipeline" (VOLATILE) 2014a2e2270fSchristos "halt" 2015a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 2) (f-sub4 2)) 2016a2e2270fSchristos ; set psw.halt 2017a2e2270fSchristos (set (raw-reg h-csr 16) (or psw (sll 1 11))) 2018a2e2270fSchristos ()) 2019a2e2270fSchristos 2020a2e2270fSchristos(dnci sleep "sleep pipeline" (VOLATILE) 2021a2e2270fSchristos "sleep" 2022a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 6) (f-sub4 2)) 2023a2e2270fSchristos (c-call VOID "do_sleep") 2024a2e2270fSchristos ()) 2025a2e2270fSchristos 2026a2e2270fSchristos(dnci swi "software interrupt" (MAY_TRAP VOLATILE) 2027a2e2270fSchristos "swi $uimm2" 2028a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-8 0) (f-9 0) uimm2 (f-sub4 6)) 2029a2e2270fSchristos (cond 2030a2e2270fSchristos ((eq uimm2 0) (set exc (or exc (sll 1 4)))) 2031a2e2270fSchristos ((eq uimm2 1) (set exc (or exc (sll 1 5)))) 2032a2e2270fSchristos ((eq uimm2 2) (set exc (or exc (sll 1 6)))) 2033a2e2270fSchristos ((eq uimm2 3) (set exc (or exc (sll 1 7))))) 2034a2e2270fSchristos ()) 2035a2e2270fSchristos 2036a2e2270fSchristos(dnci break "break exception" (MAY_TRAP VOLATILE) 2037a2e2270fSchristos "break" 2038a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 3) (f-sub4 2)) 2039a2e2270fSchristos (set pc (c-call USI "break_exception" pc)) 2040a2e2270fSchristos ((mep (unit u-exec) 2041a2e2270fSchristos (unit u-branch)))) 2042a2e2270fSchristos 2043a2e2270fSchristos(dnci syncm "synchronise with memory" (VOLATILE) 2044a2e2270fSchristos "syncm" 2045a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 1)) 2046a2e2270fSchristos (unimp "syncm") 2047a2e2270fSchristos ()) 2048a2e2270fSchristos 2049a2e2270fSchristos(dnci stcb "store in control bus space" (VOLATILE (STALL STCB)) 2050a2e2270fSchristos "stcb $rn,$uimm16" 2051a2e2270fSchristos (+ MAJ_15 rn (f-rm 0) (f-sub4 4) uimm16) 2052a2e2270fSchristos (c-call VOID "do_stcb" rn uimm16) 2053a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2054a2e2270fSchristos (unit u-exec) 2055a2e2270fSchristos (unit u-stcb)))) 2056a2e2270fSchristos 2057a2e2270fSchristos(dnci ldcb "load from control bus space" (VOLATILE (STALL LDCB) (LATENCY 3)) 2058a2e2270fSchristos "ldcb $rn,$uimm16" 2059a2e2270fSchristos (+ MAJ_15 rn (f-rm 1) (f-sub4 4) uimm16) 2060a2e2270fSchristos (set rn (c-call SI "do_ldcb" uimm16)) 2061a2e2270fSchristos ((mep (unit u-ldcb) 2062a2e2270fSchristos (unit u-exec) 2063a2e2270fSchristos (unit u-ldcb-gpr (out loadreg rn))))) 2064a2e2270fSchristos 2065a2e2270fSchristos 2066a2e2270fSchristos; Bit manipulation instructions. 2067a2e2270fSchristos; The following instructions become the reserved instruction when the 2068a2e2270fSchristos; bit manipulation option is off. 2069a2e2270fSchristos 2070a2e2270fSchristos(dnci bsetm "set bit in memory" (OPTIONAL_BIT_INSN) 2071a2e2270fSchristos "bsetm ($rma),$uimm3" 2072a2e2270fSchristos (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 0)) 2073a2e2270fSchristos (sequence () 2074a2e2270fSchristos (c-call "check_option_bit" pc) 2075a2e2270fSchristos (set (mem UQI rma) (or (mem UQI rma) (sll 1 uimm3)))) 2076a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2077a2e2270fSchristos (unit u-exec)))) 2078a2e2270fSchristos 2079a2e2270fSchristos(dnci bclrm "clear bit in memory" (OPTIONAL_BIT_INSN) 2080a2e2270fSchristos "bclrm ($rma),$uimm3" 2081a2e2270fSchristos (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 1)) 2082a2e2270fSchristos (sequence () 2083a2e2270fSchristos (c-call "check_option_bit" pc) 2084a2e2270fSchristos (set (mem UQI rma) (and (mem UQI rma) (inv (sll 1 uimm3))))) 2085a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2086a2e2270fSchristos (unit u-exec)))) 2087a2e2270fSchristos 2088a2e2270fSchristos(dnci bnotm "toggle bit in memory" (OPTIONAL_BIT_INSN) 2089a2e2270fSchristos "bnotm ($rma),$uimm3" 2090a2e2270fSchristos (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 2)) 2091a2e2270fSchristos (sequence () 2092a2e2270fSchristos (c-call "check_option_bit" pc) 2093a2e2270fSchristos (set (mem UQI rma) (xor (mem UQI rma) (sll 1 uimm3)))) 2094a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2095a2e2270fSchristos (unit u-exec)))) 2096a2e2270fSchristos 2097a2e2270fSchristos(dnci btstm "test bit in memory" (OPTIONAL_BIT_INSN) 2098a2e2270fSchristos "btstm \\$0,($rma),$uimm3" 2099a2e2270fSchristos (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 3)) 2100a2e2270fSchristos (sequence () 2101a2e2270fSchristos (c-call "check_option_bit" pc) 2102a2e2270fSchristos (set r0 (zext SI (and UQI (mem UQI rma) (sll 1 uimm3))))) 2103a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2104a2e2270fSchristos (unit u-exec)))) 2105a2e2270fSchristos 2106a2e2270fSchristos(dnci tas "test and set" (OPTIONAL_BIT_INSN) 2107a2e2270fSchristos "tas $rn,($rma)" 2108a2e2270fSchristos (+ MAJ_2 rn rma (f-sub4 4)) 2109a2e2270fSchristos (sequence ((SI result)) 2110a2e2270fSchristos (c-call "check_option_bit" pc) 2111a2e2270fSchristos (set result (zext SI (mem UQI rma))) 2112a2e2270fSchristos (set (mem UQI rma) 1) 2113a2e2270fSchristos (set rn result)) 2114a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2115a2e2270fSchristos (unit u-exec)))) 2116a2e2270fSchristos 2117a2e2270fSchristos 2118a2e2270fSchristos; Data cache instruction. 2119a2e2270fSchristos 2120a2e2270fSchristos(dnci cache "cache operations" (VOLATILE) 2121a2e2270fSchristos "cache $cimm4,($rma)" 2122a2e2270fSchristos (+ MAJ_7 cimm4 rma (f-sub4 4)) 2123a2e2270fSchristos (c-call VOID "do_cache" cimm4 rma pc) 2124a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2125a2e2270fSchristos (unit u-exec)))) 2126a2e2270fSchristos 2127a2e2270fSchristos 2128a2e2270fSchristos; Multiply instructions. 2129a2e2270fSchristos; These instructions become the RI when the 32-bit multiply 2130a2e2270fSchristos; instruction option is off. 2131a2e2270fSchristos 2132a2e2270fSchristos(dnci mul "multiply" (OPTIONAL_MUL_INSN (STALL MUL)) 2133a2e2270fSchristos "mul $rn,$rm" 2134a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 4)) 2135a2e2270fSchristos (sequence ((DI result)) 2136a2e2270fSchristos (c-call "check_option_mul" pc) 2137a2e2270fSchristos (set result (mul (ext DI rn) (ext DI rm))) 2138a2e2270fSchristos (set hi (subword SI result 0)) 2139a2e2270fSchristos (set lo (subword SI result 1))) 2140a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2141a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2142a2e2270fSchristos (unit u-exec) 2143a2e2270fSchristos (unit u-multiply)))) 2144a2e2270fSchristos 2145a2e2270fSchristos(dnci mulu "multiply unsigned" (OPTIONAL_MUL_INSN (STALL MUL)) 2146a2e2270fSchristos "mulu $rn,$rm" 2147a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 5)) 2148a2e2270fSchristos (sequence ((DI result)) 2149a2e2270fSchristos (c-call "check_option_mul" pc) 2150a2e2270fSchristos (set result (mul (zext UDI rn) (zext UDI rm))) 2151a2e2270fSchristos (set hi (subword SI result 0)) 2152a2e2270fSchristos (set lo (subword SI result 1))) 2153a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2154a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2155a2e2270fSchristos (unit u-exec) 2156a2e2270fSchristos (unit u-multiply)))) 2157a2e2270fSchristos 2158a2e2270fSchristos(dnci mulr "multiply, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3)) 2159a2e2270fSchristos "mulr $rn,$rm" 2160a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 6)) 2161a2e2270fSchristos (sequence ((DI result)) 2162a2e2270fSchristos (c-call "check_option_mul" pc) 2163a2e2270fSchristos (set result (mul (ext DI rn) (ext DI rm))) 2164a2e2270fSchristos (set hi (subword SI result 0)) 2165a2e2270fSchristos (set lo (subword SI result 1)) 2166a2e2270fSchristos (set rn (subword SI result 1))) 2167a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2168a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2169a2e2270fSchristos (unit u-exec) 2170a2e2270fSchristos (unit u-multiply) 2171a2e2270fSchristos (unit u-mul-gpr (out resultreg rn))))) 2172a2e2270fSchristos 2173a2e2270fSchristos(dnci mulru "multiply unsigned, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3)) 2174a2e2270fSchristos "mulru $rn,$rm" 2175a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 7)) 2176a2e2270fSchristos (sequence ((DI result)) 2177a2e2270fSchristos (c-call "check_option_mul" pc) 2178a2e2270fSchristos (set result (mul (zext UDI rn) (zext UDI rm))) 2179a2e2270fSchristos (set hi (subword SI result 0)) 2180a2e2270fSchristos (set lo (subword SI result 1)) 2181a2e2270fSchristos (set rn (subword SI result 1))) 2182a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2183a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2184a2e2270fSchristos (unit u-exec) 2185a2e2270fSchristos (unit u-multiply) 2186a2e2270fSchristos (unit u-mul-gpr (out resultreg rn))))) 2187a2e2270fSchristos 2188a2e2270fSchristos(dnci madd "multiply accumulate" (OPTIONAL_MUL_INSN (STALL MUL)) 2189a2e2270fSchristos "madd $rn,$rm" 2190a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3004)) 2191a2e2270fSchristos (sequence ((DI result)) 2192a2e2270fSchristos (c-call "check_option_mul" pc) 2193a2e2270fSchristos (set result (or (sll (zext DI hi) 32) (zext DI lo))) 2194a2e2270fSchristos (set result (add result (mul (ext DI rn) (ext DI rm)))) 2195a2e2270fSchristos (set hi (subword SI result 0)) 2196a2e2270fSchristos (set lo (subword SI result 1))) 2197a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2198a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2199a2e2270fSchristos (unit u-exec) 2200a2e2270fSchristos (unit u-multiply)))) 2201a2e2270fSchristos 2202a2e2270fSchristos(dnci maddu "multiply accumulate unsigned" (OPTIONAL_MUL_INSN (STALL MUL)) 2203a2e2270fSchristos "maddu $rn,$rm" 2204a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3005)) 2205a2e2270fSchristos (sequence ((DI result)) 2206a2e2270fSchristos (c-call "check_option_mul" pc) 2207a2e2270fSchristos (set result (or (sll (zext DI hi) 32) (zext DI lo))) 2208a2e2270fSchristos (set result (add result (mul (zext UDI rn) (zext UDI rm)))) 2209a2e2270fSchristos (set hi (subword SI result 0)) 2210a2e2270fSchristos (set lo (subword SI result 1))) 2211a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2212a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2213a2e2270fSchristos (unit u-exec) 2214a2e2270fSchristos (unit u-multiply)))) 2215a2e2270fSchristos 2216a2e2270fSchristos 2217a2e2270fSchristos(dnci maddr "multiply accumulate, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3)) 2218a2e2270fSchristos "maddr $rn,$rm" 2219a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3006)) 2220a2e2270fSchristos (sequence ((DI result)) 2221a2e2270fSchristos (c-call "check_option_mul" pc) 2222a2e2270fSchristos (set result (or (sll (zext DI hi) 32) (zext DI lo))) 2223a2e2270fSchristos (set result (add result (mul (ext DI rn) (ext DI rm)))) 2224a2e2270fSchristos (set hi (subword SI result 0)) 2225a2e2270fSchristos (set lo (subword SI result 1)) 2226a2e2270fSchristos (set rn (subword SI result 1))) 2227a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2228a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2229a2e2270fSchristos (unit u-exec) 2230a2e2270fSchristos (unit u-multiply) 2231a2e2270fSchristos (unit u-mul-gpr (out resultreg rn))))) 2232a2e2270fSchristos 2233a2e2270fSchristos(dnci maddru "multiple accumulate unsigned, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3)) 2234a2e2270fSchristos "maddru $rn,$rm" 2235a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3007)) 2236a2e2270fSchristos (sequence ((DI result)) 2237a2e2270fSchristos (c-call "check_option_mul" pc) 2238a2e2270fSchristos (set result (or (sll (zext DI hi) 32) (zext DI lo))) 2239a2e2270fSchristos (set result (add result (mul (zext UDI rn) (zext UDI rm)))) 2240a2e2270fSchristos (set hi (subword SI result 0)) 2241a2e2270fSchristos (set lo (subword SI result 1)) 2242a2e2270fSchristos (set rn (subword SI result 1))) 2243a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2244a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2245a2e2270fSchristos (unit u-exec) 2246a2e2270fSchristos (unit u-multiply) 2247a2e2270fSchristos (unit u-mul-gpr (out resultreg rn))))) 2248a2e2270fSchristos 2249a2e2270fSchristos 2250a2e2270fSchristos; Divide instructions. 2251a2e2270fSchristos; These instructions become the RI when the 32-bit divide instruction 2252a2e2270fSchristos; option is off. 2253a2e2270fSchristos 2254a2e2270fSchristos(dnci div "divide" (OPTIONAL_DIV_INSN (STALL DIV) (LATENCY 34) MAY_TRAP) 2255a2e2270fSchristos "div $rn,$rm" 2256a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 8)) 2257a2e2270fSchristos (sequence () 2258a2e2270fSchristos (c-call "check_option_div" pc) 2259a2e2270fSchristos (if (eq rm 0) 2260a2e2270fSchristos (set pc (c-call USI "zdiv_exception" pc)) 2261a2e2270fSchristos ; Special case described on p. 76. 2262a2e2270fSchristos (if (and (eq rn #x80000000) 2263a2e2270fSchristos (eq rm #xffffffff)) 2264a2e2270fSchristos (sequence () 2265a2e2270fSchristos (set lo #x80000000) 2266a2e2270fSchristos (set hi 0)) 2267a2e2270fSchristos (sequence () 2268a2e2270fSchristos (set lo (div rn rm)) 2269a2e2270fSchristos (set hi (mod rn rm)))))) 2270a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2271a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2272a2e2270fSchristos (unit u-exec) 2273a2e2270fSchristos (unit u-divide) 2274a2e2270fSchristos (unit u-branch)))) 2275a2e2270fSchristos 2276a2e2270fSchristos(dnci divu "divide unsigned" (OPTIONAL_DIV_INSN (STALL DIV) (LATENCY 34) MAY_TRAP) 2277a2e2270fSchristos "divu $rn,$rm" 2278a2e2270fSchristos (+ MAJ_1 rn rm (f-sub4 9)) 2279a2e2270fSchristos (sequence () 2280a2e2270fSchristos (c-call "check_option_div" pc) 2281a2e2270fSchristos (if (eq rm 0) 2282a2e2270fSchristos (set pc (c-call USI "zdiv_exception" pc)) 2283a2e2270fSchristos (sequence () 2284a2e2270fSchristos (set lo (udiv rn rm)) 2285a2e2270fSchristos (set hi (umod rn rm))))) 2286a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2287a2e2270fSchristos (unit u-use-gpr (in usereg rm)) 2288a2e2270fSchristos (unit u-exec) 2289a2e2270fSchristos (unit u-divide) 2290a2e2270fSchristos (unit u-branch)))) 2291a2e2270fSchristos 2292a2e2270fSchristos 2293a2e2270fSchristos; Debug functions. 2294a2e2270fSchristos; These instructions become the RI when the debug function option is 2295a2e2270fSchristos; off. 2296a2e2270fSchristos 2297a2e2270fSchristos(dnci dret "return from debug exception" (OPTIONAL_DEBUG_INSN) 2298a2e2270fSchristos "dret" 2299a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 3)) 2300a2e2270fSchristos (sequence () 2301a2e2270fSchristos (c-call "check_option_debug" pc) 2302a2e2270fSchristos ; set DBG.DM. 2303a2e2270fSchristos (set dbg (and dbg (inv (sll SI 1 15)))) 2304a2e2270fSchristos (set pc depc)) 2305a2e2270fSchristos ((mep (unit u-exec) 2306a2e2270fSchristos (unit u-branch)))) 2307a2e2270fSchristos 2308a2e2270fSchristos(dnci dbreak "generate debug exception" (OPTIONAL_DEBUG_INSN MAY_TRAP VOLATILE) 2309a2e2270fSchristos "dbreak" 2310a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 3) (f-sub4 3)) 2311a2e2270fSchristos (sequence () 2312a2e2270fSchristos (c-call "check_option_debug" pc) 2313a2e2270fSchristos ; set DBG.DPB. 2314a2e2270fSchristos (set dbg (or dbg 1))) 2315a2e2270fSchristos ()) 2316a2e2270fSchristos 2317a2e2270fSchristos 2318a2e2270fSchristos; Leading zero instruction. 2319a2e2270fSchristos 2320a2e2270fSchristos(dnci ldz "leading zeroes" (OPTIONAL_LDZ_INSN (STALL INT2)) 2321a2e2270fSchristos "ldz $rn,$rm" 2322a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 0)) 2323a2e2270fSchristos (sequence () 2324a2e2270fSchristos (c-call "check_option_ldz" pc) 2325a2e2270fSchristos (set rn (c-call SI "do_ldz" rm))) 2326a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2327a2e2270fSchristos (unit u-exec)))) 2328a2e2270fSchristos 2329a2e2270fSchristos 2330a2e2270fSchristos; Absolute difference instruction. 2331a2e2270fSchristos 2332a2e2270fSchristos(dnci abs "absolute difference" (OPTIONAL_ABS_INSN (STALL INT2)) 2333a2e2270fSchristos "abs $rn,$rm" 2334a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 3)) 2335a2e2270fSchristos (sequence () 2336a2e2270fSchristos (c-call "check_option_abs" pc) 2337a2e2270fSchristos (set rn (abs (sub rn rm)))) 2338a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2339a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2340a2e2270fSchristos (unit u-exec)))) 2341a2e2270fSchristos 2342a2e2270fSchristos 2343a2e2270fSchristos; Average instruction. 2344a2e2270fSchristos 2345a2e2270fSchristos(dnci ave "average" (OPTIONAL_AVE_INSN (STALL INT2)) 2346a2e2270fSchristos "ave $rn,$rm" 2347a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 2)) 2348a2e2270fSchristos (sequence () 2349a2e2270fSchristos (c-call "check_option_ave" pc) 2350a2e2270fSchristos (set rn (sra (add (add rn rm) 1) 1))) 2351a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2352a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2353a2e2270fSchristos (unit u-exec)))) 2354a2e2270fSchristos 2355a2e2270fSchristos 2356a2e2270fSchristos; MIN/MAX instructions. 2357a2e2270fSchristos 2358a2e2270fSchristos(dnci min "minimum" (OPTIONAL_MINMAX_INSN (STALL INT2)) 2359a2e2270fSchristos "min $rn,$rm" 2360a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 4)) 2361a2e2270fSchristos (sequence () 2362a2e2270fSchristos (c-call "check_option_minmax" pc) 2363a2e2270fSchristos (if (gt rn rm) 2364a2e2270fSchristos (set rn rm))) 2365a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2366a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2367a2e2270fSchristos (unit u-exec)))) 2368a2e2270fSchristos 2369a2e2270fSchristos(dnci max "maximum" (OPTIONAL_MINMAX_INSN (STALL INT2)) 2370a2e2270fSchristos "max $rn,$rm" 2371a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 5)) 2372a2e2270fSchristos (sequence () 2373a2e2270fSchristos (c-call "check_option_minmax" pc) 2374a2e2270fSchristos (if (lt rn rm) 2375a2e2270fSchristos (set rn rm))) 2376a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2377a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2378a2e2270fSchristos (unit u-exec)))) 2379a2e2270fSchristos 2380a2e2270fSchristos(dnci minu "minimum unsigned" (OPTIONAL_MINMAX_INSN (STALL INT2)) 2381a2e2270fSchristos "minu $rn,$rm" 2382a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 6)) 2383a2e2270fSchristos (sequence () 2384a2e2270fSchristos (c-call "check_option_minmax" pc) 2385a2e2270fSchristos (if (gtu rn rm) 2386a2e2270fSchristos (set rn rm))) 2387a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2388a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2389a2e2270fSchristos (unit u-exec)))) 2390a2e2270fSchristos 2391a2e2270fSchristos(dnci maxu "maximum unsigned" (OPTIONAL_MINMAX_INSN (STALL INT2)) 2392a2e2270fSchristos "maxu $rn,$rm" 2393a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 7)) 2394a2e2270fSchristos (sequence () 2395a2e2270fSchristos (c-call "check_option_minmax" pc) 2396a2e2270fSchristos (if (ltu rn rm) 2397a2e2270fSchristos (set rn rm))) 2398a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2399a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2400a2e2270fSchristos (unit u-exec)))) 2401a2e2270fSchristos 2402a2e2270fSchristos 2403a2e2270fSchristos; Clipping instruction. 2404a2e2270fSchristos 2405a2e2270fSchristos(dnci clip "clip" (OPTIONAL_CLIP_INSN (STALL INT2)) 2406a2e2270fSchristos "clip $rn,$cimm5" 2407a2e2270fSchristos (+ MAJ_15 rn (f-rm 0) (f-sub4 1) (f-ext #x10) cimm5 (f-29 0) (f-30 0) (f-31 0)) 2408a2e2270fSchristos (sequence ((SI min) (SI max)) 2409a2e2270fSchristos (c-call "check_option_clip" pc) 2410a2e2270fSchristos (set max (sub (sll 1 (sub cimm5 1)) 1)) 2411a2e2270fSchristos (set min (neg (sll 1 (sub cimm5 1)))) 2412a2e2270fSchristos (cond 2413a2e2270fSchristos ((eq cimm5 0) (set rn 0)) 2414a2e2270fSchristos ((gt rn max) (set rn max)) 2415a2e2270fSchristos ((lt rn min) (set rn min)))) 2416a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2417a2e2270fSchristos (unit u-exec)))) 2418a2e2270fSchristos 2419a2e2270fSchristos(dnci clipu "clip unsigned" (OPTIONAL_CLIP_INSN (STALL INT2)) 2420a2e2270fSchristos "clipu $rn,$cimm5" 2421a2e2270fSchristos (+ MAJ_15 rn (f-rm 0) (f-sub4 1) (f-ext #x10) cimm5 (f-29 0) (f-30 0) (f-31 1)) 2422a2e2270fSchristos (sequence ((SI max)) 2423a2e2270fSchristos (c-call "check_option_clip" pc) 2424a2e2270fSchristos (set max (sub (sll 1 cimm5) 1)) 2425a2e2270fSchristos (cond 2426a2e2270fSchristos ((eq cimm5 0) (set rn 0)) 2427a2e2270fSchristos ((gt rn max) (set rn max)) 2428a2e2270fSchristos ((lt rn 0) (set rn 0)))) 2429a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rn)) 2430a2e2270fSchristos (unit u-exec)))) 2431a2e2270fSchristos 2432a2e2270fSchristos 2433a2e2270fSchristos; Saturation instructions. 2434a2e2270fSchristos 2435a2e2270fSchristos(dnci sadd "saturating addition" (OPTIONAL_SAT_INSN (STALL INT2)) 2436a2e2270fSchristos "sadd $rn,$rm" 2437a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 8)) 2438a2e2270fSchristos (sequence () 2439a2e2270fSchristos (c-call "check_option_sat" pc) 2440a2e2270fSchristos (if (add-oflag rn rm 0) 2441a2e2270fSchristos (if (nflag rn) 2442a2e2270fSchristos ; underflow 2443a2e2270fSchristos (set rn (neg (sll 1 31))) 2444a2e2270fSchristos ; overflow 2445a2e2270fSchristos (set rn (sub (sll 1 31) 1))) 2446a2e2270fSchristos (set rn (add rn rm)))) 2447a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2448a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2449a2e2270fSchristos (unit u-exec)))) 2450a2e2270fSchristos 2451a2e2270fSchristos(dnci ssub "saturating subtraction" (OPTIONAL_SAT_INSN (STALL INT2)) 2452a2e2270fSchristos "ssub $rn,$rm" 2453a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 10)) 2454a2e2270fSchristos (sequence () 2455a2e2270fSchristos (c-call "check_option_sat" pc) 2456a2e2270fSchristos (if (sub-oflag rn rm 0) 2457a2e2270fSchristos (if (nflag rn) 2458a2e2270fSchristos ; underflow 2459a2e2270fSchristos (set rn (neg (sll 1 31))) 2460a2e2270fSchristos ; overflow 2461a2e2270fSchristos (set rn (sub (sll 1 31) 1))) 2462a2e2270fSchristos (set rn (sub rn rm)))) 2463a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2464a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2465a2e2270fSchristos (unit u-exec)))) 2466a2e2270fSchristos 2467a2e2270fSchristos(dnci saddu "saturating unsigned addition" (OPTIONAL_SAT_INSN (STALL INT2)) 2468a2e2270fSchristos "saddu $rn,$rm" 2469a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 9)) 2470a2e2270fSchristos (sequence () 2471a2e2270fSchristos (c-call "check_option_sat" pc) 2472a2e2270fSchristos (if (add-cflag rn rm 0) 2473a2e2270fSchristos (set rn (inv 0)) 2474a2e2270fSchristos (set rn (add rn rm)))) 2475a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2476a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2477a2e2270fSchristos (unit u-exec)))) 2478a2e2270fSchristos 2479a2e2270fSchristos(dnci ssubu "saturating unsigned subtraction" (OPTIONAL_SAT_INSN (STALL INT2)) 2480a2e2270fSchristos "ssubu $rn,$rm" 2481a2e2270fSchristos (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 11)) 2482a2e2270fSchristos (sequence () 2483a2e2270fSchristos (c-call "check_option_sat" pc) 2484a2e2270fSchristos (if (sub-cflag rn rm 0) 2485a2e2270fSchristos (set rn 0) 2486a2e2270fSchristos (set rn (sub rn rm)))) 2487a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2488a2e2270fSchristos (unit u-use-gpr (in usereg rn)) 2489a2e2270fSchristos (unit u-exec)))) 2490a2e2270fSchristos 2491a2e2270fSchristos 2492a2e2270fSchristos; UCI and DSP options are defined in an external file. 2493a2e2270fSchristos; See `mep-sample-ucidsp.cpu' for a sample. 2494a2e2270fSchristos 2495a2e2270fSchristos 2496a2e2270fSchristos; Coprocessor instructions. 2497a2e2270fSchristos 2498a2e2270fSchristos(dnci swcp "store word coprocessor" (OPTIONAL_CP_INSN (STALL STORE)) 2499a2e2270fSchristos "swcp $crn,($rma)" 2500a2e2270fSchristos (+ MAJ_3 crn rma (f-sub4 8)) 2501a2e2270fSchristos (sequence () 2502a2e2270fSchristos (c-call "check_option_cp" pc) 2503a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 3))) 2504a2e2270fSchristos (set (mem SI (and rma (inv SI 3))) crn)) 2505a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2506a2e2270fSchristos (unit u-exec)))) 2507a2e2270fSchristos 2508a2e2270fSchristos(dnci lwcp "load word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD)) 2509a2e2270fSchristos "lwcp $crn,($rma)" 2510a2e2270fSchristos (+ MAJ_3 crn rma (f-sub4 9)) 2511a2e2270fSchristos (sequence () 2512a2e2270fSchristos (c-call "check_option_cp" pc) 2513a2e2270fSchristos (set crn (mem SI (and rma (inv SI 3))))) 2514a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2515a2e2270fSchristos (unit u-exec)))) 2516a2e2270fSchristos 2517a2e2270fSchristos(dnci smcp "smcp" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE)) 2518a2e2270fSchristos "smcp $crn64,($rma)" 2519a2e2270fSchristos (+ MAJ_3 crn64 rma (f-sub4 10)) 2520a2e2270fSchristos (sequence () 2521a2e2270fSchristos (c-call "check_option_cp" pc) 2522a2e2270fSchristos (c-call "check_option_cp64" pc) 2523a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2524a2e2270fSchristos (c-call "do_smcp" rma crn64 pc)) 2525a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2526a2e2270fSchristos (unit u-exec)))) 2527a2e2270fSchristos 2528a2e2270fSchristos(dnci lmcp "lmcp" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD)) 2529a2e2270fSchristos "lmcp $crn64,($rma)" 2530a2e2270fSchristos (+ MAJ_3 crn64 rma (f-sub4 11)) 2531a2e2270fSchristos (sequence () 2532a2e2270fSchristos (c-call "check_option_cp" pc) 2533a2e2270fSchristos (c-call "check_option_cp64" pc) 2534a2e2270fSchristos (set crn64 (c-call DI "do_lmcp" rma pc))) 2535a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2536a2e2270fSchristos (unit u-exec)))) 2537a2e2270fSchristos 2538a2e2270fSchristos(dnci swcpi "swcp (post-increment)" (OPTIONAL_CP_INSN (STALL STORE)) 2539a2e2270fSchristos "swcpi $crn,($rma+)" 2540a2e2270fSchristos (+ MAJ_3 crn rma (f-sub4 0)) 2541a2e2270fSchristos (sequence () 2542a2e2270fSchristos (c-call "check_option_cp" pc) 2543a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 3))) 2544a2e2270fSchristos (set (mem SI (and rma (inv SI 3))) crn) 2545a2e2270fSchristos (set rma (add rma 4))) 2546a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2547a2e2270fSchristos (unit u-exec)))) 2548a2e2270fSchristos 2549a2e2270fSchristos(dnci lwcpi "lwcp (post-increment)" (OPTIONAL_CP_INSN (STALL LOAD)) 2550a2e2270fSchristos "lwcpi $crn,($rma+)" 2551a2e2270fSchristos (+ MAJ_3 crn rma (f-sub4 1)) 2552a2e2270fSchristos (sequence () 2553a2e2270fSchristos (c-call "check_option_cp" pc) 2554a2e2270fSchristos (set crn (mem SI (and rma (inv SI 3)))) 2555a2e2270fSchristos (set rma (add rma 4))) 2556a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2557a2e2270fSchristos (unit u-exec)))) 2558a2e2270fSchristos 2559a2e2270fSchristos(dnci smcpi "smcp (post-increment)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE)) 2560a2e2270fSchristos "smcpi $crn64,($rma+)" 2561a2e2270fSchristos (+ MAJ_3 crn64 rma (f-sub4 2)) 2562a2e2270fSchristos (sequence () 2563a2e2270fSchristos (c-call "check_option_cp" pc) 2564a2e2270fSchristos (c-call "check_option_cp64" pc) 2565a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2566a2e2270fSchristos (c-call "do_smcpi" (index-of rma) crn64 pc) 2567a2e2270fSchristos (set rma rma)) ; reference as output for intrinsic generation 2568a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2569a2e2270fSchristos (unit u-exec)))) 2570a2e2270fSchristos 2571a2e2270fSchristos(dnci lmcpi "lmcp (post-increment)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD)) 2572a2e2270fSchristos "lmcpi $crn64,($rma+)" 2573a2e2270fSchristos (+ MAJ_3 crn64 rma (f-sub4 3)) 2574a2e2270fSchristos (sequence () 2575a2e2270fSchristos (c-call "check_option_cp" pc) 2576a2e2270fSchristos (c-call "check_option_cp64" pc) 2577a2e2270fSchristos (set crn64 (c-call DI "do_lmcpi" (index-of rma) pc)) 2578a2e2270fSchristos (set rma rma)) ; reference as output for intrinsic generation 2579a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2580a2e2270fSchristos (unit u-exec)))) 2581a2e2270fSchristos 2582a2e2270fSchristos(dnci swcp16 "swcp (16-bit displacement)" (OPTIONAL_CP_INSN (STALL STORE)) 2583a2e2270fSchristos "swcp $crn,$sdisp16($rma)" 2584a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 12) sdisp16) 2585a2e2270fSchristos (sequence () 2586a2e2270fSchristos (c-call "check_option_cp" pc) 2587a2e2270fSchristos (set (mem SI (and (add rma sdisp16) (inv SI 3))) crn)) 2588a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2589a2e2270fSchristos (unit u-exec)))) 2590a2e2270fSchristos 2591a2e2270fSchristos(dnci lwcp16 "lwcp (16-bit displacement)" (OPTIONAL_CP_INSN (STALL LOAD)) 2592a2e2270fSchristos "lwcp $crn,$sdisp16($rma)" 2593a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 13) sdisp16) 2594a2e2270fSchristos (sequence () 2595a2e2270fSchristos (c-call "check_option_cp" pc) 2596a2e2270fSchristos (set crn (mem SI (and (add rma sdisp16) (inv SI 3))))) 2597a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2598a2e2270fSchristos (unit u-exec)))) 2599a2e2270fSchristos 2600a2e2270fSchristos(dnci smcp16 "smcp (16-bit displacement)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE)) 2601a2e2270fSchristos "smcp $crn64,$sdisp16($rma)" 2602a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 14) sdisp16) 2603a2e2270fSchristos (sequence () 2604a2e2270fSchristos (c-call "check_option_cp" pc) 2605a2e2270fSchristos (c-call "check_option_cp64" pc) 2606a2e2270fSchristos (c-call "do_smcp16" rma sdisp16 crn64 pc)) 2607a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2608a2e2270fSchristos (unit u-exec)))) 2609a2e2270fSchristos 2610a2e2270fSchristos(dnci lmcp16 "lmcp (16-bit displacement)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD)) 2611a2e2270fSchristos "lmcp $crn64,$sdisp16($rma)" 2612a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 15) sdisp16) 2613a2e2270fSchristos (sequence () 2614a2e2270fSchristos (c-call "check_option_cp" pc) 2615a2e2270fSchristos (c-call "check_option_cp64" pc) 2616a2e2270fSchristos (set crn64 (c-call DI "do_lmcp16" rma sdisp16 pc))) 2617a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2618a2e2270fSchristos (unit u-exec)))) 2619a2e2270fSchristos 2620a2e2270fSchristos(dnci sbcpa "store byte coprocessor" (OPTIONAL_CP_INSN (STALL STORE)) 2621a2e2270fSchristos "sbcpa $crn,($rma+),$cdisp10" 2622a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 0) (f-ext62 0) cdisp10) 2623a2e2270fSchristos (sequence () 2624a2e2270fSchristos (c-call "check_option_cp" pc) 2625a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2626a2e2270fSchristos (set (mem QI rma) (and crn #xff)) 2627a2e2270fSchristos (set rma (add rma (ext SI cdisp10)))) 2628a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2629a2e2270fSchristos (unit u-exec)))) 2630a2e2270fSchristos 2631a2e2270fSchristos(dnci lbcpa "load byte coprocessor" (OPTIONAL_CP_INSN (STALL LOAD)) 2632a2e2270fSchristos "lbcpa $crn,($rma+),$cdisp10" 2633a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x4) (f-ext62 #x0) cdisp10) 2634a2e2270fSchristos (sequence () 2635a2e2270fSchristos (c-call "check_option_cp" pc) 2636a2e2270fSchristos (set crn (ext SI (mem QI rma))) 2637a2e2270fSchristos (set rma (add rma (ext SI cdisp10)))) 2638a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2639a2e2270fSchristos (unit u-exec)))) 2640a2e2270fSchristos 2641a2e2270fSchristos(dnci shcpa "store half-word coprocessor" (OPTIONAL_CP_INSN (STALL STORE)) 2642a2e2270fSchristos "shcpa $crn,($rma+),$cdisp10a2" 2643a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x1) (f-ext62 #x0) cdisp10a2) 2644a2e2270fSchristos (sequence () 2645a2e2270fSchristos (c-call "check_option_cp" pc) 2646a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 1))) 2647a2e2270fSchristos (set (mem HI (and rma (inv SI 1))) (and crn #xffff)) 2648a2e2270fSchristos (set rma (add rma (ext SI cdisp10a2)))) 2649a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2650a2e2270fSchristos (unit u-exec)))) 2651a2e2270fSchristos 2652a2e2270fSchristos(dnci lhcpa "load half-word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD)) 2653a2e2270fSchristos "lhcpa $crn,($rma+),$cdisp10a2" 2654a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x5) (f-ext62 #x0) cdisp10a2) 2655a2e2270fSchristos (sequence () 2656a2e2270fSchristos (c-call "check_option_cp" pc) 2657a2e2270fSchristos (set crn (ext SI (mem HI (and rma (inv SI 1))))) 2658a2e2270fSchristos (set rma (add rma (ext SI cdisp10a2)))) 2659a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2660a2e2270fSchristos (unit u-exec)))) 2661a2e2270fSchristos 2662a2e2270fSchristos(dnci swcpa "store word coprocessor" (OPTIONAL_CP_INSN (STALL STORE)) 2663a2e2270fSchristos "swcpa $crn,($rma+),$cdisp10a4" 2664a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x2) (f-ext62 #x0) cdisp10a4) 2665a2e2270fSchristos (sequence () 2666a2e2270fSchristos (c-call "check_option_cp" pc) 2667a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 3))) 2668a2e2270fSchristos (set (mem SI (and rma (inv SI 3))) crn) 2669a2e2270fSchristos (set rma (add rma (ext SI cdisp10a4)))) 2670a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2671a2e2270fSchristos (unit u-exec)))) 2672a2e2270fSchristos 2673a2e2270fSchristos(dnci lwcpa "load word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD)) 2674a2e2270fSchristos "lwcpa $crn,($rma+),$cdisp10a4" 2675a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x6) (f-ext62 #x0) cdisp10a4) 2676a2e2270fSchristos (sequence () 2677a2e2270fSchristos (c-call "check_option_cp" pc) 2678a2e2270fSchristos (set crn (mem SI (and rma (inv SI 3)))) 2679a2e2270fSchristos (set rma (add rma (ext SI cdisp10a4)))) 2680a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2681a2e2270fSchristos (unit u-exec)))) 2682a2e2270fSchristos 2683a2e2270fSchristos(dnci smcpa "smcpa" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE)) 2684a2e2270fSchristos "smcpa $crn64,($rma+),$cdisp10a8" 2685a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x3) (f-ext62 #x0) cdisp10a8) 2686a2e2270fSchristos (sequence () 2687a2e2270fSchristos (c-call "check_option_cp" pc) 2688a2e2270fSchristos (c-call "check_option_cp64" pc) 2689a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2690a2e2270fSchristos (c-call "do_smcpa" (index-of rma) cdisp10a8 crn64 pc) 2691a2e2270fSchristos (set rma rma)) ; reference as output for intrinsic generation 2692a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2693a2e2270fSchristos (unit u-exec)))) 2694a2e2270fSchristos 2695a2e2270fSchristos(dnci lmcpa "lmcpa" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD)) 2696a2e2270fSchristos "lmcpa $crn64,($rma+),$cdisp10a8" 2697a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x7) (f-ext62 #x0) cdisp10a8) 2698a2e2270fSchristos (sequence () 2699a2e2270fSchristos (c-call "check_option_cp" pc) 2700a2e2270fSchristos (c-call "check_option_cp64" pc) 2701a2e2270fSchristos (set crn64 (c-call DI "do_lmcpa" (index-of rma) cdisp10a8 pc)) 2702a2e2270fSchristos (set rma rma)) ; reference as output for intrinsic generation 2703a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2704a2e2270fSchristos (unit u-exec)))) 2705a2e2270fSchristos 2706a2e2270fSchristos 2707a2e2270fSchristos(dnci sbcpm0 "sbcpm0" (OPTIONAL_CP_INSN) 2708a2e2270fSchristos "sbcpm0 $crn,($rma+),$cdisp10" 2709a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x0) (f-ext62 #x2) cdisp10) 2710a2e2270fSchristos (sequence () 2711a2e2270fSchristos (c-call "check_option_cp" pc) 2712a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2713a2e2270fSchristos (set (mem QI rma) (and crn #xff)) 2714a2e2270fSchristos (set rma (mod0 cdisp10))) 2715a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2716a2e2270fSchristos (unit u-exec)))) 2717a2e2270fSchristos 2718a2e2270fSchristos(dnci lbcpm0 "lbcpm0" (OPTIONAL_CP_INSN) 2719a2e2270fSchristos "lbcpm0 $crn,($rma+),$cdisp10" 2720a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x4) (f-ext62 #x2) cdisp10) 2721a2e2270fSchristos (sequence () 2722a2e2270fSchristos (c-call "check_option_cp" pc) 2723a2e2270fSchristos (set crn (ext SI (mem QI rma))) 2724a2e2270fSchristos (set rma (mod0 cdisp10))) 2725a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2726a2e2270fSchristos (unit u-exec)))) 2727a2e2270fSchristos 2728a2e2270fSchristos(dnci shcpm0 "shcpm0" (OPTIONAL_CP_INSN) 2729a2e2270fSchristos "shcpm0 $crn,($rma+),$cdisp10a2" 2730a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x1) (f-ext62 #x2) cdisp10a2) 2731a2e2270fSchristos (sequence () 2732a2e2270fSchristos (c-call "check_option_cp" pc) 2733a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 1))) 2734a2e2270fSchristos (set (mem HI (and rma (inv SI 1))) (and crn #xffff)) 2735a2e2270fSchristos (set rma (mod0 cdisp10a2))) 2736a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2737a2e2270fSchristos (unit u-exec)))) 2738a2e2270fSchristos 2739a2e2270fSchristos(dnci lhcpm0 "lhcpm0" (OPTIONAL_CP_INSN) 2740a2e2270fSchristos "lhcpm0 $crn,($rma+),$cdisp10a2" 2741a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x5) (f-ext62 #x2) cdisp10a2) 2742a2e2270fSchristos (sequence () 2743a2e2270fSchristos (c-call "check_option_cp" pc) 2744a2e2270fSchristos (set crn (ext SI (mem HI (and rma (inv SI 1))))) 2745a2e2270fSchristos (set rma (mod0 cdisp10a2))) 2746a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2747a2e2270fSchristos (unit u-exec)))) 2748a2e2270fSchristos 2749a2e2270fSchristos(dnci swcpm0 "swcpm0" (OPTIONAL_CP_INSN) 2750a2e2270fSchristos "swcpm0 $crn,($rma+),$cdisp10a4" 2751a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x2) (f-ext62 #x2) cdisp10a4) 2752a2e2270fSchristos (sequence () 2753a2e2270fSchristos (c-call "check_option_cp" pc) 2754a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 3))) 2755a2e2270fSchristos (set (mem SI (and rma (inv SI 3))) crn) 2756a2e2270fSchristos (set rma (mod0 cdisp10a4))) 2757a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2758a2e2270fSchristos (unit u-exec)))) 2759a2e2270fSchristos 2760a2e2270fSchristos(dnci lwcpm0 "lwcpm0" (OPTIONAL_CP_INSN) 2761a2e2270fSchristos "lwcpm0 $crn,($rma+),$cdisp10a4" 2762a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x6) (f-ext62 #x2) cdisp10a4) 2763a2e2270fSchristos (sequence () 2764a2e2270fSchristos (c-call "check_option_cp" pc) 2765a2e2270fSchristos (set crn (mem SI (and rma (inv SI 3)))) 2766a2e2270fSchristos (set rma (mod0 cdisp10a4))) 2767a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2768a2e2270fSchristos (unit u-exec)))) 2769a2e2270fSchristos 2770a2e2270fSchristos(dnci smcpm0 "smcpm0" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN) 2771a2e2270fSchristos "smcpm0 $crn64,($rma+),$cdisp10a8" 2772a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x3) (f-ext62 #x2) cdisp10a8) 2773a2e2270fSchristos (sequence () 2774a2e2270fSchristos (c-call "check_option_cp" pc) 2775a2e2270fSchristos (c-call "check_option_cp64" pc) 2776a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2777a2e2270fSchristos (c-call "do_smcp" rma crn64 pc) 2778a2e2270fSchristos (set rma (mod0 cdisp10a8))) 2779a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2780a2e2270fSchristos (unit u-exec)))) 2781a2e2270fSchristos 2782a2e2270fSchristos(dnci lmcpm0 "lmcpm0" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN) 2783a2e2270fSchristos "lmcpm0 $crn64,($rma+),$cdisp10a8" 2784a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x7) (f-ext62 #x2) cdisp10a8) 2785a2e2270fSchristos (sequence () 2786a2e2270fSchristos (c-call "check_option_cp" pc) 2787a2e2270fSchristos (c-call "check_option_cp64" pc) 2788a2e2270fSchristos (set crn64 (c-call DI "do_lmcp" rma pc)) 2789a2e2270fSchristos (set rma (mod0 cdisp10a8))) 2790a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2791a2e2270fSchristos (unit u-exec)))) 2792a2e2270fSchristos 2793a2e2270fSchristos(dnci sbcpm1 "sbcpm1" (OPTIONAL_CP_INSN) 2794a2e2270fSchristos "sbcpm1 $crn,($rma+),$cdisp10" 2795a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x0) (f-ext62 #x3) cdisp10) 2796a2e2270fSchristos (sequence () 2797a2e2270fSchristos (c-call "check_option_cp" pc) 2798a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2799a2e2270fSchristos (set (mem QI rma) (and crn #xff)) 2800a2e2270fSchristos (set rma (mod1 cdisp10))) 2801a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2802a2e2270fSchristos (unit u-exec)))) 2803a2e2270fSchristos 2804a2e2270fSchristos(dnci lbcpm1 "lbcpm1" (OPTIONAL_CP_INSN) 2805a2e2270fSchristos "lbcpm1 $crn,($rma+),$cdisp10" 2806a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x4) (f-ext62 #x3) cdisp10) 2807a2e2270fSchristos (sequence () 2808a2e2270fSchristos (c-call "check_option_cp" pc) 2809a2e2270fSchristos (set crn (ext SI (mem QI rma))) 2810a2e2270fSchristos (set rma (mod1 cdisp10))) 2811a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2812a2e2270fSchristos (unit u-exec)))) 2813a2e2270fSchristos 2814a2e2270fSchristos(dnci shcpm1 "shcpm1" (OPTIONAL_CP_INSN) 2815a2e2270fSchristos "shcpm1 $crn,($rma+),$cdisp10a2" 2816a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x1) (f-ext62 #x3) cdisp10a2) 2817a2e2270fSchristos (sequence () 2818a2e2270fSchristos (c-call "check_option_cp" pc) 2819a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 1))) 2820a2e2270fSchristos (set (mem HI (and rma (inv SI 1))) (and crn #xffff)) 2821a2e2270fSchristos (set rma (mod1 cdisp10a2))) 2822a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2823a2e2270fSchristos (unit u-exec)))) 2824a2e2270fSchristos 2825a2e2270fSchristos(dnci lhcpm1 "lhcpm1" (OPTIONAL_CP_INSN) 2826a2e2270fSchristos "lhcpm1 $crn,($rma+),$cdisp10a2" 2827a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x5) (f-ext62 #x3) cdisp10a2) 2828a2e2270fSchristos (sequence () 2829a2e2270fSchristos (c-call "check_option_cp" pc) 2830a2e2270fSchristos (set crn (ext SI (mem HI (and rma (inv SI 1))))) 2831a2e2270fSchristos (set rma (mod1 cdisp10a2))) 2832a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2833a2e2270fSchristos (unit u-exec)))) 2834a2e2270fSchristos 2835a2e2270fSchristos(dnci swcpm1 "swcpm1" (OPTIONAL_CP_INSN) 2836a2e2270fSchristos "swcpm1 $crn,($rma+),$cdisp10a4" 2837a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x2) (f-ext62 #x3) cdisp10a4) 2838a2e2270fSchristos (sequence () 2839a2e2270fSchristos (c-call "check_option_cp" pc) 2840a2e2270fSchristos (c-call VOID "check_write_to_text" (and rma (inv SI 3))) 2841a2e2270fSchristos (set (mem SI (and rma (inv SI 3))) crn) 2842a2e2270fSchristos (set rma (mod1 cdisp10a4))) 2843a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2844a2e2270fSchristos (unit u-exec)))) 2845a2e2270fSchristos 2846a2e2270fSchristos(dnci lwcpm1 "lwcpm1" (OPTIONAL_CP_INSN) 2847a2e2270fSchristos "lwcpm1 $crn,($rma+),$cdisp10a4" 2848a2e2270fSchristos (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x6) (f-ext62 #x3) cdisp10a4) 2849a2e2270fSchristos (sequence () 2850a2e2270fSchristos (c-call "check_option_cp" pc) 2851a2e2270fSchristos (set crn (ext SI (mem SI (and rma (inv SI 3))))) 2852a2e2270fSchristos (set rma (mod1 cdisp10a4))) 2853a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2854a2e2270fSchristos (unit u-exec)))) 2855a2e2270fSchristos 2856a2e2270fSchristos(dnci smcpm1 "smcpm1" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN) 2857a2e2270fSchristos "smcpm1 $crn64,($rma+),$cdisp10a8" 2858a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x3) (f-ext62 #x3) cdisp10a8) 2859a2e2270fSchristos (sequence () 2860a2e2270fSchristos (c-call "check_option_cp" pc) 2861a2e2270fSchristos (c-call "check_option_cp64" pc) 2862a2e2270fSchristos (c-call "do_smcp" rma crn64 pc) 2863a2e2270fSchristos (c-call VOID "check_write_to_text" rma) 2864a2e2270fSchristos (set rma (mod1 cdisp10a8))) 2865a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2866a2e2270fSchristos (unit u-exec)))) 2867a2e2270fSchristos 2868a2e2270fSchristos(dnci lmcpm1 "lmcpm1" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN) 2869a2e2270fSchristos "lmcpm1 $crn64,($rma+),$cdisp10a8" 2870a2e2270fSchristos (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x7) (f-ext62 #x3) cdisp10a8) 2871a2e2270fSchristos (sequence () 2872a2e2270fSchristos (c-call "check_option_cp" pc) 2873a2e2270fSchristos (c-call "check_option_cp64" pc) 2874a2e2270fSchristos (set crn64 (c-call DI "do_lmcp" rma pc)) 2875a2e2270fSchristos (set rma (mod1 cdisp10a8))) 2876a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rma)) 2877a2e2270fSchristos (unit u-exec)))) 2878a2e2270fSchristos 2879a2e2270fSchristos(dnop cp_flag "branch condition register" (all-mep-isas) h-ccr 1) 2880a2e2270fSchristos 2881a2e2270fSchristos(dnci bcpeq "branch coprocessor equal" (OPTIONAL_CP_INSN RELAXABLE) 2882a2e2270fSchristos "bcpeq $cccc,$pcrel17a2" 2883a2e2270fSchristos (+ MAJ_13 (f-rn 8) cccc (f-sub4 4) pcrel17a2) 2884a2e2270fSchristos (sequence () 2885a2e2270fSchristos (c-call "check_option_cp" pc) 2886a2e2270fSchristos (if (eq (xor cccc cp_flag) 0) 2887a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2))) 2888a2e2270fSchristos ()) 2889a2e2270fSchristos 2890a2e2270fSchristos(dnci bcpne "branch coprocessor not equal" (OPTIONAL_CP_INSN RELAXABLE) 2891a2e2270fSchristos "bcpne $cccc,$pcrel17a2" 2892a2e2270fSchristos (+ MAJ_13 (f-rn 8) cccc (f-sub4 5) pcrel17a2) 2893a2e2270fSchristos (sequence () 2894a2e2270fSchristos (c-call "check_option_cp" pc) 2895a2e2270fSchristos (if (ne (xor cccc cp_flag) 0) 2896a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2))) 2897a2e2270fSchristos ()) 2898a2e2270fSchristos 2899a2e2270fSchristos(dnci bcpat "branch coprocessor and true" (OPTIONAL_CP_INSN RELAXABLE) 2900a2e2270fSchristos "bcpat $cccc,$pcrel17a2" 2901a2e2270fSchristos (+ MAJ_13 (f-rn 8) cccc (f-sub4 6) pcrel17a2) 2902a2e2270fSchristos (sequence () 2903a2e2270fSchristos (c-call "check_option_cp" pc) 2904a2e2270fSchristos (if (ne (and cccc cp_flag) 0) 2905a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2))) 2906a2e2270fSchristos ()) 2907a2e2270fSchristos 2908a2e2270fSchristos(dnci bcpaf "branch coprocessor and false" (OPTIONAL_CP_INSN RELAXABLE) 2909a2e2270fSchristos "bcpaf $cccc,$pcrel17a2" 2910a2e2270fSchristos (+ MAJ_13 (f-rn 8) cccc (f-sub4 7) pcrel17a2) 2911a2e2270fSchristos (sequence () 2912a2e2270fSchristos (c-call "check_option_cp" pc) 2913a2e2270fSchristos (if (eq (and cccc cp_flag) 0) 2914a2e2270fSchristos (set-vliw-alignment-modified pc pcrel17a2))) 2915a2e2270fSchristos ()) 2916a2e2270fSchristos 2917a2e2270fSchristos(dnci synccp "synchronise with coprocessor" (OPTIONAL_CP_INSN) 2918a2e2270fSchristos "synccp" 2919a2e2270fSchristos (+ MAJ_7 (f-rn 0) (f-rm 2) (f-sub4 1)) 2920a2e2270fSchristos (sequence () 2921a2e2270fSchristos (c-call "check_option_cp" pc) 2922a2e2270fSchristos (unimp "synccp")) 2923a2e2270fSchristos ()) 2924a2e2270fSchristos 2925a2e2270fSchristos(dnci jsrv "jump to vliw subroutine " (OPTIONAL_CP_INSN) 2926a2e2270fSchristos "jsrv $rm" 2927a2e2270fSchristos (+ MAJ_1 (f-rn 8) rm (f-sub4 15)) 2928a2e2270fSchristos (sequence () 2929a2e2270fSchristos (cg-profile pc rm) 2930a2e2270fSchristos (c-call "check_option_cp" pc) 2931a2e2270fSchristos (core-vliw-switch 2932a2e2270fSchristos 2933a2e2270fSchristos ;; in core operating mode 2934a2e2270fSchristos (sequence () 2935a2e2270fSchristos (set lp (or (add pc 2) 1)) 2936a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc rm) 2937a2e2270fSchristos (set-psw.om 1)) ;; to VLIW operation mode 2938a2e2270fSchristos 2939a2e2270fSchristos ;; in VLIW32 operating mode 2940a2e2270fSchristos (sequence () 2941a2e2270fSchristos (set lp (or (add pc 4) 1)) 2942a2e2270fSchristos (set pc (and rm (inv 1))) 2943a2e2270fSchristos (set-psw.om 0)) ;; to core operation mode 2944a2e2270fSchristos 2945a2e2270fSchristos ;; in VLIW64 operating mode 2946a2e2270fSchristos (sequence () 2947a2e2270fSchristos (set lp (or (add pc 8) 1)) 2948a2e2270fSchristos (set pc (and rm (inv 1))) 2949a2e2270fSchristos (set-psw.om 0)))) ;; to core operation mode 2950a2e2270fSchristos ((mep (unit u-use-gpr (in usereg rm)) 2951a2e2270fSchristos (unit u-exec) 2952a2e2270fSchristos (unit u-branch)))) 2953a2e2270fSchristos 2954a2e2270fSchristos(dnci bsrv "branch to vliw subroutine" (OPTIONAL_CP_INSN) 2955a2e2270fSchristos "bsrv $pcrel24a2" 2956a2e2270fSchristos (+ MAJ_13 (f-4 1) (f-sub4 11) pcrel24a2) 2957a2e2270fSchristos (sequence () 2958a2e2270fSchristos (cg-profile pc pcrel24a2) 2959a2e2270fSchristos (c-call "check_option_cp" pc) 2960a2e2270fSchristos (core-vliw-switch 2961a2e2270fSchristos 2962a2e2270fSchristos ;; in core operating mode 2963a2e2270fSchristos (sequence () 2964a2e2270fSchristos (set lp (or (add pc 4) 1)) 2965a2e2270fSchristos (set-vliw-aliignment-modified-by-option pc pcrel24a2) 2966a2e2270fSchristos (set-psw.om 1)) ;; to VLIW operation mode 2967a2e2270fSchristos 2968a2e2270fSchristos ;; in VLIW32 operating mode 2969a2e2270fSchristos (sequence () 2970a2e2270fSchristos (set lp (or (add pc 4) 1)) 2971a2e2270fSchristos (set pc (and pcrel24a2 (inv 1))) 2972a2e2270fSchristos (set-psw.om 0)) ;; to core operation mode 2973a2e2270fSchristos 2974a2e2270fSchristos ;; in VLIW64 operating mode 2975a2e2270fSchristos (sequence () 2976a2e2270fSchristos (set lp (or (add pc 8) 1)) 2977a2e2270fSchristos (set pc (and pcrel24a2 (inv 1))) 2978a2e2270fSchristos (set-psw.om 0)))) ;; to core operation mode 2979a2e2270fSchristos ((mep (unit u-exec) 2980a2e2270fSchristos (unit u-branch)))) 2981a2e2270fSchristos 2982a2e2270fSchristos 2983a2e2270fSchristos; An instruction for test instrumentation. 2984a2e2270fSchristos; Using a reserved opcode. 2985a2e2270fSchristos 2986a2e2270fSchristos(dnci sim-syscall "simulator system call" () 2987a2e2270fSchristos "--syscall--" 2988a2e2270fSchristos (+ MAJ_7 (f-4 1) callnum (f-8 0) (f-9 0) (f-10 0) (f-sub4 0)) 2989a2e2270fSchristos (c-call "do_syscall" pc callnum) 2990a2e2270fSchristos ()) 2991a2e2270fSchristos 2992a2e2270fSchristos(define-pmacro (dnri n major minor) 2993a2e2270fSchristos (dnci (.sym ri- n) "reserved instruction" () 2994a2e2270fSchristos "--reserved--" 2995a2e2270fSchristos (+ major rn rm (f-sub4 minor)) 2996a2e2270fSchristos (set pc (c-call USI "ri_exception" pc)) 2997a2e2270fSchristos ((mep (unit u-exec) 2998a2e2270fSchristos (unit u-branch))))) 2999a2e2270fSchristos 3000a2e2270fSchristos(dnri 0 MAJ_0 6) 3001a2e2270fSchristos(dnri 1 MAJ_1 10) 3002a2e2270fSchristos(dnri 2 MAJ_1 11) 3003a2e2270fSchristos(dnri 3 MAJ_2 5) 3004a2e2270fSchristos(dnri 4 MAJ_2 8) 3005a2e2270fSchristos(dnri 5 MAJ_2 9) 3006a2e2270fSchristos(dnri 6 MAJ_2 10) 3007a2e2270fSchristos(dnri 7 MAJ_2 11) 3008a2e2270fSchristos(dnri 8 MAJ_3 4) 3009a2e2270fSchristos(dnri 9 MAJ_3 5) 3010a2e2270fSchristos(dnri 10 MAJ_3 6) 3011a2e2270fSchristos(dnri 11 MAJ_3 7) 3012a2e2270fSchristos(dnri 12 MAJ_3 12) 3013a2e2270fSchristos(dnri 13 MAJ_3 13) 3014a2e2270fSchristos(dnri 14 MAJ_3 14) 3015a2e2270fSchristos(dnri 15 MAJ_3 15) 3016a2e2270fSchristos(dnri 17 MAJ_7 7) 3017a2e2270fSchristos(dnri 20 MAJ_7 14) 3018a2e2270fSchristos(dnri 21 MAJ_7 15) 3019a2e2270fSchristos(dnri 22 MAJ_12 7) 3020a2e2270fSchristos(dnri 23 MAJ_14 13) 3021a2e2270fSchristos;(dnri 24 MAJ_15 3) 3022a2e2270fSchristos(dnri 26 MAJ_15 8) 3023a2e2270fSchristos; begin core-specific reserved insns 3024a2e2270fSchristos; end core-specific reserved insns 3025a2e2270fSchristos 3026a2e2270fSchristos 3027a2e2270fSchristos; Macro instructions. 3028a2e2270fSchristos 3029a2e2270fSchristos(dnmi nop "nop" 3030a2e2270fSchristos () 3031a2e2270fSchristos "nop" 3032a2e2270fSchristos (emit mov (rn 0) (rm 0))) 3033a2e2270fSchristos 3034a2e2270fSchristos; Emit the 16 bit form of these 32 bit insns when the displacement is zero. 3035a2e2270fSchristos; 3036a2e2270fSchristos(dncmi sb16-0 "store byte (explicit 16 bit displacement of zero)" (NO-DIS) 3037a2e2270fSchristos "sb $rnc,$zero($rma)" 3038a2e2270fSchristos (emit sb rnc rma)) 3039a2e2270fSchristos 3040a2e2270fSchristos(dncmi sh16-0 "store half (explicit 16 bit displacement of zero)" (NO-DIS) 3041a2e2270fSchristos "sh $rns,$zero($rma)" 3042a2e2270fSchristos (emit sh rns rma)) 3043a2e2270fSchristos 3044a2e2270fSchristos(dncmi sw16-0 "store word (explicit 16 bit displacement of zero)" (NO-DIS) 3045a2e2270fSchristos "sw $rnl,$zero($rma)" 3046a2e2270fSchristos (emit sw rnl rma)) 3047a2e2270fSchristos 3048a2e2270fSchristos(dncmi lb16-0 "load byte (explicit 16 bit displacement of zero)" (NO-DIS) 3049a2e2270fSchristos "lb $rnc,$zero($rma)" 3050a2e2270fSchristos (emit lb rnc rma)) 3051a2e2270fSchristos 3052a2e2270fSchristos(dncmi lh16-0 "load half (explicit 16 bit displacement of zero)" (NO-DIS) 3053a2e2270fSchristos "lh $rns,$zero($rma)" 3054a2e2270fSchristos (emit lh rns rma)) 3055a2e2270fSchristos 3056a2e2270fSchristos(dncmi lw16-0 "load word (explicit 16 bit displacement of zero)" (NO-DIS) 3057a2e2270fSchristos "lw $rnl,$zero($rma)" 3058a2e2270fSchristos (emit lw rnl rma)) 3059a2e2270fSchristos 3060a2e2270fSchristos(dncmi lbu16-0 "load unsigned byte (explicit 16 bit displacement of zero)" (NO-DIS) 3061a2e2270fSchristos "lbu $rnuc,$zero($rma)" 3062a2e2270fSchristos (emit lbu rnuc rma)) 3063a2e2270fSchristos 3064a2e2270fSchristos(dncmi lhu16-0 "load unsigned half (explicit 16 bit displacement of zero)" (NO-DIS) 3065a2e2270fSchristos "lhu $rnus,$zero($rma)" 3066a2e2270fSchristos (emit lhu rnus rma)) 3067a2e2270fSchristos 3068a2e2270fSchristos(dncmi swcp16-0 "swcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN NO-DIS) 3069a2e2270fSchristos "swcp $crn,$zero($rma)" 3070a2e2270fSchristos (emit swcp crn rma)) 3071a2e2270fSchristos 3072a2e2270fSchristos(dncmi lwcp16-0 "lwcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN NO-DIS) 3073a2e2270fSchristos "lwcp $crn,$zero($rma)" 3074a2e2270fSchristos (emit lwcp crn rma)) 3075a2e2270fSchristos 3076a2e2270fSchristos(dncmi smcp16-0 "smcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN NO-DIS) 3077a2e2270fSchristos "smcp $crn64,$zero($rma)" 3078a2e2270fSchristos (emit smcp crn64 rma)) 3079a2e2270fSchristos 3080a2e2270fSchristos(dncmi lmcp16-0 "lmcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN NO-DIS) 3081a2e2270fSchristos "lmcp $crn64,$zero($rma)" 3082a2e2270fSchristos (emit lmcp crn64 rma)) 3083