123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734 |
- ; Hitachi SHmedia instruction set description. -*- Scheme -*-
- ;
- ; Copyright 2000, 2001, 2007, 2009 Free Software Foundation, Inc.
- ;
- ; Contributed by Red Hat Inc; developed under contract from Hitachi
- ; Semiconductor (America) Inc.
- ;
- ; This file is part of the GNU Binutils.
- ;
- ; This program is free software; you can redistribute it and/or modify
- ; it under the terms of the GNU General Public License as published by
- ; the Free Software Foundation; either version 3 of the License, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License
- ; along with this program; if not, write to the Free Software
- ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
- ; MA 02110-1301, USA.
- ; dshmf -- define-normal-sh-media-field
- (define-pmacro (dshmf xname xcomment ignored xstart xlength)
- (dnf xname xcomment ((ISA media)) xstart xlength))
- ; dshmop -- define-normal-sh-media-operand
- (define-pmacro (dshmop xname xcomment ignored xhardware xfield)
- (dnop xname xcomment ((ISA media)) xhardware xfield))
- ; dnshmi -- define-normal-sh-media-insn
- (define-pmacro (dshmi xname xcomment xattrs xsyntax xformat xsemantics)
- (define-insn
- (name xname)
- (comment xcomment)
- (.splice attrs (.unsplice xattrs) (ISA media))
- (syntax xsyntax)
- (format xformat)
- (semantics xsemantics)))
- ; Saturation functions.
- ; Force a value `i' into words `n' bits wide.
- ; See Hitachi SH-5 CPU core, volume 2, p. 25 for details.
- ; saturate -- signed saturatation function
- (define-pmacro (saturate mode n i)
- (if mode (lt i (neg mode (sll mode 1 (sub n 1))))
- (neg (sll mode 1 (sub n 1)))
- (if mode (lt i (sll mode 1 (sub n 1)))
- i
- (sub mode (sll mode 1 (sub n 1)) 1))))
- ; usaturate -- unsigned saturation function
- (define-pmacro (usaturate mode n i)
- (if mode (lt i (const mode 0))
- (const mode 0)
- (if mode (lt i (sll mode 1 n))
- i
- (sub mode (sll mode 1 n) 1))))
- ; Ifields.
- (dshmf f-op "Opcode" () 31 6)
- (dshmf f-ext "Extension opcode" () 19 4)
- (dshmf f-rsvd "Reserved" (RESERVED) 3 4)
- (dshmf f-left "Left register" () 25 6)
- (dshmf f-right "Right register" () 15 6)
- (dshmf f-dest "Destination register" () 9 6)
- (define-multi-ifield
- (name f-left-right)
- (comment "Left and right matched register pair")
- (attrs (ISA media))
- (mode UINT)
- (subfields f-left f-right)
- (insert (sequence ()
- (set (ifield f-left)
- (and (ifield f-left-right) 63))
- (set (ifield f-right)
- (and (ifield f-left-right) 63))))
- (extract (set (ifield f-left-right) (ifield f-left)))
- )
- (dshmf f-tra "Target register" () 6 3)
- (dshmf f-trb "Target register" () 22 3)
- (dshmf f-likely "Likely bit" () 9 1)
- (dshmf f-25 "Three unused bits at bit 25" () 25 3)
- (dshmf f-8-2 "Two unused bits at bit 8" () 8 2)
- (df f-imm6 "Immediate value (6 bits)" ((ISA media)) 15 6 INT #f #f)
- (df f-imm10 "Immediate value (10 bits)" ((ISA media)) 19 10 INT #f #f)
- (df f-imm16 "Immediate value (16 bits)" ((ISA media)) 25 16 INT #f #f)
- (dshmf f-uimm6 "Immediate value (6 bits)" () 15 6)
- (dshmf f-uimm16 "Immediate value (16 bits)" () 25 16)
- ; Various displacement fields.
- ; The 10 bit field, for example, has different scaling for displacements.
- (df f-disp6 "Displacement (6 bits)" ((ISA media)) 15 6 INT #f #f)
- (df f-disp6x32 "Displacement (6 bits)" ((ISA media)) 15 6 INT
- ((value pc) (sra SI value 5))
- ((value pc) (sll SI value 5)))
- (df f-disp10 "Displacement (10 bits)" ((ISA media)) 19 10 INT #f #f)
- (df f-disp10x8 "Displacement (10 bits)" ((ISA media)) 19 10 INT
- ((value pc) (sra SI value 3))
- ((value pc) (sll SI value 3)))
- (df f-disp10x4 "Displacement (10 bits)" ((ISA media)) 19 10 INT
- ((value pc) (sra SI value 2))
- ((value pc) (sll SI value 2)))
- (df f-disp10x2 "Displacement (10 bits)" ((ISA media)) 19 10 INT
- ((value pc) (sra SI value 1))
- ((value pc) (sll SI value 1)))
- (df f-disp16 "Displacement (16 bits)" ((ISA media) PCREL-ADDR) 25 16 INT
- ((value pc) (sra DI value 2))
- ((value pc) (add DI (sll DI value 2) pc)))
- ; Operands.
- (dshmop rm "Left general purpose reg" () h-gr f-left)
- (dshmop rn "Right general purpose reg" () h-gr f-right)
- (dshmop rd "Destination general purpose reg" () h-gr f-dest)
- (dshmop frg "Left single precision register" () h-fr f-left)
- (dshmop frh "Right single precision register" () h-fr f-right)
- (dshmop frf "Destination single precision reg" () h-fr f-dest)
- (dshmop frgh "Single precision register pair" () h-fr f-left-right)
- (dshmop fpf "Pair of single precision registers" () h-fp f-dest)
- (dshmop fvg "Left single precision vector" () h-fv f-left)
- (dshmop fvh "Right single precision vector" () h-fv f-right)
- (dshmop fvf "Destination single precision vector" () h-fv f-dest)
- (dshmop mtrxg "Left single precision matrix" () h-fmtx f-left)
- (dshmop drg "Left double precision register" () h-dr f-left)
- (dshmop drh "Right double precision register" () h-dr f-right)
- (dshmop drf "Destination double precision reg" () h-dr f-dest)
- (dshmop drgh "Double precision register pair" () h-dr f-left-right)
- (dshmop fpscr "Floating point status register" () h-fpscr f-nil)
- (dshmop crj "Control register j" () h-cr f-dest)
- (dshmop crk "Control register k" () h-cr f-left)
- (dshmop tra "Target register a" () h-tr f-tra)
- (dshmop trb "Target register b" () h-tr f-trb)
- (dshmop disp6 "Displacement (6 bits)" () h-sint f-disp6)
- (dshmop disp6x32 "Displacement (6 bits, scale 32)" () h-sint f-disp6x32)
- (dshmop disp10 "Displacement (10 bits)" () h-sint f-disp10)
- (dshmop disp10x2 "Displacement (10 bits, scale 2)" () h-sint f-disp10x2)
- (dshmop disp10x4 "Displacement (10 bits, scale 4)" () h-sint f-disp10x4)
- (dshmop disp10x8 "Displacement (10 bits, scale 8)" () h-sint f-disp10x8)
- (dshmop disp16 "Displacement (16 bits)" () h-sint f-disp16)
- (dshmop imm6 "Immediate (6 bits)" () h-sint f-imm6)
- (dshmop imm10 "Immediate (10 bits)" () h-sint f-imm10)
- (dshmop imm16 "Immediate (16 bits)" () h-sint f-imm16)
- (dshmop uimm6 "Immediate (6 bits)" () h-uint f-uimm6)
- (dshmop uimm16 "Unsigned immediate (16 bits)" () h-uint f-uimm16)
- ; FIXME: provide these parse/print functions in `sh-media.opc'.
- (define-operand (name likely) (comment "Likely branch?") (attrs (ISA media))
- (type h-uint) (index f-likely) (handlers (parse "likely") (print "likely")))
- ; Instructions.
- (dshmi add "Add"
- ()
- "add $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 9) rn rd (f-rsvd 0))
- (set rd (add rm rn)))
- (dshmi addl "Add long"
- ()
- "add.l $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 8) rn rd (f-rsvd 0))
- (set rd (add (subword SI rm 1) (subword SI rn 1))))
- (dshmi addi "Add immediate"
- ()
- "addi $rm, $disp10, $rd"
- (+ (f-op 52) rm disp10 rd (f-rsvd 0))
- (set rd (add rm (ext DI disp10))))
- (dshmi addil "Add immediate long"
- ()
- "addi.l $rm, $disp10, $rd"
- (+ (f-op 53) rm disp10 rd (f-rsvd 0))
- (set rd (ext DI (add (ext SI disp10) (subword SI rm 1)))))
- (dshmi addzl "Add zero extended long"
- ()
- "addz.l $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 12) rn rd (f-rsvd 0))
- (set rd (zext DI (add (subword SI rm 1) (subword SI rn 1)))))
- (dshmi alloco "Allocate operand cache block"
- ()
- "alloco $rm, $disp6x32"
- (+ (f-op 56) rm (f-ext 4) disp6x32 (f-dest 63) (f-rsvd 0))
- (unimp "alloco"))
- (dshmi and "AND"
- ()
- "and $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 11) rn rd (f-rsvd 0))
- (set rd (and rm rn)))
- (dshmi andc "AND complement"
- ()
- "andc $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 15) rn rd (f-rsvd 0))
- (set rd (and rm (inv rn))))
- (dshmi andi "AND immediate"
- ()
- "andi $rm, $disp10, $rd"
- (+ (f-op 54) rm disp10 rd (f-rsvd 0))
- (set rd (and rm (ext DI disp10))))
- (dshmi beq "Branch if equal"
- ()
- "beq$likely $rm, $rn, $tra"
- (+ (f-op 25) rm (f-ext 1) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (eq rm rn)
- (set pc tra)))
- (dshmi beqi "Branch if equal immediate"
- ()
- "beqi$likely $rm, $imm6, $tra"
- (+ (f-op 57) rm (f-ext 1) imm6 likely (f-8-2 0) tra (f-rsvd 0))
- (if (eq rm (ext DI imm6))
- (set pc tra)))
- (dshmi bge "Branch if greater than or equal"
- ()
- "bge$likely $rm, $rn, $tra"
- (+ (f-op 25) rm (f-ext 3) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (ge rm rn)
- (set pc tra)))
- (dshmi bgeu "Branch if greater than or equal (unsigned comparison)"
- ()
- "bgeu$likely $rm, $rn, $tra"
- (+ (f-op 25) rm (f-ext 11) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (geu rm rn)
- (set pc tra)))
- (dshmi bgt "Branch greater than"
- ()
- "bgt$likely $rm, $rn, $tra"
- (+ (f-op 25) rm (f-ext 7) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (gt rm rn)
- (set pc tra)))
- (dshmi bgtu "Branch greater than (unsigned comparison)"
- ()
- "bgtu$likely $rm, $rn, $tra"
- (+ (f-op 25) rm (f-ext 15) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (gtu rm rn)
- (set pc tra)))
- (dshmi blink "Branch and link"
- ()
- "blink $trb, $rd"
- (+ (f-op 17) (f-25 0) trb (f-ext 1) (f-right 63) rd (f-rsvd 0))
- (sequence ()
- (set rd (or (add pc 4) 1))
- (set pc trb)))
- (dshmi bne "Branch if not equal"
- ()
- "bne$likely $rm, $rn, $tra"
- (+ (f-op 25) rm (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (ne rm rn)
- (set pc tra)))
- (dshmi bnei "Branch if not equal immediate"
- ()
- "bnei$likely $rm, $imm6, $tra"
- (+ (f-op 57) rm (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0))
- (if (ne rm (ext DI imm6))
- (set pc tra)))
- (dshmi brk "Breakpoint instruction"
- ()
- "brk"
- (+ (f-op 27) (f-left 63) (f-ext 5) (f-right 63) (f-dest 63) (f-rsvd 0))
- (c-call "sh64_break" pc))
- (define-pmacro (-byterev-step)
- (sequence ()
- (set result (or (sll result 8) (and source 255)))
- (set source (srl source 8)))
- )
- (dshmi byterev "Byte reverse"
- ()
- "byterev $rm, $rd"
- (+ (f-op 0) rm (f-ext 15) (f-right 63) rd (f-rsvd 0))
- (sequence ((DI source) (DI result))
- (set source rm)
- (set result 0)
- (-byterev-step)
- (-byterev-step)
- (-byterev-step)
- (-byterev-step)
- (-byterev-step)
- (-byterev-step)
- (-byterev-step)
- (-byterev-step)
- (set rd result)))
- (dshmi cmpeq "Compare equal"
- ()
- "cmpeq $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 1) rn rd (f-rsvd 0))
- (set rd (if DI (eq rm rn) 1 0)))
- (dshmi cmpgt "Compare greater than"
- ()
- "cmpgt $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 3) rn rd (f-rsvd 0))
- (set rd (if DI (gt rm rn) 1 0)))
- (dshmi cmpgtu "Compare greater than (unsigned comparison)"
- ()
- "cmpgtu $rm,$rn, $rd"
- (+ (f-op 0) rm (f-ext 7) rn rd (f-rsvd 0))
- (set rd (if DI (gtu rm rn) 1 0)))
- (dshmi cmveq "Conditional move if equal to zero"
- ()
- "cmveq $rm, $rn, $rd"
- (+ (f-op 8) rm (f-ext 1) rn rd (f-rsvd 0))
- (if (eq rm 0)
- (set rd rn)))
- (dshmi cmvne "Conditional move if not equal to zero"
- ()
- "cmvne $rm, $rn, $rd"
- (+ (f-op 8) rm (f-ext 5) rn rd (f-rsvd 0))
- (if (ne rm 0)
- (set rd rn)))
- (dshmi fabsd "Floating point absolute (double)"
- ()
- "fabs.d $drgh, $drf"
- (+ (f-op 6) drgh (f-ext 1) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_fabsd" drgh)))
- (dshmi fabss "Floating point absolute (single)"
- ()
- "fabs.s $frgh, $frf"
- (+ (f-op 6) frgh (f-ext 0) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fabss" frgh)))
- (dshmi faddd "Floating point add (double)"
- ()
- "fadd.d $drg, $drh, $drf"
- (+ (f-op 13) drg (f-ext 1) drh drf (f-rsvd 0))
- (set drf (c-call DF "sh64_faddd" drg drh)))
- (dshmi fadds "Floating point add (single)"
- ()
- "fadd.s $frg, $frh, $frf"
- (+ (f-op 13) frg (f-ext 0) frh frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fadds" frg frh)))
- (dshmi fcmpeqd "Floating point compare if equal (double)"
- ()
- "fcmpeq.d $drg, $drh, $rd"
- (+ (f-op 12) drg (f-ext 9) drh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpeqd" drg drh))))
- (dshmi fcmpeqs "Floating point compare if equal (single)"
- ()
- "fcmpeq.s $frg, $frh, $rd"
- (+ (f-op 12) frg (f-ext 8) frh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpeqs" frg frh))))
- (dshmi fcmpged "Floating compare compare if greater than or equal (double)"
- ()
- "fcmpge.d $drg, $drh, $rd"
- (+ (f-op 12) drg (f-ext 15) drh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpged" drg drh))))
- (dshmi fcmpges "Floating point compare if greater than or equal (single)"
- ()
- "fcmpge.s $frg, $frh, $rd"
- (+ (f-op 12) frg (f-ext 14) frh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpges" frg frh))))
- (dshmi fcmpgtd "Floating point compare if greater than (double)"
- ()
- "fcmpgt.d $drg, $drh, $rd"
- (+ (f-op 12) drg (f-ext 13) drh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpgtd" drg drh))))
- (dshmi fcmpgts "Floating point compare if greater than (single)"
- ()
- "fcmpgt.s $frg, $frh, $rd"
- (+ (f-op 12) frg (f-ext 12) frh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpgts" frg frh))))
- (dshmi fcmpund "Floating point unordered comparison (double)"
- ()
- "fcmpun.d $drg, $drh, $rd"
- (+ (f-op 12) drg (f-ext 11) drh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpund" drg drh))))
- (dshmi fcmpuns "Floating point unordered comparison (single)"
- ()
- "fcmpun.s $frg, $frh, $rd"
- (+ (f-op 12) frg (f-ext 10) frh rd (f-rsvd 0))
- (set rd (zext DI (c-call BI "sh64_fcmpuns" frg frh))))
- (dshmi fcnvds "Floating point coversion (double to single)"
- ()
- "fcnv.ds $drgh, $frf"
- (+ (f-op 14) drgh (f-ext 7) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fcnvds" drgh)))
- (dshmi fcnvsd "Floating point conversion (single to double)"
- ()
- "fcnv.sd $frgh, $drf"
- (+ (f-op 14) frgh (f-ext 6) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_fcnvsd" frgh)))
- (dshmi fdivd "Floating point divide (double)"
- ()
- "fdiv.d $drg, $drh, $drf"
- (+ (f-op 13) drg (f-ext 5) drh drf (f-rsvd 0))
- (set drf (c-call DF "sh64_fdivd" drg drh)))
- (dshmi fdivs "Floating point divide (single)"
- ()
- "fdiv.s $frg, $frh, $frf"
- (+ (f-op 13) frg (f-ext 4) frh frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fdivs" frg frh)))
- (dshmi fgetscr "Floating point get from FPSCR"
- ()
- "fgetscr $frf"
- (+ (f-op 7) (f-left 63) (f-ext 2) (f-right 63) frf (f-rsvd 0))
- (unimp "fputscr"))
- ; FIXME: this should work!
- ; (set frf fpscr))
- (dshmi fiprs "Floating point inner product (single)"
- ()
- "fipr.s $fvg, $fvh, $frf"
- (+ (f-op 5) fvg (f-ext 6) fvh frf (f-rsvd 0))
- (sequence ((UQI g) (UQI h) (SF temp))
- (set g (index-of fvg))
- (set h (index-of fvh))
- (set temp (c-call SF "sh64_fmuls" (reg h-fr g) (reg h-fr h)))
- (set temp (c-call SF "sh64_fadds" temp
- (c-call SF "sh64_fmuls" (reg h-fr (add g 1)) (reg h-fr (add h 1)))))
- (set temp (c-call SF "sh64_fadds" temp
- (c-call SF "sh64_fmuls" (reg h-fr (add g 2)) (reg h-fr (add h 2)))))
- (set temp (c-call SF "sh64_fadds" temp
- (c-call SF "sh64_fmuls" (reg h-fr (add g 3)) (reg h-fr (add h 3)))))
- (set frf temp)))
- (dshmi fldd "Floating point load (double)"
- ()
- "fld.d $rm, $disp10x8, $drf"
- (+ (f-op 39) rm disp10x8 drf (f-rsvd 0))
- (set drf (mem DF (add rm disp10x8))))
- (dshmi fldp "Floating point load (pair of singles)"
- ()
- "fld.p $rm, $disp10x8, $fpf"
- (+ (f-op 38) rm disp10x8 fpf (f-rsvd 0))
- (sequence ((QI f))
- (set f (index-of fpf))
- (set (reg h-fr f) (mem SF (add rm disp10x8)))
- (set (reg h-fr (add f 1)) (mem SF (add rm (add disp10x8 4))))))
- (dshmi flds "Floating point load (single)"
- ()
- "fld.s $rm, $disp10x4, $frf"
- (+ (f-op 37) rm disp10x4 frf (f-rsvd 0))
- (set frf (mem SF (add rm disp10x4))))
- (dshmi fldxd "Floating point extended load (double)"
- ()
- "fldx.d $rm, $rn, $drf"
- (+ (f-op 7) rm (f-ext 9) rn frf (f-rsvd 0))
- (set drf (mem DF (add rm rn))))
- (dshmi fldxp "Floating point extended load (pair of singles)"
- ()
- "fldx.p $rm, $rn, $fpf"
- (+ (f-op 7) rm (f-ext 13) rn fpf (f-rsvd 0))
- (sequence ((QI f))
- (set f (index-of fpf))
- (set (reg h-fr f) (mem SF (add rm rn)))
- (set (reg h-fr (add f 1)) (mem SF (add rm (add rn 4))))))
- (dshmi fldxs "Floating point extended load (single)"
- ()
- "fldx.s $rm, $rn, $frf"
- (+ (f-op 7) rm (f-ext 8) rn frf (f-rsvd 0))
- (set frf (mem SF (add rm rn))))
- (dshmi floatld "Floating point conversion (long to double)"
- ()
- "float.ld $frgh, $drf"
- (+ (f-op 14) frgh (f-ext 14) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_floatld" frgh)))
- (dshmi floatls "Floating point conversion (long to single)"
- ()
- "float.ls $frgh, $frf"
- (+ (f-op 14) frgh (f-ext 12) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_floatls" frgh)))
- (dshmi floatqd "Floating point conversion (quad to double)"
- ()
- "float.qd $drgh, $drf"
- (+ (f-op 14) drgh (f-ext 13) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_floatqd" drgh)))
- (dshmi floatqs "Floating point conversion (quad to single)"
- ()
- "float.qs $drgh, $frf"
- (+ (f-op 14) drgh (f-ext 15) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_floatqs" drgh)))
- (dshmi fmacs "Floating point multiply and accumulate (single)"
- ()
- "fmac.s $frg, $frh, $frf"
- (+ (f-op 13) frg (f-ext 14) frh frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fadds" frf (c-call SF "sh64_fmuls" frg frh))))
- (dshmi fmovd "Floating point move double"
- ()
- "fmov.d $drgh, $drf"
- (+ (f-op 14) drgh (f-ext 1) drf (f-rsvd 0))
- (set drf drgh))
- (dshmi fmovdq "Floating point move (double to quad integer)"
- ()
- "fmov.dq $drgh, $rd"
- (+ (f-op 12) drgh (f-ext 1) rd (f-rsvd 0))
- (set rd (subword DI drgh 0)))
- (dshmi fmovls "Floating point move (lower to single)"
- ()
- "fmov.ls $rm, $frf"
- (+ (f-op 7) rm (f-ext 0) (f-right 63) frf (f-rsvd 0))
- (set frf (subword SF (subword SI rm 1) 0)))
- (dshmi fmovqd "Floating point move (quad to double)"
- ()
- "fmov.qd $rm, $drf"
- (+ (f-op 7) rm (f-ext 1) (f-right 63) frf (f-rsvd 0))
- (set drf (subword DF rm 0)))
- (dshmi fmovs "Floating point move (single)"
- ()
- "fmov.s $frgh, $frf"
- (+ (f-op 14) frgh (f-ext 0) frf (f-rsvd 0))
- (set frf frgh))
- (dshmi fmovsl "Floating point move (single to lower)"
- ()
- "fmov.sl $frgh, $rd"
- (+ (f-op 12) frgh (f-ext 0) rd (f-rsvd 0))
- (set rd (ext DI (subword SI frgh 1))))
- (dshmi fmuld "Floating point multiply (double)"
- ()
- "fmul.d $drg, $drh, $drf"
- (+ (f-op 13) drg (f-ext 7) drh drf (f-rsvd 0))
- (set drf (c-call DF "sh64_fmuld" drg drh)))
- (dshmi fmuls "Floating point multiply (single)"
- ()
- "fmul.s $frg, $frh, $frf"
- (+ (f-op 13) frg (f-ext 6) frh frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fmuls" frg frh)))
- (dshmi fnegd "Floating point negate (double)"
- ()
- "fneg.d $drgh, $drf"
- (+ (f-op 6) drgh (f-ext 3) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_fnegd" drgh)))
- (dshmi fnegs "Floating point negate (single)"
- ()
- "fneg.s $frgh, $frf"
- (+ (f-op 6) frgh (f-ext 2) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fnegs" frgh)))
- (dshmi fputscr "Floating point put to FPSCR"
- ()
- "fputscr $frgh"
- (+ (f-op 12) frgh (f-ext 2) (f-dest 63) (f-rsvd 0))
- (unimp "fputscr"))
- ; FIXME: this should work!
- ; (set fpscr (subword SI frgh 0)))
- (dshmi fsqrtd "Floating point square root (double)"
- ()
- "fsqrt.d $drgh, $drf"
- (+ (f-op 14) drgh (f-ext 5) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_fsqrtd" drgh)))
- (dshmi fsqrts "Floating point squart root (single)"
- ()
- "fsqrt.s $frgh, $frf"
- (+ (f-op 14) frgh (f-ext 4) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fsqrts" frgh)))
- (dshmi fstd "Floating point store (double)"
- ()
- "fst.d $rm, $disp10x8, $drf"
- (+ (f-op 47) rm disp10x8 drf (f-rsvd 0))
- (set (mem DF (add rm disp10x8)) drf))
- (dshmi fstp "Floating point store (pair of singles)"
- ()
- "fst.p $rm, $disp10x8, $fpf"
- (+ (f-op 46) rm disp10x8 fpf (f-rsvd 0))
- (sequence ((QI f))
- (set f (index-of fpf))
- (set (mem SF (add rm disp10x8)) (reg h-fr f))
- (set (mem SF (add rm (add disp10x8 4))) (reg h-fr (add f 1)))))
- (dshmi fsts "Floating point store (single)"
- ()
- "fst.s $rm, $disp10x4, $frf"
- (+ (f-op 45) rm disp10x4 frf (f-rsvd 0))
- (set (mem SF (add rm disp10x4)) frf))
- (dshmi fstxd "Floating point extended store (double)"
- ()
- "fstx.d $rm, $rn, $drf"
- (+ (f-op 15) rm (f-ext 9) rn drf (f-rsvd 0))
- (set (mem DF (add rm rn)) drf))
- (dshmi fstxp "Floating point extended store (pair of singles)"
- ()
- "fstx.p $rm, $rn, $fpf"
- (+ (f-op 15) rm (f-ext 13) rn fpf (f-rsvd 0))
- (sequence ((QI f))
- (set f (index-of fpf))
- (set (mem SF (add rm rn)) (reg h-fr f))
- (set (mem SF (add rm (add rn 4))) (reg h-fr (add f 1)))))
- (dshmi fstxs "Floating point extended store (single)"
- ()
- "fstx.s $rm, $rn, $frf"
- (+ (f-op 15) rm (f-ext 8) rn frf (f-rsvd 0))
- (set (mem SF (add rm rn)) frf))
- (dshmi fsubd "Floating point subtract (double)"
- ()
- "fsub.d $drg, $drh, $drf"
- (+ (f-op 13) frg (f-ext 3) frh frf (f-rsvd 0))
- (set drf (c-call DF "sh64_fsubd" drg drh)))
- (dshmi fsubs "Floating point subtract (single)"
- ()
- "fsub.s $frg, $frh, $frf"
- (+ (f-op 13) frg (f-ext 2) frh frf (f-rsvd 0))
- (set frf (c-call SF "sh64_fsubs" frg frh)))
- (dshmi ftrcdl "Floating point conversion (double to long)"
- ()
- "ftrc.dl $drgh, $frf"
- (+ (f-op 14) drgh (f-ext 11) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_ftrcdl" drgh)))
- (dshmi ftrcsl "Floating point conversion (single to long)"
- ()
- "ftrc.sl $frgh, $frf"
- (+ (f-op 14) frgh (f-ext 8) frf (f-rsvd 0))
- (set frf (c-call SF "sh64_ftrcsl" frgh)))
- (dshmi ftrcdq "Floating point conversion (double to quad)"
- ()
- "ftrc.dq $drgh, $drf"
- (+ (f-op 14) drgh (f-ext 9) frf (f-rsvd 0))
- (set drf (c-call DF "sh64_ftrcdq" drgh)))
- (dshmi ftrcsq "Floating point conversion (single to quad)"
- ()
- "ftrc.sq $frgh, $drf"
- (+ (f-op 14) frgh (f-ext 10) drf (f-rsvd 0))
- (set drf (c-call DF "sh64_ftrcsq" frgh)))
- (dshmi ftrvs "Floating point matrix multiply"
- ()
- "ftrv.s $mtrxg, $fvh, $fvf"
- (+ (f-op 5) mtrxg (f-ext 14) fvh fvf (f-rsvd 0))
- (c-call "sh64_ftrvs" (index-of mtrxg) (index-of fvh) (index-of fvf)))
- (dshmi getcfg "Get configuration register"
- ()
- "getcfg $rm, $disp6, $rd"
- (+ (f-op 48) rm (f-ext 15) disp6 rd (f-rsvd 0))
- (unimp "getcfg"))
- (dshmi getcon "Get control register"
- ()
- "getcon $crk, $rd"
- (+ (f-op 9) crk (f-ext 15) (f-right 63) rd (f-rsvd 0))
- (set rd crk))
- (dshmi gettr "Get target register"
- ()
- "gettr $trb, $rd"
- (+ (f-op 17) (f-25 0) trb (f-ext 5) (f-right 63) rd (f-rsvd 0))
- (set rd trb))
- (dshmi icbi "Invalidate instruction cache block"
- ()
- "icbi $rm, $disp6x32"
- (+ (f-op 56) rm (f-ext 5) disp6x32 (f-dest 63) (f-rsvd 0))
- (unimp "icbi"))
- (dshmi ldb "Load byte"
- ()
- "ld.b $rm, $disp10, $rd"
- (+ (f-op 32) rm disp10 rd (f-rsvd 0))
- (set rd (ext DI (mem QI (add rm (ext DI disp10))))))
- (dshmi ldl "Load long word"
- ()
- "ld.l $rm, $disp10x4, $rd"
- (+ (f-op 34) rm disp10x4 rd (f-rsvd 0))
- (set rd (ext DI (mem SI (add rm (ext DI disp10x4))))))
- (dshmi ldq "Load quad word"
- ()
- "ld.q $rm, $disp10x8, $rd"
- (+ (f-op 35) rm disp10x8 rd (f-rsvd 0))
- (set rd (mem DI (add rm (ext DI disp10x8)))))
- (dshmi ldub "Load unsigned byte"
- ()
- "ld.ub $rm, $disp10, $rd"
- (+ (f-op 36) rm disp10 rd (f-rsvd 0))
- (set rd (zext DI (mem QI (add rm (ext DI disp10))))))
- (dshmi lduw "Load unsigned word"
- ()
- "ld.uw $rm, $disp10x2, $rd"
- (+ (f-op 44) rm disp10 rd (f-rsvd 0))
- (set rd (zext DI (mem HI (add rm (ext DI disp10x2))))))
- (dshmi ldw "Load word"
- ()
- "ld.w $rm, $disp10x2, $rd"
- (+ (f-op 33) rm disp10 rd (f-rsvd 0))
- (set rd (ext DI (mem HI (add rm (ext DI disp10x2))))))
- (dshmi ldhil "Load high part (long word)"
- ()
- "ldhi.l $rm, $disp6, $rd"
- (+ (f-op 48) rm (f-ext 6) disp6 rd (f-rsvd 0))
- ; FIXME.
- (unimp "ldhil"))
- (dshmi ldhiq "Load high part (quad word)"
- ()
- "ldhi.q $rm, $disp6, $rd"
- (+ (f-op 48) rm (f-ext 7) disp6 rd (f-rsvd 0))
- ; FIXME.
- (unimp "ldhiq"))
- (dshmi ldlol "Load low part (long word)"
- ()
- "ldlo.l $rm, $disp6, $rd"
- (+ (f-op 48) rm (f-ext 2) disp6 rd (f-rsvd 0))
- ; FIXME.
- (unimp "ldlol"))
- (dshmi ldloq "Load low part (quad word)"
- ()
- "ldlo.q $rm, $disp6, $rd"
- (+ (f-op 48) rm (f-ext 3) disp6 rd (f-rsvd 0))
- ; FIXME;
- (unimp "ldloq"))
- (dshmi ldxb "Load byte (extended displacement)"
- ()
- "ldx.b $rm, $rn, $rd"
- (+ (f-op 16) rm (f-ext 0) rn rd (f-rsvd 0))
- (set rd (ext DI (mem QI (add rm rn)))))
- (dshmi ldxl "Load long word (extended displacement)"
- ()
- "ldx.l $rm, $rn, $rd"
- (+ (f-op 16) rm (f-ext 2) rn rd (f-rsvd 0))
- (set rd (ext DI (mem SI (add rm rn)))))
- (dshmi ldxq "Load quad word (extended displacement)"
- ()
- "ldx.q $rm, $rn, $rd"
- (+ (f-op 16) rm (f-ext 3) rn rd (f-rsvd 0))
- (set rd (mem DI (add rm rn))))
- (dshmi ldxub "Load unsigned byte (extended displacement)"
- ()
- "ldx.ub $rm, $rn, $rd"
- (+ (f-op 16) rm (f-ext 4) rn rd (f-rsvd 0))
- (set rd (zext DI (mem UQI (add rm rn)))))
- (dshmi ldxuw "Load unsigned word (extended displacement)"
- ()
- "ldx.uw $rm, $rn, $rd"
- (+ (f-op 16) rm (f-ext 5) rn rd (f-rsvd 0))
- (set rd (zext DI (mem UHI (add rm rn)))))
- (dshmi ldxw "Load word (extended displacement)"
- ()
- "ldx.w $rm, $rn, $rd"
- (+ (f-op 16) rm (f-ext 1) rn rd (f-rsvd 0))
- (set rd (ext DI (mem HI (add rm rn)))))
- ; Macros to facilitate multimedia instructions.
- (define-pmacro (slice-byte expr)
- (sequence ((QI result7) (QI result6) (QI result5) (QI result4)
- (QI result3) (QI result2) (QI result1) (QI result0))
- (set result0 (expr (subword QI rm 7) (subword QI rn 7)))
- (set result1 (expr (subword QI rm 6) (subword QI rn 6)))
- (set result2 (expr (subword QI rm 5) (subword QI rn 5)))
- (set result3 (expr (subword QI rm 4) (subword QI rn 4)))
- (set result4 (expr (subword QI rm 3) (subword QI rn 3)))
- (set result5 (expr (subword QI rm 2) (subword QI rn 2)))
- (set result6 (expr (subword QI rm 1) (subword QI rn 1)))
- (set result7 (expr (subword QI rm 0) (subword QI rn 0)))
- (set rd (-join-qi result7 result6 result5 result4 result3 result2
- result1 result0))))
- (define-pmacro (slice-word expr)
- (sequence ((HI result3) (HI result2) (HI result1) (HI result0))
- (set result0 (expr (subword HI rm 3) (subword HI rn 3)))
- (set result1 (expr (subword HI rm 2) (subword HI rn 2)))
- (set result2 (expr (subword HI rm 1) (subword HI rn 1)))
- (set result3 (expr (subword HI rm 0) (subword HI rn 0)))
- (set rd (-join-hi result3 result2 result1 result0))))
- (define-pmacro (slice-word-unop expr)
- (sequence ((HI result3) (HI result2) (HI result1) (HI result0))
- (set result0 (expr (subword HI rm 3)))
- (set result1 (expr (subword HI rm 2)))
- (set result2 (expr (subword HI rm 1)))
- (set result3 (expr (subword HI rm 0)))
- (set rd (-join-hi result3 result2 result1 result0))))
- (define-pmacro (slice-long expr)
- (sequence ((SI result1) (SI result0))
- (set result0 (expr (subword SI rm 1) (subword SI rn 1)))
- (set result1 (expr (subword SI rm 0) (subword SI rn 0)))
- (set rd (-join-si result1 result0))))
- (define-pmacro (slice-long-unop expr)
- (sequence ((SI result1) (SI result0))
- (set result0 (expr (subword SI rm 1)))
- (set result1 (expr (subword SI rm 0)))
- (set rd (-join-si result1 result0))))
- ; Multimedia instructions.
- (dshmi mabsl "Multimedia absolute value (long word)"
- ()
- "mabs.l $rm, $rd"
- (+ (f-op 10) rm (f-ext 10) (f-right 63) rd (f-rsvd 0))
- (slice-long-unop abs))
- (dshmi mabsw "Multimedia absolute value (word)"
- ()
- "mabs.w $rm, $rd"
- (+ (f-op 10) rm (f-ext 9) (f-right 63) rd (f-rsvd 0))
- (slice-word-unop abs))
- (dshmi maddl "Multimedia add (long word)"
- ()
- "madd.l $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 2) rn rd (f-rsvd 0))
- (slice-long add))
- (dshmi maddw "Multimedia add (word)"
- ()
- "madd.w $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 1) rn rd (f-rsvd 0))
- (slice-word add))
- (define-pmacro (-maddsl arg1 arg2) (saturate SI 32 (add arg1 arg2)))
- (dshmi maddsl "Multimedia add (saturating, long word)"
- ()
- "madds.l $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 6) rn rd (f-rsvd 0))
- (slice-long -maddsl))
- (define-pmacro (-maddsub arg1 arg2) (usaturate QI 8 (add arg1 arg2)))
- (dshmi maddsub "Multimedia add (saturating, unsigned byte)"
- ()
- "madds.ub $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 4) rn rd (f-rsvd 0))
- (slice-byte -maddsub))
- (define-pmacro (-maddsw arg1 arg2) (saturate HI 16 (add arg1 arg2)))
- (dshmi maddsw "Multimedia add (saturating, word)"
- ()
- "madds.w $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 5) rn rd (f-rsvd 0))
- (slice-word -maddsw))
- (define-pmacro (-mcmpeq mode arg1 arg2)
- (if mode (eq arg1 arg2) (inv mode 0) (const mode 0)))
- (define-pmacro (-mcmpeqb arg1 arg2) (-mcmpeq QI arg1 arg2))
- (dshmi mcmpeqb "Multimedia compare equal (byte)"
- ()
- "mcmpeq.b $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 0) rn rd (f-rsvd 0))
- (slice-byte -mcmpeqb))
- (define-pmacro (-mcmpeql arg1 arg2) (-mcmpeq SI arg1 arg2))
- (dshmi mcmpeql "Multimedia compare equal (long word)"
- ()
- "mcmpeq.l $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 2) rn rd (f-rsvd 0))
- (slice-long -mcmpeql))
- (define-pmacro (-mcmpeqw arg1 arg2) (-mcmpeq HI arg1 arg2))
- (dshmi mcmpeqw "Multimedia compare equal (word)"
- ()
- "mcmpeq.w $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 1) rn rd (f-rsvd 0))
- (slice-word -mcmpeqw))
- (define-pmacro (-mcmpgt mode arg1 arg2)
- (if mode (gt arg1 arg2) (inv mode 0) (const mode 0)))
- (define-pmacro (-mcmpgtu mode arg1 arg2)
- (if mode (gtu arg1 arg2) (inv mode 0) (const mode 0)))
- (define-pmacro (-mcmpgtl arg1 arg2) (-mcmpgt SI arg1 arg2))
- (dshmi mcmpgtl "Multimedia compare greater than (long word)"
- ()
- "mcmpgt.l $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 6) rn rd (f-rsvd 0))
- (slice-long -mcmpgtl))
- (define-pmacro (-mcmpgtub arg1 arg2) (-mcmpgtu QI arg1 arg2))
- (dshmi mcmpgtub "Multimediate compare unsigned greater than (byte)"
- ()
- "mcmpgt.ub $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 4) rn rd (f-rsvd 0))
- (slice-byte -mcmpgtub))
- (define-pmacro (-mcmpgtw arg1 arg2) (-mcmpgt HI arg1 arg2))
- (dshmi mcmpgtw "Multimedia compare greater than (word)"
- ()
- "mcmpgt.w $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 5) rn rd (f-rsvd 0))
- (slice-word -mcmpgtw))
- (dshmi mcmv "Multimedia conditional move"
- ()
- "mcmv $rm, $rn, $rd"
- (+ (f-op 18) rm (f-ext 3) rn rd (f-rsvd 0))
- (set rd (or (and rm rn) (and rd (inv rn)))))
- (dshmi mcnvslw "Multimedia convert/saturate (long to word)"
- ()
- "mcnvs.lw $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 13) rn rd (f-rsvd 0))
- (sequence ((HI result3) (HI result2) (HI result1) (HI result0))
- (set result0 (saturate HI 16 (subword SI rm 0)))
- (set result1 (saturate HI 16 (subword SI rm 1)))
- (set result2 (saturate HI 16 (subword SI rn 0)))
- (set result3 (saturate HI 16 (subword SI rn 1)))
- (set rd (-join-hi result3 result2 result1 result0))))
- (dshmi mcnvswb "Multimedia convert/saturate (word to byte)"
- ()
- "mcnvs.wb $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 8) rn rd (f-rsvd 0))
- (sequence ((QI result7) (QI result6) (QI result5) (QI result4)
- (QI result3) (QI result2) (QI result1) (QI result0))
- (set result0 (saturate QI 8 (subword HI rm 0)))
- (set result1 (saturate QI 8 (subword HI rm 1)))
- (set result2 (saturate QI 8 (subword HI rm 2)))
- (set result3 (saturate QI 8 (subword HI rm 3)))
- (set result4 (saturate QI 8 (subword HI rn 0)))
- (set result5 (saturate QI 8 (subword HI rn 1)))
- (set result6 (saturate QI 8 (subword HI rn 2)))
- (set result7 (saturate QI 8 (subword HI rn 3)))
- (set rd (-join-qi result7 result6 result5 result4
- result3 result2 result1 result0))))
- (dshmi mcnvswub "Multimedia convert/saturate (word to unsigned byte)"
- ()
- "mcnvs.wub $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 12) rn rd (f-rsvd 0))
- (sequence ((QI result7) (QI result6) (QI result5) (QI result4)
- (QI result3) (QI result2) (QI result1) (QI result0))
- (set result0 (usaturate QI 8 (subword HI rm 0)))
- (set result1 (usaturate QI 8 (subword HI rm 1)))
- (set result2 (usaturate QI 8 (subword HI rm 2)))
- (set result3 (usaturate QI 8 (subword HI rm 3)))
- (set result4 (usaturate QI 8 (subword HI rn 0)))
- (set result5 (usaturate QI 8 (subword HI rn 1)))
- (set result6 (usaturate QI 8 (subword HI rn 2)))
- (set result7 (usaturate QI 8 (subword HI rn 3)))
- (set rd (-join-qi result7 result6 result5 result4 result3
- result2 result1 result0))))
- ; mexter -- generate an mexterN instruction, where:
- ; op = primary opcode
- ; extop = extended opcode
- (define-pmacro (make-mextr n op extop)
- (dshmi (.sym mextr n)
- (.str "Multimedia extract 64-bit slice (from byte " n ")")
- ()
- (.str "mextr" n " $rm, $rn, $rd")
- (+ (f-op op) rm (f-ext extop) rn rd (f-rsvd 0))
- (sequence ((QI count) (DI mask) (DI rhs))
- (set count (mul QI 8 (sub QI 8 n)))
- (set mask (sll DI (inv 0) count))
- (set rhs (srl (and rm mask) count))
- (set count (mul QI 8 n))
- (set mask (srl DI (inv 0) count))
- (set rd (or DI rhs (sll DI (and rn mask) count))))))
- (make-mextr 1 10 7)
- (make-mextr 2 10 11)
- (make-mextr 3 10 15)
- (make-mextr 4 11 3)
- (make-mextr 5 11 7)
- (make-mextr 6 11 11)
- (make-mextr 7 11 15)
- (dshmi mmacfxwl "Multimedia fractional multiply (word to long)"
- ()
- "mmacfx.wl $rm, $rn, $rd"
- (+ (f-op 18) rm (f-ext 1) rn rd (f-rsvd 0))
- (sequence ((SI temp) (SI result1) (SI result0))
- (set result0 (subword SI rd 0))
- (set result1 (subword SI rd 1))
- (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0))))
- (set temp (saturate SI 32 (sll temp 1)))
- (set result0 (saturate SI 32 (add result0 temp)))
- (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))
- (set temp (saturate SI 32 (sll temp 1)))
- (set result1 (saturate SI 32 (add result1 temp)))
- (set rd (-join-si result1 result0))))
- (dshmi mmacnfx.wl "Multimedia fractional multiple (word to long)"
- ()
- "mmacnfx.wl $rm, $rn, $rd"
- (+ (f-op 18) rn (f-ext 5) rn rd (f-rsvd 0))
- (sequence ((SI temp) (SI result1) (SI result0))
- (set result0 (subword SI rd 0))
- (set result1 (subword SI rd 1))
- (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0))))
- (set temp (saturate SI 32 (sll temp 1)))
- (set result0 (saturate SI 32 (sub result0 temp)))
- (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))
- (set temp (saturate SI 32 (sll temp 1)))
- (set result1 (saturate SI 32 (sub result1 temp)))
- (set rd (-join-si result1 result0))))
- (dshmi mmull "Multimedia multiply (long word)"
- ()
- "mmul.l $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 2) rn rd (f-rsvd 0))
- (slice-long mul))
- (dshmi mmulw "Multimedia multiply (word)"
- ()
- "mmul.w $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 1) rn rd (f-rsvd 0))
- (slice-word mul))
- (dshmi mmulfxl "Multimedia fractional multiply (long word)"
- ()
- "mmulfx.l $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 6) rn rd (f-rsvd 0))
- (sequence ((DI temp) (SI result0) (SI result1))
- (set temp (mul (zext DI (subword SI rm 0)) (zext DI (subword SI rn 0))))
- (set result0 (saturate SI 32 (sra temp 31)))
- (set temp (mul (zext DI (subword SI rm 1)) (zext DI (subword SI rn 1))))
- (set result1 (saturate SI 32 (sra temp 31)))
- (set rd (-join-si result1 result0))))
- (dshmi mmulfxw "Multimedia fractional multiply (word)"
- ()
- "mmulfx.w $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 5) rn rd (f-rsvd 0))
- (sequence ((SI temp) (HI result0) (HI result1) (HI result2) (HI result3))
- (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0))))
- (set result0 (saturate HI 16 (sra temp 15)))
- (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))
- (set result1 (saturate HI 16 (sra temp 15)))
- (set temp (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2))))
- (set result2 (saturate HI 16 (sra temp 15)))
- (set temp (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3))))
- (set result3 (saturate HI 16 (sra temp 15)))
- (set rd (-join-hi result3 result2 result1 result0))))
- (dshmi mmulfxrpw "Multimedia fractional multiply round positive (word op)"
- ()
- "mmulfxrp.w $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 9) rn rd (f-rsvd 0))
- (sequence ((SI temp) (HI result0) (HI result1) (HI result2) (HI result3) (HI c))
- (set c (sll 1 14))
- (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0))))
- (set result0 (saturate HI 16 (sra (add temp c) 15)))
- (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))
- (set result1 (saturate HI 16 (sra (add temp c) 15)))
- (set temp (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2))))
- (set result2 (saturate HI 16 (sra (add temp c) 15)))
- (set temp (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3))))
- (set result3 (saturate HI 16 (sra (add temp c) 15)))
- (set rd (-join-hi result3 result2 result1 result0))))
- (dshmi mmulhiwl "Multimedia multiply higher halves (word to long)"
- ()
- "mmulhi.wl $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 14) rn rd (f-rsvd 0))
- (sequence ((SI result1) (SI result0))
- (set result0 (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2))))
- (set result1 (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3))))
- (set rd (-join-si result1 result0))))
- (dshmi mmullowl "Multimedia multiply lower halves (word to long)"
- ()
- "mmullo.wl $rm, $rn, $rd"
- (+ (f-op 19) rm (f-ext 10) rn rd (f-rsvd 0))
- (sequence ((SI result1) (SI result0))
- (set result0 (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0))))
- (set result1 (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))
- (set rd (-join-si result1 result0))))
- (dshmi mmulsumwq "Multimedia multiply and accumulate (word to quad)"
- ()
- "mmulsum.wq $rm, $rn, $rd"
- (+ (f-op 18) rm (f-ext 9) rn rd (f-rsvd 0))
- (sequence ((DI acc))
- (set acc (mul SI (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0))))
- (set acc (add acc (mul SI (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))))
- (set acc (add acc (mul SI (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))))
- (set acc (add acc (mul SI (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))))
- (set rd (add rd acc))))
- (dshmi movi "Move immediate"
- ()
- "movi $imm16, $rd"
- (+ (f-op 51) imm16 rd (f-rsvd 0))
- (set rd (ext DI imm16)))
- (dshmi mpermw "Multimedia permutate word"
- ()
- "mperm.w $rm, $rn, $rd"
- (+ (f-op 10) rm (f-ext 13) rn rd (f-rsvd 0))
- (sequence ((QI control) (HI result3) (HI result2) (HI result1) (HI result0))
- (set control (and QI rn #x3f))
- (set result0 (subword HI rm (sub 3 (and control 3))))
- (set result1 (subword HI rm (sub 3 (and (srl control 2) 3))))
- (set result2 (subword HI rm (sub 3 (and (srl control 4) 3))))
- (set result3 (subword HI rm (sub 3 (and (srl control 6) 3))))
- (set rd (-join-hi result3 result2 result1 result0))))
- (dshmi msadubq "Multimedia absolute difference (byte)"
- ()
- "msad.ubq $rm, $rn, $rd"
- (+ (f-op 18) rm (f-ext 0) rn rd (f-rsvd 0))
- (sequence ((DI acc))
- (set acc (abs DI (sub (subword QI rm 0) (subword QI rn 1))))
- (set acc (add DI acc (abs (sub (subword QI rm 1) (subword QI rn 1)))))
- (set acc (add DI acc (abs (sub (subword QI rm 2) (subword QI rn 2)))))
- (set acc (add DI acc (abs (sub (subword QI rm 3) (subword QI rn 3)))))
- (set acc (add DI acc (abs (sub (subword QI rm 4) (subword QI rn 4)))))
- (set acc (add DI acc (abs (sub (subword QI rm 5) (subword QI rn 5)))))
- (set acc (add DI acc (abs (sub (subword QI rm 6) (subword QI rn 6)))))
- (set acc (add DI acc (abs (sub (subword QI rm 7) (subword QI rn 7)))))
- (set rd (add rd acc))))
- (define-pmacro (-mshaldsl arg) (saturate SI 32 (sll arg (and rn 31))))
- (dshmi mshaldsl "Multimedia saturating arithmetic left shift (long word)"
- ()
- "mshalds.l $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 6) rn rd (f-rsvd 0))
- (slice-long-unop -mshaldsl))
- (define-pmacro (-mshaldsw arg) (saturate HI 16 (sll arg (and rn 15))))
- (dshmi mshaldsw "Multimedia saturating arithmetic left shift (word)"
- ()
- "mshalds.w $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 5) rn rd (f-rsvd 0))
- (slice-word-unop -mshaldsw))
- (define-pmacro (-mshardl arg) (sra arg (and rn 31)))
- (dshmi mshardl "Multimedia arithmetic right shift (long)"
- ()
- "mshard.l $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 10) rn rd (f-rsvd 0))
- (slice-long-unop -mshardl))
- (define-pmacro (-mshardw arg) (sra arg (and rn 15)))
- (dshmi mshardw "Multimedia arithmetic right shift (word)"
- ()
- "mshard.w $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 9) rn rd (f-rsvd 0))
- (slice-word-unop -mshardw))
- (dshmi mshardsq "Multimedia saturating arithmetic right shift (quad word)"
- ()
- "mshards.q $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 11) rn rd (f-rsvd 0))
- (set rd (saturate DI 16 (sra rm (and rn 63)))))
- (dshmi mshfhib "Multimedia shuffle higher-half (byte)"
- ()
- "mshfhi.b $rm, $rn, $rd"
- (+ (f-op 11) rm (f-ext 4) rn rd (f-rsvd 0))
- (sequence ((QI result7) (QI result6) (QI result5) (QI result4)
- (QI result3) (QI result2) (QI result1) (QI result0))
- (set result0 (subword QI rm 4))
- (set result1 (subword QI rn 4))
- (set result2 (subword QI rm 5))
- (set result3 (subword QI rn 5))
- (set result4 (subword QI rm 6))
- (set result5 (subword QI rn 6))
- (set result6 (subword QI rm 7))
- (set result7 (subword QI rn 7))
- (set rd (-join-qi result7 result6 result5 result4 result3
- result2 result1 result0))))
- (dshmi mshfhil "Multimedia shuffle higher-half (long)"
- ()
- "mshfhi.l $rm, $rn, $rd"
- (+ (f-op 11) rm (f-ext 6) rn rd (f-rsvd 0))
- (sequence ((SI result1) (SI result0))
- (set result0 (subword SI rm 1))
- (set result1 (subword SI rn 1))
- (set rd (-join-si result1 result0))))
- (dshmi mshfhiw "Multimedia shuffle higher-half (word)"
- ()
- "mshfhi.w $rm, $rn, $rd"
- (+ (f-op 11) rm (f-ext 5) rn rd (f-rsvd 0))
- (sequence ((HI result3) (HI result2) (HI result1) (HI result0))
- (set result0 (subword HI rm 2))
- (set result1 (subword HI rn 2))
- (set result2 (subword HI rm 3))
- (set result3 (subword HI rn 3))
- (set rd (-join-hi result3 result2 result1 result0))))
- (dshmi mshflob "Multimedia shuffle lower-half (byte)"
- ()
- "mshflo.b $rm, $rn, $rd"
- (+ (f-op 11) rm (f-ext 0) rn rd (f-rsvd 0))
- (sequence ((QI result7) (QI result6) (QI result5) (QI result4)
- (QI result3) (QI result2) (QI result1) (QI result0))
- (set result0 (subword QI rm 0))
- (set result1 (subword QI rn 0))
- (set result2 (subword QI rm 1))
- (set result3 (subword QI rn 1))
- (set result4 (subword QI rm 2))
- (set result5 (subword QI rn 2))
- (set result6 (subword QI rm 3))
- (set result7 (subword QI rn 3))
- (set rd (-join-qi result7 result6 result5 result4 result3
- result2 result1 result0))))
- (dshmi mshflol "Multimedia shuffle lower-half (long)"
- ()
- "mshflo.l $rm, $rn, $rd"
- (+ (f-op 11) rm (f-ext 2) rn rd (f-rsvd 0))
- (sequence ((SI result1) (SI result0))
- (set result0 (subword SI rm 0))
- (set result1 (subword SI rn 0))
- (set rd (-join-si result1 result0))))
- (dshmi mshflow "Multimedia shuffle lower-half (word)"
- ()
- "mshflo.w $rm, $rn, $rd"
- (+ (f-op 11) rm (f-ext 1) rn rd (f-rsvd 0))
- (sequence ((HI result3) (HI result2) (HI result1) (HI result0))
- (set result0 (subword HI rm 0))
- (set result1 (subword HI rn 0))
- (set result2 (subword HI rm 1))
- (set result3 (subword HI rn 1))
- (set rd (-join-hi result3 result2 result1 result0))))
- (define-pmacro (-mshlldl arg) (sll arg (and rn 31)))
- (dshmi mshlldl "Multimedia logical left shift (long word)"
- ()
- "mshlld.l $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 2) rn rd (f-rsvd 0))
- (slice-long-unop -mshlldl))
- (define-pmacro (-mshlldw arg) (sll arg (and rn 15)))
- (dshmi mshlldw "Multimedia logical left shift (word)"
- ()
- "mshlld.w $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 1) rn rd (f-rsvd 0))
- (slice-word-unop -mshlldw))
- (define-pmacro (-mshlrdl arg) (srl arg (and rn 31)))
- (dshmi mshlrdl "Multimedia logical right shift (long word)"
- ()
- "mshlrd.l $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 14) rn rd (f-rsvd 0))
- (slice-long-unop -mshlrdl))
- (define-pmacro (-mshlrdw arg) (srl arg (and rn 15)))
- (dshmi mshlrdw "Multimedia logical right shift (word)"
- ()
- "mshlrd.w $rm, $rn, $rd"
- (+ (f-op 3) rm (f-ext 13) rn rd (f-rsvd 0))
- (slice-word-unop -mshlrdw))
- (dshmi msubl "Multimedia subtract (long word)"
- ()
- "msub.l $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 10) rn rd (f-rsvd 0))
- (slice-long sub))
- (dshmi msubw "Multimedia add (word)"
- ()
- "msub.w $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 9) rn rd (f-rsvd 0))
- (slice-word sub))
- (define-pmacro (-msubsl arg1 arg2) (saturate SI 32 (sub arg1 arg2)))
- (dshmi msubsl "Multimedia subtract (saturating long)"
- ()
- "msubs.l $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 14) rn rd (f-rsvd 0))
- (slice-long -msubsl))
- (define-pmacro (-msubsub arg1 arg2) (usaturate QI 8 (sub arg1 arg2)))
- (dshmi msubsub "Multimedia subtract (saturating byte)"
- ()
- "msubs.ub $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 12) rn rd (f-rsvd 0))
- (slice-byte -msubsub))
- (define-pmacro (-msubsw arg1 arg2) (saturate HI 16 (sub arg1 arg2)))
- (dshmi msubsw "Multimedia subtract (saturating word)"
- ()
- "msubs.w $rm, $rn, $rd"
- (+ (f-op 2) rm (f-ext 13) rn rd (f-rsvd 0))
- (slice-byte -msubsw))
- (dshmi mulsl "Multiply signed long"
- ()
- "muls.l $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 14) rn rd (f-rsvd 0))
- (set rd (mul (ext DI (subword SI rm 1)) (ext DI (subword SI rn 1)))))
- (dshmi mulul "Multiply unsigned long"
- ()
- "mulu.l $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 14) rn rd (f-rsvd 0))
- (set rd (mul (zext DI (subword SI rm 1)) (zext DI (subword SI rn 1)))))
- (dshmi nop "No operation"
- ()
- "nop"
- (+ (f-op 27) (f-left 63) (f-ext 0) (f-right 63) (f-dest 63) (f-rsvd 0))
- (nop))
- (dshmi nsb "Number of consecutive sign bits"
- ()
- "nsb $rm, $rd"
- (+ (f-op 0) rm (f-ext 13) (f-right 63) rd (f-rsvd 0))
- ; Semantics requires a loop construct, so punt to C.
- (set rd (c-call DI "sh64_nsb" rm)))
- (dshmi ocbi "Invalidate operand cache block"
- ()
- "ocbi $rm, $disp6x32"
- (+ (f-op 56) rm (f-ext 9) disp6x32 (f-dest 63) (f-rsvd 0))
- (unimp "ocbi"))
- (dshmi ocbp "Purge operand cache block"
- ()
- "ocbp $rm, $disp6x32"
- (+ (f-op 56) rm (f-ext 8) disp6x32 (f-dest 63) (f-rsvd 0))
- (unimp "ocbp"))
- (dshmi ocbwb "Write-back operand cache block"
- ()
- "ocbwb $rm, $disp6x32"
- (+ (f-op 56) rm (f-ext 12) disp6x32 (f-dest 63) (f-rsvd 0))
- (unimp "ocbwb"))
- (dshmi or "OR"
- ()
- "or $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 9) rn rd (f-rsvd 0))
- (set rd (or rm rn)))
- (dshmi ori "OR immediate"
- ()
- "ori $rm, $imm10, $rd"
- (+ (f-op 55) rm imm10 rd (f-rsvd 0))
- (set rd (or rm (ext DI imm10))))
- (dshmi prefi "Prefetch instruction"
- ()
- "prefi $rm, $disp6x32"
- (+ (f-op 56) rm (f-ext 1) disp6x32 (f-right 63) (f-rsvd 0))
- (unimp "prefi"))
- (dshmi pta "Prepare target register for SHmedia target"
- ()
- "pta$likely $disp16, $tra"
- (+ (f-op 58) disp16 likely (f-8-2 0) tra (f-rsvd 0))
- (set tra (add disp16 1)))
- (dshmi ptabs "Prepare target register with absolute value from register"
- ()
- "ptabs$likely $rn, $tra"
- (+ (f-op 26) (f-left 63) (f-ext 1) rn likely (f-8-2 0) tra (f-rsvd 0))
- (set tra rn))
- (dshmi ptb "Prepare target register for SHcompact target"
- ()
- "ptb$likely $disp16, $tra"
- (+ (f-op 59) disp16 likely (f-8-2 0) tra (f-rsvd 0))
- (set tra disp16))
- (dshmi ptrel "Prepare target register with relative value from register"
- ()
- "ptrel$likely $rn, $tra"
- (+ (f-op 26) (f-left 63) (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0))
- (set tra (add pc rn)))
- (dshmi putcfg "Put configuration register"
- ()
- "putcfg $rm, $disp6, $rd"
- (+ (f-op 56) rm (f-ext 15) disp6 rd (f-rsvd 0))
- (unimp "putcfg"))
- (dshmi putcon "Put control register"
- ()
- "putcon $rm, $crj"
- (+ (f-op 27) rm (f-ext 15) (f-right 63) crj (f-rsvd 0))
- (set crj rm))
- (dshmi rte "Return from exception"
- ()
- "rte"
- (+ (f-op 27) (f-left 63) (f-ext 3) (f-right 63) (f-dest 63) (f-rsvd 0))
- (unimp "rte"))
- (dshmi shard "Arithmetic right shift"
- ()
- "shard $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 7) rn rd (f-rsvd 0))
- (set rd (sra rm (and rn 63))))
- (dshmi shardl "Arithmetic right shift (long word)"
- ()
- "shard.l $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 6) rn rd (f-rsvd 0))
- (set rd (ext DI (sra (subword SI rm 1) (and rn 63)))))
- (dshmi shari "Arithmetic right shift (immediate count)"
- ()
- "shari $rm, $uimm6, $rd"
- (+ (f-op 49) rm (f-ext 7) uimm6 rd (f-rsvd 0))
- (set rd (sra rm uimm6)))
- (dshmi sharil "Arithmetic right shift (long word, immediate count)"
- ()
- "shari.l $rm, $uimm6, $rd"
- (+ (f-op 49) rm (f-ext 6) uimm6 rd (f-rsvd 0))
- (set rd (ext DI (sra (subword SI rm 1) (and uimm6 63)))))
- (dshmi shlld "Logical left shift"
- ()
- "shlld $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 1) rn rd (f-rsvd 0))
- (set rd (sll rm (and rn 63))))
- (dshmi shlldl "Logical left shift (long word)"
- ()
- "shlld.l $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 0) rn rd (f-rsvd 0))
- (set rd (ext DI (sll (subword SI rm 1) (and rn 63)))))
- (dshmi shlli "Logical left shift (immediate count)"
- ()
- "shlli $rm, $uimm6, $rd"
- (+ (f-op 49) rm (f-ext 1) uimm6 rd (f-rsvd 0))
- (set rd (sll rm uimm6)))
- (dshmi shllil "Logical left shift (long word, immediate count)"
- ()
- "shlli.l $rm, $uimm6, $rd"
- (+ (f-op 49) rm (f-ext 0) uimm6 rd (f-rsvd 0))
- (set rd (ext DI (sll (subword SI rm 1) (and uimm6 63)))))
- (dshmi shlrd "Logical right shift"
- ()
- "shlrd $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 3) rn rd (f-rsvd 0))
- (set rd (srl rm (and rn 63))))
- (dshmi shlrdl "Logical right shift (long word)"
- ()
- "shlrd.l $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 2) rn rd (f-rsvd 0))
- (set rd (ext DI (srl (subword SI rm 1) (and rn 63)))))
- (dshmi shlri "Logical right shift (immediate count)"
- ()
- "shlri $rm, $uimm6, $rd"
- (+ (f-op 49) rm (f-ext 3) uimm6 rd (f-rsvd 0))
- (set rd (srl rm uimm6)))
- (dshmi shlril "Logical right shift (long word, immediate count)"
- ()
- "shlri.l $rm, $uimm6, $rd"
- (+ (f-op 49) rm (f-ext 2) uimm6 rd (f-rsvd 0))
- (set rd (ext DI (srl (subword SI rm 1) (and uimm6 63)))))
- (dshmi shori "Shift-or immediate"
- ()
- "shori $uimm16, $rd"
- (+ (f-op 50) uimm16 rd (f-rsvd 0))
- (set rd (or (sll rd 16) (zext DI uimm16))))
- (dshmi sleep "Sleep"
- ()
- "sleep"
- (+ (f-op 27) (f-left 63) (f-ext 7) (f-right 63) (f-dest 63) (f-rsvd 0))
- (unimp "sleep"))
- (dshmi stb "Store byte"
- ()
- "st.b $rm, $disp10, $rd"
- (+ (f-op 40) rm disp10 rd (f-rsvd 0))
- (set (mem UQI (add rm (ext DI disp10))) (and QI rd #xff)))
- (dshmi stl "Store long word"
- ()
- "st.l $rm, $disp10x4, $rd"
- (+ (f-op 42) rm disp10x4 rd (f-rsvd 0))
- (set (mem SI (add rm (ext DI disp10x4))) (and SI rd #xffffffff)))
- (dshmi stq "Store quad word"
- ()
- "st.q $rm, $disp10x8, $rd"
- (+ (f-op 43) rm disp10x8 rd (f-rsvd 0))
- (set (mem DI (add rm (ext DI disp10x8))) rd))
- (dshmi stw "Store word"
- ()
- "st.w $rm, $disp10x2, $rd"
- (+ (f-op 41) rm disp10x2 rd (f-rsvd 0))
- (set (mem HI (add rm (ext DI disp10x2))) (and HI rd #xffff)))
- (define-pmacro (-sthi-byte)
- (sequence ()
- (set (mem UQI addr) (and QI val #xff))
- (set val (srl val 8))
- (set addr (add addr 1))))
- (dshmi sthil "Store high part (long word)"
- ()
- "sthi.l $rm, $disp6, $rd"
- (+ (f-op 56) rm (f-ext 6) disp6 rd (f-rsvd 0))
- (sequence ((DI addr) (QI bytecount) (DI val))
- (set addr (add rm disp6))
- (set bytecount (add (and addr 3) 1))
- (if endian
- (set val rd)
- (set val (srl rd (sub 32 (mul 8 bytecount)))))
- (set addr (add (sub addr bytecount) 1))
- (if (gt bytecount 3)
- (-sthi-byte))
- (if (gt bytecount 2)
- (-sthi-byte))
- (if (gt bytecount 1)
- (-sthi-byte))
- (if (gt bytecount 0)
- (-sthi-byte))))
- (dshmi sthiq "Store high part (quad word)"
- ()
- "sthi.q $rm, $disp6, $rd"
- (+ (f-op 56) rm (f-ext 7) disp6 rd (f-rsvd 0))
- (sequence ((DI addr) (QI bytecount) (DI val))
- (set addr (add rm disp6))
- (set bytecount (add (and addr 7) 1))
- (if endian
- (set val rd)
- (set val (srl rd (sub 64 (mul 8 bytecount)))))
- (set addr (add (sub addr bytecount) 1))
- (if (gt bytecount 7)
- (-sthi-byte))
- (if (gt bytecount 6)
- (-sthi-byte))
- (if (gt bytecount 5)
- (-sthi-byte))
- (if (gt bytecount 4)
- (-sthi-byte))
- (if (gt bytecount 3)
- (-sthi-byte))
- (if (gt bytecount 2)
- (-sthi-byte))
- (if (gt bytecount 1)
- (-sthi-byte))
- (if (gt bytecount 0)
- (-sthi-byte))))
- (dshmi stlol "Store low part (long word)"
- ()
- "stlo.l $rm, $disp6, $rd"
- (+ (f-op 56) rm (f-ext 2) disp6 rd (f-rsvd 0))
- ; FIXME.
- (unimp "stlol"))
- (dshmi stloq "Store low part (quad word)"
- ()
- "stlo.q $rm, $disp6, $rd"
- (+ (f-op 56) rm (f-ext 3) disp6 rd (f-rsvd 0))
- ; FIXME.
- (unimp "stloq"))
- (dshmi stxb "Store byte (extended displacement)"
- ()
- "stx.b $rm, $rn, $rd"
- (+ (f-op 24) rm (f-ext 0) rn rd (f-rsvd 0))
- (set (mem UQI (add rm rn)) (subword QI rd 7)))
- (dshmi stxl "Store long (extended displacement)"
- ()
- "stx.l $rm, $rn, $rd"
- (+ (f-op 24) rm (f-ext 2) rn rd (f-rsvd 0))
- (set (mem SI (add rm rn)) (subword SI rd 1)))
- (dshmi stxq "Store quad word (extended displacement)"
- ()
- "stx.q $rm, $rn, $rd"
- (+ (f-op 24) rm (f-ext 3) rn rd (f-rsvd 0))
- (set (mem DI (add rm rn)) rd))
- (dshmi stxw "Store word (extended displacement)"
- ()
- "stx.w $rm, $rn, $rd"
- (+ (f-op 24) rm (f-ext 1) rn rd (f-rsvd 0))
- (set (mem HI (add rm rn)) (subword HI rd 3)))
- (dshmi sub "Subtract"
- ()
- "sub $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 11) rn rd (f-rsvd 0))
- (set rd (sub rm rn)))
- (dshmi subl "Subtract long"
- ()
- "sub.l $rm, $rn, $rd"
- (+ (f-op 0) rm (f-ext 10) rn rd (f-rsvd 0))
- (set rd (ext DI (sub (subword SI rm 1) (subword SI rn 1)))))
- (dshmi swapq "Swap quad words"
- ()
- "swap.q $rm, $rn, $rd"
- (+ (f-op 8) rm (f-ext 3) rn rd (f-rsvd 0))
- (sequence ((DI addr) (DI temp))
- (set addr (add rm rn))
- (set temp (mem DI addr))
- (set (mem DI addr) rd)
- (set rd temp)))
- (dshmi synci "Synchronise instruction fetch"
- ()
- "synci"
- (+ (f-op 27) (f-left 63) (f-ext 2) (f-right 63) (f-dest 63) (f-rsvd 0))
- (unimp "synci"))
- (dshmi synco "Synchronise data operations"
- ()
- "synco"
- (+ (f-op 27) (f-left 63) (f-ext 6) (f-right 63) (f-dest 63) (f-rsvd 0))
- (unimp "synco"))
- (dshmi trapa "Trap"
- ()
- "trapa $rm"
- (+ (f-op 27) rm (f-ext 1) (f-right 63) (f-dest 63) (f-rsvd 0))
- (c-call "sh64_trapa" rm pc))
- (dshmi xor "Exclusive OR"
- ()
- "xor $rm, $rn, $rd"
- (+ (f-op 1) rm (f-ext 13) rn rd (f-rsvd 0))
- (set rd (xor rm rn)))
- (dshmi xori "Exclusive OR immediate"
- ()
- "xori $rm, $imm6, $rd"
- (+ (f-op 49) rm (f-ext 13) rn rd (f-rsvd 0))
- (set rd (xor rm (ext DI imm6))))
|