1 ; Toshiba MeP Media Engine architecture description. -*- Scheme -*-
2 ; Copyright 2011 Free Software Foundation, Inc.
4 ; Contributed by Red Hat Inc;
6 ; This file is part of the GNU Binutils.
8 ; This program is free software; you can redistribute it and/or modify
9 ; it under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation; either version 3 of the License, or
11 ; (at your option) any later version.
13 ; This program is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with this program; if not, write to the Free Software
20 ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 (include "simplify.inc")
25 (define-pmacro isa-enum ()
28 ext_core1 ext_cop1_16 ext_cop1_32 ext_cop1_48 ext_cop1_64
35 (comment "Toshiba MeP Media Engine")
36 (insn-lsb0? #f) ;; work around cgen limitation
43 (comment "MeP core instruction set")
44 (default-insn-word-bitsize 32)
45 (default-insn-bitsize 32)
46 (base-insn-bitsize 32)
52 (comment "MeP core extension instruction set")
53 (default-insn-word-bitsize 32)
54 (default-insn-bitsize 32)
55 (base-insn-bitsize 32)
60 (comment "MeP coprocessor instruction set")
61 (default-insn-word-bitsize 32)
62 (default-insn-bitsize 32)
63 (base-insn-bitsize 32)
68 (comment "MeP coprocessor instruction set")
69 (default-insn-word-bitsize 32)
70 (default-insn-bitsize 32)
71 (base-insn-bitsize 32)
76 (comment "MeP coprocessor instruction set")
77 (default-insn-word-bitsize 32)
78 (default-insn-bitsize 32)
79 (base-insn-bitsize 32)
84 (comment "MeP coprocessor instruction set")
85 (default-insn-word-bitsize 32)
86 (default-insn-bitsize 32)
87 (base-insn-bitsize 32)
90 (define-pmacro all-mep-isas () (ISA mep,ext_core1,ext_cop1_16,ext_cop1_32,ext_cop1_48,ext_cop1_64))
92 (define-pmacro all-mep-core-isas () (ISA mep,ext_core1,ext_cop1_32))
94 (define-pmacro all-core-isa-list () mep,ext_core1)
99 (comment "MeP family")
101 (insn-chunk-bitsize 16)
107 (comment "MeP media engine")
114 (comment "H1 media engine")
121 (comment "C5 media engine")
128 (comment "MeP media engine processor")
129 (mach c5) ; mach gets changed by MeP-Integrator
131 (unit u-exec "execution unit" ()
136 (unit u-branch "Branch Unit" ()
141 () ; profile action (default)
145 (unit u-multiply "Multiply Unit" ()
150 () ; profile action (default)
154 (unit u-divide "Divide Unit" ()
159 () ; profile action (default)
163 (unit u-stcb "stcb Unit" ()
168 () ; profile action (default)
172 (unit u-ldcb "ldcb Unit" ()
177 () ; profile action (default)
181 (unit u-load-gpr "Load into GPR Unit" ()
185 ((loadreg INT -1)) ; outputs
186 () ; profile action (default)
189 (unit u-ldcb-gpr "Ldcb into GPR Unit" ()
193 ((loadreg INT -1)) ; outputs
194 () ; profile action (default)
197 ; Multiply into GPR unit
198 (unit u-mul-gpr "Multiply into GPR Unit" ()
202 ((resultreg INT -1)) ; outputs
203 () ; profile action (default)
206 ; Use gpr unit -- stalls if GPR not ready
207 (unit u-use-gpr "Use GPR Unit" ()
210 ((usereg INT -1)) ; inputs
212 () ; profile action (default)
215 ; Use ctrl-reg unit -- stalls if CTRL-REG not ready
216 (unit u-use-ctrl-reg "Use CTRL-REG Unit" ()
219 ((usereg INT -1)) ; inputs
221 () ; profile action (default)
224 ; Store ctrl-reg unit -- stalls if CTRL-REG not ready
225 (unit u-store-ctrl-reg "Store CTRL-REG Unit" ()
229 ((storereg INT -1)) ; outputs
230 () ; profile action (default)
236 (dnh h-pc "program counter" (PC PROFILE all-mep-isas) (pc) () () ())
240 (comment "General purpose registers")
241 (attrs all-mep-isas CACHE-ADDR PROFILE)
242 (type register SI (16))
244 (("0" 0) ("1" 1) ("2" 2) ("3" 3) ("4" 4) ("5" 5)
245 ("6" 6) ("7" 7) ("8" 8) ("9" 9) ("10" 10) ("11" 11)
246 ; "$8" is the preferred name for register 8, but "$tp", "$gp"
247 ; and "$sp" are preferred for their respective registers.
248 (fp 8) (tp 13) (gp 14) (sp 15)
249 ("12" 12) ("13" 13) ("14" 14) ("15" 15)))
254 (comment "Control/special registers")
255 (attrs all-mep-isas PROFILE)
256 (type register SI (32))
258 ((pc 0) (lp 1) (sar 2) (rpb 4) (rpe 5) (rpc 6)
259 (hi 7) (lo 8) (mb0 12) (me0 13) (mb1 14) (me1 15)
260 (psw 16) (id 17) (tmp 18) (epc 19) (exc 20) (cfg 21)
261 (npc 23) (dbg 24) (depc 25) (opt 26) (rcfg 27) (ccfg 28)
262 ; begin-extra-csr-registers
264 ; end-extra-csr-registers
266 (get (index) (c-call SI "cgen_get_csr_value" index))
267 (set (index newval) (c-call VOID "cgen_set_csr_value" index newval))
270 (define-pmacro (-reg-pair n) ((.sym n) n))
273 (comment "64-bit coprocessor registers")
275 ; This assumes that the data path of the co-pro is 64 bits.
276 (type register DI (32))
277 (indices keyword "$c" (.map -reg-pair (.iota 32)))
278 (set (index newval) (c-call VOID "h_cr64_queue_set" index newval))
282 (comment "64-bit coprocessor registers, pending writes")
284 ; This assumes that the data path of the co-pro is 64 bits.
285 (type register DI (32))
290 (comment "32-bit coprocessor registers")
291 (attrs all-mep-isas VIRTUAL)
292 (type register SI (32))
293 (indices keyword "$c" (.map -reg-pair (.iota 32)))
294 (set (index newval) (c-call VOID "h_cr64_set" index (ext DI newval)))
295 (get (index) (trunc SI (c-call DI "h_cr64_get" index)))
298 ;; Given a coprocessor control register number N, expand to a
299 ;; name/index pair: ($ccrN N)
300 (define-pmacro (-ccr-reg-pair n) ((.sym "$ccr" n) n))
304 (comment "Coprocessor control registers")
306 (type register SI (64))
307 (indices keyword "" (.map -ccr-reg-pair (.iota 64)))
308 (set (index newval) (c-call VOID "h_ccr_queue_set" index newval))
312 (comment "Coprocessor control registers, pending writes")
314 (type register SI (64))
318 ; Instruction fields. Bit numbering reversed.
322 ; N = number of bits in value
323 ; A = alignment (2 or 4, omit for 1)
324 ; B = leftmost (i.e. closest to zero) bit position
326 ; -- Generic Fields (f-*) --
327 ; N number of bits in *value* (1-24)
328 ; [us] signed vs unsigned
329 ; B position of left-most bit (4-16)
330 ; aA opt. alignment (2=drop 1 lsb, 4=drop 2 lsbs, etc)
331 ; n opt. for noncontiguous fields
332 ; f-foo-{hi,lo} msb/lsb parts of field f-foo
335 ; pcrelNaA PC-relative branch target (signed)
336 ; pcabsNaA Absolute branch target (unsigned)
338 ; [us]dispNaA [un]signed displacement
339 ; [us]immN [un]signed immediate value
340 ; addrNaA absolute address (unsigned)
342 ; Additional prefixes may be used for special cases.
344 (dnf f-major "major opcode" (all-mep-core-isas) 0 4)
346 (dnf f-rn "register n" (all-mep-core-isas) 4 4)
347 (dnf f-rn3 "register 0-7" (all-mep-core-isas) 5 3)
348 (dnf f-rm "register m" (all-mep-core-isas) 8 4)
349 (dnf f-rl "register l" (all-mep-core-isas) 12 4)
350 (dnf f-sub2 "sub opcode (2 bits)" (all-mep-core-isas) 14 2)
351 (dnf f-sub3 "sub opcode (3 bits)" (all-mep-core-isas) 13 3)
352 (dnf f-sub4 "sub opcode (4 bits)" (all-mep-core-isas) 12 4)
353 (dnf f-ext "extended field" (all-mep-core-isas) 16 8)
354 (dnf f-ext4 "extended field 16:4" (all-mep-core-isas) 16 4)
355 (dnf f-ext62 "extended field 20:2" (all-mep-core-isas) 20 2)
356 (dnf f-crn "copro register n" (all-mep-core-isas) 4 4)
358 (df f-csrn-hi "cr hi 1u15" (all-mep-core-isas) 15 1 UINT #f #f)
359 (df f-csrn-lo "cr lo 4u8" (all-mep-core-isas) 8 4 UINT #f #f)
362 (comment "control reg")
363 (attrs all-mep-core-isas)
365 (subfields f-csrn-hi f-csrn-lo)
367 (set (ifield f-csrn-lo) (and (ifield f-csrn) #xf))
368 (set (ifield f-csrn-hi) (srl (ifield f-csrn) 4))))
369 (extract (set (ifield f-csrn)
370 (or (sll (ifield f-csrn-hi) 4) (ifield f-csrn-lo))))
373 (df f-crnx-hi "crx hi 1u28" (all-mep-core-isas) 28 1 UINT #f #f)
374 (df f-crnx-lo "crx lo 4u4" (all-mep-core-isas) 4 4 UINT #f #f)
377 (comment "copro register n (0-31)")
378 (attrs all-mep-core-isas)
380 (subfields f-crnx-hi f-crnx-lo)
382 (set (ifield f-crnx-lo) (and (ifield f-crnx) #xf))
383 (set (ifield f-crnx-hi) (srl (ifield f-crnx) 4))))
384 (extract (set (ifield f-crnx)
385 (or (sll (ifield f-crnx-hi) 4) (ifield f-crnx-lo))))
388 ; Miscellaneous fields.
390 (define-pmacro (dnfb n)
391 (dnf (.sym f- n) (.str "bit " n) (all-mep-isas) n 1))
393 ; Define small fields used throughout the instruction set description.
394 ; Each field (eg. `f-N') is at single bit field at position N.
429 ; Branch/Jump target addresses
431 (df f-8s8a2 "pc-rel addr (8 bits)" (all-mep-core-isas PCREL-ADDR) 8 7 INT
432 ((value pc) (sra SI (sub SI value pc) 1))
433 ((value pc) (add SI (mul SI value 2) pc)))
435 (df f-12s4a2 "pc-rel addr (12 bits)" (all-mep-core-isas PCREL-ADDR) 4 11 INT
436 ((value pc) (sra SI (sub SI value pc) 1))
437 ((value pc) (add SI (mul SI value 2) pc)))
439 (df f-17s16a2 "pc-rel addr (17 bits)" (all-mep-core-isas PCREL-ADDR) 16 16 INT
440 ((value pc) (sra SI (sub SI value pc) 1))
441 ((value pc) (add SI (mul SI value 2) pc)))
443 (df f-24s5a2n-hi "24s5a2n hi 16s16" (all-mep-core-isas PCREL-ADDR) 16 16 INT #f #f)
444 (df f-24s5a2n-lo "24s5a2n lo 7s5a2" (all-mep-core-isas PCREL-ADDR) 5 7 UINT #f #f)
447 (comment "pc-rel addr (24 bits align 2)")
448 (attrs all-mep-core-isas PCREL-ADDR)
450 (subfields f-24s5a2n-hi f-24s5a2n-lo)
452 (set (ifield f-24s5a2n)
453 (sub (ifield f-24s5a2n) pc))
454 (set (ifield f-24s5a2n-lo)
455 (srl (and (ifield f-24s5a2n) #xfe) 1))
456 (set (ifield f-24s5a2n-hi)
457 (sra INT (ifield f-24s5a2n) 8))))
458 (extract (set (ifield f-24s5a2n)
459 (add SI (or (mul (ifield f-24s5a2n-hi) 256)
460 (sll (ifield f-24s5a2n-lo) 1))
464 (df f-24u5a2n-hi "24u5a2n hi 16u16" (all-mep-core-isas) 16 16 UINT #f #f)
465 (df f-24u5a2n-lo "24u5a2n lo 7u5a2" (all-mep-core-isas) 5 7 UINT #f #f)
468 (comment "abs jump target (24 bits, alignment 2)")
469 (attrs all-mep-core-isas ABS-ADDR)
471 (subfields f-24u5a2n-hi f-24u5a2n-lo)
473 (set (ifield f-24u5a2n-lo)
474 (srl (and (ifield f-24u5a2n) #xff) 1))
475 (set (ifield f-24u5a2n-hi)
476 (srl (ifield f-24u5a2n) 8))
478 (extract (set (ifield f-24u5a2n)
479 (or (sll (ifield f-24u5a2n-hi) 8)
480 (sll (ifield f-24u5a2n-lo) 1))))
483 ; Displacement fields.
485 (df f-2u6 "SAR offset (2 bits)" (all-mep-core-isas) 6 2 UINT #f #f)
486 (df f-7u9 "tp-rel b (7 bits)" (all-mep-core-isas) 9 7 UINT #f #f)
487 (df f-7u9a2 "tp-rel h (7 bits)" (all-mep-core-isas) 9 6 UINT
488 ((value pc) (srl SI value 1))
489 ((value pc) (mul SI value 2)))
490 (df f-7u9a4 "tp/sp-rel w (7 bits)" (all-mep-core-isas) 9 5 UINT
491 ((value pc) (srl SI value 2))
492 ((value pc) (sll SI value 2)))
493 (df f-16s16 "general 16-bit s-val" (all-mep-core-isas) 16 16 INT #f #f)
497 (df f-2u10 "swi level (2 bits)" (all-mep-core-isas) 10 2 UINT #f #f)
498 (df f-3u5 "bit offset (3 bits)" (all-mep-core-isas) 5 3 UINT #f #f)
499 (df f-4u8 "bCC const (4 bits)" (all-mep-core-isas) 8 4 UINT #f #f)
500 (df f-5u8 "slt & shifts (5 bits)" (all-mep-core-isas) 8 5 UINT #f #f)
501 (df f-5u24 "clip immediate (5 bits)" (all-mep-core-isas) 24 5 UINT #f #f)
502 (df f-6s8 "add immediate (6 bits)" (all-mep-core-isas) 8 6 INT #f #f)
503 (df f-8s8 "add imm (8 bits)" (all-mep-core-isas) 8 8 INT #f #f)
504 (df f-16u16 "general 16-bit u-val" (all-mep-core-isas) 16 16 UINT #f #f)
505 (df f-12u16 "cmov fixed 1" (all-mep-core-isas) 16 12 UINT #f #f)
506 (df f-3u29 "cmov fixed 2" (all-mep-core-isas) 29 3 UINT #f #f)
509 ; These are all for the coprocessor opcodes
511 ; The field is like IJKiiiiiii where I and J are toggled if K is set,
512 ; for compatibility with older cores.
513 (define-pmacro (compute-cdisp10 val)
515 ((and SI (cond SI ((and SI val #x80) (xor SI val #x300)) (else val)) #x200)
516 (sub (cond SI ((and SI val #x80) (xor SI val #x300)) (else val)) #x400))
518 (cond SI ((and SI val #x80) (xor SI val #x300)) (else val)))
521 (define-pmacro (extend-cdisp10 val)
523 ((and SI (compute-cdisp10 val) #x200)
524 (sub (and SI (compute-cdisp10 val) #x3ff) #x400))
526 (and SI (compute-cdisp10 val) #x3ff))
530 (df f-cdisp10 "cop imm10" (all-mep-core-isas) 22 10 INT
531 ((value pc) (extend-cdisp10 value))
532 ((value pc) (extend-cdisp10 value))
535 ; Non-contiguous fields.
537 (df f-24u8a4n-hi "24u8a4n hi 16u16" (all-mep-core-isas) 16 16 UINT #f #f)
538 (df f-24u8a4n-lo "24u8a4n lo 8u8a4" (all-mep-core-isas) 8 6 UINT #f #f)
541 (comment "absolute 24-bit address")
542 (attrs all-mep-core-isas)
544 (subfields f-24u8a4n-hi f-24u8a4n-lo)
546 (set (ifield f-24u8a4n-hi) (srl (ifield f-24u8a4n) 8))
547 (set (ifield f-24u8a4n-lo) (srl (and (ifield f-24u8a4n) #xfc) 2))))
548 (extract (set (ifield f-24u8a4n)
549 (or (sll (ifield f-24u8a4n-hi) 8)
550 (sll (ifield f-24u8a4n-lo) 2))))
553 (df f-24u8n-hi "24u8n hi 16u16" (all-mep-core-isas) 16 16 UINT #f #f)
554 (df f-24u8n-lo "24u8n lo 8u8" (all-mep-core-isas) 8 8 UINT #f #f)
557 (comment "24-bit constant")
558 (attrs all-mep-core-isas)
560 (subfields f-24u8n-hi f-24u8n-lo)
562 (set (ifield f-24u8n-hi) (srl (ifield f-24u8n) 8))
563 (set (ifield f-24u8n-lo) (and (ifield f-24u8n) #xff))))
564 (extract (set (ifield f-24u8n)
565 (or (sll (ifield f-24u8n-hi) 8)
566 (ifield f-24u8n-lo))))
569 (df f-24u4n-hi "24u4n hi 8u4" (all-mep-core-isas) 4 8 UINT #f #f)
570 (df f-24u4n-lo "24u4n lo 16u16" (all-mep-core-isas) 16 16 UINT #f #f)
573 (comment "coprocessor code")
574 (attrs all-mep-core-isas)
576 (subfields f-24u4n-hi f-24u4n-lo)
578 (set (ifield f-24u4n-hi) (srl (ifield f-24u4n) 16))
579 (set (ifield f-24u4n-lo) (and (ifield f-24u4n) #xffff))))
580 (extract (set (ifield f-24u4n)
581 (or (sll (ifield f-24u4n-hi) 16)
582 (ifield f-24u4n-lo))))
587 (comment "system call number field")
588 (attrs all-mep-core-isas)
590 (subfields f-5 f-6 f-7 f-11)
592 (set (ifield f-5) (and (srl (ifield f-callnum) 3) 1))
593 (set (ifield f-6) (and (srl (ifield f-callnum) 2) 1))
594 (set (ifield f-7) (and (srl (ifield f-callnum) 1) 1))
595 (set (ifield f-11) (and (ifield f-callnum) 1))))
596 (extract (set (ifield f-callnum)
597 (or (sll (ifield f-5) 3)
598 (or (sll (ifield f-6) 2)
599 (or (sll (ifield f-7) 1)
603 (df f-ccrn-hi "ccrn hi 2u28" (all-mep-core-isas) 28 2 UINT #f #f)
604 (df f-ccrn-lo "ccrn lo 4u4" (all-mep-core-isas) 4 4 UINT #f #f)
607 (comment "Coprocessor register number field")
608 (attrs all-mep-core-isas)
610 (subfields f-ccrn-hi f-ccrn-lo)
612 (set (ifield f-ccrn-hi) (and (srl (ifield f-ccrn) 4) #x3))
613 (set (ifield f-ccrn-lo) (and (ifield f-ccrn) #xf))))
614 (extract (set (ifield f-ccrn)
615 (or (sll (ifield f-ccrn-hi) 4)
616 (ifield f-ccrn-lo))))
621 ;; Only LABEL, REGNUM, FMAX_FLOAT and FMAX_INT are now relevant for correct
622 ;; operation. The others are mostly kept for backwards compatibility,
623 ;; although they do affect the dummy prototypes in
624 ;; gcc/config/mep/intrinsics.h.
629 (comment "datatype to use for C intrinsics mapping")
630 (values LABEL REGNUM FMAX_FLOAT FMAX_INT
631 POINTER LONG ULONG SHORT USHORT CHAR UCHAR CP_DATA_BUS_INT)
638 (comment "datatype to use for coprocessor values")
639 (values CP_DATA_BUS_INT VECT V2SI V4HI V8QI V2USI V4UHI V8UQI)
640 (default CP_DATA_BUS_INT))
646 ;; VOID - all arguments are passed as parameters; if any are written, pointers to them are passed.
647 ;; FIRST - the first argument is the return value.
648 ;; FIRSTCOPY - the first argument is the return value, but a copy is also the first parameter.
649 (values VOID FIRST FIRSTCOPY)
651 (comment "Insn's intrinsic returns void, or the first argument rather than (or in addition to) passing it."))
657 (comment "alignment of immediate operands")
663 (name RELOC_IMPLIES_OVERFLOW)
664 (comment "Operand should not be considered as a candidate for relocs"))
670 (comment "Register contains a floating point value"))
672 (define-pmacro (dpop name commment attrib hwr field func)
673 (define-full-operand name comment attrib
674 hwr DFLT field ((parse func)) () ()))
675 (define-pmacro (dprp name commment attrib hwr field pafunc prfunc)
676 (define-full-operand name comment attrib
677 hwr DFLT field ((parse pafunc) (print prfunc)) () ()))
679 (dnop r0 "register 0" (all-mep-core-isas) h-gpr 0)
680 (dnop rn "register Rn" (all-mep-core-isas) h-gpr f-rn)
681 (dnop rm "register Rm" (all-mep-core-isas) h-gpr f-rm)
682 (dnop rl "register Rl" (all-mep-core-isas) h-gpr f-rl)
683 (dnop rn3 "register 0-7" (all-mep-core-isas) h-gpr f-rn3)
685 ;; Variants of RM/RN with different CDATA attributes. See comment above
686 ;; CDATA for more details.
688 (dnop rma "register Rm holding pointer" (all-mep-core-isas (CDATA POINTER)) h-gpr f-rm)
690 (dnop rnc "register Rn holding char" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn)
691 (dnop rnuc "register Rn holding unsigned char" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn)
692 (dnop rns "register Rn holding short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn)
693 (dnop rnus "register Rn holding unsigned short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn)
694 (dnop rnl "register Rn holding long" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn)
695 (dnop rnul "register Rn holding unsigned long" (all-mep-core-isas (CDATA ULONG)) h-gpr f-rn)
697 (dnop rn3c "register 0-7 holding unsigned char" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3)
698 (dnop rn3uc "register 0-7 holding byte" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3)
699 (dnop rn3s "register 0-7 holding unsigned short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3)
700 (dnop rn3us "register 0-7 holding short" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3)
701 (dnop rn3l "register 0-7 holding unsigned long" (all-mep-core-isas (CDATA LONG)) h-gpr f-rn3)
702 (dnop rn3ul "register 0-7 holding long" (all-mep-core-isas (CDATA ULONG)) h-gpr f-rn3)
705 (dnop lp "link pointer" (all-mep-core-isas) h-csr 1)
706 (dnop sar "shift amount register" (all-mep-core-isas) h-csr 2)
707 (dnop hi "high result" (all-mep-core-isas) h-csr 7)
708 (dnop lo "low result" (all-mep-core-isas) h-csr 8)
709 (dnop mb0 "modulo begin register 0" (all-mep-core-isas) h-csr 12)
710 (dnop me0 "modulo end register 0" (all-mep-core-isas) h-csr 13)
711 (dnop mb1 "modulo begin register 1" (all-mep-core-isas) h-csr 14)
712 (dnop me1 "modulo end register 1" (all-mep-core-isas) h-csr 15)
713 (dnop psw "program status word" (all-mep-core-isas) h-csr 16)
714 (dnop epc "exception prog counter" (all-mep-core-isas) h-csr 19)
715 (dnop exc "exception cause" (all-mep-core-isas) h-csr 20)
716 (dnop npc "nmi program counter" (all-mep-core-isas) h-csr 23)
717 (dnop dbg "debug register" (all-mep-core-isas) h-csr 24)
718 (dnop depc "debug exception pc" (all-mep-core-isas) h-csr 25)
719 (dnop opt "option register" (all-mep-core-isas) h-csr 26)
720 (dnop r1 "register 1" (all-mep-core-isas) h-gpr 1)
721 (dnop tp "tiny data area pointer" (all-mep-core-isas) h-gpr 13)
722 (dnop sp "stack pointer" (all-mep-core-isas) h-gpr 15)
723 (dprp tpr "TP register" (all-mep-core-isas) h-gpr 13 "tpreg" "tpreg")
724 (dprp spr "SP register" (all-mep-core-isas) h-gpr 15 "spreg" "spreg")
727 csrn "control/special register" (all-mep-core-isas (CDATA REGNUM)) h-csr
728 DFLT f-csrn ((parse "csrn")) () ()
731 (dnop csrn-idx "control/special reg idx" (all-mep-core-isas) h-uint f-csrn)
732 (dnop crn64 "copro Rn (64-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr64 f-crn)
733 (dnop crn "copro Rn (32-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr f-crn)
734 (dnop crnx64 "copro Rn (0-31, 64-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr64 f-crnx)
735 (dnop crnx "copro Rn (0-31, 32-bit)" (all-mep-core-isas (CDATA CP_DATA_BUS_INT)) h-cr f-crnx)
736 (dnop ccrn "copro control reg CCRn" (all-mep-core-isas (CDATA REGNUM)) h-ccr f-ccrn)
737 (dnop cccc "copro flags" (all-mep-core-isas) h-uint f-rm)
739 (dprp pcrel8a2 "pc-rel addr (8 bits)" (all-mep-core-isas (CDATA LABEL) RELAX) h-sint f-8s8a2 "mep_align" "address")
740 (dprp pcrel12a2 "pc-rel addr (12 bits)" (all-mep-core-isas (CDATA LABEL) RELAX) h-sint f-12s4a2 "mep_align" "address")
741 (dprp pcrel17a2 "pc-rel addr (17 bits)" (all-mep-core-isas (CDATA LABEL) RELAX) h-sint f-17s16a2 "mep_align" "address")
742 (dprp pcrel24a2 "pc-rel addr (24 bits)" (all-mep-core-isas (CDATA LABEL)) h-sint f-24s5a2n "mep_align" "address")
743 (dprp pcabs24a2 "pc-abs addr (24 bits)" (all-mep-core-isas (CDATA LABEL)) h-uint f-24u5a2n "mep_alignu" "address")
745 (dpop sdisp16 "displacement (16 bits)" (all-mep-core-isas) h-sint f-16s16 "signed16")
746 (dpop simm16 "signed imm (16 bits)" (all-mep-core-isas) h-sint f-16s16 "signed16")
747 (dpop uimm16 "unsigned imm (16 bits)" (all-mep-core-isas) h-uint f-16u16 "unsigned16")
748 (dnop code16 "uci/dsp code (16 bits)" (all-mep-core-isas) h-uint f-16u16)
750 (dnop udisp2 "SSARB addend (2 bits)" (all-mep-core-isas) h-sint f-2u6)
751 (dnop uimm2 "interrupt (2 bits)" (all-mep-core-isas) h-uint f-2u10)
753 (dnop simm6 "add const (6 bits)" (all-mep-core-isas) h-sint f-6s8)
754 (dnop simm8 "mov const (8 bits)" (all-mep-core-isas RELOC_IMPLIES_OVERFLOW)
757 (dpop addr24a4 "sw/lw addr (24 bits)" (all-mep-core-isas (ALIGN 4)) h-uint f-24u8a4n "mep_alignu")
758 (dnop code24 "coprocessor code" (all-mep-core-isas) h-uint f-24u4n)
760 (dnop callnum "system call number" (all-mep-core-isas) h-uint f-callnum)
761 (dnop uimm3 "bit immediate (3 bits)" (all-mep-core-isas) h-uint f-3u5)
762 (dnop uimm4 "bCC const (4 bits)" (all-mep-core-isas) h-uint f-4u8)
763 (dnop uimm5 "bit/shift val (5 bits)" (all-mep-core-isas) h-uint f-5u8)
765 (dpop udisp7 "tp-rel b (7 bits)" (all-mep-core-isas) h-uint f-7u9 "unsigned7")
766 (dpop udisp7a2 "tp-rel h (7 bits)" (all-mep-core-isas (ALIGN 2)) h-uint f-7u9a2 "unsigned7")
767 (dpop udisp7a4 "tp/sp-rel w (7 bits)" (all-mep-core-isas (ALIGN 4)) h-uint f-7u9a4 "unsigned7")
768 (dpop uimm7a4 "sp w-addend (7 bits)" (all-mep-core-isas (ALIGN 4)) h-uint f-7u9a4 "mep_alignu")
770 (dnop uimm24 "immediate (24 bits)" (all-mep-core-isas) h-uint f-24u8n)
772 (dnop cimm4 "cache immed'te (4 bits)" (all-mep-core-isas) h-uint f-rn)
773 (dnop cimm5 "clip immediate (5 bits)" (all-mep-core-isas) h-uint f-5u24)
775 (dpop cdisp10 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10")
776 (dpop cdisp10a2 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10")
777 (dpop cdisp10a4 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10")
778 (dpop cdisp10a8 "copro addend (8/10 bits)" (all-mep-core-isas) h-sint f-cdisp10 "cdisp10")
780 ; Special operand representing the various ways that the literal zero can be
783 zero "Zero operand" (all-mep-core-isas) h-sint DFLT f-nil
784 ((parse "zero")) () ()
792 (name OPTIONAL_BIT_INSN)
793 (comment "optional bit manipulation instruction"))
798 (name OPTIONAL_MUL_INSN)
799 (comment "optional 32-bit multiply instruction"))
804 (name OPTIONAL_DIV_INSN)
805 (comment "optional 32-bit divide instruction"))
810 (name OPTIONAL_DEBUG_INSN)
811 (comment "optional debug instruction"))
816 (name OPTIONAL_LDZ_INSN)
817 (comment "optional leading zeroes instruction"))
822 (name OPTIONAL_ABS_INSN)
823 (comment "optional absolute difference instruction"))
828 (name OPTIONAL_AVE_INSN)
829 (comment "optional average instruction"))
834 (name OPTIONAL_MINMAX_INSN)
835 (comment "optional min/max instruction"))
840 (name OPTIONAL_CLIP_INSN)
841 (comment "optional clipping instruction"))
846 (name OPTIONAL_SAT_INSN)
847 (comment "optional saturation instruction"))
852 (name OPTIONAL_UCI_INSN)
853 (comment "optional UCI instruction"))
858 (name OPTIONAL_DSP_INSN)
859 (comment "optional DSP instruction"))
864 (name OPTIONAL_CP_INSN)
865 (comment "optional coprocessor-related instruction"))
870 (name OPTIONAL_CP64_INSN)
871 (comment "optional coprocessor-related 64 data bit instruction"))
876 (name OPTIONAL_VLIW64)
877 (comment "optional vliw64 mode (vliw32 is default)"))
884 (values NONE SHIFTI INT2 LOAD STORE LDC STC LDCB STCB SSARB FSFT RET
887 (comment "gcc stall attribute"))
894 (comment "gcc intrinsic name"))
901 (values NONE C3 V1 V3 P0S P0 P1)
903 (comment "coprocessor slot type"))
909 (comment "instruction may generate an exception"))
911 ; Attributes for scheduling restrictions in vliw mode
917 (comment "instruction can be scheduled alone in vliw mode"))
922 (name VLIW_NO_CORE_NOP)
923 (comment "there is no corresponding nop core instruction"))
928 (name VLIW_NO_COP_NOP)
929 (comment "there is no corresponding nop coprocessor instruction"))
934 (name VLIW64_NO_MATCHING_NOP)
935 (comment "there is no corresponding nop coprocessor instruction"))
939 (name VLIW32_NO_MATCHING_NOP)
940 (comment "there is no corresponding nop coprocessor instruction"))
946 (comment "Insn is volatile."))
952 (comment "The latency of this insn, used for scheduling as an intrinsic in gcc")
955 ; The MeP config tool will edit this.
960 (values NONE ; config-attr-start
968 (define-normal-insn-enum major "major opcodes" (all-mep-core-isas) MAJ_
970 (.map .str (.iota 16))
974 (define-pmacro (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming isa)
978 (.splice attrs (.unsplice xattrs) (ISA isa))
981 (semantics xsemantics)
982 (.splice timing (.unsplice xtiming))
986 (define-pmacro (dnmi-isa xname xcomment xattrs xsyntax xemit isa)
987 (dnmi xname xcomment (.splice (.unsplice xattrs) (ISA isa)) xsyntax xemit)
990 ; For making profiling calls and dynamic configuration
991 (define-pmacro (cg-profile caller callee)
992 (c-call "cg_profile" caller callee)
994 ; For dynamic configuration only
995 (define-pmacro (cg-profile-jump caller callee)
996 (c-call "cg_profile_jump" caller callee)
999 ; For defining Core Instructions
1000 (define-pmacro (dnci xname xcomment xattrs xsyntax xformat xsemantics xtiming)
1001 (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming all-core-isa-list)
1003 (define-pmacro (dncmi xname xcomment xattrs xsyntax xemit)
1004 (dnmi-isa xname xcomment xattrs xsyntax xemit all-core-isa-list)
1007 ; For defining Coprocessor Instructions
1008 ;(define-pmacro (dncpi xname xcomment xattrs xsyntax xformat xsemantics xtiming) (dni-isa xname xcomment xattrs xsyntax xformat xsemantics xtiming cop)
1011 ;; flag setting macro
1012 (define-pmacro (set-bit xop xbitnum xval)
1014 (and xop (inv (sll 1 xbitnum)))
1015 (and (sll 1 xbitnum) (sll xval xbitnum)))))
1017 ;; some flags we commonly use in vliw reasoning / mode-switching etc.
1018 (define-pmacro (get-opt.vliw64) (and (srl opt 6) 1))
1019 (define-pmacro (get-opt.vliw32) (and (srl opt 5) 1))
1020 (define-pmacro (get-rm.lsb) (and rm 1))
1021 (define-pmacro (get-psw.om) (and (srl psw 12) 1))
1022 (define-pmacro (get-psw.nmi) (and (srl psw 9) 1))
1023 (define-pmacro (get-psw.iep) (and (srl psw 1) 1))
1024 (define-pmacro (get-psw.ump) (and (srl psw 3) 1))
1025 (define-pmacro (get-epc.etom) (and epc 1))
1026 (define-pmacro (get-npc.ntom) (and npc 1))
1027 (define-pmacro (get-lp.ltom) (and lp 1))
1029 (define-pmacro (set-psw.om zval) (set-bit (raw-reg h-csr 16) 12 zval))
1030 (define-pmacro (set-psw.nmi zval) (set-bit (raw-reg h-csr 16) 9 zval))
1031 (define-pmacro (set-psw.umc zval) (set-bit (raw-reg h-csr 16) 2 zval))
1032 (define-pmacro (set-psw.iec zval) (set-bit (raw-reg h-csr 16) 0 zval))
1033 (define-pmacro (set-rpe.elr zval) (set-bit (raw-reg h-csr 5) 0 zval))
1036 ;; the "3 way switch" depending on our current operating mode and vliw status flags
1037 (define-pmacro (core-vliw-switch core-rtl vliw32-rtl vliw64-rtl)
1039 ((andif (get-psw.om) (get-opt.vliw64)) vliw64-rtl)
1040 ((andif (get-psw.om) (get-opt.vliw32)) vliw32-rtl)
1043 ;; the varying-pcrel idiom
1044 (define-pmacro (set-vliw-modified-pcrel-offset xtarg xa xb xc)
1045 (core-vliw-switch (set xtarg (add pc xa))
1046 (set xtarg (add pc xb))
1047 (set xtarg (add pc xc))))
1049 ;; the increasing-alignment idiom in branch displacements
1050 (define-pmacro (set-vliw-alignment-modified xtarg zaddr)
1051 (core-vliw-switch (set xtarg (and zaddr (inv 1)))
1052 (set xtarg (and zaddr (inv 3)))
1053 (set xtarg (and zaddr (inv 7)))))
1055 ;; the increasing-alignment idiom in option-only form
1056 (define-pmacro (set-vliw-aliignment-modified-by-option xtarg zaddr)
1057 (if (get-opt.vliw32)
1058 (set xtarg (and zaddr (inv 3)))
1059 (set xtarg (and zaddr (inv 7)))))
1063 ; pmacros needed for coprocessor modulo addressing.
1065 ; Taken from supplement ``The operation of the modulo addressing'' in
1066 ; Toshiba documentation rev 2.2, p. 34.
1068 (define-pmacro (compute-mask0)
1069 (sequence SI ((SI temp))
1070 (set temp (or mb0 me0))
1071 (srl (const SI -1) (c-call SI "do_ldz" temp))))
1073 (define-pmacro (mod0 immed)
1074 (sequence SI ((SI modulo-mask))
1075 (set modulo-mask (compute-mask0))
1076 (if SI (eq (and rma modulo-mask) me0)
1077 (or (and rma (inv modulo-mask)) mb0)
1078 (add rma (ext SI immed)))))
1080 (define-pmacro (compute-mask1)
1081 (sequence SI ((SI temp))
1082 (set temp (or mb1 me1))
1083 (srl (const SI -1) (c-call SI "do_ldz" temp))))
1085 (define-pmacro (mod1 immed)
1086 (sequence SI ((SI modulo-mask))
1087 (set modulo-mask (compute-mask1))
1088 (if SI (eq (and rma modulo-mask) me1)
1089 (or (and rma (inv modulo-mask)) mb1)
1090 (add rma (ext SI immed)))))
1095 ; A pmacro for use in semantic bodies of unimplemented insns.
1096 (define-pmacro (unimp mnemonic) (nop))
1098 ; Core specific instructions
1099 ; (include "mep-h1.cpu") ; -- exposed by MeP-Integrator
1100 (include "mep-c5.cpu") ; -- exposed by MeP-Integrator
1102 ; Load/store instructions.
1104 (dnci sb "store byte (register indirect)" ((STALL STORE))
1106 (+ MAJ_0 rnc rma (f-sub4 8))
1108 (c-call VOID "check_write_to_text" rma)
1109 (set (mem UQI rma) (and rnc #xff)))
1110 ((mep (unit u-use-gpr (in usereg rnc))
1111 (unit u-use-gpr (in usereg rma))
1114 (dnci sh "store half-word (register indirect)" ((STALL STORE))
1116 (+ MAJ_0 rns rma (f-sub4 9))
1118 (c-call VOID "check_write_to_text" (and rma (inv 1)))
1119 (set (mem UHI (and rma (inv 1))) (and rns #xffff)))
1120 ((mep (unit u-use-gpr (in usereg rns))
1121 (unit u-use-gpr (in usereg rma))
1124 (dnci sw "store word (register indirect)" ((STALL STORE))
1126 (+ MAJ_0 rnl rma (f-sub4 10))
1128 (c-call VOID "check_write_to_text" (and rma (inv 3)))
1129 (set (mem USI (and rma (inv 3))) rnl))
1130 ((mep (unit u-use-gpr (in usereg rnl))
1131 (unit u-use-gpr (in usereg rma))
1134 (dnci lb "load byte (register indirect)" ((STALL LOAD) (LATENCY 2))
1136 (+ MAJ_0 rnc rma (f-sub4 12))
1137 (set rnc (ext SI (mem QI rma)))
1138 ((mep (unit u-use-gpr (in usereg rma))
1140 (unit u-load-gpr (out loadreg rnc)))))
1142 (dnci lh "load half-word (register indirect)" ((STALL LOAD) (LATENCY 2))
1144 (+ MAJ_0 rns rma (f-sub4 13))
1145 (set rns (ext SI (mem HI (and rma (inv 1)))))
1146 ((mep (unit u-use-gpr (in usereg rma))
1148 (unit u-load-gpr (out loadreg rns)))))
1150 (dnci lw "load word (register indirect)" ((STALL LOAD) (LATENCY 2))
1152 (+ MAJ_0 rnl rma (f-sub4 14))
1153 (set rnl (mem SI (and rma (inv 3))))
1154 ((mep (unit u-use-gpr (in usereg rma))
1156 (unit u-load-gpr (out loadreg rnl)))))
1158 (dnci lbu "load unsigned byte (register indirect)" ((STALL LOAD) (LATENCY 2))
1160 (+ MAJ_0 rnuc rma (f-sub4 11))
1161 (set rnuc (zext SI (mem UQI rma)))
1162 ((mep (unit u-use-gpr (in usereg rma))
1164 (unit u-load-gpr (out loadreg rnuc)))))
1166 (dnci lhu "load unsigned half-word (register indirect)" ((STALL LOAD) (LATENCY 2))
1168 (+ MAJ_0 rnus rma (f-sub4 15))
1169 (set rnus (zext SI (mem UHI (and rma (inv 1)))))
1170 ((mep (unit u-use-gpr (in usereg rma))
1172 (unit u-load-gpr (out loadreg rnus)))))
1174 (dnci sw-sp "store word (sp relative)" ((STALL STORE))
1175 "sw $rnl,$udisp7a4($spr)"
1176 (+ MAJ_4 rnl (f-8 0) udisp7a4 (f-sub2 2))
1178 (c-call VOID "check_write_to_text" (and (add udisp7a4 sp) (inv 3)))
1179 (set (mem SI (and (add udisp7a4 sp) (inv 3))) rnl))
1180 ((mep (unit u-use-gpr (in usereg rnl))
1181 (unit u-use-gpr (in usereg sp))
1185 (dnci lw-sp "load word (sp relative)" ((STALL LOAD) (LATENCY 2))
1186 "lw $rnl,$udisp7a4($spr)"
1187 (+ MAJ_4 rnl (f-8 0) udisp7a4 (f-sub2 3))
1188 (set rnl (mem SI (and (add udisp7a4 sp) (inv 3))))
1189 ((mep (unit u-use-gpr (in usereg sp))
1191 (unit u-load-gpr (out loadreg rnl)))))
1193 (dnci sb-tp "store byte (tp relative)" ((STALL STORE))
1194 "sb $rn3c,$udisp7($tpr)"
1195 (+ MAJ_8 (f-4 0) rn3c (f-8 0) udisp7)
1197 (c-call VOID "check_write_to_text" (add (zext SI udisp7) tp))
1198 (set (mem QI (add (zext SI udisp7) tp)) (and rn3c #xff)))
1199 ((mep (unit u-use-gpr (in usereg rn3c))
1200 (unit u-use-gpr (in usereg tp))
1203 (dnci sh-tp "store half-word (tp relative)" ((STALL STORE))
1204 "sh $rn3s,$udisp7a2($tpr)"
1205 (+ MAJ_8 (f-4 0) rn3s (f-8 1) udisp7a2 (f-15 0))
1207 (c-call VOID "check_write_to_text" (and (add (zext SI udisp7a2) tp) (inv 1)))
1208 (set (mem HI (and (add (zext SI udisp7a2) tp) (inv 1))) (and rn3s #xffff)))
1209 ((mep (unit u-use-gpr (in usereg rn3s))
1210 (unit u-use-gpr (in usereg tp))
1213 (dnci sw-tp "store word (tp relative)" ((STALL STORE))
1214 "sw $rn3l,$udisp7a4($tpr)"
1215 (+ MAJ_4 (f-4 0) rn3l (f-8 1) udisp7a4 (f-sub2 2))
1217 (c-call VOID "check_write_to_text" (and (add (zext SI udisp7a4) tp) (inv 3)))
1218 (set (mem SI (and (add (zext SI udisp7a4) tp) (inv 3))) rn3l))
1219 ((mep (unit u-use-gpr (in usereg rn3l))
1220 (unit u-use-gpr (in usereg tp))
1223 (dnci lb-tp "load byte (tp relative)" ((STALL LOAD) (LATENCY 2))
1224 "lb $rn3c,$udisp7($tpr)"
1225 (+ MAJ_8 (f-4 1) rn3c (f-8 0) udisp7)
1226 (set rn3c (ext SI (mem QI (add (zext SI udisp7) tp))))
1227 ((mep (unit u-use-gpr (in usereg tp))
1229 (unit u-load-gpr (out loadreg rn3c)))))
1231 (dnci lh-tp "load half-word (tp relative)" ((STALL LOAD) (LATENCY 2))
1232 "lh $rn3s,$udisp7a2($tpr)"
1233 (+ MAJ_8 (f-4 1) rn3s (f-8 1) udisp7a2 (f-15 0))
1234 (set rn3s (ext SI (mem HI (and (add (zext SI udisp7a2) tp) (inv 1)))))
1235 ((mep (unit u-use-gpr (in usereg tp))
1237 (unit u-load-gpr (out loadreg rn3s)))))
1239 (dnci lw-tp "load word (tp relative)" ((STALL LOAD) (LATENCY 2))
1240 "lw $rn3l,$udisp7a4($tpr)"
1241 (+ MAJ_4 (f-4 0) rn3l (f-8 1) udisp7a4 (f-sub2 3))
1242 (set rn3l (mem SI (and (add (zext SI udisp7a4) tp) (inv 3))))
1243 ((mep (unit u-use-gpr (in usereg tp))
1245 (unit u-load-gpr (out loadreg rn3l)))))
1247 (dnci lbu-tp "load unsigned byte (tp relative)" ((STALL LOAD) (LATENCY 2))
1248 "lbu $rn3uc,$udisp7($tpr)"
1249 (+ MAJ_4 (f-4 1) rn3uc (f-8 1) udisp7)
1250 (set rn3uc (zext SI (mem QI (add (zext SI udisp7) tp))))
1251 ((mep (unit u-use-gpr (in usereg tp))
1253 (unit u-load-gpr (out loadreg rn3uc)))))
1255 (dnci lhu-tp "load unsigned half-word (tp relative)" ((STALL LOAD) (LATENCY 2))
1256 "lhu $rn3us,$udisp7a2($tpr)"
1257 (+ MAJ_8 (f-4 1) rn3us (f-8 1) udisp7a2 (f-15 1))
1258 (set rn3us (zext SI (mem HI (and (add (zext SI udisp7a2) tp) (inv 1)))))
1259 ((mep (unit u-use-gpr (in usereg tp))
1261 (unit u-load-gpr (out loadreg rn3us)))))
1263 (dnci sb16 "store byte (16 bit displacement)" ((STALL STORE))
1264 "sb $rnc,$sdisp16($rma)"
1265 (+ MAJ_12 rnc rma (f-sub4 8) sdisp16)
1267 (c-call VOID "check_write_to_text" (add rma (ext SI sdisp16)))
1268 (set (mem QI (add rma (ext SI sdisp16))) (and rnc #xff)))
1269 ((mep (unit u-use-gpr (in usereg rnc))
1270 (unit u-use-gpr (in usereg rma))
1273 (dnci sh16 "store half-word (16 bit displacement)" ((STALL STORE))
1274 "sh $rns,$sdisp16($rma)"
1275 (+ MAJ_12 rns rma (f-sub4 9) sdisp16)
1277 (c-call VOID "check_write_to_text" (and (add rma (ext SI sdisp16)) (inv 1)))
1278 (set (mem HI (and (add rma (ext SI sdisp16)) (inv 1))) (and rns #xffff)))
1279 ((mep (unit u-use-gpr (in usereg rns))
1280 (unit u-use-gpr (in usereg rma))
1283 (dnci sw16 "store word (16 bit displacement)" ((STALL STORE))
1284 "sw $rnl,$sdisp16($rma)"
1285 (+ MAJ_12 rnl rma (f-sub4 10) sdisp16)
1287 (c-call "check_write_to_text" (and (add rma (ext SI sdisp16)) (inv 3)))
1288 (set (mem SI (and (add rma (ext SI sdisp16)) (inv 3))) rnl))
1289 ((mep (unit u-use-gpr (in usereg rnl))
1290 (unit u-use-gpr (in usereg rma))
1293 (dnci lb16 "load byte (16 bit displacement)" ((STALL LOAD) (LATENCY 2))
1294 "lb $rnc,$sdisp16($rma)"
1295 (+ MAJ_12 rnc rma (f-sub4 12) sdisp16)
1296 (set rnc (ext SI (mem QI (add rma (ext SI sdisp16)))))
1297 ((mep (unit u-use-gpr (in usereg rma))
1299 (unit u-load-gpr (out loadreg rnc)))))
1301 (dnci lh16 "load half-word (16 bit displacement)" ((STALL LOAD) (LATENCY 2))
1302 "lh $rns,$sdisp16($rma)"
1303 (+ MAJ_12 rns rma (f-sub4 13) sdisp16)
1304 (set rns (ext SI (mem HI (and (add rma (ext SI sdisp16)) (inv 1)))))
1305 ((mep (unit u-use-gpr (in usereg rma))
1307 (unit u-load-gpr (out loadreg rns)))))
1309 (dnci lw16 "load word (16 bit displacement)" ((STALL LOAD) (LATENCY 2))
1310 "lw $rnl,$sdisp16($rma)"
1311 (+ MAJ_12 rnl rma (f-sub4 14) sdisp16)
1312 (set rnl (mem SI (and (add rma (ext SI sdisp16)) (inv 3))))
1313 ((mep (unit u-use-gpr (in usereg rma))
1315 (unit u-load-gpr (out loadreg rnl)))))
1317 (dnci lbu16 "load unsigned byte (16 bit displacement)" ((STALL LOAD) (LATENCY 2))
1318 "lbu $rnuc,$sdisp16($rma)"
1319 (+ MAJ_12 rnuc rma (f-sub4 11) sdisp16)
1320 (set rnuc (zext SI (mem QI (add rma (ext SI sdisp16)))))
1321 ((mep (unit u-use-gpr (in usereg rma))
1323 (unit u-load-gpr (out loadreg rnuc)))))
1325 (dnci lhu16 "load unsigned half-word (16 bit displacement)" ((STALL LOAD) (LATENCY 2))
1326 "lhu $rnus,$sdisp16($rma)"
1327 (+ MAJ_12 rnus rma (f-sub4 15) sdisp16)
1328 (set rnus (zext SI (mem HI (and (add rma (ext SI sdisp16)) (inv 1)))))
1329 ((mep (unit u-use-gpr (in usereg rma))
1331 (unit u-load-gpr (out loadreg rnus)))))
1333 (dnci sw24 "store word (24 bit absolute addressing)" ((STALL STORE))
1334 "sw $rnl,($addr24a4)"
1335 (+ MAJ_14 rnl addr24a4 (f-sub2 2))
1337 (c-call VOID "check_write_to_text" (zext SI addr24a4))
1338 (set (mem SI (zext SI addr24a4)) rnl))
1339 ((mep (unit u-use-gpr (in usereg rnl))
1342 (dnci lw24 "load word (24 bit absolute addressing)" ((STALL LOAD) (LATENCY 2))
1343 "lw $rnl,($addr24a4)"
1344 (+ MAJ_14 rnl addr24a4 (f-sub2 3))
1345 (set rnl (mem SI (zext SI addr24a4)))
1347 (unit u-load-gpr (out loadreg rnl)))))
1350 ; Extension instructions.
1352 (dnci extb "sign extend byte" ()
1354 (+ MAJ_1 rn (f-rm 0) (f-sub4 13))
1355 (set rn (ext SI (and QI rn #xff)))
1356 ((mep (unit u-use-gpr (in usereg rn))
1359 (dnci exth "sign extend half-word" ()
1361 (+ MAJ_1 rn (f-rm 2) (f-sub4 13))
1362 (set rn (ext SI (and HI rn #xffff)))
1363 ((mep (unit u-use-gpr (in usereg rn))
1366 (dnci extub "zero extend byte" ()
1368 (+ MAJ_1 rn (f-rm 8) (f-sub4 13))
1369 (set rn (zext SI (and rn #xff)))
1370 ((mep (unit u-use-gpr (in usereg rn))
1373 (dnci extuh "zero extend half-word" ()
1375 (+ MAJ_1 rn (f-rm 10) (f-sub4 13))
1376 (set rn (zext SI (and rn #xffff)))
1377 ((mep (unit u-use-gpr (in usereg rn))
1381 ; Shift amount manipulation instructions.
1383 (dnci ssarb "set sar to bytes" ((STALL SSARB) VOLATILE)
1384 "ssarb $udisp2($rm)"
1385 (+ MAJ_1 (f-4 0) (f-5 0) udisp2 rm (f-sub4 12))
1386 (if (c-call BI "big_endian_p")
1387 (set sar (zext SI (mul (and (add udisp2 rm) 3) 8)))
1388 (set sar (sub 32 (zext SI (mul (and (add udisp2 rm) 3) 8)))))
1389 ((mep (unit u-use-gpr (in usereg rm))
1393 ; Move instructions.
1397 (+ MAJ_0 rn rm (f-sub4 0))
1399 ((mep (unit u-use-gpr (in usereg rm))
1402 (dnci movi8 "move 8-bit immediate" ()
1405 (set rn (ext SI simm8))
1408 (dnci movi16 "move 16-bit immediate" ()
1410 (+ MAJ_12 rn (f-rm 0) (f-sub4 1) simm16)
1411 (set rn (ext SI simm16))
1414 (dnci movu24 "move 24-bit unsigned immediate" ()
1416 (+ MAJ_13 (f-4 0) rn3 uimm24)
1417 (set rn3 (zext SI uimm24))
1420 (dnci movu16 "move 16-bit unsigned immediate" ()
1422 (+ MAJ_12 rn (f-rm 1) (f-sub4 1) uimm16)
1423 (set rn (zext SI uimm16))
1426 (dnci movh "move high 16-bit immediate" ()
1428 (+ MAJ_12 rn (f-rm 2) (f-sub4 1) uimm16)
1429 (set rn (sll uimm16 16))
1433 ; Arithmetic instructions.
1435 (dnci add3 "add three registers" ()
1438 (set rl (add rn rm))
1439 ((mep (unit u-use-gpr (in usereg rn))
1440 (unit u-use-gpr (in usereg rm))
1445 (+ MAJ_6 rn simm6 (f-sub2 0))
1446 (set rn (add rn (ext SI simm6)))
1447 ((mep (unit u-use-gpr (in usereg rn))
1450 (dnci add3i "add two registers and immediate" ()
1451 "add3 $rn,$spr,$uimm7a4"
1452 (+ MAJ_4 rn (f-8 0) uimm7a4 (f-sub2 0))
1453 (set rn (add sp (zext SI uimm7a4)))
1454 ((mep (unit u-use-gpr (in usereg sp))
1457 (dnci advck3 "add overflow check" ((STALL ADVCK))
1458 "advck3 \\$0,$rn,$rm"
1459 (+ MAJ_0 rn rm (f-sub4 7))
1460 (if (add-oflag rn rm 0)
1463 ((mep (unit u-use-gpr (in usereg rn))
1464 (unit u-use-gpr (in usereg rm))
1467 (dnci sub "subtract" ()
1469 (+ MAJ_0 rn rm (f-sub4 4))
1470 (set rn (sub rn rm))
1471 ((mep (unit u-use-gpr (in usereg rn))
1472 (unit u-use-gpr (in usereg rm)))))
1474 (dnci sbvck3 "subtraction overflow check" ((STALL ADVCK))
1475 "sbvck3 \\$0,$rn,$rm"
1476 (+ MAJ_0 rn rm (f-sub4 5))
1477 (if (sub-oflag rn rm 0)
1480 ((mep (unit u-use-gpr (in usereg rn))
1481 (unit u-use-gpr (in usereg rm))
1484 (dnci neg "negate" ()
1486 (+ MAJ_0 rn rm (f-sub4 1))
1488 ((mep (unit u-use-gpr (in usereg rm))
1491 (dnci slt3 "set if less than" ()
1493 (+ MAJ_0 rn rm (f-sub4 2))
1497 ((mep (unit u-use-gpr (in usereg rn))
1498 (unit u-use-gpr (in usereg rm))
1501 (dnci sltu3 "set less than unsigned" ()
1502 "sltu3 \\$0,$rn,$rm"
1503 (+ MAJ_0 rn rm (f-sub4 3))
1507 ((mep (unit u-use-gpr (in usereg rn))
1508 (unit u-use-gpr (in usereg rm))
1511 (dnci slt3i "set if less than immediate" ()
1512 "slt3 \\$0,$rn,$uimm5"
1513 (+ MAJ_6 rn uimm5 (f-sub3 1))
1514 (if (lt rn (zext SI uimm5))
1517 ((mep (unit u-use-gpr (in usereg rn))
1520 (dnci sltu3i "set if less than unsigned immediate" ()
1521 "sltu3 \\$0,$rn,$uimm5"
1522 (+ MAJ_6 rn uimm5 (f-sub3 5))
1523 (if (ltu rn (zext SI uimm5))
1528 (dnci sl1ad3 "shift left one and add" ((STALL INT2))
1529 "sl1ad3 \\$0,$rn,$rm"
1530 (+ MAJ_2 rn rm (f-sub4 6))
1531 (set r0 (add (sll rn 1) rm))
1532 ((mep (unit u-use-gpr (in usereg rn))
1533 (unit u-use-gpr (in usereg rm))
1536 (dnci sl2ad3 "shift left two and add" ((STALL INT2))
1537 "sl2ad3 \\$0,$rn,$rm"
1538 (+ MAJ_2 rn rm (f-sub4 7))
1539 (set r0 (add (sll rn 2) rm))
1540 ((mep (unit u-use-gpr (in usereg rn))
1541 (unit u-use-gpr (in usereg rm))
1544 (dnci add3x "three operand add (extended)" ()
1545 "add3 $rn,$rm,$simm16"
1546 (+ MAJ_12 rn rm (f-sub4 0) simm16)
1547 (set rn (add rm (ext SI simm16)))
1548 ((mep (unit u-use-gpr (in usereg rm))
1551 (dnci slt3x "set if less than (extended)" ()
1552 "slt3 $rn,$rm,$simm16"
1553 (+ MAJ_12 rn rm (f-sub4 2) simm16)
1554 (if (lt rm (ext SI simm16))
1557 ((mep (unit u-use-gpr (in usereg rm))
1560 (dnci sltu3x "set if less than unsigned (extended)" ()
1561 "sltu3 $rn,$rm,$uimm16"
1562 (+ MAJ_12 rn rm (f-sub4 3) uimm16)
1563 (if (ltu rm (zext SI uimm16))
1566 ((mep (unit u-use-gpr (in usereg rm))
1570 ; Logical instructions.
1572 (dnci or "bitwise or" ()
1574 (+ MAJ_1 rn rm (f-sub4 0))
1576 ((mep (unit u-use-gpr (in usereg rn))
1577 (unit u-use-gpr (in usereg rm))
1580 (dnci and "bitwise and" ()
1582 (+ MAJ_1 rn rm (f-sub4 1))
1583 (set rn (and rn rm))
1584 ((mep (unit u-use-gpr (in usereg rn))
1585 (unit u-use-gpr (in usereg rm))
1588 (dnci xor "bitwise exclusive or" ()
1590 (+ MAJ_1 rn rm (f-sub4 2))
1591 (set rn (xor rn rm))
1592 ((mep (unit u-use-gpr (in usereg rn))
1593 (unit u-use-gpr (in usereg rm))
1596 (dnci nor "bitwise negated or" ()
1598 (+ MAJ_1 rn rm (f-sub4 3))
1599 (set rn (inv (or rn rm)))
1600 ((mep (unit u-use-gpr (in usereg rn))
1601 (unit u-use-gpr (in usereg rm))
1604 (dnci or3 "or three operand" ()
1605 "or3 $rn,$rm,$uimm16"
1606 (+ MAJ_12 rn rm (f-sub4 4) uimm16)
1607 (set rn (or rm (zext SI uimm16)))
1608 ((mep (unit u-use-gpr (in usereg rm))
1611 (dnci and3 "and three operand" ()
1612 "and3 $rn,$rm,$uimm16"
1613 (+ MAJ_12 rn rm (f-sub4 5) uimm16)
1614 (set rn (and rm (zext SI uimm16)))
1615 ((mep (unit u-use-gpr (in usereg rm))
1618 (dnci xor3 "exclusive or three operand" ()
1619 "xor3 $rn,$rm,$uimm16"
1620 (+ MAJ_12 rn rm (f-sub4 6) uimm16)
1621 (set rn (xor rm (zext SI uimm16)))
1622 ((mep (unit u-use-gpr (in usereg rm))
1626 ; Shift instructions.
1628 (dnci sra "shift right arithmetic" ((STALL INT2))
1630 (+ MAJ_2 rn rm (f-sub4 13))
1631 (set rn (sra rn (and rm #x1f)))
1632 ((mep (unit u-use-gpr (in usereg rn))
1633 (unit u-use-gpr (in usereg rm))
1636 (dnci srl "shift right logical" ((STALL INT2))
1638 (+ MAJ_2 rn rm (f-sub4 12))
1639 (set rn (srl rn (and rm #x1f)))
1640 ((mep (unit u-use-gpr (in usereg rn))
1641 (unit u-use-gpr (in usereg rm))
1644 (dnci sll "shift left logical" ((STALL INT2))
1646 (+ MAJ_2 rn rm (f-sub4 14))
1647 (set rn (sll rn (and rm #x1f)))
1648 ((mep (unit u-use-gpr (in usereg rn))
1649 (unit u-use-gpr (in usereg rm))
1652 (dnci srai "shift right arithmetic (immediate)" ((STALL SHIFTI))
1654 (+ MAJ_6 rn uimm5 (f-sub3 3))
1655 (set rn (sra rn uimm5))
1656 ((mep (unit u-use-gpr (in usereg rn))
1659 (dnci srli "shift right logical (immediate)" ((STALL SHIFTI))
1661 (+ MAJ_6 rn uimm5 (f-sub3 2))
1662 (set rn (srl rn uimm5))
1663 ((mep (unit u-use-gpr (in usereg rn))
1666 (dnci slli "shift left logical (immediate)" ((STALL SHIFTI))
1668 (+ MAJ_6 rn uimm5 (f-sub3 6))
1669 (set rn (sll rn uimm5))
1670 ((mep (unit u-use-gpr (in usereg rn))
1673 (dnci sll3 "three-register shift left logical" ((STALL INT2))
1674 "sll3 \\$0,$rn,$uimm5"
1675 (+ MAJ_6 rn uimm5 (f-sub3 7))
1676 (set r0 (sll rn uimm5))
1677 ((mep (unit u-use-gpr (in usereg rn))
1680 (dnci fsft "field shift" ((STALL FSFT) VOLATILE)
1682 (+ MAJ_2 rn rm (f-sub4 15))
1683 (sequence ((DI temp) (QI shamt))
1684 (set shamt (and sar #x3f))
1685 (set temp (sll (or (sll (zext DI rn) 32) (zext DI rm)) shamt))
1686 (set rn (subword SI (srl temp 32) 1)))
1687 ((mep (unit u-use-gpr (in usereg rn))
1688 (unit u-use-gpr (in usereg rm))
1692 ; Branch/jump instructions.
1694 (dnci bra "branch" (RELAXABLE)
1696 (+ MAJ_11 pcrel12a2 (f-15 0))
1697 (set-vliw-alignment-modified pc pcrel12a2)
1698 ((mep (unit u-branch)
1701 (dnci beqz "branch if equal zero" (RELAXABLE)
1702 "beqz $rn,$pcrel8a2"
1703 (+ MAJ_10 rn pcrel8a2 (f-15 0))
1705 (set-vliw-alignment-modified pc pcrel8a2))
1706 ((mep (unit u-use-gpr (in usereg rn))
1710 (dnci bnez "branch if not equal zero" (RELAXABLE)
1711 "bnez $rn,$pcrel8a2"
1712 (+ MAJ_10 rn pcrel8a2 (f-15 1))
1714 (set-vliw-alignment-modified pc pcrel8a2))
1715 ((mep (unit u-use-gpr (in usereg rn))
1719 (dnci beqi "branch equal immediate" (RELAXABLE)
1720 "beqi $rn,$uimm4,$pcrel17a2"
1721 (+ MAJ_14 rn uimm4 (f-sub4 0) pcrel17a2)
1722 (if (eq rn (zext SI uimm4))
1723 (set-vliw-alignment-modified pc pcrel17a2))
1724 ((mep (unit u-use-gpr (in usereg rn))
1728 (dnci bnei "branch not equal immediate" (RELAXABLE)
1729 "bnei $rn,$uimm4,$pcrel17a2"
1730 (+ MAJ_14 rn uimm4 (f-sub4 4) pcrel17a2)
1731 (if (ne rn (zext SI uimm4))
1732 (set-vliw-alignment-modified pc pcrel17a2))
1733 ((mep (unit u-use-gpr (in usereg rn))
1737 (dnci blti "branch less than immediate" (RELAXABLE)
1738 "blti $rn,$uimm4,$pcrel17a2"
1739 (+ MAJ_14 rn uimm4 (f-sub4 12) pcrel17a2)
1740 (if (lt rn (zext SI uimm4))
1741 (set-vliw-alignment-modified pc pcrel17a2))
1742 ((mep (unit u-use-gpr (in usereg rn))
1746 (dnci bgei "branch greater than immediate" (RELAXABLE)
1747 "bgei $rn,$uimm4,$pcrel17a2"
1748 (+ MAJ_14 rn uimm4 (f-sub4 8) pcrel17a2)
1749 (if (ge rn (zext SI uimm4))
1750 (set-vliw-alignment-modified pc pcrel17a2))
1751 ((mep (unit u-use-gpr (in usereg rn))
1755 (dnci beq "branch equal" ()
1756 "beq $rn,$rm,$pcrel17a2"
1757 (+ MAJ_14 rn rm (f-sub4 1) pcrel17a2)
1759 (set-vliw-alignment-modified pc pcrel17a2))
1760 ((mep (unit u-use-gpr (in usereg rn))
1761 (unit u-use-gpr (in usereg rm))
1765 (dnci bne "branch not equal" ()
1766 "bne $rn,$rm,$pcrel17a2"
1767 (+ MAJ_14 rn rm (f-sub4 5) pcrel17a2)
1769 (set-vliw-alignment-modified pc pcrel17a2))
1770 ((mep (unit u-use-gpr (in usereg rn))
1771 (unit u-use-gpr (in usereg rm))
1775 (dnci bsr12 "branch to subroutine (12 bit displacement)" (RELAXABLE)
1777 (+ MAJ_11 pcrel12a2 (f-15 1))
1779 (cg-profile pc pcrel12a2)
1780 (set-vliw-modified-pcrel-offset lp 2 4 8)
1781 (set-vliw-alignment-modified pc pcrel12a2))
1785 (dnci bsr24 "branch to subroutine (24 bit displacement)" ()
1787 (+ MAJ_13 (f-4 1) (f-sub4 9) pcrel24a2)
1789 (cg-profile pc pcrel24a2)
1790 (set-vliw-modified-pcrel-offset lp 4 4 8)
1791 (set-vliw-alignment-modified pc pcrel24a2))
1797 (+ MAJ_1 (f-rn 0) rm (f-sub4 14))
1799 (if (eq (get-psw.om) 0)
1803 (set-psw.om 1) ;; enter VLIW mode
1804 (set-vliw-aliignment-modified-by-option pc rm))
1805 (set pc (and rm (inv 1))))
1809 (set-psw.om 0) ;; enter core mode
1810 (set pc (and rm (inv 1))))
1811 (set-vliw-aliignment-modified-by-option pc rm)))
1812 (cg-profile-jump pc rm))
1813 ((mep (unit u-use-gpr (in usereg rm))
1817 (dnci jmp24 "jump (24 bit target)" ()
1819 (+ MAJ_13 (f-4 1) (f-sub4 8) pcabs24a2)
1821 (set-vliw-alignment-modified pc (or (and pc #xf0000000) pcabs24a2))
1822 (cg-profile-jump pc pcabs24a2))
1826 (dnci jsr "jump to subroutine" ()
1828 (+ MAJ_1 (f-rn 0) rm (f-sub4 15))
1831 (set-vliw-modified-pcrel-offset lp 2 4 8)
1832 (set-vliw-alignment-modified pc rm))
1833 ((mep (unit u-use-gpr (in usereg rm))
1837 (dnci ret "return from subroutine" ((STALL RET))
1839 (+ MAJ_7 (f-rn 0) (f-rm 0) (f-sub4 2))
1841 (if (eq (get-psw.om) 0)
1843 (if (get-lp.ltom) ;; link-pointer "toggle mode" bit
1845 (set-psw.om 1) ;; enter VLIW mode
1846 (set-vliw-aliignment-modified-by-option pc lp))
1847 (set pc (and lp (inv 1))))
1849 (if (get-lp.ltom) ;; link-pointer "toggle mode" bit
1851 (set-psw.om 0) ;; enter VLIW mode
1852 (set pc (and lp (inv 1))))
1853 (set-vliw-aliignment-modified-by-option pc lp)))
1854 (c-call VOID "notify_ret" pc))
1859 ; Repeat instructions.
1861 (dnci repeat "repeat specified repeat block" ()
1862 "repeat $rn,$pcrel17a2"
1863 (+ MAJ_14 rn (f-rm 0) (f-sub4 9) pcrel17a2)
1865 (set-vliw-modified-pcrel-offset (reg h-csr 4) 4 4 8)
1866 (set-vliw-alignment-modified (reg h-csr 5) pcrel17a2)
1867 (set (reg h-csr 6) rn))
1868 ((mep (unit u-use-gpr (in usereg rn))
1871 (dnci erepeat "endless repeat" ()
1872 "erepeat $pcrel17a2"
1873 (+ MAJ_14 (f-rn 0) (f-rm 1) (f-sub4 9) pcrel17a2)
1875 (set-vliw-modified-pcrel-offset (reg h-csr 4) 4 4 8)
1876 (set-vliw-alignment-modified (reg h-csr 5) pcrel17a2)
1878 ; rpc may be undefined for erepeat
1879 ; use 1 to trigger repeat logic in the sim's main loop
1880 (set (reg h-csr 6) 1))
1884 ; Control instructions.
1886 ;; special store variants
1888 (dnci stc_lp "store to control register lp" ((STALL STC))
1890 (+ MAJ_7 rn (f-csrn-lo 1) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 0))
1892 ((mep (unit u-use-gpr (in usereg rn))
1893 (unit u-store-ctrl-reg (out storereg lp))
1896 (dnci stc_hi "store to control register hi" ((STALL STC))
1898 (+ MAJ_7 rn (f-csrn-lo 7) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 0))
1900 ((mep (unit u-use-gpr (in usereg rn))
1901 (unit u-store-ctrl-reg (out storereg hi))
1904 (dnci stc_lo "store to control register lo" ((STALL STC))
1906 (+ MAJ_7 rn (f-csrn-lo 8) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 0))
1908 ((mep (unit u-use-gpr (in usereg rn))
1909 (unit u-store-ctrl-reg (out storereg lo))
1914 (dnci stc "store to control register" (VOLATILE (STALL STC))
1916 (+ MAJ_7 rn csrn (f-12 1) (f-13 0) (f-14 0))
1918 ((mep (unit u-use-gpr (in usereg rn))
1919 (unit u-store-ctrl-reg (out storereg csrn))
1922 ;; special load variants
1924 (dnci ldc_lp "load from control register lp" ((STALL LDC))
1926 (+ MAJ_7 rn (f-csrn-lo 1) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 1))
1928 ((mep (unit u-use-ctrl-reg (in usereg lp))
1930 (unit u-load-gpr (out loadreg rn)))))
1933 (dnci ldc_hi "load from control register hi" ((STALL LDC))
1935 (+ MAJ_7 rn (f-csrn-lo 7) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 1))
1937 ((mep (unit u-use-ctrl-reg (in usereg hi))
1939 (unit u-load-gpr (out loadreg rn)))))
1941 (dnci ldc_lo "load from control register lo" ((STALL LDC))
1943 (+ MAJ_7 rn (f-csrn-lo 8) (f-csrn-hi 0) (f-12 1) (f-13 0) (f-14 1))
1945 ((mep (unit u-use-ctrl-reg (in usereg lo))
1947 (unit u-load-gpr (out loadreg rn)))))
1951 (dnci ldc "load from control register" (VOLATILE (STALL LDC) (LATENCY 2))
1953 (+ MAJ_7 rn csrn (f-12 1) (f-13 0) (f-14 1))
1954 (if (eq (ifield f-csrn) 0)
1955 ;; loading from the pc
1956 (set-vliw-modified-pcrel-offset rn 2 4 8)
1957 ;; loading from something else
1959 ((mep (unit u-use-ctrl-reg (in usereg csrn))
1961 (unit u-load-gpr (out loadreg rn)))))
1963 (dnci di "disable interrupt" (VOLATILE)
1965 (+ MAJ_7 (f-rn 0) (f-rm 0) (f-sub4 0))
1967 (set psw (sll (srl psw 1) 1))
1970 (dnci ei "enable interrupt" (VOLATILE)
1972 (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 0))
1974 (set psw (or psw 1))
1977 (dnci reti "return from interrupt" ((STALL RET))
1979 (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 2))
1980 (if (eq (get-psw.om) 0)
1981 ;; core operation mode
1985 ;; return in VLIW operation mode
1988 (set-vliw-aliignment-modified-by-option pc npc)
1990 ;; return in core mode
1992 (set pc (and npc (inv 1)))
1994 ;; return from non-NMI
1996 ;; return in VLIW mode
1999 (set-vliw-aliignment-modified-by-option pc epc)
2000 (set-psw.umc (get-psw.ump))
2001 (set-psw.iec (get-psw.iep)))
2002 ;; return in core mode
2004 (set pc (and epc (inv 1)))
2005 (set-psw.umc (get-psw.ump))
2006 (set-psw.iec (get-psw.iep)))))
2007 ;; VLIW operation mode
2013 (dnci halt "halt pipeline" (VOLATILE)
2015 (+ MAJ_7 (f-rn 0) (f-rm 2) (f-sub4 2))
2017 (set (raw-reg h-csr 16) (or psw (sll 1 11)))
2020 (dnci sleep "sleep pipeline" (VOLATILE)
2022 (+ MAJ_7 (f-rn 0) (f-rm 6) (f-sub4 2))
2023 (c-call VOID "do_sleep")
2026 (dnci swi "software interrupt" (MAY_TRAP VOLATILE)
2028 (+ MAJ_7 (f-rn 0) (f-8 0) (f-9 0) uimm2 (f-sub4 6))
2030 ((eq uimm2 0) (set exc (or exc (sll 1 4))))
2031 ((eq uimm2 1) (set exc (or exc (sll 1 5))))
2032 ((eq uimm2 2) (set exc (or exc (sll 1 6))))
2033 ((eq uimm2 3) (set exc (or exc (sll 1 7)))))
2036 (dnci break "break exception" (MAY_TRAP VOLATILE)
2038 (+ MAJ_7 (f-rn 0) (f-rm 3) (f-sub4 2))
2039 (set pc (c-call USI "break_exception" pc))
2043 (dnci syncm "synchronise with memory" (VOLATILE)
2045 (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 1))
2049 (dnci stcb "store in control bus space" (VOLATILE (STALL STCB))
2051 (+ MAJ_15 rn (f-rm 0) (f-sub4 4) uimm16)
2052 (c-call VOID "do_stcb" rn uimm16)
2053 ((mep (unit u-use-gpr (in usereg rn))
2057 (dnci ldcb "load from control bus space" (VOLATILE (STALL LDCB) (LATENCY 3))
2059 (+ MAJ_15 rn (f-rm 1) (f-sub4 4) uimm16)
2060 (set rn (c-call SI "do_ldcb" uimm16))
2063 (unit u-ldcb-gpr (out loadreg rn)))))
2066 ; Bit manipulation instructions.
2067 ; The following instructions become the reserved instruction when the
2068 ; bit manipulation option is off.
2070 (dnci bsetm "set bit in memory" (OPTIONAL_BIT_INSN)
2071 "bsetm ($rma),$uimm3"
2072 (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 0))
2074 (c-call "check_option_bit" pc)
2075 (set (mem UQI rma) (or (mem UQI rma) (sll 1 uimm3))))
2076 ((mep (unit u-use-gpr (in usereg rma))
2079 (dnci bclrm "clear bit in memory" (OPTIONAL_BIT_INSN)
2080 "bclrm ($rma),$uimm3"
2081 (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 1))
2083 (c-call "check_option_bit" pc)
2084 (set (mem UQI rma) (and (mem UQI rma) (inv (sll 1 uimm3)))))
2085 ((mep (unit u-use-gpr (in usereg rma))
2088 (dnci bnotm "toggle bit in memory" (OPTIONAL_BIT_INSN)
2089 "bnotm ($rma),$uimm3"
2090 (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 2))
2092 (c-call "check_option_bit" pc)
2093 (set (mem UQI rma) (xor (mem UQI rma) (sll 1 uimm3))))
2094 ((mep (unit u-use-gpr (in usereg rma))
2097 (dnci btstm "test bit in memory" (OPTIONAL_BIT_INSN)
2098 "btstm \\$0,($rma),$uimm3"
2099 (+ MAJ_2 (f-4 0) uimm3 rma (f-sub4 3))
2101 (c-call "check_option_bit" pc)
2102 (set r0 (zext SI (and UQI (mem UQI rma) (sll 1 uimm3)))))
2103 ((mep (unit u-use-gpr (in usereg rma))
2106 (dnci tas "test and set" (OPTIONAL_BIT_INSN)
2108 (+ MAJ_2 rn rma (f-sub4 4))
2109 (sequence ((SI result))
2110 (c-call "check_option_bit" pc)
2111 (set result (zext SI (mem UQI rma)))
2112 (set (mem UQI rma) 1)
2114 ((mep (unit u-use-gpr (in usereg rma))
2118 ; Data cache instruction.
2120 (dnci cache "cache operations" (VOLATILE)
2121 "cache $cimm4,($rma)"
2122 (+ MAJ_7 cimm4 rma (f-sub4 4))
2123 (c-call VOID "do_cache" cimm4 rma pc)
2124 ((mep (unit u-use-gpr (in usereg rma))
2128 ; Multiply instructions.
2129 ; These instructions become the RI when the 32-bit multiply
2130 ; instruction option is off.
2132 (dnci mul "multiply" (OPTIONAL_MUL_INSN (STALL MUL))
2134 (+ MAJ_1 rn rm (f-sub4 4))
2135 (sequence ((DI result))
2136 (c-call "check_option_mul" pc)
2137 (set result (mul (ext DI rn) (ext DI rm)))
2138 (set hi (subword SI result 0))
2139 (set lo (subword SI result 1)))
2140 ((mep (unit u-use-gpr (in usereg rn))
2141 (unit u-use-gpr (in usereg rm))
2143 (unit u-multiply))))
2145 (dnci mulu "multiply unsigned" (OPTIONAL_MUL_INSN (STALL MUL))
2147 (+ MAJ_1 rn rm (f-sub4 5))
2148 (sequence ((DI result))
2149 (c-call "check_option_mul" pc)
2150 (set result (mul (zext UDI rn) (zext UDI rm)))
2151 (set hi (subword SI result 0))
2152 (set lo (subword SI result 1)))
2153 ((mep (unit u-use-gpr (in usereg rn))
2154 (unit u-use-gpr (in usereg rm))
2156 (unit u-multiply))))
2158 (dnci mulr "multiply, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3))
2160 (+ MAJ_1 rn rm (f-sub4 6))
2161 (sequence ((DI result))
2162 (c-call "check_option_mul" pc)
2163 (set result (mul (ext DI rn) (ext DI rm)))
2164 (set hi (subword SI result 0))
2165 (set lo (subword SI result 1))
2166 (set rn (subword SI result 1)))
2167 ((mep (unit u-use-gpr (in usereg rn))
2168 (unit u-use-gpr (in usereg rm))
2171 (unit u-mul-gpr (out resultreg rn)))))
2173 (dnci mulru "multiply unsigned, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3))
2175 (+ MAJ_1 rn rm (f-sub4 7))
2176 (sequence ((DI result))
2177 (c-call "check_option_mul" pc)
2178 (set result (mul (zext UDI rn) (zext UDI rm)))
2179 (set hi (subword SI result 0))
2180 (set lo (subword SI result 1))
2181 (set rn (subword SI result 1)))
2182 ((mep (unit u-use-gpr (in usereg rn))
2183 (unit u-use-gpr (in usereg rm))
2186 (unit u-mul-gpr (out resultreg rn)))))
2188 (dnci madd "multiply accumulate" (OPTIONAL_MUL_INSN (STALL MUL))
2190 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3004))
2191 (sequence ((DI result))
2192 (c-call "check_option_mul" pc)
2193 (set result (or (sll (zext DI hi) 32) (zext DI lo)))
2194 (set result (add result (mul (ext DI rn) (ext DI rm))))
2195 (set hi (subword SI result 0))
2196 (set lo (subword SI result 1)))
2197 ((mep (unit u-use-gpr (in usereg rn))
2198 (unit u-use-gpr (in usereg rm))
2200 (unit u-multiply))))
2202 (dnci maddu "multiply accumulate unsigned" (OPTIONAL_MUL_INSN (STALL MUL))
2204 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3005))
2205 (sequence ((DI result))
2206 (c-call "check_option_mul" pc)
2207 (set result (or (sll (zext DI hi) 32) (zext DI lo)))
2208 (set result (add result (mul (zext UDI rn) (zext UDI rm))))
2209 (set hi (subword SI result 0))
2210 (set lo (subword SI result 1)))
2211 ((mep (unit u-use-gpr (in usereg rn))
2212 (unit u-use-gpr (in usereg rm))
2214 (unit u-multiply))))
2217 (dnci maddr "multiply accumulate, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3))
2219 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3006))
2220 (sequence ((DI result))
2221 (c-call "check_option_mul" pc)
2222 (set result (or (sll (zext DI hi) 32) (zext DI lo)))
2223 (set result (add result (mul (ext DI rn) (ext DI rm))))
2224 (set hi (subword SI result 0))
2225 (set lo (subword SI result 1))
2226 (set rn (subword SI result 1)))
2227 ((mep (unit u-use-gpr (in usereg rn))
2228 (unit u-use-gpr (in usereg rm))
2231 (unit u-mul-gpr (out resultreg rn)))))
2233 (dnci maddru "multiple accumulate unsigned, lo -> reg" (OPTIONAL_MUL_INSN (STALL MULR) (LATENCY 3))
2235 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 #x3007))
2236 (sequence ((DI result))
2237 (c-call "check_option_mul" pc)
2238 (set result (or (sll (zext DI hi) 32) (zext DI lo)))
2239 (set result (add result (mul (zext UDI rn) (zext UDI rm))))
2240 (set hi (subword SI result 0))
2241 (set lo (subword SI result 1))
2242 (set rn (subword SI result 1)))
2243 ((mep (unit u-use-gpr (in usereg rn))
2244 (unit u-use-gpr (in usereg rm))
2247 (unit u-mul-gpr (out resultreg rn)))))
2250 ; Divide instructions.
2251 ; These instructions become the RI when the 32-bit divide instruction
2254 (dnci div "divide" (OPTIONAL_DIV_INSN (STALL DIV) (LATENCY 34) MAY_TRAP)
2256 (+ MAJ_1 rn rm (f-sub4 8))
2258 (c-call "check_option_div" pc)
2260 (set pc (c-call USI "zdiv_exception" pc))
2261 ; Special case described on p. 76.
2262 (if (and (eq rn #x80000000)
2268 (set lo (div rn rm))
2269 (set hi (mod rn rm))))))
2270 ((mep (unit u-use-gpr (in usereg rn))
2271 (unit u-use-gpr (in usereg rm))
2276 (dnci divu "divide unsigned" (OPTIONAL_DIV_INSN (STALL DIV) (LATENCY 34) MAY_TRAP)
2278 (+ MAJ_1 rn rm (f-sub4 9))
2280 (c-call "check_option_div" pc)
2282 (set pc (c-call USI "zdiv_exception" pc))
2284 (set lo (udiv rn rm))
2285 (set hi (umod rn rm)))))
2286 ((mep (unit u-use-gpr (in usereg rn))
2287 (unit u-use-gpr (in usereg rm))
2294 ; These instructions become the RI when the debug function option is
2297 (dnci dret "return from debug exception" (OPTIONAL_DEBUG_INSN)
2299 (+ MAJ_7 (f-rn 0) (f-rm 1) (f-sub4 3))
2301 (c-call "check_option_debug" pc)
2303 (set dbg (and dbg (inv (sll SI 1 15))))
2308 (dnci dbreak "generate debug exception" (OPTIONAL_DEBUG_INSN MAY_TRAP VOLATILE)
2310 (+ MAJ_7 (f-rn 0) (f-rm 3) (f-sub4 3))
2312 (c-call "check_option_debug" pc)
2314 (set dbg (or dbg 1)))
2318 ; Leading zero instruction.
2320 (dnci ldz "leading zeroes" (OPTIONAL_LDZ_INSN (STALL INT2))
2322 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 0))
2324 (c-call "check_option_ldz" pc)
2325 (set rn (c-call SI "do_ldz" rm)))
2326 ((mep (unit u-use-gpr (in usereg rm))
2330 ; Absolute difference instruction.
2332 (dnci abs "absolute difference" (OPTIONAL_ABS_INSN (STALL INT2))
2334 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 3))
2336 (c-call "check_option_abs" pc)
2337 (set rn (abs (sub rn rm))))
2338 ((mep (unit u-use-gpr (in usereg rm))
2339 (unit u-use-gpr (in usereg rn))
2343 ; Average instruction.
2345 (dnci ave "average" (OPTIONAL_AVE_INSN (STALL INT2))
2347 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 2))
2349 (c-call "check_option_ave" pc)
2350 (set rn (sra (add (add rn rm) 1) 1)))
2351 ((mep (unit u-use-gpr (in usereg rm))
2352 (unit u-use-gpr (in usereg rn))
2356 ; MIN/MAX instructions.
2358 (dnci min "minimum" (OPTIONAL_MINMAX_INSN (STALL INT2))
2360 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 4))
2362 (c-call "check_option_minmax" pc)
2365 ((mep (unit u-use-gpr (in usereg rm))
2366 (unit u-use-gpr (in usereg rn))
2369 (dnci max "maximum" (OPTIONAL_MINMAX_INSN (STALL INT2))
2371 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 5))
2373 (c-call "check_option_minmax" pc)
2376 ((mep (unit u-use-gpr (in usereg rm))
2377 (unit u-use-gpr (in usereg rn))
2380 (dnci minu "minimum unsigned" (OPTIONAL_MINMAX_INSN (STALL INT2))
2382 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 6))
2384 (c-call "check_option_minmax" pc)
2387 ((mep (unit u-use-gpr (in usereg rm))
2388 (unit u-use-gpr (in usereg rn))
2391 (dnci maxu "maximum unsigned" (OPTIONAL_MINMAX_INSN (STALL INT2))
2393 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 7))
2395 (c-call "check_option_minmax" pc)
2398 ((mep (unit u-use-gpr (in usereg rm))
2399 (unit u-use-gpr (in usereg rn))
2403 ; Clipping instruction.
2405 (dnci clip "clip" (OPTIONAL_CLIP_INSN (STALL INT2))
2407 (+ MAJ_15 rn (f-rm 0) (f-sub4 1) (f-ext #x10) cimm5 (f-29 0) (f-30 0) (f-31 0))
2408 (sequence ((SI min) (SI max))
2409 (c-call "check_option_clip" pc)
2410 (set max (sub (sll 1 (sub cimm5 1)) 1))
2411 (set min (neg (sll 1 (sub cimm5 1))))
2413 ((eq cimm5 0) (set rn 0))
2414 ((gt rn max) (set rn max))
2415 ((lt rn min) (set rn min))))
2416 ((mep (unit u-use-gpr (in usereg rn))
2419 (dnci clipu "clip unsigned" (OPTIONAL_CLIP_INSN (STALL INT2))
2421 (+ MAJ_15 rn (f-rm 0) (f-sub4 1) (f-ext #x10) cimm5 (f-29 0) (f-30 0) (f-31 1))
2422 (sequence ((SI max))
2423 (c-call "check_option_clip" pc)
2424 (set max (sub (sll 1 cimm5) 1))
2426 ((eq cimm5 0) (set rn 0))
2427 ((gt rn max) (set rn max))
2428 ((lt rn 0) (set rn 0))))
2429 ((mep (unit u-use-gpr (in usereg rn))
2433 ; Saturation instructions.
2435 (dnci sadd "saturating addition" (OPTIONAL_SAT_INSN (STALL INT2))
2437 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 8))
2439 (c-call "check_option_sat" pc)
2440 (if (add-oflag rn rm 0)
2443 (set rn (neg (sll 1 31)))
2445 (set rn (sub (sll 1 31) 1)))
2446 (set rn (add rn rm))))
2447 ((mep (unit u-use-gpr (in usereg rm))
2448 (unit u-use-gpr (in usereg rn))
2451 (dnci ssub "saturating subtraction" (OPTIONAL_SAT_INSN (STALL INT2))
2453 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 10))
2455 (c-call "check_option_sat" pc)
2456 (if (sub-oflag rn rm 0)
2459 (set rn (neg (sll 1 31)))
2461 (set rn (sub (sll 1 31) 1)))
2462 (set rn (sub rn rm))))
2463 ((mep (unit u-use-gpr (in usereg rm))
2464 (unit u-use-gpr (in usereg rn))
2467 (dnci saddu "saturating unsigned addition" (OPTIONAL_SAT_INSN (STALL INT2))
2469 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 9))
2471 (c-call "check_option_sat" pc)
2472 (if (add-cflag rn rm 0)
2474 (set rn (add rn rm))))
2475 ((mep (unit u-use-gpr (in usereg rm))
2476 (unit u-use-gpr (in usereg rn))
2479 (dnci ssubu "saturating unsigned subtraction" (OPTIONAL_SAT_INSN (STALL INT2))
2481 (+ MAJ_15 rn rm (f-sub4 1) (f-16u16 11))
2483 (c-call "check_option_sat" pc)
2484 (if (sub-cflag rn rm 0)
2486 (set rn (sub rn rm))))
2487 ((mep (unit u-use-gpr (in usereg rm))
2488 (unit u-use-gpr (in usereg rn))
2492 ; UCI and DSP options are defined in an external file.
2493 ; See `mep-sample-ucidsp.cpu' for a sample.
2496 ; Coprocessor instructions.
2498 (dnci swcp "store word coprocessor" (OPTIONAL_CP_INSN (STALL STORE))
2500 (+ MAJ_3 crn rma (f-sub4 8))
2502 (c-call "check_option_cp" pc)
2503 (c-call VOID "check_write_to_text" (and rma (inv SI 3)))
2504 (set (mem SI (and rma (inv SI 3))) crn))
2505 ((mep (unit u-use-gpr (in usereg rma))
2508 (dnci lwcp "load word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD))
2510 (+ MAJ_3 crn rma (f-sub4 9))
2512 (c-call "check_option_cp" pc)
2513 (set crn (mem SI (and rma (inv SI 3)))))
2514 ((mep (unit u-use-gpr (in usereg rma))
2517 (dnci smcp "smcp" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE))
2518 "smcp $crn64,($rma)"
2519 (+ MAJ_3 crn64 rma (f-sub4 10))
2521 (c-call "check_option_cp" pc)
2522 (c-call "check_option_cp64" pc)
2523 (c-call VOID "check_write_to_text" rma)
2524 (c-call "do_smcp" rma crn64 pc))
2525 ((mep (unit u-use-gpr (in usereg rma))
2528 (dnci lmcp "lmcp" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD))
2529 "lmcp $crn64,($rma)"
2530 (+ MAJ_3 crn64 rma (f-sub4 11))
2532 (c-call "check_option_cp" pc)
2533 (c-call "check_option_cp64" pc)
2534 (set crn64 (c-call DI "do_lmcp" rma pc)))
2535 ((mep (unit u-use-gpr (in usereg rma))
2538 (dnci swcpi "swcp (post-increment)" (OPTIONAL_CP_INSN (STALL STORE))
2539 "swcpi $crn,($rma+)"
2540 (+ MAJ_3 crn rma (f-sub4 0))
2542 (c-call "check_option_cp" pc)
2543 (c-call VOID "check_write_to_text" (and rma (inv SI 3)))
2544 (set (mem SI (and rma (inv SI 3))) crn)
2545 (set rma (add rma 4)))
2546 ((mep (unit u-use-gpr (in usereg rma))
2549 (dnci lwcpi "lwcp (post-increment)" (OPTIONAL_CP_INSN (STALL LOAD))
2550 "lwcpi $crn,($rma+)"
2551 (+ MAJ_3 crn rma (f-sub4 1))
2553 (c-call "check_option_cp" pc)
2554 (set crn (mem SI (and rma (inv SI 3))))
2555 (set rma (add rma 4)))
2556 ((mep (unit u-use-gpr (in usereg rma))
2559 (dnci smcpi "smcp (post-increment)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE))
2560 "smcpi $crn64,($rma+)"
2561 (+ MAJ_3 crn64 rma (f-sub4 2))
2563 (c-call "check_option_cp" pc)
2564 (c-call "check_option_cp64" pc)
2565 (c-call VOID "check_write_to_text" rma)
2566 (c-call "do_smcpi" (index-of rma) crn64 pc)
2567 (set rma rma)) ; reference as output for intrinsic generation
2568 ((mep (unit u-use-gpr (in usereg rma))
2571 (dnci lmcpi "lmcp (post-increment)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD))
2572 "lmcpi $crn64,($rma+)"
2573 (+ MAJ_3 crn64 rma (f-sub4 3))
2575 (c-call "check_option_cp" pc)
2576 (c-call "check_option_cp64" pc)
2577 (set crn64 (c-call DI "do_lmcpi" (index-of rma) pc))
2578 (set rma rma)) ; reference as output for intrinsic generation
2579 ((mep (unit u-use-gpr (in usereg rma))
2582 (dnci swcp16 "swcp (16-bit displacement)" (OPTIONAL_CP_INSN (STALL STORE))
2583 "swcp $crn,$sdisp16($rma)"
2584 (+ MAJ_15 crn rma (f-sub4 12) sdisp16)
2586 (c-call "check_option_cp" pc)
2587 (set (mem SI (and (add rma sdisp16) (inv SI 3))) crn))
2588 ((mep (unit u-use-gpr (in usereg rma))
2591 (dnci lwcp16 "lwcp (16-bit displacement)" (OPTIONAL_CP_INSN (STALL LOAD))
2592 "lwcp $crn,$sdisp16($rma)"
2593 (+ MAJ_15 crn rma (f-sub4 13) sdisp16)
2595 (c-call "check_option_cp" pc)
2596 (set crn (mem SI (and (add rma sdisp16) (inv SI 3)))))
2597 ((mep (unit u-use-gpr (in usereg rma))
2600 (dnci smcp16 "smcp (16-bit displacement)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE))
2601 "smcp $crn64,$sdisp16($rma)"
2602 (+ MAJ_15 crn64 rma (f-sub4 14) sdisp16)
2604 (c-call "check_option_cp" pc)
2605 (c-call "check_option_cp64" pc)
2606 (c-call "do_smcp16" rma sdisp16 crn64 pc))
2607 ((mep (unit u-use-gpr (in usereg rma))
2610 (dnci lmcp16 "lmcp (16-bit displacement)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD))
2611 "lmcp $crn64,$sdisp16($rma)"
2612 (+ MAJ_15 crn64 rma (f-sub4 15) sdisp16)
2614 (c-call "check_option_cp" pc)
2615 (c-call "check_option_cp64" pc)
2616 (set crn64 (c-call DI "do_lmcp16" rma sdisp16 pc)))
2617 ((mep (unit u-use-gpr (in usereg rma))
2620 (dnci sbcpa "store byte coprocessor" (OPTIONAL_CP_INSN (STALL STORE))
2621 "sbcpa $crn,($rma+),$cdisp10"
2622 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 0) (f-ext62 0) cdisp10)
2624 (c-call "check_option_cp" pc)
2625 (c-call VOID "check_write_to_text" rma)
2626 (set (mem QI rma) (and crn #xff))
2627 (set rma (add rma (ext SI cdisp10))))
2628 ((mep (unit u-use-gpr (in usereg rma))
2631 (dnci lbcpa "load byte coprocessor" (OPTIONAL_CP_INSN (STALL LOAD))
2632 "lbcpa $crn,($rma+),$cdisp10"
2633 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x4) (f-ext62 #x0) cdisp10)
2635 (c-call "check_option_cp" pc)
2636 (set crn (ext SI (mem QI rma)))
2637 (set rma (add rma (ext SI cdisp10))))
2638 ((mep (unit u-use-gpr (in usereg rma))
2641 (dnci shcpa "store half-word coprocessor" (OPTIONAL_CP_INSN (STALL STORE))
2642 "shcpa $crn,($rma+),$cdisp10a2"
2643 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x1) (f-ext62 #x0) cdisp10a2)
2645 (c-call "check_option_cp" pc)
2646 (c-call VOID "check_write_to_text" (and rma (inv SI 1)))
2647 (set (mem HI (and rma (inv SI 1))) (and crn #xffff))
2648 (set rma (add rma (ext SI cdisp10a2))))
2649 ((mep (unit u-use-gpr (in usereg rma))
2652 (dnci lhcpa "load half-word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD))
2653 "lhcpa $crn,($rma+),$cdisp10a2"
2654 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x5) (f-ext62 #x0) cdisp10a2)
2656 (c-call "check_option_cp" pc)
2657 (set crn (ext SI (mem HI (and rma (inv SI 1)))))
2658 (set rma (add rma (ext SI cdisp10a2))))
2659 ((mep (unit u-use-gpr (in usereg rma))
2662 (dnci swcpa "store word coprocessor" (OPTIONAL_CP_INSN (STALL STORE))
2663 "swcpa $crn,($rma+),$cdisp10a4"
2664 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x2) (f-ext62 #x0) cdisp10a4)
2666 (c-call "check_option_cp" pc)
2667 (c-call VOID "check_write_to_text" (and rma (inv SI 3)))
2668 (set (mem SI (and rma (inv SI 3))) crn)
2669 (set rma (add rma (ext SI cdisp10a4))))
2670 ((mep (unit u-use-gpr (in usereg rma))
2673 (dnci lwcpa "load word coprocessor" (OPTIONAL_CP_INSN (STALL LOAD))
2674 "lwcpa $crn,($rma+),$cdisp10a4"
2675 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x6) (f-ext62 #x0) cdisp10a4)
2677 (c-call "check_option_cp" pc)
2678 (set crn (mem SI (and rma (inv SI 3))))
2679 (set rma (add rma (ext SI cdisp10a4))))
2680 ((mep (unit u-use-gpr (in usereg rma))
2683 (dnci smcpa "smcpa" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL STORE))
2684 "smcpa $crn64,($rma+),$cdisp10a8"
2685 (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x3) (f-ext62 #x0) cdisp10a8)
2687 (c-call "check_option_cp" pc)
2688 (c-call "check_option_cp64" pc)
2689 (c-call VOID "check_write_to_text" rma)
2690 (c-call "do_smcpa" (index-of rma) cdisp10a8 crn64 pc)
2691 (set rma rma)) ; reference as output for intrinsic generation
2692 ((mep (unit u-use-gpr (in usereg rma))
2695 (dnci lmcpa "lmcpa" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN (STALL LOAD))
2696 "lmcpa $crn64,($rma+),$cdisp10a8"
2697 (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x7) (f-ext62 #x0) cdisp10a8)
2699 (c-call "check_option_cp" pc)
2700 (c-call "check_option_cp64" pc)
2701 (set crn64 (c-call DI "do_lmcpa" (index-of rma) cdisp10a8 pc))
2702 (set rma rma)) ; reference as output for intrinsic generation
2703 ((mep (unit u-use-gpr (in usereg rma))
2707 (dnci sbcpm0 "sbcpm0" (OPTIONAL_CP_INSN)
2708 "sbcpm0 $crn,($rma+),$cdisp10"
2709 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x0) (f-ext62 #x2) cdisp10)
2711 (c-call "check_option_cp" pc)
2712 (c-call VOID "check_write_to_text" rma)
2713 (set (mem QI rma) (and crn #xff))
2714 (set rma (mod0 cdisp10)))
2715 ((mep (unit u-use-gpr (in usereg rma))
2718 (dnci lbcpm0 "lbcpm0" (OPTIONAL_CP_INSN)
2719 "lbcpm0 $crn,($rma+),$cdisp10"
2720 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x4) (f-ext62 #x2) cdisp10)
2722 (c-call "check_option_cp" pc)
2723 (set crn (ext SI (mem QI rma)))
2724 (set rma (mod0 cdisp10)))
2725 ((mep (unit u-use-gpr (in usereg rma))
2728 (dnci shcpm0 "shcpm0" (OPTIONAL_CP_INSN)
2729 "shcpm0 $crn,($rma+),$cdisp10a2"
2730 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x1) (f-ext62 #x2) cdisp10a2)
2732 (c-call "check_option_cp" pc)
2733 (c-call VOID "check_write_to_text" (and rma (inv SI 1)))
2734 (set (mem HI (and rma (inv SI 1))) (and crn #xffff))
2735 (set rma (mod0 cdisp10a2)))
2736 ((mep (unit u-use-gpr (in usereg rma))
2739 (dnci lhcpm0 "lhcpm0" (OPTIONAL_CP_INSN)
2740 "lhcpm0 $crn,($rma+),$cdisp10a2"
2741 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x5) (f-ext62 #x2) cdisp10a2)
2743 (c-call "check_option_cp" pc)
2744 (set crn (ext SI (mem HI (and rma (inv SI 1)))))
2745 (set rma (mod0 cdisp10a2)))
2746 ((mep (unit u-use-gpr (in usereg rma))
2749 (dnci swcpm0 "swcpm0" (OPTIONAL_CP_INSN)
2750 "swcpm0 $crn,($rma+),$cdisp10a4"
2751 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x2) (f-ext62 #x2) cdisp10a4)
2753 (c-call "check_option_cp" pc)
2754 (c-call VOID "check_write_to_text" (and rma (inv SI 3)))
2755 (set (mem SI (and rma (inv SI 3))) crn)
2756 (set rma (mod0 cdisp10a4)))
2757 ((mep (unit u-use-gpr (in usereg rma))
2760 (dnci lwcpm0 "lwcpm0" (OPTIONAL_CP_INSN)
2761 "lwcpm0 $crn,($rma+),$cdisp10a4"
2762 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x6) (f-ext62 #x2) cdisp10a4)
2764 (c-call "check_option_cp" pc)
2765 (set crn (mem SI (and rma (inv SI 3))))
2766 (set rma (mod0 cdisp10a4)))
2767 ((mep (unit u-use-gpr (in usereg rma))
2770 (dnci smcpm0 "smcpm0" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN)
2771 "smcpm0 $crn64,($rma+),$cdisp10a8"
2772 (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x3) (f-ext62 #x2) cdisp10a8)
2774 (c-call "check_option_cp" pc)
2775 (c-call "check_option_cp64" pc)
2776 (c-call VOID "check_write_to_text" rma)
2777 (c-call "do_smcp" rma crn64 pc)
2778 (set rma (mod0 cdisp10a8)))
2779 ((mep (unit u-use-gpr (in usereg rma))
2782 (dnci lmcpm0 "lmcpm0" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN)
2783 "lmcpm0 $crn64,($rma+),$cdisp10a8"
2784 (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x7) (f-ext62 #x2) cdisp10a8)
2786 (c-call "check_option_cp" pc)
2787 (c-call "check_option_cp64" pc)
2788 (set crn64 (c-call DI "do_lmcp" rma pc))
2789 (set rma (mod0 cdisp10a8)))
2790 ((mep (unit u-use-gpr (in usereg rma))
2793 (dnci sbcpm1 "sbcpm1" (OPTIONAL_CP_INSN)
2794 "sbcpm1 $crn,($rma+),$cdisp10"
2795 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x0) (f-ext62 #x3) cdisp10)
2797 (c-call "check_option_cp" pc)
2798 (c-call VOID "check_write_to_text" rma)
2799 (set (mem QI rma) (and crn #xff))
2800 (set rma (mod1 cdisp10)))
2801 ((mep (unit u-use-gpr (in usereg rma))
2804 (dnci lbcpm1 "lbcpm1" (OPTIONAL_CP_INSN)
2805 "lbcpm1 $crn,($rma+),$cdisp10"
2806 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x4) (f-ext62 #x3) cdisp10)
2808 (c-call "check_option_cp" pc)
2809 (set crn (ext SI (mem QI rma)))
2810 (set rma (mod1 cdisp10)))
2811 ((mep (unit u-use-gpr (in usereg rma))
2814 (dnci shcpm1 "shcpm1" (OPTIONAL_CP_INSN)
2815 "shcpm1 $crn,($rma+),$cdisp10a2"
2816 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x1) (f-ext62 #x3) cdisp10a2)
2818 (c-call "check_option_cp" pc)
2819 (c-call VOID "check_write_to_text" (and rma (inv SI 1)))
2820 (set (mem HI (and rma (inv SI 1))) (and crn #xffff))
2821 (set rma (mod1 cdisp10a2)))
2822 ((mep (unit u-use-gpr (in usereg rma))
2825 (dnci lhcpm1 "lhcpm1" (OPTIONAL_CP_INSN)
2826 "lhcpm1 $crn,($rma+),$cdisp10a2"
2827 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x5) (f-ext62 #x3) cdisp10a2)
2829 (c-call "check_option_cp" pc)
2830 (set crn (ext SI (mem HI (and rma (inv SI 1)))))
2831 (set rma (mod1 cdisp10a2)))
2832 ((mep (unit u-use-gpr (in usereg rma))
2835 (dnci swcpm1 "swcpm1" (OPTIONAL_CP_INSN)
2836 "swcpm1 $crn,($rma+),$cdisp10a4"
2837 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x2) (f-ext62 #x3) cdisp10a4)
2839 (c-call "check_option_cp" pc)
2840 (c-call VOID "check_write_to_text" (and rma (inv SI 3)))
2841 (set (mem SI (and rma (inv SI 3))) crn)
2842 (set rma (mod1 cdisp10a4)))
2843 ((mep (unit u-use-gpr (in usereg rma))
2846 (dnci lwcpm1 "lwcpm1" (OPTIONAL_CP_INSN)
2847 "lwcpm1 $crn,($rma+),$cdisp10a4"
2848 (+ MAJ_15 crn rma (f-sub4 5) (f-ext4 #x6) (f-ext62 #x3) cdisp10a4)
2850 (c-call "check_option_cp" pc)
2851 (set crn (ext SI (mem SI (and rma (inv SI 3)))))
2852 (set rma (mod1 cdisp10a4)))
2853 ((mep (unit u-use-gpr (in usereg rma))
2856 (dnci smcpm1 "smcpm1" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN)
2857 "smcpm1 $crn64,($rma+),$cdisp10a8"
2858 (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x3) (f-ext62 #x3) cdisp10a8)
2860 (c-call "check_option_cp" pc)
2861 (c-call "check_option_cp64" pc)
2862 (c-call "do_smcp" rma crn64 pc)
2863 (c-call VOID "check_write_to_text" rma)
2864 (set rma (mod1 cdisp10a8)))
2865 ((mep (unit u-use-gpr (in usereg rma))
2868 (dnci lmcpm1 "lmcpm1" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN)
2869 "lmcpm1 $crn64,($rma+),$cdisp10a8"
2870 (+ MAJ_15 crn64 rma (f-sub4 5) (f-ext4 #x7) (f-ext62 #x3) cdisp10a8)
2872 (c-call "check_option_cp" pc)
2873 (c-call "check_option_cp64" pc)
2874 (set crn64 (c-call DI "do_lmcp" rma pc))
2875 (set rma (mod1 cdisp10a8)))
2876 ((mep (unit u-use-gpr (in usereg rma))
2879 (dnop cp_flag "branch condition register" (all-mep-isas) h-ccr 1)
2881 (dnci bcpeq "branch coprocessor equal" (OPTIONAL_CP_INSN RELAXABLE)
2882 "bcpeq $cccc,$pcrel17a2"
2883 (+ MAJ_13 (f-rn 8) cccc (f-sub4 4) pcrel17a2)
2885 (c-call "check_option_cp" pc)
2886 (if (eq (xor cccc cp_flag) 0)
2887 (set-vliw-alignment-modified pc pcrel17a2)))
2890 (dnci bcpne "branch coprocessor not equal" (OPTIONAL_CP_INSN RELAXABLE)
2891 "bcpne $cccc,$pcrel17a2"
2892 (+ MAJ_13 (f-rn 8) cccc (f-sub4 5) pcrel17a2)
2894 (c-call "check_option_cp" pc)
2895 (if (ne (xor cccc cp_flag) 0)
2896 (set-vliw-alignment-modified pc pcrel17a2)))
2899 (dnci bcpat "branch coprocessor and true" (OPTIONAL_CP_INSN RELAXABLE)
2900 "bcpat $cccc,$pcrel17a2"
2901 (+ MAJ_13 (f-rn 8) cccc (f-sub4 6) pcrel17a2)
2903 (c-call "check_option_cp" pc)
2904 (if (ne (and cccc cp_flag) 0)
2905 (set-vliw-alignment-modified pc pcrel17a2)))
2908 (dnci bcpaf "branch coprocessor and false" (OPTIONAL_CP_INSN RELAXABLE)
2909 "bcpaf $cccc,$pcrel17a2"
2910 (+ MAJ_13 (f-rn 8) cccc (f-sub4 7) pcrel17a2)
2912 (c-call "check_option_cp" pc)
2913 (if (eq (and cccc cp_flag) 0)
2914 (set-vliw-alignment-modified pc pcrel17a2)))
2917 (dnci synccp "synchronise with coprocessor" (OPTIONAL_CP_INSN)
2919 (+ MAJ_7 (f-rn 0) (f-rm 2) (f-sub4 1))
2921 (c-call "check_option_cp" pc)
2925 (dnci jsrv "jump to vliw subroutine " (OPTIONAL_CP_INSN)
2927 (+ MAJ_1 (f-rn 8) rm (f-sub4 15))
2930 (c-call "check_option_cp" pc)
2933 ;; in core operating mode
2935 (set lp (or (add pc 2) 1))
2936 (set-vliw-aliignment-modified-by-option pc rm)
2937 (set-psw.om 1)) ;; to VLIW operation mode
2939 ;; in VLIW32 operating mode
2941 (set lp (or (add pc 4) 1))
2942 (set pc (and rm (inv 1)))
2943 (set-psw.om 0)) ;; to core operation mode
2945 ;; in VLIW64 operating mode
2947 (set lp (or (add pc 8) 1))
2948 (set pc (and rm (inv 1)))
2949 (set-psw.om 0)))) ;; to core operation mode
2950 ((mep (unit u-use-gpr (in usereg rm))
2954 (dnci bsrv "branch to vliw subroutine" (OPTIONAL_CP_INSN)
2956 (+ MAJ_13 (f-4 1) (f-sub4 11) pcrel24a2)
2958 (cg-profile pc pcrel24a2)
2959 (c-call "check_option_cp" pc)
2962 ;; in core operating mode
2964 (set lp (or (add pc 4) 1))
2965 (set-vliw-aliignment-modified-by-option pc pcrel24a2)
2966 (set-psw.om 1)) ;; to VLIW operation mode
2968 ;; in VLIW32 operating mode
2970 (set lp (or (add pc 4) 1))
2971 (set pc (and pcrel24a2 (inv 1)))
2972 (set-psw.om 0)) ;; to core operation mode
2974 ;; in VLIW64 operating mode
2976 (set lp (or (add pc 8) 1))
2977 (set pc (and pcrel24a2 (inv 1)))
2978 (set-psw.om 0)))) ;; to core operation mode
2983 ; An instruction for test instrumentation.
2984 ; Using a reserved opcode.
2986 (dnci sim-syscall "simulator system call" ()
2988 (+ MAJ_7 (f-4 1) callnum (f-8 0) (f-9 0) (f-10 0) (f-sub4 0))
2989 (c-call "do_syscall" pc callnum)
2992 (define-pmacro (dnri n major minor)
2993 (dnci (.sym ri- n) "reserved instruction" ()
2995 (+ major rn rm (f-sub4 minor))
2996 (set pc (c-call USI "ri_exception" pc))
3023 ; begin core-specific reserved insns
3024 ; end core-specific reserved insns
3027 ; Macro instructions.
3032 (emit mov (rn 0) (rm 0)))
3034 ; Emit the 16 bit form of these 32 bit insns when the displacement is zero.
3036 (dncmi sb16-0 "store byte (explicit 16 bit displacement of zero)" (NO-DIS)
3037 "sb $rnc,$zero($rma)"
3040 (dncmi sh16-0 "store half (explicit 16 bit displacement of zero)" (NO-DIS)
3041 "sh $rns,$zero($rma)"
3044 (dncmi sw16-0 "store word (explicit 16 bit displacement of zero)" (NO-DIS)
3045 "sw $rnl,$zero($rma)"
3048 (dncmi lb16-0 "load byte (explicit 16 bit displacement of zero)" (NO-DIS)
3049 "lb $rnc,$zero($rma)"
3052 (dncmi lh16-0 "load half (explicit 16 bit displacement of zero)" (NO-DIS)
3053 "lh $rns,$zero($rma)"
3056 (dncmi lw16-0 "load word (explicit 16 bit displacement of zero)" (NO-DIS)
3057 "lw $rnl,$zero($rma)"
3060 (dncmi lbu16-0 "load unsigned byte (explicit 16 bit displacement of zero)" (NO-DIS)
3061 "lbu $rnuc,$zero($rma)"
3062 (emit lbu rnuc rma))
3064 (dncmi lhu16-0 "load unsigned half (explicit 16 bit displacement of zero)" (NO-DIS)
3065 "lhu $rnus,$zero($rma)"
3066 (emit lhu rnus rma))
3068 (dncmi swcp16-0 "swcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN NO-DIS)
3069 "swcp $crn,$zero($rma)"
3070 (emit swcp crn rma))
3072 (dncmi lwcp16-0 "lwcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN NO-DIS)
3073 "lwcp $crn,$zero($rma)"
3074 (emit lwcp crn rma))
3076 (dncmi smcp16-0 "smcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN NO-DIS)
3077 "smcp $crn64,$zero($rma)"
3078 (emit smcp crn64 rma))
3080 (dncmi lmcp16-0 "lmcp (explicit 16-bit displacement of zero)" (OPTIONAL_CP_INSN OPTIONAL_CP64_INSN NO-DIS)
3081 "lmcp $crn64,$zero($rma)"
3082 (emit lmcp crn64 rma))