1 ; Renesas M32R CPU description. -*- Scheme -*-
3 ; Copyright 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
5 ; Contributed by Red Hat Inc; developed under contract from Mitsubishi
6 ; Electric Corporation.
8 ; This file is part of the GNU Binutils.
10 ; This program is free software; you can redistribute it and/or modify
11 ; it under the terms of the GNU General Public License as published by
12 ; the Free Software Foundation; either version 2 of the License, or
13 ; (at your option) any later version.
15 ; This program is distributed in the hope that it will be useful,
16 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ; GNU General Public License for more details.
20 ; You should have received a copy of the GNU General Public License
21 ; along with this program; if not, write to the Free Software
22 ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
24 (include "simplify.inc")
26 ; FIXME: Delete sign extension of accumulator results.
27 ; Sign extension is done when accumulator is read.
29 ; define-arch must appear first
32 (name m32r) ; name of cpu family
33 (comment "Renesas M32R")
34 (default-alignment aligned)
36 (machs m32r m32rx m32r2)
42 ; An attribute to describe which pipeline an insn runs in.
43 ; O_OS is a special attribute for sll, sra, sla, slli, srai, slai.
44 ; These instructions have O attribute for m32rx and OS attribute for m32r2.
50 (comment "parallel execution pipeline selection")
51 (values NONE O S OS O_OS)
54 ; A derived attribute that says which insns can be executed in parallel
55 ; with others. This is a required attribute for architectures with
62 (attrs META) ; do not define in any generated file for now
64 (default (if (eq-attr (current-insn) PIPE NONE) (symbol NO) (symbol YES)))
67 ; Instruction set parameters.
72 ; This is 32 because 16 bit insns always appear as pairs.
73 ; ??? See if this can go away. It's only used by the disassembler (right?)
74 ; to decide how long an unknown insn is. One value isn't sufficient (e.g. if
75 ; on a 16 bit (and not 32 bit) boundary, will only want to advance pc by 16.)
76 (default-insn-bitsize 32)
78 ; Number of bytes of insn we can initially fetch.
79 ; The M32R is tricky in that insns are either two 16-bit insns
80 ; (executed sequentially or in parallel) or one 32-bit insn.
81 ; So on one hand the base insn size is 16 bits, but on another it's 32.
82 ; 32 is chosen because:
83 ; - if the chip were ever bi-endian it is believed that the byte order would
84 ; be based on 32 bit quantities
85 ; - 32 bit insns are always aligned on 32 bit boundaries
86 ; - the pc will never stop on a 16 bit (and not 32 bit) boundary
87 ; [well actually it can, but there are no branches to such places]
88 (base-insn-bitsize 32)
90 ; Used in computing bit numbers.
91 (default-insn-word-bitsize 32)
93 ; The m32r fetches 2 insns at a time.
96 ; While the m32r can execute insns in parallel, the base mach can't
97 ; (other than nop). The base mach is greatly handicapped by this, but
98 ; we still need to cleanly handle it.
101 ; Initial bitnumbers to decode insns by.
102 (decode-assist (0 1 2 3 8 9 10 11))
104 ; Classification of instructions that fit in the various frames.
105 ; wip, not currently used
106 (insn-types (long ; name
108 (eq-attr (current-insn) LENGTH 31) ; matching insns
109 (0 1 2 7 8 9 10) ; decode-assist
113 (eq-attr (current-insn) LENGTH 15) ; matching insns
118 ; Instruction framing.
119 ; Each m32r insn is either one 32 bit insn, two 16 bit insns executed
120 ; serially (left->right), or two 16 bit insns executed parallelly.
121 ; wip, not currently used
123 ((long)) ; list of insns in frame, plus constraint
125 (+ (1 1) (31 $0)) ; value
126 (sequence () (execute $0)) ; action
132 (+ (1 0) (15 $0) (1 0) (15 $1))
138 ((short (eq-attr (current-insn) PIPE "O,BOTH"))
139 (short (eq-attr (current-insn) PIPE "S,BOTH")))
141 (+ (1 0) (15 $0) (1 1) (15 $1))
148 ; Cpu family definitions.
150 ; ??? define-cpu-family [and in general "cpu-family"] might be clearer than
152 ; ??? Have define-arch provide defaults for architecture that define-cpu can
153 ; then override [reduces duplication in define-cpu].
154 ; ??? Another way to go is to delete cpu-families entirely and have one mach
155 ; able to inherit things from another mach (would also need the ability to
156 ; not only override specific inherited things but also disable some,
157 ; e.g. if an insn wasn't supported).
160 ; cpu names must be distinct from the architecture name and machine names.
161 ; The "b" suffix stands for "base" and is the convention.
162 ; The "f" suffix stands for "family" and is the convention.
164 (comment "Renesas M32R base family")
167 ; Override isa spec (??? keeps things simpler, though it was more true
168 ; in the early days and not so much now).
174 (comment "Renesas M32Rx family")
177 ; Generated files have an "x" suffix.
183 (comment "Renesas M32R2 family")
186 ; Generated files have an "2" suffix.
192 (comment "Generic M32R cpu")
198 (comment "M32RX cpu")
204 (comment "M32R2 cpu")
208 ; Model descriptions.
210 ; The meaning of this value is wip but at the moment it's intended to describe
211 ; the implementation (i.e. what -mtune=foo does in sparc gcc).
214 ; - format of pipeline entry:
215 ; (pipeline name (stage1-name ...) (stage2-name ...) ...)
216 ; The contents of a stage description is wip.
217 ; - each mach must have at least one model
218 ; - the default model must be the first one
219 ;- maybe have `retire' support update total cycle count to handle current
220 ; parallel insn cycle counting problems
223 (name m32r/d) (comment "m32r/d") (attrs)
229 (pipeline p-non-mem "" () ((fetch) (decode) (execute) (writeback)))
230 (pipeline p-mem "" () ((fetch) (decode) (execute) (memory) (writeback)))
232 ; `state' is a list of variables for recording model state
234 ; bit mask of h-gr registers, =1 means value being loaded from memory
238 (unit u-exec "Execution Unit" ()
241 ((sr INT -1) (dr INT -1)) ; inputs
242 ((dr INT -1)) ; outputs
243 () ; profile action (default)
245 (unit u-cmp "Compare Unit" ()
248 ((src1 INT -1) (src2 INT -1)) ; inputs
250 () ; profile action (default)
252 (unit u-mac "Multiply/Accumulate Unit" ()
255 ((src1 INT -1) (src2 INT -1)) ; inputs
257 () ; profile action (default)
259 (unit u-cti "Branch Unit" ()
262 ((sr INT -1)) ; inputs
264 () ; profile action (default)
266 (unit u-load "Memory Load Unit" ()
273 () ; profile action (default)
275 (unit u-store "Memory Store Unit" ()
278 ((src1 INT) (src2 INT)) ; inputs
279 () ; ((st-mem AI)) ; outputs
280 () ; profile action (default)
285 (name test) (comment "test") (attrs)
287 (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
288 (unit u-exec "Execution Unit" ()
293 ; Each mach must have at least one model.
296 (name m32rx) (comment "m32rx") (attrs)
299 ; ??? It's 6 stages but I forget the details right now.
300 (pipeline p-o "" () ((fetch) (decode) (execute) (writeback)))
301 (pipeline p-s "" () ((fetch) (decode) (execute) (writeback)))
302 (pipeline p-o-mem "" () ((fetch) (decode) (execute) (memory) (writeback)))
304 (unit u-exec "Execution Unit" ()
307 ((sr INT -1) (dr INT -1)) ; inputs
308 ((dr INT -1)) ; outputs
309 () ; profile action (default)
311 (unit u-cmp "Compare Unit" ()
314 ((src1 INT -1) (src2 INT -1)) ; inputs
316 () ; profile action (default)
318 (unit u-mac "Multiply/Accumulate Unit" ()
321 ((src1 INT -1) (src2 INT -1)) ; inputs
323 () ; profile action (default)
325 (unit u-cti "Branch Unit" ()
328 ((sr INT -1)) ; inputs
330 () ; profile action (default)
332 (unit u-load "Memory Load Unit" ()
337 () ; profile action (default)
339 (unit u-store "Memory Store Unit" ()
342 ((src1 INT) (src2 INT)) ; inputs
344 () ; profile action (default)
349 (name m32r2) (comment "m32r2") (attrs)
352 ; ??? It's 6 stages but I forget the details right now.
353 (pipeline p-o "" () ((fetch) (decode) (execute) (writeback)))
354 (pipeline p-s "" () ((fetch) (decode) (execute) (writeback)))
355 (pipeline p-o-mem "" () ((fetch) (decode) (execute) (memory) (writeback)))
357 (unit u-exec "Execution Unit" ()
360 ((sr INT -1) (dr INT -1)) ; inputs
361 ((dr INT -1)) ; outputs
362 () ; profile action (default)
364 (unit u-cmp "Compare Unit" ()
367 ((src1 INT -1) (src2 INT -1)) ; inputs
369 () ; profile action (default)
371 (unit u-mac "Multiply/Accumulate Unit" ()
374 ((src1 INT -1) (src2 INT -1)) ; inputs
376 () ; profile action (default)
378 (unit u-cti "Branch Unit" ()
381 ((sr INT -1)) ; inputs
383 () ; profile action (default)
385 (unit u-load "Memory Load Unit" ()
390 () ; profile action (default)
392 (unit u-store "Memory Store Unit" ()
395 ((src1 INT) (src2 INT)) ; inputs
397 () ; profile action (default)
401 ; The instruction fetch/execute cycle.
402 ; This is split into two parts as sometimes more than one instruction is
404 ; The `const SI' argument to decode/execute is used to distinguish
405 ; multiple instructions processed at the same time (e.g. m32r).
407 ; ??? This is wip, and not currently used.
408 ; ??? Needs to be moved to define-isa.
410 ; This is how to fetch and decode an instruction.
414 ; (if VOID (ne AI (and AI pc (const AI 3)) (const AI 0))
416 ; (set-quiet USI (scratch UHI insn1) (ifetch UHI pc))
417 ; (decode VOID pc (and UHI insn1 (const UHI #x7fff))
420 ; (set-quiet USI (scratch USI insn) (ifetch USI pc))
421 ; (if VOID (ne USI (and USI insn (const USI #x80000000))
423 ; (decode VOID pc (srl USI insn (const WI 16)) (const SI 0))
425 ; ; ??? parallel support
426 ; (decode VOID pc (srl USI insn (const WI 16))
428 ; (decode VOID (add AI pc (const AI 2))
429 ; (and USI insn (const WI #x7fff))
434 ; This is how to execute a decoded instruction.
437 ; (sequence VOID () ; () is empty option list
439 ; (set AI new_pc (execute: AI (const 0)) #:quiet)
440 ; (set AI pc new_pc #:direct)
444 ; FIXME: It might simplify things to separate the execute process from the
445 ; one that updates the PC.
447 ; Instruction fields.
450 ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
451 ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
452 ; RESERVED: bits are not used to decode insn, must be all 0
453 ; RELOC: there is a relocation associated with this field (experiment)
459 (comment "there is a reloc associated with this field (experiment)")
462 (dnf f-op1 "op1" () 0 4)
463 (dnf f-op2 "op2" () 8 4)
464 (dnf f-cond "cond" () 4 4)
465 (dnf f-r1 "r1" () 4 4)
466 (dnf f-r2 "r2" () 12 4)
467 (df f-simm8 "simm8" () 8 8 INT #f #f)
468 (df f-simm16 "simm16" () 16 16 INT #f #f)
469 (dnf f-shift-op2 "shift op2" () 8 3)
470 (dnf f-uimm3 "uimm3" () 5 3)
471 (dnf f-uimm4 "uimm4" () 12 4)
472 (dnf f-uimm5 "uimm5" () 11 5)
473 (dnf f-uimm8 "uimm8" () 8 8)
474 (dnf f-uimm16 "uimm16" () 16 16)
475 (dnf f-uimm24 "uimm24" (ABS-ADDR RELOC) 8 24)
476 (dnf f-hi16 "high 16 bits" (SIGN-OPT) 16 16)
477 (df f-disp8 "disp8, slot unknown" (PCREL-ADDR RELOC) 8 8 INT
478 ((value pc) (sra WI (sub WI value (and WI pc (const -4))) (const 2)))
479 ((value pc) (add WI (sll WI value (const 2)) (and WI pc (const -4)))))
480 (df f-disp16 "disp16" (PCREL-ADDR RELOC) 16 16 INT
481 ((value pc) (sra WI (sub WI value pc) (const 2)))
482 ((value pc) (add WI (sll WI value (const 2)) pc)))
483 (df f-disp24 "disp24" (PCREL-ADDR RELOC) 8 24 INT
484 ((value pc) (sra WI (sub WI value pc) (const 2)))
485 ((value pc) (add WI (sll WI value (const 2)) pc)))
487 (dnf f-op23 "op2.3" () 9 3)
488 (dnf f-op3 "op3" () 14 2)
489 (dnf f-acc "acc" () 8 1)
490 (dnf f-accs "accs" () 12 2)
491 (dnf f-accd "accd" () 4 2)
492 (dnf f-bits67 "bits67" () 6 2)
493 (dnf f-bit4 "bit4" () 4 1)
494 (dnf f-bit14 "bit14" () 14 1)
496 (define-ifield (name f-imm1) (comment "1 bit immediate, 0->1 1->2")
498 (start 15) (length 1)
499 (encode (value pc) (sub WI value (const WI 1)))
500 (decode (value pc) (add WI value (const WI 1)))
506 ; FIXME: should use die macro or some such
507 (define-normal-insn-enum insn-op1 "insn format enums" () OP1_ f-op1
508 ("0" "1" "2" "3" "4" "5" "6" "7"
509 "8" "9" "10" "11" "12" "13" "14" "15")
512 ; insn-op2: bits 8-11
513 ; FIXME: should use die macro or some such
514 (define-normal-insn-enum insn-op2 "op2 enums" () OP2_ f-op2
515 ("0" "1" "2" "3" "4" "5" "6" "7"
516 "8" "9" "10" "11" "12" "13" "14" "15")
520 ; These entries list the elements of the raw hardware.
521 ; They're also used to provide tables and other elements of the assembly
524 (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
526 (dnh h-hi16 "high 16 bits" ()
527 (immediate (UINT 16))
531 ; These two aren't technically needed.
532 ; They're here for illustration sake mostly.
533 ; Plus they cause the value to be stored in the extraction buffers to only
534 ; be 16 bits wide (vs 32 or 64). Whoopie ding. But it's fun.
535 (dnh h-slo16 "signed low 16 bits" ()
539 (dnh h-ulo16 "unsigned low 16 bits" ()
540 (immediate (UINT 16))
548 (values (fp 13) (lr 14) (sp 15)
549 (r0 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6) (r7 7)
550 (r8 8) (r9 9) (r10 10) (r11 11) (r12 12) (r13 13) (r14 14) (r15 15))
555 (comment "general registers")
556 (attrs PROFILE CACHE-ADDR)
557 (type register WI (16))
558 (indices extern-keyword gr-names)
565 (values (psw 0) (cbr 1) (spi 2) (spu 3)
566 (bpc 6) (bbpsw 8) (bbpc 14) (evb 5)
567 (cr0 0) (cr1 1) (cr2 2) (cr3 3)
568 (cr4 4) (cr5 5) (cr6 6) (cr7 7)
569 (cr8 8) (cr9 9) (cr10 10) (cr11 11)
570 (cr12 12) (cr13 13) (cr14 14) (cr15 15))
575 (comment "control registers")
576 (type register UWI (16))
577 (indices extern-keyword cr-names)
578 (get (index) (c-call UWI "@cpu@_h_cr_get_handler" index))
579 (set (index newval) (c-call VOID "@cpu@_h_cr_set_handler" index newval))
582 ; The actual accumulator is only 56 bits.
583 ; The top 8 bits are sign extended from bit 8 (when counting msb = bit 0).
584 ; To simplify the accumulator instructions, no attempt is made to keep the
585 ; top 8 bits properly sign extended (currently there's no point since they
586 ; all ignore them). When the value is read it is properly sign extended
587 ; [in the `get' handler].
590 (comment "accumulator")
592 (get () (c-call DI "@cpu@_h_accum_get_handler"))
593 (set (newval) (c-call VOID "@cpu@_h_accum_set_handler" newval))
596 ; FIXME: Revisit after sanitization can be removed. Remove h-accum.
599 (comment "accumulators")
600 (attrs (MACH m32rx,m32r2))
601 (type register DI (2))
602 (indices keyword "" ((a0 0) (a1 1)))
603 ; get/set so a0 accesses are redirected to h-accum.
604 ; They're also so reads can properly sign extend the value.
605 ; FIXME: Needn't be a function call.
606 (get (index) (c-call DI "@cpu@_h_accums_get_handler" index))
607 (set (index newval) (c-call VOID "@cpu@_h_accums_set_handler" index newval))
610 ; For condbit operand. FIXME: Need to allow spec of get/set of operands.
611 ; Having this separate from h-psw keeps the parts that use it simpler
612 ; [since they greatly outnumber those that use h-psw].
613 (dsh h-cond "condition bit" () (register BI))
615 ; The actual values of psw,bpsw,bbpsw are recorded here to allow access
619 (comment "psw part of psw")
621 ; get/set to handle cond bit.
622 ; FIXME: missing: use's and clobber's
623 ; FIXME: remove c-call?
624 (get () (c-call UQI "@cpu@_h_psw_get_handler"))
625 (set (newval) (c-call VOID "@cpu@_h_psw_set_handler" newval))
627 (dsh h-bpsw "backup psw" () (register UQI))
628 (dsh h-bbpsw "backup bpsw" () (register UQI))
630 ; FIXME: Later make add get/set specs and support SMP.
631 (dsh h-lock "lock" () (register BI))
633 ; Instruction Operands.
634 ; These entries provide a layer between the assembler and the raw hardware
635 ; description, and are used to refer to hardware elements in the semantic
636 ; code. Usually there's a bit of over-specification, but in more complicated
637 ; instruction sets there isn't.
639 ; M32R specific operand attributes:
645 (comment "immediates have an optional '#' prefix")
648 ; ??? Convention says this should be o-sr, but then the insn definitions
649 ; should refer to o-sr which is clumsy. The "o-" could be implicit, but
650 ; then it should be implicit for all the symbols here, but then there would
651 ; be confusion between (f-)simm8 and (h-)simm8.
652 ; So for now the rule is exactly as it appears here.
654 (dnop sr "source register" () h-gr f-r2)
655 (dnop dr "destination register" () h-gr f-r1)
656 ;; The assembler relies upon the fact that dr and src1 are the same field.
658 (dnop src1 "source register 1" () h-gr f-r1)
659 (dnop src2 "source register 2" () h-gr f-r2)
660 (dnop scr "source control register" () h-cr f-r2)
661 (dnop dcr "destination control register" () h-cr f-r1)
663 (dnop simm8 "8 bit signed immediate" (HASH-PREFIX) h-sint f-simm8)
664 (dnop simm16 "16 bit signed immediate" (HASH-PREFIX) h-sint f-simm16)
665 (dnop uimm3 "3 bit unsigned number" (HASH-PREFIX) h-uint f-uimm3)
666 (dnop uimm4 "4 bit trap number" (HASH-PREFIX) h-uint f-uimm4)
667 (dnop uimm5 "5 bit shift count" (HASH-PREFIX) h-uint f-uimm5)
668 (dnop uimm8 "8 bit unsigned immediate" (HASH-PREFIX) h-uint f-uimm8)
669 (dnop uimm16 "16 bit unsigned immediate" (HASH-PREFIX) h-uint f-uimm16)
671 (dnop imm1 "1 bit immediate" ((MACH m32rx,m32r2) HASH-PREFIX) h-uint f-imm1)
672 (dnop accd "accumulator destination register" ((MACH m32rx,m32r2)) h-accums f-accd)
673 (dnop accs "accumulator source register" ((MACH m32rx,m32r2)) h-accums f-accs)
674 (dnop acc "accumulator reg (d)" ((MACH m32rx,m32r2)) h-accums f-acc)
676 ; slo16,ulo16 are used in both with-hash-prefix/no-hash-prefix cases.
677 ; e.g. add3 r3,r3,#1 and ld r3,@(4,r4). We could use HASH-PREFIX.
678 ; Instead we create a fake operand `hash'. The m32r is an illustration port,
679 ; so we often try out various ways of doing things.
681 (define-operand (name hash) (comment "# prefix") (attrs)
682 (type h-sint) ; doesn't really matter
684 (handlers (parse "hash") (print "hash"))
687 ; For high(foo),shigh(foo).
690 (comment "high 16 bit immediate, sign optional")
694 (handlers (parse "hi16"))
697 ; For low(foo),sda(foo).
700 (comment "16 bit signed immediate, for low()")
704 (handlers (parse "slo16"))
710 (comment "16 bit unsigned immediate, for low()")
714 (handlers (parse "ulo16"))
717 (dnop uimm24 "24 bit address" (HASH-PREFIX) h-addr f-uimm24)
721 (comment "8 bit displacement")
725 ; ??? Early experiments had insert/extract fields here.
726 ; Moving these to f-disp8 made things cleaner, but may wish to re-introduce
727 ; fields here to handle more complicated cases.
730 (dnop disp16 "16 bit displacement" () h-iaddr f-disp16)
731 (dnop disp24 "24 bit displacement" (RELAX) h-iaddr f-disp24)
733 ; These hardware elements are refered to frequently.
735 (dnop condbit "condition bit" (SEM-ONLY) h-cond f-nil)
736 (dnop accum "accumulator" (SEM-ONLY) h-accum f-nil)
738 ; Instruction definitions.
741 ; - dni is a cover macro to the real "this is an instruction" keyword.
742 ; The syntax of the real one is yet to be determined.
743 ; At the lowest level (i.e. the "real" one) it will probably take a variable
744 ; list of arguments where each argument [perhaps after the standard three of
745 ; name, comment, attrs] is "(keyword arg-to-keyword)". This syntax is simple
746 ; and yet completely upward extensible. And given the macro facility, one
747 ; needn't code at that low a level so even though it'll be more verbose than
748 ; necessary it won't matter. This same reasoning can be applied to most
749 ; types of entries in this file.
751 ; M32R specific instruction attributes:
753 ; FILL-SLOT: Need next insn to begin on 32 bit boundary.
754 ; (A "slot" as used here is a 32 bit quantity that can either be filled with
755 ; one 32 bit insn or two 16 bit insns which go in the "left bin" and "right
756 ; bin" where the left bin is the one with a lower address).
762 (comment "fill right bin with `nop' if insn is in left bin")
769 (comment "non-public m32rx insn")
776 (comment "non-public m32r insn")
783 (comment "floating point insn")
786 ; IDOC attribute for instruction documentation.
792 (comment "insn kind for documentation")
798 (ACCUM - () "Accumulator")
799 (MAC - () "Multiply/Accumulate")
800 (MISC - () "Miscellaneous")
804 (define-pmacro (bin-op mnemonic op2-op sem-op imm-prefix imm)
807 (.str mnemonic " reg/reg")
808 ((PIPE OS) (IDOC ALU))
809 (.str mnemonic " $dr,$sr")
810 (+ OP1_0 op2-op dr sr)
811 (set dr (sem-op dr sr))
814 (dni (.sym mnemonic "3")
815 (.str mnemonic " reg/" imm)
817 (.str mnemonic "3 $dr,$sr," imm-prefix "$" imm)
818 (+ OP1_8 op2-op dr sr imm)
819 (set dr (sem-op sr imm))
824 (bin-op add OP2_10 add "$hash" slo16)
825 ; sub isn't present because sub3 doesn't exist.
826 (bin-op and OP2_12 and "" uimm16)
827 (bin-op or OP2_14 or "$hash" ulo16)
828 (bin-op xor OP2_13 xor "" uimm16)
831 ((PIPE OS) (IDOC ALU))
832 ;#.(string-append "addi " "$dr,$simm8") ; #. experiment
835 (set dr (add dr simm8))
836 ((m32r/d (unit u-exec))
837 (m32rx (unit u-exec))
838 (m32r2 (unit u-exec)))
842 ((PIPE OS) (IDOC ALU))
844 (+ OP1_0 OP2_8 dr sr)
847 (set condbit (add-oflag dr sr (const 0))))
853 "addv3 $dr,$sr,$simm16"
854 (+ OP1_8 OP2_8 dr sr simm16)
856 (set dr (add sr simm16))
857 (set condbit (add-oflag sr simm16 (const 0))))
862 ((PIPE OS) (IDOC ALU))
864 (+ OP1_0 OP2_9 dr sr)
866 (set dr (addc dr sr condbit))
867 (set condbit (add-cflag dr sr condbit)))
871 (dni bc8 "bc with 8 bit displacement"
872 (COND-CTI (PIPE O) (IDOC BR))
874 (+ OP1_7 (f-r1 12) disp8)
875 (if condbit (set pc disp8))
876 ((m32r/d (unit u-cti))
878 (m32r2 (unit u-cti)))
881 (dnmi bc8r "relaxable bc8"
882 (COND-CTI RELAXABLE (PIPE O) (IDOC BR))
887 (dni bc24 "bc with 24 bit displacement"
890 (+ OP1_15 (f-r1 12) disp24)
891 (if condbit (set pc disp24))
892 ((m32r/d (unit u-cti))
894 (m32r2 (unit u-cti)))
897 (dnmi bc24r "relaxable bc24"
898 (COND-CTI RELAXED (IDOC BR))
905 "beq $src1,$src2,$disp16"
906 (+ OP1_11 OP2_0 src1 src2 disp16)
907 (if (eq src1 src2) (set pc disp16))
908 ((m32r/d (unit u-cti) (unit u-cmp (cycles 0)))
909 (m32rx (unit u-cti) (unit u-cmp (cycles 0)))
910 (m32r2 (unit u-cti) (unit u-cmp (cycles 0))))
913 (define-pmacro (cbranch sym comment op2-op comp-op)
914 (dni sym comment (COND-CTI (IDOC BR))
915 (.str sym " $src2,$disp16")
916 (+ OP1_11 op2-op (f-r1 0) src2 disp16)
917 (if (comp-op src2 (const WI 0)) (set pc disp16))
918 ((m32r/d (unit u-cti) (unit u-cmp (cycles 0)))
919 (m32rx (unit u-cti) (unit u-cmp (cycles 0)))
920 (m32r2 (unit u-cti) (unit u-cmp (cycles 0))))
923 (cbranch beqz "beqz" OP2_8 eq)
924 (cbranch bgez "bgez" OP2_11 ge)
925 (cbranch bgtz "bgtz" OP2_13 gt)
926 (cbranch blez "blez" OP2_12 le)
927 (cbranch bltz "bltz" OP2_10 lt)
928 (cbranch bnez "bnez" OP2_9 ne)
930 (dni bl8 "bl with 8 bit displacement"
931 (UNCOND-CTI FILL-SLOT (PIPE O) (IDOC BR))
933 (+ OP1_7 (f-r1 14) disp8)
936 (add (and pc (const -4)) (const 4)))
938 ((m32r/d (unit u-cti))
940 (m32r2 (unit u-cti)))
943 (dnmi bl8r "relaxable bl8"
944 (UNCOND-CTI FILL-SLOT RELAXABLE (PIPE O) (IDOC BR))
949 (dni bl24 "bl with 24 bit displacement"
950 (UNCOND-CTI (IDOC BR))
952 (+ OP1_15 (f-r1 14) disp24)
954 (set (reg h-gr 14) (add pc (const 4)))
956 ((m32r/d (unit u-cti))
958 (m32r2 (unit u-cti)))
961 (dnmi bl24r "relaxable bl24"
962 (UNCOND-CTI RELAXED (IDOC BR))
967 (dni bcl8 "bcl with 8 bit displacement"
968 (COND-CTI FILL-SLOT (MACH m32rx,m32r2) (PIPE O) (IDOC BR))
970 (+ OP1_7 (f-r1 8) disp8)
974 (add (and pc (const -4))
977 ((m32rx (unit u-cti))
978 (m32r2 (unit u-cti)))
981 (dnmi bcl8r "relaxable bcl8"
982 (COND-CTI FILL-SLOT (MACH m32rx,m32r2) (PIPE O) RELAXABLE (IDOC BR))
987 (dni bcl24 "bcl with 24 bit displacement"
988 (COND-CTI (MACH m32rx,m32r2) (IDOC BR))
990 (+ OP1_15 (f-r1 8) disp24)
993 (set (reg h-gr 14) (add pc (const 4)))
995 ((m32rx (unit u-cti))
996 (m32r2 (unit u-cti)))
999 (dnmi bcl24r "relaxable bcl24"
1000 (COND-CTI (MACH m32rx,m32r2) RELAXED (IDOC BR))
1005 (dni bnc8 "bnc with 8 bit displacement"
1006 (COND-CTI (PIPE O) (IDOC BR))
1008 (+ OP1_7 (f-r1 13) disp8)
1009 (if (not condbit) (set pc disp8))
1010 ((m32r/d (unit u-cti))
1011 (m32rx (unit u-cti))
1012 (m32r2 (unit u-cti)))
1015 (dnmi bnc8r "relaxable bnc8"
1016 (COND-CTI RELAXABLE (PIPE O) (IDOC BR))
1021 (dni bnc24 "bnc with 24 bit displacement"
1022 (COND-CTI (IDOC BR))
1024 (+ OP1_15 (f-r1 13) disp24)
1025 (if (not condbit) (set pc disp24))
1026 ((m32r/d (unit u-cti))
1027 (m32rx (unit u-cti))
1028 (m32r2 (unit u-cti)))
1031 (dnmi bnc24r "relaxable bnc24"
1032 (COND-CTI RELAXED (IDOC BR))
1038 (COND-CTI (IDOC BR))
1039 "bne $src1,$src2,$disp16"
1040 (+ OP1_11 OP2_1 src1 src2 disp16)
1041 (if (ne src1 src2) (set pc disp16))
1042 ((m32r/d (unit u-cti) (unit u-cmp (cycles 0)))
1043 (m32rx (unit u-cti) (unit u-cmp (cycles 0)))
1044 (m32r2 (unit u-cti) (unit u-cmp (cycles 0))))
1047 (dni bra8 "bra with 8 bit displacement"
1048 (UNCOND-CTI FILL-SLOT (PIPE O) (IDOC BR))
1050 (+ OP1_7 (f-r1 15) disp8)
1052 ((m32r/d (unit u-cti))
1053 (m32rx (unit u-cti))
1054 (m32r2 (unit u-cti)))
1057 (dnmi bra8r "relaxable bra8"
1058 (UNCOND-CTI FILL-SLOT RELAXABLE (PIPE O) (IDOC BR))
1063 (dni bra24 "bra with 24 displacement"
1064 (UNCOND-CTI (IDOC BR))
1066 (+ OP1_15 (f-r1 15) disp24)
1068 ((m32r/d (unit u-cti))
1069 (m32rx (unit u-cti))
1070 (m32r2 (unit u-cti)))
1073 (dnmi bra24r "relaxable bra24"
1074 (UNCOND-CTI RELAXED (IDOC BR))
1079 (dni bncl8 "bncl with 8 bit displacement"
1080 (COND-CTI FILL-SLOT (MACH m32rx,m32r2) (PIPE O) (IDOC BR))
1082 (+ OP1_7 (f-r1 9) disp8)
1086 (add (and pc (const -4))
1089 ((m32rx (unit u-cti))
1090 (m32r2 (unit u-cti)))
1093 (dnmi bncl8r "relaxable bncl8"
1094 (COND-CTI FILL-SLOT (MACH m32rx,m32r2) (PIPE O) RELAXABLE (IDOC BR))
1099 (dni bncl24 "bncl with 24 bit displacement"
1100 (COND-CTI (MACH m32rx,m32r2) (IDOC BR))
1102 (+ OP1_15 (f-r1 9) disp24)
1105 (set (reg h-gr 14) (add pc (const 4)))
1107 ((m32rx (unit u-cti))
1108 (m32r2 (unit u-cti)))
1111 (dnmi bncl24r "relaxable bncl24"
1112 (COND-CTI (MACH m32rx,m32r2) RELAXED (IDOC BR))
1114 (emit bncl24 disp24)
1118 ((PIPE OS) (IDOC ALU))
1120 (+ OP1_0 OP2_4 src1 src2)
1121 (set condbit (lt src1 src2))
1122 ((m32r/d (unit u-cmp))
1123 (m32rx (unit u-cmp))
1124 (m32r2 (unit u-cmp)))
1129 "cmpi $src2,$simm16"
1130 (+ OP1_8 (f-r1 0) OP2_4 src2 simm16)
1131 (set condbit (lt src2 simm16))
1132 ((m32r/d (unit u-cmp))
1133 (m32rx (unit u-cmp))
1134 (m32r2 (unit u-cmp)))
1138 ((PIPE OS) (IDOC ALU))
1140 (+ OP1_0 OP2_5 src1 src2)
1141 (set condbit (ltu src1 src2))
1142 ((m32r/d (unit u-cmp))
1143 (m32rx (unit u-cmp))
1144 (m32r2 (unit u-cmp)))
1149 "cmpui $src2,$simm16"
1150 (+ OP1_8 (f-r1 0) OP2_5 src2 simm16)
1151 (set condbit (ltu src2 simm16))
1152 ((m32r/d (unit u-cmp))
1153 (m32rx (unit u-cmp))
1154 (m32r2 (unit u-cmp)))
1158 ((MACH m32rx,m32r2) (PIPE OS) (IDOC ALU))
1160 (+ OP1_0 OP2_6 src1 src2)
1161 (set condbit (eq src1 src2))
1162 ((m32rx (unit u-cmp))
1163 (m32r2 (unit u-cmp)))
1167 ((MACH m32rx,m32r2) (PIPE OS) (IDOC ALU))
1169 (+ OP1_0 OP2_7 (f-r1 0) src2)
1170 (set condbit (eq src2 (const 0)))
1171 ((m32rx (unit u-cmp))
1172 (m32r2 (unit u-cmp)))
1178 (+ OP1_9 OP2_0 dr sr (f-simm16 0))
1179 (if (ne sr (const 0)) (set dr (div dr sr)))
1180 ((m32r/d (unit u-exec (cycles 37)))
1181 (m32rx (unit u-exec (cycles 37)))
1182 (m32r2 (unit u-exec (cycles 37))))
1188 (+ OP1_9 OP2_1 dr sr (f-simm16 0))
1189 (if (ne sr (const 0)) (set dr (udiv dr sr)))
1190 ((m32r/d (unit u-exec (cycles 37)))
1191 (m32rx (unit u-exec (cycles 37)))
1192 (m32r2 (unit u-exec (cycles 37))))
1198 (+ OP1_9 OP2_2 dr sr (f-simm16 0))
1199 ; FIXME: Check rounding direction.
1200 (if (ne sr (const 0)) (set dr (mod dr sr)))
1201 ((m32r/d (unit u-exec (cycles 37)))
1202 (m32rx (unit u-exec (cycles 37)))
1203 (m32r2 (unit u-exec (cycles 37))))
1209 (+ OP1_9 OP2_3 dr sr (f-simm16 0))
1210 ; FIXME: Check rounding direction.
1211 (if (ne sr (const 0)) (set dr (umod dr sr)))
1212 ((m32r/d (unit u-exec (cycles 37)))
1213 (m32rx (unit u-exec (cycles 37)))
1214 (m32r2 (unit u-exec (cycles 37))))
1220 (+ OP1_9 OP2_2 dr sr (f-simm16 #x10))
1221 ; FIXME: Check rounding direction.
1222 (if (ne sr (const 0)) (set dr (mod (ext WI (trunc HI dr)) sr)))
1223 ((m32r2 (unit u-exec (cycles 21))))
1229 (+ OP1_9 OP2_3 dr sr (f-simm16 #x10))
1230 ; FIXME: Check rounding direction.
1231 (if (ne sr (const 0)) (set dr (umod dr sr)))
1232 ((m32r2 (unit u-exec (cycles 21))))
1238 (+ OP1_9 OP2_2 dr sr (f-simm16 #x18))
1239 ; FIXME: Check rounding direction.
1240 (if (ne sr (const 0)) (set dr (mod (ext WI (trunc BI dr)) sr)))
1241 ((m32r2 (unit u-exec (cycles 21))))
1247 (+ OP1_9 OP2_3 dr sr (f-simm16 #x18))
1248 ; FIXME: Check rounding direction.
1249 (if (ne sr (const 0)) (set dr (umod dr sr)))
1250 ((m32r2 (unit u-exec (cycles 21))))
1256 (+ OP1_9 OP2_1 dr sr (f-simm16 #x10))
1257 (if (ne sr (const 0)) (set dr (udiv dr sr)))
1258 ((m32r2 (unit u-exec (cycles 21))))
1264 (+ OP1_9 OP2_0 dr sr (f-simm16 #x18))
1265 (if (ne sr (const 0)) (set dr (div (ext WI (trunc BI dr)) sr)))
1266 ((m32r2 (unit u-exec (cycles 21))))
1272 (+ OP1_9 OP2_1 dr sr (f-simm16 #x18))
1273 (if (ne sr (const 0)) (set dr (udiv dr sr)))
1274 ((m32r2 (unit u-exec (cycles 21))))
1278 ((MACH m32rx,m32r2) (IDOC ALU))
1280 (+ OP1_9 OP2_0 dr sr (f-simm16 #x10))
1281 (if (ne sr (const 0)) (set dr (div (ext WI (trunc HI dr)) sr)))
1282 ((m32rx (unit u-exec (cycles 21)))
1283 (m32r2 (unit u-exec (cycles 21))))
1287 (COND-CTI (MACH m32rx,m32r2) (PIPE O) SPECIAL (IDOC BR))
1289 (+ OP1_1 (f-r1 12) OP2_12 sr)
1290 (if condbit (set pc (and sr (const -4))))
1291 ((m32rx (unit u-cti))
1292 (m32r2 (unit u-cti)))
1296 (COND-CTI (MACH m32rx,m32r2) (PIPE O) SPECIAL (IDOC BR))
1298 (+ OP1_1 (f-r1 13) OP2_12 sr)
1299 (if (not condbit) (set pc (and sr (const -4))))
1300 ((m32rx (unit u-cti))
1301 (m32r2 (unit u-cti)))
1305 (UNCOND-CTI FILL-SLOT (PIPE O) (IDOC BR))
1307 (+ OP1_1 (f-r1 14) OP2_12 sr)
1310 (add (and pc (const -4)) (const 4)))
1311 (set pc (and sr (const -4))))
1312 ((m32r/d (unit u-cti))
1313 (m32rx (unit u-cti))
1314 (m32r2 (unit u-cti)))
1318 (UNCOND-CTI (PIPE O) (IDOC BR))
1320 (+ OP1_1 (f-r1 15) OP2_12 sr)
1321 (set pc (and sr (const -4)))
1322 ; The above works now so this kludge has been commented out.
1323 ; It's kept around because the f-r1 reference in the semantic part
1325 ; FIXME: kludge, instruction decoding not finished.
1326 ; But this should work, so that's another FIXME.
1327 ;(sequence VOID (if VOID (eq SI f-r1 (const SI 14))
1328 ; FIXME: abuf->insn should be a macro of some sort.
1330 ; (if VOID (eq SI (c-code SI "((abuf->insn >> 8) & 15)")
1332 ; (set WI (reg WI h-gr 14)
1333 ; (add WI (and WI pc (const WI -4)) (const WI 4))))
1335 ((m32r/d (unit u-cti))
1336 (m32rx (unit u-cti))
1337 (m32r2 (unit u-cti)))
1340 (define-pmacro (no-ext-expr mode expr) expr)
1341 (define-pmacro (ext-expr mode expr) (ext mode expr))
1342 (define-pmacro (zext-expr mode expr) (zext mode expr))
1344 (define-pmacro (load-op suffix op2-op mode ext-op)
1346 (dni (.sym ld suffix) (.str "ld" suffix)
1347 ((PIPE O) (IDOC MEM))
1348 (.str "ld" suffix " $dr,@$sr")
1349 (+ OP1_2 op2-op dr sr)
1350 (set dr (ext-op WI (mem mode sr)))
1351 ((m32r/d (unit u-load))
1352 (m32rx (unit u-load))
1353 (m32r2 (unit u-load)))
1355 (dnmi (.sym ld suffix "-2") (.str "ld" suffix "-2")
1356 (NO-DIS (PIPE O) (IDOC MEM))
1357 (.str "ld" suffix " $dr,@($sr)")
1358 (emit (.sym ld suffix) dr sr))
1359 (dni (.sym ld suffix -d) (.str "ld" suffix "-d")
1361 (.str "ld" suffix " $dr,@($slo16,$sr)")
1362 (+ OP1_10 op2-op dr sr slo16)
1363 (set dr (ext-op WI (mem mode (add sr slo16))))
1364 ((m32r/d (unit u-load (cycles 2)))
1365 (m32rx (unit u-load (cycles 2)))
1366 (m32r2 (unit u-load (cycles 2))))
1368 (dnmi (.sym ld suffix -d2) (.str "ld" suffix "-d2")
1370 (.str "ld" suffix " $dr,@($sr,$slo16)")
1371 (emit (.sym ld suffix -d) dr sr slo16))
1374 (load-op "" OP2_12 WI no-ext-expr)
1375 (load-op b OP2_8 QI ext-expr)
1376 (load-op h OP2_10 HI ext-expr)
1377 (load-op ub OP2_9 QI zext-expr)
1378 (load-op uh OP2_11 HI zext-expr)
1381 ((PIPE O) (IDOC MEM))
1383 (+ OP1_2 dr OP2_14 sr)
1385 ; wip: memory addresses in profiling support
1386 ;(set dr (name ld-mem (mem WI sr)))
1387 (set dr (mem WI sr))
1388 (set sr (add sr (const 4))))
1389 ; Note: `pred' is the constraint. Also useful here is (ref name)
1390 ; and returns true if operand <name> was referenced
1391 ; (where "referenced" means _read_ if input operand and _written_ if
1393 ; args to unit are "unit-name (name1 value1) ..."
1394 ; - cycles(done),issue,pred are also specified this way
1395 ; - if unspecified, default is used
1396 ; - for ins/outs, extra arg is passed that says what was specified
1397 ; - this is AND'd with `written' for outs
1398 ((m32r/d (unit u-load (pred (const 1)))
1399 (unit u-exec (in sr #f) (in dr sr) (out dr sr) (cycles 0) (pred (const 1))))
1400 (m32rx (unit u-load)
1401 (unit u-exec (in sr #f) (in dr sr) (out dr sr) (cycles 0) (pred (const 1))))
1402 (m32r2 (unit u-load)
1403 (unit u-exec (in sr #f) (in dr sr) (out dr sr) (cycles 0) (pred (const 1))))
1408 ((PIPE O) (IDOC MEM))
1410 (emit ld-plus dr (sr 15)) ; "ld %0,@sp+"
1416 (+ OP1_14 dr uimm24)
1421 ; ldi8 appears before ldi16 so we try the shorter version first
1424 ((PIPE OS) (IDOC ALU))
1431 (dnmi ldi8a "ldi8 alias"
1432 ((PIPE OS) (IDOC ALU))
1434 (emit ldi8 dr simm8)
1439 "ldi16 $dr,$hash$slo16"
1440 (+ OP1_9 OP2_15 (f-r2 0) dr slo16)
1445 (dnmi ldi16a "ldi16 alias"
1447 "ldi $dr,$hash$slo16"
1448 (emit ldi16 dr slo16)
1452 ((PIPE O) (IDOC MISC))
1454 (+ OP1_2 OP2_13 dr sr)
1456 (set (reg h-lock) (const BI 1))
1457 (set dr (mem WI sr)))
1458 ((m32r/d (unit u-load))
1459 (m32rx (unit u-load))
1460 (m32r2 (unit u-load)))
1465 ; (MACH m32r) is a temporary hack. This insn collides with machi-a
1466 ; in the simulator so disable it for m32rx.
1467 (MACH m32r) (PIPE S) (IDOC MAC)
1470 (+ OP1_3 OP2_4 src1 src2)
1471 ; FIXME: TRACE_RESULT will print the wrong thing since we
1472 ; alter one of the arguments.
1479 (ext DI (and WI src1 (const #xffff0000)))
1480 (ext DI (trunc HI (sra WI src2 (const 16))))))
1483 ((m32r/d (unit u-mac)))
1486 (dni machi-a "machi-a"
1487 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1488 "machi $src1,$src2,$acc"
1489 (+ OP1_3 src1 acc (f-op23 4) src2)
1496 (ext DI (and WI src1 (const #xffff0000)))
1497 (ext DI (trunc HI (sra WI src2 (const 16))))))
1500 ((m32rx (unit u-mac))
1501 (m32r2 (unit u-mac)))
1505 ((MACH m32r) (PIPE S) (IDOC MAC))
1507 (+ OP1_3 OP2_5 src1 src2)
1514 (ext DI (sll WI src1 (const 16)))
1515 (ext DI (trunc HI src2))))
1518 ((m32r/d (unit u-mac)))
1521 (dni maclo-a "maclo-a"
1522 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1523 "maclo $src1,$src2,$acc"
1524 (+ OP1_3 src1 acc (f-op23 5) src2)
1531 (ext DI (sll WI src1 (const 16)))
1532 (ext DI (trunc HI src2))))
1535 ((m32rx (unit u-mac))
1536 (m32r2 (unit u-mac)))
1539 (dni macwhi "macwhi"
1540 ((MACH m32r) (PIPE S) (IDOC MAC))
1541 "macwhi $src1,$src2"
1542 (+ OP1_3 OP2_6 src1 src2)
1550 (ext DI (trunc HI (sra WI src2 (const 16))))))
1553 ((m32r/d (unit u-mac)))
1556 (dni macwhi-a "macwhi-a"
1557 ((MACH m32rx,m32r2) (PIPE S) SPECIAL (IDOC MAC))
1558 "macwhi $src1,$src2,$acc"
1559 (+ OP1_3 src1 acc (f-op23 6) src2)
1560 ; Note that this doesn't do the sign extension, which is correct.
1564 (ext DI (trunc HI (sra src2 (const 16)))))))
1565 ((m32rx (unit u-mac))
1566 (m32r2 (unit u-mac)))
1569 (dni macwlo "macwlo"
1570 ((MACH m32r) (PIPE S) (IDOC MAC))
1571 "macwlo $src1,$src2"
1572 (+ OP1_3 OP2_7 src1 src2)
1580 (ext DI (trunc HI src2))))
1583 ((m32r/d (unit u-mac)))
1586 (dni macwlo-a "macwlo-a"
1587 ((MACH m32rx,m32r2) (PIPE S) SPECIAL (IDOC MAC))
1588 "macwlo $src1,$src2,$acc"
1589 (+ OP1_3 src1 acc (f-op23 7) src2)
1590 ; Note that this doesn't do the sign extension, which is correct.
1594 (ext DI (trunc HI src2)))))
1595 ((m32rx (unit u-mac))
1596 (m32r2 (unit u-mac)))
1600 ((PIPE S) (IDOC ALU))
1602 (+ OP1_1 OP2_6 dr sr)
1603 (set dr (mul dr sr))
1604 ((m32r/d (unit u-exec (cycles 4)))
1605 (m32rx (unit u-exec (cycles 4)))
1606 (m32r2 (unit u-exec (cycles 4))))
1610 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1612 (+ OP1_3 OP2_0 src1 src2)
1617 (ext DI (and WI src1 (const #xffff0000)))
1618 (ext DI (trunc HI (sra WI src2 (const 16)))))
1621 ((m32r/d (unit u-mac)))
1624 (dni mulhi-a "mulhi-a"
1625 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1626 "mulhi $src1,$src2,$acc"
1627 (+ OP1_3 (f-op23 0) src1 acc src2)
1632 (ext DI (and WI src1 (const #xffff0000)))
1633 (ext DI (trunc HI (sra WI src2 (const 16)))))
1636 ((m32rx (unit u-mac))
1637 (m32r2 (unit u-mac)))
1641 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1643 (+ OP1_3 OP2_1 src1 src2)
1648 (ext DI (sll WI src1 (const 16)))
1649 (ext DI (trunc HI src2)))
1652 ((m32r/d (unit u-mac)))
1655 (dni mullo-a "mullo-a"
1656 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1657 "mullo $src1,$src2,$acc"
1658 (+ OP1_3 src1 acc (f-op23 1) src2)
1663 (ext DI (sll WI src1 (const 16)))
1664 (ext DI (trunc HI src2)))
1667 ((m32rx (unit u-mac))
1668 (m32r2 (unit u-mac)))
1671 (dni mulwhi "mulwhi"
1672 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1673 "mulwhi $src1,$src2"
1674 (+ OP1_3 OP2_2 src1 src2)
1680 (ext DI (trunc HI (sra WI src2 (const 16)))))
1683 ((m32r/d (unit u-mac)))
1686 (dni mulwhi-a "mulwhi-a"
1687 ((MACH m32rx,m32r2) (PIPE S) SPECIAL (IDOC ACCUM))
1688 "mulwhi $src1,$src2,$acc"
1689 (+ OP1_3 src1 acc (f-op23 2) src2)
1690 ; Note that this doesn't do the sign extension, which is correct.
1693 (ext DI (trunc HI (sra src2 (const 16))))))
1694 ((m32rx (unit u-mac))
1695 (m32r2 (unit u-mac)))
1698 (dni mulwlo "mulwlo"
1699 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1700 "mulwlo $src1,$src2"
1701 (+ OP1_3 OP2_3 src1 src2)
1707 (ext DI (trunc HI src2)))
1710 ((m32r/d (unit u-mac)))
1713 (dni mulwlo-a "mulwlo-a"
1714 ((MACH m32rx,m32r2) (PIPE S) SPECIAL (IDOC ACCUM))
1715 "mulwlo $src1,$src2,$acc"
1716 (+ OP1_3 src1 acc (f-op23 3) src2)
1717 ; Note that this doesn't do the sign extension, which is correct.
1720 (ext DI (trunc HI src2))))
1721 ((m32rx (unit u-mac))
1722 (m32r2 (unit u-mac)))
1726 ((PIPE OS) (IDOC ALU))
1728 (+ OP1_1 OP2_8 dr sr)
1733 (dni mvfachi "mvfachi"
1734 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1736 (+ OP1_5 OP2_15 (f-r2 0) dr)
1737 (set dr (trunc WI (sra DI accum (const 32))))
1738 ((m32r/d (unit u-exec (cycles 2))))
1741 (dni mvfachi-a "mvfachi-a"
1742 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1744 (+ OP1_5 dr OP2_15 accs (f-op3 0))
1745 (set dr (trunc WI (sra DI accs (const 32))))
1746 ((m32rx (unit u-exec (cycles 2)))
1747 (m32r2 (unit u-exec (cycles 2))))
1750 (dni mvfaclo "mvfaclo"
1751 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1753 (+ OP1_5 OP2_15 (f-r2 1) dr)
1754 (set dr (trunc WI accum))
1755 ((m32r/d (unit u-exec (cycles 2))))
1758 (dni mvfaclo-a "mvfaclo-a"
1759 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1761 (+ OP1_5 dr OP2_15 accs (f-op3 1))
1762 (set dr (trunc WI accs))
1763 ((m32rx (unit u-exec (cycles 2)))
1764 (m32r2 (unit u-exec (cycles 2))))
1767 (dni mvfacmi "mvfacmi"
1768 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1770 (+ OP1_5 OP2_15 (f-r2 2) dr)
1771 (set dr (trunc WI (sra DI accum (const 16))))
1772 ((m32r/d (unit u-exec (cycles 2))))
1775 (dni mvfacmi-a "mvfacmi-a"
1776 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1778 (+ OP1_5 dr OP2_15 accs (f-op3 2))
1779 (set dr (trunc WI (sra DI accs (const 16))))
1780 ((m32rx (unit u-exec (cycles 2)))
1781 (m32r2 (unit u-exec (cycles 2))))
1785 ((PIPE O) (IDOC MISC))
1787 (+ OP1_1 OP2_9 dr scr)
1792 (dni mvtachi "mvtachi"
1793 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1795 (+ OP1_5 OP2_7 (f-r2 0) src1)
1798 (and DI accum (const DI #xffffffff))
1799 (sll DI (ext DI src1) (const 32))))
1800 ((m32r/d (unit u-exec (in sr src1))))
1803 (dni mvtachi-a "mvtachi-a"
1804 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1805 "mvtachi $src1,$accs"
1806 (+ OP1_5 src1 OP2_7 accs (f-op3 0))
1809 (and DI accs (const DI #xffffffff))
1810 (sll DI (ext DI src1) (const 32))))
1811 ((m32rx (unit u-exec (in sr src1)))
1812 (m32r2 (unit u-exec (in sr src1))))
1815 (dni mvtaclo "mvtaclo"
1816 ((MACH m32r) (PIPE S) (IDOC ACCUM))
1818 (+ OP1_5 OP2_7 (f-r2 1) src1)
1821 (and DI accum (const DI #xffffffff00000000))
1823 ((m32r/d (unit u-exec (in sr src1))))
1826 (dni mvtaclo-a "mvtaclo-a"
1827 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
1828 "mvtaclo $src1,$accs"
1829 (+ OP1_5 src1 OP2_7 accs (f-op3 1))
1832 (and DI accs (const DI #xffffffff00000000))
1834 ((m32rx (unit u-exec (in sr src1)))
1835 (m32r2 (unit u-exec (in sr src1))))
1839 ((PIPE O) (IDOC MISC))
1841 (+ OP1_1 OP2_10 dcr sr)
1847 ((PIPE OS) (IDOC ALU))
1849 (+ OP1_0 OP2_3 dr sr)
1855 ((PIPE OS) (IDOC MISC))
1857 (+ OP1_7 OP2_0 (f-r1 0) (f-r2 0))
1858 (c-code VOID "PROFILE_COUNT_FILLNOPS (current_cpu, abuf->addr);\n")
1859 ; FIXME: quick hack: parallel nops don't contribute to cycle count.
1860 ; Other kinds of nops do however (which we currently ignore).
1861 ((m32r/d (unit u-exec (cycles 0)))
1862 (m32rx (unit u-exec (cycles 0)))
1863 (m32r2 (unit u-exec (cycles 0))))
1867 ((PIPE OS) (IDOC ALU))
1869 (+ OP1_0 OP2_11 dr sr)
1875 ((MACH m32r) (PIPE S) (IDOC MAC))
1877 (+ OP1_5 OP2_9 (f-r1 0) (f-r2 0))
1878 (sequence ((DI tmp1))
1879 (set tmp1 (sll DI accum (const 1)))
1880 (set tmp1 (add DI tmp1 (const DI #x8000)))
1883 ((gt tmp1 (const DI #x00007fffffff0000))
1884 (const DI #x00007fffffff0000))
1885 ((lt tmp1 (const DI #xffff800000000000))
1886 (const DI #xffff800000000000))
1887 (else (and tmp1 (const DI #xffffffffffff0000)))))
1889 ((m32r/d (unit u-mac)))
1892 (dni rac-dsi "rac-dsi"
1893 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1894 "rac $accd,$accs,$imm1"
1895 (+ OP1_5 accd (f-bits67 0) OP2_9 accs (f-bit14 0) imm1)
1896 (sequence ((DI tmp1))
1897 (set tmp1 (sll accs imm1))
1898 (set tmp1 (add tmp1 (const DI #x8000)))
1901 ((gt tmp1 (const DI #x00007fffffff0000))
1902 (const DI #x00007fffffff0000))
1903 ((lt tmp1 (const DI #xffff800000000000))
1904 (const DI #xffff800000000000))
1905 (else (and tmp1 (const DI #xffffffffffff0000)))))
1907 ((m32rx (unit u-mac))
1908 (m32r2 (unit u-mac)))
1912 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1914 (emit rac-dsi accd (f-accs 0) (f-imm1 0))
1917 (dnmi rac-ds "rac-ds"
1918 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1920 (emit rac-dsi accd accs (f-imm1 0))
1925 ((MACH m32r) (PIPE S) (IDOC MAC))
1927 (+ OP1_5 OP2_8 (f-r1 0) (f-r2 0))
1928 (sequence ((DI tmp1))
1929 ; Lop off top 8 bits.
1930 ; The sign bit we want to use is bit 55 so the 64 bit value
1931 ; isn't properly signed which we deal with in the if's below.
1932 (set tmp1 (and accum (const DI #xffffffffffffff)))
1933 (if (andif (ge tmp1 (const DI #x003fff80000000))
1934 (le tmp1 (const DI #x7fffffffffffff)))
1935 (set tmp1 (const DI #x003fff80000000))
1937 (if (andif (ge tmp1 (const DI #x80000000000000))
1938 (le tmp1 (const DI #xffc00000000000)))
1939 (set tmp1 (const DI #xffc00000000000))
1940 (set tmp1 (and (add accum (const DI #x40000000))
1941 (const DI #xffffffff80000000)))))
1942 (set tmp1 (sll tmp1 (const 1)))
1943 ; Sign extend top 8 bits.
1946 (sra DI (sll DI tmp1 (const 7)) (const 7)))
1948 ((m32r/d (unit u-mac)))
1951 (dni rach-dsi "rach-dsi"
1952 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1953 "rach $accd,$accs,$imm1"
1954 (+ OP1_5 accd (f-bits67 0) OP2_8 accs (f-bit14 0) imm1)
1955 (sequence ((DI tmp1))
1956 (set tmp1 (sll accs imm1))
1957 (set tmp1 (add tmp1 (const DI #x80000000)))
1960 ((gt tmp1 (const DI #x00007fff00000000))
1961 (const DI #x00007fff00000000))
1962 ((lt tmp1 (const DI #xffff800000000000))
1963 (const DI #xffff800000000000))
1964 (else (and tmp1 (const DI #xffffffff00000000)))))
1966 ((m32rx (unit u-mac))
1967 (m32r2 (unit u-mac)))
1970 (dnmi rach-d "rach-d"
1971 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1973 (emit rach-dsi accd (f-accs 0) (f-imm1 0))
1976 (dnmi rach-ds "rach-ds"
1977 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
1979 (emit rach-dsi accd accs (f-imm1 0))
1983 (UNCOND-CTI (PIPE O) (IDOC BR))
1985 (+ OP1_1 OP2_13 (f-r1 0) (f-r2 6))
1988 (set pc (and (reg h-cr 6) (const -4)))
1990 (set (reg h-cr 6) (reg h-cr 14))
1992 (set (reg h-psw) (reg h-bpsw))
1994 (set (reg h-bpsw) (reg h-bbpsw))
2001 "seth $dr,$hash$hi16"
2002 (+ OP1_13 OP2_12 dr (f-r2 0) hi16)
2003 (set dr (sll WI hi16 (const 16)))
2007 (define-pmacro (shift-op sym op2-r-op op2-3-op op2-i-op sem-op)
2009 (dni sym sym ((PIPE O_OS) (IDOC ALU))
2010 (.str sym " $dr,$sr")
2011 (+ OP1_1 op2-r-op dr sr)
2012 (set dr (sem-op dr (and sr (const 31))))
2015 (dni (.sym sym "3") sym ((IDOC ALU))
2016 (.str sym "3 $dr,$sr,$simm16")
2017 (+ OP1_9 op2-3-op dr sr simm16)
2018 (set dr (sem-op sr (and WI simm16 (const 31))))
2021 (dni (.sym sym "i") sym ((PIPE O_OS) (IDOC ALU))
2022 (.str sym "i $dr,$uimm5")
2023 (+ OP1_5 (f-shift-op2 op2-i-op) dr uimm5)
2024 (set dr (sem-op dr uimm5))
2029 (shift-op sll OP2_4 OP2_12 2 sll)
2030 (shift-op sra OP2_2 OP2_10 1 sra)
2031 (shift-op srl OP2_0 OP2_8 0 srl)
2033 (define-pmacro (store-op suffix op2-op mode)
2035 (dni (.sym st suffix) (.str "st" suffix)
2036 ((PIPE O) (IDOC MEM))
2037 (.str "st" suffix " $src1,@$src2")
2038 (+ OP1_2 op2-op src1 src2)
2039 (set mode (mem mode src2) src1)
2040 ((m32r/d (unit u-store (cycles 1)))
2041 (m32rx (unit u-store (cycles 1)))
2042 (m32r2 (unit u-store (cycles 1))))
2044 (dnmi (.sym st suffix "-2") (.str "st" suffix "-2")
2045 (NO-DIS (PIPE O) (IDOC MEM))
2046 (.str "st" suffix " $src1,@($src2)")
2047 (emit (.sym st suffix) src1 src2))
2048 (dni (.sym st suffix -d) (.str "st" suffix "-d")
2050 (.str "st" suffix " $src1,@($slo16,$src2)")
2051 (+ OP1_10 op2-op src1 src2 slo16)
2052 (set mode (mem mode (add src2 slo16)) src1)
2053 ((m32r/d (unit u-store (cycles 2)))
2054 (m32rx (unit u-store (cycles 2)))
2055 (m32r2 (unit u-store (cycles 2))))
2057 (dnmi (.sym st suffix -d2) (.str "st" suffix "-d2")
2059 (.str "st" suffix " $src1,@($src2,$slo16)")
2060 (emit (.sym st suffix -d) src1 src2 slo16))
2063 (store-op "" OP2_4 WI)
2064 (store-op b OP2_0 QI)
2065 (store-op h OP2_2 HI)
2068 ((PIPE O) (IDOC MEM))
2070 (+ OP1_2 OP2_6 src1 src2)
2071 ; This has to be coded carefully to avoid an "earlyclobber" of src2.
2072 (sequence ((WI new-src2))
2073 (set new-src2 (add WI src2 (const WI 4)))
2074 (set (mem WI new-src2) src1)
2075 (set src2 new-src2))
2076 ((m32r/d (unit u-store)
2077 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2078 (m32rx (unit u-store)
2079 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2080 (m32r2 (unit u-store)
2081 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2085 (dni sth-plus "sth+"
2086 ((MACH m32rx,m32r2) (PIPE O) SPECIAL)
2088 (+ OP1_2 OP2_3 src1 src2)
2089 ; This has to be coded carefully to avoid an "earlyclobber" of src2.
2090 (sequence ((HI new-src2))
2091 (set (mem HI new-src2) src1)
2092 (set new-src2 (add src2 (const 2)))
2093 (set src2 new-src2))
2094 ((m32rx (unit u-store)
2095 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2096 (m32r2 (unit u-store)
2097 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2101 (dni stb-plus "stb+"
2102 ((MACH m32rx,m32r2) (PIPE O) SPECIAL)
2104 (+ OP1_2 OP2_1 src1 src2)
2105 ; This has to be coded carefully to avoid an "earlyclobber" of src2.
2106 (sequence ((QI new-src2))
2107 (set (mem QI new-src2) src1)
2108 (set new-src2 (add src2 (const 1)))
2109 (set src2 new-src2))
2110 ((m32rx (unit u-store)
2111 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2112 (m32r2 (unit u-store)
2113 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2118 ((PIPE O) (IDOC MEM))
2120 (+ OP1_2 OP2_7 src1 src2)
2121 ; This is the original way. It doesn't work for parallel execution
2122 ; because of the earlyclobber of src2.
2124 ; (set src2 (sub src2 (const 4)))
2125 ; (set (mem WI src2) src1))
2126 (sequence ((WI new-src2))
2127 (set new-src2 (sub src2 (const 4)))
2128 (set (mem WI new-src2) src1)
2129 (set src2 new-src2))
2130 ((m32r/d (unit u-store)
2131 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2132 (m32rx (unit u-store)
2133 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2134 (m32r2 (unit u-store)
2135 (unit u-exec (in dr src2) (out dr src2) (cycles 0)))
2139 (dnmi push "push" ((PIPE O) (IDOC MEM))
2141 (emit st-minus src1 (src2 15)) ; "st %0,@-sp"
2145 ((PIPE OS) (IDOC ALU))
2147 (+ OP1_0 OP2_2 dr sr)
2148 (set dr (sub dr sr))
2153 ((PIPE OS) (IDOC ALU))
2155 (+ OP1_0 OP2_0 dr sr)
2157 (set dr (sub dr sr))
2158 (set condbit (sub-oflag dr sr (const 0))))
2163 ((PIPE OS) (IDOC ALU))
2165 (+ OP1_0 OP2_1 dr sr)
2167 (set dr (subc dr sr condbit))
2168 (set condbit (sub-cflag dr sr condbit)))
2173 (UNCOND-CTI FILL-SLOT (PIPE O) (IDOC MISC))
2175 (+ OP1_1 OP2_15 (f-r1 0) uimm4)
2178 (set (reg h-cr 14) (reg h-cr 6))
2179 ; Set bpc to the return address. Actually it's not quite the
2180 ; return address as RTE rounds the address down to a word
2182 (set (reg h-cr 6) (add pc (const 4)))
2184 (set (reg h-bbpsw) (reg h-bpsw))
2186 (set (reg h-bpsw) (reg h-psw))
2187 ; sm is unchanged, ie,c are set to zero.
2188 (set (reg h-psw) (and (reg h-psw) (const #x80)))
2189 ; m32r_trap handles operating vs user mode
2190 (set WI pc (c-call WI "m32r_trap" pc uimm4))
2195 (dni unlock "unlock"
2196 ((PIPE O) (IDOC MISC))
2197 "unlock $src1,@$src2"
2198 (+ OP1_2 OP2_5 src1 src2)
2201 (set (mem WI src2) src1))
2202 (set (reg h-lock) (const BI 0)))
2203 ((m32r/d (unit u-load))
2204 (m32rx (unit u-load))
2205 (m32r2 (unit u-load)))
2208 ; Saturate into byte.
2210 ((MACH m32rx,m32r2) (IDOC ALU))
2212 (+ OP1_8 dr OP2_6 sr (f-uimm16 #x0300))
2214 ; FIXME: min/max would simplify this nicely of course.
2216 ((ge sr (const 127)) (const 127))
2217 ((le sr (const -128)) (const -128))
2222 ; Saturate into half word.
2224 ((MACH m32rx,m32r2) (IDOC ALU))
2226 (+ OP1_8 dr OP2_6 sr (f-uimm16 #x0200))
2229 ((ge sr (const 32767)) (const 32767))
2230 ((le sr (const -32768)) (const -32768))
2237 ((MACH m32rx,m32r2) SPECIAL (IDOC ALU))
2239 (+ OP1_8 dr OP2_6 sr (f-uimm16 0))
2242 (if WI (lt sr (const 0))
2249 ; Parallel compare byte zeros.
2250 ; Set C bit in condition register if any byte in source register is zero.
2251 (dni pcmpbz "pcmpbz"
2252 ((MACH m32rx,m32r2) (PIPE OS) SPECIAL (IDOC ALU))
2254 (+ OP1_0 (f-r1 3) OP2_7 src2)
2257 ((eq (and src2 (const #xff)) (const 0)) (const BI 1))
2258 ((eq (and src2 (const #xff00)) (const 0)) (const BI 1))
2259 ((eq (and src2 (const #xff0000)) (const 0)) (const BI 1))
2260 ((eq (and src2 (const #xff000000)) (const 0)) (const BI 1))
2261 (else (const BI 0))))
2262 ((m32rx (unit u-cmp))
2263 (m32r2 (unit u-cmp)))
2268 ((MACH m32rx,m32r2) (PIPE S) (IDOC ACCUM))
2270 (+ OP1_5 (f-r1 0) OP2_14 (f-r2 4))
2271 (set (reg h-accums 0)
2272 (add (sra (reg h-accums 1) (const 16))
2274 ((m32rx (unit u-mac))
2275 (m32r2 (unit u-mac)))
2278 ; Multiply and add into accumulator 1
2279 (dni macwu1 "macwu1"
2280 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
2281 "macwu1 $src1,$src2"
2282 (+ OP1_5 src1 OP2_11 src2)
2283 (set (reg h-accums 1)
2290 (ext DI (and src2 (const #xffff)))))
2293 ((m32rx (unit u-mac))
2294 (m32r2 (unit u-mac)))
2297 ; Multiply and subtract from accumulator 0
2299 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
2301 (+ OP1_5 src1 OP2_13 src2)
2309 (ext DI (trunc HI src1))
2310 (ext DI (trunc HI src2)))
2315 ((m32rx (unit u-mac))
2316 (m32r2 (unit u-mac)))
2319 ; Multiply into accumulator 1
2320 (dni mulwu1 "mulwu1"
2321 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
2322 "mulwu1 $src1,$src2"
2323 (+ OP1_5 src1 OP2_10 src2)
2324 (set (reg h-accums 1)
2329 (ext DI (and src2 (const #xffff))))
2332 ((m32rx (unit u-mac))
2333 (m32r2 (unit u-mac)))
2336 ; Multiply and add into accumulator 1
2337 (dni maclh1 "maclh1"
2338 ((MACH m32rx,m32r2) (PIPE S) (IDOC MAC))
2339 "maclh1 $src1,$src2"
2340 (+ OP1_5 src1 OP2_12 src2)
2341 (set (reg h-accums 1)
2349 (ext SI (trunc HI src1))
2350 (sra SI src2 (const SI 16))))
2354 ((m32rx (unit u-mac))
2355 (m32r2 (unit u-mac)))
2358 ; skip instruction if C
2360 ((MACH m32rx,m32r2) (PIPE O) SPECIAL (IDOC BR))
2362 (+ OP1_7 (f-r1 4) OP2_0 (f-r2 1))
2363 (skip (zext INT condbit))
2367 ; skip instruction if not C
2369 ((MACH m32rx,m32r2) (PIPE O) SPECIAL (IDOC BR))
2371 (+ OP1_7 (f-r1 5) OP2_0 (f-r2 1))
2372 (skip (zext INT (not condbit)))
2376 ; PSW &= ~((unsigned char) uimm8 | 0x000ff00)
2377 (dni clrpsw "clrpsw"
2378 ((PIPE O) SPECIAL_M32R)
2380 (+ OP1_7 (f-r1 2) uimm8)
2381 (set USI (reg h-cr 0)
2382 (and USI (reg h-cr 0)
2383 (or USI (inv BI uimm8) (const #xff00))))
2387 ; PSW |= (unsigned char) uimm8
2388 (dni setpsw "setpsw"
2389 ((PIPE O) SPECIAL_M32R)
2391 (+ OP1_7 (f-r1 1) uimm8)
2392 (set USI (reg h-cr 0) uimm8)
2399 "bset $uimm3,@($slo16,$sr)"
2400 (+ OP1_10 (f-bit4 0) uimm3 OP2_6 sr slo16)
2401 (set QI (mem QI (add sr slo16))
2402 (or QI (mem QI (add sr slo16))
2403 (sll USI (const 1) (sub (const 7) uimm3))))
2410 "bclr $uimm3,@($slo16,$sr)"
2411 (+ OP1_10 (f-bit4 0) uimm3 OP2_7 sr slo16)
2412 (set QI (mem QI (add sr slo16))
2413 (and QI (mem QI (add sr slo16))
2414 (inv QI (sll USI (const 1) (sub (const 7) uimm3)))))
2420 (SPECIAL_M32R (PIPE O))
2422 (+ OP1_0 (f-bit4 0) uimm3 OP2_15 sr)
2423 (set condbit (and QI (srl USI sr (sub (const 7) uimm3)) (const 1)))