1 ; Hitachi SHcompact instruction set description. -*- Scheme -*-
3 ; Copyright 2000, 2007 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 3 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,
25 ; dshcf -- define-normal-sh-compact-field
27 (define-pmacro (dshcf xname xcomment ignored xstart xlength)
28 (dnf xname xcomment ((ISA compact)) xstart xlength))
30 ; dshcop -- define-normal-sh-compact-operand
32 (define-pmacro (dshcop xname xcomment ignored xhardware xfield)
33 (dnop xname xcomment ((ISA compact)) xhardware xfield))
36 ; SHcompact-specific attributes.
42 (comment "instruction may not appear in a delay slot")
49 (comment "floating point instruction")
56 (values (fr0 0) (fr1 1) (fr2 2) (fr3 3) (fr4 4) (fr5 5)
57 (fr6 6) (fr7 7) (fr8 8) (fr9 9) (fr10 10) (fr11 11)
58 (fr12 12) (fr13 13) (fr14 14) (fr15 15))
65 (values (dr0 0) (dr2 2) (dr4 4) (dr6 6) (dr8 8) (dr10 10) (dr12 12) (dr14 14))
72 (values (xf0 0) (xf1 1) (xf2 2) (xf3 3) (xf4 4) (xf5 5)
73 (xf6 6) (xf7 7) (xf8 8) (xf9 9) (xf10 10) (xf11 11)
74 (xf12 12) (xf13 13) (xf14 14) (xf15 15))
77 ; Hardware specific to the SHcompact mode.
79 (define-pmacro (front) (mul 16 frbit))
80 (define-pmacro (back) (mul 16 (not frbit)))
84 (comment "Single precision floating point registers")
85 (attrs VIRTUAL (ISA compact))
86 (indices extern-keyword frc-names)
87 (type register SF (16))
88 (get (index) (reg h-fr (add (front) index)))
89 (set (index newval) (set (reg h-fr (add (front) index)) newval))
94 (comment "Double precision floating point registers")
95 (attrs VIRTUAL (ISA compact))
96 (indices extern-keyword drc-names)
97 (type register DF (8))
98 (get (index) (reg h-dr (add (front) index)))
99 (set (index newval) (set (reg h-dr (add (front) index)) newval))
104 (comment "Extended single precision floating point registers")
105 (attrs VIRTUAL (ISA compact))
106 (indices extern-keyword xf-names)
107 (type register SF (16))
108 (get (index) (reg h-fr (add (back) index)))
109 (set (index newval) (set (reg h-fr (add (back) index)) newval))
114 (comment "Extended double precision floating point registers")
115 (attrs VIRTUAL (ISA compact))
116 (indices extern-keyword frc-names)
117 (type register DF (8))
118 (get (index) (reg h-dr (add (back) index)))
119 (set (index newval) (set (reg h-dr (add (back) index)) newval))
124 (comment "Single precision floating point vectors")
125 (attrs VIRTUAL (ISA compact))
126 (indices keyword "" ((fv0 0) (fv4 4) (fv8 8) (fv12 12)))
127 (type register SF (4))
128 (get (index) (reg h-fr (add (front) index)))
129 (set (index newval) (set (reg h-fr (add (front) index)) newval))
134 (comment "SHcompact floating point status/control register")
135 (attrs VIRTUAL (ISA compact))
137 (get () (or (or (or (raw-reg h-fpscr) (sll SI prbit 19)) (sll SI szbit 20)) (sll SI frbit 21)))
138 (set (newvalue) (sequence ()
139 (set (reg h-fpscr) newvalue)
140 (set prbit (and (srl newvalue 19) 1))
141 (set szbit (and (srl newvalue 20) 1))
142 (set frbit (and (srl newvalue 21) 1))))
147 (comment "Global base register")
148 (attrs VIRTUAL (ISA compact))
150 (get () (subword SI (raw-reg h-gr 16) 1))
151 (set (newval) (set (raw-reg h-gr 16) (ext DI newval)))
156 (comment "Procedure link register")
157 (attrs VIRTUAL (ISA compact))
159 (get () (subword SI (raw-reg h-gr 18) 1))
160 (set (newval) (set (raw-reg h-gr 18) (ext DI newval)))
165 (comment "Multiple-accumulate low register")
166 (attrs VIRTUAL (ISA compact))
168 (get () (subword SI (raw-reg h-gr 17) 1))
169 (set (newval) (set (raw-reg h-gr 17) (-join-si (subword SI (raw-reg h-gr 17) 0) newval)))
174 (comment "Multiply-accumulate high register")
175 (attrs VIRTUAL (ISA compact))
177 (get () (subword SI (raw-reg h-gr 17) 0))
178 (set (newval) (set (raw-reg h-gr 17) (-join-si newval (subword SI (raw-reg h-gr 17) 1))))
183 (comment "Condition code flag")
184 (attrs VIRTUAL (ISA compact))
186 (get () (and BI (raw-reg h-gr 19) 1))
187 (set (newval) (set (raw-reg h-gr 19) (or (and (raw-reg h-gr 19) (inv DI 1)) (zext DI newval))))
191 (dshcf f-op4 "Opcode (4 bits)" () 15 4)
192 (dshcf f-op8 "Opcode (8 bits)" () 15 8)
193 (dshcf f-op16 "Opcode (16 bits)" () 15 16)
195 (dshcf f-sub4 "Sub opcode (4 bits)" () 3 4)
196 (dshcf f-sub8 "Sub opcode (8 bits)" () 7 8)
197 (dshcf f-sub10 "Sub opcode (10 bits)" () 9 10)
199 (dshcf f-rn "Register selector n" () 11 4)
200 (dshcf f-rm "Register selector m" () 7 4)
202 (dshcf f-8-1 "One bit at bit 8" () 8 1)
204 (df f-disp8 "Displacement (8 bits)" ((ISA compact) PCREL-ADDR) 7 8 INT
205 ((value pc) (sra SI value 1))
206 ((value pc) (add SI (sll SI value 1) (add pc 4))))
208 (df f-disp12 "Displacement (12 bits)" ((ISA compact) PCREL-ADDR) 11 12 INT
209 ((value pc) (sra SI value 1))
210 ((value pc) (add SI (sll SI value 1) (add pc 4))))
212 (dshcf f-imm8 "Immediate (8 bits)" () 7 8)
213 (dshcf f-imm4 "Immediate (4 bits)" () 3 4)
215 (df f-imm4x2 "Immediate (4 bits)" ((ISA compact)) 3 4 UINT
216 ((value pc) (srl SI value 1))
217 ((value pc) (sll SI value 1)))
219 (df f-imm4x4 "Immediate (4 bits)" ((ISA compact)) 3 4 UINT
220 ((value pc) (srl SI value 2))
221 ((value pc) (sll SI value 2)))
223 (df f-imm8x2 "Immediate (8 bits)" ((ISA compact)) 7 8 UINT
224 ((value pc) (sra SI value 1))
225 ((value pc) (sll SI value 1)))
227 (df f-imm8x4 "Immediate (8 bits)" ((ISA compact)) 7 8 UINT
228 ((value pc) (sra SI value 2))
229 ((value pc) (sll SI value 2)))
231 (df f-dn "Double selector n" ((ISA compact)) 11 3 UINT
232 ((value pc) (srl SI value 1))
233 ((value pc) (sll SI value 1)))
235 (df f-dm "Double selector m" ((ISA compact)) 7 3 UINT
236 ((value pc) (srl SI value 1))
237 ((value pc) (sll SI value 1)))
239 (df f-vn "Vector selector n" ((ISA compact)) 11 2 UINT
240 ((value pc) (srl SI value 2))
241 ((value pc) (sll SI value 2)))
243 (df f-vm "Vector selector m" ((ISA compact)) 9 2 UINT
244 ((value pc) (srl SI value 2))
245 ((value pc) (sll SI value 2)))
247 (df f-xn "Extended selector n" ((ISA compact)) 11 3 UINT
248 ((value pc) (srl SI value 1))
249 ((value pc) (add SI (sll SI value 1) 1)))
251 (df f-xm "Extended selector m" ((ISA compact)) 7 3 UINT
252 ((value pc) (srl SI value 1))
253 ((value pc) (add SI (sll SI value 1) 1)))
258 (dshcop rm "Left general purpose register" () h-grc f-rm)
259 (dshcop rn "Right general purpose register" () h-grc f-rn)
260 (dshcop r0 "Register 0" () h-grc 0)
262 (dshcop frn "Single precision register" () h-frc f-rn)
263 (dshcop frm "Single precision register" () h-frc f-rm)
265 (dshcop fvn "Left floating point vector" () h-fvc f-vn)
266 (dshcop fvm "Right floating point vector" () h-fvc f-vm)
268 (dshcop drn "Left double precision register" () h-drc f-dn)
269 (dshcop drm "Right double precision register" () h-drc f-dm)
271 (dshcop imm4 "Immediate value (4 bits)" () h-sint f-imm4)
272 (dshcop imm8 "Immediate value (8 bits)" () h-sint f-imm8)
273 (dshcop uimm8 "Immediate value (8 bits unsigned)" () h-uint f-imm8)
275 (dshcop imm4x2 "Immediate value (4 bits, 2x scale)" () h-uint f-imm4x2)
276 (dshcop imm4x4 "Immediate value (4 bits, 4x scale)" () h-uint f-imm4x4)
277 (dshcop imm8x2 "Immediate value (8 bits, 2x scale)" () h-uint f-imm8x2)
278 (dshcop imm8x4 "Immediate value (8 bits, 4x scale)" () h-uint f-imm8x4)
280 (dshcop disp8 "Displacement (8 bits)" () h-iaddr f-disp8)
281 (dshcop disp12 "Displacement (12 bits)" () h-iaddr f-disp12)
283 (dshcop rm64 "Register m (64 bits)" () h-gr f-rm)
284 (dshcop rn64 "Register n (64 bits)" () h-gr f-rn)
286 (dshcop gbr "Global base register" () h-gbr f-nil)
287 (dshcop pr "Procedure link register" () h-pr f-nil)
289 (dshcop fpscr "Floating point status/control register" () h-fpccr f-nil)
291 (dshcop tbit "Condition code flag" () h-tbit f-nil)
292 (dshcop sbit "Multiply-accumulate saturation flag" () h-sbit f-nil)
293 (dshcop mbit "Divide-step M flag" () h-mbit f-nil)
294 (dshcop qbit "Divide-step Q flag" () h-qbit f-nil)
295 (dshcop fpul "Floating point ???" () h-fr 32)
297 (dshcop frbit "Floating point register bank bit" () h-frbit f-nil)
298 (dshcop szbit "Floating point transfer size bit" () h-szbit f-nil)
299 (dshcop prbit "Floating point precision bit" () h-prbit f-nil)
301 (dshcop macl "Multiply-accumulate low register" () h-macl f-nil)
302 (dshcop mach "Multiply-accumulate high register" () h-mach f-nil)
305 (define-operand (name fsdm) (comment "bar")
306 (attrs (ISA compact)) (type h-frc) (index f-rm) (handlers (parse "fsd")))
308 (define-operand (name fsdn) (comment "bar")
309 (attrs (ISA compact)) (type h-frc) (index f-rn))
312 ; Cover macro to dni to indicate these are all SHcompact instructions.
313 ; dshmi: define-normal-sh-compact-insn
315 (define-pmacro (dshci xname xcomment xattrs xsyntax xformat xsemantics)
317 (name (.sym xname -compact))
319 (.splice attrs (.unsplice xattrs) (ISA compact))
322 (semantics xsemantics)))
324 (define-pmacro (dr operand) (reg h-dr (index-of operand)))
325 (define-pmacro (xd x) (reg h-xd (and (index-of x) (inv QI 1))))
330 (+ (f-op4 3) rn rm (f-sub4 12))
331 (set rn (add rn rm)))
333 (dshci addi "Add immediate"
336 (+ (f-op4 7) rn imm8)
337 (set rn (add rn (ext SI (and QI imm8 255)))))
339 (dshci addc "Add with carry"
342 (+ (f-op4 3) rn rm (f-sub4 14))
343 (sequence ((BI flag))
344 (set flag (add-cflag rn rm tbit))
345 (set rn (addc rn rm tbit))
348 (dshci addv "Add with overflow"
351 (+ (f-op4 3) rn rm (f-sub4 15))
353 (set t (add-oflag rn rm 0))
357 (dshci and "Bitwise AND"
360 (+ (f-op4 2) rn64 rm64 (f-sub4 9))
361 (set rn64 (and rm64 rn64)))
363 (dshci andi "Bitwise AND immediate"
366 (+ (f-op8 #xc9) uimm8)
367 (set r0 (and r0 (zext DI uimm8))))
369 (dshci andb "Bitwise AND memory byte"
371 "and.b #$imm8, @(r0, gbr)"
372 (+ (f-op8 #xcd) imm8)
373 (sequence ((DI addr) (UQI data))
374 (set addr (add r0 gbr))
375 (set data (and (mem UQI addr) imm8))
376 (set (mem UQI addr) data)))
378 (dshci bf "Conditional branch"
381 (+ (f-op8 #x8b) disp8)
385 (dshci bfs "Conditional branch with delay slot"
388 (+ (f-op8 #x8f) disp8)
390 (delay 1 (set pc disp8))))
395 (+ (f-op4 10) disp12)
396 (delay 1 (set pc disp12)))
398 (dshci braf "Branch far"
401 (+ (f-op4 0) rn (f-sub8 35))
402 (delay 1 (set pc (add (ext DI rn) (add pc 4)))))
404 (dshci brk "Breakpoint"
408 (c-call "sh64_break" pc))
410 (dshci bsr "Branch to subroutine"
413 (+ (f-op4 11) disp12)
414 (delay 1 (sequence ()
418 (dshci bsrf "Branch to far subroutine"
421 (+ (f-op4 0) rn (f-sub8 3))
422 (delay 1 (sequence ()
424 (set pc (add (ext DI rn) (add pc 4))))))
426 (dshci bt "Conditional branch"
429 (+ (f-op8 #x89) disp8)
433 (dshci bts "Conditional branch with delay slot"
436 (+ (f-op8 #x8d) disp8)
438 (delay 1 (set pc disp8))))
440 (dshci clrmac "Clear MACL and MACH"
448 (dshci clrs "Clear S-bit"
454 (dshci clrt "Clear T-bit"
460 (dshci cmpeq "Compare if equal"
463 (+ (f-op4 3) rn rm (f-sub4 0))
464 (set tbit (eq rm rn)))
466 (dshci cmpeqi "Compare if equal (immediate)"
469 (+ (f-op8 #x88) imm8)
470 (set tbit (eq r0 (ext SI (and QI imm8 255)))))
472 (dshci cmpge "Compare if greater than or equal"
475 (+ (f-op4 3) rn rm (f-sub4 3))
476 (set tbit (ge rn rm)))
478 (dshci cmpgt "Compare if greater than"
481 (+ (f-op4 3) rn rm (f-sub4 7))
482 (set tbit (gt rn rm)))
484 (dshci cmphi "Compare if greater than (unsigned)"
487 (+ (f-op4 3) rn rm (f-sub4 6))
488 (set tbit (gtu rn rm)))
490 (dshci cmphs "Compare if greater than or equal (unsigned)"
493 (+ (f-op4 3) rn rm (f-sub4 2))
494 (set tbit (geu rn rm)))
496 (dshci cmppl "Compare if greater than zero"
499 (+ (f-op4 4) rn (f-sub8 21))
500 (set tbit (gt rn 0)))
502 (dshci cmppz "Compare if greater than or equal zero"
505 (+ (f-op4 4) rn (f-sub8 17))
506 (set tbit (ge rn 0)))
508 (dshci cmpstr "Compare bytes"
511 (+ (f-op4 2) rn rm (f-sub4 12))
512 (sequence ((BI t) (SI temp))
513 (set temp (xor rm rn))
514 (set t (eq (and temp #xff000000) 0))
515 (set t (or (eq (and temp #xff0000) 0) t))
516 (set t (or (eq (and temp #xff00) 0) t))
517 (set t (or (eq (and temp #xff) 0) t))
518 (set tbit (if BI (gtu t 0) 1 0))))
520 (dshci div0s "Initialise divide-step state for signed division"
523 (+ (f-op4 2) rn rm (f-sub4 7))
525 (set qbit (srl rn 31))
526 (set mbit (srl rm 31))
527 (set tbit (if BI (eq (srl rm 31) (srl rn 31)) 0 1))))
529 (dshci div0u "Initialise divide-step state for unsigned division"
538 (dshci div1 "Divide step"
541 (+ (f-op4 3) rn rm (f-sub4 4))
542 (sequence ((BI oldq) (SI tmp0) (UQI tmp1))
544 (set qbit (srl rn 31))
545 (set rn (or (sll rn 1) (zext SI tbit)))
551 (set tmp1 (gtu rn tmp0))
553 (set qbit (if BI tmp1 1 0))
554 (set qbit (if BI (eq tmp1 0) 1 0))))
558 (set tmp1 (ltu rn tmp0))
560 (set qbit (if BI (eq tmp1 0) 1 0))
561 (set qbit (if BI tmp1 1 0)))))
566 (set tmp1 (ltu rn tmp0))
568 (set qbit (if BI tmp1 1 0))
569 (set qbit (if BI (eq tmp1 0) 1 0))))
573 (set tmp1 (gtu rn tmp0))
575 (set qbit (if BI (eq tmp1 0) 1 0))
576 (set qbit (if BI tmp1 1 0))))))
577 (set tbit (if BI (eq qbit mbit) 1 0))))
579 (dshci dmulsl "Multiply long (signed)"
582 (+ (f-op4 3) rn rm (f-sub4 13))
583 (sequence ((DI result))
584 (set result (mul (ext DI rm) (ext DI rn)))
585 (set mach (subword SI result 0))
586 (set macl (subword SI result 1))))
588 (dshci dmulul "Multiply long (unsigned)"
591 (+ (f-op4 3) rn rm (f-sub4 5))
592 (sequence ((DI result))
593 (set result (mul (zext DI rm) (zext DI rn)))
594 (set mach (subword SI result 0))
595 (set macl (subword SI result 1))))
597 (dshci dt "Decrement and set"
600 (+ (f-op4 4) rn (f-sub8 16))
603 (set tbit (eq rn 0))))
605 (dshci extsb "Sign extend byte"
608 (+ (f-op4 6) rn rm (f-sub4 14))
609 (set rn (ext SI (subword QI rm 3))))
611 (dshci extsw "Sign extend word"
614 (+ (f-op4 6) rn rm (f-sub4 15))
615 (set rn (ext SI (subword HI rm 1))))
617 (dshci extub "Zero extend byte"
620 (+ (f-op4 6) rn rm (f-sub4 12))
621 (set rn (zext SI (subword QI rm 3))))
623 (dshci extuw "Zero etxend word"
626 (+ (f-op4 6) rn rm (f-sub4 13))
627 (set rn (zext SI (subword HI rm 1))))
629 (dshci fabs "Floating point absolute"
632 (+ (f-op4 15) fsdn (f-sub8 #x5d))
634 (set (dr fsdn) (c-call DF "sh64_fabsd" (dr fsdn)))
635 (set fsdn (c-call SF "sh64_fabss" fsdn))))
637 (dshci fadd "Floating point add"
640 (+ (f-op4 15) fsdn fsdm (f-sub4 0))
642 (set (dr fsdn) (c-call DF "sh64_faddd" (dr fsdm) (dr fsdn)))
643 (set fsdn (c-call SF "sh64_fadds" fsdm fsdn))))
645 (dshci fcmpeq "Floating point compare equal"
647 "fcmp/eq $fsdm, $fsdn"
648 (+ (f-op4 15) fsdn fsdm (f-sub4 4))
650 (set tbit (c-call BI "sh64_fcmpeqd" (dr fsdm) (dr fsdn)))
651 (set tbit (c-call BI "sh64_fcmpeqs" fsdm fsdn))))
653 (dshci fcmpgt "Floating point compare greater than"
655 "fcmp/gt $fsdm, $fsdn"
656 (+ (f-op4 15) fsdn fsdm (f-sub4 5))
658 (set tbit (c-call BI "sh64_fcmpgtd" (dr fsdn) (dr fsdm)))
659 (set tbit (c-call BI "sh64_fcmpgts" fsdn fsdm))))
661 (dshci fcnvds "Floating point convert (double to single)"
664 (+ (f-op4 15) drn (f-8-1 10) (f-sub8 #xbd))
665 (set fpul (c-call SF "sh64_fcnvds" drn)))
667 (dshci fcnvsd "Floating point convert (single to double)"
670 (+ (f-op4 15) drn (f-8-1 0) (f-sub8 #xad))
671 (set drn (c-call DF "sh64_fcnvsd" fpul)))
673 (dshci fdiv "Floating point divide"
676 (+ (f-op4 15) fsdn fsdm (f-sub4 3))
678 (set (dr fsdn) (c-call DF "sh64_fdivd" (dr fsdn) (dr fsdm)))
679 (set fsdn (c-call SF "sh64_fdivs" fsdn fsdm))))
681 (dshci fipr "Floating point inner product"
684 (+ (f-op4 15) fvn fvm (f-sub8 #xed))
685 (sequence ((QI m) (QI n) (SF res))
686 (set m (index-of fvm))
687 (set n (index-of fvn))
688 (set res (c-call SF "sh64_fmuls" fvm fvn))
689 (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)))))
690 (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)))))
691 (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)))))
692 (set (reg h-frc (add n 3)) res)))
694 (dshci flds "Floating point load status register"
697 (+ (f-op4 15) frn (f-sub8 #x1d))
700 (dshci fldi0 "Floating point load immediate 0.0"
703 (+ (f-op4 15) frn (f-sub8 #x8d))
704 (set frn (c-call SF "sh64_fldi0")))
706 (dshci fldi1 "Floating point load immediate 1.0"
709 (+ (f-op4 15) frn (f-sub8 #x9d))
710 (set frn (c-call SF "sh64_fldi1")))
712 (dshci float "Floating point integer conversion"
715 (+ (f-op4 15) fsdn (f-sub8 #x2d))
717 (set (dr fsdn) (c-call DF "sh64_floatld" fpul))
718 (set fsdn (c-call SF "sh64_floatls" fpul))))
720 (dshci fmac "Floating point multiply and accumulate"
722 "fmac fr0, $frm, $frn"
723 (+ (f-op4 15) frn frm (f-sub4 14))
724 (set frn (c-call SF "sh64_fmacs" (reg h-frc 0) frm frn)))
726 (define-pmacro (even x) (eq (and x 1) 0))
727 (define-pmacro (odd x) (eq (and x 1) 1))
728 (define-pmacro (extd x) (odd (index-of x)))
730 (dshci fmov1 "Floating point move (register to register)"
733 (+ (f-op4 15) frn frm (f-sub4 12))
735 ; single precision operation
737 ; double or extended operation
740 (set (xd frn) (xd frm))
741 (set (dr frn) (xd frm)))
743 (set (xd frn) (dr frm))
744 (set (dr frn) (dr frm))))))
746 (dshci fmov2 "Floating point load"
749 (+ (f-op4 15) frn rm (f-sub4 8))
751 ; single precision operation
752 (set frn (mem SF rm))
753 ; double or extended operation
755 (set (xd frn) (mem DF rm))
756 (set (dr frn) (mem DF rm)))))
758 (dshci fmov3 "Floating point load (post-increment)"
761 (+ (f-op4 15) frn rm (f-sub4 9))
763 ; single precision operation
765 (set frn (mem SF rm))
767 ; double or extended operation
770 (set (xd frn) (mem DF rm))
771 (set (dr frn) (mem DF rm)))
772 (set rm (add rm 8)))))
774 (dshci fmov4 "Floating point load (register/register indirect)"
776 "fmov @(r0, $rm), $frn"
777 (+ (f-op4 15) frn rm (f-sub4 6))
779 ; single precision operation
780 (set frn (mem SF (add r0 rm)))
781 ; double or extended operation
783 (set (xd frn) (mem DF (add r0 rm)))
784 (set (dr frn) (mem DF (add r0 rm))))))
786 (dshci fmov5 "Floating point store"
789 (+ (f-op4 15) rn frm (f-sub4 10))
791 ; single precision operation
792 (set (mem SF rn) frm)
793 ; double or extended operation
795 (set (mem DF rn) (xd frm))
796 (set (mem DF rn) (dr frm)))))
798 (dshci fmov6 "Floating point store (pre-decrement)"
801 (+ (f-op4 15) rn frm (f-sub4 11))
803 ; single precision operation
806 (set (mem SF rn) frm))
807 ; double or extended operation
811 (set (mem DF rn) (xd frm))
812 (set (mem DF rn) (dr frm))))))
814 (dshci fmov7 "Floating point store (register/register indirect)"
816 "fmov $frm, @(r0, $rn)"
817 (+ (f-op4 15) rn frm (f-sub4 7))
819 ; single precision operation
820 (set (mem SF (add r0 rn)) frm)
821 ; double or extended operation
823 (set (mem DF (add r0 rn)) (xd frm))
824 (set (mem DF (add r0 rn)) (dr frm)))))
826 (dshci fmul "Floating point multiply"
829 (+ (f-op4 15) fsdn fsdm (f-sub4 2))
831 (set (dr fsdn) (c-call DF "sh64_fmuld" (dr fsdm) (dr fsdn)))
832 (set fsdn (c-call SF "sh64_fmuls" fsdm fsdn))))
834 (dshci fneg "Floating point negate"
837 (+ (f-op4 15) fsdn (f-sub8 #x4d))
839 (set (dr fsdn) (c-call DF "sh64_fnegd" (dr fsdn)))
840 (set fsdn (c-call SF "sh64_fnegs" fsdn))))
842 (dshci frchg "Toggle floating point register banks"
846 (set frbit (not frbit)))
848 (dshci fschg "Set size of floating point transfers"
852 (set szbit (not szbit)))
854 (dshci fsqrt "Floating point square root"
857 (+ (f-op4 15) fsdn (f-sub8 #x6d))
859 (set (dr fsdn) (c-call DF "sh64_fsqrtd" (dr fsdn)))
860 (set fsdn (c-call SF "sh64_fsqrts" fsdn))))
862 (dshci fsts "Floating point store status register"
865 (+ (f-op4 15) frn (f-sub8 13))
868 (dshci fsub "Floating point subtract"
871 (+ (f-op4 15) fsdn fsdm (f-sub4 1))
873 (set (dr fsdn) (c-call DF "sh64_fsubd" (dr fsdn) (dr fsdm)))
874 (set fsdn (c-call SF "sh64_fsubs" fsdn fsdm))))
876 (dshci ftrc "Floating point truncate"
879 (+ (f-op4 15) fsdn (f-sub8 #x3d))
880 (set fpul (if SF prbit
881 (c-call SF "sh64_ftrcdl" (dr fsdn))
882 (c-call SF "sh64_ftrcsl" fsdn))))
884 (dshci ftrv "Floating point transform vector"
887 (+ (f-op4 15) fvn (f-sub10 #x1fd))
888 (sequence ((QI n) (SF res))
889 (set n (index-of fvn))
890 (set res (c-call SF "sh64_fmuls" (reg h-xf 0) (reg h-frc n)))
891 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 4) (reg h-frc (add n 1)))))
892 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 8) (reg h-frc (add n 2)))))
893 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 12) (reg h-frc (add n 3)))))
894 (set (reg h-frc n) res)
895 (set res (c-call SF "sh64_fmuls" (reg h-xf 1) (reg h-frc n)))
896 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 5) (reg h-frc (add n 1)))))
897 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 9) (reg h-frc (add n 2)))))
898 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 13) (reg h-frc (add n 3)))))
899 (set (reg h-frc (add n 1)) res)
900 (set res (c-call SF "sh64_fmuls" (reg h-xf 2) (reg h-frc n)))
901 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 6) (reg h-frc (add n 1)))))
902 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 10) (reg h-frc (add n 2)))))
903 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 14) (reg h-frc (add n 3)))))
904 (set (reg h-frc (add n 2)) res)
905 (set res (c-call SF "sh64_fmuls" (reg h-xf 3) (reg h-frc n)))
906 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 7) (reg h-frc (add n 1)))))
907 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 11) (reg h-frc (add n 2)))))
908 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 15) (reg h-frc (add n 3)))))
909 (set (reg h-frc (add n 3)) res)))
914 (+ (f-op4 4) rn (f-sub8 43))
915 (delay 1 (set pc rn)))
917 (dshci jsr "Jump to subroutine"
920 (+ (f-op4 4) rn (f-sub8 11))
921 (delay 1 (sequence ()
925 (dshci ldc "Load control register (GBR)"
928 (+ (f-op4 4) rn (f-sub8 30))
931 (dshci ldcl "Load control register (GBR)"
934 (+ (f-op4 4) rn (f-sub8 39))
936 (set gbr (mem SI rn))
937 (set rn (add rn 4))))
939 (dshci lds-fpscr "Load status register (FPSCR)"
942 (+ (f-op4 4) rn (f-sub8 106))
945 (dshci ldsl-fpscr "Load status register (FPSCR)"
947 "lds.l @${rn}+, fpscr"
948 (+ (f-op4 4) rn (f-sub8 102))
950 (set fpscr (mem SI rn))
951 (set rn (add rn 4))))
953 (dshci lds-fpul "Load status register (FPUL)"
956 (+ (f-op4 4) rn (f-sub8 90))
957 ; Use subword to convert rn's mode.
958 (set fpul (subword SF rn 0)))
960 (dshci ldsl-fpul "Load status register (FPUL)"
962 "lds.l @${rn}+, fpul"
963 (+ (f-op4 4) rn (f-sub8 86))
965 (set fpul (mem SF rn))
966 (set rn (add rn 4))))
968 (dshci lds-mach "Load status register (MACH)"
971 (+ (f-op4 4) rn (f-sub8 10))
974 (dshci ldsl-mach "Load status register (MACH), post-increment"
976 "lds.l @${rn}+, mach"
977 (+ (f-op4 4) rn (f-sub8 6))
979 (set mach (mem SI rn))
980 (set rn (add rn 4))))
982 (dshci lds-macl "Load status register (MACL)"
985 (+ (f-op4 4) rn (f-sub8 26))
988 (dshci ldsl-macl "Load status register (MACL), post-increment"
990 "lds.l @${rn}+, macl"
991 (+ (f-op4 4) rn (f-sub8 22))
993 (set macl (mem SI rn))
994 (set rn (add rn 4))))
996 (dshci lds-pr "Load status register (PR)"
999 (+ (f-op4 4) rn (f-sub8 42))
1002 (dshci ldsl-pr "Load status register (PR), post-increment"
1005 (+ (f-op4 4) rn (f-sub8 38))
1007 (set pr (mem SI rn))
1008 (set rn (add rn 4))))
1010 (dshci macl "Multiply and accumulate (long)"
1012 "mac.l @${rm}+, @${rn}+"
1013 (+ (f-op4 0) rn rm (f-sub4 15))
1014 (sequence ((DI tmpry) (DI mac) (DI result) (SI x) (SI y))
1017 (if (eq (index-of rn) (index-of rm))
1020 (set rm (add rm 4))))
1023 (set tmpry (mul (zext DI x) (zext DI y)))
1024 (set mac (or DI (sll (zext DI mach) 32) (zext DI macl)))
1025 (set result (add mac tmpry))
1028 (sequence ((SI min) (SI max))
1029 (set max (srl (inv DI 0) 16))
1030 ; Preserve bit 48 for sign.
1031 (set min (srl (inv DI 0) 15))
1035 (set result min)))))
1036 (set mach (subword SI result 0))
1037 (set macl (subword SI result 1)))))
1039 (dshci macw "Multiply and accumulate (word)"
1041 "mac.w @${rm}+, @${rn}+"
1042 (+ (f-op4 4) rn rm (f-sub4 15))
1043 (sequence ((SI tmpry) (DI mac) (DI result) (HI x) (HI y))
1046 (if (eq (index-of rn) (index-of rm))
1049 (set rm (add rm 2))))
1052 (set tmpry (mul (zext SI x) (zext SI y)))
1055 (if (add-oflag tmpry macl 0)
1057 (set macl (add tmpry macl)))
1059 (set mac (or DI (sll (zext DI mach) 32) (zext DI macl)))
1060 (set result (add mac (ext DI tmpry)))
1061 (set mach (subword SI result 0))
1062 (set macl (subword SI result 1))))))
1067 (+ (f-op4 6) rn64 rm64 (f-sub4 3))
1070 (dshci movi "Move immediate"
1073 (+ (f-op4 14) rn imm8)
1074 (set rn (ext DI (and QI imm8 255))))
1076 (dshci movb1 "Store byte to memory (register indirect w/ zero displacement)"
1079 (+ (f-op4 2) rn rm (f-sub4 0))
1080 (set (mem UQI rn) (subword UQI rm 3)))
1082 (dshci movb2 "Store byte to memory (register indirect w/ pre-decrement)"
1085 (+ (f-op4 2) rn rm (f-sub4 4))
1086 (sequence ((DI addr))
1087 (set addr (sub rn 1))
1088 (set (mem UQI addr) (subword UQI rm 3))
1091 (dshci movb3 "Store byte to memory (register/register indirect)"
1093 "mov.b $rm, @(r0,$rn)"
1094 (+ (f-op4 0) rn rm (f-sub4 4))
1095 (set (mem UQI (add r0 rn)) (subword UQI rm 3)))
1097 (dshci movb4 "Store byte to memory (GBR-relative w/ displacement)"
1099 "mov.b r0, @($imm8, gbr)"
1100 (+ (f-op8 #xc0) imm8)
1101 (sequence ((DI addr))
1102 (set addr (add gbr imm8))
1103 (set (mem UQI addr) (subword UQI r0 3))))
1105 (dshci movb5 "Store byte to memory (register indirect w/ displacement)"
1107 "mov.b r0, @($imm4, $rm)"
1108 (+ (f-op8 #x80) rm imm4)
1109 (sequence ((DI addr))
1110 (set addr (add rm imm4))
1111 (set (mem UQI addr) (subword UQI r0 3))))
1113 (dshci movb6 "Load byte from memory (register indirect w/ zero displacement)"
1116 (+ (f-op4 6) rn rm (f-sub4 0))
1117 (set rn (ext SI (mem QI rm))))
1119 (dshci movb7 "Load byte from memory (register indirect w/ post-increment)"
1121 "mov.b @${rm}+, $rn"
1122 (+ (f-op4 6) rn rm (f-sub4 4))
1123 (sequence ((QI data))
1124 (set data (mem QI rm))
1125 (if (eq (index-of rm) (index-of rn))
1126 (set rm (ext SI data))
1127 (set rm (add rm 1)))
1128 (set rn (ext SI data))))
1130 (dshci movb8 "Load byte from memory (register/register indirect)"
1132 "mov.b @(r0, $rm), $rn"
1133 (+ (f-op4 0) rn rm (f-sub4 12))
1134 (set rn (ext SI (mem QI (add r0 rm)))))
1136 (dshci movb9 "Load byte from memory (GBR-relative with displacement)"
1138 "mov.b @($imm8, gbr), r0"
1139 (+ (f-op8 #xc4) imm8)
1140 (set r0 (ext SI (mem QI (add gbr imm8)))))
1142 (dshci movb10 "Load byte from memory (register indirect w/ displacement)"
1144 "mov.b @($imm4, $rm), r0"
1145 (+ (f-op8 #x84) rm imm4)
1146 (set r0 (ext SI (mem QI (add rm imm4)))))
1148 (dshci movl1 "Store long word to memory (register indirect w/ zero displacement)"
1151 (+ (f-op4 2) rn rm (f-sub4 2))
1152 (set (mem SI rn) rm))
1154 (dshci movl2 "Store long word to memory (register indirect w/ pre-decrement)"
1157 (+ (f-op4 2) rn rm (f-sub4 6))
1158 (sequence ((SI addr))
1159 (set addr (sub rn 4))
1160 (set (mem SI addr) rm)
1163 (dshci movl3 "Store long word to memory (register/register indirect)"
1165 "mov.l $rm, @(r0, $rn)"
1166 (+ (f-op4 0) rn rm (f-sub4 6))
1167 (set (mem SI (add r0 rn)) rm))
1169 (dshci movl4 "Store long word to memory (GBR-relative w/ displacement)"
1171 "mov.l r0, @($imm8x4, gbr)"
1172 (+ (f-op8 #xc2) imm8x4)
1173 (set (mem SI (add gbr imm8x4)) r0))
1175 (dshci movl5 "Store long word to memory (register indirect w/ displacement)"
1177 "mov.l $rm, @($imm4x4, $rn)"
1178 (+ (f-op4 1) rn rm imm4x4)
1179 (set (mem SI (add rn imm4x4)) rm))
1181 (dshci movl6 "Load long word to memory (register indirect w/ zero displacement)"
1184 (+ (f-op4 6) rn rm (f-sub4 2))
1185 (set rn (mem SI rm)))
1187 (dshci movl7 "Load long word from memory (register indirect w/ post-increment)"
1189 "mov.l @${rm}+, $rn"
1190 (+ (f-op4 6) rn rm (f-sub4 6))
1192 (set rn (mem SI rm))
1193 (if (eq (index-of rm) (index-of rn))
1195 (set rm (add rm 4)))))
1197 (dshci movl8 "Load long word from memory (register/register indirect)"
1199 "mov.l @(r0, $rm), $rn"
1200 (+ (f-op4 0) rn rm (f-sub4 14))
1201 (set rn (mem SI (add r0 rm))))
1203 (dshci movl9 "Load long word from memory (GBR-relative w/ displacement)"
1205 "mov.l @($imm8x4, gbr), r0"
1206 (+ (f-op8 #xc6) imm8x4)
1207 (set r0 (mem SI (add gbr imm8x4))))
1209 (dshci movl10 "Load long word from memory (PC-relative w/ displacement)"
1211 "mov.l @($imm8x4, pc), $rn"
1212 (+ (f-op4 13) rn imm8x4)
1213 (set rn (mem SI (add imm8x4 (and (add pc 4) (inv 3))))))
1215 (dshci movl11 "Load long word from memory (register indirect w/ displacement)"
1217 "mov.l @($imm4x4, $rm), $rn"
1218 (+ (f-op4 5) rn rm imm4x4)
1219 (set rn (mem SI (add rm imm4x4))))
1221 (dshci movw1 "Store word to memory (register indirect w/ zero displacement)"
1224 (+ (f-op4 2) rn rm (f-sub4 1))
1225 (set (mem HI rn) (subword HI rm 1)))
1227 (dshci movw2 "Store word to memory (register indirect w/ pre-decrement)"
1230 (+ (f-op4 2) rn rm (f-sub4 5))
1231 (sequence ((DI addr))
1232 (set addr (sub rn 2))
1233 (set (mem HI addr) (subword HI rm 1))
1236 (dshci movw3 "Store word to memory (register/register indirect)"
1238 "mov.w $rm, @(r0, $rn)"
1239 (+ (f-op4 0) rn rm (f-sub4 5))
1240 (set (mem HI (add r0 rn)) (subword HI rm 1)))
1242 (dshci movw4 "Store word to memory (GBR-relative w/ displacement)"
1244 "mov.w r0, @($imm8x2, gbr)"
1245 (+ (f-op8 #xc1) imm8x2)
1246 (set (mem HI (add gbr imm8x2)) (subword HI r0 1)))
1248 (dshci movw5 "Store word to memory (register indirect w/ displacement)"
1250 "mov.w r0, @($imm4x2, $rn)"
1251 (+ (f-op8 #x81) rn imm4x2)
1252 (set (mem HI (add rn imm4x2)) (subword HI r0 1)))
1254 (dshci movw6 "Load word from memory (register indirect w/ zero displacement)"
1257 (+ (f-op4 6) rn rm (f-sub4 1))
1258 (set rn (ext SI (mem HI rm))))
1260 (dshci movw7 "Load word from memory (register indirect w/ post-increment)"
1262 "mov.w @${rm}+, $rn"
1263 (+ (f-op4 6) rn rm (f-sub4 5))
1264 (sequence ((HI data))
1265 (set data (mem HI rm))
1266 (if (eq (index-of rm) (index-of rn))
1267 (set rm (ext SI data))
1268 (set rm (add rm 2)))
1269 (set rn (ext SI data))))
1271 (dshci movw8 "Load word from memory (register/register indirect)"
1273 "mov.w @(r0, $rm), $rn"
1274 (+ (f-op4 0) rn rm (f-sub4 13))
1275 (set rn (ext SI (mem HI (add r0 rm)))))
1277 (dshci movw9 "Load word from memory (GBR-relative w/ displacement)"
1279 "mov.w @($imm8x2, gbr), r0"
1280 (+ (f-op8 #xc5) imm8x2)
1281 (set r0 (ext SI (mem HI (add gbr imm8x2)))))
1283 (dshci movw10 "Load word from memory (PC-relative w/ displacement)"
1285 "mov.w @($imm8x2, pc), $rn"
1286 (+ (f-op4 9) rn imm8x2)
1287 (set rn (ext SI (mem HI (add (add pc 4) imm8x2)))))
1289 (dshci movw11 "Load word from memory (register indirect w/ displacement)"
1291 "mov.w @($imm4x2, $rm), r0"
1292 (+ (f-op8 #x85) rm imm4x2)
1293 (set r0 (ext SI (mem HI (add rm imm4x2)))))
1295 (dshci mova "Move effective address"
1297 "mova @($imm8x4, pc), r0"
1298 (+ (f-op8 #xc7) imm8x4)
1299 (set r0 (add (and (add pc 4) (inv 3)) imm8x4)))
1301 (dshci movcal "Move with cache block allocation"
1304 (+ (f-op4 0) rn (f-sub8 #xc3))
1305 (set (mem SI rn) r0))
1307 (dshci movt "Move t-bit"
1310 (+ (f-op4 0) rn (f-sub8 41))
1311 (set rn (zext SI tbit)))
1313 (dshci mull "Multiply"
1316 (+ (f-op4 0) rn rm (f-sub4 7))
1317 (set macl (mul rm rn)))
1319 (dshci mulsw "Multiply words (signed)"
1322 (+ (f-op4 2) rn rm (f-sub4 15))
1323 (set macl (mul (ext SI (subword HI rm 1)) (ext SI (subword HI rn 1)))))
1325 (dshci muluw "Multiply words (unsigned)"
1328 (+ (f-op4 2) rn rm (f-sub4 14))
1329 (set macl (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))))
1334 (+ (f-op4 6) rn rm (f-sub4 11))
1337 (dshci negc "Negate with carry"
1340 (+ (f-op4 6) rn rm (f-sub4 10))
1341 (sequence ((BI flag))
1342 (set flag (sub-cflag 0 rm tbit))
1343 (set rn (subc 0 rm tbit))
1346 (dshci nop "No operation"
1352 (dshci not "Bitwise NOT"
1355 (+ (f-op4 6) rn64 rm64 (f-sub4 7))
1356 (set rn64 (inv rm64)))
1358 (dshci ocbi "Invalidate operand cache block"
1361 (+ (f-op4 0) rn (f-sub8 147))
1364 (dshci ocbp "Purge operand cache block"
1367 (+ (f-op4 0) rn (f-sub8 163))
1370 (dshci ocbwb "Write back operand cache block"
1373 (+ (f-op4 0) rn (f-sub8 179))
1376 (dshci or "Bitwise OR"
1379 (+ (f-op4 2) rn64 rm64 (f-sub4 11))
1380 (set rn64 (or rm64 rn64)))
1382 (dshci ori "Bitwise OR immediate"
1385 (+ (f-op8 #xcb) uimm8)
1386 (set r0 (or r0 (zext DI uimm8))))
1388 (dshci orb "Bitwise OR immediate"
1390 "or.b #$imm8, @(r0, gbr)"
1391 (+ (f-op8 #xcf) imm8)
1392 (sequence ((DI addr) (UQI data))
1393 (set addr (add r0 gbr))
1394 (set data (or (mem UQI addr) imm8))
1395 (set (mem UQI addr) data)))
1397 (dshci pref "Prefetch data"
1400 (+ (f-op4 0) rn (f-sub8 131))
1403 (dshci rotcl "Rotate with carry left"
1406 (+ (f-op4 4) rn (f-sub8 36))
1407 (sequence ((BI temp))
1408 (set temp (srl rn 31))
1409 (set rn (or (sll rn 1) tbit))
1410 (set tbit (if BI temp 1 0))))
1412 (dshci rotcr "Rotate with carry right"
1415 (+ (f-op4 4) rn (f-sub8 37))
1416 (sequence ((BI lsbit) (SI temp))
1417 (set lsbit (if BI (eq (and rn 1) 0) 0 1))
1419 (set rn (or (srl rn 1) (sll temp 31)))
1420 (set tbit (if BI lsbit 1 0))))
1422 (dshci rotl "Rotate left"
1425 (+ (f-op4 4) rn (f-sub8 4))
1426 (sequence ((BI temp))
1427 (set temp (srl rn 31))
1428 (set rn (or (sll rn 1) temp))
1429 (set tbit (if BI temp 1 0))))
1431 (dshci rotr "Rotate right"
1434 (+ (f-op4 4) rn (f-sub8 5))
1435 (sequence ((BI lsbit) (SI temp))
1436 (set lsbit (if BI (eq (and rn 1) 0) 0 1))
1438 (set rn (or (srl rn 1) (sll temp 31)))
1439 (set tbit (if BI lsbit 1 0))))
1441 (dshci rts "Return from subroutine"
1445 (delay 1 (set pc pr)))
1447 (dshci sets "Set S-bit"
1453 (dshci sett "Set T-bit"
1459 (dshci shad "Shift arithmetic dynamic"
1462 (+ (f-op4 4) rn rm (f-sub4 12))
1463 (sequence ((QI shamt))
1464 (set shamt (and QI rm 31))
1466 (set rn (sll rn shamt))
1468 (set rn (sra rn (sub 32 shamt)))
1473 (dshci shal "Shift left arithmetic one bit"
1476 (+ (f-op4 4) rn (f-sub8 32))
1480 (set tbit (if BI t 1 0))))
1482 (dshci shar "Shift right arithmetic one bit"
1485 (+ (f-op4 4) rn (f-sub8 33))
1489 (set tbit (if BI t 1 0))))
1491 (dshci shld "Shift logical dynamic"
1494 (+ (f-op4 4) rn rm (f-sub4 13))
1495 (sequence ((QI shamt))
1496 (set shamt (and QI rm 31))
1498 (set rn (sll rn shamt))
1500 (set rn (srl rn (sub 32 shamt)))
1503 (dshci shll "Shift left logical one bit"
1506 (+ (f-op4 4) rn (f-sub8 0))
1510 (set tbit (if BI t 1 0))))
1512 (dshci shll2 "Shift left logical two bits"
1515 (+ (f-op4 4) rn (f-sub8 8))
1516 (set rn (sll rn 2)))
1518 (dshci shll8 "Shift left logical eight bits"
1521 (+ (f-op4 4) rn (f-sub8 24))
1522 (set rn (sll rn 8)))
1524 (dshci shll16 "Shift left logical sixteen bits"
1527 (+ (f-op4 4) rn (f-sub8 40))
1528 (set rn (sll rn 16)))
1530 (dshci shlr "Shift right logical one bit"
1533 (+ (f-op4 4) rn (f-sub8 1))
1537 (set tbit (if BI t 1 0))))
1539 (dshci shlr2 "Shift right logical two bits"
1542 (+ (f-op4 4) rn (f-sub8 9))
1543 (set rn (srl rn 2)))
1545 (dshci shlr8 "Shift right logical eight bits"
1548 (+ (f-op4 4) rn (f-sub8 25))
1549 (set rn (srl rn 8)))
1551 (dshci shlr16 "Shift right logical sixteen bits"
1554 (+ (f-op4 4) rn (f-sub8 41))
1555 (set rn (srl rn 16)))
1557 (dshci stc-gbr "Store control register (GBR)"
1560 (+ (f-op4 0) rn (f-sub8 18))
1563 (dshci stcl-gbr "Store control register (GBR)"
1566 (+ (f-op4 4) rn (f-sub8 19))
1567 (sequence ((DI addr))
1568 (set addr (sub rn 4))
1569 (set (mem SI addr) gbr)
1572 (dshci sts-fpscr "Store status register (FPSCR)"
1575 (+ (f-op4 0) rn (f-sub8 106))
1578 (dshci stsl-fpscr "Store status register (FPSCR)"
1580 "sts.l fpscr, @-$rn"
1581 (+ (f-op4 4) rn (f-sub8 98))
1582 (sequence ((DI addr))
1583 (set addr (sub rn 4))
1584 (set (mem SI addr) fpscr)
1587 (dshci sts-fpul "Store status register (FPUL)"
1590 (+ (f-op4 0) rn (f-sub8 90))
1591 (set rn (subword SI fpul 0)))
1593 (dshci stsl-fpul "Store status register (FPUL)"
1596 (+ (f-op4 4) rn (f-sub8 82))
1597 (sequence ((DI addr))
1598 (set addr (sub rn 4))
1599 (set (mem SF addr) fpul)
1602 (dshci sts-mach "Store status register (MACH)"
1605 (+ (f-op4 0) rn (f-sub8 10))
1608 (dshci stsl-mach "Store status register (MACH)"
1611 (+ (f-op4 4) rn (f-sub8 2))
1612 (sequence ((DI addr))
1613 (set addr (sub rn 4))
1614 (set (mem SI addr) mach)
1617 (dshci sts-macl "Store status register (MACL)"
1620 (+ (f-op4 0) rn (f-sub8 26))
1623 (dshci stsl-macl "Store status register (MACL)"
1626 (+ (f-op4 4) rn (f-sub8 18))
1627 (sequence ((DI addr))
1628 (set addr (sub rn 4))
1629 (set (mem SI addr) macl)
1632 (dshci sts-pr "Store status register (PR)"
1635 (+ (f-op4 0) rn (f-sub8 42))
1638 (dshci stsl-pr "Store status register (PR)"
1641 (+ (f-op4 4) rn (f-sub8 34))
1642 (sequence ((DI addr))
1643 (set addr (sub rn 4))
1644 (set (mem SI addr) pr)
1647 (dshci sub "Subtract"
1650 (+ (f-op4 3) rn rm (f-sub4 8))
1651 (set rn (sub rn rm)))
1653 (dshci subc "Subtract and detect carry"
1656 (+ (f-op4 3) rn rm (f-sub4 10))
1657 (sequence ((BI flag))
1658 (set flag (sub-cflag rn rm tbit))
1659 (set rn (subc rn rm tbit))
1662 (dshci subv "Subtract and detect overflow"
1665 (+ (f-op4 3) rn rm (f-sub4 11))
1667 (set t (sub-oflag rn rm 0))
1668 (set rn (sub rn rm))
1669 (set tbit (if BI t 1 0))))
1671 (dshci swapb "Swap bytes"
1674 (+ (f-op4 6) rn rm (f-sub4 8))
1675 (sequence ((UHI top-half) (UQI byte1) (UQI byte0))
1676 (set top-half (subword HI rm 0))
1677 (set byte1 (subword QI rm 2))
1678 (set byte0 (subword QI rm 3))
1679 (set rn (or SI (sll SI top-half 16) (or SI (sll SI byte0 8) byte1)))))
1681 (dshci swapw "Swap words"
1684 (+ (f-op4 6) rn rm (f-sub4 9))
1685 (set rn (or (srl rm 16) (sll rm 16))))
1687 (dshci tasb "Test and set byte"
1690 (+ (f-op4 4) rn (f-sub8 27))
1691 (sequence ((UQI byte))
1692 (set byte (mem UQI rn))
1693 (set tbit (if BI (eq byte 0) 1 0))
1694 (set byte (or byte 128))
1695 (set (mem UQI rn) byte)))
1700 (+ (f-op8 #xc3) uimm8)
1701 (c-call "sh64_compact_trapa" uimm8 pc))
1703 (dshci tst "Test and set t-bit"
1706 (+ (f-op4 2) rn rm (f-sub4 8))
1707 (set tbit (if BI (eq (and rm rn) 0) 1 0)))
1709 (dshci tsti "Test and set t-bit immediate"
1712 (+ (f-op8 #xc8) uimm8)
1713 (set tbit (if BI (eq (and r0 (zext SI uimm8)) 0) 1 0)))
1715 (dshci tstb "Test and set t-bit immedate with memory byte"
1717 "tst.b #$imm8, @(r0, gbr)"
1718 (+ (f-op8 #xcc) imm8)
1719 (sequence ((DI addr))
1720 (set addr (add r0 gbr))
1721 (set tbit (if BI (eq (and (mem UQI addr) imm8) 0) 1 0))))
1723 (dshci xor "Exclusive OR"
1726 (+ (f-op4 2) rn64 rm64 (f-sub4 10))
1727 (set rn64 (xor rn64 rm64)))
1729 (dshci xori "Exclusive OR immediate"
1732 (+ (f-op8 #xca) uimm8)
1733 (set (reg h-gr 0) (xor (reg h-gr 0) (zext DI uimm8))))
1735 (dshci xorb "Exclusive OR immediate with memory byte"
1737 "xor.b #$imm8, @(r0, gbr)"
1738 (+ (f-op8 #xce) imm8)
1739 (sequence ((DI addr) (UQI data))
1740 (set addr (add r0 gbr))
1741 (set data (xor (mem UQI addr) imm8))
1742 (set (mem UQI addr) data)))
1744 (dshci xtrct "Extract"
1747 (+ (f-op4 2) rn rm (f-sub4 13))
1748 (set rn (or (sll rm 16) (srl rn 16))))