1 ; Fujitsu FR30 CPU 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 (define-rtl-version 0 8)
25 (include "simplify.inc")
27 ; define-arch must appear first
30 (name fr30) ; name of cpu family
31 (comment "Fujitsu FR30")
32 (default-alignment forced)
40 (base-insn-bitsize 16)
41 (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
42 (liw-insns 1) ; The fr30 fetches 1 insn at a time.
43 (parallel-insns 1) ; The fr30 executes 1 insn at a time.
47 ; cpu names must be distinct from the architecture name and machine names.
48 ; The "b" suffix stands for "base" and is the convention.
49 ; The "f" suffix stands for "family" and is the convention.
51 (comment "Fujitsu FR30 base family")
58 (comment "Generic FR30 cpu")
65 (name fr30-1) (comment "fr30-1") (attrs)
68 (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
70 ; `state' is a list of variables for recording model state
72 ; bit mask of h-gr registers loaded from memory by previous insn
74 ; bit mask of h-gr registers loaded from memory by current insn
75 (load-regs-pending UINT)
78 (unit u-exec "Execution Unit" ()
81 ((Ri INT -1) (Rj INT -1)) ; inputs
82 ((Ri INT -1)) ; outputs
83 () ; profile action (default)
85 (unit u-cti "Branch Unit" ()
88 ((Ri INT -1)) ; inputs
90 () ; profile action (default)
92 (unit u-load "Memory Load Unit" ()
98 ((Ri INT -1)) ; outputs
99 () ; profile action (default)
101 (unit u-store "Memory Store Unit" ()
104 ((Ri INT -1) (Rj INT -1)) ; inputs
105 () ; ((st-mem AI)) ; outputs
106 () ; profile action (default)
108 (unit u-ldm "LDM Memory Load Unit" ()
111 ((reglist INT)) ; inputs
113 () ; profile action (default)
115 (unit u-stm "STM Memory Store Unit" ()
118 ((reglist INT)) ; inputs
120 () ; profile action (default)
124 ; The instruction fetch/execute cycle.
126 ; This is how to fetch and decode an instruction.
127 ; Leave it out for now
129 ; (define-extract (const SI 0))
131 ; This is how to execute a decoded instruction.
132 ; Leave it out for now
134 ; (define-execute (const SI 0))
136 ; Instruction fields.
139 ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
140 ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
141 ; RESERVED: bits are not used to decode insn, must be all 0
143 (dnf f-op1 "1st 4 bits of opcode" () 0 4)
144 (dnf f-op2 "2nd 4 bits of opcode" () 4 4)
145 (dnf f-op3 "3rd 4 bits of opcode" () 8 4)
146 (dnf f-op4 "4th 4 bits of opcode" () 12 4)
147 (dnf f-op5 "5th bit of opcode" () 4 1)
148 (dnf f-cc "condition code" () 4 4)
149 (dnf f-ccc "coprocessor calc code" () 16 8)
150 (dnf f-Rj "register Rj" () 8 4)
151 (dnf f-Ri "register Ri" () 12 4)
152 (dnf f-Rs1 "register Rs" () 8 4)
153 (dnf f-Rs2 "register Rs" () 12 4)
154 (dnf f-Rjc "register Rj" () 24 4)
155 (dnf f-Ric "register Ri" () 28 4)
156 (dnf f-CRj "coprocessor register" () 24 4)
157 (dnf f-CRi "coprocessor register" () 28 4)
158 (dnf f-u4 "4 bit 0 extended" () 8 4)
159 (dnf f-u4c "4 bit 0 extended" () 12 4)
160 (df f-i4 "4 bit sign extended" () 8 4 INT #f #f)
161 (df f-m4 "4 bit minus extended" () 8 4 UINT
162 ; ??? This field takes a value in the range [-16,-1] but there
163 ; doesn't seem a way to tell CGEN that. Use an unsigned field and
164 ; disable range checks on insertion by masking. Restore the sign
165 ; on extraction. CGEN generated documentation for insns that use
166 ; this field will be wrong.
167 ((value pc) (and WI value (const #xf)))
168 ((value pc) (or WI value (const -16)))
170 (dnf f-u8 "8 bit unsigned" () 8 8)
171 (dnf f-i8 "8 bit unsigned" () 4 8)
173 (dnf f-i20-4 "upper 4 bits of i20" () 8 4)
174 (dnf f-i20-16 "lower 16 bits of i20" () 16 16)
175 (dnmf f-i20 "20 bit unsigned" () UINT
177 (sequence () ; insert
178 (set (ifield f-i20-4) (srl (ifield f-i20) (const 16)))
179 (set (ifield f-i20-16) (and (ifield f-i20) (const #xffff)))
181 (sequence () ; extract
182 (set (ifield f-i20) (or (sll (ifield f-i20-4) (const 16))
187 (dnf f-i32 "32 bit immediate" (SIGN-OPT) 16 32)
189 (df f-udisp6 "6 bit unsigned offset" () 8 4 UINT
190 ((value pc) (srl UWI value (const 2)))
191 ((value pc) (sll UWI value (const 2)))
193 (df f-disp8 "8 bit signed offset" () 4 8 INT #f #f)
194 (df f-disp9 "9 bit signed offset" () 4 8 INT
195 ((value pc) (sra WI value (const 1)))
196 ((value pc) (mul WI value (const 2)))
198 (df f-disp10 "10 bit signed offset" () 4 8 INT
199 ((value pc) (sra WI value (const 2)))
200 ((value pc) (mul WI value (const 4)))
202 (df f-s10 "10 bit signed offset" () 8 8 INT
203 ((value pc) (sra WI value (const 2)))
204 ((value pc) (mul WI value (const 4)))
206 (df f-u10 "10 bit unsigned offset" () 8 8 UINT
207 ((value pc) (srl UWI value (const 2)))
208 ((value pc) (sll UWI value (const 2)))
210 (df f-rel9 "9 pc relative signed offset" (PCREL-ADDR) 8 8 INT
211 ((value pc) (sra WI (sub WI value (add WI pc (const 2))) (const 1)))
212 ((value pc) (add WI (mul WI value (const 2)) (add WI pc (const 2))))
214 (dnf f-dir8 "8 bit direct address" () 8 8)
215 (df f-dir9 "9 bit direct address" () 8 8 UINT
216 ((value pc) (srl UWI value (const 1)))
217 ((value pc) (sll UWI value (const 1)))
219 (df f-dir10 "10 bit direct address" () 8 8 UINT
220 ((value pc) (srl UWI value (const 2)))
221 ((value pc) (sll UWI value (const 2)))
223 (df f-rel12 "12 bit pc relative signed offset" (PCREL-ADDR) 5 11 INT
224 ((value pc) (sra WI (sub WI value (add WI pc (const 2))) (const 1)))
225 ((value pc) (add WI (mul WI value (const 2)) (add WI pc (const 2))))
228 (dnf f-reglist_hi_st "8 bit register mask for stm" () 8 8)
229 (dnf f-reglist_low_st "8 bit register mask for stm" () 8 8)
230 (dnf f-reglist_hi_ld "8 bit register mask for ldm" () 8 8)
231 (dnf f-reglist_low_ld "8 bit register mask for ldm" () 8 8)
236 ; FIXME: should use die macro or some such
237 (define-normal-insn-enum insn-op1 "insn op1 enums" () OP1_ f-op1
238 ("0" "1" "2" "3" "4" "5" "6" "7"
239 "8" "9" "A" "B" "C" "D" "E" "F")
243 ; FIXME: should use die macro or some such
244 (define-normal-insn-enum insn-op2 "insn op2 enums" () OP2_ f-op2
245 ("0" "1" "2" "3" "4" "5" "6" "7"
246 "8" "9" "A" "B" "C" "D" "E" "F")
249 ; insn-op3: bits 8-11
250 ; FIXME: should use die macro or some such
251 (define-normal-insn-enum insn-op3 "insn op3 enums" () OP3_ f-op3
252 ("0" "1" "2" "3" "4" "5" "6" "7"
253 "8" "9" "A" "B" "C" "D" "E" "F")
256 ; insn-op4: bits 12-15
257 ; FIXME: should use die macro or some such
258 (define-normal-insn-enum insn-op4 "insn op4 enums" () OP4_ f-op4
262 ; insn-op5: bit 4 (5th bit origin 0)
263 ; FIXME: should use die macro or some such
264 (define-normal-insn-enum insn-op5 "insn op5 enums" () OP5_ f-op5
268 ; insn-cc: condition codes
269 ; FIXME: should use die macro or some such
270 (define-normal-insn-enum insn-cc "insn cc enums" () CC_ f-cc
271 ("ra" "no" "eq" "ne" "c" "nc" "n" "p" "v" "nv" "lt" "ge" "le" "gt" "ls" "hi")
275 ; These entries list the elements of the raw hardware.
276 ; They're also used to provide tables and other elements of the assembly
279 (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
284 (values (r0 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6) (r7 7)
285 (r8 8) (r9 9) (r10 10) (r11 11) (r12 12) (r13 13) (r14 14) (r15 15)
286 (ac 13) (fp 14) (sp 15))
291 (comment "general registers")
292 (attrs PROFILE CACHE-ADDR)
293 (type register WI (16))
294 (indices extern-keyword gr-names)
300 (values (cr0 0) (cr1 1) (cr2 2) (cr3 3)
301 (cr4 4) (cr5 5) (cr6 6) (cr7 7)
302 (cr8 8) (cr9 9) (cr10 10) (cr11 11)
303 (cr12 12) (cr13 13) (cr14 14) (cr15 15))
308 (comment "coprocessor registers")
310 (type register WI (16))
311 (indices extern-keyword cr-names)
317 (values (tbr 0) (rp 1) (ssp 2) (usp 3) (mdh 4) (mdl 5))
322 (comment "dedicated registers")
323 (type register WI (6))
324 (indices extern-keyword dr-names)
325 (get (index) (c-call WI "@cpu@_h_dr_get_handler" index))
326 (set (index newval) (c-call VOID "@cpu@_h_dr_set_handler" index newval))
331 (comment "processor status")
333 (indices keyword "" ((ps 0)))
334 (get () (c-call UWI "@cpu@_h_ps_get_handler"))
335 (set (newval) (c-call VOID "@cpu@_h_ps_set_handler" newval))
338 (dnh h-r13 "General Register 13 explicitly required"
341 (keyword "" ((r13 0)))
345 (dnh h-r14 "General Register 14 explicitly required"
348 (keyword "" ((r14 0)))
352 (dnh h-r15 "General Register 15 explicitly required"
355 (keyword "" ((r15 0)))
359 ; These bits are actually part of the PS register but are accessed more
360 ; often than the entire register, so define them directly. We can assemble
361 ; the PS register from its components when necessary.
363 (dsh h-nbit "negative bit" () (register BI))
364 (dsh h-zbit "zero bit" () (register BI))
365 (dsh h-vbit "overflow bit" () (register BI))
366 (dsh h-cbit "carry bit" () (register BI))
367 (dsh h-ibit "interrupt enable bit" () (register BI))
370 (comment "stack bit")
372 (get () (c-call BI "@cpu@_h_sbit_get_handler"))
373 (set (newval) (c-call VOID "@cpu@_h_sbit_set_handler" newval))
375 (dsh h-tbit "trace trap bit" () (register BI))
376 (dsh h-d0bit "division 0 bit" () (register BI))
377 (dsh h-d1bit "division 1 bit" () (register BI))
379 ; These represent sub-registers within the program status register
383 (comment "condition code bits")
385 (get () (c-call UQI "@cpu@_h_ccr_get_handler"))
386 (set (newval) (c-call VOID "@cpu@_h_ccr_set_handler" newval))
390 (comment "system condition bits")
392 (get () (c-call UQI "@cpu@_h_scr_get_handler"))
393 (set (newval) (c-call VOID "@cpu@_h_scr_set_handler" newval))
397 (comment "interrupt level mask")
399 (get () (c-call UQI "@cpu@_h_ilm_get_handler"))
400 (set (newval) (c-call VOID "@cpu@_h_ilm_set_handler" newval))
403 ; Instruction Operands.
404 ; These entries provide a layer between the assembler and the raw hardware
405 ; description, and are used to refer to hardware elements in the semantic
406 ; code. Usually there's a bit of over-specification, but in more complicated
407 ; instruction sets there isn't.
409 ; FR30 specific operand attributes:
415 (comment "immediates have an optional '#' prefix")
418 ; ??? Convention says this should be o-sr, but then the insn definitions
419 ; should refer to o-sr which is clumsy. The "o-" could be implicit, but
420 ; then it should be implicit for all the symbols here, but then there would
421 ; be confusion between (f-)simm8 and (h-)simm8.
422 ; So for now the rule is exactly as it appears here.
424 (dnop Ri "destination register" () h-gr f-Ri)
425 (dnop Rj "source register" () h-gr f-Rj)
426 (dnop Ric "target register coproc insn" () h-gr f-Ric)
427 (dnop Rjc "source register coproc insn" () h-gr f-Rjc)
428 (dnop CRi "coprocessor register" () h-cr f-CRi)
429 (dnop CRj "coprocessor register" () h-cr f-CRj)
430 (dnop Rs1 "dedicated register" () h-dr f-Rs1)
431 (dnop Rs2 "dedicated register" () h-dr f-Rs2)
432 (dnop R13 "General Register 13" () h-r13 f-nil)
433 (dnop R14 "General Register 14" () h-r14 f-nil)
434 (dnop R15 "General Register 15" () h-r15 f-nil)
435 (dnop ps "Program Status register" () h-ps f-nil)
436 (dnop u4 "4 bit unsigned immediate" (HASH-PREFIX) h-uint f-u4)
437 (dnop u4c "4 bit unsigned immediate" (HASH-PREFIX) h-uint f-u4c)
438 (dnop u8 "8 bit unsigned immediate" (HASH-PREFIX) h-uint f-u8)
439 (dnop i8 "8 bit unsigned immediate" (HASH-PREFIX) h-uint f-i8)
440 (dnop udisp6 "6 bit unsigned immediate" (HASH-PREFIX) h-uint f-udisp6)
441 (dnop disp8 "8 bit signed immediate" (HASH-PREFIX) h-sint f-disp8)
442 (dnop disp9 "9 bit signed immediate" (HASH-PREFIX) h-sint f-disp9)
443 (dnop disp10 "10 bit signed immediate" (HASH-PREFIX) h-sint f-disp10)
445 (dnop s10 "10 bit signed immediate" (HASH-PREFIX) h-sint f-s10)
446 (dnop u10 "10 bit unsigned immediate" (HASH-PREFIX) h-uint f-u10)
447 (dnop i32 "32 bit immediate" (HASH-PREFIX) h-uint f-i32)
451 (comment "4 bit negative immediate")
455 (handlers (print "m4"))
460 (comment "20 bit immediate")
466 (dnop dir8 "8 bit direct address" () h-uint f-dir8)
467 (dnop dir9 "9 bit direct address" () h-uint f-dir9)
468 (dnop dir10 "10 bit direct address" () h-uint f-dir10)
470 (dnop label9 "9 bit pc relative address" () h-iaddr f-rel9)
471 (dnop label12 "12 bit pc relative address" () h-iaddr f-rel12)
474 (name reglist_low_ld)
475 (comment "8 bit low register mask for ldm")
478 (index f-reglist_low_ld)
479 (handlers (parse "low_register_list_ld")
480 (print "low_register_list_ld"))
485 (comment "8 bit high register mask for ldm")
488 (index f-reglist_hi_ld)
489 (handlers (parse "hi_register_list_ld")
490 (print "hi_register_list_ld"))
494 (name reglist_low_st)
495 (comment "8 bit low register mask for stm")
498 (index f-reglist_low_st)
499 (handlers (parse "low_register_list_st")
500 (print "low_register_list_st"))
505 (comment "8 bit high register mask for stm")
508 (index f-reglist_hi_st)
509 (handlers (parse "hi_register_list_st")
510 (print "hi_register_list_st"))
513 (dnop cc "condition codes" () h-uint f-cc)
514 (dnop ccc "coprocessor calc" (HASH-PREFIX) h-uint f-ccc)
516 (dnop nbit "negative bit" (SEM-ONLY) h-nbit f-nil)
517 (dnop vbit "overflow bit" (SEM-ONLY) h-vbit f-nil)
518 (dnop zbit "zero bit" (SEM-ONLY) h-zbit f-nil)
519 (dnop cbit "carry bit" (SEM-ONLY) h-cbit f-nil)
520 (dnop ibit "interrupt bit" (SEM-ONLY) h-ibit f-nil)
521 (dnop sbit "stack bit" (SEM-ONLY) h-sbit f-nil)
522 (dnop tbit "trace trap bit" (SEM-ONLY) h-tbit f-nil)
523 (dnop d0bit "division 0 bit" (SEM-ONLY) h-d0bit f-nil)
524 (dnop d1bit "division 1 bit" (SEM-ONLY) h-d1bit f-nil)
526 (dnop ccr "condition code bits" (SEM-ONLY) h-ccr f-nil)
527 (dnop scr "system condition bits" (SEM-ONLY) h-scr f-nil)
528 (dnop ilm "interrupt level mask" (SEM-ONLY) h-ilm f-nil)
530 ; Instruction definitions.
533 ; - dni is short for "define-normal-instruction"
535 ; FR30 specific insn attributes:
540 (name NOT-IN-DELAY-SLOT)
541 (comment "insn can't go in delay slot")
544 ; Sets zbit and nbit based on the value of x
546 (define-pmacro (set-z-and-n x)
548 (set zbit (eq x (const 0)))
549 (set nbit (lt x (const 0))))
552 ; Binary integer instruction which sets status bits
554 (define-pmacro (binary-int-op name insn comment opc1 opc2 op arg1 arg2)
556 (.str insn " " comment)
558 (.str insn " $" arg1 ",$" arg2)
559 (+ opc1 opc2 arg1 arg2)
561 (set vbit ((.sym op -oflag) arg2 arg1 (const 0)))
562 (set cbit ((.sym op -cflag) arg2 arg1 (const 0)))
563 (set arg2 (op arg2 arg1))
569 ; Binary integer instruction which does *not* set status bits
571 (define-pmacro (binary-int-op-n name insn comment opc1 opc2 op arg1 arg2)
573 (.str insn " " comment)
575 (.str insn " $" arg1 ",$" arg2)
576 (+ opc1 opc2 arg1 arg2)
577 (set arg2 (op arg2 arg1))
582 ; Binary integer instruction with carry which sets status bits
584 (define-pmacro (binary-int-op-c name insn comment opc1 opc2 op arg1 arg2)
586 (.str insn " " comment)
588 (.str insn " $" arg1 ",$" arg2)
589 (+ opc1 opc2 arg1 arg2)
591 (set tmp ((.sym op c) arg2 arg1 cbit))
592 (set vbit ((.sym op -oflag) arg2 arg1 cbit))
593 (set cbit ((.sym op -cflag) arg2 arg1 cbit))
600 (binary-int-op add add "reg/reg" OP1_A OP2_6 add Rj Ri)
601 (binary-int-op addi add "immed/reg" OP1_A OP2_4 add u4 Ri)
602 (binary-int-op add2 add2 "immed/reg" OP1_A OP2_5 add m4 Ri)
603 (binary-int-op-c addc addc "reg/reg" OP1_A OP2_7 add Rj Ri)
604 (binary-int-op-n addn addn "reg/reg" OP1_A OP2_2 add Rj Ri)
605 (binary-int-op-n addni addn "immed/reg" OP1_A OP2_0 add u4 Ri)
606 (binary-int-op-n addn2 addn2 "immed/reg" OP1_A OP2_1 add m4 Ri)
608 (binary-int-op sub sub "reg/reg" OP1_A OP2_C sub Rj Ri)
609 (binary-int-op-c subc subc "reg/reg" OP1_A OP2_D sub Rj Ri)
610 (binary-int-op-n subn subn "reg/reg" OP1_A OP2_E sub Rj Ri)
612 ; Integer compare instruction
614 (define-pmacro (int-cmp name insn comment opc1 opc2 arg1 arg2)
616 (.str insn " " comment)
618 (.str insn " $" arg1 ",$" arg2)
619 (+ opc1 opc2 arg1 arg2)
620 (sequence ((WI tmp1))
621 (set vbit (sub-oflag arg2 arg1 (const 0)))
622 (set cbit (sub-cflag arg2 arg1 (const 0)))
623 (set tmp1 (sub arg2 arg1))
630 (int-cmp cmp cmp "reg/reg" OP1_A OP2_A Rj Ri)
631 (int-cmp cmpi cmp "immed/reg" OP1_A OP2_8 u4 Ri)
632 (int-cmp cmp2 cmp2 "immed/reg" OP1_A OP2_9 m4 Ri)
634 ; Binary logical instruction
636 (define-pmacro (binary-logical-op name insn comment opc1 opc2 op arg1 arg2)
638 (.str insn " " comment)
640 (.str insn " $" arg1 ",$" arg2)
641 (+ opc1 opc2 arg1 arg2)
643 (set arg2 (op arg2 arg1))
649 (binary-logical-op and and "reg/reg" OP1_8 OP2_2 and Rj Ri)
650 (binary-logical-op or or "reg/reg" OP1_9 OP2_2 or Rj Ri)
651 (binary-logical-op eor eor "reg/reg" OP1_9 OP2_A xor Rj Ri)
653 (define-pmacro (les-units model) ; les: load-exec-store
654 (model (unit u-exec) (unit u-load) (unit u-store))
657 ; Binary logical instruction to memory
659 (define-pmacro (binary-logical-op-m name insn comment opc1 opc2 mode op arg1 arg2)
661 (.str insn " " comment)
663 (.str insn " $" arg1 ",@$" arg2)
664 (+ opc1 opc2 arg1 arg2)
665 (sequence ((mode tmp))
666 (set mode tmp (op mode (mem mode arg2) arg1))
668 (set mode (mem mode arg2) tmp))
673 (binary-logical-op-m andm and "reg/mem" OP1_8 OP2_4 WI and Rj Ri)
674 (binary-logical-op-m andh andh "reg/mem" OP1_8 OP2_5 HI and Rj Ri)
675 (binary-logical-op-m andb andb "reg/mem" OP1_8 OP2_6 QI and Rj Ri)
676 (binary-logical-op-m orm or "reg/mem" OP1_9 OP2_4 WI or Rj Ri)
677 (binary-logical-op-m orh orh "reg/mem" OP1_9 OP2_5 HI or Rj Ri)
678 (binary-logical-op-m orb orb "reg/mem" OP1_9 OP2_6 QI or Rj Ri)
679 (binary-logical-op-m eorm eor "reg/mem" OP1_9 OP2_C WI xor Rj Ri)
680 (binary-logical-op-m eorh eorh "reg/mem" OP1_9 OP2_D HI xor Rj Ri)
681 (binary-logical-op-m eorb eorb "reg/mem" OP1_9 OP2_E QI xor Rj Ri)
683 ; Binary logical instruction to low half of byte in memory
689 (+ OP1_8 OP2_0 u4 Ri)
692 (or QI u4 (const #xf0))
701 (+ OP1_9 OP2_0 u4 Ri)
702 (set QI (mem QI Ri) (or QI u4 (mem QI Ri)))
710 (+ OP1_9 OP2_8 u4 Ri)
711 (set QI (mem QI Ri) (xor QI u4 (mem QI Ri)))
715 ; Binary logical instruction to high half of byte in memory
721 (+ OP1_8 OP2_1 u4 Ri)
724 (or QI (sll QI u4 (const 4)) (const #x0f))
729 (define-pmacro (binary-or-op-mh name insn opc1 opc2 op arg1 arg2)
731 (.str name " #" arg1 ",@" args)
733 (.str name " $" arg1 ",@$" arg2)
734 (+ opc1 opc2 arg1 arg2)
735 (set QI (mem QI arg2)
737 (sll QI arg1 (const 4))
743 (binary-or-op-mh borh or OP1_9 OP2_1 or u4 Ri)
744 (binary-or-op-mh beorh xor OP1_9 OP2_9 xor u4 Ri)
750 (+ OP1_8 OP2_8 u4 Ri)
752 (set tmp (and QI u4 (mem QI Ri)))
753 (set zbit (eq tmp (const 0)))
754 (set nbit (const 0)))
755 ((fr30-1 (unit u-load) (unit u-exec (cycles 2))))
762 (+ OP1_8 OP2_9 u4 Ri)
764 (set tmp (and QI (sll QI u4 (const 4)) (mem QI Ri)))
765 (set zbit (eq tmp (const 0)))
766 (set nbit (lt tmp (const 0))))
767 ((fr30-1 (unit u-load) (unit u-exec (cycles 2))))
774 (+ OP1_A OP2_F Rj Ri)
776 (set tmp (mul DI (ext DI Rj) (ext DI Ri)))
777 (set (reg h-dr 5) (trunc WI tmp))
778 (set (reg h-dr 4) (trunc WI (srl tmp (const 32))))
779 (set nbit (lt (reg h-dr 5) (const 0)))
780 (set zbit (eq tmp (const DI 0)))
782 (gt tmp (const DI #x7fffffff))
783 (lt tmp (neg (const DI #x80000000))))))
784 ((fr30-1 (unit u-exec (cycles 5))))
791 (+ OP1_A OP2_B Rj Ri)
793 (set tmp (mul DI (zext DI Rj) (zext DI Ri)))
794 (set (reg h-dr 5) (trunc WI tmp))
795 (set (reg h-dr 4) (trunc WI (srl tmp (const 32))))
796 (set nbit (lt (reg h-dr 4) (const 0)))
797 (set zbit (eq (reg h-dr 5) (const 0)))
798 (set vbit (ne (reg h-dr 4) (const 0))))
799 ((fr30-1 (unit u-exec (cycles 5))))
806 (+ OP1_B OP2_F Rj Ri)
808 (set (reg h-dr 5) (mul (trunc HI Rj) (trunc HI Ri)))
809 (set nbit (lt (reg h-dr 5) (const 0)))
810 (set zbit (ge (reg h-dr 5) (const 0))))
811 ((fr30-1 (unit u-exec (cycles 3))))
818 (+ OP1_B OP2_B Rj Ri)
820 (set (reg h-dr 5) (mul (and Rj (const #xffff))
821 (and Ri (const #xffff))))
822 (set nbit (lt (reg h-dr 5) (const 0)))
823 (set zbit (ge (reg h-dr 5) (const 0))))
824 ((fr30-1 (unit u-exec (cycles 3))))
831 (+ OP1_9 OP2_7 OP3_4 Ri)
833 (set d0bit (lt (reg h-dr 5) (const 0)))
834 (set d1bit (xor d0bit (lt Ri (const 0))))
835 (if (ne d0bit (const 0))
836 (set (reg h-dr 4) (const #xffffffff))
837 (set (reg h-dr 4) (const 0))))
845 (+ OP1_9 OP2_7 OP3_5 Ri)
847 (set d0bit (const 0))
848 (set d1bit (const 0))
849 (set (reg h-dr 4) (const 0)))
857 (+ OP1_9 OP2_7 OP3_6 Ri)
859 (set (reg h-dr 4) (sll (reg h-dr 4) (const 1)))
860 (if (lt (reg h-dr 5) (const 0))
861 (set (reg h-dr 4) (add (reg h-dr 4) (const 1))))
862 (set (reg h-dr 5) (sll (reg h-dr 5) (const 1)))
863 (if (eq d1bit (const 1))
865 (set tmp (add (reg h-dr 4) Ri))
866 (set cbit (add-cflag (reg h-dr 4) Ri (const 0))))
868 (set tmp (sub (reg h-dr 4) Ri))
869 (set cbit (sub-cflag (reg h-dr 4) Ri (const 0)))))
870 (if (not (xor (xor d0bit d1bit) cbit))
872 (set (reg h-dr 4) tmp)
873 (set (reg h-dr 5) (or (reg h-dr 5) (const 1)))))
874 (set zbit (eq (reg h-dr 4) (const 0))))
882 (+ OP1_9 OP2_7 OP3_7 Ri)
884 (if (eq d1bit (const 1))
886 (set tmp (add (reg h-dr 4) Ri))
887 (set cbit (add-cflag (reg h-dr 4) Ri (const 0))))
889 (set tmp (sub (reg h-dr 4) Ri))
890 (set cbit (sub-cflag (reg h-dr 4) Ri (const 0)))))
891 (if (eq tmp (const 0))
894 (set (reg h-dr 4) (const 0)))
895 (set zbit (const 0))))
903 (+ OP1_9 OP2_F OP3_6 OP4_0)
904 (if (eq zbit (const 1))
905 (set (reg h-dr 5) (add (reg h-dr 5) (const 1))))
913 (+ OP1_9 OP2_F OP3_7 OP4_0)
914 (if (eq d1bit (const 1))
915 (set (reg h-dr 5) (neg (reg h-dr 5))))
919 (define-pmacro (leftshift-op name insn opc1 opc2 arg1 arg2 shift-expr)
921 (.str insn " " arg1 "," arg2)
923 (.str insn " $" arg1 ",$" arg2)
924 (+ opc1 opc2 arg1 arg2)
925 (sequence ((WI shift))
926 (set shift shift-expr)
927 (if (ne shift (const 0))
929 (set cbit (ne (and arg2
931 (sub (const 32) shift)))
933 (set arg2 (sll arg2 shift)))
934 (set cbit (const 0)))
935 (set nbit (lt arg2 (const 0)))
936 (set zbit (eq arg2 (const 0))))
940 (leftshift-op lsl lsl OP1_B OP2_6 Rj Ri (and Rj (const #x1f)))
941 (leftshift-op lsli lsl OP1_B OP2_4 u4 Ri u4)
942 (leftshift-op lsl2 lsl2 OP1_B OP2_5 u4 Ri (add u4 (const #x10)))
944 (define-pmacro (rightshift-op name insn opc1 opc2 op arg1 arg2 shift-expr)
946 (.str insn " " arg1 "," arg2)
948 (.str insn " $" arg1 ",$" arg2)
949 (+ opc1 opc2 arg1 arg2)
950 (sequence ((WI shift))
951 (set shift shift-expr)
952 (if (ne shift (const 0))
954 (set cbit (ne (and arg2
956 (sub shift (const 1))))
958 (set arg2 (op arg2 shift)))
959 (set cbit (const 0)))
960 (set nbit (lt arg2 (const 0)))
961 (set zbit (eq arg2 (const 0))))
965 (rightshift-op lsr lsr OP1_B OP2_2 srl Rj Ri (and Rj (const #x1f)))
966 (rightshift-op lsri lsr OP1_B OP2_0 srl u4 Ri u4)
967 (rightshift-op lsr2 lsr2 OP1_B OP2_1 srl u4 Ri (add u4 (const #x10)))
968 (rightshift-op asr asr OP1_B OP2_A sra Rj Ri (and Rj (const #x1f)))
969 (rightshift-op asri asr OP1_B OP2_8 sra u4 Ri u4)
970 (rightshift-op asr2 asr2 OP1_B OP2_9 sra u4 Ri (add u4 (const #x10)))
973 "load 8 bit unsigned immediate"
981 ; Typing ldi:8 in in emacs is a pain.
982 (dnmi ldi8m "ldi:8 without the colon"
989 "load 20 bit unsigned immediate"
992 (+ OP1_9 OP2_B Ri i20)
994 ((fr30-1 (unit u-exec (cycles 2))))
997 ; Typing ldi:20 in in emacs is a pain.
998 (dnmi ldi20m "ldi:20 without the colon"
1005 "load 32 bit immediate"
1008 (+ OP1_9 OP2_F OP3_8 Ri i32)
1010 ((fr30-1 (unit u-exec (cycles 3))))
1013 ; Typing ldi:32 in in emacs is a pain.
1014 (dnmi ldi32m "ldi:32 without the colon"
1020 (define-pmacro (basic-ld name insn opc1 opc2 mode arg1 arg2)
1022 (.str name " @" arg1 "," arg2)
1024 (.str name " @$" arg1 ",$" arg2)
1025 (+ opc1 opc2 arg1 arg2)
1026 (set arg2 (mem mode arg1))
1027 ((fr30-1 (unit u-load)))
1031 (basic-ld ld ld OP1_0 OP2_4 WI Rj Ri)
1032 (basic-ld lduh lduh OP1_0 OP2_5 UHI Rj Ri)
1033 (basic-ld ldub ldub OP1_0 OP2_6 UQI Rj Ri)
1035 (define-pmacro (r13base-ld name insn opc1 opc2 mode arg1 arg2)
1037 (.str insn " @(R13," arg1 ")," arg2)
1039 (.str insn " @($R13,$" arg1 "),$" arg2)
1040 (+ opc1 opc2 arg1 arg2)
1041 (set arg2 (mem mode (add arg1 (reg h-gr 13))))
1042 ((fr30-1 (unit u-load)))
1046 (r13base-ld ldr13 ld OP1_0 OP2_0 WI Rj Ri)
1047 (r13base-ld ldr13uh lduh OP1_0 OP2_1 UHI Rj Ri)
1048 (r13base-ld ldr13ub ldub OP1_0 OP2_2 UQI Rj Ri)
1050 (define-pmacro (r14base-ld name insn opc1 mode arg1 arg2)
1052 (.str insn " @(R14," arg1 ")," arg2)
1054 (.str insn " @($R14,$" arg1 "),$" arg2)
1056 (set arg2 (mem mode (add arg1 (reg h-gr 14))))
1057 ((fr30-1 (unit u-load)))
1061 (r14base-ld ldr14 ld OP1_2 WI disp10 Ri)
1062 (r14base-ld ldr14uh lduh OP1_4 UHI disp9 Ri)
1063 (r14base-ld ldr14ub ldub OP1_6 UQI disp8 Ri)
1066 "ld @(R15,udisp6),Ri mem/reg"
1068 "ld @($R15,$udisp6),$Ri"
1069 (+ OP1_0 OP2_3 udisp6 Ri)
1070 (set Ri (mem WI (add udisp6 (reg h-gr 15))))
1071 ((fr30-1 (unit u-load)))
1078 (+ OP1_0 OP2_7 OP3_0 Ri)
1080 (set Ri (mem WI (reg h-gr 15)))
1081 (if (ne (ifield f-Ri) (const 15))
1082 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1083 ((fr30-1 (unit u-load)))
1086 ; This insn loads a value from where r15 points into the target register and
1087 ; then increments r15. If the target register is also r15, then the post
1088 ; increment is not performed.
1094 (+ OP1_0 OP2_7 OP3_8 Rs2)
1095 ; This seems more straight forward, but doesn't work due to a problem in
1096 ; cgen. We're trying to not increment r15 if it is the target register.
1098 ; (set Rs2 (mem WI (reg h-gr 15)))
1099 ; (if (not (or (and (eq (ifield f-Rs2) (const 2))
1100 ; (eq sbit (const 0)))
1101 ; (and (eq (ifield f-Rs2) (const 3))
1102 ; (eq sbit (const 1)))))
1103 ; (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))
1106 (sequence ((WI tmp))
1107 (set tmp (mem WI (reg h-gr 15))) ; save in case target is r15
1108 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))
1110 ((fr30-1 (unit u-load)))
1114 "ld @R15+,ps mem/reg"
1117 (+ OP1_0 OP2_7 OP3_9 OP4_0)
1119 (set ps (mem WI (reg h-gr 15)))
1120 (set (reg h-gr 15) (add (reg h-gr 15) (const 4))))
1121 ((fr30-1 (unit u-load)))
1124 (define-pmacro (basic-st name insn opc1 opc2 mode arg1 arg2)
1126 (.str name " " arg1 ",@" arg2)
1128 (.str name " $" arg1 ",@$" arg2)
1129 (+ opc1 opc2 arg1 arg2)
1130 (set (mem mode arg2) arg1)
1131 ((fr30-1 (unit u-store)))
1135 (basic-st st st OP1_1 OP2_4 WI Ri Rj)
1136 (basic-st sth sth OP1_1 OP2_5 HI Ri Rj)
1137 (basic-st stb stb OP1_1 OP2_6 QI Ri Rj)
1139 (define-pmacro (r13base-st name insn opc1 opc2 mode arg1 arg2)
1141 (.str insn " " arg1 ",@(R13," arg2 ")")
1143 (.str insn " $" arg1 ",@($R13,$" arg2 ")")
1144 (+ opc1 opc2 arg1 arg2)
1145 (set (mem mode (add arg2 (reg h-gr 13))) arg1)
1146 ((fr30-1 (unit u-store)))
1150 (r13base-st str13 st OP1_1 OP2_0 WI Ri Rj)
1151 (r13base-st str13h sth OP1_1 OP2_1 HI Ri Rj)
1152 (r13base-st str13b stb OP1_1 OP2_2 QI Ri Rj)
1154 (define-pmacro (r14base-st name insn opc1 mode arg1 arg2)
1156 (.str insn " " arg1 ",@(R14," arg2 ")")
1158 (.str insn " $" arg1 ",@($R14,$" arg2 ")")
1160 (set (mem mode (add arg2 (reg h-gr 14))) arg1)
1161 ((fr30-1 (unit u-store)))
1165 (r14base-st str14 st OP1_3 WI Ri disp10)
1166 (r14base-st str14h sth OP1_5 HI Ri disp9)
1167 (r14base-st str14b stb OP1_7 QI Ri disp8)
1170 "st Ri,@(R15,udisp6) reg/mem"
1172 "st $Ri,@($R15,$udisp6)"
1173 (+ OP1_1 OP2_3 udisp6 Ri)
1174 (set (mem WI (add (reg h-gr 15) udisp6)) Ri)
1175 ((fr30-1 (unit u-store)))
1178 ; These store insns predecrement r15 and then store the contents of the source
1179 ; register where r15 then points. If the source register is also r15, then the
1180 ; original value of r15 is stored.
1183 "st Ri,@-R15 reg/mem"
1186 (+ OP1_1 OP2_7 OP3_0 Ri)
1187 (sequence ((WI tmp))
1188 (set tmp Ri) ; save in case it's r15
1189 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1190 (set (mem WI (reg h-gr 15)) tmp))
1191 ((fr30-1 (unit u-store)))
1195 "st Rs,@-R15 reg/mem"
1198 (+ OP1_1 OP2_7 OP3_8 Rs2)
1199 (sequence ((WI tmp))
1200 (set tmp Rs2) ; save in case it's r15
1201 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1202 (set (mem WI (reg h-gr 15)) tmp))
1203 ((fr30-1 (unit u-store)))
1207 "st ps,@-R15 reg/mem"
1210 (+ OP1_1 OP2_7 OP3_9 OP4_0)
1212 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1213 (set (mem WI (reg h-gr 15)) ps))
1214 ((fr30-1 (unit u-store)))
1217 (define-pmacro (mov2gr name opc1 opc2 arg1 arg2)
1219 (.str "mov " arg1 "," arg2)
1221 (.str "mov $" arg1 ",$" arg2)
1222 (+ opc1 opc2 arg1 arg2)
1228 (mov2gr mov OP1_8 OP2_B Rj Ri)
1229 (mov2gr movdr OP1_B OP2_7 Rs1 Ri)
1235 (+ OP1_1 OP2_7 OP3_1 Ri)
1244 (+ OP1_B OP2_3 Rs1 Ri)
1253 (+ OP1_0 OP2_7 OP3_1 Ri)
1259 "jmp with no delay slot"
1262 (+ OP1_9 OP2_7 OP3_0 Ri)
1264 ((fr30-1 (unit u-cti)))
1267 (dni jmpd "jmp with delay slot"
1270 (+ OP1_9 OP2_F OP3_0 Ri)
1273 ((fr30-1 (unit u-cti)))
1276 ; These versions which use registers must appear before the other
1277 ; versions which use relative addresses due to a problem in cgen
1283 (+ OP1_9 OP2_7 OP3_1 Ri)
1285 (set (reg h-dr 1) (add pc (const 2)))
1287 ((fr30-1 (unit u-cti)))
1293 (+ OP1_9 OP2_F OP3_1 Ri)
1296 (set (reg h-dr 1) (add pc (const 4)))
1298 ((fr30-1 (unit u-cti)))
1300 ; end of reordered insns
1303 "call relative to pc"
1306 (+ OP1_D OP5_0 label12)
1308 (set (reg h-dr 1) (add pc (const 2)))
1310 ((fr30-1 (unit u-cti)))
1313 "call relative to pc"
1316 (+ OP1_D OP5_1 label12)
1319 (set (reg h-dr 1) (add pc (const 4)))
1321 ((fr30-1 (unit u-cti)))
1325 "return from subroutine"
1328 (+ OP1_9 OP2_7 OP3_2 OP4_0)
1329 (set pc (reg h-dr 1))
1330 ((fr30-1 (unit u-cti)))
1334 "return from subroutine with delay slot"
1337 (+ OP1_9 OP2_F OP3_2 OP4_0)
1339 (set pc (reg h-dr 1)))
1340 ((fr30-1 (unit u-cti)))
1349 ; This is defered to fr30_int because for the breakpoint case
1350 ; we want to change as little of the machine state as possible.
1351 ; Push PS onto the system stack
1352 ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
1353 ;(set UWI (mem UWI (reg h-dr 2)) ps)
1354 ; Push the return address onto the system stack
1355 ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
1356 ;(set UWI (mem UWI (reg h-dr 2)) (add pc (const 2)))
1358 ;(set ibit (const 0))
1359 ;(set sbit (const 0))
1361 ; We still should indicate what is modified by this insn.
1362 (clobber (reg h-dr 2))
1365 ; ??? (clobber memory)?
1367 ; fr30_int handles operating vs user mode
1368 (set WI pc (c-call WI "fr30_int" pc u8))
1370 ; This is more properly a cti, but branch stall calculation is different.
1371 ((fr30-1 (unit u-exec (cycles 6))))
1375 "interrupt for emulator"
1378 (+ OP1_9 OP2_F OP3_3 OP4_0)
1380 ; This is defered to fr30_inte because for the breakpoint case
1381 ; we want to change as little of the machine state as possible.
1382 ; Push PS onto the system stack
1383 ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
1384 ;(set UWI (mem UWI (reg h-dr 2)) ps)
1385 ; Push the return address onto the system stack
1386 ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
1387 ;(set UWI (mem UWI (reg h-dr 2)) (add pc (const 2)))
1389 ;(set ibit (const 0))
1390 ;(set ilm (const 4))
1392 ; We still should indicate what is modified by this insn.
1393 (clobber (reg h-dr 2))
1396 ; ??? (clobber memory)?
1398 ; fr30_int handles operating vs user mode
1399 (set WI pc (c-call WI "fr30_inte" pc))
1401 ; This is more properly a cti, but branch stall calculation is different.
1402 ((fr30-1 (unit u-exec (cycles 6))))
1406 "return from interrupt"
1409 (+ OP1_9 OP2_7 OP3_3 OP4_0)
1410 (if (eq sbit (const 0))
1412 ; Pop the return address from the system stack
1413 (set UWI pc (mem UWI (reg h-dr 2)))
1414 (set (reg h-dr 2) (add (reg h-dr 2) (const 4)))
1415 ; Pop PS from the system stack
1416 (set UWI ps (mem UWI (reg h-dr 2)))
1417 (set (reg h-dr 2) (add (reg h-dr 2) (const 4)))
1420 ; Pop the return address from the user stack
1421 (set UWI pc (mem UWI (reg h-dr 3)))
1422 (set (reg h-dr 3) (add (reg h-dr 3) (const 4)))
1423 ; Pop PS from the user stack
1424 (set UWI ps (mem UWI (reg h-dr 3)))
1425 (set (reg h-dr 3) (add (reg h-dr 3) (const 4)))
1428 ; This is more properly a cti, but branch stall calculation is different.
1429 ((fr30-1 (unit u-exec (cycles 4))))
1432 ; Conditional branches with and without delay slots
1434 (define-pmacro (cond-branch cc condition)
1437 (.str (.sym b cc :d) " label9")
1439 (.str (.sym b cc :d) " $label9")
1440 (+ OP1_F (.sym CC_ cc) label9)
1442 (if condition (set pc label9)))
1443 ((fr30-1 (unit u-cti)))
1446 (.str (.sym b cc) " label9")
1448 (.str (.sym b cc) " $label9")
1449 (+ OP1_E (.sym CC_ cc) label9)
1450 (if condition (set pc label9))
1451 ((fr30-1 (unit u-cti)))
1456 (cond-branch ra (const BI 1))
1457 (cond-branch no (const BI 0))
1458 (cond-branch eq zbit)
1459 (cond-branch ne (not zbit))
1460 (cond-branch c cbit)
1461 (cond-branch nc (not cbit))
1462 (cond-branch n nbit)
1463 (cond-branch p (not nbit))
1464 (cond-branch v vbit)
1465 (cond-branch nv (not vbit))
1466 (cond-branch lt (xor vbit nbit))
1467 (cond-branch ge (not (xor vbit nbit)))
1468 (cond-branch le (or (xor vbit nbit) zbit))
1469 (cond-branch gt (not (or (xor vbit nbit) zbit)))
1470 (cond-branch ls (or cbit zbit))
1471 (cond-branch hi (not (or cbit zbit)))
1473 (define-pmacro (dir2r13 name insn opc1 opc2 mode arg1)
1475 (.str insn " @" arg1 ",R13")
1477 (.str insn " @$" arg1 ",$R13")
1479 (set (reg h-gr 13) (mem mode arg1))
1480 ((fr30-1 (unit u-load)))
1484 (define-pmacro (dir2r13-postinc name insn opc1 opc2 mode arg1 incr)
1486 (.str insn " @" arg1 ",@R13+")
1488 (.str insn " @$" arg1 ",@$R13+")
1491 (set (mem mode (reg h-gr 13)) (mem mode arg1))
1492 (set (reg h-gr 13) (add (reg h-gr 13) incr)))
1493 ((fr30-1 (unit u-load) (unit u-store)))
1497 (define-pmacro (r132dir name insn opc1 opc2 mode arg1)
1499 (.str insn " R13,@" arg1)
1501 (.str insn " $R13,@$" arg1)
1503 (set (mem mode arg1) (reg h-gr 13))
1504 ((fr30-1 (unit u-store)))
1508 (define-pmacro (r13-postinc2dir name insn opc1 opc2 mode arg1 incr)
1510 (.str insn " @R13+,@" arg1)
1512 (.str insn " @$R13+,@$" arg1)
1515 (set (mem mode arg1) (mem mode (reg h-gr 13)))
1516 (set (reg h-gr 13) (add (reg h-gr 13) incr)))
1517 ((fr30-1 (unit u-load) (unit u-store)))
1521 ; These versions which move from reg to mem must appear before the other
1522 ; versions which use immediate addresses due to a problem in cgen
1524 (r132dir dmovr13 dmov OP1_1 OP2_8 WI dir10)
1525 (r132dir dmovr13h dmovh OP1_1 OP2_9 HI dir9)
1526 (r132dir dmovr13b dmovb OP1_1 OP2_A QI dir8)
1528 (r13-postinc2dir dmovr13pi dmov OP1_1 OP2_C WI dir10 (const 4))
1529 (r13-postinc2dir dmovr13pih dmovh OP1_1 OP2_D HI dir9 (const 2))
1530 (r13-postinc2dir dmovr13pib dmovb OP1_1 OP2_E QI dir8 (const 1))
1535 "dmov @$R15+,@$dir10"
1536 (+ OP1_1 OP2_B dir10)
1538 (set (mem WI dir10) (mem WI (reg h-gr 15)))
1539 (set (reg h-gr 15) (add (reg h-gr 15) (const 4))))
1540 ((fr30-1 (unit u-load) (unit u-store)))
1542 ; End of reordered insns.
1544 (dir2r13 dmov2r13 dmov OP1_0 OP2_8 WI dir10)
1545 (dir2r13 dmov2r13h dmovh OP1_0 OP2_9 HI dir9)
1546 (dir2r13 dmov2r13b dmovb OP1_0 OP2_A QI dir8)
1548 (dir2r13-postinc dmov2r13pi dmov OP1_0 OP2_C WI dir10 (const 4))
1549 (dir2r13-postinc dmov2r13pih dmovh OP1_0 OP2_D HI dir9 (const 2))
1550 (dir2r13-postinc dmov2r13pib dmovb OP1_0 OP2_E QI dir8 (const 1))
1555 "dmov @$dir10,@-$R15"
1556 (+ OP1_0 OP2_B dir10)
1558 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1559 (set (mem WI (reg h-gr 15)) (mem WI dir10)))
1560 ((fr30-1 (unit u-load) (unit u-store)))
1563 ; Leave these insns as stubs for now, except for the increment of $Ri
1569 (+ OP1_B OP2_C u4 Ri)
1570 (set Ri (add Ri (const 4)))
1578 (+ OP1_B OP2_D u4 Ri)
1579 (set Ri (add Ri (const 4)))
1583 ; Leave the coprocessor insns as stubs for now.
1585 (define-pmacro (cop-stub name insn opc1 opc2 opc3 arg1 arg2)
1587 (.str insn " u4c,ccc,CRj," arg1 "," arg2)
1589 (.str insn " $u4c,$ccc,$" arg1 ",$" arg2)
1590 (+ opc1 opc2 opc3 u4c ccc arg1 arg2)
1596 (cop-stub copop copop OP1_9 OP2_F OP3_C CRj CRi)
1597 (cop-stub copld copld OP1_9 OP2_F OP3_D Rjc CRi)
1598 (cop-stub copst copst OP1_9 OP2_F OP3_E CRj Ric)
1599 (cop-stub copsv copsv OP1_9 OP2_F OP3_F CRj Ric)
1605 (+ OP1_9 OP2_F OP3_A OP4_0)
1615 (set ccr (and ccr u8))
1624 (set ccr (or ccr u8))
1633 (set ilm (and u8 (const #x1f)))
1642 (set (reg h-gr 15) (add (reg h-gr 15) s10))
1646 (define-pmacro (ext-op name opc1 opc2 opc3 op mode mask)
1651 (+ opc1 opc2 opc3 Ri)
1652 (set Ri (op WI (and mode Ri mask)))
1657 (ext-op extsb OP1_9 OP2_7 OP3_8 ext QI (const #xff))
1658 (ext-op extub OP1_9 OP2_7 OP3_9 zext UQI (const #xff))
1659 (ext-op extsh OP1_9 OP2_7 OP3_A ext HI (const #xffff))
1660 (ext-op extuh OP1_9 OP2_7 OP3_B zext UHI (const #xffff))
1663 "ldm0 (reglist_low_ld)"
1665 "ldm0 ($reglist_low_ld)"
1666 (+ OP1_8 OP2_C reglist_low_ld)
1668 (if (and reglist_low_ld (const #x1))
1670 (set (reg h-gr 0) (mem WI (reg h-gr 15)))
1671 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1672 (if (and reglist_low_ld (const #x2))
1674 (set (reg h-gr 1) (mem WI (reg h-gr 15)))
1675 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1676 (if (and reglist_low_ld (const #x4))
1678 (set (reg h-gr 2) (mem WI (reg h-gr 15)))
1679 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1680 (if (and reglist_low_ld (const #x8))
1682 (set (reg h-gr 3) (mem WI (reg h-gr 15)))
1683 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1684 (if (and reglist_low_ld (const #x10))
1686 (set (reg h-gr 4) (mem WI (reg h-gr 15)))
1687 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1688 (if (and reglist_low_ld (const #x20))
1690 (set (reg h-gr 5) (mem WI (reg h-gr 15)))
1691 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1692 (if (and reglist_low_ld (const #x40))
1694 (set (reg h-gr 6) (mem WI (reg h-gr 15)))
1695 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1696 (if (and reglist_low_ld (const #x80))
1698 (set (reg h-gr 7) (mem WI (reg h-gr 15)))
1699 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1701 ((fr30-1 (unit u-ldm)))
1705 "ldm1 (reglist_hi_ld)"
1707 "ldm1 ($reglist_hi_ld)"
1708 (+ OP1_8 OP2_D reglist_hi_ld)
1710 (if (and reglist_hi_ld (const #x1))
1712 (set (reg h-gr 8) (mem WI (reg h-gr 15)))
1713 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1714 (if (and reglist_hi_ld (const #x2))
1716 (set (reg h-gr 9) (mem WI (reg h-gr 15)))
1717 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1718 (if (and reglist_hi_ld (const #x4))
1720 (set (reg h-gr 10) (mem WI (reg h-gr 15)))
1721 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1722 (if (and reglist_hi_ld (const #x8))
1724 (set (reg h-gr 11) (mem WI (reg h-gr 15)))
1725 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1726 (if (and reglist_hi_ld (const #x10))
1728 (set (reg h-gr 12) (mem WI (reg h-gr 15)))
1729 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1730 (if (and reglist_hi_ld (const #x20))
1732 (set (reg h-gr 13) (mem WI (reg h-gr 15)))
1733 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1734 (if (and reglist_hi_ld (const #x40))
1736 (set (reg h-gr 14) (mem WI (reg h-gr 15)))
1737 (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
1738 (if (and reglist_hi_ld (const #x80))
1739 (set (reg h-gr 15) (mem WI (reg h-gr 15))))
1741 ((fr30-1 (unit u-ldm)))
1745 "stm0 (reglist_low_st)"
1747 "stm0 ($reglist_low_st)"
1748 (+ OP1_8 OP2_E reglist_low_st)
1750 (if (and reglist_low_st (const #x1))
1752 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1753 (set (mem WI (reg h-gr 15)) (reg h-gr 7))))
1754 (if (and reglist_low_st (const #x2))
1756 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1757 (set (mem WI (reg h-gr 15)) (reg h-gr 6))))
1758 (if (and reglist_low_st (const #x4))
1760 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1761 (set (mem WI (reg h-gr 15)) (reg h-gr 5))))
1762 (if (and reglist_low_st (const #x8))
1764 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1765 (set (mem WI (reg h-gr 15)) (reg h-gr 4))))
1766 (if (and reglist_low_st (const #x10))
1768 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1769 (set (mem WI (reg h-gr 15)) (reg h-gr 3))))
1770 (if (and reglist_low_st (const #x20))
1772 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1773 (set (mem WI (reg h-gr 15)) (reg h-gr 2))))
1774 (if (and reglist_low_st (const #x40))
1776 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1777 (set (mem WI (reg h-gr 15)) (reg h-gr 1))))
1778 (if (and reglist_low_st (const #x80))
1780 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1781 (set (mem WI (reg h-gr 15)) (reg h-gr 0))))
1783 ((fr30-1 (unit u-stm)))
1787 "stm1 (reglist_hi_st)"
1789 "stm1 ($reglist_hi_st)"
1790 (+ OP1_8 OP2_F reglist_hi_st)
1792 (if (and reglist_hi_st (const #x1))
1793 (sequence ((WI save-r15))
1794 (set save-r15 (reg h-gr 15))
1795 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1796 (set (mem WI (reg h-gr 15)) save-r15)))
1797 (if (and reglist_hi_st (const #x2))
1799 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1800 (set (mem WI (reg h-gr 15)) (reg h-gr 14))))
1801 (if (and reglist_hi_st (const #x4))
1803 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1804 (set (mem WI (reg h-gr 15)) (reg h-gr 13))))
1805 (if (and reglist_hi_st (const #x8))
1807 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1808 (set (mem WI (reg h-gr 15)) (reg h-gr 12))))
1809 (if (and reglist_hi_st (const #x10))
1811 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1812 (set (mem WI (reg h-gr 15)) (reg h-gr 11))))
1813 (if (and reglist_hi_st (const #x20))
1815 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1816 (set (mem WI (reg h-gr 15)) (reg h-gr 10))))
1817 (if (and reglist_hi_st (const #x40))
1819 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1820 (set (mem WI (reg h-gr 15)) (reg h-gr 9))))
1821 (if (and reglist_hi_st (const #x80))
1823 (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
1824 (set (mem WI (reg h-gr 15)) (reg h-gr 8))))
1826 ((fr30-1 (unit u-stm)))
1834 (sequence ((WI tmp))
1835 (set tmp (sub (reg h-gr 15) (const 4)))
1836 (set (mem WI tmp) (reg h-gr 14))
1837 (set (reg h-gr 14) tmp)
1838 (set (reg h-gr 15) (sub (reg h-gr 15) u10)))
1839 ((fr30-1 (unit u-exec (cycles 2))))
1846 (+ OP1_9 OP2_F OP3_9 OP4_0)
1848 (set (reg h-gr 15) (add (reg h-gr 14) (const 4)))
1849 (set (reg h-gr 14) (mem WI (sub (reg h-gr 15) (const 4)))))
1857 (+ OP1_8 OP2_A Rj Ri)
1858 (sequence ((WI tmp))
1860 (set Ri (mem UQI Rj))
1861 (set (mem UQI Rj) tmp))
1862 ((fr30-1 (unit u-load) (unit u-store)))