1 ; Hitachi SHcompact instruction set description. -*- Scheme -*-
3 ; Copyright 2000 Free Software Foundation, Inc.
5 ; Contributed by Red Hat Inc; developed under contract from Hitachi
6 ; Semiconductor (America) Inc.
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 ; dshcf -- define-normal-sh-compact-field
26 (define-pmacro (dshcf xname xcomment ignored xstart xlength)
27 (dnf xname xcomment ((ISA compact)) xstart xlength))
29 ; dshcop -- define-normal-sh-compact-operand
31 (define-pmacro (dshcop xname xcomment ignored xhardware xfield)
32 (dnop xname xcomment ((ISA compact)) xhardware xfield))
35 ; SHcompact-specific attributes.
41 (comment "instruction may not appear in a delay slot")
48 (comment "floating point instruction")
55 (values (fr0 0) (fr1 1) (fr2 2) (fr3 3) (fr4 4) (fr5 5)
56 (fr6 6) (fr7 7) (fr8 8) (fr9 9) (fr10 10) (fr11 11)
57 (fr12 12) (fr13 13) (fr14 14) (fr15 15))
64 (values (dr0 0) (dr2 2) (dr4 4) (dr6 6) (dr8 8) (dr10 10) (dr12 12) (dr14 14))
71 (values (xf0 0) (xf1 1) (xf2 2) (xf3 3) (xf4 4) (xf5 5)
72 (xf6 6) (xf7 7) (xf8 8) (xf9 9) (xf10 10) (xf11 11)
73 (xf12 12) (xf13 13) (xf14 14) (xf15 15))
76 ; Hardware specific to the SHcompact mode.
78 (define-pmacro (front) (mul 16 frbit))
79 (define-pmacro (back) (mul 16 (not frbit)))
83 (comment "Single precision floating point registers")
84 (attrs VIRTUAL (ISA compact))
85 (indices extern-keyword frc-names)
86 (type register SF (16))
87 (get (index) (reg h-fr (add (front) index)))
88 (set (index newval) (set (reg h-fr (add (front) index)) newval))
93 (comment "Double precision floating point registers")
94 (attrs VIRTUAL (ISA compact))
95 (indices extern-keyword drc-names)
96 (type register DF (8))
97 (get (index) (reg h-dr (add (front) index)))
98 (set (index newval) (set (reg h-dr (add (front) index)) newval))
103 (comment "Extended single precision floating point registers")
104 (attrs VIRTUAL (ISA compact))
105 (indices extern-keyword xf-names)
106 (type register SF (16))
107 (get (index) (reg h-fr (add (back) index)))
108 (set (index newval) (set (reg h-fr (add (back) index)) newval))
113 (comment "Extended double precision floating point registers")
114 (attrs VIRTUAL (ISA compact))
115 (indices extern-keyword frc-names)
116 (type register DF (8))
117 (get (index) (reg h-dr (add (back) index)))
118 (set (index newval) (set (reg h-dr (add (back) index)) newval))
123 (comment "Single precision floating point vectors")
124 (attrs VIRTUAL (ISA compact))
125 (indices keyword "" ((fv0 0) (fv4 4) (fv8 8) (fv12 12)))
126 (type register SF (4))
127 (get (index) (reg h-fr (add (front) index)))
128 (set (index newval) (set (reg h-fr (add (front) index)) newval))
133 (comment "SHcompact floating point status/control register")
134 (attrs VIRTUAL (ISA compact))
136 (get () (or (or (or (raw-reg h-fpscr) (sll SI prbit 19)) (sll SI szbit 20)) (sll SI frbit 21)))
137 (set (newvalue) (sequence ()
138 (set (reg h-fpscr) newvalue)
139 (set prbit (and (srl newvalue 19) 1))
140 (set szbit (and (srl newvalue 20) 1))
141 (set frbit (and (srl newvalue 21) 1))))
146 (comment "Global base register")
147 (attrs VIRTUAL (ISA compact))
149 (get () (subword SI (raw-reg h-gr 16) 1))
150 (set (newval) (set (raw-reg h-gr 16) (ext DI newval)))
155 (comment "Procedure link register")
156 (attrs VIRTUAL (ISA compact))
158 (get () (subword SI (raw-reg h-gr 18) 1))
159 (set (newval) (set (raw-reg h-gr 18) (ext DI newval)))
164 (comment "Multiple-accumulate low register")
165 (attrs VIRTUAL (ISA compact))
167 (get () (subword SI (raw-reg h-gr 17) 1))
168 (set (newval) (set (raw-reg h-gr 17) (-join-si (subword SI (raw-reg h-gr 17) 0) newval)))
173 (comment "Multiply-accumulate high register")
174 (attrs VIRTUAL (ISA compact))
176 (get () (subword SI (raw-reg h-gr 17) 0))
177 (set (newval) (set (raw-reg h-gr 17) (-join-si newval (subword SI (raw-reg h-gr 17) 1))))
182 (comment "Condition code flag")
183 (attrs VIRTUAL (ISA compact))
185 (get () (and BI (raw-reg h-gr 19) 1))
186 (set (newval) (set (raw-reg h-gr 19) (or (and (raw-reg h-gr 19) (inv DI 1)) (zext DI newval))))
190 (dshcf f-op4 "Opcode (4 bits)" () 15 4)
191 (dshcf f-op8 "Opcode (8 bits)" () 15 8)
192 (dshcf f-op16 "Opcode (16 bits)" () 15 16)
194 (dshcf f-sub4 "Sub opcode (4 bits)" () 3 4)
195 (dshcf f-sub8 "Sub opcode (8 bits)" () 7 8)
196 (dshcf f-sub10 "Sub opcode (10 bits)" () 9 10)
198 (dshcf f-rn "Register selector n" () 11 4)
199 (dshcf f-rm "Register selector m" () 7 4)
201 (dshcf f-8-1 "One bit at bit 8" () 8 1)
203 (df f-disp8 "Displacement (8 bits)" ((ISA compact) PCREL-ADDR) 7 8 INT
204 ((value pc) (sra SI value 1))
205 ((value pc) (add SI (sll SI value 1) (add pc 4))))
207 (df f-disp12 "Displacement (12 bits)" ((ISA compact) PCREL-ADDR) 11 12 INT
208 ((value pc) (sra SI value 1))
209 ((value pc) (add SI (sll SI value 1) (add pc 4))))
211 (dshcf f-imm8 "Immediate (8 bits)" () 7 8)
212 (dshcf f-imm4 "Immediate (4 bits)" () 3 4)
214 (df f-imm4x2 "Immediate (4 bits)" ((ISA compact)) 3 4 UINT
215 ((value pc) (srl SI value 1))
216 ((value pc) (sll SI value 1)))
218 (df f-imm4x4 "Immediate (4 bits)" ((ISA compact)) 3 4 UINT
219 ((value pc) (srl SI value 2))
220 ((value pc) (sll SI value 2)))
222 (df f-imm8x2 "Immediate (8 bits)" ((ISA compact)) 7 8 UINT
223 ((value pc) (sra SI value 1))
224 ((value pc) (sll SI value 1)))
226 (df f-imm8x4 "Immediate (8 bits)" ((ISA compact)) 7 8 UINT
227 ((value pc) (sra SI value 2))
228 ((value pc) (sll SI value 2)))
230 (df f-dn "Double selector n" ((ISA compact)) 11 3 UINT
231 ((value pc) (srl SI value 1))
232 ((value pc) (sll SI value 1)))
234 (df f-dm "Double selector m" ((ISA compact)) 7 3 UINT
235 ((value pc) (srl SI value 1))
236 ((value pc) (sll SI value 1)))
238 (df f-vn "Vector selector n" ((ISA compact)) 11 2 UINT
239 ((value pc) (srl SI value 2))
240 ((value pc) (sll SI value 2)))
242 (df f-vm "Vector selector m" ((ISA compact)) 9 2 UINT
243 ((value pc) (srl SI value 2))
244 ((value pc) (sll SI value 2)))
246 (df f-xn "Extended selector n" ((ISA compact)) 11 3 UINT
247 ((value pc) (srl SI value 1))
248 ((value pc) (add SI (sll SI value 1) 1)))
250 (df f-xm "Extended selector m" ((ISA compact)) 7 3 UINT
251 ((value pc) (srl SI value 1))
252 ((value pc) (add SI (sll SI value 1) 1)))
257 (dshcop rm "Left general purpose register" () h-grc f-rm)
258 (dshcop rn "Right general purpose register" () h-grc f-rn)
259 (dshcop r0 "Register 0" () h-grc 0)
261 (dshcop frn "Single precision register" () h-frc f-rn)
262 (dshcop frm "Single precision register" () h-frc f-rm)
264 (dshcop fvn "Left floating point vector" () h-fvc f-vn)
265 (dshcop fvm "Right floating point vector" () h-fvc f-vm)
267 (dshcop drn "Left double precision register" () h-drc f-dn)
268 (dshcop drm "Right double precision register" () h-drc f-dm)
270 (dshcop imm4 "Immediate value (4 bits)" () h-sint f-imm4)
271 (dshcop imm8 "Immediate value (8 bits)" () h-sint f-imm8)
272 (dshcop uimm8 "Immediate value (8 bits unsigned)" () h-uint f-imm8)
274 (dshcop imm4x2 "Immediate value (4 bits, 2x scale)" () h-uint f-imm4x2)
275 (dshcop imm4x4 "Immediate value (4 bits, 4x scale)" () h-uint f-imm4x4)
276 (dshcop imm8x2 "Immediate value (8 bits, 2x scale)" () h-uint f-imm8x2)
277 (dshcop imm8x4 "Immediate value (8 bits, 4x scale)" () h-uint f-imm8x4)
279 (dshcop disp8 "Displacement (8 bits)" () h-iaddr f-disp8)
280 (dshcop disp12 "Displacement (12 bits)" () h-iaddr f-disp12)
282 (dshcop rm64 "Register m (64 bits)" () h-gr f-rm)
283 (dshcop rn64 "Register n (64 bits)" () h-gr f-rn)
285 (dshcop gbr "Global base register" () h-gbr f-nil)
286 (dshcop pr "Procedure link register" () h-pr f-nil)
288 (dshcop fpscr "Floating point status/control register" () h-fpccr f-nil)
290 (dshcop tbit "Condition code flag" () h-tbit f-nil)
291 (dshcop sbit "Multiply-accumulate saturation flag" () h-sbit f-nil)
292 (dshcop mbit "Divide-step M flag" () h-mbit f-nil)
293 (dshcop qbit "Divide-step Q flag" () h-qbit f-nil)
294 (dshcop fpul "Floating point ???" () h-fr 32)
296 (dshcop frbit "Floating point register bank bit" () h-frbit f-nil)
297 (dshcop szbit "Floating point transfer size bit" () h-szbit f-nil)
298 (dshcop prbit "Floating point precision bit" () h-prbit f-nil)
300 (dshcop macl "Multiply-accumulate low register" () h-macl f-nil)
301 (dshcop mach "Multiply-accumulate high register" () h-mach f-nil)
304 (define-operand (name fsdm) (comment "bar")
305 (attrs (ISA compact)) (type h-frc) (index f-rm) (handlers (parse "fsd")))
307 (define-operand (name fsdn) (comment "bar")
308 (attrs (ISA compact)) (type h-frc) (index f-rn))
311 ; Cover macro to dni to indicate these are all SHcompact instructions.
312 ; dshmi: define-normal-sh-compact-insn
314 (define-pmacro (dshci xname xcomment xattrs xsyntax xformat xsemantics)
316 (name (.sym xname -compact))
318 (.splice attrs (.unsplice xattrs) (ISA compact))
321 (semantics xsemantics)))
323 (define-pmacro (dr operand) (reg h-dr (index-of operand)))
324 (define-pmacro (xd x) (reg h-xd (and (index-of x) (inv QI 1))))
329 (+ (f-op4 3) rn rm (f-sub4 12))
330 (set rn (add rn rm)))
332 (dshci addi "Add immediate"
335 (+ (f-op4 7) rn imm8)
336 (set rn (add rn (ext SI (and QI imm8 255)))))
338 (dshci addc "Add with carry"
341 (+ (f-op4 3) rn rm (f-sub4 14))
342 (sequence ((BI flag))
343 (set flag (add-cflag rn rm tbit))
344 (set rn (addc rn rm tbit))
347 (dshci addv "Add with overflow"
350 (+ (f-op4 3) rn rm (f-sub4 15))
352 (set t (add-oflag rn rm 0))
356 (dshci and "Bitwise AND"
359 (+ (f-op4 2) rn64 rm64 (f-sub4 9))
360 (set rn64 (and rm64 rn64)))
362 (dshci andi "Bitwise AND immediate"
365 (+ (f-op8 #xc9) uimm8)
366 (set r0 (and r0 (zext DI uimm8))))
368 (dshci andb "Bitwise AND memory byte"
370 "and.b #$imm8, @(r0, gbr)"
371 (+ (f-op8 #xcd) imm8)
372 (sequence ((DI addr) (UQI data))
373 (set addr (add r0 gbr))
374 (set data (and (mem UQI addr) imm8))
375 (set (mem UQI addr) data)))
377 (dshci bf "Conditional branch"
380 (+ (f-op8 #x8b) disp8)
384 (dshci bfs "Conditional branch with delay slot"
387 (+ (f-op8 #x8f) disp8)
389 (delay 1 (set pc disp8))))
394 (+ (f-op4 10) disp12)
395 (delay 1 (set pc disp12)))
397 (dshci braf "Branch far"
400 (+ (f-op4 0) rn (f-sub8 35))
401 (delay 1 (set pc (add (ext DI rn) (add pc 4)))))
403 (dshci brk "Breakpoint"
407 (c-call "sh64_break" pc))
409 (dshci bsr "Branch to subroutine"
412 (+ (f-op4 11) disp12)
413 (delay 1 (sequence ()
417 (dshci bsrf "Branch to far subroutine"
420 (+ (f-op4 0) rn (f-sub8 3))
421 (delay 1 (sequence ()
423 (set pc (add (ext DI rn) (add pc 4))))))
425 (dshci bt "Conditional branch"
428 (+ (f-op8 #x89) disp8)
432 (dshci bts "Conditional branch with delay slot"
435 (+ (f-op8 #x8d) disp8)
437 (delay 1 (set pc disp8))))
439 (dshci clrmac "Clear MACL and MACH"
447 (dshci clrs "Clear S-bit"
453 (dshci clrt "Clear T-bit"
459 (dshci cmpeq "Compare if equal"
462 (+ (f-op4 3) rn rm (f-sub4 0))
463 (set tbit (eq rm rn)))
465 (dshci cmpeqi "Compare if equal (immediate)"
468 (+ (f-op8 #x88) imm8)
469 (set tbit (eq r0 (ext SI (and QI imm8 255)))))
471 (dshci cmpge "Compare if greater than or equal"
474 (+ (f-op4 3) rn rm (f-sub4 3))
475 (set tbit (ge rn rm)))
477 (dshci cmpgt "Compare if greater than"
480 (+ (f-op4 3) rn rm (f-sub4 7))
481 (set tbit (gt rn rm)))
483 (dshci cmphi "Compare if greater than (unsigned)"
486 (+ (f-op4 3) rn rm (f-sub4 6))
487 (set tbit (gtu rn rm)))
489 (dshci cmphs "Compare if greater than or equal (unsigned)"
492 (+ (f-op4 3) rn rm (f-sub4 2))
493 (set tbit (geu rn rm)))
495 (dshci cmppl "Compare if greater than zero"
498 (+ (f-op4 4) rn (f-sub8 21))
499 (set tbit (gt rn 0)))
501 (dshci cmppz "Compare if greater than or equal zero"
504 (+ (f-op4 4) rn (f-sub8 17))
505 (set tbit (ge rn 0)))
507 (dshci cmpstr "Compare bytes"
510 (+ (f-op4 2) rn rm (f-sub4 12))
511 (sequence ((BI t) (SI temp))
512 (set temp (xor rm rn))
513 (set t (eq (and temp #xff000000) 0))
514 (set t (or (eq (and temp #xff0000) 0) t))
515 (set t (or (eq (and temp #xff00) 0) t))
516 (set t (or (eq (and temp #xff) 0) t))
517 (set tbit (if BI (gtu t 0) 1 0))))
519 (dshci div0s "Initialise divide-step state for signed division"
522 (+ (f-op4 2) rn rm (f-sub4 7))
524 (set qbit (srl rn 31))
525 (set mbit (srl rm 31))
526 (set tbit (if BI (eq (srl rm 31) (srl rn 31)) 0 1))))
528 (dshci div0u "Initialise divide-step state for unsigned division"
537 (dshci div1 "Divide step"
540 (+ (f-op4 3) rn rm (f-sub4 4))
541 (sequence ((BI oldq) (SI tmp0) (UQI tmp1))
543 (set qbit (srl rn 31))
544 (set rn (or (sll rn 1) (zext SI tbit)))
550 (set tmp1 (gtu rn tmp0))
552 (set qbit (if BI tmp1 1 0))
553 (set qbit (if BI (eq tmp1 0) 1 0))))
557 (set tmp1 (ltu rn tmp0))
559 (set qbit (if BI (eq tmp1 0) 1 0))
560 (set qbit (if BI tmp1 1 0)))))
565 (set tmp1 (ltu rn tmp0))
567 (set qbit (if BI tmp1 1 0))
568 (set qbit (if BI (eq tmp1 0) 1 0))))
572 (set tmp1 (gtu rn tmp0))
574 (set qbit (if BI (eq tmp1 0) 1 0))
575 (set qbit (if BI tmp1 1 0))))))
576 (set tbit (if BI (eq qbit mbit) 1 0))))
578 (dshci dmulsl "Multiply long (signed)"
581 (+ (f-op4 3) rn rm (f-sub4 13))
582 (sequence ((DI result))
583 (set result (mul (ext DI rm) (ext DI rn)))
584 (set mach (subword SI result 0))
585 (set macl (subword SI result 1))))
587 (dshci dmulul "Multiply long (unsigned)"
590 (+ (f-op4 3) rn rm (f-sub4 5))
591 (sequence ((DI result))
592 (set result (mul (zext DI rm) (zext DI rn)))
593 (set mach (subword SI result 0))
594 (set macl (subword SI result 1))))
596 (dshci dt "Decrement and set"
599 (+ (f-op4 4) rn (f-sub8 16))
602 (set tbit (eq rn 0))))
604 (dshci extsb "Sign extend byte"
607 (+ (f-op4 6) rn rm (f-sub4 14))
608 (set rn (ext SI (subword QI rm 3))))
610 (dshci extsw "Sign extend word"
613 (+ (f-op4 6) rn rm (f-sub4 15))
614 (set rn (ext SI (subword HI rm 1))))
616 (dshci extub "Zero extend byte"
619 (+ (f-op4 6) rn rm (f-sub4 12))
620 (set rn (zext SI (subword QI rm 3))))
622 (dshci extuw "Zero etxend word"
625 (+ (f-op4 6) rn rm (f-sub4 13))
626 (set rn (zext SI (subword HI rm 1))))
628 (dshci fabs "Floating point absolute"
631 (+ (f-op4 15) fsdn (f-sub8 #x5d))
633 (set (dr fsdn) (c-call DF "sh64_fabsd" (dr fsdn)))
634 (set fsdn (c-call SF "sh64_fabss" fsdn))))
636 (dshci fadd "Floating point add"
639 (+ (f-op4 15) fsdn fsdm (f-sub4 0))
641 (set (dr fsdn) (c-call DF "sh64_faddd" (dr fsdm) (dr fsdn)))
642 (set fsdn (c-call SF "sh64_fadds" fsdm fsdn))))
644 (dshci fcmpeq "Floating point compare equal"
646 "fcmp/eq $fsdm, $fsdn"
647 (+ (f-op4 15) fsdn fsdm (f-sub4 4))
649 (set tbit (c-call BI "sh64_fcmpeqd" (dr fsdm) (dr fsdn)))
650 (set tbit (c-call BI "sh64_fcmpeqs" fsdm fsdn))))
652 (dshci fcmpgt "Floating point compare greater than"
654 "fcmp/gt $fsdm, $fsdn"
655 (+ (f-op4 15) fsdn fsdm (f-sub4 5))
657 (set tbit (c-call BI "sh64_fcmpgtd" (dr fsdn) (dr fsdm)))
658 (set tbit (c-call BI "sh64_fcmpgts" fsdn fsdm))))
660 (dshci fcnvds "Floating point convert (double to single)"
663 (+ (f-op4 15) drn (f-8-1 10) (f-sub8 #xbd))
664 (set fpul (c-call SF "sh64_fcnvds" drn)))
666 (dshci fcnvsd "Floating point convert (single to double)"
669 (+ (f-op4 15) drn (f-8-1 0) (f-sub8 #xad))
670 (set drn (c-call DF "sh64_fcnvsd" fpul)))
672 (dshci fdiv "Floating point divide"
675 (+ (f-op4 15) fsdn fsdm (f-sub4 3))
677 (set (dr fsdn) (c-call DF "sh64_fdivd" (dr fsdn) (dr fsdm)))
678 (set fsdn (c-call SF "sh64_fdivs" fsdn fsdm))))
680 (dshci fipr "Floating point inner product"
683 (+ (f-op4 15) fvn fvm (f-sub8 #xed))
684 (sequence ((QI m) (QI n) (SF res))
685 (set m (index-of fvm))
686 (set n (index-of fvn))
687 (set res (c-call SF "sh64_fmuls" fvm fvn))
688 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-frc (add m 1)) (reg h-frc (add n 1)))))
689 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-frc (add m 2)) (reg h-frc (add n 2)))))
690 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-frc (add m 3)) (reg h-frc (add n 3)))))
691 (set (reg h-frc (add n 3)) res)))
693 (dshci flds "Floating point load status register"
696 (+ (f-op4 15) frn (f-sub8 #x1d))
699 (dshci fldi0 "Floating point load immediate 0.0"
702 (+ (f-op4 15) frn (f-sub8 #x8d))
703 (set frn (c-call SF "sh64_fldi0")))
705 (dshci fldi1 "Floating point load immediate 1.0"
708 (+ (f-op4 15) frn (f-sub8 #x9d))
709 (set frn (c-call SF "sh64_fldi1")))
711 (dshci float "Floating point integer conversion"
714 (+ (f-op4 15) fsdn (f-sub8 #x2d))
716 (set (dr fsdn) (c-call DF "sh64_floatld" fpul))
717 (set fsdn (c-call SF "sh64_floatls" fpul))))
719 (dshci fmac "Floating point multiply and accumulate"
721 "fmac fr0, $frm, $frn"
722 (+ (f-op4 15) frn frm (f-sub4 14))
723 (set frn (c-call SF "sh64_fmacs" (reg h-frc 0) frm frn)))
725 (define-pmacro (even x) (eq (and x 1) 0))
726 (define-pmacro (odd x) (eq (and x 1) 1))
727 (define-pmacro (extd x) (odd (index-of x)))
729 (dshci fmov1 "Floating point move (register to register)"
732 (+ (f-op4 15) frn frm (f-sub4 12))
734 ; single precision operation
736 ; double or extended operation
739 (set (xd frn) (xd frm))
740 (set (dr frn) (xd frm)))
742 (set (xd frn) (dr frm))
743 (set (dr frn) (dr frm))))))
745 (dshci fmov2 "Floating point load"
748 (+ (f-op4 15) frn rm (f-sub4 8))
750 ; single precision operation
751 (set frn (mem SF rm))
752 ; double or extended operation
754 (set (xd frn) (mem DF rm))
755 (set (dr frn) (mem DF rm)))))
757 (dshci fmov3 "Floating point load (post-increment)"
760 (+ (f-op4 15) frn rm (f-sub4 9))
762 ; single precision operation
764 (set frn (mem SF rm))
766 ; double or extended operation
769 (set (xd frn) (mem DF rm))
770 (set (dr frn) (mem DF rm)))
771 (set rm (add rm 8)))))
773 (dshci fmov4 "Floating point load (register/register indirect)"
775 "fmov @(r0, $rm), $frn"
776 (+ (f-op4 15) frn rm (f-sub4 6))
778 ; single precision operation
779 (set frn (mem SF (add r0 rm)))
780 ; double or extended operation
782 (set (xd frn) (mem DF (add r0 rm)))
783 (set (dr frn) (mem DF (add r0 rm))))))
785 (dshci fmov5 "Floating point store"
788 (+ (f-op4 15) rn frm (f-sub4 10))
790 ; single precision operation
791 (set (mem SF rn) frm)
792 ; double or extended operation
794 (set (mem DF rn) (xd frm))
795 (set (mem DF rn) (dr frm)))))
797 (dshci fmov6 "Floating point store (pre-decrement)"
800 (+ (f-op4 15) rn frm (f-sub4 11))
802 ; single precision operation
805 (set (mem SF rn) frm))
806 ; double or extended operation
810 (set (mem DF rn) (xd frm))
811 (set (mem DF rn) (dr frm))))))
813 (dshci fmov7 "Floating point store (register/register indirect)"
815 "fmov $frm, @(r0, $rn)"
816 (+ (f-op4 15) rn frm (f-sub4 7))
818 ; single precision operation
819 (set (mem SF (add r0 rn)) frm)
820 ; double or extended operation
822 (set (mem DF (add r0 rn)) (xd frm))
823 (set (mem DF (add r0 rn)) (dr frm)))))
825 (dshci fmul "Floating point multiply"
828 (+ (f-op4 15) fsdn fsdm (f-sub4 2))
830 (set (dr fsdn) (c-call DF "sh64_fmuld" (dr fsdm) (dr fsdn)))
831 (set fsdn (c-call SF "sh64_fmuls" fsdm fsdn))))
833 (dshci fneg "Floating point negate"
836 (+ (f-op4 15) fsdn (f-sub8 #x4d))
838 (set (dr fsdn) (c-call DF "sh64_fnegd" (dr fsdn)))
839 (set fsdn (c-call SF "sh64_fnegs" fsdn))))
841 (dshci frchg "Toggle floating point register banks"
845 (set frbit (not frbit)))
847 (dshci fschg "Set size of floating point transfers"
851 (set szbit (not szbit)))
853 (dshci fsqrt "Floating point square root"
856 (+ (f-op4 15) fsdn (f-sub8 #x6d))
858 (set (dr fsdn) (c-call DF "sh64_fsqrtd" (dr fsdn)))
859 (set fsdn (c-call SF "sh64_fsqrts" fsdn))))
861 (dshci fsts "Floating point store status register"
864 (+ (f-op4 15) frn (f-sub8 13))
867 (dshci fsub "Floating point subtract"
870 (+ (f-op4 15) fsdn fsdm (f-sub4 1))
872 (set (dr fsdn) (c-call DF "sh64_fsubd" (dr fsdn) (dr fsdm)))
873 (set fsdn (c-call SF "sh64_fsubs" fsdn fsdm))))
875 (dshci ftrc "Floating point truncate"
878 (+ (f-op4 15) fsdn (f-sub8 #x3d))
879 (set fpul (if SF prbit
880 (c-call SF "sh64_ftrcdl" (dr fsdn))
881 (c-call SF "sh64_ftrcsl" fsdn))))
883 (dshci ftrv "Floating point transform vector"
886 (+ (f-op4 15) fvn (f-sub10 #x1fd))
887 (sequence ((QI n) (SF res))
888 (set n (index-of fvn))
889 (set res (c-call SF "sh64_fmuls" (reg h-xf 0) (reg h-frc n)))
890 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 4) (reg h-frc (add n 1)))))
891 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 8) (reg h-frc (add n 2)))))
892 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 12) (reg h-frc (add n 3)))))
893 (set (reg h-frc n) res)
894 (set res (c-call SF "sh64_fmuls" (reg h-xf 1) (reg h-frc n)))
895 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 5) (reg h-frc (add n 1)))))
896 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 9) (reg h-frc (add n 2)))))
897 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 13) (reg h-frc (add n 3)))))
898 (set (reg h-frc (add n 1)) res)
899 (set res (c-call SF "sh64_fmuls" (reg h-xf 2) (reg h-frc n)))
900 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 6) (reg h-frc (add n 1)))))
901 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 10) (reg h-frc (add n 2)))))
902 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 14) (reg h-frc (add n 3)))))
903 (set (reg h-frc (add n 2)) res)
904 (set res (c-call SF "sh64_fmuls" (reg h-xf 3) (reg h-frc n)))
905 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 7) (reg h-frc (add n 1)))))
906 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 11) (reg h-frc (add n 2)))))
907 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 15) (reg h-frc (add n 3)))))
908 (set (reg h-frc (add n 3)) res)))
913 (+ (f-op4 4) rn (f-sub8 43))
914 (delay 1 (set pc rn)))
916 (dshci jsr "Jump to subroutine"
919 (+ (f-op4 4) rn (f-sub8 11))
920 (delay 1 (sequence ()
924 (dshci ldc "Load control register (GBR)"
927 (+ (f-op4 4) rn (f-sub8 30))
930 (dshci ldcl "Load control register (GBR)"
933 (+ (f-op4 4) rn (f-sub8 39))
935 (set gbr (mem SI rn))
936 (set rn (add rn 4))))
938 (dshci lds-fpscr "Load status register (FPSCR)"
941 (+ (f-op4 4) rn (f-sub8 106))
944 (dshci ldsl-fpscr "Load status register (FPSCR)"
946 "lds.l @${rn}+, fpscr"
947 (+ (f-op4 4) rn (f-sub8 102))
949 (set fpscr (mem SI rn))
950 (set rn (add rn 4))))
952 (dshci lds-fpul "Load status register (FPUL)"
955 (+ (f-op4 4) rn (f-sub8 90))
956 ; Use subword to convert rn's mode.
957 (set fpul (subword SF rn 0)))
959 (dshci ldsl-fpul "Load status register (FPUL)"
961 "lds.l @${rn}+, fpul"
962 (+ (f-op4 4) rn (f-sub8 86))
964 (set fpul (mem SF rn))
965 (set rn (add rn 4))))
967 (dshci lds-mach "Load status register (MACH)"
970 (+ (f-op4 4) rn (f-sub8 10))
973 (dshci ldsl-mach "Load status register (MACH), post-increment"
975 "lds.l @${rn}+, mach"
976 (+ (f-op4 4) rn (f-sub8 6))
978 (set mach (mem SI rn))
979 (set rn (add rn 4))))
981 (dshci lds-macl "Load status register (MACL)"
984 (+ (f-op4 4) rn (f-sub8 26))
987 (dshci ldsl-macl "Load status register (MACL), post-increment"
989 "lds.l @${rn}+, macl"
990 (+ (f-op4 4) rn (f-sub8 22))
992 (set macl (mem SI rn))
993 (set rn (add rn 4))))
995 (dshci lds-pr "Load status register (PR)"
998 (+ (f-op4 4) rn (f-sub8 42))
1001 (dshci ldsl-pr "Load status register (PR), post-increment"
1004 (+ (f-op4 4) rn (f-sub8 38))
1006 (set pr (mem SI rn))
1007 (set rn (add rn 4))))
1009 (dshci macl "Multiply and accumulate (long)"
1011 "mac.l @${rm}+, @${rn}+"
1012 (+ (f-op4 0) rn rm (f-sub4 15))
1013 (sequence ((DI tmpry) (DI mac) (DI result) (SI x) (SI y))
1016 (if (eq (index-of rn) (index-of rm))
1019 (set rm (add rm 4))))
1022 (set tmpry (mul (zext DI x) (zext DI y)))
1023 (set mac (or DI (sll (zext DI mach) 32) (zext DI macl)))
1024 (set result (add mac tmpry))
1027 (sequence ((SI min) (SI max))
1028 (set max (srl (inv DI 0) 16))
1029 ; Preserve bit 48 for sign.
1030 (set min (srl (inv DI 0) 15))
1034 (set result min)))))
1035 (set mach (subword SI result 0))
1036 (set macl (subword SI result 1)))))
1038 (dshci macw "Multiply and accumulate (word)"
1040 "mac.w @${rm}+, @${rn}+"
1041 (+ (f-op4 4) rn rm (f-sub4 15))
1042 (sequence ((SI tmpry) (DI mac) (DI result) (HI x) (HI y))
1045 (if (eq (index-of rn) (index-of rm))
1048 (set rm (add rm 2))))
1051 (set tmpry (mul (zext SI x) (zext SI y)))
1054 (if (add-oflag tmpry macl 0)
1056 (set macl (add tmpry macl)))
1058 (set mac (or DI (sll (zext DI mach) 32) (zext DI macl)))
1059 (set result (add mac (ext DI tmpry)))
1060 (set mach (subword SI result 0))
1061 (set macl (subword SI result 1))))))
1066 (+ (f-op4 6) rn64 rm64 (f-sub4 3))
1069 (dshci movi "Move immediate"
1072 (+ (f-op4 14) rn imm8)
1073 (set rn (ext DI (and QI imm8 255))))
1075 (dshci movb1 "Store byte to memory (register indirect w/ zero displacement)"
1078 (+ (f-op4 2) rn rm (f-sub4 0))
1079 (set (mem UQI rn) (subword UQI rm 3)))
1081 (dshci movb2 "Store byte to memory (register indirect w/ pre-decrement)"
1084 (+ (f-op4 2) rn rm (f-sub4 4))
1085 (sequence ((DI addr))
1086 (set addr (sub rn 1))
1087 (set (mem UQI addr) (subword UQI rm 3))
1090 (dshci movb3 "Store byte to memory (register/register indirect)"
1092 "mov.b $rm, @(r0,$rn)"
1093 (+ (f-op4 0) rn rm (f-sub4 4))
1094 (set (mem UQI (add r0 rn)) (subword UQI rm 3)))
1096 (dshci movb4 "Store byte to memory (GBR-relative w/ displacement)"
1098 "mov.b r0, @($imm8, gbr)"
1099 (+ (f-op8 #xc0) imm8)
1100 (sequence ((DI addr))
1101 (set addr (add gbr imm8))
1102 (set (mem UQI addr) (subword UQI r0 3))))
1104 (dshci movb5 "Store byte to memory (register indirect w/ displacement)"
1106 "mov.b r0, @($imm4, $rm)"
1107 (+ (f-op8 #x80) rm imm4)
1108 (sequence ((DI addr))
1109 (set addr (add rm imm4))
1110 (set (mem UQI addr) (subword UQI r0 3))))
1112 (dshci movb6 "Load byte from memory (register indirect w/ zero displacement)"
1115 (+ (f-op4 6) rn rm (f-sub4 0))
1116 (set rn (ext SI (mem QI rm))))
1118 (dshci movb7 "Load byte from memory (register indirect w/ post-increment)"
1120 "mov.b @${rm}+, $rn"
1121 (+ (f-op4 6) rn rm (f-sub4 4))
1122 (sequence ((QI data))
1123 (set data (mem QI rm))
1124 (if (eq (index-of rm) (index-of rn))
1125 (set rm (ext SI data))
1126 (set rm (add rm 1)))
1127 (set rn (ext SI data))))
1129 (dshci movb8 "Load byte from memory (register/register indirect)"
1131 "mov.b @(r0, $rm), $rn"
1132 (+ (f-op4 0) rn rm (f-sub4 12))
1133 (set rn (ext SI (mem QI (add r0 rm)))))
1135 (dshci movb9 "Load byte from memory (GBR-relative with displacement)"
1137 "mov.b @($imm8, gbr), r0"
1138 (+ (f-op8 #xc4) imm8)
1139 (set r0 (ext SI (mem QI (add gbr imm8)))))
1141 (dshci movb10 "Load byte from memory (register indirect w/ displacement)"
1143 "mov.b @($imm4, $rm), r0"
1144 (+ (f-op8 #x84) rm imm4)
1145 (set r0 (ext SI (mem QI (add rm imm4)))))
1147 (dshci movl1 "Store long word to memory (register indirect w/ zero displacement)"
1150 (+ (f-op4 2) rn rm (f-sub4 2))
1151 (set (mem SI rn) rm))
1153 (dshci movl2 "Store long word to memory (register indirect w/ pre-decrement)"
1156 (+ (f-op4 2) rn rm (f-sub4 6))
1157 (sequence ((SI addr))
1158 (set addr (sub rn 4))
1159 (set (mem SI addr) rm)
1162 (dshci movl3 "Store long word to memory (register/register indirect)"
1164 "mov.l $rm, @(r0, $rn)"
1165 (+ (f-op4 0) rn rm (f-sub4 6))
1166 (set (mem SI (add r0 rn)) rm))
1168 (dshci movl4 "Store long word to memory (GBR-relative w/ displacement)"
1170 "mov.l r0, @($imm8x4, gbr)"
1171 (+ (f-op8 #xc2) imm8x4)
1172 (set (mem SI (add gbr imm8x4)) r0))
1174 (dshci movl5 "Store long word to memory (register indirect w/ displacement)"
1176 "mov.l $rm, @($imm4x4, $rn)"
1177 (+ (f-op4 1) rn rm imm4x4)
1178 (set (mem SI (add rn imm4x4)) rm))
1180 (dshci movl6 "Load long word to memory (register indirect w/ zero displacement)"
1183 (+ (f-op4 6) rn rm (f-sub4 2))
1184 (set rn (mem SI rm)))
1186 (dshci movl7 "Load long word from memory (register indirect w/ post-increment)"
1188 "mov.l @${rm}+, $rn"
1189 (+ (f-op4 6) rn rm (f-sub4 6))
1191 (set rn (mem SI rm))
1192 (if (eq (index-of rm) (index-of rn))
1194 (set rm (add rm 4)))))
1196 (dshci movl8 "Load long word from memory (register/register indirect)"
1198 "mov.l @(r0, $rm), $rn"
1199 (+ (f-op4 0) rn rm (f-sub4 14))
1200 (set rn (mem SI (add r0 rm))))
1202 (dshci movl9 "Load long word from memory (GBR-relative w/ displacement)"
1204 "mov.l @($imm8x4, gbr), r0"
1205 (+ (f-op8 #xc6) imm8x4)
1206 (set r0 (mem SI (add gbr imm8x4))))
1208 (dshci movl10 "Load long word from memory (PC-relative w/ displacement)"
1210 "mov.l @($imm8x4, pc), $rn"
1211 (+ (f-op4 13) rn imm8x4)
1212 (set rn (mem SI (add imm8x4 (and (add pc 4) (inv 3))))))
1214 (dshci movl11 "Load long word from memory (register indirect w/ displacement)"
1216 "mov.l @($imm4x4, $rm), $rn"
1217 (+ (f-op4 5) rn rm imm4x4)
1218 (set rn (mem SI (add rm imm4x4))))
1220 (dshci movw1 "Store word to memory (register indirect w/ zero displacement)"
1223 (+ (f-op4 2) rn rm (f-sub4 1))
1224 (set (mem HI rn) (subword HI rm 1)))
1226 (dshci movw2 "Store word to memory (register indirect w/ pre-decrement)"
1229 (+ (f-op4 2) rn rm (f-sub4 5))
1230 (sequence ((DI addr))
1231 (set addr (sub rn 2))
1232 (set (mem HI addr) (subword HI rm 1))
1235 (dshci movw3 "Store word to memory (register/register indirect)"
1237 "mov.w $rm, @(r0, $rn)"
1238 (+ (f-op4 0) rn rm (f-sub4 5))
1239 (set (mem HI (add r0 rn)) (subword HI rm 1)))
1241 (dshci movw4 "Store word to memory (GBR-relative w/ displacement)"
1243 "mov.w r0, @($imm8x2, gbr)"
1244 (+ (f-op8 #xc1) imm8x2)
1245 (set (mem HI (add gbr imm8x2)) (subword HI r0 1)))
1247 (dshci movw5 "Store word to memory (register indirect w/ displacement)"
1249 "mov.w r0, @($imm4x2, $rn)"
1250 (+ (f-op8 #x81) rn imm4x2)
1251 (set (mem HI (add rn imm4x2)) (subword HI r0 1)))
1253 (dshci movw6 "Load word from memory (register indirect w/ zero displacement)"
1256 (+ (f-op4 6) rn rm (f-sub4 1))
1257 (set rn (ext SI (mem HI rm))))
1259 (dshci movw7 "Load word from memory (register indirect w/ post-increment)"
1261 "mov.w @${rm}+, $rn"
1262 (+ (f-op4 6) rn rm (f-sub4 5))
1263 (sequence ((HI data))
1264 (set data (mem HI rm))
1265 (if (eq (index-of rm) (index-of rn))
1266 (set rm (ext SI data))
1267 (set rm (add rm 2)))
1268 (set rn (ext SI data))))
1270 (dshci movw8 "Load word from memory (register/register indirect)"
1272 "mov.w @(r0, $rm), $rn"
1273 (+ (f-op4 0) rn rm (f-sub4 13))
1274 (set rn (ext SI (mem HI (add r0 rm)))))
1276 (dshci movw9 "Load word from memory (GBR-relative w/ displacement)"
1278 "mov.w @($imm8x2, gbr), r0"
1279 (+ (f-op8 #xc5) imm8x2)
1280 (set r0 (ext SI (mem HI (add gbr imm8x2)))))
1282 (dshci movw10 "Load word from memory (PC-relative w/ displacement)"
1284 "mov.w @($imm8x2, pc), $rn"
1285 (+ (f-op4 9) rn imm8x2)
1286 (set rn (ext SI (mem HI (add (add pc 4) imm8x2)))))
1288 (dshci movw11 "Load word from memory (register indirect w/ displacement)"
1290 "mov.w @($imm4x2, $rm), r0"
1291 (+ (f-op8 #x85) rm imm4x2)
1292 (set r0 (ext SI (mem HI (add rm imm4x2)))))
1294 (dshci mova "Move effective address"
1296 "mova @($imm8x4, pc), r0"
1297 (+ (f-op8 #xc7) imm8x4)
1298 (set r0 (add (and (add pc 4) (inv 3)) imm8x4)))
1300 (dshci movcal "Move with cache block allocation"
1303 (+ (f-op4 0) rn (f-sub8 #xc3))
1304 (set (mem SI rn) r0))
1306 (dshci movt "Move t-bit"
1309 (+ (f-op4 0) rn (f-sub8 41))
1310 (set rn (zext SI tbit)))
1312 (dshci mull "Multiply"
1315 (+ (f-op4 0) rn rm (f-sub4 7))
1316 (set macl (mul rm rn)))
1318 (dshci mulsw "Multiply words (signed)"
1321 (+ (f-op4 2) rn rm (f-sub4 15))
1322 (set macl (mul (ext SI (subword HI rm 1)) (ext SI (subword HI rn 1)))))
1324 (dshci muluw "Multiply words (unsigned)"
1327 (+ (f-op4 2) rn rm (f-sub4 14))
1328 (set macl (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))))
1333 (+ (f-op4 6) rn rm (f-sub4 11))
1336 (dshci negc "Negate with carry"
1339 (+ (f-op4 6) rn rm (f-sub4 10))
1340 (sequence ((BI flag))
1341 (set flag (sub-cflag 0 rm tbit))
1342 (set rn (subc 0 rm tbit))
1345 (dshci nop "No operation"
1351 (dshci not "Bitwise NOT"
1354 (+ (f-op4 6) rn64 rm64 (f-sub4 7))
1355 (set rn64 (inv rm64)))
1357 (dshci ocbi "Invalidate operand cache block"
1360 (+ (f-op4 0) rn (f-sub8 147))
1363 (dshci ocbp "Purge operand cache block"
1366 (+ (f-op4 0) rn (f-sub8 163))
1369 (dshci ocbwb "Write back operand cache block"
1372 (+ (f-op4 0) rn (f-sub8 179))
1375 (dshci or "Bitwise OR"
1378 (+ (f-op4 2) rn64 rm64 (f-sub4 11))
1379 (set rn64 (or rm64 rn64)))
1381 (dshci ori "Bitwise OR immediate"
1384 (+ (f-op8 #xcb) uimm8)
1385 (set r0 (or r0 (zext DI uimm8))))
1387 (dshci orb "Bitwise OR immediate"
1389 "or.b #$imm8, @(r0, gbr)"
1390 (+ (f-op8 #xcf) imm8)
1391 (sequence ((DI addr) (UQI data))
1392 (set addr (add r0 gbr))
1393 (set data (or (mem UQI addr) imm8))
1394 (set (mem UQI addr) data)))
1396 (dshci pref "Prefetch data"
1399 (+ (f-op4 0) rn (f-sub8 131))
1402 (dshci rotcl "Rotate with carry left"
1405 (+ (f-op4 4) rn (f-sub8 36))
1406 (sequence ((BI temp))
1407 (set temp (srl rn 31))
1408 (set rn (or (sll rn 1) tbit))
1409 (set tbit (if BI temp 1 0))))
1411 (dshci rotcr "Rotate with carry right"
1414 (+ (f-op4 4) rn (f-sub8 37))
1415 (sequence ((BI lsbit) (SI temp))
1416 (set lsbit (if BI (eq (and rn 1) 0) 0 1))
1418 (set rn (or (srl rn 1) (sll temp 31)))
1419 (set tbit (if BI lsbit 1 0))))
1421 (dshci rotl "Rotate left"
1424 (+ (f-op4 4) rn (f-sub8 4))
1425 (sequence ((BI temp))
1426 (set temp (srl rn 31))
1427 (set rn (or (sll rn 1) temp))
1428 (set tbit (if BI temp 1 0))))
1430 (dshci rotr "Rotate right"
1433 (+ (f-op4 4) rn (f-sub8 5))
1434 (sequence ((BI lsbit) (SI temp))
1435 (set lsbit (if BI (eq (and rn 1) 0) 0 1))
1437 (set rn (or (srl rn 1) (sll temp 31)))
1438 (set tbit (if BI lsbit 1 0))))
1440 (dshci rts "Return from subroutine"
1444 (delay 1 (set pc pr)))
1446 (dshci sets "Set S-bit"
1452 (dshci sett "Set T-bit"
1458 (dshci shad "Shift arithmetic dynamic"
1461 (+ (f-op4 4) rn rm (f-sub4 12))
1462 (sequence ((QI shamt))
1463 (set shamt (and QI rm 31))
1465 (set rn (sll rn shamt))
1467 (set rn (sra rn (sub 32 shamt)))
1472 (dshci shal "Shift left arithmetic one bit"
1475 (+ (f-op4 4) rn (f-sub8 32))
1479 (set tbit (if BI t 1 0))))
1481 (dshci shar "Shift right arithmetic one bit"
1484 (+ (f-op4 4) rn (f-sub8 33))
1488 (set tbit (if BI t 1 0))))
1490 (dshci shld "Shift logical dynamic"
1493 (+ (f-op4 4) rn rm (f-sub4 13))
1494 (sequence ((QI shamt))
1495 (set shamt (and QI rm 31))
1497 (set rn (sll rn shamt))
1499 (set rn (srl rn (sub 32 shamt)))
1502 (dshci shll "Shift left logical one bit"
1505 (+ (f-op4 4) rn (f-sub8 0))
1509 (set tbit (if BI t 1 0))))
1511 (dshci shll2 "Shift left logical two bits"
1514 (+ (f-op4 4) rn (f-sub8 8))
1515 (set rn (sll rn 2)))
1517 (dshci shll8 "Shift left logical eight bits"
1520 (+ (f-op4 4) rn (f-sub8 24))
1521 (set rn (sll rn 8)))
1523 (dshci shll16 "Shift left logical sixteen bits"
1526 (+ (f-op4 4) rn (f-sub8 40))
1527 (set rn (sll rn 16)))
1529 (dshci shlr "Shift right logical one bit"
1532 (+ (f-op4 4) rn (f-sub8 1))
1536 (set tbit (if BI t 1 0))))
1538 (dshci shlr2 "Shift right logical two bits"
1541 (+ (f-op4 4) rn (f-sub8 9))
1542 (set rn (srl rn 2)))
1544 (dshci shlr8 "Shift right logical eight bits"
1547 (+ (f-op4 4) rn (f-sub8 25))
1548 (set rn (srl rn 8)))
1550 (dshci shlr16 "Shift right logical sixteen bits"
1553 (+ (f-op4 4) rn (f-sub8 41))
1554 (set rn (srl rn 16)))
1556 (dshci stc-gbr "Store control register (GBR)"
1559 (+ (f-op4 0) rn (f-sub8 18))
1562 (dshci stcl-gbr "Store control register (GBR)"
1565 (+ (f-op4 4) rn (f-sub8 19))
1566 (sequence ((DI addr))
1567 (set addr (sub rn 4))
1568 (set (mem SI addr) gbr)
1571 (dshci sts-fpscr "Store status register (FPSCR)"
1574 (+ (f-op4 0) rn (f-sub8 106))
1577 (dshci stsl-fpscr "Store status register (FPSCR)"
1579 "sts.l fpscr, @-$rn"
1580 (+ (f-op4 4) rn (f-sub8 98))
1581 (sequence ((DI addr))
1582 (set addr (sub rn 4))
1583 (set (mem SI addr) fpscr)
1586 (dshci sts-fpul "Store status register (FPUL)"
1589 (+ (f-op4 0) rn (f-sub8 90))
1590 (set rn (subword SI fpul 0)))
1592 (dshci stsl-fpul "Store status register (FPUL)"
1595 (+ (f-op4 4) rn (f-sub8 82))
1596 (sequence ((DI addr))
1597 (set addr (sub rn 4))
1598 (set (mem SF addr) fpul)
1601 (dshci sts-mach "Store status register (MACH)"
1604 (+ (f-op4 0) rn (f-sub8 10))
1607 (dshci stsl-mach "Store status register (MACH)"
1610 (+ (f-op4 4) rn (f-sub8 2))
1611 (sequence ((DI addr))
1612 (set addr (sub rn 4))
1613 (set (mem SI addr) mach)
1616 (dshci sts-macl "Store status register (MACL)"
1619 (+ (f-op4 0) rn (f-sub8 26))
1622 (dshci stsl-macl "Store status register (MACL)"
1625 (+ (f-op4 4) rn (f-sub8 18))
1626 (sequence ((DI addr))
1627 (set addr (sub rn 4))
1628 (set (mem SI addr) macl)
1631 (dshci sts-pr "Store status register (PR)"
1634 (+ (f-op4 0) rn (f-sub8 42))
1637 (dshci stsl-pr "Store status register (PR)"
1640 (+ (f-op4 4) rn (f-sub8 34))
1641 (sequence ((DI addr))
1642 (set addr (sub rn 4))
1643 (set (mem SI addr) pr)
1646 (dshci sub "Subtract"
1649 (+ (f-op4 3) rn rm (f-sub4 8))
1650 (set rn (sub rn rm)))
1652 (dshci subc "Subtract and detect carry"
1655 (+ (f-op4 3) rn rm (f-sub4 10))
1656 (sequence ((BI flag))
1657 (set flag (sub-cflag rn rm tbit))
1658 (set rn (subc rn rm tbit))
1661 (dshci subv "Subtract and detect overflow"
1664 (+ (f-op4 3) rn rm (f-sub4 11))
1666 (set t (sub-oflag rn rm 0))
1667 (set rn (sub rn rm))
1668 (set tbit (if BI t 1 0))))
1670 (dshci swapb "Swap bytes"
1673 (+ (f-op4 6) rn rm (f-sub4 8))
1674 (sequence ((UHI top-half) (UQI byte1) (UQI byte0))
1675 (set top-half (subword HI rm 0))
1676 (set byte1 (subword QI rm 2))
1677 (set byte0 (subword QI rm 3))
1678 (set rn (or SI (sll SI top-half 16) (or SI (sll SI byte0 8) byte1)))))
1680 (dshci swapw "Swap words"
1683 (+ (f-op4 6) rn rm (f-sub4 9))
1684 (set rn (or (srl rm 16) (sll rm 16))))
1686 (dshci tasb "Test and set byte"
1689 (+ (f-op4 4) rn (f-sub8 27))
1690 (sequence ((UQI byte))
1691 (set byte (mem UQI rn))
1692 (set tbit (if BI (eq byte 0) 1 0))
1693 (set byte (or byte 128))
1694 (set (mem UQI rn) byte)))
1699 (+ (f-op8 #xc3) uimm8)
1700 (c-call "sh64_compact_trapa" uimm8 pc))
1702 (dshci tst "Test and set t-bit"
1705 (+ (f-op4 2) rn rm (f-sub4 8))
1706 (set tbit (if BI (eq (and rm rn) 0) 1 0)))
1708 (dshci tsti "Test and set t-bit immediate"
1711 (+ (f-op8 #xc8) uimm8)
1712 (set tbit (if BI (eq (and r0 (zext SI uimm8)) 0) 1 0)))
1714 (dshci tstb "Test and set t-bit immedate with memory byte"
1716 "tst.b #$imm8, @(r0, gbr)"
1717 (+ (f-op8 #xcc) imm8)
1718 (sequence ((DI addr))
1719 (set addr (add r0 gbr))
1720 (set tbit (if BI (eq (and (mem UQI addr) imm8) 0) 1 0))))
1722 (dshci xor "Exclusive OR"
1725 (+ (f-op4 2) rn64 rm64 (f-sub4 10))
1726 (set rn64 (xor rn64 rm64)))
1728 (dshci xori "Exclusive OR immediate"
1731 (+ (f-op8 #xca) uimm8)
1732 (set (reg h-gr 0) (xor (reg h-gr 0) (zext DI uimm8))))
1734 (dshci xorb "Exclusive OR immediate with memory byte"
1736 "xor.b #$imm8, @(r0, gbr)"
1737 (+ (f-op8 #xce) imm8)
1738 (sequence ((DI addr) (UQI data))
1739 (set addr (add r0 gbr))
1740 (set data (xor (mem UQI addr) imm8))
1741 (set (mem UQI addr) data)))
1743 (dshci xtrct "Extract"
1746 (+ (f-op4 2) rn rm (f-sub4 13))
1747 (set rn (or (sll rm 16) (srl rn 16))))