1 ; Hitachi SHcompact instruction set description. -*- Scheme -*- 2 ; 3 ; Copyright 2000, 2007, 2009 Free Software Foundation, Inc. 4 ; 5 ; Contributed by Red Hat Inc; developed under contract from Hitachi 6 ; Semiconductor (America) Inc. 7 ; 8 ; This file is part of the GNU Binutils. 9 ; 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. 14 ; 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. 19 ; 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, 23 ; MA 02110-1301, USA. 24 26 ; dshcf -- define-normal-sh-compact-field 27 28 (define-pmacro (dshcf xname xcomment ignored xstart xlength) 29 (dnf xname xcomment ((ISA compact)) xstart xlength)) 30 31 ; dshcop -- define-normal-sh-compact-operand 32 33 (define-pmacro (dshcop xname xcomment ignored xhardware xfield) 34 (dnop xname xcomment ((ISA compact)) xhardware xfield)) 35 36 38 ; SHcompact-specific attributes. 39 40 (define-attr 41 (for insn) 42 (type boolean) 43 (name ILLSLOT) 44 (comment "instruction may not appear in a delay slot") 45 ) 46 47 (define-attr 48 (for insn) 49 (type boolean) 50 (name FP-INSN) 51 (comment "floating point instruction") 52 ) 53 54 (define-keyword 55 (name frc-names) 56 (attrs (ISA compact)) 57 (print-name h-frc) 58 (values (fr0 0) (fr1 1) (fr2 2) (fr3 3) (fr4 4) (fr5 5) 59 (fr6 6) (fr7 7) (fr8 8) (fr9 9) (fr10 10) (fr11 11) 60 (fr12 12) (fr13 13) (fr14 14) (fr15 15)) 61 ) 62 63 (define-keyword 64 (name drc-names) 65 (attrs (ISA compact)) 66 (print-name h-drc) 67 (values (dr0 0) (dr2 2) (dr4 4) (dr6 6) (dr8 8) (dr10 10) (dr12 12) (dr14 14)) 68 ) 69 70 (define-keyword 71 (name xf-names) 72 (attrs (ISA compact)) 73 (print-name h-xf) 74 (values (xf0 0) (xf1 1) (xf2 2) (xf3 3) (xf4 4) (xf5 5) 75 (xf6 6) (xf7 7) (xf8 8) (xf9 9) (xf10 10) (xf11 11) 76 (xf12 12) (xf13 13) (xf14 14) (xf15 15)) 77 ) 78 79 ; Hardware specific to the SHcompact mode. 80 81 (define-pmacro (front) (mul 16 frbit)) 82 (define-pmacro (back) (mul 16 (not frbit))) 83 84 (define-hardware 85 (name h-frc) 86 (comment "Single precision floating point registers") 87 (attrs VIRTUAL (ISA compact)) 88 (indices extern-keyword frc-names) 89 (type register SF (16)) 90 (get (index) (reg h-fr (add (front) index))) 91 (set (index newval) (set (reg h-fr (add (front) index)) newval)) 92 ) 93 94 (define-hardware 95 (name h-drc) 96 (comment "Double precision floating point registers") 97 (attrs VIRTUAL (ISA compact)) 98 (indices extern-keyword drc-names) 99 (type register DF (8)) 100 (get (index) (reg h-dr (add (front) index))) 101 (set (index newval) (set (reg h-dr (add (front) index)) newval)) 102 ) 103 104 (define-hardware 105 (name h-xf) 106 (comment "Extended single precision floating point registers") 107 (attrs VIRTUAL (ISA compact)) 108 (indices extern-keyword xf-names) 109 (type register SF (16)) 110 (get (index) (reg h-fr (add (back) index))) 111 (set (index newval) (set (reg h-fr (add (back) index)) newval)) 112 ) 113 114 (define-hardware 115 (name h-xd) 116 (comment "Extended double precision floating point registers") 117 (attrs VIRTUAL (ISA compact)) 118 (indices extern-keyword frc-names) 119 (type register DF (8)) 120 (get (index) (reg h-dr (add (back) index))) 121 (set (index newval) (set (reg h-dr (add (back) index)) newval)) 122 ) 123 124 (define-hardware 125 (name h-fvc) 126 (comment "Single precision floating point vectors") 127 (attrs VIRTUAL (ISA compact)) 128 (indices keyword "" ((fv0 0) (fv4 4) (fv8 8) (fv12 12))) 129 (type register SF (4)) 130 (get (index) (reg h-fr (add (front) index))) 131 (set (index newval) (set (reg h-fr (add (front) index)) newval)) 132 ) 133 134 (define-hardware 135 (name h-fpccr) 136 (comment "SHcompact floating point status/control register") 137 (attrs VIRTUAL (ISA compact)) 138 (type register SI) 139 (get () (or (or (or (raw-reg h-fpscr) (sll SI prbit 19)) (sll SI szbit 20)) (sll SI frbit 21))) 140 (set (newvalue) (sequence () 141 (set (reg h-fpscr) newvalue) 142 (set prbit (and (srl newvalue 19) 1)) 143 (set szbit (and (srl newvalue 20) 1)) 144 (set frbit (and (srl newvalue 21) 1)))) 145 ) 146 147 (define-hardware 148 (name h-gbr) 149 (comment "Global base register") 150 (attrs VIRTUAL (ISA compact)) 151 (type register SI) 152 (get () (subword SI (raw-reg h-gr 16) 1)) 153 (set (newval) (set (raw-reg h-gr 16) (ext DI newval))) 154 ) 155 156 (define-hardware 157 (name h-pr) 158 (comment "Procedure link register") 159 (attrs VIRTUAL (ISA compact)) 160 (type register SI) 161 (get () (subword SI (raw-reg h-gr 18) 1)) 162 (set (newval) (set (raw-reg h-gr 18) (ext DI newval))) 163 ) 164 165 (define-hardware 166 (name h-macl) 167 (comment "Multiple-accumulate low register") 168 (attrs VIRTUAL (ISA compact)) 169 (type register SI) 170 (get () (subword SI (raw-reg h-gr 17) 1)) 171 (set (newval) (set (raw-reg h-gr 17) (-join-si (subword SI (raw-reg h-gr 17) 0) newval))) 172 ) 173 174 (define-hardware 175 (name h-mach) 176 (comment "Multiply-accumulate high register") 177 (attrs VIRTUAL (ISA compact)) 178 (type register SI) 179 (get () (subword SI (raw-reg h-gr 17) 0)) 180 (set (newval) (set (raw-reg h-gr 17) (-join-si newval (subword SI (raw-reg h-gr 17) 1)))) 181 ) 182 183 (define-hardware 184 (name h-tbit) 185 (comment "Condition code flag") 186 (attrs VIRTUAL (ISA compact)) 187 (type register BI) 188 (get () (and BI (raw-reg h-gr 19) 1)) 189 (set (newval) (set (raw-reg h-gr 19) (or (and (raw-reg h-gr 19) (inv DI 1)) (zext DI newval)))) 190 ) 191 192 194 (dshcf f-op4 "Opcode (4 bits)" () 15 4) 195 (dshcf f-op8 "Opcode (8 bits)" () 15 8) 196 (dshcf f-op16 "Opcode (16 bits)" () 15 16) 197 198 (dshcf f-sub4 "Sub opcode (4 bits)" () 3 4) 199 (dshcf f-sub8 "Sub opcode (8 bits)" () 7 8) 200 (dshcf f-sub10 "Sub opcode (10 bits)" () 9 10) 201 202 (dshcf f-rn "Register selector n" () 11 4) 203 (dshcf f-rm "Register selector m" () 7 4) 204 205 (dshcf f-8-1 "One bit at bit 8" () 8 1) 206 207 (df f-disp8 "Displacement (8 bits)" ((ISA compact) PCREL-ADDR) 7 8 INT 208 ((value pc) (sra SI value 1)) 209 ((value pc) (add SI (sll SI value 1) (add pc 4)))) 210 211 (df f-disp12 "Displacement (12 bits)" ((ISA compact) PCREL-ADDR) 11 12 INT 212 ((value pc) (sra SI value 1)) 213 ((value pc) (add SI (sll SI value 1) (add pc 4)))) 214 215 (dshcf f-imm8 "Immediate (8 bits)" () 7 8) 216 (dshcf f-imm4 "Immediate (4 bits)" () 3 4) 217 218 (df f-imm4x2 "Immediate (4 bits)" ((ISA compact)) 3 4 UINT 219 ((value pc) (srl SI value 1)) 220 ((value pc) (sll SI value 1))) 221 222 (df f-imm4x4 "Immediate (4 bits)" ((ISA compact)) 3 4 UINT 223 ((value pc) (srl SI value 2)) 224 ((value pc) (sll SI value 2))) 225 226 (df f-imm8x2 "Immediate (8 bits)" ((ISA compact)) 7 8 UINT 227 ((value pc) (sra SI value 1)) 228 ((value pc) (sll SI value 1))) 229 230 (df f-imm8x4 "Immediate (8 bits)" ((ISA compact)) 7 8 UINT 231 ((value pc) (sra SI value 2)) 232 ((value pc) (sll SI value 2))) 233 234 (df f-dn "Double selector n" ((ISA compact)) 11 3 UINT 235 ((value pc) (srl SI value 1)) 236 ((value pc) (sll SI value 1))) 237 238 (df f-dm "Double selector m" ((ISA compact)) 7 3 UINT 239 ((value pc) (srl SI value 1)) 240 ((value pc) (sll SI value 1))) 241 242 (df f-vn "Vector selector n" ((ISA compact)) 11 2 UINT 243 ((value pc) (srl SI value 2)) 244 ((value pc) (sll SI value 2))) 245 246 (df f-vm "Vector selector m" ((ISA compact)) 9 2 UINT 247 ((value pc) (srl SI value 2)) 248 ((value pc) (sll SI value 2))) 249 250 (df f-xn "Extended selector n" ((ISA compact)) 11 3 UINT 251 ((value pc) (srl SI value 1)) 252 ((value pc) (add SI (sll SI value 1) 1))) 253 254 (df f-xm "Extended selector m" ((ISA compact)) 7 3 UINT 255 ((value pc) (srl SI value 1)) 256 ((value pc) (add SI (sll SI value 1) 1))) 257 258 260 ; Operands. 261 262 (dshcop rm "Left general purpose register" () h-grc f-rm) 263 (dshcop rn "Right general purpose register" () h-grc f-rn) 264 (dshcop r0 "Register 0" () h-grc 0) 265 266 (dshcop frn "Single precision register" () h-frc f-rn) 267 (dshcop frm "Single precision register" () h-frc f-rm) 268 269 (dshcop fvn "Left floating point vector" () h-fvc f-vn) 270 (dshcop fvm "Right floating point vector" () h-fvc f-vm) 271 272 (dshcop drn "Left double precision register" () h-drc f-dn) 273 (dshcop drm "Right double precision register" () h-drc f-dm) 274 275 (dshcop imm4 "Immediate value (4 bits)" () h-sint f-imm4) 276 (dshcop imm8 "Immediate value (8 bits)" () h-sint f-imm8) 277 (dshcop uimm8 "Immediate value (8 bits unsigned)" () h-uint f-imm8) 278 279 (dshcop imm4x2 "Immediate value (4 bits, 2x scale)" () h-uint f-imm4x2) 280 (dshcop imm4x4 "Immediate value (4 bits, 4x scale)" () h-uint f-imm4x4) 281 (dshcop imm8x2 "Immediate value (8 bits, 2x scale)" () h-uint f-imm8x2) 282 (dshcop imm8x4 "Immediate value (8 bits, 4x scale)" () h-uint f-imm8x4) 283 284 (dshcop disp8 "Displacement (8 bits)" () h-iaddr f-disp8) 285 (dshcop disp12 "Displacement (12 bits)" () h-iaddr f-disp12) 286 287 (dshcop rm64 "Register m (64 bits)" () h-gr f-rm) 288 (dshcop rn64 "Register n (64 bits)" () h-gr f-rn) 289 290 (dshcop gbr "Global base register" () h-gbr f-nil) 291 (dshcop pr "Procedure link register" () h-pr f-nil) 292 293 (dshcop fpscr "Floating point status/control register" () h-fpccr f-nil) 294 295 (dshcop tbit "Condition code flag" () h-tbit f-nil) 296 (dshcop sbit "Multiply-accumulate saturation flag" () h-sbit f-nil) 297 (dshcop mbit "Divide-step M flag" () h-mbit f-nil) 298 (dshcop qbit "Divide-step Q flag" () h-qbit f-nil) 299 (dshcop fpul "Floating point ???" () h-fr 32) 300 301 (dshcop frbit "Floating point register bank bit" () h-frbit f-nil) 302 (dshcop szbit "Floating point transfer size bit" () h-szbit f-nil) 303 (dshcop prbit "Floating point precision bit" () h-prbit f-nil) 304 305 (dshcop macl "Multiply-accumulate low register" () h-macl f-nil) 306 (dshcop mach "Multiply-accumulate high register" () h-mach f-nil) 307 308 309 (define-operand (name fsdm) (comment "bar") 310 (attrs (ISA compact)) (type h-frc) (index f-rm) (handlers (parse "fsd"))) 311 312 (define-operand (name fsdn) (comment "bar") 313 (attrs (ISA compact)) (type h-frc) (index f-rn)) 314 316 317 ; Cover macro to dni to indicate these are all SHcompact instructions. 318 ; dshmi: define-normal-sh-compact-insn 319 320 (define-pmacro (dshci xname xcomment xattrs xsyntax xformat xsemantics) 321 (define-insn 322 (name (.sym xname -compact)) 323 (comment xcomment) 324 (.splice attrs (.unsplice xattrs) (ISA compact)) 325 (syntax xsyntax) 326 (format xformat) 327 (semantics xsemantics))) 328 329 (define-pmacro (dr operand) (reg h-dr (index-of operand))) 330 (define-pmacro (xd x) (reg h-xd (and (index-of x) (inv QI 1)))) 331 333 (dshci add "Add" 334 () 335 "add $rm, $rn" 336 (+ (f-op4 3) rn rm (f-sub4 12)) 337 (set rn (add rn rm))) 338 339 (dshci addi "Add immediate" 340 () 341 "add #$imm8, $rn" 342 (+ (f-op4 7) rn imm8) 343 (set rn (add rn (ext SI (and QI imm8 255))))) 344 345 (dshci addc "Add with carry" 346 () 347 "addc $rm, $rn" 348 (+ (f-op4 3) rn rm (f-sub4 14)) 349 (sequence ((BI flag)) 350 (set flag (add-cflag rn rm tbit)) 351 (set rn (addc rn rm tbit)) 352 (set tbit flag))) 353 354 (dshci addv "Add with overflow" 355 () 356 "addv $rm, $rn" 357 (+ (f-op4 3) rn rm (f-sub4 15)) 358 (sequence ((BI t)) 359 (set t (add-oflag rn rm 0)) 360 (set rn (add rn rm)) 361 (set tbit t))) 362 363 (dshci and "Bitwise AND" 364 () 365 "and $rm64, $rn64" 366 (+ (f-op4 2) rn64 rm64 (f-sub4 9)) 367 (set rn64 (and rm64 rn64))) 368 369 (dshci andi "Bitwise AND immediate" 370 () 371 "and #$uimm8, r0" 372 (+ (f-op8 #xc9) uimm8) 373 (set r0 (and r0 (zext DI uimm8)))) 374 375 (dshci andb "Bitwise AND memory byte" 376 () 377 "and.b #$imm8, @(r0, gbr)" 378 (+ (f-op8 #xcd) imm8) 379 (sequence ((DI addr) (UQI data)) 380 (set addr (add r0 gbr)) 381 (set data (and (mem UQI addr) imm8)) 382 (set (mem UQI addr) data))) 383 384 (dshci bf "Conditional branch" 385 () 386 "bf $disp8" 387 (+ (f-op8 #x8b) disp8) 388 (if (not tbit) 389 (set pc disp8))) 390 391 (dshci bfs "Conditional branch with delay slot" 392 () 393 "bf/s $disp8" 394 (+ (f-op8 #x8f) disp8) 395 (if (not tbit) 396 (delay 1 (set pc disp8)))) 397 398 (dshci bra "Branch" 399 () 400 "bra $disp12" 401 (+ (f-op4 10) disp12) 402 (delay 1 (set pc disp12))) 403 404 (dshci braf "Branch far" 405 () 406 "braf $rn" 407 (+ (f-op4 0) rn (f-sub8 35)) 408 (delay 1 (set pc (add (ext DI rn) (add pc 4))))) 409 410 (dshci brk "Breakpoint" 411 () 412 "brk" 413 (+ (f-op16 59)) 414 (c-call "sh64_break" pc)) 415 416 (dshci bsr "Branch to subroutine" 417 () 418 "bsr $disp12" 419 (+ (f-op4 11) disp12) 420 (delay 1 (sequence () 421 (set pr (add pc 4)) 422 (set pc disp12)))) 423 424 (dshci bsrf "Branch to far subroutine" 425 () 426 "bsrf $rn" 427 (+ (f-op4 0) rn (f-sub8 3)) 428 (delay 1 (sequence () 429 (set pr (add pc 4)) 430 (set pc (add (ext DI rn) (add pc 4)))))) 431 432 (dshci bt "Conditional branch" 433 () 434 "bt $disp8" 435 (+ (f-op8 #x89) disp8) 436 (if tbit 437 (set pc disp8))) 438 439 (dshci bts "Conditional branch with delay slot" 440 () 441 "bt/s $disp8" 442 (+ (f-op8 #x8d) disp8) 443 (if tbit 444 (delay 1 (set pc disp8)))) 445 446 (dshci clrmac "Clear MACL and MACH" 447 () 448 "clrmac" 449 (+ (f-op16 40)) 450 (sequence () 451 (set macl 0) 452 (set mach 0))) 453 454 (dshci clrs "Clear S-bit" 455 () 456 "clrs" 457 (+ (f-op16 72)) 458 (set sbit 0)) 459 460 (dshci clrt "Clear T-bit" 461 () 462 "clrt" 463 (+ (f-op16 8)) 464 (set tbit 0)) 465 466 (dshci cmpeq "Compare if equal" 467 () 468 "cmp/eq $rm, $rn" 469 (+ (f-op4 3) rn rm (f-sub4 0)) 470 (set tbit (eq rm rn))) 471 472 (dshci cmpeqi "Compare if equal (immediate)" 473 () 474 "cmp/eq #$imm8, r0" 475 (+ (f-op8 #x88) imm8) 476 (set tbit (eq r0 (ext SI (and QI imm8 255))))) 477 478 (dshci cmpge "Compare if greater than or equal" 479 () 480 "cmp/ge $rm, $rn" 481 (+ (f-op4 3) rn rm (f-sub4 3)) 482 (set tbit (ge rn rm))) 483 484 (dshci cmpgt "Compare if greater than" 485 () 486 "cmp/gt $rm, $rn" 487 (+ (f-op4 3) rn rm (f-sub4 7)) 488 (set tbit (gt rn rm))) 489 490 (dshci cmphi "Compare if greater than (unsigned)" 491 () 492 "cmp/hi $rm, $rn" 493 (+ (f-op4 3) rn rm (f-sub4 6)) 494 (set tbit (gtu rn rm))) 495 496 (dshci cmphs "Compare if greater than or equal (unsigned)" 497 () 498 "cmp/hs $rm, $rn" 499 (+ (f-op4 3) rn rm (f-sub4 2)) 500 (set tbit (geu rn rm))) 501 502 (dshci cmppl "Compare if greater than zero" 503 () 504 "cmp/pl $rn" 505 (+ (f-op4 4) rn (f-sub8 21)) 506 (set tbit (gt rn 0))) 507 508 (dshci cmppz "Compare if greater than or equal zero" 509 () 510 "cmp/pz $rn" 511 (+ (f-op4 4) rn (f-sub8 17)) 512 (set tbit (ge rn 0))) 513 514 (dshci cmpstr "Compare bytes" 515 () 516 "cmp/str $rm, $rn" 517 (+ (f-op4 2) rn rm (f-sub4 12)) 518 (sequence ((BI t) (SI temp)) 519 (set temp (xor rm rn)) 520 (set t (eq (and temp #xff000000) 0)) 521 (set t (or (eq (and temp #xff0000) 0) t)) 522 (set t (or (eq (and temp #xff00) 0) t)) 523 (set t (or (eq (and temp #xff) 0) t)) 524 (set tbit (if BI (gtu t 0) 1 0)))) 525 526 (dshci div0s "Initialise divide-step state for signed division" 527 () 528 "div0s $rm, $rn" 529 (+ (f-op4 2) rn rm (f-sub4 7)) 530 (sequence () 531 (set qbit (srl rn 31)) 532 (set mbit (srl rm 31)) 533 (set tbit (if BI (eq (srl rm 31) (srl rn 31)) 0 1)))) 534 535 (dshci div0u "Initialise divide-step state for unsigned division" 536 () 537 "div0u" 538 (+ (f-op16 25)) 539 (sequence () 540 (set tbit 0) 541 (set qbit 0) 542 (set mbit 0))) 543 544 (dshci div1 "Divide step" 545 () 546 "div1 $rm, $rn" 547 (+ (f-op4 3) rn rm (f-sub4 4)) 548 (sequence ((BI oldq) (SI tmp0) (UQI tmp1)) 549 (set oldq qbit) 550 (set qbit (srl rn 31)) 551 (set rn (or (sll rn 1) (zext SI tbit))) 552 (if (not oldq) 553 (if (not mbit) 554 (sequence () 555 (set tmp0 rn) 556 (set rn (sub rn rm)) 557 (set tmp1 (gtu rn tmp0)) 558 (if (not qbit) 559 (set qbit (if BI tmp1 1 0)) 560 (set qbit (if BI (eq tmp1 0) 1 0)))) 561 (sequence () 562 (set tmp0 rn) 563 (set rn (add rn rm)) 564 (set tmp1 (ltu rn tmp0)) 565 (if (not qbit) 566 (set qbit (if BI (eq tmp1 0) 1 0)) 567 (set qbit (if BI tmp1 1 0))))) 568 (if (not mbit) 569 (sequence () 570 (set tmp0 rn) 571 (set rn (add rm rn)) 572 (set tmp1 (ltu rn tmp0)) 573 (if (not qbit) 574 (set qbit (if BI tmp1 1 0)) 575 (set qbit (if BI (eq tmp1 0) 1 0)))) 576 (sequence () 577 (set tmp0 rn) 578 (set rn (sub rn rm)) 579 (set tmp1 (gtu rn tmp0)) 580 (if (not qbit) 581 (set qbit (if BI (eq tmp1 0) 1 0)) 582 (set qbit (if BI tmp1 1 0)))))) 583 (set tbit (if BI (eq qbit mbit) 1 0)))) 584 585 (dshci dmulsl "Multiply long (signed)" 586 () 587 "dmuls.l $rm, $rn" 588 (+ (f-op4 3) rn rm (f-sub4 13)) 589 (sequence ((DI result)) 590 (set result (mul (ext DI rm) (ext DI rn))) 591 (set mach (subword SI result 0)) 592 (set macl (subword SI result 1)))) 593 594 (dshci dmulul "Multiply long (unsigned)" 595 () 596 "dmulu.l $rm, $rn" 597 (+ (f-op4 3) rn rm (f-sub4 5)) 598 (sequence ((DI result)) 599 (set result (mul (zext DI rm) (zext DI rn))) 600 (set mach (subword SI result 0)) 601 (set macl (subword SI result 1)))) 602 603 (dshci dt "Decrement and set" 604 () 605 "dt $rn" 606 (+ (f-op4 4) rn (f-sub8 16)) 607 (sequence () 608 (set rn (sub rn 1)) 609 (set tbit (eq rn 0)))) 610 611 (dshci extsb "Sign extend byte" 612 () 613 "exts.b $rm, $rn" 614 (+ (f-op4 6) rn rm (f-sub4 14)) 615 (set rn (ext SI (subword QI rm 3)))) 616 617 (dshci extsw "Sign extend word" 618 () 619 "exts.w $rm, $rn" 620 (+ (f-op4 6) rn rm (f-sub4 15)) 621 (set rn (ext SI (subword HI rm 1)))) 622 623 (dshci extub "Zero extend byte" 624 () 625 "extu.b $rm, $rn" 626 (+ (f-op4 6) rn rm (f-sub4 12)) 627 (set rn (zext SI (subword QI rm 3)))) 628 629 (dshci extuw "Zero etxend word" 630 () 631 "extu.w $rm, $rn" 632 (+ (f-op4 6) rn rm (f-sub4 13)) 633 (set rn (zext SI (subword HI rm 1)))) 634 635 (dshci fabs "Floating point absolute" 636 (FP-INSN) 637 "fabs $fsdn" 638 (+ (f-op4 15) fsdn (f-sub8 #x5d)) 639 (if prbit 640 (set (dr fsdn) (c-call DF "sh64_fabsd" (dr fsdn))) 641 (set fsdn (c-call SF "sh64_fabss" fsdn)))) 642 643 (dshci fadd "Floating point add" 644 (FP-INSN) 645 "fadd $fsdm, $fsdn" 646 (+ (f-op4 15) fsdn fsdm (f-sub4 0)) 647 (if prbit 648 (set (dr fsdn) (c-call DF "sh64_faddd" (dr fsdm) (dr fsdn))) 649 (set fsdn (c-call SF "sh64_fadds" fsdm fsdn)))) 650 651 (dshci fcmpeq "Floating point compare equal" 652 (FP-INSN) 653 "fcmp/eq $fsdm, $fsdn" 654 (+ (f-op4 15) fsdn fsdm (f-sub4 4)) 655 (if prbit 656 (set tbit (c-call BI "sh64_fcmpeqd" (dr fsdm) (dr fsdn))) 657 (set tbit (c-call BI "sh64_fcmpeqs" fsdm fsdn)))) 658 659 (dshci fcmpgt "Floating point compare greater than" 660 (FP-INSN) 661 "fcmp/gt $fsdm, $fsdn" 662 (+ (f-op4 15) fsdn fsdm (f-sub4 5)) 663 (if prbit 664 (set tbit (c-call BI "sh64_fcmpgtd" (dr fsdn) (dr fsdm))) 665 (set tbit (c-call BI "sh64_fcmpgts" fsdn fsdm)))) 666 667 (dshci fcnvds "Floating point convert (double to single)" 668 (FP-INSN) 669 "fcnvds $drn, fpul" 670 (+ (f-op4 15) drn (f-8-1 10) (f-sub8 #xbd)) 671 (set fpul (c-call SF "sh64_fcnvds" drn))) 672 673 (dshci fcnvsd "Floating point convert (single to double)" 674 (FP-INSN) 675 "fcnvsd fpul, $drn" 676 (+ (f-op4 15) drn (f-8-1 0) (f-sub8 #xad)) 677 (set drn (c-call DF "sh64_fcnvsd" fpul))) 678 679 (dshci fdiv "Floating point divide" 680 (FP-INSN) 681 "fdiv $fsdm, $fsdn" 682 (+ (f-op4 15) fsdn fsdm (f-sub4 3)) 683 (if prbit 684 (set (dr fsdn) (c-call DF "sh64_fdivd" (dr fsdn) (dr fsdm))) 685 (set fsdn (c-call SF "sh64_fdivs" fsdn fsdm)))) 686 687 (dshci fipr "Floating point inner product" 688 (FP-INSN) 689 "fipr $fvm, $fvn" 690 (+ (f-op4 15) fvn fvm (f-sub8 #xed)) 691 (sequence ((QI m) (QI n) (SF res)) 692 (set m (index-of fvm)) 693 (set n (index-of fvn)) 694 (set res (c-call SF "sh64_fmuls" fvm fvn)) 695 (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))))) 696 (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))))) 697 (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))))) 698 (set (reg h-frc (add n 3)) res))) 699 700 (dshci flds "Floating point load status register" 701 (FP-INSN) 702 "flds $frn" 703 (+ (f-op4 15) frn (f-sub8 #x1d)) 704 (set fpul frn)) 705 706 (dshci fldi0 "Floating point load immediate 0.0" 707 (FP-INSN) 708 "fldi0 $frn" 709 (+ (f-op4 15) frn (f-sub8 #x8d)) 710 (set frn (c-call SF "sh64_fldi0"))) 711 712 (dshci fldi1 "Floating point load immediate 1.0" 713 (FP-INSN) 714 "fldi1 $frn" 715 (+ (f-op4 15) frn (f-sub8 #x9d)) 716 (set frn (c-call SF "sh64_fldi1"))) 717 718 (dshci float "Floating point integer conversion" 719 (FP-INSN) 720 "float fpul, $fsdn" 721 (+ (f-op4 15) fsdn (f-sub8 #x2d)) 722 (if prbit 723 (set (dr fsdn) (c-call DF "sh64_floatld" fpul)) 724 (set fsdn (c-call SF "sh64_floatls" fpul)))) 725 726 (dshci fmac "Floating point multiply and accumulate" 727 (FP-INSN) 728 "fmac fr0, $frm, $frn" 729 (+ (f-op4 15) frn frm (f-sub4 14)) 730 (set frn (c-call SF "sh64_fmacs" (reg h-frc 0) frm frn))) 731 732 (define-pmacro (even x) (eq (and x 1) 0)) 733 (define-pmacro (odd x) (eq (and x 1) 1)) 734 (define-pmacro (extd x) (odd (index-of x))) 735 736 (dshci fmov1 "Floating point move (register to register)" 737 (FP-INSN) 738 "fmov $frm, $frn" 739 (+ (f-op4 15) frn frm (f-sub4 12)) 740 (if (not szbit) 741 ; single precision operation 742 (set frn frm) 743 ; double or extended operation 744 (if (extd frm) 745 (if (extd frn) 746 (set (xd frn) (xd frm)) 747 (set (dr frn) (xd frm))) 748 (if (extd frn) 749 (set (xd frn) (dr frm)) 750 (set (dr frn) (dr frm)))))) 751 752 (dshci fmov2 "Floating point load" 753 (FP-INSN) 754 "fmov @$rm, $frn" 755 (+ (f-op4 15) frn rm (f-sub4 8)) 756 (if (not szbit) 757 ; single precision operation 758 (set frn (mem SF rm)) 759 ; double or extended operation 760 (if (extd frn) 761 (set (xd frn) (mem DF rm)) 762 (set (dr frn) (mem DF rm))))) 763 764 (dshci fmov3 "Floating point load (post-increment)" 765 (FP-INSN) 766 "fmov @${rm}+, frn" 767 (+ (f-op4 15) frn rm (f-sub4 9)) 768 (if (not szbit) 769 ; single precision operation 770 (sequence () 771 (set frn (mem SF rm)) 772 (set rm (add rm 4))) 773 ; double or extended operation 774 (sequence () 775 (if (extd frn) 776 (set (xd frn) (mem DF rm)) 777 (set (dr frn) (mem DF rm))) 778 (set rm (add rm 8))))) 779 780 (dshci fmov4 "Floating point load (register/register indirect)" 781 (FP-INSN) 782 "fmov @(r0, $rm), $frn" 783 (+ (f-op4 15) frn rm (f-sub4 6)) 784 (if (not szbit) 785 ; single precision operation 786 (set frn (mem SF (add r0 rm))) 787 ; double or extended operation 788 (if (extd frn) 789 (set (xd frn) (mem DF (add r0 rm))) 790 (set (dr frn) (mem DF (add r0 rm)))))) 791 792 (dshci fmov5 "Floating point store" 793 (FP-INSN) 794 "fmov $frm, @$rn" 795 (+ (f-op4 15) rn frm (f-sub4 10)) 796 (if (not szbit) 797 ; single precision operation 798 (set (mem SF rn) frm) 799 ; double or extended operation 800 (if (extd frm) 801 (set (mem DF rn) (xd frm)) 802 (set (mem DF rn) (dr frm))))) 803 804 (dshci fmov6 "Floating point store (pre-decrement)" 805 (FP-INSN) 806 "fmov $frm, @-$rn" 807 (+ (f-op4 15) rn frm (f-sub4 11)) 808 (if (not szbit) 809 ; single precision operation 810 (sequence () 811 (set rn (sub rn 4)) 812 (set (mem SF rn) frm)) 813 ; double or extended operation 814 (sequence () 815 (set rn (sub rn 8)) 816 (if (extd frm) 817 (set (mem DF rn) (xd frm)) 818 (set (mem DF rn) (dr frm)))))) 819 820 (dshci fmov7 "Floating point store (register/register indirect)" 821 (FP-INSN) 822 "fmov $frm, @(r0, $rn)" 823 (+ (f-op4 15) rn frm (f-sub4 7)) 824 (if (not szbit) 825 ; single precision operation 826 (set (mem SF (add r0 rn)) frm) 827 ; double or extended operation 828 (if (extd frm) 829 (set (mem DF (add r0 rn)) (xd frm)) 830 (set (mem DF (add r0 rn)) (dr frm))))) 831 832 (dshci fmul "Floating point multiply" 833 (FP-INSN) 834 "fmul $fsdm, $fsdn" 835 (+ (f-op4 15) fsdn fsdm (f-sub4 2)) 836 (if prbit 837 (set (dr fsdn) (c-call DF "sh64_fmuld" (dr fsdm) (dr fsdn))) 838 (set fsdn (c-call SF "sh64_fmuls" fsdm fsdn)))) 839 840 (dshci fneg "Floating point negate" 841 (FP-INSN) 842 "fneg $fsdn" 843 (+ (f-op4 15) fsdn (f-sub8 #x4d)) 844 (if prbit 845 (set (dr fsdn) (c-call DF "sh64_fnegd" (dr fsdn))) 846 (set fsdn (c-call SF "sh64_fnegs" fsdn)))) 847 848 (dshci frchg "Toggle floating point register banks" 849 (FP-INSN) 850 "frchg" 851 (+ (f-op16 #xfbfd)) 852 (set frbit (not frbit))) 853 854 (dshci fschg "Set size of floating point transfers" 855 (FP-INSN) 856 "fschg" 857 (+ (f-op16 #xf3fd)) 858 (set szbit (not szbit))) 859 860 (dshci fsqrt "Floating point square root" 861 (FP-INSN) 862 "fsqrt $fsdn" 863 (+ (f-op4 15) fsdn (f-sub8 #x6d)) 864 (if prbit 865 (set (dr fsdn) (c-call DF "sh64_fsqrtd" (dr fsdn))) 866 (set fsdn (c-call SF "sh64_fsqrts" fsdn)))) 867 868 (dshci fsts "Floating point store status register" 869 (FP-INSN) 870 "fsts fpul, $frn" 871 (+ (f-op4 15) frn (f-sub8 13)) 872 (set frn fpul)) 873 874 (dshci fsub "Floating point subtract" 875 (FP-INSN) 876 "fsub $fsdm, $fsdn" 877 (+ (f-op4 15) fsdn fsdm (f-sub4 1)) 878 (if prbit 879 (set (dr fsdn) (c-call DF "sh64_fsubd" (dr fsdn) (dr fsdm))) 880 (set fsdn (c-call SF "sh64_fsubs" fsdn fsdm)))) 881 882 (dshci ftrc "Floating point truncate" 883 (FP-INSN) 884 "ftrc $fsdn, fpul" 885 (+ (f-op4 15) fsdn (f-sub8 #x3d)) 886 (set fpul (if SF prbit 887 (c-call SF "sh64_ftrcdl" (dr fsdn)) 888 (c-call SF "sh64_ftrcsl" fsdn)))) 889 890 (dshci ftrv "Floating point transform vector" 891 (FP-INSN) 892 "ftrv xmtrx, $fvn" 893 (+ (f-op4 15) fvn (f-sub10 #x1fd)) 894 (sequence ((QI n) (SF res)) 895 (set n (index-of fvn)) 896 (set res (c-call SF "sh64_fmuls" (reg h-xf 0) (reg h-frc n))) 897 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 4) (reg h-frc (add n 1))))) 898 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 8) (reg h-frc (add n 2))))) 899 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 12) (reg h-frc (add n 3))))) 900 (set (reg h-frc n) res) 901 (set res (c-call SF "sh64_fmuls" (reg h-xf 1) (reg h-frc n))) 902 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 5) (reg h-frc (add n 1))))) 903 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 9) (reg h-frc (add n 2))))) 904 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 13) (reg h-frc (add n 3))))) 905 (set (reg h-frc (add n 1)) res) 906 (set res (c-call SF "sh64_fmuls" (reg h-xf 2) (reg h-frc n))) 907 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 6) (reg h-frc (add n 1))))) 908 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 10) (reg h-frc (add n 2))))) 909 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 14) (reg h-frc (add n 3))))) 910 (set (reg h-frc (add n 2)) res) 911 (set res (c-call SF "sh64_fmuls" (reg h-xf 3) (reg h-frc n))) 912 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 7) (reg h-frc (add n 1))))) 913 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 11) (reg h-frc (add n 2))))) 914 (set res (c-call SF "sh64_fadds" res (c-call SF "sh64_fmuls" (reg h-xf 15) (reg h-frc (add n 3))))) 915 (set (reg h-frc (add n 3)) res))) 916 917 (dshci jmp "Jump" 918 () 919 "jmp @$rn" 920 (+ (f-op4 4) rn (f-sub8 43)) 921 (delay 1 (set pc rn))) 922 923 (dshci jsr "Jump to subroutine" 924 () 925 "jsr @$rn" 926 (+ (f-op4 4) rn (f-sub8 11)) 927 (delay 1 (sequence () 928 (set pr (add pc 4)) 929 (set pc rn)))) 930 931 (dshci ldc "Load control register (GBR)" 932 () 933 "ldc $rn, gbr" 934 (+ (f-op4 4) rn (f-sub8 30)) 935 (set gbr rn)) 936 937 (dshci ldcl "Load control register (GBR)" 938 () 939 "ldc.l @${rn}+, gbr" 940 (+ (f-op4 4) rn (f-sub8 39)) 941 (sequence () 942 (set gbr (mem SI rn)) 943 (set rn (add rn 4)))) 944 945 (dshci lds-fpscr "Load status register (FPSCR)" 946 () 947 "lds $rn, fpscr" 948 (+ (f-op4 4) rn (f-sub8 106)) 949 (set fpscr rn)) 950 951 (dshci ldsl-fpscr "Load status register (FPSCR)" 952 () 953 "lds.l @${rn}+, fpscr" 954 (+ (f-op4 4) rn (f-sub8 102)) 955 (sequence () 956 (set fpscr (mem SI rn)) 957 (set rn (add rn 4)))) 958 959 (dshci lds-fpul "Load status register (FPUL)" 960 () 961 "lds $rn, fpul" 962 (+ (f-op4 4) rn (f-sub8 90)) 963 ; Use subword to convert rn's mode. 964 (set fpul (subword SF rn 0))) 965 966 (dshci ldsl-fpul "Load status register (FPUL)" 967 () 968 "lds.l @${rn}+, fpul" 969 (+ (f-op4 4) rn (f-sub8 86)) 970 (sequence () 971 (set fpul (mem SF rn)) 972 (set rn (add rn 4)))) 973 974 (dshci lds-mach "Load status register (MACH)" 975 () 976 "lds $rn, mach" 977 (+ (f-op4 4) rn (f-sub8 10)) 978 (set mach rn)) 979 980 (dshci ldsl-mach "Load status register (MACH), post-increment" 981 () 982 "lds.l @${rn}+, mach" 983 (+ (f-op4 4) rn (f-sub8 6)) 984 (sequence () 985 (set mach (mem SI rn)) 986 (set rn (add rn 4)))) 987 988 (dshci lds-macl "Load status register (MACL)" 989 () 990 "lds $rn, macl" 991 (+ (f-op4 4) rn (f-sub8 26)) 992 (set macl rn)) 993 994 (dshci ldsl-macl "Load status register (MACL), post-increment" 995 () 996 "lds.l @${rn}+, macl" 997 (+ (f-op4 4) rn (f-sub8 22)) 998 (sequence () 999 (set macl (mem SI rn)) 1000 (set rn (add rn 4)))) 1001 1002 (dshci lds-pr "Load status register (PR)" 1003 () 1004 "lds $rn, pr" 1005 (+ (f-op4 4) rn (f-sub8 42)) 1006 (set pr rn)) 1007 1008 (dshci ldsl-pr "Load status register (PR), post-increment" 1009 () 1010 "lds.l @${rn}+, pr" 1011 (+ (f-op4 4) rn (f-sub8 38)) 1012 (sequence () 1013 (set pr (mem SI rn)) 1014 (set rn (add rn 4)))) 1015 1016 (dshci macl "Multiply and accumulate (long)" 1017 () 1018 "mac.l @${rm}+, @${rn}+" 1019 (+ (f-op4 0) rn rm (f-sub4 15)) 1020 (sequence ((DI tmpry) (DI mac) (DI result) (SI x) (SI y)) 1021 (set x (mem SI rn)) 1022 (set rn (add rn 4)) 1023 (if (eq (index-of rn) (index-of rm)) 1024 (sequence () 1025 (set rn (add rn 4)) 1026 (set rm (add rm 4)))) 1027 (set y (mem SI rm)) 1028 (set rm (add rm 4)) 1029 (set tmpry (mul (zext DI x) (zext DI y))) 1030 (set mac (or DI (sll (zext DI mach) 32) (zext DI macl))) 1031 (set result (add mac tmpry)) 1032 (sequence () 1033 (if sbit 1034 (sequence ((SI min) (SI max)) 1035 (set max (srl (inv DI 0) 16)) 1036 ; Preserve bit 48 for sign. 1037 (set min (srl (inv DI 0) 15)) 1038 (if (gt result max) 1039 (set result max) 1040 (if (lt result min) 1041 (set result min))))) 1042 (set mach (subword SI result 0)) 1043 (set macl (subword SI result 1))))) 1044 1045 (dshci macw "Multiply and accumulate (word)" 1046 () 1047 "mac.w @${rm}+, @${rn}+" 1048 (+ (f-op4 4) rn rm (f-sub4 15)) 1049 (sequence ((SI tmpry) (DI mac) (DI result) (HI x) (HI y)) 1050 (set x (mem HI rn)) 1051 (set rn (add rn 2)) 1052 (if (eq (index-of rn) (index-of rm)) 1053 (sequence () 1054 (set rn (add rn 2)) 1055 (set rm (add rm 2)))) 1056 (set y (mem HI rm)) 1057 (set rm (add rm 2)) 1058 (set tmpry (mul (zext SI x) (zext SI y))) 1059 (if sbit 1060 (sequence () 1061 (if (add-oflag tmpry macl 0) 1062 (set mach 1)) 1063 (set macl (add tmpry macl))) 1064 (sequence () 1065 (set mac (or DI (sll (zext DI mach) 32) (zext DI macl))) 1066 (set result (add mac (ext DI tmpry))) 1067 (set mach (subword SI result 0)) 1068 (set macl (subword SI result 1)))))) 1069 1070 (dshci mov "Move" 1071 () 1072 "mov $rm64, $rn64" 1073 (+ (f-op4 6) rn64 rm64 (f-sub4 3)) 1074 (set rn64 rm64)) 1075 1076 (dshci movi "Move immediate" 1077 () 1078 "mov #$imm8, $rn" 1079 (+ (f-op4 14) rn imm8) 1080 (set rn (ext DI (and QI imm8 255)))) 1081 1082 (dshci movb1 "Store byte to memory (register indirect w/ zero displacement)" 1083 () 1084 "mov.b $rm, @$rn" 1085 (+ (f-op4 2) rn rm (f-sub4 0)) 1086 (set (mem UQI rn) (subword UQI rm 3))) 1087 1088 (dshci movb2 "Store byte to memory (register indirect w/ pre-decrement)" 1089 () 1090 "mov.b $rm, @-$rn" 1091 (+ (f-op4 2) rn rm (f-sub4 4)) 1092 (sequence ((DI addr)) 1093 (set addr (sub rn 1)) 1094 (set (mem UQI addr) (subword UQI rm 3)) 1095 (set rn addr))) 1096 1097 (dshci movb3 "Store byte to memory (register/register indirect)" 1098 () 1099 "mov.b $rm, @(r0,$rn)" 1100 (+ (f-op4 0) rn rm (f-sub4 4)) 1101 (set (mem UQI (add r0 rn)) (subword UQI rm 3))) 1102 1103 (dshci movb4 "Store byte to memory (GBR-relative w/ displacement)" 1104 () 1105 "mov.b r0, @($imm8, gbr)" 1106 (+ (f-op8 #xc0) imm8) 1107 (sequence ((DI addr)) 1108 (set addr (add gbr imm8)) 1109 (set (mem UQI addr) (subword UQI r0 3)))) 1110 1111 (dshci movb5 "Store byte to memory (register indirect w/ displacement)" 1112 () 1113 "mov.b r0, @($imm4, $rm)" 1114 (+ (f-op8 #x80) rm imm4) 1115 (sequence ((DI addr)) 1116 (set addr (add rm imm4)) 1117 (set (mem UQI addr) (subword UQI r0 3)))) 1118 1119 (dshci movb6 "Load byte from memory (register indirect w/ zero displacement)" 1120 () 1121 "mov.b @$rm, $rn" 1122 (+ (f-op4 6) rn rm (f-sub4 0)) 1123 (set rn (ext SI (mem QI rm)))) 1124 1125 (dshci movb7 "Load byte from memory (register indirect w/ post-increment)" 1126 () 1127 "mov.b @${rm}+, $rn" 1128 (+ (f-op4 6) rn rm (f-sub4 4)) 1129 (sequence ((QI data)) 1130 (set data (mem QI rm)) 1131 (if (eq (index-of rm) (index-of rn)) 1132 (set rm (ext SI data)) 1133 (set rm (add rm 1))) 1134 (set rn (ext SI data)))) 1135 1136 (dshci movb8 "Load byte from memory (register/register indirect)" 1137 () 1138 "mov.b @(r0, $rm), $rn" 1139 (+ (f-op4 0) rn rm (f-sub4 12)) 1140 (set rn (ext SI (mem QI (add r0 rm))))) 1141 1142 (dshci movb9 "Load byte from memory (GBR-relative with displacement)" 1143 () 1144 "mov.b @($imm8, gbr), r0" 1145 (+ (f-op8 #xc4) imm8) 1146 (set r0 (ext SI (mem QI (add gbr imm8))))) 1147 1148 (dshci movb10 "Load byte from memory (register indirect w/ displacement)" 1149 () 1150 "mov.b @($imm4, $rm), r0" 1151 (+ (f-op8 #x84) rm imm4) 1152 (set r0 (ext SI (mem QI (add rm imm4))))) 1153 1154 (dshci movl1 "Store long word to memory (register indirect w/ zero displacement)" 1155 () 1156 "mov.l $rm, @$rn" 1157 (+ (f-op4 2) rn rm (f-sub4 2)) 1158 (set (mem SI rn) rm)) 1159 1160 (dshci movl2 "Store long word to memory (register indirect w/ pre-decrement)" 1161 () 1162 "mov.l $rm, @-$rn" 1163 (+ (f-op4 2) rn rm (f-sub4 6)) 1164 (sequence ((SI addr)) 1165 (set addr (sub rn 4)) 1166 (set (mem SI addr) rm) 1167 (set rn addr))) 1168 1169 (dshci movl3 "Store long word to memory (register/register indirect)" 1170 () 1171 "mov.l $rm, @(r0, $rn)" 1172 (+ (f-op4 0) rn rm (f-sub4 6)) 1173 (set (mem SI (add r0 rn)) rm)) 1174 1175 (dshci movl4 "Store long word to memory (GBR-relative w/ displacement)" 1176 () 1177 "mov.l r0, @($imm8x4, gbr)" 1178 (+ (f-op8 #xc2) imm8x4) 1179 (set (mem SI (add gbr imm8x4)) r0)) 1180 1181 (dshci movl5 "Store long word to memory (register indirect w/ displacement)" 1182 () 1183 "mov.l $rm, @($imm4x4, $rn)" 1184 (+ (f-op4 1) rn rm imm4x4) 1185 (set (mem SI (add rn imm4x4)) rm)) 1186 1187 (dshci movl6 "Load long word to memory (register indirect w/ zero displacement)" 1188 () 1189 "mov.l @$rm, $rn" 1190 (+ (f-op4 6) rn rm (f-sub4 2)) 1191 (set rn (mem SI rm))) 1192 1193 (dshci movl7 "Load long word from memory (register indirect w/ post-increment)" 1194 () 1195 "mov.l @${rm}+, $rn" 1196 (+ (f-op4 6) rn rm (f-sub4 6)) 1197 (sequence () 1198 (set rn (mem SI rm)) 1199 (if (eq (index-of rm) (index-of rn)) 1200 (set rm rn) 1201 (set rm (add rm 4))))) 1202 1203 (dshci movl8 "Load long word from memory (register/register indirect)" 1204 () 1205 "mov.l @(r0, $rm), $rn" 1206 (+ (f-op4 0) rn rm (f-sub4 14)) 1207 (set rn (mem SI (add r0 rm)))) 1208 1209 (dshci movl9 "Load long word from memory (GBR-relative w/ displacement)" 1210 () 1211 "mov.l @($imm8x4, gbr), r0" 1212 (+ (f-op8 #xc6) imm8x4) 1213 (set r0 (mem SI (add gbr imm8x4)))) 1214 1215 (dshci movl10 "Load long word from memory (PC-relative w/ displacement)" 1216 (ILLSLOT) 1217 "mov.l @($imm8x4, pc), $rn" 1218 (+ (f-op4 13) rn imm8x4) 1219 (set rn (mem SI (add imm8x4 (and (add pc 4) (inv 3)))))) 1220 1221 (dshci movl11 "Load long word from memory (register indirect w/ displacement)" 1222 () 1223 "mov.l @($imm4x4, $rm), $rn" 1224 (+ (f-op4 5) rn rm imm4x4) 1225 (set rn (mem SI (add rm imm4x4)))) 1226 1227 (dshci movw1 "Store word to memory (register indirect w/ zero displacement)" 1228 () 1229 "mov.w $rm, @$rn" 1230 (+ (f-op4 2) rn rm (f-sub4 1)) 1231 (set (mem HI rn) (subword HI rm 1))) 1232 1233 (dshci movw2 "Store word to memory (register indirect w/ pre-decrement)" 1234 () 1235 "mov.w $rm, @-$rn" 1236 (+ (f-op4 2) rn rm (f-sub4 5)) 1237 (sequence ((DI addr)) 1238 (set addr (sub rn 2)) 1239 (set (mem HI addr) (subword HI rm 1)) 1240 (set rn addr))) 1241 1242 (dshci movw3 "Store word to memory (register/register indirect)" 1243 () 1244 "mov.w $rm, @(r0, $rn)" 1245 (+ (f-op4 0) rn rm (f-sub4 5)) 1246 (set (mem HI (add r0 rn)) (subword HI rm 1))) 1247 1248 (dshci movw4 "Store word to memory (GBR-relative w/ displacement)" 1249 () 1250 "mov.w r0, @($imm8x2, gbr)" 1251 (+ (f-op8 #xc1) imm8x2) 1252 (set (mem HI (add gbr imm8x2)) (subword HI r0 1))) 1253 1254 (dshci movw5 "Store word to memory (register indirect w/ displacement)" 1255 () 1256 "mov.w r0, @($imm4x2, $rn)" 1257 (+ (f-op8 #x81) rn imm4x2) 1258 (set (mem HI (add rn imm4x2)) (subword HI r0 1))) 1259 1260 (dshci movw6 "Load word from memory (register indirect w/ zero displacement)" 1261 () 1262 "mov.w @$rm, $rn" 1263 (+ (f-op4 6) rn rm (f-sub4 1)) 1264 (set rn (ext SI (mem HI rm)))) 1265 1266 (dshci movw7 "Load word from memory (register indirect w/ post-increment)" 1267 () 1268 "mov.w @${rm}+, $rn" 1269 (+ (f-op4 6) rn rm (f-sub4 5)) 1270 (sequence ((HI data)) 1271 (set data (mem HI rm)) 1272 (if (eq (index-of rm) (index-of rn)) 1273 (set rm (ext SI data)) 1274 (set rm (add rm 2))) 1275 (set rn (ext SI data)))) 1276 1277 (dshci movw8 "Load word from memory (register/register indirect)" 1278 () 1279 "mov.w @(r0, $rm), $rn" 1280 (+ (f-op4 0) rn rm (f-sub4 13)) 1281 (set rn (ext SI (mem HI (add r0 rm))))) 1282 1283 (dshci movw9 "Load word from memory (GBR-relative w/ displacement)" 1284 () 1285 "mov.w @($imm8x2, gbr), r0" 1286 (+ (f-op8 #xc5) imm8x2) 1287 (set r0 (ext SI (mem HI (add gbr imm8x2))))) 1288 1289 (dshci movw10 "Load word from memory (PC-relative w/ displacement)" 1290 (ILLSLOT) 1291 "mov.w @($imm8x2, pc), $rn" 1292 (+ (f-op4 9) rn imm8x2) 1293 (set rn (ext SI (mem HI (add (add pc 4) imm8x2))))) 1294 1295 (dshci movw11 "Load word from memory (register indirect w/ displacement)" 1296 () 1297 "mov.w @($imm4x2, $rm), r0" 1298 (+ (f-op8 #x85) rm imm4x2) 1299 (set r0 (ext SI (mem HI (add rm imm4x2))))) 1300 1301 (dshci mova "Move effective address" 1302 (ILLSLOT) 1303 "mova @($imm8x4, pc), r0" 1304 (+ (f-op8 #xc7) imm8x4) 1305 (set r0 (add (and (add pc 4) (inv 3)) imm8x4))) 1306 1307 (dshci movcal "Move with cache block allocation" 1308 () 1309 "movca.l r0, @$rn" 1310 (+ (f-op4 0) rn (f-sub8 #xc3)) 1311 (set (mem SI rn) r0)) 1312 1313 (dshci movt "Move t-bit" 1314 () 1315 "movt $rn" 1316 (+ (f-op4 0) rn (f-sub8 41)) 1317 (set rn (zext SI tbit))) 1318 1319 (dshci mull "Multiply" 1320 () 1321 "mul.l $rm, $rn" 1322 (+ (f-op4 0) rn rm (f-sub4 7)) 1323 (set macl (mul rm rn))) 1324 1325 (dshci mulsw "Multiply words (signed)" 1326 () 1327 "muls.w $rm, $rn" 1328 (+ (f-op4 2) rn rm (f-sub4 15)) 1329 (set macl (mul (ext SI (subword HI rm 1)) (ext SI (subword HI rn 1))))) 1330 1331 (dshci muluw "Multiply words (unsigned)" 1332 () 1333 "mulu.w $rm, $rn" 1334 (+ (f-op4 2) rn rm (f-sub4 14)) 1335 (set macl (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))) 1336 1337 (dshci neg "Negate" 1338 () 1339 "neg $rm, $rn" 1340 (+ (f-op4 6) rn rm (f-sub4 11)) 1341 (set rn (neg rm))) 1342 1343 (dshci negc "Negate with carry" 1344 () 1345 "negc $rm, $rn" 1346 (+ (f-op4 6) rn rm (f-sub4 10)) 1347 (sequence ((BI flag)) 1348 (set flag (sub-cflag 0 rm tbit)) 1349 (set rn (subc 0 rm tbit)) 1350 (set tbit flag))) 1351 1352 (dshci nop "No operation" 1353 () 1354 "nop" 1355 (+ (f-op16 9)) 1356 (nop)) 1357 1358 (dshci not "Bitwise NOT" 1359 () 1360 "not $rm64, $rn64" 1361 (+ (f-op4 6) rn64 rm64 (f-sub4 7)) 1362 (set rn64 (inv rm64))) 1363 1364 (dshci ocbi "Invalidate operand cache block" 1365 () 1366 "ocbi @$rn" 1367 (+ (f-op4 0) rn (f-sub8 147)) 1368 (unimp "ocbi")) 1369 1370 (dshci ocbp "Purge operand cache block" 1371 () 1372 "ocbp @$rn" 1373 (+ (f-op4 0) rn (f-sub8 163)) 1374 (unimp "ocbp")) 1375 1376 (dshci ocbwb "Write back operand cache block" 1377 () 1378 "ocbwb @$rn" 1379 (+ (f-op4 0) rn (f-sub8 179)) 1380 (unimp "ocbwb")) 1381 1382 (dshci or "Bitwise OR" 1383 () 1384 "or $rm64, $rn64" 1385 (+ (f-op4 2) rn64 rm64 (f-sub4 11)) 1386 (set rn64 (or rm64 rn64))) 1387 1388 (dshci ori "Bitwise OR immediate" 1389 () 1390 "or #$uimm8, r0" 1391 (+ (f-op8 #xcb) uimm8) 1392 (set r0 (or r0 (zext DI uimm8)))) 1393 1394 (dshci orb "Bitwise OR immediate" 1395 () 1396 "or.b #$imm8, @(r0, gbr)" 1397 (+ (f-op8 #xcf) imm8) 1398 (sequence ((DI addr) (UQI data)) 1399 (set addr (add r0 gbr)) 1400 (set data (or (mem UQI addr) imm8)) 1401 (set (mem UQI addr) data))) 1402 1403 (dshci pref "Prefetch data" 1404 () 1405 "pref @$rn" 1406 (+ (f-op4 0) rn (f-sub8 131)) 1407 (unimp "pref")) 1408 1409 (dshci rotcl "Rotate with carry left" 1410 () 1411 "rotcl $rn" 1412 (+ (f-op4 4) rn (f-sub8 36)) 1413 (sequence ((BI temp)) 1414 (set temp (srl rn 31)) 1415 (set rn (or (sll rn 1) tbit)) 1416 (set tbit (if BI temp 1 0)))) 1417 1418 (dshci rotcr "Rotate with carry right" 1419 () 1420 "rotcr $rn" 1421 (+ (f-op4 4) rn (f-sub8 37)) 1422 (sequence ((BI lsbit) (SI temp)) 1423 (set lsbit (if BI (eq (and rn 1) 0) 0 1)) 1424 (set temp tbit) 1425 (set rn (or (srl rn 1) (sll temp 31))) 1426 (set tbit (if BI lsbit 1 0)))) 1427 1428 (dshci rotl "Rotate left" 1429 () 1430 "rotl $rn" 1431 (+ (f-op4 4) rn (f-sub8 4)) 1432 (sequence ((BI temp)) 1433 (set temp (srl rn 31)) 1434 (set rn (or (sll rn 1) temp)) 1435 (set tbit (if BI temp 1 0)))) 1436 1437 (dshci rotr "Rotate right" 1438 () 1439 "rotr $rn" 1440 (+ (f-op4 4) rn (f-sub8 5)) 1441 (sequence ((BI lsbit) (SI temp)) 1442 (set lsbit (if BI (eq (and rn 1) 0) 0 1)) 1443 (set temp lsbit) 1444 (set rn (or (srl rn 1) (sll temp 31))) 1445 (set tbit (if BI lsbit 1 0)))) 1446 1447 (dshci rts "Return from subroutine" 1448 () 1449 "rts" 1450 (+ (f-op16 11)) 1451 (delay 1 (set pc pr))) 1452 1453 (dshci sets "Set S-bit" 1454 () 1455 "sets" 1456 (+ (f-op16 88)) 1457 (set sbit 1)) 1458 1459 (dshci sett "Set T-bit" 1460 () 1461 "sett" 1462 (+ (f-op16 24)) 1463 (set tbit 1)) 1464 1465 (dshci shad "Shift arithmetic dynamic" 1466 () 1467 "shad $rm, $rn" 1468 (+ (f-op4 4) rn rm (f-sub4 12)) 1469 (sequence ((QI shamt)) 1470 (set shamt (and QI rm 31)) 1471 (if (ge rm 0) 1472 (set rn (sll rn shamt)) 1473 (if (ne shamt 0) 1474 (set rn (sra rn (sub 32 shamt))) 1475 (if (lt rn 0) 1476 (set rn (neg 1)) 1477 (set rn 0)))))) 1478 1479 (dshci shal "Shift left arithmetic one bit" 1480 () 1481 "shal $rn" 1482 (+ (f-op4 4) rn (f-sub8 32)) 1483 (sequence ((BI t)) 1484 (set t (srl rn 31)) 1485 (set rn (sll rn 1)) 1486 (set tbit (if BI t 1 0)))) 1487 1488 (dshci shar "Shift right arithmetic one bit" 1489 () 1490 "shar $rn" 1491 (+ (f-op4 4) rn (f-sub8 33)) 1492 (sequence ((BI t)) 1493 (set t (and rn 1)) 1494 (set rn (sra rn 1)) 1495 (set tbit (if BI t 1 0)))) 1496 1497 (dshci shld "Shift logical dynamic" 1498 () 1499 "shld $rm, $rn" 1500 (+ (f-op4 4) rn rm (f-sub4 13)) 1501 (sequence ((QI shamt)) 1502 (set shamt (and QI rm 31)) 1503 (if (ge rm 0) 1504 (set rn (sll rn shamt)) 1505 (if (ne shamt 0) 1506 (set rn (srl rn (sub 32 shamt))) 1507 (set rn 0))))) 1508 1509 (dshci shll "Shift left logical one bit" 1510 () 1511 "shll $rn" 1512 (+ (f-op4 4) rn (f-sub8 0)) 1513 (sequence ((BI t)) 1514 (set t (srl rn 31)) 1515 (set rn (sll rn 1)) 1516 (set tbit (if BI t 1 0)))) 1517 1518 (dshci shll2 "Shift left logical two bits" 1519 () 1520 "shll2 $rn" 1521 (+ (f-op4 4) rn (f-sub8 8)) 1522 (set rn (sll rn 2))) 1523 1524 (dshci shll8 "Shift left logical eight bits" 1525 () 1526 "shll8 $rn" 1527 (+ (f-op4 4) rn (f-sub8 24)) 1528 (set rn (sll rn 8))) 1529 1530 (dshci shll16 "Shift left logical sixteen bits" 1531 () 1532 "shll16 $rn" 1533 (+ (f-op4 4) rn (f-sub8 40)) 1534 (set rn (sll rn 16))) 1535 1536 (dshci shlr "Shift right logical one bit" 1537 () 1538 "shlr $rn" 1539 (+ (f-op4 4) rn (f-sub8 1)) 1540 (sequence ((BI t)) 1541 (set t (and rn 1)) 1542 (set rn (srl rn 1)) 1543 (set tbit (if BI t 1 0)))) 1544 1545 (dshci shlr2 "Shift right logical two bits" 1546 () 1547 "shlr2 $rn" 1548 (+ (f-op4 4) rn (f-sub8 9)) 1549 (set rn (srl rn 2))) 1550 1551 (dshci shlr8 "Shift right logical eight bits" 1552 () 1553 "shlr8 $rn" 1554 (+ (f-op4 4) rn (f-sub8 25)) 1555 (set rn (srl rn 8))) 1556 1557 (dshci shlr16 "Shift right logical sixteen bits" 1558 () 1559 "shlr16 $rn" 1560 (+ (f-op4 4) rn (f-sub8 41)) 1561 (set rn (srl rn 16))) 1562 1563 (dshci stc-gbr "Store control register (GBR)" 1564 () 1565 "stc gbr, $rn" 1566 (+ (f-op4 0) rn (f-sub8 18)) 1567 (set rn gbr)) 1568 1569 (dshci stcl-gbr "Store control register (GBR)" 1570 () 1571 "stc.l gbr, @-$rn" 1572 (+ (f-op4 4) rn (f-sub8 19)) 1573 (sequence ((DI addr)) 1574 (set addr (sub rn 4)) 1575 (set (mem SI addr) gbr) 1576 (set rn addr))) 1577 1578 (dshci sts-fpscr "Store status register (FPSCR)" 1579 () 1580 "sts fpscr, $rn" 1581 (+ (f-op4 0) rn (f-sub8 106)) 1582 (set rn fpscr)) 1583 1584 (dshci stsl-fpscr "Store status register (FPSCR)" 1585 () 1586 "sts.l fpscr, @-$rn" 1587 (+ (f-op4 4) rn (f-sub8 98)) 1588 (sequence ((DI addr)) 1589 (set addr (sub rn 4)) 1590 (set (mem SI addr) fpscr) 1591 (set rn addr))) 1592 1593 (dshci sts-fpul "Store status register (FPUL)" 1594 () 1595 "sts fpul, $rn" 1596 (+ (f-op4 0) rn (f-sub8 90)) 1597 (set rn (subword SI fpul 0))) 1598 1599 (dshci stsl-fpul "Store status register (FPUL)" 1600 () 1601 "sts.l fpul, @-$rn" 1602 (+ (f-op4 4) rn (f-sub8 82)) 1603 (sequence ((DI addr)) 1604 (set addr (sub rn 4)) 1605 (set (mem SF addr) fpul) 1606 (set rn addr))) 1607 1608 (dshci sts-mach "Store status register (MACH)" 1609 () 1610 "sts mach, $rn" 1611 (+ (f-op4 0) rn (f-sub8 10)) 1612 (set rn mach)) 1613 1614 (dshci stsl-mach "Store status register (MACH)" 1615 () 1616 "sts.l mach, @-$rn" 1617 (+ (f-op4 4) rn (f-sub8 2)) 1618 (sequence ((DI addr)) 1619 (set addr (sub rn 4)) 1620 (set (mem SI addr) mach) 1621 (set rn addr))) 1622 1623 (dshci sts-macl "Store status register (MACL)" 1624 () 1625 "sts macl, $rn" 1626 (+ (f-op4 0) rn (f-sub8 26)) 1627 (set rn macl)) 1628 1629 (dshci stsl-macl "Store status register (MACL)" 1630 () 1631 "sts.l macl, @-$rn" 1632 (+ (f-op4 4) rn (f-sub8 18)) 1633 (sequence ((DI addr)) 1634 (set addr (sub rn 4)) 1635 (set (mem SI addr) macl) 1636 (set rn addr))) 1637 1638 (dshci sts-pr "Store status register (PR)" 1639 () 1640 "sts pr, $rn" 1641 (+ (f-op4 0) rn (f-sub8 42)) 1642 (set rn pr)) 1643 1644 (dshci stsl-pr "Store status register (PR)" 1645 () 1646 "sts.l pr, @-$rn" 1647 (+ (f-op4 4) rn (f-sub8 34)) 1648 (sequence ((DI addr)) 1649 (set addr (sub rn 4)) 1650 (set (mem SI addr) pr) 1651 (set rn addr))) 1652 1653 (dshci sub "Subtract" 1654 () 1655 "sub $rm, $rn" 1656 (+ (f-op4 3) rn rm (f-sub4 8)) 1657 (set rn (sub rn rm))) 1658 1659 (dshci subc "Subtract and detect carry" 1660 () 1661 "subc $rm, $rn" 1662 (+ (f-op4 3) rn rm (f-sub4 10)) 1663 (sequence ((BI flag)) 1664 (set flag (sub-cflag rn rm tbit)) 1665 (set rn (subc rn rm tbit)) 1666 (set tbit flag))) 1667 1668 (dshci subv "Subtract and detect overflow" 1669 () 1670 "subv $rm, $rn" 1671 (+ (f-op4 3) rn rm (f-sub4 11)) 1672 (sequence ((BI t)) 1673 (set t (sub-oflag rn rm 0)) 1674 (set rn (sub rn rm)) 1675 (set tbit (if BI t 1 0)))) 1676 1677 (dshci swapb "Swap bytes" 1678 () 1679 "swap.b $rm, $rn" 1680 (+ (f-op4 6) rn rm (f-sub4 8)) 1681 (sequence ((UHI top-half) (UQI byte1) (UQI byte0)) 1682 (set top-half (subword HI rm 0)) 1683 (set byte1 (subword QI rm 2)) 1684 (set byte0 (subword QI rm 3)) 1685 (set rn (or SI (sll SI top-half 16) (or SI (sll SI byte0 8) byte1))))) 1686 1687 (dshci swapw "Swap words" 1688 () 1689 "swap.w $rm, $rn" 1690 (+ (f-op4 6) rn rm (f-sub4 9)) 1691 (set rn (or (srl rm 16) (sll rm 16)))) 1692 1693 (dshci tasb "Test and set byte" 1694 () 1695 "tas.b @$rn" 1696 (+ (f-op4 4) rn (f-sub8 27)) 1697 (sequence ((UQI byte)) 1698 (set byte (mem UQI rn)) 1699 (set tbit (if BI (eq byte 0) 1 0)) 1700 (set byte (or byte 128)) 1701 (set (mem UQI rn) byte))) 1702 1703 (dshci trapa "Trap" 1704 (ILLSLOT) 1705 "trapa #$uimm8" 1706 (+ (f-op8 #xc3) uimm8) 1707 (c-call "sh64_compact_trapa" uimm8 pc)) 1708 1709 (dshci tst "Test and set t-bit" 1710 () 1711 "tst $rm, $rn" 1712 (+ (f-op4 2) rn rm (f-sub4 8)) 1713 (set tbit (if BI (eq (and rm rn) 0) 1 0))) 1714 1715 (dshci tsti "Test and set t-bit immediate" 1716 () 1717 "tst #$uimm8, r0" 1718 (+ (f-op8 #xc8) uimm8) 1719 (set tbit (if BI (eq (and r0 (zext SI uimm8)) 0) 1 0))) 1720 1721 (dshci tstb "Test and set t-bit immedate with memory byte" 1722 () 1723 "tst.b #$imm8, @(r0, gbr)" 1724 (+ (f-op8 #xcc) imm8) 1725 (sequence ((DI addr)) 1726 (set addr (add r0 gbr)) 1727 (set tbit (if BI (eq (and (mem UQI addr) imm8) 0) 1 0)))) 1728 1729 (dshci xor "Exclusive OR" 1730 () 1731 "xor $rm64, $rn64" 1732 (+ (f-op4 2) rn64 rm64 (f-sub4 10)) 1733 (set rn64 (xor rn64 rm64))) 1734 1735 (dshci xori "Exclusive OR immediate" 1736 () 1737 "xor #$uimm8, r0" 1738 (+ (f-op8 #xca) uimm8) 1739 (set (reg h-gr 0) (xor (reg h-gr 0) (zext DI uimm8)))) 1740 1741 (dshci xorb "Exclusive OR immediate with memory byte" 1742 () 1743 "xor.b #$imm8, @(r0, gbr)" 1744 (+ (f-op8 #xce) imm8) 1745 (sequence ((DI addr) (UQI data)) 1746 (set addr (add r0 gbr)) 1747 (set data (xor (mem UQI addr) imm8)) 1748 (set (mem UQI addr) data))) 1749 1750 (dshci xtrct "Extract" 1751 () 1752 "xtrct $rm, $rn" 1753 (+ (f-op4 2) rn rm (f-sub4 13)) 1754 (set rn (or (sll rm 16) (srl rn 16)))) 1755