1 ; Hitachi SHmedia instruction set description. -*- Scheme -*- 2 ; 3 ; Copyright 2000, 2001, 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 25 27 ; dshmf -- define-normal-sh-media-field 28 29 (define-pmacro (dshmf xname xcomment ignored xstart xlength) 30 (dnf xname xcomment ((ISA media)) xstart xlength)) 31 32 ; dshmop -- define-normal-sh-media-operand 33 34 (define-pmacro (dshmop xname xcomment ignored xhardware xfield) 35 (dnop xname xcomment ((ISA media)) xhardware xfield)) 36 37 ; dnshmi -- define-normal-sh-media-insn 38 39 (define-pmacro (dshmi xname xcomment xattrs xsyntax xformat xsemantics) 40 (define-insn 41 (name xname) 42 (comment xcomment) 43 (.splice attrs (.unsplice xattrs) (ISA media)) 44 (syntax xsyntax) 45 (format xformat) 46 (semantics xsemantics))) 47 48 ; Saturation functions. 49 ; Force a value `i' into words `n' bits wide. 50 ; See Hitachi SH-5 CPU core, volume 2, p. 25 for details. 51 52 ; saturate -- signed saturatation function 53 54 (define-pmacro (saturate mode n i) 55 (if mode (lt i (neg mode (sll mode 1 (sub n 1)))) 56 (neg (sll mode 1 (sub n 1))) 57 (if mode (lt i (sll mode 1 (sub n 1))) 58 i 59 (sub mode (sll mode 1 (sub n 1)) 1)))) 60 61 ; usaturate -- unsigned saturation function 62 63 (define-pmacro (usaturate mode n i) 64 (if mode (lt i (const mode 0)) 65 (const mode 0) 66 (if mode (lt i (sll mode 1 n)) 67 i 68 (sub mode (sll mode 1 n) 1)))) 69 70 72 ; Ifields. 73 74 (dshmf f-op "Opcode" () 31 6) 75 (dshmf f-ext "Extension opcode" () 19 4) 76 (dshmf f-rsvd "Reserved" (RESERVED) 3 4) 77 78 (dshmf f-left "Left register" () 25 6) 79 (dshmf f-right "Right register" () 15 6) 80 (dshmf f-dest "Destination register" () 9 6) 81 82 (define-multi-ifield 83 (name f-left-right) 84 (comment "Left and right matched register pair") 85 (attrs (ISA media)) 86 (mode UINT) 87 (subfields f-left f-right) 88 (insert (sequence () 89 (set (ifield f-left) 90 (and (ifield f-left-right) 63)) 91 (set (ifield f-right) 92 (and (ifield f-left-right) 63)))) 93 (extract (set (ifield f-left-right) (ifield f-left))) 94 ) 95 96 (dshmf f-tra "Target register" () 6 3) 97 (dshmf f-trb "Target register" () 22 3) 98 (dshmf f-likely "Likely bit" () 9 1) 99 (dshmf f-25 "Three unused bits at bit 25" () 25 3) 100 (dshmf f-8-2 "Two unused bits at bit 8" () 8 2) 101 102 (df f-imm6 "Immediate value (6 bits)" ((ISA media)) 15 6 INT #f #f) 103 (df f-imm10 "Immediate value (10 bits)" ((ISA media)) 19 10 INT #f #f) 104 (df f-imm16 "Immediate value (16 bits)" ((ISA media)) 25 16 INT #f #f) 105 106 (dshmf f-uimm6 "Immediate value (6 bits)" () 15 6) 107 (dshmf f-uimm16 "Immediate value (16 bits)" () 25 16) 108 109 ; Various displacement fields. 110 ; The 10 bit field, for example, has different scaling for displacements. 111 112 (df f-disp6 "Displacement (6 bits)" ((ISA media)) 15 6 INT #f #f) 113 114 (df f-disp6x32 "Displacement (6 bits)" ((ISA media)) 15 6 INT 115 ((value pc) (sra SI value 5)) 116 ((value pc) (sll SI value 5))) 117 118 (df f-disp10 "Displacement (10 bits)" ((ISA media)) 19 10 INT #f #f) 119 120 (df f-disp10x8 "Displacement (10 bits)" ((ISA media)) 19 10 INT 121 ((value pc) (sra SI value 3)) 122 ((value pc) (sll SI value 3))) 123 124 (df f-disp10x4 "Displacement (10 bits)" ((ISA media)) 19 10 INT 125 ((value pc) (sra SI value 2)) 126 ((value pc) (sll SI value 2))) 127 128 (df f-disp10x2 "Displacement (10 bits)" ((ISA media)) 19 10 INT 129 ((value pc) (sra SI value 1)) 130 ((value pc) (sll SI value 1))) 131 132 (df f-disp16 "Displacement (16 bits)" ((ISA media) PCREL-ADDR) 25 16 INT 133 ((value pc) (sra DI value 2)) 134 ((value pc) (add DI (sll DI value 2) pc))) 135 136 138 ; Operands. 139 140 (dshmop rm "Left general purpose reg" () h-gr f-left) 141 (dshmop rn "Right general purpose reg" () h-gr f-right) 142 (dshmop rd "Destination general purpose reg" () h-gr f-dest) 143 144 (dshmop frg "Left single precision register" () h-fr f-left) 145 (dshmop frh "Right single precision register" () h-fr f-right) 146 (dshmop frf "Destination single precision reg" () h-fr f-dest) 147 (dshmop frgh "Single precision register pair" () h-fr f-left-right) 148 149 (dshmop fpf "Pair of single precision registers" () h-fp f-dest) 150 151 (dshmop fvg "Left single precision vector" () h-fv f-left) 152 (dshmop fvh "Right single precision vector" () h-fv f-right) 153 (dshmop fvf "Destination single precision vector" () h-fv f-dest) 154 (dshmop mtrxg "Left single precision matrix" () h-fmtx f-left) 155 156 (dshmop drg "Left double precision register" () h-dr f-left) 157 (dshmop drh "Right double precision register" () h-dr f-right) 158 (dshmop drf "Destination double precision reg" () h-dr f-dest) 159 (dshmop drgh "Double precision register pair" () h-dr f-left-right) 160 161 (dshmop fpscr "Floating point status register" () h-fpscr f-nil) 162 (dshmop crj "Control register j" () h-cr f-dest) 163 (dshmop crk "Control register k" () h-cr f-left) 164 165 (dshmop tra "Target register a" () h-tr f-tra) 166 (dshmop trb "Target register b" () h-tr f-trb) 167 168 (dshmop disp6 "Displacement (6 bits)" () h-sint f-disp6) 169 (dshmop disp6x32 "Displacement (6 bits, scale 32)" () h-sint f-disp6x32) 170 (dshmop disp10 "Displacement (10 bits)" () h-sint f-disp10) 171 (dshmop disp10x2 "Displacement (10 bits, scale 2)" () h-sint f-disp10x2) 172 (dshmop disp10x4 "Displacement (10 bits, scale 4)" () h-sint f-disp10x4) 173 (dshmop disp10x8 "Displacement (10 bits, scale 8)" () h-sint f-disp10x8) 174 (dshmop disp16 "Displacement (16 bits)" () h-sint f-disp16) 175 176 (dshmop imm6 "Immediate (6 bits)" () h-sint f-imm6) 177 (dshmop imm10 "Immediate (10 bits)" () h-sint f-imm10) 178 (dshmop imm16 "Immediate (16 bits)" () h-sint f-imm16) 179 (dshmop uimm6 "Immediate (6 bits)" () h-uint f-uimm6) 180 (dshmop uimm16 "Unsigned immediate (16 bits)" () h-uint f-uimm16) 181 182 ; FIXME: provide these parse/print functions in `sh-media.opc'. 183 184 (define-operand (name likely) (comment "Likely branch?") (attrs (ISA media)) 185 (type h-uint) (index f-likely) (handlers (parse "likely") (print "likely"))) 186 187 189 ; Instructions. 190 191 (dshmi add "Add" 192 () 193 "add $rm, $rn, $rd" 194 (+ (f-op 0) rm (f-ext 9) rn rd (f-rsvd 0)) 195 (set rd (add rm rn))) 196 197 (dshmi addl "Add long" 198 () 199 "add.l $rm, $rn, $rd" 200 (+ (f-op 0) rm (f-ext 8) rn rd (f-rsvd 0)) 201 (set rd (add (subword SI rm 1) (subword SI rn 1)))) 202 203 (dshmi addi "Add immediate" 204 () 205 "addi $rm, $disp10, $rd" 206 (+ (f-op 52) rm disp10 rd (f-rsvd 0)) 207 (set rd (add rm (ext DI disp10)))) 208 209 (dshmi addil "Add immediate long" 210 () 211 "addi.l $rm, $disp10, $rd" 212 (+ (f-op 53) rm disp10 rd (f-rsvd 0)) 213 (set rd (ext DI (add (ext SI disp10) (subword SI rm 1))))) 214 215 (dshmi addzl "Add zero extended long" 216 () 217 "addz.l $rm, $rn, $rd" 218 (+ (f-op 0) rm (f-ext 12) rn rd (f-rsvd 0)) 219 (set rd (zext DI (add (subword SI rm 1) (subword SI rn 1))))) 220 221 (dshmi alloco "Allocate operand cache block" 222 () 223 "alloco $rm, $disp6x32" 224 (+ (f-op 56) rm (f-ext 4) disp6x32 (f-dest 63) (f-rsvd 0)) 225 (unimp "alloco")) 226 227 (dshmi and "AND" 228 () 229 "and $rm, $rn, $rd" 230 (+ (f-op 1) rm (f-ext 11) rn rd (f-rsvd 0)) 231 (set rd (and rm rn))) 232 233 (dshmi andc "AND complement" 234 () 235 "andc $rm, $rn, $rd" 236 (+ (f-op 1) rm (f-ext 15) rn rd (f-rsvd 0)) 237 (set rd (and rm (inv rn)))) 238 239 (dshmi andi "AND immediate" 240 () 241 "andi $rm, $disp10, $rd" 242 (+ (f-op 54) rm disp10 rd (f-rsvd 0)) 243 (set rd (and rm (ext DI disp10)))) 244 245 (dshmi beq "Branch if equal" 246 () 247 "beq$likely $rm, $rn, $tra" 248 (+ (f-op 25) rm (f-ext 1) rn likely (f-8-2 0) tra (f-rsvd 0)) 249 (if (eq rm rn) 250 (set pc tra))) 251 252 (dshmi beqi "Branch if equal immediate" 253 () 254 "beqi$likely $rm, $imm6, $tra" 255 (+ (f-op 57) rm (f-ext 1) imm6 likely (f-8-2 0) tra (f-rsvd 0)) 256 (if (eq rm (ext DI imm6)) 257 (set pc tra))) 258 259 (dshmi bge "Branch if greater than or equal" 260 () 261 "bge$likely $rm, $rn, $tra" 262 (+ (f-op 25) rm (f-ext 3) rn likely (f-8-2 0) tra (f-rsvd 0)) 263 (if (ge rm rn) 264 (set pc tra))) 265 266 (dshmi bgeu "Branch if greater than or equal (unsigned comparison)" 267 () 268 "bgeu$likely $rm, $rn, $tra" 269 (+ (f-op 25) rm (f-ext 11) rn likely (f-8-2 0) tra (f-rsvd 0)) 270 (if (geu rm rn) 271 (set pc tra))) 272 273 (dshmi bgt "Branch greater than" 274 () 275 "bgt$likely $rm, $rn, $tra" 276 (+ (f-op 25) rm (f-ext 7) rn likely (f-8-2 0) tra (f-rsvd 0)) 277 (if (gt rm rn) 278 (set pc tra))) 279 280 (dshmi bgtu "Branch greater than (unsigned comparison)" 281 () 282 "bgtu$likely $rm, $rn, $tra" 283 (+ (f-op 25) rm (f-ext 15) rn likely (f-8-2 0) tra (f-rsvd 0)) 284 (if (gtu rm rn) 285 (set pc tra))) 286 287 (dshmi blink "Branch and link" 288 () 289 "blink $trb, $rd" 290 (+ (f-op 17) (f-25 0) trb (f-ext 1) (f-right 63) rd (f-rsvd 0)) 291 (sequence () 292 (set rd (or (add pc 4) 1)) 293 (set pc trb))) 294 295 (dshmi bne "Branch if not equal" 296 () 297 "bne$likely $rm, $rn, $tra" 298 (+ (f-op 25) rm (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0)) 299 (if (ne rm rn) 300 (set pc tra))) 301 302 (dshmi bnei "Branch if not equal immediate" 303 () 304 "bnei$likely $rm, $imm6, $tra" 305 (+ (f-op 57) rm (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0)) 306 (if (ne rm (ext DI imm6)) 307 (set pc tra))) 308 309 (dshmi brk "Breakpoint instruction" 310 () 311 "brk" 312 (+ (f-op 27) (f-left 63) (f-ext 5) (f-right 63) (f-dest 63) (f-rsvd 0)) 313 (c-call "sh64_break" pc)) 314 315 (define-pmacro (-byterev-step) 316 (sequence () 317 (set result (or (sll result 8) (and source 255))) 318 (set source (srl source 8))) 319 ) 320 321 (dshmi byterev "Byte reverse" 322 () 323 "byterev $rm, $rd" 324 (+ (f-op 0) rm (f-ext 15) (f-right 63) rd (f-rsvd 0)) 325 (sequence ((DI source) (DI result)) 326 (set source rm) 327 (set result 0) 328 (-byterev-step) 329 (-byterev-step) 330 (-byterev-step) 331 (-byterev-step) 332 (-byterev-step) 333 (-byterev-step) 334 (-byterev-step) 335 (-byterev-step) 336 (set rd result))) 337 338 (dshmi cmpeq "Compare equal" 339 () 340 "cmpeq $rm, $rn, $rd" 341 (+ (f-op 0) rm (f-ext 1) rn rd (f-rsvd 0)) 342 (set rd (if DI (eq rm rn) 1 0))) 343 344 (dshmi cmpgt "Compare greater than" 345 () 346 "cmpgt $rm, $rn, $rd" 347 (+ (f-op 0) rm (f-ext 3) rn rd (f-rsvd 0)) 348 (set rd (if DI (gt rm rn) 1 0))) 349 350 (dshmi cmpgtu "Compare greater than (unsigned comparison)" 351 () 352 "cmpgtu $rm,$rn, $rd" 353 (+ (f-op 0) rm (f-ext 7) rn rd (f-rsvd 0)) 354 (set rd (if DI (gtu rm rn) 1 0))) 355 356 (dshmi cmveq "Conditional move if equal to zero" 357 () 358 "cmveq $rm, $rn, $rd" 359 (+ (f-op 8) rm (f-ext 1) rn rd (f-rsvd 0)) 360 (if (eq rm 0) 361 (set rd rn))) 362 363 (dshmi cmvne "Conditional move if not equal to zero" 364 () 365 "cmvne $rm, $rn, $rd" 366 (+ (f-op 8) rm (f-ext 5) rn rd (f-rsvd 0)) 367 (if (ne rm 0) 368 (set rd rn))) 369 370 (dshmi fabsd "Floating point absolute (double)" 371 () 372 "fabs.d $drgh, $drf" 373 (+ (f-op 6) drgh (f-ext 1) drf (f-rsvd 0)) 374 (set drf (c-call DF "sh64_fabsd" drgh))) 375 376 (dshmi fabss "Floating point absolute (single)" 377 () 378 "fabs.s $frgh, $frf" 379 (+ (f-op 6) frgh (f-ext 0) frf (f-rsvd 0)) 380 (set frf (c-call SF "sh64_fabss" frgh))) 381 382 (dshmi faddd "Floating point add (double)" 383 () 384 "fadd.d $drg, $drh, $drf" 385 (+ (f-op 13) drg (f-ext 1) drh drf (f-rsvd 0)) 386 (set drf (c-call DF "sh64_faddd" drg drh))) 387 388 (dshmi fadds "Floating point add (single)" 389 () 390 "fadd.s $frg, $frh, $frf" 391 (+ (f-op 13) frg (f-ext 0) frh frf (f-rsvd 0)) 392 (set frf (c-call SF "sh64_fadds" frg frh))) 393 394 (dshmi fcmpeqd "Floating point compare if equal (double)" 395 () 396 "fcmpeq.d $drg, $drh, $rd" 397 (+ (f-op 12) drg (f-ext 9) drh rd (f-rsvd 0)) 398 (set rd (zext DI (c-call BI "sh64_fcmpeqd" drg drh)))) 399 400 (dshmi fcmpeqs "Floating point compare if equal (single)" 401 () 402 "fcmpeq.s $frg, $frh, $rd" 403 (+ (f-op 12) frg (f-ext 8) frh rd (f-rsvd 0)) 404 (set rd (zext DI (c-call BI "sh64_fcmpeqs" frg frh)))) 405 406 (dshmi fcmpged "Floating compare compare if greater than or equal (double)" 407 () 408 "fcmpge.d $drg, $drh, $rd" 409 (+ (f-op 12) drg (f-ext 15) drh rd (f-rsvd 0)) 410 (set rd (zext DI (c-call BI "sh64_fcmpged" drg drh)))) 411 412 (dshmi fcmpges "Floating point compare if greater than or equal (single)" 413 () 414 "fcmpge.s $frg, $frh, $rd" 415 (+ (f-op 12) frg (f-ext 14) frh rd (f-rsvd 0)) 416 (set rd (zext DI (c-call BI "sh64_fcmpges" frg frh)))) 417 418 (dshmi fcmpgtd "Floating point compare if greater than (double)" 419 () 420 "fcmpgt.d $drg, $drh, $rd" 421 (+ (f-op 12) drg (f-ext 13) drh rd (f-rsvd 0)) 422 (set rd (zext DI (c-call BI "sh64_fcmpgtd" drg drh)))) 423 424 (dshmi fcmpgts "Floating point compare if greater than (single)" 425 () 426 "fcmpgt.s $frg, $frh, $rd" 427 (+ (f-op 12) frg (f-ext 12) frh rd (f-rsvd 0)) 428 (set rd (zext DI (c-call BI "sh64_fcmpgts" frg frh)))) 429 430 (dshmi fcmpund "Floating point unordered comparison (double)" 431 () 432 "fcmpun.d $drg, $drh, $rd" 433 (+ (f-op 12) drg (f-ext 11) drh rd (f-rsvd 0)) 434 (set rd (zext DI (c-call BI "sh64_fcmpund" drg drh)))) 435 436 (dshmi fcmpuns "Floating point unordered comparison (single)" 437 () 438 "fcmpun.s $frg, $frh, $rd" 439 (+ (f-op 12) frg (f-ext 10) frh rd (f-rsvd 0)) 440 (set rd (zext DI (c-call BI "sh64_fcmpuns" frg frh)))) 441 442 (dshmi fcnvds "Floating point coversion (double to single)" 443 () 444 "fcnv.ds $drgh, $frf" 445 (+ (f-op 14) drgh (f-ext 7) frf (f-rsvd 0)) 446 (set frf (c-call SF "sh64_fcnvds" drgh))) 447 448 (dshmi fcnvsd "Floating point conversion (single to double)" 449 () 450 "fcnv.sd $frgh, $drf" 451 (+ (f-op 14) frgh (f-ext 6) drf (f-rsvd 0)) 452 (set drf (c-call DF "sh64_fcnvsd" frgh))) 453 454 (dshmi fdivd "Floating point divide (double)" 455 () 456 "fdiv.d $drg, $drh, $drf" 457 (+ (f-op 13) drg (f-ext 5) drh drf (f-rsvd 0)) 458 (set drf (c-call DF "sh64_fdivd" drg drh))) 459 460 (dshmi fdivs "Floating point divide (single)" 461 () 462 "fdiv.s $frg, $frh, $frf" 463 (+ (f-op 13) frg (f-ext 4) frh frf (f-rsvd 0)) 464 (set frf (c-call SF "sh64_fdivs" frg frh))) 465 466 (dshmi fgetscr "Floating point get from FPSCR" 467 () 468 "fgetscr $frf" 469 (+ (f-op 7) (f-left 63) (f-ext 2) (f-right 63) frf (f-rsvd 0)) 470 (unimp "fputscr")) 471 ; FIXME: this should work! 472 ; (set frf fpscr)) 473 474 (dshmi fiprs "Floating point inner product (single)" 475 () 476 "fipr.s $fvg, $fvh, $frf" 477 (+ (f-op 5) fvg (f-ext 6) fvh frf (f-rsvd 0)) 478 (sequence ((UQI g) (UQI h) (SF temp)) 479 (set g (index-of fvg)) 480 (set h (index-of fvh)) 481 (set temp (c-call SF "sh64_fmuls" (reg h-fr g) (reg h-fr h))) 482 (set temp (c-call SF "sh64_fadds" temp 483 (c-call SF "sh64_fmuls" (reg h-fr (add g 1)) (reg h-fr (add h 1))))) 484 (set temp (c-call SF "sh64_fadds" temp 485 (c-call SF "sh64_fmuls" (reg h-fr (add g 2)) (reg h-fr (add h 2))))) 486 (set temp (c-call SF "sh64_fadds" temp 487 (c-call SF "sh64_fmuls" (reg h-fr (add g 3)) (reg h-fr (add h 3))))) 488 (set frf temp))) 489 490 (dshmi fldd "Floating point load (double)" 491 () 492 "fld.d $rm, $disp10x8, $drf" 493 (+ (f-op 39) rm disp10x8 drf (f-rsvd 0)) 494 (set drf (mem DF (add rm disp10x8)))) 495 496 (dshmi fldp "Floating point load (pair of singles)" 497 () 498 "fld.p $rm, $disp10x8, $fpf" 499 (+ (f-op 38) rm disp10x8 fpf (f-rsvd 0)) 500 (sequence ((QI f)) 501 (set f (index-of fpf)) 502 (set (reg h-fr f) (mem SF (add rm disp10x8))) 503 (set (reg h-fr (add f 1)) (mem SF (add rm (add disp10x8 4)))))) 504 505 (dshmi flds "Floating point load (single)" 506 () 507 "fld.s $rm, $disp10x4, $frf" 508 (+ (f-op 37) rm disp10x4 frf (f-rsvd 0)) 509 (set frf (mem SF (add rm disp10x4)))) 510 511 (dshmi fldxd "Floating point extended load (double)" 512 () 513 "fldx.d $rm, $rn, $drf" 514 (+ (f-op 7) rm (f-ext 9) rn frf (f-rsvd 0)) 515 (set drf (mem DF (add rm rn)))) 516 517 (dshmi fldxp "Floating point extended load (pair of singles)" 518 () 519 "fldx.p $rm, $rn, $fpf" 520 (+ (f-op 7) rm (f-ext 13) rn fpf (f-rsvd 0)) 521 (sequence ((QI f)) 522 (set f (index-of fpf)) 523 (set (reg h-fr f) (mem SF (add rm rn))) 524 (set (reg h-fr (add f 1)) (mem SF (add rm (add rn 4)))))) 525 526 (dshmi fldxs "Floating point extended load (single)" 527 () 528 "fldx.s $rm, $rn, $frf" 529 (+ (f-op 7) rm (f-ext 8) rn frf (f-rsvd 0)) 530 (set frf (mem SF (add rm rn)))) 531 532 (dshmi floatld "Floating point conversion (long to double)" 533 () 534 "float.ld $frgh, $drf" 535 (+ (f-op 14) frgh (f-ext 14) drf (f-rsvd 0)) 536 (set drf (c-call DF "sh64_floatld" frgh))) 537 538 (dshmi floatls "Floating point conversion (long to single)" 539 () 540 "float.ls $frgh, $frf" 541 (+ (f-op 14) frgh (f-ext 12) frf (f-rsvd 0)) 542 (set frf (c-call SF "sh64_floatls" frgh))) 543 544 (dshmi floatqd "Floating point conversion (quad to double)" 545 () 546 "float.qd $drgh, $drf" 547 (+ (f-op 14) drgh (f-ext 13) drf (f-rsvd 0)) 548 (set drf (c-call DF "sh64_floatqd" drgh))) 549 550 (dshmi floatqs "Floating point conversion (quad to single)" 551 () 552 "float.qs $drgh, $frf" 553 (+ (f-op 14) drgh (f-ext 15) frf (f-rsvd 0)) 554 (set frf (c-call SF "sh64_floatqs" drgh))) 555 556 (dshmi fmacs "Floating point multiply and accumulate (single)" 557 () 558 "fmac.s $frg, $frh, $frf" 559 (+ (f-op 13) frg (f-ext 14) frh frf (f-rsvd 0)) 560 (set frf (c-call SF "sh64_fadds" frf (c-call SF "sh64_fmuls" frg frh)))) 561 562 (dshmi fmovd "Floating point move double" 563 () 564 "fmov.d $drgh, $drf" 565 (+ (f-op 14) drgh (f-ext 1) drf (f-rsvd 0)) 566 (set drf drgh)) 567 568 (dshmi fmovdq "Floating point move (double to quad integer)" 569 () 570 "fmov.dq $drgh, $rd" 571 (+ (f-op 12) drgh (f-ext 1) rd (f-rsvd 0)) 572 (set rd (subword DI drgh 0))) 573 574 (dshmi fmovls "Floating point move (lower to single)" 575 () 576 "fmov.ls $rm, $frf" 577 (+ (f-op 7) rm (f-ext 0) (f-right 63) frf (f-rsvd 0)) 578 (set frf (subword SF (subword SI rm 1) 0))) 579 580 (dshmi fmovqd "Floating point move (quad to double)" 581 () 582 "fmov.qd $rm, $drf" 583 (+ (f-op 7) rm (f-ext 1) (f-right 63) frf (f-rsvd 0)) 584 (set drf (subword DF rm 0))) 585 586 (dshmi fmovs "Floating point move (single)" 587 () 588 "fmov.s $frgh, $frf" 589 (+ (f-op 14) frgh (f-ext 0) frf (f-rsvd 0)) 590 (set frf frgh)) 591 592 (dshmi fmovsl "Floating point move (single to lower)" 593 () 594 "fmov.sl $frgh, $rd" 595 (+ (f-op 12) frgh (f-ext 0) rd (f-rsvd 0)) 596 (set rd (ext DI (subword SI frgh 1)))) 597 598 (dshmi fmuld "Floating point multiply (double)" 599 () 600 "fmul.d $drg, $drh, $drf" 601 (+ (f-op 13) drg (f-ext 7) drh drf (f-rsvd 0)) 602 (set drf (c-call DF "sh64_fmuld" drg drh))) 603 604 (dshmi fmuls "Floating point multiply (single)" 605 () 606 "fmul.s $frg, $frh, $frf" 607 (+ (f-op 13) frg (f-ext 6) frh frf (f-rsvd 0)) 608 (set frf (c-call SF "sh64_fmuls" frg frh))) 609 610 (dshmi fnegd "Floating point negate (double)" 611 () 612 "fneg.d $drgh, $drf" 613 (+ (f-op 6) drgh (f-ext 3) drf (f-rsvd 0)) 614 (set drf (c-call DF "sh64_fnegd" drgh))) 615 616 (dshmi fnegs "Floating point negate (single)" 617 () 618 "fneg.s $frgh, $frf" 619 (+ (f-op 6) frgh (f-ext 2) frf (f-rsvd 0)) 620 (set frf (c-call SF "sh64_fnegs" frgh))) 621 622 (dshmi fputscr "Floating point put to FPSCR" 623 () 624 "fputscr $frgh" 625 (+ (f-op 12) frgh (f-ext 2) (f-dest 63) (f-rsvd 0)) 626 (unimp "fputscr")) 627 ; FIXME: this should work! 628 ; (set fpscr (subword SI frgh 0))) 629 630 (dshmi fsqrtd "Floating point square root (double)" 631 () 632 "fsqrt.d $drgh, $drf" 633 (+ (f-op 14) drgh (f-ext 5) drf (f-rsvd 0)) 634 (set drf (c-call DF "sh64_fsqrtd" drgh))) 635 636 (dshmi fsqrts "Floating point squart root (single)" 637 () 638 "fsqrt.s $frgh, $frf" 639 (+ (f-op 14) frgh (f-ext 4) frf (f-rsvd 0)) 640 (set frf (c-call SF "sh64_fsqrts" frgh))) 641 642 (dshmi fstd "Floating point store (double)" 643 () 644 "fst.d $rm, $disp10x8, $drf" 645 (+ (f-op 47) rm disp10x8 drf (f-rsvd 0)) 646 (set (mem DF (add rm disp10x8)) drf)) 647 648 (dshmi fstp "Floating point store (pair of singles)" 649 () 650 "fst.p $rm, $disp10x8, $fpf" 651 (+ (f-op 46) rm disp10x8 fpf (f-rsvd 0)) 652 (sequence ((QI f)) 653 (set f (index-of fpf)) 654 (set (mem SF (add rm disp10x8)) (reg h-fr f)) 655 (set (mem SF (add rm (add disp10x8 4))) (reg h-fr (add f 1))))) 656 657 (dshmi fsts "Floating point store (single)" 658 () 659 "fst.s $rm, $disp10x4, $frf" 660 (+ (f-op 45) rm disp10x4 frf (f-rsvd 0)) 661 (set (mem SF (add rm disp10x4)) frf)) 662 663 (dshmi fstxd "Floating point extended store (double)" 664 () 665 "fstx.d $rm, $rn, $drf" 666 (+ (f-op 15) rm (f-ext 9) rn drf (f-rsvd 0)) 667 (set (mem DF (add rm rn)) drf)) 668 669 (dshmi fstxp "Floating point extended store (pair of singles)" 670 () 671 "fstx.p $rm, $rn, $fpf" 672 (+ (f-op 15) rm (f-ext 13) rn fpf (f-rsvd 0)) 673 (sequence ((QI f)) 674 (set f (index-of fpf)) 675 (set (mem SF (add rm rn)) (reg h-fr f)) 676 (set (mem SF (add rm (add rn 4))) (reg h-fr (add f 1))))) 677 678 (dshmi fstxs "Floating point extended store (single)" 679 () 680 "fstx.s $rm, $rn, $frf" 681 (+ (f-op 15) rm (f-ext 8) rn frf (f-rsvd 0)) 682 (set (mem SF (add rm rn)) frf)) 683 684 (dshmi fsubd "Floating point subtract (double)" 685 () 686 "fsub.d $drg, $drh, $drf" 687 (+ (f-op 13) frg (f-ext 3) frh frf (f-rsvd 0)) 688 (set drf (c-call DF "sh64_fsubd" drg drh))) 689 690 (dshmi fsubs "Floating point subtract (single)" 691 () 692 "fsub.s $frg, $frh, $frf" 693 (+ (f-op 13) frg (f-ext 2) frh frf (f-rsvd 0)) 694 (set frf (c-call SF "sh64_fsubs" frg frh))) 695 696 (dshmi ftrcdl "Floating point conversion (double to long)" 697 () 698 "ftrc.dl $drgh, $frf" 699 (+ (f-op 14) drgh (f-ext 11) frf (f-rsvd 0)) 700 (set frf (c-call SF "sh64_ftrcdl" drgh))) 701 702 (dshmi ftrcsl "Floating point conversion (single to long)" 703 () 704 "ftrc.sl $frgh, $frf" 705 (+ (f-op 14) frgh (f-ext 8) frf (f-rsvd 0)) 706 (set frf (c-call SF "sh64_ftrcsl" frgh))) 707 708 (dshmi ftrcdq "Floating point conversion (double to quad)" 709 () 710 "ftrc.dq $drgh, $drf" 711 (+ (f-op 14) drgh (f-ext 9) frf (f-rsvd 0)) 712 (set drf (c-call DF "sh64_ftrcdq" drgh))) 713 714 (dshmi ftrcsq "Floating point conversion (single to quad)" 715 () 716 "ftrc.sq $frgh, $drf" 717 (+ (f-op 14) frgh (f-ext 10) drf (f-rsvd 0)) 718 (set drf (c-call DF "sh64_ftrcsq" frgh))) 719 720 (dshmi ftrvs "Floating point matrix multiply" 721 () 722 "ftrv.s $mtrxg, $fvh, $fvf" 723 (+ (f-op 5) mtrxg (f-ext 14) fvh fvf (f-rsvd 0)) 724 (c-call "sh64_ftrvs" (index-of mtrxg) (index-of fvh) (index-of fvf))) 725 726 (dshmi getcfg "Get configuration register" 727 () 728 "getcfg $rm, $disp6, $rd" 729 (+ (f-op 48) rm (f-ext 15) disp6 rd (f-rsvd 0)) 730 (unimp "getcfg")) 731 732 (dshmi getcon "Get control register" 733 () 734 "getcon $crk, $rd" 735 (+ (f-op 9) crk (f-ext 15) (f-right 63) rd (f-rsvd 0)) 736 (set rd crk)) 737 738 (dshmi gettr "Get target register" 739 () 740 "gettr $trb, $rd" 741 (+ (f-op 17) (f-25 0) trb (f-ext 5) (f-right 63) rd (f-rsvd 0)) 742 (set rd trb)) 743 744 (dshmi icbi "Invalidate instruction cache block" 745 () 746 "icbi $rm, $disp6x32" 747 (+ (f-op 56) rm (f-ext 5) disp6x32 (f-dest 63) (f-rsvd 0)) 748 (unimp "icbi")) 749 750 (dshmi ldb "Load byte" 751 () 752 "ld.b $rm, $disp10, $rd" 753 (+ (f-op 32) rm disp10 rd (f-rsvd 0)) 754 (set rd (ext DI (mem QI (add rm (ext DI disp10)))))) 755 756 (dshmi ldl "Load long word" 757 () 758 "ld.l $rm, $disp10x4, $rd" 759 (+ (f-op 34) rm disp10x4 rd (f-rsvd 0)) 760 (set rd (ext DI (mem SI (add rm (ext DI disp10x4)))))) 761 762 (dshmi ldq "Load quad word" 763 () 764 "ld.q $rm, $disp10x8, $rd" 765 (+ (f-op 35) rm disp10x8 rd (f-rsvd 0)) 766 (set rd (mem DI (add rm (ext DI disp10x8))))) 767 768 (dshmi ldub "Load unsigned byte" 769 () 770 "ld.ub $rm, $disp10, $rd" 771 (+ (f-op 36) rm disp10 rd (f-rsvd 0)) 772 (set rd (zext DI (mem QI (add rm (ext DI disp10)))))) 773 774 (dshmi lduw "Load unsigned word" 775 () 776 "ld.uw $rm, $disp10x2, $rd" 777 (+ (f-op 44) rm disp10 rd (f-rsvd 0)) 778 (set rd (zext DI (mem HI (add rm (ext DI disp10x2)))))) 779 780 (dshmi ldw "Load word" 781 () 782 "ld.w $rm, $disp10x2, $rd" 783 (+ (f-op 33) rm disp10 rd (f-rsvd 0)) 784 (set rd (ext DI (mem HI (add rm (ext DI disp10x2)))))) 785 786 (dshmi ldhil "Load high part (long word)" 787 () 788 "ldhi.l $rm, $disp6, $rd" 789 (+ (f-op 48) rm (f-ext 6) disp6 rd (f-rsvd 0)) 790 ; FIXME. 791 (unimp "ldhil")) 792 793 (dshmi ldhiq "Load high part (quad word)" 794 () 795 "ldhi.q $rm, $disp6, $rd" 796 (+ (f-op 48) rm (f-ext 7) disp6 rd (f-rsvd 0)) 797 ; FIXME. 798 (unimp "ldhiq")) 799 800 (dshmi ldlol "Load low part (long word)" 801 () 802 "ldlo.l $rm, $disp6, $rd" 803 (+ (f-op 48) rm (f-ext 2) disp6 rd (f-rsvd 0)) 804 ; FIXME. 805 (unimp "ldlol")) 806 807 (dshmi ldloq "Load low part (quad word)" 808 () 809 "ldlo.q $rm, $disp6, $rd" 810 (+ (f-op 48) rm (f-ext 3) disp6 rd (f-rsvd 0)) 811 ; FIXME; 812 (unimp "ldloq")) 813 814 (dshmi ldxb "Load byte (extended displacement)" 815 () 816 "ldx.b $rm, $rn, $rd" 817 (+ (f-op 16) rm (f-ext 0) rn rd (f-rsvd 0)) 818 (set rd (ext DI (mem QI (add rm rn))))) 819 820 (dshmi ldxl "Load long word (extended displacement)" 821 () 822 "ldx.l $rm, $rn, $rd" 823 (+ (f-op 16) rm (f-ext 2) rn rd (f-rsvd 0)) 824 (set rd (ext DI (mem SI (add rm rn))))) 825 826 (dshmi ldxq "Load quad word (extended displacement)" 827 () 828 "ldx.q $rm, $rn, $rd" 829 (+ (f-op 16) rm (f-ext 3) rn rd (f-rsvd 0)) 830 (set rd (mem DI (add rm rn)))) 831 832 (dshmi ldxub "Load unsigned byte (extended displacement)" 833 () 834 "ldx.ub $rm, $rn, $rd" 835 (+ (f-op 16) rm (f-ext 4) rn rd (f-rsvd 0)) 836 (set rd (zext DI (mem UQI (add rm rn))))) 837 838 (dshmi ldxuw "Load unsigned word (extended displacement)" 839 () 840 "ldx.uw $rm, $rn, $rd" 841 (+ (f-op 16) rm (f-ext 5) rn rd (f-rsvd 0)) 842 (set rd (zext DI (mem UHI (add rm rn))))) 843 844 (dshmi ldxw "Load word (extended displacement)" 845 () 846 "ldx.w $rm, $rn, $rd" 847 (+ (f-op 16) rm (f-ext 1) rn rd (f-rsvd 0)) 848 (set rd (ext DI (mem HI (add rm rn))))) 849 850 852 ; Macros to facilitate multimedia instructions. 853 854 (define-pmacro (slice-byte expr) 855 (sequence ((QI result7) (QI result6) (QI result5) (QI result4) 856 (QI result3) (QI result2) (QI result1) (QI result0)) 857 (set result0 (expr (subword QI rm 7) (subword QI rn 7))) 858 (set result1 (expr (subword QI rm 6) (subword QI rn 6))) 859 (set result2 (expr (subword QI rm 5) (subword QI rn 5))) 860 (set result3 (expr (subword QI rm 4) (subword QI rn 4))) 861 (set result4 (expr (subword QI rm 3) (subword QI rn 3))) 862 (set result5 (expr (subword QI rm 2) (subword QI rn 2))) 863 (set result6 (expr (subword QI rm 1) (subword QI rn 1))) 864 (set result7 (expr (subword QI rm 0) (subword QI rn 0))) 865 (set rd (-join-qi result7 result6 result5 result4 result3 result2 866 result1 result0)))) 867 868 (define-pmacro (slice-word expr) 869 (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) 870 (set result0 (expr (subword HI rm 3) (subword HI rn 3))) 871 (set result1 (expr (subword HI rm 2) (subword HI rn 2))) 872 (set result2 (expr (subword HI rm 1) (subword HI rn 1))) 873 (set result3 (expr (subword HI rm 0) (subword HI rn 0))) 874 (set rd (-join-hi result3 result2 result1 result0)))) 875 876 (define-pmacro (slice-word-unop expr) 877 (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) 878 (set result0 (expr (subword HI rm 3))) 879 (set result1 (expr (subword HI rm 2))) 880 (set result2 (expr (subword HI rm 1))) 881 (set result3 (expr (subword HI rm 0))) 882 (set rd (-join-hi result3 result2 result1 result0)))) 883 884 (define-pmacro (slice-long expr) 885 (sequence ((SI result1) (SI result0)) 886 (set result0 (expr (subword SI rm 1) (subword SI rn 1))) 887 (set result1 (expr (subword SI rm 0) (subword SI rn 0))) 888 (set rd (-join-si result1 result0)))) 889 890 (define-pmacro (slice-long-unop expr) 891 (sequence ((SI result1) (SI result0)) 892 (set result0 (expr (subword SI rm 1))) 893 (set result1 (expr (subword SI rm 0))) 894 (set rd (-join-si result1 result0)))) 895 896 ; Multimedia instructions. 897 898 (dshmi mabsl "Multimedia absolute value (long word)" 899 () 900 "mabs.l $rm, $rd" 901 (+ (f-op 10) rm (f-ext 10) (f-right 63) rd (f-rsvd 0)) 902 (slice-long-unop abs)) 903 904 (dshmi mabsw "Multimedia absolute value (word)" 905 () 906 "mabs.w $rm, $rd" 907 (+ (f-op 10) rm (f-ext 9) (f-right 63) rd (f-rsvd 0)) 908 (slice-word-unop abs)) 909 910 (dshmi maddl "Multimedia add (long word)" 911 () 912 "madd.l $rm, $rn, $rd" 913 (+ (f-op 2) rm (f-ext 2) rn rd (f-rsvd 0)) 914 (slice-long add)) 915 916 (dshmi maddw "Multimedia add (word)" 917 () 918 "madd.w $rm, $rn, $rd" 919 (+ (f-op 2) rm (f-ext 1) rn rd (f-rsvd 0)) 920 (slice-word add)) 921 922 (define-pmacro (-maddsl arg1 arg2) (saturate SI 32 (add arg1 arg2))) 923 (dshmi maddsl "Multimedia add (saturating, long word)" 924 () 925 "madds.l $rm, $rn, $rd" 926 (+ (f-op 2) rm (f-ext 6) rn rd (f-rsvd 0)) 927 (slice-long -maddsl)) 928 929 (define-pmacro (-maddsub arg1 arg2) (usaturate QI 8 (add arg1 arg2))) 930 (dshmi maddsub "Multimedia add (saturating, unsigned byte)" 931 () 932 "madds.ub $rm, $rn, $rd" 933 (+ (f-op 2) rm (f-ext 4) rn rd (f-rsvd 0)) 934 (slice-byte -maddsub)) 935 936 (define-pmacro (-maddsw arg1 arg2) (saturate HI 16 (add arg1 arg2))) 937 (dshmi maddsw "Multimedia add (saturating, word)" 938 () 939 "madds.w $rm, $rn, $rd" 940 (+ (f-op 2) rm (f-ext 5) rn rd (f-rsvd 0)) 941 (slice-word -maddsw)) 942 943 (define-pmacro (-mcmpeq mode arg1 arg2) 944 (if mode (eq arg1 arg2) (inv mode 0) (const mode 0))) 945 946 (define-pmacro (-mcmpeqb arg1 arg2) (-mcmpeq QI arg1 arg2)) 947 (dshmi mcmpeqb "Multimedia compare equal (byte)" 948 () 949 "mcmpeq.b $rm, $rn, $rd" 950 (+ (f-op 10) rm (f-ext 0) rn rd (f-rsvd 0)) 951 (slice-byte -mcmpeqb)) 952 953 (define-pmacro (-mcmpeql arg1 arg2) (-mcmpeq SI arg1 arg2)) 954 (dshmi mcmpeql "Multimedia compare equal (long word)" 955 () 956 "mcmpeq.l $rm, $rn, $rd" 957 (+ (f-op 10) rm (f-ext 2) rn rd (f-rsvd 0)) 958 (slice-long -mcmpeql)) 959 960 (define-pmacro (-mcmpeqw arg1 arg2) (-mcmpeq HI arg1 arg2)) 961 (dshmi mcmpeqw "Multimedia compare equal (word)" 962 () 963 "mcmpeq.w $rm, $rn, $rd" 964 (+ (f-op 10) rm (f-ext 1) rn rd (f-rsvd 0)) 965 (slice-word -mcmpeqw)) 966 967 (define-pmacro (-mcmpgt mode arg1 arg2) 968 (if mode (gt arg1 arg2) (inv mode 0) (const mode 0))) 969 (define-pmacro (-mcmpgtu mode arg1 arg2) 970 (if mode (gtu arg1 arg2) (inv mode 0) (const mode 0))) 971 972 (define-pmacro (-mcmpgtl arg1 arg2) (-mcmpgt SI arg1 arg2)) 973 (dshmi mcmpgtl "Multimedia compare greater than (long word)" 974 () 975 "mcmpgt.l $rm, $rn, $rd" 976 (+ (f-op 10) rm (f-ext 6) rn rd (f-rsvd 0)) 977 (slice-long -mcmpgtl)) 978 979 (define-pmacro (-mcmpgtub arg1 arg2) (-mcmpgtu QI arg1 arg2)) 980 (dshmi mcmpgtub "Multimediate compare unsigned greater than (byte)" 981 () 982 "mcmpgt.ub $rm, $rn, $rd" 983 (+ (f-op 10) rm (f-ext 4) rn rd (f-rsvd 0)) 984 (slice-byte -mcmpgtub)) 985 986 (define-pmacro (-mcmpgtw arg1 arg2) (-mcmpgt HI arg1 arg2)) 987 (dshmi mcmpgtw "Multimedia compare greater than (word)" 988 () 989 "mcmpgt.w $rm, $rn, $rd" 990 (+ (f-op 10) rm (f-ext 5) rn rd (f-rsvd 0)) 991 (slice-word -mcmpgtw)) 992 993 (dshmi mcmv "Multimedia conditional move" 994 () 995 "mcmv $rm, $rn, $rd" 996 (+ (f-op 18) rm (f-ext 3) rn rd (f-rsvd 0)) 997 (set rd (or (and rm rn) (and rd (inv rn))))) 998 999 (dshmi mcnvslw "Multimedia convert/saturate (long to word)" 1000 () 1001 "mcnvs.lw $rm, $rn, $rd" 1002 (+ (f-op 19) rm (f-ext 13) rn rd (f-rsvd 0)) 1003 (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) 1004 (set result0 (saturate HI 16 (subword SI rm 0))) 1005 (set result1 (saturate HI 16 (subword SI rm 1))) 1006 (set result2 (saturate HI 16 (subword SI rn 0))) 1007 (set result3 (saturate HI 16 (subword SI rn 1))) 1008 (set rd (-join-hi result3 result2 result1 result0)))) 1009 1010 (dshmi mcnvswb "Multimedia convert/saturate (word to byte)" 1011 () 1012 "mcnvs.wb $rm, $rn, $rd" 1013 (+ (f-op 19) rm (f-ext 8) rn rd (f-rsvd 0)) 1014 (sequence ((QI result7) (QI result6) (QI result5) (QI result4) 1015 (QI result3) (QI result2) (QI result1) (QI result0)) 1016 (set result0 (saturate QI 8 (subword HI rm 0))) 1017 (set result1 (saturate QI 8 (subword HI rm 1))) 1018 (set result2 (saturate QI 8 (subword HI rm 2))) 1019 (set result3 (saturate QI 8 (subword HI rm 3))) 1020 (set result4 (saturate QI 8 (subword HI rn 0))) 1021 (set result5 (saturate QI 8 (subword HI rn 1))) 1022 (set result6 (saturate QI 8 (subword HI rn 2))) 1023 (set result7 (saturate QI 8 (subword HI rn 3))) 1024 (set rd (-join-qi result7 result6 result5 result4 1025 result3 result2 result1 result0)))) 1026 1027 (dshmi mcnvswub "Multimedia convert/saturate (word to unsigned byte)" 1028 () 1029 "mcnvs.wub $rm, $rn, $rd" 1030 (+ (f-op 19) rm (f-ext 12) rn rd (f-rsvd 0)) 1031 (sequence ((QI result7) (QI result6) (QI result5) (QI result4) 1032 (QI result3) (QI result2) (QI result1) (QI result0)) 1033 (set result0 (usaturate QI 8 (subword HI rm 0))) 1034 (set result1 (usaturate QI 8 (subword HI rm 1))) 1035 (set result2 (usaturate QI 8 (subword HI rm 2))) 1036 (set result3 (usaturate QI 8 (subword HI rm 3))) 1037 (set result4 (usaturate QI 8 (subword HI rn 0))) 1038 (set result5 (usaturate QI 8 (subword HI rn 1))) 1039 (set result6 (usaturate QI 8 (subword HI rn 2))) 1040 (set result7 (usaturate QI 8 (subword HI rn 3))) 1041 (set rd (-join-qi result7 result6 result5 result4 result3 1042 result2 result1 result0)))) 1043 1044 ; mexter -- generate an mexterN instruction, where: 1045 ; op = primary opcode 1046 ; extop = extended opcode 1047 1048 (define-pmacro (make-mextr n op extop) 1049 (dshmi (.sym mextr n) 1050 (.str "Multimedia extract 64-bit slice (from byte " n ")") 1051 () 1052 (.str "mextr" n " $rm, $rn, $rd") 1053 (+ (f-op op) rm (f-ext extop) rn rd (f-rsvd 0)) 1054 (sequence ((QI count) (DI mask) (DI rhs)) 1055 (set count (mul QI 8 (sub QI 8 n))) 1056 (set mask (sll DI (inv 0) count)) 1057 (set rhs (srl (and rm mask) count)) 1058 (set count (mul QI 8 n)) 1059 (set mask (srl DI (inv 0) count)) 1060 (set rd (or DI rhs (sll DI (and rn mask) count)))))) 1061 1062 (make-mextr 1 10 7) 1063 (make-mextr 2 10 11) 1064 (make-mextr 3 10 15) 1065 (make-mextr 4 11 3) 1066 (make-mextr 5 11 7) 1067 (make-mextr 6 11 11) 1068 (make-mextr 7 11 15) 1069 1070 (dshmi mmacfxwl "Multimedia fractional multiply (word to long)" 1071 () 1072 "mmacfx.wl $rm, $rn, $rd" 1073 (+ (f-op 18) rm (f-ext 1) rn rd (f-rsvd 0)) 1074 (sequence ((SI temp) (SI result1) (SI result0)) 1075 (set result0 (subword SI rd 0)) 1076 (set result1 (subword SI rd 1)) 1077 (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) 1078 (set temp (saturate SI 32 (sll temp 1))) 1079 (set result0 (saturate SI 32 (add result0 temp))) 1080 (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) 1081 (set temp (saturate SI 32 (sll temp 1))) 1082 (set result1 (saturate SI 32 (add result1 temp))) 1083 (set rd (-join-si result1 result0)))) 1084 1085 (dshmi mmacnfx.wl "Multimedia fractional multiple (word to long)" 1086 () 1087 "mmacnfx.wl $rm, $rn, $rd" 1088 (+ (f-op 18) rn (f-ext 5) rn rd (f-rsvd 0)) 1089 (sequence ((SI temp) (SI result1) (SI result0)) 1090 (set result0 (subword SI rd 0)) 1091 (set result1 (subword SI rd 1)) 1092 (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) 1093 (set temp (saturate SI 32 (sll temp 1))) 1094 (set result0 (saturate SI 32 (sub result0 temp))) 1095 (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) 1096 (set temp (saturate SI 32 (sll temp 1))) 1097 (set result1 (saturate SI 32 (sub result1 temp))) 1098 (set rd (-join-si result1 result0)))) 1099 1100 (dshmi mmull "Multimedia multiply (long word)" 1101 () 1102 "mmul.l $rm, $rn, $rd" 1103 (+ (f-op 19) rm (f-ext 2) rn rd (f-rsvd 0)) 1104 (slice-long mul)) 1105 1106 (dshmi mmulw "Multimedia multiply (word)" 1107 () 1108 "mmul.w $rm, $rn, $rd" 1109 (+ (f-op 19) rm (f-ext 1) rn rd (f-rsvd 0)) 1110 (slice-word mul)) 1111 1112 (dshmi mmulfxl "Multimedia fractional multiply (long word)" 1113 () 1114 "mmulfx.l $rm, $rn, $rd" 1115 (+ (f-op 19) rm (f-ext 6) rn rd (f-rsvd 0)) 1116 (sequence ((DI temp) (SI result0) (SI result1)) 1117 (set temp (mul (zext DI (subword SI rm 0)) (zext DI (subword SI rn 0)))) 1118 (set result0 (saturate SI 32 (sra temp 31))) 1119 (set temp (mul (zext DI (subword SI rm 1)) (zext DI (subword SI rn 1)))) 1120 (set result1 (saturate SI 32 (sra temp 31))) 1121 (set rd (-join-si result1 result0)))) 1122 1123 (dshmi mmulfxw "Multimedia fractional multiply (word)" 1124 () 1125 "mmulfx.w $rm, $rn, $rd" 1126 (+ (f-op 19) rm (f-ext 5) rn rd (f-rsvd 0)) 1127 (sequence ((SI temp) (HI result0) (HI result1) (HI result2) (HI result3)) 1128 (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) 1129 (set result0 (saturate HI 16 (sra temp 15))) 1130 (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) 1131 (set result1 (saturate HI 16 (sra temp 15))) 1132 (set temp (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))) 1133 (set result2 (saturate HI 16 (sra temp 15))) 1134 (set temp (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))) 1135 (set result3 (saturate HI 16 (sra temp 15))) 1136 (set rd (-join-hi result3 result2 result1 result0)))) 1137 1138 (dshmi mmulfxrpw "Multimedia fractional multiply round positive (word op)" 1139 () 1140 "mmulfxrp.w $rm, $rn, $rd" 1141 (+ (f-op 19) rm (f-ext 9) rn rd (f-rsvd 0)) 1142 (sequence ((SI temp) (HI result0) (HI result1) (HI result2) (HI result3) (HI c)) 1143 (set c (sll 1 14)) 1144 (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) 1145 (set result0 (saturate HI 16 (sra (add temp c) 15))) 1146 (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) 1147 (set result1 (saturate HI 16 (sra (add temp c) 15))) 1148 (set temp (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))) 1149 (set result2 (saturate HI 16 (sra (add temp c) 15))) 1150 (set temp (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))) 1151 (set result3 (saturate HI 16 (sra (add temp c) 15))) 1152 (set rd (-join-hi result3 result2 result1 result0)))) 1153 1154 (dshmi mmulhiwl "Multimedia multiply higher halves (word to long)" 1155 () 1156 "mmulhi.wl $rm, $rn, $rd" 1157 (+ (f-op 19) rm (f-ext 14) rn rd (f-rsvd 0)) 1158 (sequence ((SI result1) (SI result0)) 1159 (set result0 (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))) 1160 (set result1 (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))) 1161 (set rd (-join-si result1 result0)))) 1162 1163 (dshmi mmullowl "Multimedia multiply lower halves (word to long)" 1164 () 1165 "mmullo.wl $rm, $rn, $rd" 1166 (+ (f-op 19) rm (f-ext 10) rn rd (f-rsvd 0)) 1167 (sequence ((SI result1) (SI result0)) 1168 (set result0 (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) 1169 (set result1 (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) 1170 (set rd (-join-si result1 result0)))) 1171 1172 (dshmi mmulsumwq "Multimedia multiply and accumulate (word to quad)" 1173 () 1174 "mmulsum.wq $rm, $rn, $rd" 1175 (+ (f-op 18) rm (f-ext 9) rn rd (f-rsvd 0)) 1176 (sequence ((DI acc)) 1177 (set acc (mul SI (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) 1178 (set acc (add acc (mul SI (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))) 1179 (set acc (add acc (mul SI (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2))))) 1180 (set acc (add acc (mul SI (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3))))) 1181 (set rd (add rd acc)))) 1182 1183 (dshmi movi "Move immediate" 1184 () 1185 "movi $imm16, $rd" 1186 (+ (f-op 51) imm16 rd (f-rsvd 0)) 1187 (set rd (ext DI imm16))) 1188 1189 (dshmi mpermw "Multimedia permutate word" 1190 () 1191 "mperm.w $rm, $rn, $rd" 1192 (+ (f-op 10) rm (f-ext 13) rn rd (f-rsvd 0)) 1193 (sequence ((QI control) (HI result3) (HI result2) (HI result1) (HI result0)) 1194 (set control (and QI rn #x3f)) 1195 (set result0 (subword HI rm (sub 3 (and control 3)))) 1196 (set result1 (subword HI rm (sub 3 (and (srl control 2) 3)))) 1197 (set result2 (subword HI rm (sub 3 (and (srl control 4) 3)))) 1198 (set result3 (subword HI rm (sub 3 (and (srl control 6) 3)))) 1199 (set rd (-join-hi result3 result2 result1 result0)))) 1200 1201 (dshmi msadubq "Multimedia absolute difference (byte)" 1202 () 1203 "msad.ubq $rm, $rn, $rd" 1204 (+ (f-op 18) rm (f-ext 0) rn rd (f-rsvd 0)) 1205 (sequence ((DI acc)) 1206 (set acc (abs DI (sub (subword QI rm 0) (subword QI rn 1)))) 1207 (set acc (add DI acc (abs (sub (subword QI rm 1) (subword QI rn 1))))) 1208 (set acc (add DI acc (abs (sub (subword QI rm 2) (subword QI rn 2))))) 1209 (set acc (add DI acc (abs (sub (subword QI rm 3) (subword QI rn 3))))) 1210 (set acc (add DI acc (abs (sub (subword QI rm 4) (subword QI rn 4))))) 1211 (set acc (add DI acc (abs (sub (subword QI rm 5) (subword QI rn 5))))) 1212 (set acc (add DI acc (abs (sub (subword QI rm 6) (subword QI rn 6))))) 1213 (set acc (add DI acc (abs (sub (subword QI rm 7) (subword QI rn 7))))) 1214 (set rd (add rd acc)))) 1215 1216 (define-pmacro (-mshaldsl arg) (saturate SI 32 (sll arg (and rn 31)))) 1217 (dshmi mshaldsl "Multimedia saturating arithmetic left shift (long word)" 1218 () 1219 "mshalds.l $rm, $rn, $rd" 1220 (+ (f-op 3) rm (f-ext 6) rn rd (f-rsvd 0)) 1221 (slice-long-unop -mshaldsl)) 1222 1223 (define-pmacro (-mshaldsw arg) (saturate HI 16 (sll arg (and rn 15)))) 1224 (dshmi mshaldsw "Multimedia saturating arithmetic left shift (word)" 1225 () 1226 "mshalds.w $rm, $rn, $rd" 1227 (+ (f-op 3) rm (f-ext 5) rn rd (f-rsvd 0)) 1228 (slice-word-unop -mshaldsw)) 1229 1230 (define-pmacro (-mshardl arg) (sra arg (and rn 31))) 1231 (dshmi mshardl "Multimedia arithmetic right shift (long)" 1232 () 1233 "mshard.l $rm, $rn, $rd" 1234 (+ (f-op 3) rm (f-ext 10) rn rd (f-rsvd 0)) 1235 (slice-long-unop -mshardl)) 1236 1237 (define-pmacro (-mshardw arg) (sra arg (and rn 15))) 1238 (dshmi mshardw "Multimedia arithmetic right shift (word)" 1239 () 1240 "mshard.w $rm, $rn, $rd" 1241 (+ (f-op 3) rm (f-ext 9) rn rd (f-rsvd 0)) 1242 (slice-word-unop -mshardw)) 1243 1244 (dshmi mshardsq "Multimedia saturating arithmetic right shift (quad word)" 1245 () 1246 "mshards.q $rm, $rn, $rd" 1247 (+ (f-op 3) rm (f-ext 11) rn rd (f-rsvd 0)) 1248 (set rd (saturate DI 16 (sra rm (and rn 63))))) 1249 1250 (dshmi mshfhib "Multimedia shuffle higher-half (byte)" 1251 () 1252 "mshfhi.b $rm, $rn, $rd" 1253 (+ (f-op 11) rm (f-ext 4) rn rd (f-rsvd 0)) 1254 (sequence ((QI result7) (QI result6) (QI result5) (QI result4) 1255 (QI result3) (QI result2) (QI result1) (QI result0)) 1256 (set result0 (subword QI rm 4)) 1257 (set result1 (subword QI rn 4)) 1258 (set result2 (subword QI rm 5)) 1259 (set result3 (subword QI rn 5)) 1260 (set result4 (subword QI rm 6)) 1261 (set result5 (subword QI rn 6)) 1262 (set result6 (subword QI rm 7)) 1263 (set result7 (subword QI rn 7)) 1264 (set rd (-join-qi result7 result6 result5 result4 result3 1265 result2 result1 result0)))) 1266 1267 (dshmi mshfhil "Multimedia shuffle higher-half (long)" 1268 () 1269 "mshfhi.l $rm, $rn, $rd" 1270 (+ (f-op 11) rm (f-ext 6) rn rd (f-rsvd 0)) 1271 (sequence ((SI result1) (SI result0)) 1272 (set result0 (subword SI rm 1)) 1273 (set result1 (subword SI rn 1)) 1274 (set rd (-join-si result1 result0)))) 1275 1276 (dshmi mshfhiw "Multimedia shuffle higher-half (word)" 1277 () 1278 "mshfhi.w $rm, $rn, $rd" 1279 (+ (f-op 11) rm (f-ext 5) rn rd (f-rsvd 0)) 1280 (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) 1281 (set result0 (subword HI rm 2)) 1282 (set result1 (subword HI rn 2)) 1283 (set result2 (subword HI rm 3)) 1284 (set result3 (subword HI rn 3)) 1285 (set rd (-join-hi result3 result2 result1 result0)))) 1286 1287 (dshmi mshflob "Multimedia shuffle lower-half (byte)" 1288 () 1289 "mshflo.b $rm, $rn, $rd" 1290 (+ (f-op 11) rm (f-ext 0) rn rd (f-rsvd 0)) 1291 (sequence ((QI result7) (QI result6) (QI result5) (QI result4) 1292 (QI result3) (QI result2) (QI result1) (QI result0)) 1293 (set result0 (subword QI rm 0)) 1294 (set result1 (subword QI rn 0)) 1295 (set result2 (subword QI rm 1)) 1296 (set result3 (subword QI rn 1)) 1297 (set result4 (subword QI rm 2)) 1298 (set result5 (subword QI rn 2)) 1299 (set result6 (subword QI rm 3)) 1300 (set result7 (subword QI rn 3)) 1301 (set rd (-join-qi result7 result6 result5 result4 result3 1302 result2 result1 result0)))) 1303 1304 (dshmi mshflol "Multimedia shuffle lower-half (long)" 1305 () 1306 "mshflo.l $rm, $rn, $rd" 1307 (+ (f-op 11) rm (f-ext 2) rn rd (f-rsvd 0)) 1308 (sequence ((SI result1) (SI result0)) 1309 (set result0 (subword SI rm 0)) 1310 (set result1 (subword SI rn 0)) 1311 (set rd (-join-si result1 result0)))) 1312 1313 (dshmi mshflow "Multimedia shuffle lower-half (word)" 1314 () 1315 "mshflo.w $rm, $rn, $rd" 1316 (+ (f-op 11) rm (f-ext 1) rn rd (f-rsvd 0)) 1317 (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) 1318 (set result0 (subword HI rm 0)) 1319 (set result1 (subword HI rn 0)) 1320 (set result2 (subword HI rm 1)) 1321 (set result3 (subword HI rn 1)) 1322 (set rd (-join-hi result3 result2 result1 result0)))) 1323 1324 (define-pmacro (-mshlldl arg) (sll arg (and rn 31))) 1325 (dshmi mshlldl "Multimedia logical left shift (long word)" 1326 () 1327 "mshlld.l $rm, $rn, $rd" 1328 (+ (f-op 3) rm (f-ext 2) rn rd (f-rsvd 0)) 1329 (slice-long-unop -mshlldl)) 1330 1331 (define-pmacro (-mshlldw arg) (sll arg (and rn 15))) 1332 (dshmi mshlldw "Multimedia logical left shift (word)" 1333 () 1334 "mshlld.w $rm, $rn, $rd" 1335 (+ (f-op 3) rm (f-ext 1) rn rd (f-rsvd 0)) 1336 (slice-word-unop -mshlldw)) 1337 1338 (define-pmacro (-mshlrdl arg) (srl arg (and rn 31))) 1339 (dshmi mshlrdl "Multimedia logical right shift (long word)" 1340 () 1341 "mshlrd.l $rm, $rn, $rd" 1342 (+ (f-op 3) rm (f-ext 14) rn rd (f-rsvd 0)) 1343 (slice-long-unop -mshlrdl)) 1344 1345 (define-pmacro (-mshlrdw arg) (srl arg (and rn 15))) 1346 (dshmi mshlrdw "Multimedia logical right shift (word)" 1347 () 1348 "mshlrd.w $rm, $rn, $rd" 1349 (+ (f-op 3) rm (f-ext 13) rn rd (f-rsvd 0)) 1350 (slice-word-unop -mshlrdw)) 1351 1352 (dshmi msubl "Multimedia subtract (long word)" 1353 () 1354 "msub.l $rm, $rn, $rd" 1355 (+ (f-op 2) rm (f-ext 10) rn rd (f-rsvd 0)) 1356 (slice-long sub)) 1357 1358 (dshmi msubw "Multimedia add (word)" 1359 () 1360 "msub.w $rm, $rn, $rd" 1361 (+ (f-op 2) rm (f-ext 9) rn rd (f-rsvd 0)) 1362 (slice-word sub)) 1363 1364 (define-pmacro (-msubsl arg1 arg2) (saturate SI 32 (sub arg1 arg2))) 1365 (dshmi msubsl "Multimedia subtract (saturating long)" 1366 () 1367 "msubs.l $rm, $rn, $rd" 1368 (+ (f-op 2) rm (f-ext 14) rn rd (f-rsvd 0)) 1369 (slice-long -msubsl)) 1370 1371 (define-pmacro (-msubsub arg1 arg2) (usaturate QI 8 (sub arg1 arg2))) 1372 (dshmi msubsub "Multimedia subtract (saturating byte)" 1373 () 1374 "msubs.ub $rm, $rn, $rd" 1375 (+ (f-op 2) rm (f-ext 12) rn rd (f-rsvd 0)) 1376 (slice-byte -msubsub)) 1377 1378 (define-pmacro (-msubsw arg1 arg2) (saturate HI 16 (sub arg1 arg2))) 1379 (dshmi msubsw "Multimedia subtract (saturating word)" 1380 () 1381 "msubs.w $rm, $rn, $rd" 1382 (+ (f-op 2) rm (f-ext 13) rn rd (f-rsvd 0)) 1383 (slice-byte -msubsw)) 1384 1385 (dshmi mulsl "Multiply signed long" 1386 () 1387 "muls.l $rm, $rn, $rd" 1388 (+ (f-op 1) rm (f-ext 14) rn rd (f-rsvd 0)) 1389 (set rd (mul (ext DI (subword SI rm 1)) (ext DI (subword SI rn 1))))) 1390 1391 (dshmi mulul "Multiply unsigned long" 1392 () 1393 "mulu.l $rm, $rn, $rd" 1394 (+ (f-op 0) rm (f-ext 14) rn rd (f-rsvd 0)) 1395 (set rd (mul (zext DI (subword SI rm 1)) (zext DI (subword SI rn 1))))) 1396 1397 (dshmi nop "No operation" 1398 () 1399 "nop" 1400 (+ (f-op 27) (f-left 63) (f-ext 0) (f-right 63) (f-dest 63) (f-rsvd 0)) 1401 (nop)) 1402 1403 (dshmi nsb "Number of consecutive sign bits" 1404 () 1405 "nsb $rm, $rd" 1406 (+ (f-op 0) rm (f-ext 13) (f-right 63) rd (f-rsvd 0)) 1407 ; Semantics requires a loop construct, so punt to C. 1408 (set rd (c-call DI "sh64_nsb" rm))) 1409 1410 (dshmi ocbi "Invalidate operand cache block" 1411 () 1412 "ocbi $rm, $disp6x32" 1413 (+ (f-op 56) rm (f-ext 9) disp6x32 (f-dest 63) (f-rsvd 0)) 1414 (unimp "ocbi")) 1415 1416 (dshmi ocbp "Purge operand cache block" 1417 () 1418 "ocbp $rm, $disp6x32" 1419 (+ (f-op 56) rm (f-ext 8) disp6x32 (f-dest 63) (f-rsvd 0)) 1420 (unimp "ocbp")) 1421 1422 (dshmi ocbwb "Write-back operand cache block" 1423 () 1424 "ocbwb $rm, $disp6x32" 1425 (+ (f-op 56) rm (f-ext 12) disp6x32 (f-dest 63) (f-rsvd 0)) 1426 (unimp "ocbwb")) 1427 1428 (dshmi or "OR" 1429 () 1430 "or $rm, $rn, $rd" 1431 (+ (f-op 1) rm (f-ext 9) rn rd (f-rsvd 0)) 1432 (set rd (or rm rn))) 1433 1434 (dshmi ori "OR immediate" 1435 () 1436 "ori $rm, $imm10, $rd" 1437 (+ (f-op 55) rm imm10 rd (f-rsvd 0)) 1438 (set rd (or rm (ext DI imm10)))) 1439 1440 (dshmi prefi "Prefetch instruction" 1441 () 1442 "prefi $rm, $disp6x32" 1443 (+ (f-op 56) rm (f-ext 1) disp6x32 (f-right 63) (f-rsvd 0)) 1444 (unimp "prefi")) 1445 1446 (dshmi pta "Prepare target register for SHmedia target" 1447 () 1448 "pta$likely $disp16, $tra" 1449 (+ (f-op 58) disp16 likely (f-8-2 0) tra (f-rsvd 0)) 1450 (set tra (add disp16 1))) 1451 1452 (dshmi ptabs "Prepare target register with absolute value from register" 1453 () 1454 "ptabs$likely $rn, $tra" 1455 (+ (f-op 26) (f-left 63) (f-ext 1) rn likely (f-8-2 0) tra (f-rsvd 0)) 1456 (set tra rn)) 1457 1458 (dshmi ptb "Prepare target register for SHcompact target" 1459 () 1460 "ptb$likely $disp16, $tra" 1461 (+ (f-op 59) disp16 likely (f-8-2 0) tra (f-rsvd 0)) 1462 (set tra disp16)) 1463 1464 (dshmi ptrel "Prepare target register with relative value from register" 1465 () 1466 "ptrel$likely $rn, $tra" 1467 (+ (f-op 26) (f-left 63) (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0)) 1468 (set tra (add pc rn))) 1469 1470 (dshmi putcfg "Put configuration register" 1471 () 1472 "putcfg $rm, $disp6, $rd" 1473 (+ (f-op 56) rm (f-ext 15) disp6 rd (f-rsvd 0)) 1474 (unimp "putcfg")) 1475 1476 (dshmi putcon "Put control register" 1477 () 1478 "putcon $rm, $crj" 1479 (+ (f-op 27) rm (f-ext 15) (f-right 63) crj (f-rsvd 0)) 1480 (set crj rm)) 1481 1482 (dshmi rte "Return from exception" 1483 () 1484 "rte" 1485 (+ (f-op 27) (f-left 63) (f-ext 3) (f-right 63) (f-dest 63) (f-rsvd 0)) 1486 (unimp "rte")) 1487 1488 (dshmi shard "Arithmetic right shift" 1489 () 1490 "shard $rm, $rn, $rd" 1491 (+ (f-op 1) rm (f-ext 7) rn rd (f-rsvd 0)) 1492 (set rd (sra rm (and rn 63)))) 1493 1494 (dshmi shardl "Arithmetic right shift (long word)" 1495 () 1496 "shard.l $rm, $rn, $rd" 1497 (+ (f-op 1) rm (f-ext 6) rn rd (f-rsvd 0)) 1498 (set rd (ext DI (sra (subword SI rm 1) (and rn 63))))) 1499 1500 (dshmi shari "Arithmetic right shift (immediate count)" 1501 () 1502 "shari $rm, $uimm6, $rd" 1503 (+ (f-op 49) rm (f-ext 7) uimm6 rd (f-rsvd 0)) 1504 (set rd (sra rm uimm6))) 1505 1506 (dshmi sharil "Arithmetic right shift (long word, immediate count)" 1507 () 1508 "shari.l $rm, $uimm6, $rd" 1509 (+ (f-op 49) rm (f-ext 6) uimm6 rd (f-rsvd 0)) 1510 (set rd (ext DI (sra (subword SI rm 1) (and uimm6 63))))) 1511 1512 (dshmi shlld "Logical left shift" 1513 () 1514 "shlld $rm, $rn, $rd" 1515 (+ (f-op 1) rm (f-ext 1) rn rd (f-rsvd 0)) 1516 (set rd (sll rm (and rn 63)))) 1517 1518 (dshmi shlldl "Logical left shift (long word)" 1519 () 1520 "shlld.l $rm, $rn, $rd" 1521 (+ (f-op 1) rm (f-ext 0) rn rd (f-rsvd 0)) 1522 (set rd (ext DI (sll (subword SI rm 1) (and rn 63))))) 1523 1524 (dshmi shlli "Logical left shift (immediate count)" 1525 () 1526 "shlli $rm, $uimm6, $rd" 1527 (+ (f-op 49) rm (f-ext 1) uimm6 rd (f-rsvd 0)) 1528 (set rd (sll rm uimm6))) 1529 1530 (dshmi shllil "Logical left shift (long word, immediate count)" 1531 () 1532 "shlli.l $rm, $uimm6, $rd" 1533 (+ (f-op 49) rm (f-ext 0) uimm6 rd (f-rsvd 0)) 1534 (set rd (ext DI (sll (subword SI rm 1) (and uimm6 63))))) 1535 1536 (dshmi shlrd "Logical right shift" 1537 () 1538 "shlrd $rm, $rn, $rd" 1539 (+ (f-op 1) rm (f-ext 3) rn rd (f-rsvd 0)) 1540 (set rd (srl rm (and rn 63)))) 1541 1542 (dshmi shlrdl "Logical right shift (long word)" 1543 () 1544 "shlrd.l $rm, $rn, $rd" 1545 (+ (f-op 1) rm (f-ext 2) rn rd (f-rsvd 0)) 1546 (set rd (ext DI (srl (subword SI rm 1) (and rn 63))))) 1547 1548 (dshmi shlri "Logical right shift (immediate count)" 1549 () 1550 "shlri $rm, $uimm6, $rd" 1551 (+ (f-op 49) rm (f-ext 3) uimm6 rd (f-rsvd 0)) 1552 (set rd (srl rm uimm6))) 1553 1554 (dshmi shlril "Logical right shift (long word, immediate count)" 1555 () 1556 "shlri.l $rm, $uimm6, $rd" 1557 (+ (f-op 49) rm (f-ext 2) uimm6 rd (f-rsvd 0)) 1558 (set rd (ext DI (srl (subword SI rm 1) (and uimm6 63))))) 1559 1560 (dshmi shori "Shift-or immediate" 1561 () 1562 "shori $uimm16, $rd" 1563 (+ (f-op 50) uimm16 rd (f-rsvd 0)) 1564 (set rd (or (sll rd 16) (zext DI uimm16)))) 1565 1566 (dshmi sleep "Sleep" 1567 () 1568 "sleep" 1569 (+ (f-op 27) (f-left 63) (f-ext 7) (f-right 63) (f-dest 63) (f-rsvd 0)) 1570 (unimp "sleep")) 1571 1572 (dshmi stb "Store byte" 1573 () 1574 "st.b $rm, $disp10, $rd" 1575 (+ (f-op 40) rm disp10 rd (f-rsvd 0)) 1576 (set (mem UQI (add rm (ext DI disp10))) (and QI rd #xff))) 1577 1578 (dshmi stl "Store long word" 1579 () 1580 "st.l $rm, $disp10x4, $rd" 1581 (+ (f-op 42) rm disp10x4 rd (f-rsvd 0)) 1582 (set (mem SI (add rm (ext DI disp10x4))) (and SI rd #xffffffff))) 1583 1584 (dshmi stq "Store quad word" 1585 () 1586 "st.q $rm, $disp10x8, $rd" 1587 (+ (f-op 43) rm disp10x8 rd (f-rsvd 0)) 1588 (set (mem DI (add rm (ext DI disp10x8))) rd)) 1589 1590 (dshmi stw "Store word" 1591 () 1592 "st.w $rm, $disp10x2, $rd" 1593 (+ (f-op 41) rm disp10x2 rd (f-rsvd 0)) 1594 (set (mem HI (add rm (ext DI disp10x2))) (and HI rd #xffff))) 1595 1596 (define-pmacro (-sthi-byte) 1597 (sequence () 1598 (set (mem UQI addr) (and QI val #xff)) 1599 (set val (srl val 8)) 1600 (set addr (add addr 1)))) 1601 1602 (dshmi sthil "Store high part (long word)" 1603 () 1604 "sthi.l $rm, $disp6, $rd" 1605 (+ (f-op 56) rm (f-ext 6) disp6 rd (f-rsvd 0)) 1606 (sequence ((DI addr) (QI bytecount) (DI val)) 1607 (set addr (add rm disp6)) 1608 (set bytecount (add (and addr 3) 1)) 1609 (if endian 1610 (set val rd) 1611 (set val (srl rd (sub 32 (mul 8 bytecount))))) 1612 (set addr (add (sub addr bytecount) 1)) 1613 (if (gt bytecount 3) 1614 (-sthi-byte)) 1615 (if (gt bytecount 2) 1616 (-sthi-byte)) 1617 (if (gt bytecount 1) 1618 (-sthi-byte)) 1619 (if (gt bytecount 0) 1620 (-sthi-byte)))) 1621 1622 (dshmi sthiq "Store high part (quad word)" 1623 () 1624 "sthi.q $rm, $disp6, $rd" 1625 (+ (f-op 56) rm (f-ext 7) disp6 rd (f-rsvd 0)) 1626 (sequence ((DI addr) (QI bytecount) (DI val)) 1627 (set addr (add rm disp6)) 1628 (set bytecount (add (and addr 7) 1)) 1629 (if endian 1630 (set val rd) 1631 (set val (srl rd (sub 64 (mul 8 bytecount))))) 1632 (set addr (add (sub addr bytecount) 1)) 1633 (if (gt bytecount 7) 1634 (-sthi-byte)) 1635 (if (gt bytecount 6) 1636 (-sthi-byte)) 1637 (if (gt bytecount 5) 1638 (-sthi-byte)) 1639 (if (gt bytecount 4) 1640 (-sthi-byte)) 1641 (if (gt bytecount 3) 1642 (-sthi-byte)) 1643 (if (gt bytecount 2) 1644 (-sthi-byte)) 1645 (if (gt bytecount 1) 1646 (-sthi-byte)) 1647 (if (gt bytecount 0) 1648 (-sthi-byte)))) 1649 1650 (dshmi stlol "Store low part (long word)" 1651 () 1652 "stlo.l $rm, $disp6, $rd" 1653 (+ (f-op 56) rm (f-ext 2) disp6 rd (f-rsvd 0)) 1654 ; FIXME. 1655 (unimp "stlol")) 1656 1657 (dshmi stloq "Store low part (quad word)" 1658 () 1659 "stlo.q $rm, $disp6, $rd" 1660 (+ (f-op 56) rm (f-ext 3) disp6 rd (f-rsvd 0)) 1661 ; FIXME. 1662 (unimp "stloq")) 1663 1664 (dshmi stxb "Store byte (extended displacement)" 1665 () 1666 "stx.b $rm, $rn, $rd" 1667 (+ (f-op 24) rm (f-ext 0) rn rd (f-rsvd 0)) 1668 (set (mem UQI (add rm rn)) (subword QI rd 7))) 1669 1670 (dshmi stxl "Store long (extended displacement)" 1671 () 1672 "stx.l $rm, $rn, $rd" 1673 (+ (f-op 24) rm (f-ext 2) rn rd (f-rsvd 0)) 1674 (set (mem SI (add rm rn)) (subword SI rd 1))) 1675 1676 (dshmi stxq "Store quad word (extended displacement)" 1677 () 1678 "stx.q $rm, $rn, $rd" 1679 (+ (f-op 24) rm (f-ext 3) rn rd (f-rsvd 0)) 1680 (set (mem DI (add rm rn)) rd)) 1681 1682 (dshmi stxw "Store word (extended displacement)" 1683 () 1684 "stx.w $rm, $rn, $rd" 1685 (+ (f-op 24) rm (f-ext 1) rn rd (f-rsvd 0)) 1686 (set (mem HI (add rm rn)) (subword HI rd 3))) 1687 1688 (dshmi sub "Subtract" 1689 () 1690 "sub $rm, $rn, $rd" 1691 (+ (f-op 0) rm (f-ext 11) rn rd (f-rsvd 0)) 1692 (set rd (sub rm rn))) 1693 1694 (dshmi subl "Subtract long" 1695 () 1696 "sub.l $rm, $rn, $rd" 1697 (+ (f-op 0) rm (f-ext 10) rn rd (f-rsvd 0)) 1698 (set rd (ext DI (sub (subword SI rm 1) (subword SI rn 1))))) 1699 1700 (dshmi swapq "Swap quad words" 1701 () 1702 "swap.q $rm, $rn, $rd" 1703 (+ (f-op 8) rm (f-ext 3) rn rd (f-rsvd 0)) 1704 (sequence ((DI addr) (DI temp)) 1705 (set addr (add rm rn)) 1706 (set temp (mem DI addr)) 1707 (set (mem DI addr) rd) 1708 (set rd temp))) 1709 1710 (dshmi synci "Synchronise instruction fetch" 1711 () 1712 "synci" 1713 (+ (f-op 27) (f-left 63) (f-ext 2) (f-right 63) (f-dest 63) (f-rsvd 0)) 1714 (unimp "synci")) 1715 1716 (dshmi synco "Synchronise data operations" 1717 () 1718 "synco" 1719 (+ (f-op 27) (f-left 63) (f-ext 6) (f-right 63) (f-dest 63) (f-rsvd 0)) 1720 (unimp "synco")) 1721 1722 (dshmi trapa "Trap" 1723 () 1724 "trapa $rm" 1725 (+ (f-op 27) rm (f-ext 1) (f-right 63) (f-dest 63) (f-rsvd 0)) 1726 (c-call "sh64_trapa" rm pc)) 1727 1728 (dshmi xor "Exclusive OR" 1729 () 1730 "xor $rm, $rn, $rd" 1731 (+ (f-op 1) rm (f-ext 13) rn rd (f-rsvd 0)) 1732 (set rd (xor rm rn))) 1733 1734 (dshmi xori "Exclusive OR immediate" 1735 () 1736 "xori $rm, $imm6, $rd" 1737 (+ (f-op 49) rm (f-ext 13) rn rd (f-rsvd 0)) 1738 (set rd (xor rm (ext DI imm6)))) 1739