decoder.isa revision 3056
12686Sksewell@umich.edu// -*- mode:c++ -*- 22100SN/A 32754Sksewell@umich.edu// Copyright (c) 2006 The Regents of The University of Michigan 42706Sksewell@umich.edu// All rights reserved. 52706Sksewell@umich.edu// 62706Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without 72706Sksewell@umich.edu// modification, are permitted provided that the following conditions are 82706Sksewell@umich.edu// met: redistributions of source code must retain the above copyright 92706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer; 102706Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright 112706Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the 122706Sksewell@umich.edu// documentation and/or other materials provided with the distribution; 132706Sksewell@umich.edu// neither the name of the copyright holders nor the names of its 142706Sksewell@umich.edu// contributors may be used to endorse or promote products derived from 152706Sksewell@umich.edu// this software without specific prior written permission. 162706Sksewell@umich.edu// 172706Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182706Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192706Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202706Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212706Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222706Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232706Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242706Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252706Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262706Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272706Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282706Sksewell@umich.edu// 292706Sksewell@umich.edu// Authors: Korey Sewell 302706Sksewell@umich.edu 312022SN/A//////////////////////////////////////////////////////////////////// 322022SN/A// 332043SN/A// The actual MIPS32 ISA decoder 342024SN/A// ----------------------------- 352024SN/A// The following instructions are specified in the MIPS32 ISA 362043SN/A// Specification. Decoding closely follows the style specified 372686Sksewell@umich.edu// in the MIPS32 ISA specification document starting with Table 382024SN/A// A-2 (document available @ www.mips.com) 392022SN/A// 402083SN/Adecode OPCODE_HI default Unknown::unknown() { 412686Sksewell@umich.edu //Table A-2 422101SN/A 0x0: decode OPCODE_LO { 432043SN/A 0x0: decode FUNCTION_HI { 442043SN/A 0x0: decode FUNCTION_LO { 452101SN/A 0x1: decode MOVCI { 462101SN/A format BasicOp { 472686Sksewell@umich.edu 0: movf({{ Rd = (getCondCode(FCSR, CC) == 0) ? Rd : Rs; }}); 482686Sksewell@umich.edu 1: movt({{ Rd = (getCondCode(FCSR, CC) == 1) ? Rd : Rs; }}); 492101SN/A } 502101SN/A } 512101SN/A 522046SN/A format BasicOp { 532686Sksewell@umich.edu //Table A-3 Note: "Specific encodings of the rd, rs, and 542686Sksewell@umich.edu //rt fields are used to distinguish SLL, SSNOP, and EHB 552686Sksewell@umich.edu //functions 562470SN/A 0x0: decode RS { 572686Sksewell@umich.edu 0x0: decode RT_RD { 582686Sksewell@umich.edu 0x0: decode SA default Nop::nop(){ 592686Sksewell@umich.edu 0x1: WarnUnimpl::ssnop(); 602686Sksewell@umich.edu 0x3: WarnUnimpl::ehb(); 612686Sksewell@umich.edu } 622686Sksewell@umich.edu default: sll({{ Rd = Rt.uw << SA; }}); 632470SN/A } 642241SN/A } 652101SN/A 662495SN/A 0x2: decode RS_SRL { 672495SN/A 0x0:decode SRL { 682495SN/A 0: srl({{ Rd = Rt.uw >> SA; }}); 692101SN/A 702495SN/A //Hardcoded assuming 32-bit ISA, probably need parameter here 712495SN/A 1: rotr({{ Rd = (Rt.uw << (32 - SA)) | (Rt.uw >> SA);}}); 722495SN/A } 732101SN/A } 742101SN/A 752495SN/A 0x3: decode RS { 762495SN/A 0x0: sra({{ 772495SN/A uint32_t temp = Rt >> SA; 782495SN/A if ( (Rt & 0x80000000) > 0 ) { 792495SN/A uint32_t mask = 0x80000000; 802495SN/A for(int i=0; i < SA; i++) { 812495SN/A temp |= mask; 822495SN/A mask = mask >> 1; 832495SN/A } 842495SN/A } 852495SN/A Rd = temp; 862495SN/A }}); 872495SN/A } 882101SN/A 892101SN/A 0x4: sllv({{ Rd = Rt.uw << Rs<4:0>; }}); 902101SN/A 912101SN/A 0x6: decode SRLV { 922101SN/A 0: srlv({{ Rd = Rt.uw >> Rs<4:0>; }}); 932101SN/A 942101SN/A //Hardcoded assuming 32-bit ISA, probably need parameter here 952101SN/A 1: rotrv({{ Rd = (Rt.uw << (32 - Rs<4:0>)) | (Rt.uw >> Rs<4:0>);}}); 962101SN/A } 972101SN/A 982495SN/A 0x7: srav({{ 992495SN/A int shift_amt = Rs<4:0>; 1002495SN/A 1012495SN/A uint32_t temp = Rt >> shift_amt; 1022495SN/A 1032495SN/A if ( (Rt & 0x80000000) > 0 ) { 1042495SN/A uint32_t mask = 0x80000000; 1052495SN/A for(int i=0; i < shift_amt; i++) { 1062495SN/A temp |= mask; 1072495SN/A mask = mask >> 1; 1082495SN/A } 1092495SN/A } 1102495SN/A 1112495SN/A Rd = temp; 1122495SN/A }}); 1132043SN/A } 1142043SN/A } 1152025SN/A 1162043SN/A 0x1: decode FUNCTION_LO { 1172686Sksewell@umich.edu //Table A-3 Note: "Specific encodings of the hint field are 1182686Sksewell@umich.edu //used to distinguish JR from JR.HB and JALR from JALR.HB" 1192123SN/A format Jump { 1202101SN/A 0x0: decode HINT { 1212686Sksewell@umich.edu 0x1: jr_hb({{ NNPC = Rs & ~1; }}, IsReturn, ClearHazards); 1222686Sksewell@umich.edu default: jr({{ NNPC = Rs & ~1; }}, IsReturn); 1232101SN/A } 1242042SN/A 1252101SN/A 0x1: decode HINT { 1262686Sksewell@umich.edu 0x1: jalr_hb({{ Rd = NNPC; NNPC = Rs; }}, IsCall, Link 1272686Sksewell@umich.edu , ClearHazards); 1282686Sksewell@umich.edu default: jalr({{ Rd = NNPC; NNPC = Rs; }}, IsCall, 1292686Sksewell@umich.edu Link); 1302101SN/A } 1312101SN/A } 1322042SN/A 1332101SN/A format BasicOp { 1342686Sksewell@umich.edu 0x2: movz({{ Rd = (Rt == 0) ? Rs : Rd; }}); 1352686Sksewell@umich.edu 0x3: movn({{ Rd = (Rt != 0) ? Rs : Rd; }}); 1362965Sksewell@umich.edu 0x4: syscall({{ xc->syscall(R2); }}, 1372965Sksewell@umich.edu IsSerializeAfter, IsNonSpeculative); 1382686Sksewell@umich.edu 0x7: sync({{ ; }}, IsMemBarrier); 1392101SN/A } 1402083SN/A 1412686Sksewell@umich.edu format FailUnimpl { 1422686Sksewell@umich.edu 0x5: break(); 1432101SN/A } 1442043SN/A } 1452025SN/A 1462043SN/A 0x2: decode FUNCTION_LO { 1472686Sksewell@umich.edu format HiLoMiscOp { 1482616SN/A 0x0: mfhi({{ Rd = HI; }}); 1492616SN/A 0x1: mthi({{ HI = Rs; }}); 1502616SN/A 0x2: mflo({{ Rd = LO; }}); 1512616SN/A 0x3: mtlo({{ LO = Rs; }}); 1522101SN/A } 1532083SN/A } 1542025SN/A 1552043SN/A 0x3: decode FUNCTION_LO { 1562686Sksewell@umich.edu format HiLoOp { 1572686Sksewell@umich.edu 0x0: mult({{ val = Rs.sd * Rt.sd; }}); 1582686Sksewell@umich.edu 0x1: multu({{ val = Rs.ud * Rt.ud; }}); 1592686Sksewell@umich.edu } 1602025SN/A 1612686Sksewell@umich.edu format HiLoMiscOp { 1622742Sksewell@umich.edu 0x2: div({{ if (Rt.sd != 0) { 1632742Sksewell@umich.edu HI = Rs.sd % Rt.sd; 1642742Sksewell@umich.edu LO = Rs.sd / Rt.sd; 1652742Sksewell@umich.edu } 1662742Sksewell@umich.edu }}); 1672742Sksewell@umich.edu 0x3: divu({{ if (Rt.ud != 0) { 1682742Sksewell@umich.edu HI = Rs.ud % Rt.ud; 1692742Sksewell@umich.edu LO = Rs.ud / Rt.ud; 1702742Sksewell@umich.edu } 1712742Sksewell@umich.edu }}); 1722101SN/A } 1732084SN/A } 1742025SN/A 1752495SN/A 0x4: decode HINT { 1762495SN/A 0x0: decode FUNCTION_LO { 1772495SN/A format IntOp { 1782616SN/A 0x0: add({{ Rd.sw = Rs.sw + Rt.sw; /*Trap on Overflow*/}}); 1792495SN/A 0x1: addu({{ Rd.sw = Rs.sw + Rt.sw;}}); 1802616SN/A 0x2: sub({{ Rd.sw = Rs.sw - Rt.sw; /*Trap on Overflow*/}}); 1812495SN/A 0x3: subu({{ Rd.sw = Rs.sw - Rt.sw;}}); 1822495SN/A 0x4: and({{ Rd = Rs & Rt;}}); 1832495SN/A 0x5: or({{ Rd = Rs | Rt;}}); 1842495SN/A 0x6: xor({{ Rd = Rs ^ Rt;}}); 1852495SN/A 0x7: nor({{ Rd = ~(Rs | Rt);}}); 1862495SN/A } 1872101SN/A } 1882043SN/A } 1892025SN/A 1902495SN/A 0x5: decode HINT { 1912495SN/A 0x0: decode FUNCTION_LO { 1922495SN/A format IntOp{ 1932495SN/A 0x2: slt({{ Rd.sw = ( Rs.sw < Rt.sw ) ? 1 : 0}}); 1942495SN/A 0x3: sltu({{ Rd.uw = ( Rs.uw < Rt.uw ) ? 1 : 0}}); 1952495SN/A } 1962101SN/A } 1972084SN/A } 1982024SN/A 1992043SN/A 0x6: decode FUNCTION_LO { 2002239SN/A format Trap { 2012239SN/A 0x0: tge({{ cond = (Rs.sw >= Rt.sw); }}); 2022101SN/A 0x1: tgeu({{ cond = (Rs.uw >= Rt.uw); }}); 2032101SN/A 0x2: tlt({{ cond = (Rs.sw < Rt.sw); }}); 2042101SN/A 0x3: tltu({{ cond = (Rs.uw >= Rt.uw); }}); 2052101SN/A 0x4: teq({{ cond = (Rs.sw == Rt.sw); }}); 2062101SN/A 0x6: tne({{ cond = (Rs.sw != Rt.sw); }}); 2072101SN/A } 2082043SN/A } 2092043SN/A } 2102025SN/A 2112043SN/A 0x1: decode REGIMM_HI { 2122043SN/A 0x0: decode REGIMM_LO { 2132101SN/A format Branch { 2142101SN/A 0x0: bltz({{ cond = (Rs.sw < 0); }}); 2152101SN/A 0x1: bgez({{ cond = (Rs.sw >= 0); }}); 2162686Sksewell@umich.edu 0x2: bltzl({{ cond = (Rs.sw < 0); }}, Likely); 2172686Sksewell@umich.edu 0x3: bgezl({{ cond = (Rs.sw >= 0); }}, Likely); 2182101SN/A } 2192043SN/A } 2202025SN/A 2212043SN/A 0x1: decode REGIMM_LO { 2222239SN/A format Trap { 2232101SN/A 0x0: tgei( {{ cond = (Rs.sw >= INTIMM); }}); 2242104SN/A 0x1: tgeiu({{ cond = (Rs.uw >= INTIMM); }}); 2252101SN/A 0x2: tlti( {{ cond = (Rs.sw < INTIMM); }}); 2262101SN/A 0x3: tltiu({{ cond = (Rs.uw < INTIMM); }}); 2272101SN/A 0x4: teqi( {{ cond = (Rs.sw == INTIMM);}}); 2282101SN/A 0x6: tnei( {{ cond = (Rs.sw != INTIMM);}}); 2292101SN/A } 2302043SN/A } 2312043SN/A 2322043SN/A 0x2: decode REGIMM_LO { 2332101SN/A format Branch { 2342686Sksewell@umich.edu 0x0: bltzal({{ cond = (Rs.sw < 0); }}, Link); 2352686Sksewell@umich.edu 0x1: decode RS { 2362686Sksewell@umich.edu 0x0: bal ({{ cond = 1; }}, IsCall, Link); 2372686Sksewell@umich.edu default: bgezal({{ cond = (Rs.sw >= 0); }}, Link); 2382686Sksewell@umich.edu } 2392686Sksewell@umich.edu 0x2: bltzall({{ cond = (Rs.sw < 0); }}, Link, Likely); 2402686Sksewell@umich.edu 0x3: bgezall({{ cond = (Rs.sw >= 0); }}, Link, Likely); 2412101SN/A } 2422043SN/A } 2432043SN/A 2442043SN/A 0x3: decode REGIMM_LO { 2452101SN/A format WarnUnimpl { 2462101SN/A 0x7: synci(); 2472101SN/A } 2482043SN/A } 2492043SN/A } 2502043SN/A 2512123SN/A format Jump { 2522239SN/A 0x2: j({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2);}}); 2532686Sksewell@umich.edu 0x3: jal({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2); }}, IsCall, 2542686Sksewell@umich.edu Link); 2552043SN/A } 2562043SN/A 2572100SN/A format Branch { 2582686Sksewell@umich.edu 0x4: decode RS_RT { 2592686Sksewell@umich.edu 0x0: b({{ cond = 1; }}); 2602686Sksewell@umich.edu default: beq({{ cond = (Rs.sw == Rt.sw); }}); 2612686Sksewell@umich.edu } 2622239SN/A 0x5: bne({{ cond = (Rs.sw != Rt.sw); }}); 2632686Sksewell@umich.edu 0x6: blez({{ cond = (Rs.sw <= 0); }}); 2642686Sksewell@umich.edu 0x7: bgtz({{ cond = (Rs.sw > 0); }}); 2652043SN/A } 2662084SN/A } 2672024SN/A 2682101SN/A 0x1: decode OPCODE_LO { 2692686Sksewell@umich.edu format IntImmOp { 2702239SN/A 0x0: addi({{ Rt.sw = Rs.sw + imm; /*Trap If Overflow*/}}); 2712239SN/A 0x1: addiu({{ Rt.sw = Rs.sw + imm;}}); 2722239SN/A 0x2: slti({{ Rt.sw = ( Rs.sw < imm) ? 1 : 0 }}); 2732495SN/A 0x3: sltiu({{ Rt.uw = ( Rs.uw < (uint32_t)sextImm ) ? 1 : 0 }}); 2742495SN/A 0x4: andi({{ Rt.sw = Rs.sw & zextImm;}}); 2752495SN/A 0x5: ori({{ Rt.sw = Rs.sw | zextImm;}}); 2762495SN/A 0x6: xori({{ Rt.sw = Rs.sw ^ zextImm;}}); 2772495SN/A 2782495SN/A 0x7: decode RS { 2792495SN/A 0x0: lui({{ Rt = imm << 16}}); 2802495SN/A } 2812084SN/A } 2822084SN/A } 2832024SN/A 2842101SN/A 0x2: decode OPCODE_LO { 2852101SN/A //Table A-11 MIPS32 COP0 Encoding of rs Field 2862101SN/A 0x0: decode RS_MSB { 2872101SN/A 0x0: decode RS { 2882686Sksewell@umich.edu format CP0Control { 2892686Sksewell@umich.edu 0x0: mfc0({{ Rt = xc->readMiscReg(RD << 5 | SEL); }}); 2902686Sksewell@umich.edu 0x4: mtc0({{ xc->setMiscReg(RD << 5 | SEL, Rt); }}); 2912686Sksewell@umich.edu } 2922052SN/A 2932686Sksewell@umich.edu format MipsMT { 2942686Sksewell@umich.edu 0x8: mftr(); 2952686Sksewell@umich.edu 0xC: mttr(); 2962101SN/A 0xB: decode RD { 2972101SN/A 0x0: decode SC { 2982686Sksewell@umich.edu 0x0: dvpe(); 2992686Sksewell@umich.edu 0x1: evpe(); 3002101SN/A } 3012101SN/A 0x1: decode SC { 3022686Sksewell@umich.edu 0x0: dmt(); 3032686Sksewell@umich.edu 0x1: emt(); 3042686Sksewell@umich.edu 0xC: decode SC { 3052686Sksewell@umich.edu 0x0: di(); 3062686Sksewell@umich.edu 0x1: ei(); 3072686Sksewell@umich.edu } 3082101SN/A } 3092101SN/A } 3102686Sksewell@umich.edu } 3112027SN/A 3122686Sksewell@umich.edu format FailUnimpl { 3132686Sksewell@umich.edu 0xA: rdpgpr(); 3142686Sksewell@umich.edu 0xE: wrpgpr(); 3152101SN/A } 3162101SN/A } 3172101SN/A 3182101SN/A //Table A-12 MIPS32 COP0 Encoding of Function Field When rs=CO 3192101SN/A 0x1: decode FUNCTION { 3202686Sksewell@umich.edu format FailUnimpl { 3212686Sksewell@umich.edu 0x01: tlbr(); 3222686Sksewell@umich.edu 0x02: tlbwi(); 3232686Sksewell@umich.edu 0x06: tlbwr(); 3242686Sksewell@umich.edu 0x08: tlbp(); 3252101SN/A 3262101SN/A 0x18: eret(); 3272101SN/A 0x1F: deret(); 3282101SN/A 0x20: wait(); 3292101SN/A } 3302101SN/A } 3312043SN/A } 3322027SN/A 3332101SN/A //Table A-13 MIPS32 COP1 Encoding of rs Field 3342101SN/A 0x1: decode RS_MSB { 3352041SN/A 3362101SN/A 0x0: decode RS_HI { 3372101SN/A 0x0: decode RS_LO { 3382686Sksewell@umich.edu format CP1Control { 3392742Sksewell@umich.edu 0x0: mfc1 ({{ Rt.uw = Fs.uw; }}); 3402495SN/A 3412495SN/A 0x2: cfc1({{ 3422573SN/A switch (FS) 3432573SN/A { 3442573SN/A case 0: 3452616SN/A Rt = FIR; 3462573SN/A break; 3472573SN/A case 25: 3482616SN/A Rt = 0 | (FCSR & 0xFE000000) >> 24 | (FCSR & 0x00800000) >> 23; 3492573SN/A break; 3502573SN/A case 26: 3512616SN/A Rt = 0 | (FCSR & 0x0003F07C); 3522573SN/A break; 3532573SN/A case 28: 3542616SN/A Rt = 0 | (FCSR & 0x00000F80) | (FCSR & 0x01000000) >> 21 | (FCSR & 0x00000003); 3552573SN/A break; 3562573SN/A case 31: 3572616SN/A Rt = FCSR; 3582573SN/A break; 3592573SN/A default: 3602686Sksewell@umich.edu panic("FP Control Value (%d) Not Valid"); 3612573SN/A } 3622573SN/A }}); 3632573SN/A 3642686Sksewell@umich.edu 0x3: mfhc1({{ Rt.uw = Fs.ud<63:32>;}}); 3652686Sksewell@umich.edu 3662686Sksewell@umich.edu 0x4: mtc1 ({{ Fs.uw = Rt.uw; }}); 3672686Sksewell@umich.edu 3682573SN/A 0x6: ctc1({{ 3692573SN/A switch (FS) 3702573SN/A { 3712573SN/A case 25: 3722616SN/A FCSR = 0 | (Rt.uw<7:1> << 25) // move 31...25 3732616SN/A | (FCSR & 0x01000000) // bit 24 3742616SN/A | (FCSR & 0x004FFFFF);// bit 22...0 3752573SN/A break; 3762573SN/A 3772573SN/A case 26: 3782616SN/A FCSR = 0 | (FCSR & 0xFFFC0000) // move 31...18 3792573SN/A | Rt.uw<17:12> << 12 // bit 17...12 3802616SN/A | (FCSR & 0x00000F80) << 7// bit 11...7 3812573SN/A | Rt.uw<6:2> << 2 // bit 6...2 3822616SN/A | (FCSR & 0x00000002); // bit 1...0 3832573SN/A break; 3842573SN/A 3852573SN/A case 28: 3862616SN/A FCSR = 0 | (FCSR & 0xFE000000) // move 31...25 3872573SN/A | Rt.uw<2:2> << 24 // bit 24 3882616SN/A | (FCSR & 0x00FFF000) << 23// bit 23...12 3892573SN/A | Rt.uw<11:7> << 7 // bit 24 3902616SN/A | (FCSR & 0x000007E) 3912573SN/A | Rt.uw<1:0>;// bit 22...0 3922573SN/A break; 3932573SN/A 3942573SN/A case 31: 3952616SN/A FCSR = Rt.uw; 3962573SN/A break; 3972573SN/A 3982573SN/A default: 3992495SN/A panic("FP Control Value (%d) Not Available. Ignoring Access to" 4002616SN/A "Floating Control Status Register", FS); 4012495SN/A } 4022495SN/A }}); 4032686Sksewell@umich.edu 4042686Sksewell@umich.edu 0x7: mthc1({{ 4052686Sksewell@umich.edu uint64_t fs_hi = Rt.uw; 4062686Sksewell@umich.edu uint64_t fs_lo = Fs.ud & 0x0FFFFFFFF; 4072686Sksewell@umich.edu Fs.ud = (fs_hi << 32) | fs_lo; 4082686Sksewell@umich.edu }}); 4092686Sksewell@umich.edu 4102101SN/A } 4112101SN/A } 4122025SN/A 4132101SN/A 0x1: decode ND { 4142686Sksewell@umich.edu format Branch { 4152686Sksewell@umich.edu 0x0: decode TF { 4162686Sksewell@umich.edu 0x0: bc1f({{ cond = getCondCode(FCSR, BRANCH_CC) == 0; 4172686Sksewell@umich.edu }}); 4182686Sksewell@umich.edu 0x1: bc1t({{ cond = getCondCode(FCSR, BRANCH_CC) == 1; 4192686Sksewell@umich.edu }}); 4202101SN/A } 4212686Sksewell@umich.edu 0x1: decode TF { 4222686Sksewell@umich.edu 0x0: bc1fl({{ cond = getCondCode(FCSR, BRANCH_CC) == 0; 4232686Sksewell@umich.edu }}, Likely); 4242686Sksewell@umich.edu 0x1: bc1tl({{ cond = getCondCode(FCSR, BRANCH_CC) == 1; 4252686Sksewell@umich.edu }}, Likely); 4262101SN/A } 4272101SN/A } 4282101SN/A } 4292043SN/A } 4302027SN/A 4312101SN/A 0x1: decode RS_HI { 4322101SN/A 0x2: decode RS_LO { 4332101SN/A //Table A-14 MIPS32 COP1 Encoding of Function Field When rs=S 4342686Sksewell@umich.edu //(( single-precision floating point)) 4352572SN/A 0x0: decode FUNCTION_HI { 4362572SN/A 0x0: decode FUNCTION_LO { 4372101SN/A format FloatOp { 4382601SN/A 0x0: add_s({{ Fd.sf = Fs.sf + Ft.sf;}}); 4392601SN/A 0x1: sub_s({{ Fd.sf = Fs.sf - Ft.sf;}}); 4402601SN/A 0x2: mul_s({{ Fd.sf = Fs.sf * Ft.sf;}}); 4412601SN/A 0x3: div_s({{ Fd.sf = Fs.sf / Ft.sf;}}); 4422601SN/A 0x4: sqrt_s({{ Fd.sf = sqrt(Fs.sf);}}); 4432601SN/A 0x5: abs_s({{ Fd.sf = fabs(Fs.sf);}}); 4442686Sksewell@umich.edu 0x7: neg_s({{ Fd.sf = -Fs.sf;}}); 4452101SN/A } 4462742Sksewell@umich.edu 4472742Sksewell@umich.edu 0x6: BasicOp::mov_s({{ Fd.sf = Fs.sf;}}); 4482101SN/A } 4492027SN/A 4502572SN/A 0x1: decode FUNCTION_LO { 4512686Sksewell@umich.edu format FloatConvertOp { 4522686Sksewell@umich.edu 0x0: round_l_s({{ val = Fs.sf; }}, ToLong, 4532686Sksewell@umich.edu Round); 4542686Sksewell@umich.edu 0x1: trunc_l_s({{ val = Fs.sf; }}, ToLong, 4552686Sksewell@umich.edu Trunc); 4562686Sksewell@umich.edu 0x2: ceil_l_s({{ val = Fs.sf; }}, ToLong, 4572686Sksewell@umich.edu Ceil); 4582686Sksewell@umich.edu 0x3: floor_l_s({{ val = Fs.sf; }}, ToLong, 4592686Sksewell@umich.edu Floor); 4602686Sksewell@umich.edu 0x4: round_w_s({{ val = Fs.sf; }}, ToWord, 4612686Sksewell@umich.edu Round); 4622686Sksewell@umich.edu 0x5: trunc_w_s({{ val = Fs.sf; }}, ToWord, 4632686Sksewell@umich.edu Trunc); 4642686Sksewell@umich.edu 0x6: ceil_w_s({{ val = Fs.sf; }}, ToWord, 4652686Sksewell@umich.edu Ceil); 4662686Sksewell@umich.edu 0x7: floor_w_s({{ val = Fs.sf; }}, ToWord, 4672686Sksewell@umich.edu Floor); 4682101SN/A } 4692101SN/A } 4702027SN/A 4712572SN/A 0x2: decode FUNCTION_LO { 4722101SN/A 0x1: decode MOVCF { 4732686Sksewell@umich.edu format BasicOp { 4742686Sksewell@umich.edu 0x0: movf_s({{ Fd = (getCondCode(FCSR,CC) == 0) ? Fs : Fd; }}); 4752686Sksewell@umich.edu 0x1: movt_s({{ Fd = (getCondCode(FCSR,CC) == 1) ? Fs : Fd; }}); 4762101SN/A } 4772101SN/A } 4782027SN/A 4792686Sksewell@umich.edu format BasicOp { 4802686Sksewell@umich.edu 0x2: movz_s({{ Fd = (Rt == 0) ? Fs : Fd; }}); 4812686Sksewell@umich.edu 0x3: movn_s({{ Fd = (Rt != 0) ? Fs : Fd; }}); 4822686Sksewell@umich.edu } 4832686Sksewell@umich.edu 4842602SN/A format FloatOp { 4852602SN/A 0x5: recip_s({{ Fd = 1 / Fs; }}); 4862602SN/A 0x6: rsqrt_s({{ Fd = 1 / sqrt(Fs);}}); 4872101SN/A } 4882101SN/A } 4892027SN/A 4902572SN/A 0x4: decode FUNCTION_LO { 4912603SN/A format FloatConvertOp { 4922686Sksewell@umich.edu 0x1: cvt_d_s({{ val = Fs.sf; }}, ToDouble); 4932686Sksewell@umich.edu 0x4: cvt_w_s({{ val = Fs.sf; }}, ToWord); 4942686Sksewell@umich.edu 0x5: cvt_l_s({{ val = Fs.sf; }}, ToLong); 4952101SN/A } 4962055SN/A 4972686Sksewell@umich.edu 0x6: FloatOp::cvt_ps_s({{ 4982686Sksewell@umich.edu Fd.ud = (uint64_t) Fs.uw << 32 | 4992686Sksewell@umich.edu (uint64_t) Ft.uw; 5002101SN/A }}); 5012101SN/A } 5022602SN/A 5032602SN/A 0x6: decode FUNCTION_LO { 5042603SN/A format FloatCompareOp { 5052686Sksewell@umich.edu 0x0: c_f_s({{ cond = 0; }}, SinglePrecision, 5062686Sksewell@umich.edu UnorderedFalse); 5072686Sksewell@umich.edu 0x1: c_un_s({{ cond = 0; }}, SinglePrecision, 5082686Sksewell@umich.edu UnorderedTrue); 5092686Sksewell@umich.edu 0x2: c_eq_s({{ cond = (Fs.sf == Ft.sf); }}, 5102686Sksewell@umich.edu UnorderedFalse); 5112686Sksewell@umich.edu 0x3: c_ueq_s({{ cond = (Fs.sf == Ft.sf); }}, 5122686Sksewell@umich.edu UnorderedTrue); 5132686Sksewell@umich.edu 0x4: c_olt_s({{ cond = (Fs.sf < Ft.sf); }}, 5142686Sksewell@umich.edu UnorderedFalse); 5152686Sksewell@umich.edu 0x5: c_ult_s({{ cond = (Fs.sf < Ft.sf); }}, 5162686Sksewell@umich.edu UnorderedTrue); 5172686Sksewell@umich.edu 0x6: c_ole_s({{ cond = (Fs.sf <= Ft.sf); }}, 5182686Sksewell@umich.edu UnorderedFalse); 5192686Sksewell@umich.edu 0x7: c_ule_s({{ cond = (Fs.sf <= Ft.sf); }}, 5202686Sksewell@umich.edu UnorderedTrue); 5212602SN/A } 5222602SN/A } 5232602SN/A 5242602SN/A 0x7: decode FUNCTION_LO { 5252686Sksewell@umich.edu format FloatCompareOp { 5262686Sksewell@umich.edu 0x0: c_sf_s({{ cond = 0; }}, SinglePrecision, 5272686Sksewell@umich.edu UnorderedFalse, QnanException); 5282686Sksewell@umich.edu 0x1: c_ngle_s({{ cond = 0; }}, SinglePrecision, 5292686Sksewell@umich.edu UnorderedTrue, QnanException); 5302686Sksewell@umich.edu 0x2: c_seq_s({{ cond = (Fs.sf == Ft.sf);}}, 5312686Sksewell@umich.edu UnorderedFalse, QnanException); 5322686Sksewell@umich.edu 0x3: c_ngl_s({{ cond = (Fs.sf == Ft.sf); }}, 5332686Sksewell@umich.edu UnorderedTrue, QnanException); 5342686Sksewell@umich.edu 0x4: c_lt_s({{ cond = (Fs.sf < Ft.sf); }}, 5352686Sksewell@umich.edu UnorderedFalse, QnanException); 5362686Sksewell@umich.edu 0x5: c_nge_s({{ cond = (Fs.sf < Ft.sf); }}, 5372686Sksewell@umich.edu UnorderedTrue, QnanException); 5382686Sksewell@umich.edu 0x6: c_le_s({{ cond = (Fs.sf <= Ft.sf); }}, 5392686Sksewell@umich.edu UnorderedFalse, QnanException); 5402686Sksewell@umich.edu 0x7: c_ngt_s({{ cond = (Fs.sf <= Ft.sf); }}, 5412686Sksewell@umich.edu UnorderedTrue, QnanException); 5422602SN/A } 5432602SN/A } 5442101SN/A } 5452055SN/A 5462101SN/A //Table A-15 MIPS32 COP1 Encoding of Function Field When rs=D 5472572SN/A 0x1: decode FUNCTION_HI { 5482572SN/A 0x0: decode FUNCTION_LO { 5492101SN/A format FloatOp { 5502686Sksewell@umich.edu 0x0: add_d({{ Fd.df = Fs.df + Ft.df; }}); 5512686Sksewell@umich.edu 0x1: sub_d({{ Fd.df = Fs.df - Ft.df; }}); 5522686Sksewell@umich.edu 0x2: mul_d({{ Fd.df = Fs.df * Ft.df; }}); 5532686Sksewell@umich.edu 0x3: div_d({{ Fd.df = Fs.df / Ft.df; }}); 5542686Sksewell@umich.edu 0x4: sqrt_d({{ Fd.df = sqrt(Fs.df); }}); 5552686Sksewell@umich.edu 0x5: abs_d({{ Fd.df = fabs(Fs.df); }}); 5562686Sksewell@umich.edu 0x7: neg_d({{ Fd.df = -1 * Fs.df; }}); 5572101SN/A } 5582742Sksewell@umich.edu 5592742Sksewell@umich.edu 0x6: BasicOp::mov_d({{ Fd.df = Fs.df; }}); 5602101SN/A } 5612027SN/A 5622572SN/A 0x1: decode FUNCTION_LO { 5632686Sksewell@umich.edu format FloatConvertOp { 5642686Sksewell@umich.edu 0x0: round_l_d({{ val = Fs.df; }}, ToLong, 5652686Sksewell@umich.edu Round); 5662686Sksewell@umich.edu 0x1: trunc_l_d({{ val = Fs.df; }}, ToLong, 5672686Sksewell@umich.edu Trunc); 5682686Sksewell@umich.edu 0x2: ceil_l_d({{ val = Fs.df; }}, ToLong, 5692686Sksewell@umich.edu Ceil); 5702686Sksewell@umich.edu 0x3: floor_l_d({{ val = Fs.df; }}, ToLong, 5712686Sksewell@umich.edu Floor); 5722686Sksewell@umich.edu 0x4: round_w_d({{ val = Fs.df; }}, ToWord, 5732686Sksewell@umich.edu Round); 5742686Sksewell@umich.edu 0x5: trunc_w_d({{ val = Fs.df; }}, ToWord, 5752686Sksewell@umich.edu Trunc); 5762686Sksewell@umich.edu 0x6: ceil_w_d({{ val = Fs.df; }}, ToWord, 5772686Sksewell@umich.edu Ceil); 5782686Sksewell@umich.edu 0x7: floor_w_d({{ val = Fs.df; }}, ToWord, 5792686Sksewell@umich.edu Floor); 5802101SN/A } 5812101SN/A } 5822027SN/A 5832572SN/A 0x2: decode FUNCTION_LO { 5842101SN/A 0x1: decode MOVCF { 5852686Sksewell@umich.edu format BasicOp { 5862686Sksewell@umich.edu 0x0: movf_d({{ Fd.df = (getCondCode(FCSR,CC) == 0) ? 5872686Sksewell@umich.edu Fs.df : Fd.df; 5882686Sksewell@umich.edu }}); 5892686Sksewell@umich.edu 0x1: movt_d({{ Fd.df = (getCondCode(FCSR,CC) == 1) ? 5902686Sksewell@umich.edu Fs.df : Fd.df; 5912686Sksewell@umich.edu }}); 5922101SN/A } 5932101SN/A } 5942027SN/A 5952101SN/A format BasicOp { 5962686Sksewell@umich.edu 0x2: movz_d({{ Fd.df = (Rt == 0) ? Fs.df : Fd.df; }}); 5972686Sksewell@umich.edu 0x3: movn_d({{ Fd.df = (Rt != 0) ? Fs.df : Fd.df; }}); 5982101SN/A } 5992027SN/A 6002605SN/A format FloatOp { 6012686Sksewell@umich.edu 0x5: recip_d({{ Fd.df = 1 / Fs.df }}); 6022605SN/A 0x6: rsqrt_d({{ Fd.df = 1 / sqrt(Fs.df) }}); 6032101SN/A } 6042101SN/A } 6052027SN/A 6062572SN/A 0x4: decode FUNCTION_LO { 6072686Sksewell@umich.edu format FloatConvertOp { 6082686Sksewell@umich.edu 0x0: cvt_s_d({{ val = Fs.df; }}, ToSingle); 6092686Sksewell@umich.edu 0x4: cvt_w_d({{ val = Fs.df; }}, ToWord); 6102686Sksewell@umich.edu 0x5: cvt_l_d({{ val = Fs.df; }}, ToLong); 6112101SN/A } 6122101SN/A } 6132602SN/A 6142602SN/A 0x6: decode FUNCTION_LO { 6152604SN/A format FloatCompareOp { 6162686Sksewell@umich.edu 0x0: c_f_d({{ cond = 0; }}, DoublePrecision, 6172686Sksewell@umich.edu UnorderedFalse); 6182686Sksewell@umich.edu 0x1: c_un_d({{ cond = 0; }}, DoublePrecision, 6192686Sksewell@umich.edu UnorderedTrue); 6202686Sksewell@umich.edu 0x2: c_eq_d({{ cond = (Fs.df == Ft.df); }}, 6212686Sksewell@umich.edu UnorderedFalse); 6222686Sksewell@umich.edu 0x3: c_ueq_d({{ cond = (Fs.df == Ft.df); }}, 6232686Sksewell@umich.edu UnorderedTrue); 6242686Sksewell@umich.edu 0x4: c_olt_d({{ cond = (Fs.df < Ft.df); }}, 6252686Sksewell@umich.edu UnorderedFalse); 6262686Sksewell@umich.edu 0x5: c_ult_d({{ cond = (Fs.df < Ft.df); }}, 6272686Sksewell@umich.edu UnorderedTrue); 6282686Sksewell@umich.edu 0x6: c_ole_d({{ cond = (Fs.df <= Ft.df); }}, 6292686Sksewell@umich.edu UnorderedFalse); 6302686Sksewell@umich.edu 0x7: c_ule_d({{ cond = (Fs.df <= Ft.df); }}, 6312686Sksewell@umich.edu UnorderedTrue); 6322602SN/A } 6332602SN/A } 6342602SN/A 6352602SN/A 0x7: decode FUNCTION_LO { 6362686Sksewell@umich.edu format FloatCompareOp { 6372686Sksewell@umich.edu 0x0: c_sf_d({{ cond = 0; }}, DoublePrecision, 6382686Sksewell@umich.edu UnorderedFalse, QnanException); 6392686Sksewell@umich.edu 0x1: c_ngle_d({{ cond = 0; }}, DoublePrecision, 6402686Sksewell@umich.edu UnorderedTrue, QnanException); 6412686Sksewell@umich.edu 0x2: c_seq_d({{ cond = (Fs.df == Ft.df); }}, 6422686Sksewell@umich.edu UnorderedFalse, QnanException); 6432686Sksewell@umich.edu 0x3: c_ngl_d({{ cond = (Fs.df == Ft.df); }}, 6442686Sksewell@umich.edu UnorderedTrue, QnanException); 6452686Sksewell@umich.edu 0x4: c_lt_d({{ cond = (Fs.df < Ft.df); }}, 6462686Sksewell@umich.edu UnorderedFalse, QnanException); 6472686Sksewell@umich.edu 0x5: c_nge_d({{ cond = (Fs.df < Ft.df); }}, 6482686Sksewell@umich.edu UnorderedTrue, QnanException); 6492686Sksewell@umich.edu 0x6: c_le_d({{ cond = (Fs.df <= Ft.df); }}, 6502686Sksewell@umich.edu UnorderedFalse, QnanException); 6512686Sksewell@umich.edu 0x7: c_ngt_d({{ cond = (Fs.df <= Ft.df); }}, 6522686Sksewell@umich.edu UnorderedTrue, QnanException); 6532602SN/A } 6542602SN/A } 6552101SN/A } 6562027SN/A 6572101SN/A //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=W 6582101SN/A 0x4: decode FUNCTION { 6592605SN/A format FloatConvertOp { 6602686Sksewell@umich.edu 0x20: cvt_s_w({{ val = Fs.uw; }}, ToSingle); 6612686Sksewell@umich.edu 0x21: cvt_d_w({{ val = Fs.uw; }}, ToDouble); 6622686Sksewell@umich.edu 0x26: FailUnimpl::cvt_ps_w(); 6632101SN/A } 6642101SN/A } 6652027SN/A 6662101SN/A //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=L1 6672101SN/A //Note: "1. Format type L is legal only if 64-bit floating point operations 6682101SN/A //are enabled." 6692101SN/A 0x5: decode FUNCTION_HI { 6702686Sksewell@umich.edu format FloatConvertOp { 6712686Sksewell@umich.edu 0x20: cvt_s_l({{ val = Fs.ud; }}, ToSingle); 6722686Sksewell@umich.edu 0x21: cvt_d_l({{ val = Fs.ud; }}, ToDouble); 6732686Sksewell@umich.edu 0x26: FailUnimpl::cvt_ps_l(); 6742101SN/A } 6752101SN/A } 6762101SN/A 6772101SN/A //Table A-17 MIPS64 COP1 Encoding of Function Field When rs=PS1 6782101SN/A //Note: "1. Format type PS is legal only if 64-bit floating point operations 6792101SN/A //are enabled. " 6802572SN/A 0x6: decode FUNCTION_HI { 6812572SN/A 0x0: decode FUNCTION_LO { 6822101SN/A format Float64Op { 6832605SN/A 0x0: add_ps({{ 6842607SN/A Fd1.sf = Fs1.sf + Ft2.sf; 6852607SN/A Fd2.sf = Fs2.sf + Ft2.sf; 6862101SN/A }}); 6872605SN/A 0x1: sub_ps({{ 6882607SN/A Fd1.sf = Fs1.sf - Ft2.sf; 6892607SN/A Fd2.sf = Fs2.sf - Ft2.sf; 6902101SN/A }}); 6912605SN/A 0x2: mul_ps({{ 6922607SN/A Fd1.sf = Fs1.sf * Ft2.sf; 6932607SN/A Fd2.sf = Fs2.sf * Ft2.sf; 6942101SN/A }}); 6952605SN/A 0x5: abs_ps({{ 6962607SN/A Fd1.sf = fabs(Fs1.sf); 6972607SN/A Fd2.sf = fabs(Fs2.sf); 6982101SN/A }}); 6992605SN/A 0x6: mov_ps({{ 7002607SN/A Fd1.sf = Fs1.sf; 7012607SN/A Fd2.sf = Fs2.sf; 7022101SN/A }}); 7032605SN/A 0x7: neg_ps({{ 7042686Sksewell@umich.edu Fd1.sf = -(Fs1.sf); 7052686Sksewell@umich.edu Fd2.sf = -(Fs2.sf); 7062101SN/A }}); 7072101SN/A } 7082101SN/A } 7092101SN/A 7102572SN/A 0x2: decode FUNCTION_LO { 7112101SN/A 0x1: decode MOVCF { 7122101SN/A format Float64Op { 7132607SN/A 0x0: movf_ps({{ 7142686Sksewell@umich.edu Fd1 = (getCondCode(FCSR, CC) == 0) ? 7152686Sksewell@umich.edu Fs1 : Fd1; 7162686Sksewell@umich.edu Fd2 = (getCondCode(FCSR, CC+1) == 0) ? 7172686Sksewell@umich.edu Fs2 : Fd2; 7182607SN/A }}); 7192607SN/A 0x1: movt_ps({{ 7202686Sksewell@umich.edu Fd2 = (getCondCode(FCSR, CC) == 1) ? 7212686Sksewell@umich.edu Fs1 : Fd1; 7222686Sksewell@umich.edu Fd2 = (getCondCode(FCSR, CC+1) == 1) ? 7232686Sksewell@umich.edu Fs2 : Fd2; 7242607SN/A }}); 7252101SN/A } 7262101SN/A } 7272101SN/A 7282605SN/A format Float64Op { 7292607SN/A 0x2: movz_ps({{ 7302686Sksewell@umich.edu Fd1 = (getCondCode(FCSR, CC) == 0) ? 7312686Sksewell@umich.edu Fs1 : Fd1; 7322686Sksewell@umich.edu Fd2 = (getCondCode(FCSR, CC) == 0) ? 7332686Sksewell@umich.edu Fs2 : Fd2; 7342607SN/A }}); 7352607SN/A 0x3: movn_ps({{ 7362686Sksewell@umich.edu Fd1 = (getCondCode(FCSR, CC) == 1) ? 7372686Sksewell@umich.edu Fs1 : Fd1; 7382686Sksewell@umich.edu Fd2 = (getCondCode(FCSR, CC) == 1) ? 7392686Sksewell@umich.edu Fs2 : Fd2; 7402607SN/A }}); 7412135SN/A } 7422135SN/A 7432101SN/A } 7442101SN/A 7452572SN/A 0x4: decode FUNCTION_LO { 7462686Sksewell@umich.edu 0x0: FloatOp::cvt_s_pu({{ Fd.sf = Fs2.sf; }}); 7472101SN/A } 7482101SN/A 7492572SN/A 0x5: decode FUNCTION_LO { 7502686Sksewell@umich.edu 0x0: FloatOp::cvt_s_pl({{ Fd.sf = Fs1.sf; }}); 7512686Sksewell@umich.edu 7522101SN/A format Float64Op { 7532686Sksewell@umich.edu 0x4: pll({{ Fd.ud = (uint64_t) Fs1.uw << 32 | 7542686Sksewell@umich.edu Ft1.uw; 7552686Sksewell@umich.edu }}); 7562686Sksewell@umich.edu 0x5: plu({{ Fd.ud = (uint64_t) Fs1.uw << 32 | 7572686Sksewell@umich.edu Ft2.uw; 7582686Sksewell@umich.edu }}); 7592686Sksewell@umich.edu 0x6: pul({{ Fd.ud = (uint64_t) Fs2.uw << 32 | 7602686Sksewell@umich.edu Ft1.uw; 7612686Sksewell@umich.edu }}); 7622686Sksewell@umich.edu 0x7: puu({{ Fd.ud = (uint64_t) Fs2.uw << 32 | 7632686Sksewell@umich.edu Ft2.uw; 7642686Sksewell@umich.edu }}); 7652101SN/A } 7662101SN/A } 7672602SN/A 7682602SN/A 0x6: decode FUNCTION_LO { 7692608SN/A format FloatPSCompareOp { 7702686Sksewell@umich.edu 0x0: c_f_ps({{ cond1 = 0; }}, {{ cond2 = 0; }}, 7712686Sksewell@umich.edu UnorderedFalse); 7722686Sksewell@umich.edu 0x1: c_un_ps({{ cond1 = 0; }}, {{ cond2 = 0; }}, 7732686Sksewell@umich.edu UnorderedTrue); 7742686Sksewell@umich.edu 0x2: c_eq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }}, 7752686Sksewell@umich.edu {{ cond2 = (Fs2.sf == Ft2.sf); }}, 7762686Sksewell@umich.edu UnorderedFalse); 7772686Sksewell@umich.edu 0x3: c_ueq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }}, 7782686Sksewell@umich.edu {{ cond2 = (Fs2.sf == Ft2.sf); }}, 7792686Sksewell@umich.edu UnorderedTrue); 7802686Sksewell@umich.edu 0x4: c_olt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }}, 7812686Sksewell@umich.edu {{ cond2 = (Fs2.sf < Ft2.sf); }}, 7822686Sksewell@umich.edu UnorderedFalse); 7832686Sksewell@umich.edu 0x5: c_ult_ps({{ cond1 = (Fs.sf < Ft.sf); }}, 7842686Sksewell@umich.edu {{ cond2 = (Fs2.sf < Ft2.sf); }}, 7852686Sksewell@umich.edu UnorderedTrue); 7862686Sksewell@umich.edu 0x6: c_ole_ps({{ cond1 = (Fs.sf <= Ft.sf); }}, 7872686Sksewell@umich.edu {{ cond2 = (Fs2.sf <= Ft2.sf); }}, 7882686Sksewell@umich.edu UnorderedFalse); 7892686Sksewell@umich.edu 0x7: c_ule_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }}, 7902686Sksewell@umich.edu {{ cond2 = (Fs2.sf <= Ft2.sf); }}, 7912686Sksewell@umich.edu UnorderedTrue); 7922602SN/A } 7932602SN/A } 7942602SN/A 7952602SN/A 0x7: decode FUNCTION_LO { 7962686Sksewell@umich.edu format FloatPSCompareOp { 7972686Sksewell@umich.edu 0x0: c_sf_ps({{ cond1 = 0; }}, {{ cond2 = 0; }}, 7982686Sksewell@umich.edu UnorderedFalse, QnanException); 7992686Sksewell@umich.edu 0x1: c_ngle_ps({{ cond1 = 0; }}, 8002686Sksewell@umich.edu {{ cond2 = 0; }}, 8012686Sksewell@umich.edu UnorderedTrue, QnanException); 8022686Sksewell@umich.edu 0x2: c_seq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }}, 8032686Sksewell@umich.edu {{ cond2 = (Fs2.sf == Ft2.sf); }}, 8042686Sksewell@umich.edu UnorderedFalse, QnanException); 8052686Sksewell@umich.edu 0x3: c_ngl_ps({{ cond1 = (Fs1.sf == Ft1.sf); }}, 8062686Sksewell@umich.edu {{ cond2 = (Fs2.sf == Ft2.sf); }}, 8072686Sksewell@umich.edu UnorderedTrue, QnanException); 8082686Sksewell@umich.edu 0x4: c_lt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }}, 8092686Sksewell@umich.edu {{ cond2 = (Fs2.sf < Ft2.sf); }}, 8102686Sksewell@umich.edu UnorderedFalse, QnanException); 8112686Sksewell@umich.edu 0x5: c_nge_ps({{ cond1 = (Fs1.sf < Ft1.sf); }}, 8122686Sksewell@umich.edu {{ cond2 = (Fs2.sf < Ft2.sf); }}, 8132686Sksewell@umich.edu UnorderedTrue, QnanException); 8142686Sksewell@umich.edu 0x6: c_le_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }}, 8152686Sksewell@umich.edu {{ cond2 = (Fs2.sf <= Ft2.sf); }}, 8162686Sksewell@umich.edu UnorderedFalse, QnanException); 8172686Sksewell@umich.edu 0x7: c_ngt_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }}, 8182686Sksewell@umich.edu {{ cond2 = (Fs2.sf <= Ft2.sf); }}, 8192686Sksewell@umich.edu UnorderedTrue, QnanException); 8202602SN/A } 8212602SN/A } 8222101SN/A } 8232101SN/A } 8242101SN/A } 8252101SN/A } 8262101SN/A 8272101SN/A //Table A-19 MIPS32 COP2 Encoding of rs Field 8282101SN/A 0x2: decode RS_MSB { 8292686Sksewell@umich.edu format FailUnimpl { 8302686Sksewell@umich.edu 0x0: decode RS_HI { 8312686Sksewell@umich.edu 0x0: decode RS_LO { 8322101SN/A 0x0: mfc2(); 8332101SN/A 0x2: cfc2(); 8342101SN/A 0x3: mfhc2(); 8352101SN/A 0x4: mtc2(); 8362101SN/A 0x6: ctc2(); 8372101SN/A 0x7: mftc2(); 8382101SN/A } 8392101SN/A 8402686Sksewell@umich.edu 0x1: decode ND { 8412686Sksewell@umich.edu 0x0: decode TF { 8422101SN/A 0x0: bc2f(); 8432101SN/A 0x1: bc2t(); 8442101SN/A } 8452101SN/A 8462686Sksewell@umich.edu 0x1: decode TF { 8472101SN/A 0x0: bc2fl(); 8482101SN/A 0x1: bc2tl(); 8492101SN/A } 8502101SN/A } 8512101SN/A } 8522101SN/A } 8532101SN/A } 8542101SN/A 8552101SN/A //Table A-20 MIPS64 COP1X Encoding of Function Field 1 8562101SN/A //Note: "COP1X instructions are legal only if 64-bit floating point 8572101SN/A //operations are enabled." 8582101SN/A 0x3: decode FUNCTION_HI { 8592101SN/A 0x0: decode FUNCTION_LO { 8602686Sksewell@umich.edu format LoadIndexedMemory { 8612742Sksewell@umich.edu 0x0: lwxc1({{ Fd.uw = Mem.uw;}}); 8622742Sksewell@umich.edu 0x1: ldxc1({{ Fd.ud = Mem.ud;}}); 8632750Sksewell@umich.edu 0x5: luxc1({{ Fd.ud = Mem.ud;}}, 8642742Sksewell@umich.edu {{ EA = (Rs + Rt) & ~7; }}); 8652101SN/A } 8662043SN/A } 8672027SN/A 8682101SN/A 0x1: decode FUNCTION_LO { 8692686Sksewell@umich.edu format StoreIndexedMemory { 8702742Sksewell@umich.edu 0x0: swxc1({{ Mem.uw = Fs.uw;}}); 8712742Sksewell@umich.edu 0x1: sdxc1({{ Mem.ud = Fs.ud;}}); 8722742Sksewell@umich.edu 0x5: suxc1({{ Mem.ud = Fs.ud;}}, 8732742Sksewell@umich.edu {{ EA = (Rs + Rt) & ~7; }}); 8742046SN/A } 8752084SN/A 8762686Sksewell@umich.edu 0x7: Prefetch::prefx({{ EA = Rs + Rt; }}); 8772101SN/A } 8782027SN/A 8792686Sksewell@umich.edu 0x3: decode FUNCTION_LO { 8802686Sksewell@umich.edu 0x6: Float64Op::alnv_ps({{ if (Rs<2:0> == 0) { 8812686Sksewell@umich.edu Fd.ud = Fs.ud; 8822686Sksewell@umich.edu } else if (Rs<2:0> == 4) { 8832686Sksewell@umich.edu #if BYTE_ORDER == BIG_ENDIAN 8842686Sksewell@umich.edu Fd.ud = Fs.ud<31:0> << 32 | 8852686Sksewell@umich.edu Ft.ud<63:32>; 8862686Sksewell@umich.edu #elif BYTE_ORDER == LITTLE_ENDIAN 8872686Sksewell@umich.edu Fd.ud = Ft.ud<31:0> << 32 | 8882686Sksewell@umich.edu Fs.ud<63:32>; 8892686Sksewell@umich.edu #endif 8902686Sksewell@umich.edu } else { 8912686Sksewell@umich.edu Fd.ud = Fd.ud; 8922686Sksewell@umich.edu } 8932686Sksewell@umich.edu }}); 8942686Sksewell@umich.edu } 8952027SN/A 8962686Sksewell@umich.edu format FloatAccOp { 8972686Sksewell@umich.edu 0x4: decode FUNCTION_LO { 8982686Sksewell@umich.edu 0x0: madd_s({{ Fd.sf = (Fs.sf * Ft.sf) + Fr.sf; }}); 8992686Sksewell@umich.edu 0x1: madd_d({{ Fd.df = (Fs.df * Ft.df) + Fr.df; }}); 9002686Sksewell@umich.edu 0x6: madd_ps({{ 9012686Sksewell@umich.edu Fd1.sf = (Fs1.df * Ft1.df) + Fr1.df; 9022686Sksewell@umich.edu Fd2.sf = (Fs2.df * Ft2.df) + Fr2.df; 9032686Sksewell@umich.edu }}); 9042686Sksewell@umich.edu } 9052027SN/A 9062686Sksewell@umich.edu 0x5: decode FUNCTION_LO { 9072686Sksewell@umich.edu 0x0: msub_s({{ Fd.sf = (Fs.sf * Ft.sf) - Fr.sf; }}); 9082686Sksewell@umich.edu 0x1: msub_d({{ Fd.df = (Fs.df * Ft.df) - Fr.df; }}); 9092686Sksewell@umich.edu 0x6: msub_ps({{ 9102686Sksewell@umich.edu Fd1.sf = (Fs1.df * Ft1.df) - Fr1.df; 9112686Sksewell@umich.edu Fd2.sf = (Fs2.df * Ft2.df) - Fr2.df; 9122686Sksewell@umich.edu }}); 9132686Sksewell@umich.edu } 9142027SN/A 9152686Sksewell@umich.edu 0x6: decode FUNCTION_LO { 9162686Sksewell@umich.edu 0x0: nmadd_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }}); 9172686Sksewell@umich.edu 0x1: nmadd_d({{ Fd.df = (-1 * Fs.df * Ft.df) + Fr.df; }}); 9182686Sksewell@umich.edu 0x6: nmadd_ps({{ 9192686Sksewell@umich.edu Fd1.sf = -((Fs1.df * Ft1.df) + Fr1.df); 9202686Sksewell@umich.edu Fd2.sf = -((Fs2.df * Ft2.df) + Fr2.df); 9212686Sksewell@umich.edu }}); 9222686Sksewell@umich.edu } 9232027SN/A 9242686Sksewell@umich.edu 0x7: decode FUNCTION_LO { 9252686Sksewell@umich.edu 0x0: nmsub_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }}); 9262686Sksewell@umich.edu 0x1: nmsub_d({{ Fd.df = (-1 * Fs.df * Ft.df) - Fr.df; }}); 9272686Sksewell@umich.edu 0x6: nmsub_ps({{ 9282686Sksewell@umich.edu Fd1.sf = -((Fs1.df * Ft1.df) - Fr1.df); 9292686Sksewell@umich.edu Fd2.sf = -((Fs2.df * Ft2.df) - Fr2.df); 9302686Sksewell@umich.edu }}); 9312046SN/A } 9322686Sksewell@umich.edu 9332101SN/A } 9342043SN/A } 9352025SN/A 9362686Sksewell@umich.edu format Branch { 9372686Sksewell@umich.edu 0x4: beql({{ cond = (Rs.sw == Rt.sw); }}, Likely); 9382686Sksewell@umich.edu 0x5: bnel({{ cond = (Rs.sw != Rt.sw); }}, Likely); 9392686Sksewell@umich.edu 0x6: blezl({{ cond = (Rs.sw <= 0); }}, Likely); 9402686Sksewell@umich.edu 0x7: bgtzl({{ cond = (Rs.sw > 0); }}, Likely); 9412046SN/A } 9422084SN/A } 9432024SN/A 9442686Sksewell@umich.edu 0x3: decode OPCODE_LO { 9452043SN/A //Table A-5 MIPS32 SPECIAL2 Encoding of Function Field 9462043SN/A 0x4: decode FUNCTION_HI { 9472686Sksewell@umich.edu 0x0: decode FUNCTION_LO { 9482686Sksewell@umich.edu 0x2: IntOp::mul({{ int64_t temp1 = Rs.sd * Rt.sd; 9492686Sksewell@umich.edu Rd.sw = temp1<31:0> 9502686Sksewell@umich.edu }}); 9512027SN/A 9522686Sksewell@umich.edu format HiLoOp { 9532686Sksewell@umich.edu 0x0: madd({{ val = ((int64_t) HI << 32 | LO) + 9542686Sksewell@umich.edu (Rs.sd * Rt.sd); 9552686Sksewell@umich.edu }}); 9562686Sksewell@umich.edu 0x1: maddu({{ val = ((uint64_t) HI << 32 | LO) + 9572686Sksewell@umich.edu (Rs.ud * Rt.ud); 9582686Sksewell@umich.edu }}); 9592686Sksewell@umich.edu 0x4: msub({{ val = ((int64_t) HI << 32 | LO) - 9602686Sksewell@umich.edu (Rs.sd * Rt.sd); 9612686Sksewell@umich.edu }}); 9622686Sksewell@umich.edu 0x5: msubu({{ val = ((uint64_t) HI << 32 | LO) - 9632686Sksewell@umich.edu (Rs.ud * Rt.ud); 9642686Sksewell@umich.edu }}); 9652043SN/A } 9662043SN/A } 9672027SN/A 9682043SN/A 0x4: decode FUNCTION_LO { 9692101SN/A format BasicOp { 9702686Sksewell@umich.edu 0x0: clz({{ int cnt = 32; 9712686Sksewell@umich.edu for (int idx = 31; idx >= 0; idx--) { 9722686Sksewell@umich.edu if( Rs<idx:idx> == 1) { 9732686Sksewell@umich.edu cnt = 31 - idx; 9742686Sksewell@umich.edu break; 9752686Sksewell@umich.edu } 9762686Sksewell@umich.edu } 9772686Sksewell@umich.edu Rd.uw = cnt; 9782686Sksewell@umich.edu }}); 9792686Sksewell@umich.edu 0x1: clo({{ int cnt = 32; 9802686Sksewell@umich.edu for (int idx = 31; idx >= 0; idx--) { 9812686Sksewell@umich.edu if( Rs<idx:idx> == 0) { 9822686Sksewell@umich.edu cnt = 31 - idx; 9832686Sksewell@umich.edu break; 9842686Sksewell@umich.edu } 9852686Sksewell@umich.edu } 9862686Sksewell@umich.edu Rd.uw = cnt; 9872686Sksewell@umich.edu }}); 9882101SN/A } 9892043SN/A } 9902027SN/A 9912043SN/A 0x7: decode FUNCTION_LO { 9922686Sksewell@umich.edu 0x7: FailUnimpl::sdbbp(); 9932043SN/A } 9942043SN/A } 9952024SN/A 9962686Sksewell@umich.edu //Table A-6 MIPS32 SPECIAL3 Encoding of Function Field for Release 2 9972686Sksewell@umich.edu //of the Architecture 9982043SN/A 0x7: decode FUNCTION_HI { 9992101SN/A 0x0: decode FUNCTION_LO { 10002686Sksewell@umich.edu format BasicOp { 10012742Sksewell@umich.edu 0x0: ext({{ Rt.uw = bits(Rs.uw, MSB+LSB, LSB); }}); 10022686Sksewell@umich.edu 0x4: ins({{ Rt.uw = bits(Rt.uw, 31, MSB+1) << (MSB+1) | 10032686Sksewell@umich.edu bits(Rs.uw, MSB-LSB, 0) << LSB | 10042686Sksewell@umich.edu bits(Rt.uw, LSB-1, 0); 10052686Sksewell@umich.edu }}); 10062046SN/A } 10072101SN/A } 10082026SN/A 10092101SN/A 0x1: decode FUNCTION_LO { 10102686Sksewell@umich.edu format MipsMT { 10112084SN/A 0x0: fork(); 10122084SN/A 0x1: yield(); 10132061SN/A } 10142101SN/A } 10152061SN/A 10162101SN/A //Table A-10 MIPS32 BSHFL Encoding of sa Field 10172101SN/A 0x4: decode SA { 10182046SN/A format BasicOp { 10192686Sksewell@umich.edu 0x02: wsbh({{ Rd.uw = Rt.uw<23:16> << 24 | 10202686Sksewell@umich.edu Rt.uw<31:24> << 16 | 10212686Sksewell@umich.edu Rt.uw<7:0> << 8 | 10222686Sksewell@umich.edu Rt.uw<15:8>; 10232686Sksewell@umich.edu }}); 10242742Sksewell@umich.edu 0x10: seb({{ Rd.sw = Rt.sb; }}); 10252742Sksewell@umich.edu 0x18: seh({{ Rd.sw = Rt.sh; }}); 10262046SN/A } 10272101SN/A } 10282043SN/A 10292101SN/A 0x6: decode FUNCTION_LO { 10302686Sksewell@umich.edu 0x7: FailUnimpl::rdhwr(); 10312101SN/A } 10322043SN/A } 10332084SN/A } 10342024SN/A 10352686Sksewell@umich.edu 0x4: decode OPCODE_LO { 10362124SN/A format LoadMemory { 10372239SN/A 0x0: lb({{ Rt.sw = Mem.sb; }}); 10382239SN/A 0x1: lh({{ Rt.sw = Mem.sh; }}); 10392479SN/A 0x3: lw({{ Rt.sw = Mem.sw; }}); 10402239SN/A 0x4: lbu({{ Rt.uw = Mem.ub; }}); 10412239SN/A 0x5: lhu({{ Rt.uw = Mem.uh; }}); 10422686Sksewell@umich.edu } 10432495SN/A 10442686Sksewell@umich.edu format LoadUnalignedMemory { 10452686Sksewell@umich.edu 0x2: lwl({{ uint32_t mem_shift = 24 - (8 * byte_offset); 10462686Sksewell@umich.edu Rt.uw = mem_word << mem_shift | 10472686Sksewell@umich.edu Rt.uw & mask(mem_shift); 10482686Sksewell@umich.edu }}); 10492686Sksewell@umich.edu 0x6: lwr({{ uint32_t mem_shift = 8 * byte_offset; 10502686Sksewell@umich.edu Rt.uw = Rt.uw & (mask(mem_shift) << (32 - mem_shift)) | 10512686Sksewell@umich.edu mem_word >> mem_shift; 10522686Sksewell@umich.edu }}); 10532084SN/A } 10542084SN/A } 10552024SN/A 10562686Sksewell@umich.edu 0x5: decode OPCODE_LO { 10572124SN/A format StoreMemory { 10582124SN/A 0x0: sb({{ Mem.ub = Rt<7:0>; }}); 10592124SN/A 0x1: sh({{ Mem.uh = Rt<15:0>; }}); 10602479SN/A 0x3: sw({{ Mem.uw = Rt<31:0>; }}); 10612084SN/A } 10622024SN/A 10632686Sksewell@umich.edu format StoreUnalignedMemory { 10642686Sksewell@umich.edu 0x2: swl({{ uint32_t reg_shift = 24 - (8 * byte_offset); 10652686Sksewell@umich.edu uint32_t mem_shift = 32 - reg_shift; 10662686Sksewell@umich.edu mem_word = mem_word & (mask(reg_shift) << mem_shift) | 10672686Sksewell@umich.edu Rt.uw >> reg_shift; 10682686Sksewell@umich.edu }}); 10692686Sksewell@umich.edu 0x6: swr({{ uint32_t reg_shift = 8 * byte_offset; 10702686Sksewell@umich.edu mem_word = Rt.uw << reg_shift | 10712686Sksewell@umich.edu mem_word & (mask(reg_shift)); 10722686Sksewell@umich.edu }}); 10732084SN/A } 10742024SN/A 10752686Sksewell@umich.edu 0x7: FailUnimpl::cache(); 10762084SN/A } 10772024SN/A 10782686Sksewell@umich.edu 0x6: decode OPCODE_LO { 10792686Sksewell@umich.edu format LoadMemory { 10802686Sksewell@umich.edu 0x0: ll({{ Rt.uw = Mem.uw; }}, mem_flags=LOCKED); 10812686Sksewell@umich.edu 0x1: lwc1({{ Ft.uw = Mem.uw; }}); 10822573SN/A 0x5: ldc1({{ Ft.ud = Mem.ud; }}); 10832084SN/A } 10842686Sksewell@umich.edu 10852686Sksewell@umich.edu 0x3: Prefetch::pref(); 10862084SN/A } 10872024SN/A 10882239SN/A 10892686Sksewell@umich.edu 0x7: decode OPCODE_LO { 10902686Sksewell@umich.edu 0x0: StoreCond::sc({{ Mem.uw = Rt.uw;}}, 10912686Sksewell@umich.edu {{ uint64_t tmp = write_result; 10922686Sksewell@umich.edu Rt.uw = (tmp == 0 || tmp == 1) ? tmp : Rt.uw; 10932935Sksewell@umich.edu }}, mem_flags=LOCKED, inst_flags = IsStoreConditional); 10942055SN/A 10952686Sksewell@umich.edu format StoreMemory { 10962573SN/A 0x1: swc1({{ Mem.uw = Ft.uw; }}); 10972573SN/A 0x5: sdc1({{ Mem.ud = Ft.ud; }}); 10982084SN/A } 10992027SN/A } 11002024SN/A} 11012022SN/A 11022027SN/A 1103