decoder.isa revision 2469
12686Sksewell@umich.edu// -*- mode:c++ -*-
22100SN/A
32754Sksewell@umich.edu////////////////////////////////////////////////////////////////////
42706Sksewell@umich.edu//
52706Sksewell@umich.edu// The actual MIPS32 ISA decoder
62706Sksewell@umich.edu// -----------------------------
72706Sksewell@umich.edu// The following instructions are specified in the MIPS32 ISA
82706Sksewell@umich.edu// Specification. Decoding closely follows the style specified
92706Sksewell@umich.edu// in the MIPS32 ISAthe specification document starting with Table
102706Sksewell@umich.edu// A-2 (document available @ www.mips.com)
112706Sksewell@umich.edu//
122706Sksewell@umich.edu//@todo: Distinguish "unknown/future" use insts from "reserved"
132706Sksewell@umich.edu// ones
142706Sksewell@umich.edudecode OPCODE_HI default Unknown::unknown() {
152706Sksewell@umich.edu
162706Sksewell@umich.edu    // Derived From ... Table A-2 MIPS32 ISA Manual
172706Sksewell@umich.edu    0x0: decode OPCODE_LO {
182706Sksewell@umich.edu
192706Sksewell@umich.edu        0x0: decode FUNCTION_HI {
202706Sksewell@umich.edu            0x0: decode FUNCTION_LO {
212706Sksewell@umich.edu                0x1: decode MOVCI {
222706Sksewell@umich.edu                    format BasicOp {
232706Sksewell@umich.edu                        0: movf({{ if (xc->readMiscReg(FPCR) != CC) Rd = Rs}});
242706Sksewell@umich.edu                        1: movt({{ if (xc->readMiscReg(FPCR) == CC) Rd = Rs}});
252706Sksewell@umich.edu                    }
262706Sksewell@umich.edu                }
272706Sksewell@umich.edu
282706Sksewell@umich.edu                format BasicOp {
292706Sksewell@umich.edu
302706Sksewell@umich.edu                    //Table A-3 Note: "1. Specific encodings of the rt, rd, and sa fields
312022SN/A                    //are used to distinguish among the SLL, NOP, SSNOP and EHB functions."
322022SN/A
332043SN/A                    0x0: decode RS {
342024SN/A                        0x0: sll({{ Rd = Rt.uw << SA; }});
352024SN/A                        //0x0:nop({{ ; }});  //really sll r0,r0,0
362043SN/A                        //	    0x1:ssnop({{ ; }});//really sll r0,r0,1
372686Sksewell@umich.edu                        //    0x3:ehb({{ ; }});  //really sll r0,r0,3
382024SN/A                    }
392022SN/A
402083SN/A                    0x2: decode SRL {
412686Sksewell@umich.edu                        0: srl({{ Rd = Rt.uw >> SA; }});
422101SN/A
432043SN/A                        //Hardcoded assuming 32-bit ISA, probably need parameter here
442043SN/A                        1: rotr({{ Rd = (Rt.uw << (32 - SA)) | (Rt.uw >> SA);}});
452101SN/A                    }
462101SN/A
472686Sksewell@umich.edu                    0x3: sra({{ Rd = Rt.sw >> SA; }});
482686Sksewell@umich.edu
492101SN/A                    0x4: sllv({{ Rd = Rt.uw << Rs<4:0>; }});
502101SN/A
512101SN/A                    0x6: decode SRLV {
522046SN/A                        0: srlv({{ Rd = Rt.uw >> Rs<4:0>; }});
532686Sksewell@umich.edu
542686Sksewell@umich.edu                        //Hardcoded assuming 32-bit ISA, probably need parameter here
552686Sksewell@umich.edu                        1: rotrv({{ Rd = (Rt.uw << (32 - Rs<4:0>)) | (Rt.uw >> Rs<4:0>);}});
562470SN/A                    }
572686Sksewell@umich.edu
582686Sksewell@umich.edu                    0x7: srav({{ Rd = Rt.sw >> Rs<4:0>; }});
592686Sksewell@umich.edu                }
602686Sksewell@umich.edu            }
612686Sksewell@umich.edu
622686Sksewell@umich.edu            0x1: decode FUNCTION_LO {
632470SN/A
642241SN/A                //Table A-3 Note: "Specific encodings of the hint field are used
652101SN/A                //to distinguish JR from JR.HB and JALR from JALR.HB"
662495SN/A                format Jump {
672495SN/A                    0x0: decode HINT {
682495SN/A                        0:jr({{ NNPC = Rs & ~1; }},IsReturn);
692101SN/A
702495SN/A                        1:jr_hb({{ NNPC = Rs & ~1; clear_exe_inst_hazards(); }},IsReturn);
712495SN/A                    }
722495SN/A
732101SN/A                    0x1: decode HINT {
742101SN/A                        0: jalr({{ NNPC = Rs; }},IsCall,IsReturn);
752495SN/A
762495SN/A                        1: jalr_hb({{ NNPC = Rs; clear_exe_inst_hazards();}},IsCall,IsReturn);
772495SN/A                    }
782495SN/A                }
792495SN/A
802495SN/A                format BasicOp {
812495SN/A                    0x2: movz({{ if (Rt == 0) Rd = Rs; }});
822495SN/A                    0x3: movn({{ if (Rt != 0) Rd = Rs; }});
832495SN/A                }
842495SN/A
852495SN/A                format WarnUnimpl {
862495SN/A                    0x4: syscall();//{{ xc->syscall()}},IsNonSpeculative
872495SN/A                    0x5: break();
882101SN/A                    0x7: sync();
892101SN/A                }
902101SN/A            }
912101SN/A
922101SN/A            0x2: decode FUNCTION_LO {
932101SN/A                format BasicOp {
942101SN/A                    0x0: mfhi({{ Rd = xc->readMiscReg(Hi); }});
952101SN/A                    0x1: mthi({{ xc->setMiscReg(Hi,Rs); }});
962101SN/A                    0x2: mflo({{ Rd = xc->readMiscReg(Lo); }});
972101SN/A                    0x3: mtlo({{ xc->setMiscReg(Lo,Rs); }});
982495SN/A                }
992495SN/A            }
1002495SN/A
1012495SN/A            0x3: decode FUNCTION_LO {
1022495SN/A                format IntOp {
1032495SN/A                    0x0: mult({{
1042495SN/A                        int64_t temp1 = Rs.sw * Rt.sw;
1052495SN/A                        xc->setMiscReg(Hi,temp1<63:32>);
1062495SN/A                        xc->setMiscReg(Lo,temp1<31:0>);
1072495SN/A                    }});
1082495SN/A
1092495SN/A                    0x1: multu({{
1102495SN/A                        int64_t temp1 = Rs.uw * Rt.uw;
1112495SN/A                        xc->setMiscReg(Hi,temp1<63:32>);
1122495SN/A                        xc->setMiscReg(Lo,temp1<31:0>);
1132043SN/A                    }});
1142043SN/A
1152025SN/A                    0x2: div({{
1162043SN/A                        xc->setMiscReg(Hi,Rs.sw % Rt.sw);
1172686Sksewell@umich.edu                        xc->setMiscReg(Lo,Rs.sw / Rt.sw);
1182686Sksewell@umich.edu                    }});
1192123SN/A
1202101SN/A                    0x3: divu({{
1212686Sksewell@umich.edu                        xc->setMiscReg(Hi,Rs.uw % Rt.uw);
1222686Sksewell@umich.edu                        xc->setMiscReg(Lo,Rs.uw / Rt.uw);
1232101SN/A                    }});
1242042SN/A                }
1252101SN/A            }
1262686Sksewell@umich.edu
1272686Sksewell@umich.edu            0x4: decode FUNCTION_LO {
1282686Sksewell@umich.edu                format IntOp {
1292686Sksewell@umich.edu                    0x0: add({{  Rd.sw = Rs.sw + Rt.sw;/*Trap on Overflow*/}});
1302101SN/A                    0x1: addu({{ Rd.sw = Rs.sw + Rt.sw;}});
1312101SN/A                    0x2: sub({{ Rd.sw = Rs.sw - Rt.sw; /*Trap on Overflow*/}});
1322042SN/A                    0x3: subu({{ Rd.sw = Rs.sw - Rt.uw;}});
1332101SN/A                    0x4: and({{ Rd = Rs & Rt;}});
1342686Sksewell@umich.edu                    0x5: or({{ Rd = Rs | Rt;}});
1352686Sksewell@umich.edu                    0x6: xor({{ Rd = Rs ^ Rt;}});
1362686Sksewell@umich.edu                    0x7: nor({{ Rd = ~(Rs | Rt);}});
1372686Sksewell@umich.edu                }
1382101SN/A            }
1392083SN/A
1402686Sksewell@umich.edu            0x5: decode FUNCTION_LO {
1412686Sksewell@umich.edu                format IntOp{
1422101SN/A                    0x2: slt({{  Rd.sw = ( Rs.sw < Rt.sw ) ? 1 : 0}});
1432043SN/A                    0x3: sltu({{ Rd.uw = ( Rs.uw < Rt.uw ) ? 1 : 0}});
1442025SN/A                }
1452043SN/A            }
1462686Sksewell@umich.edu
1472616SN/A            0x6: decode FUNCTION_LO {
1482616SN/A                format Trap {
1492616SN/A                    0x0: tge({{  cond = (Rs.sw >= Rt.sw); }});
1502616SN/A                    0x1: tgeu({{ cond = (Rs.uw >= Rt.uw); }});
1512101SN/A                    0x2: tlt({{ cond = (Rs.sw < Rt.sw); }});
1522083SN/A                    0x3: tltu({{ cond = (Rs.uw >= Rt.uw); }});
1532025SN/A                    0x4: teq({{ cond = (Rs.sw == Rt.sw); }});
1542043SN/A                    0x6: tne({{ cond = (Rs.sw != Rt.sw); }});
1552686Sksewell@umich.edu                }
1562686Sksewell@umich.edu            }
1572686Sksewell@umich.edu        }
1582686Sksewell@umich.edu
1592025SN/A        0x1: decode REGIMM_HI {
1602686Sksewell@umich.edu            0x0: decode REGIMM_LO {
1612742Sksewell@umich.edu                format Branch {
1622742Sksewell@umich.edu                    0x0: bltz({{ cond = (Rs.sw < 0); }});
1632742Sksewell@umich.edu                    0x1: bgez({{ cond = (Rs.sw >= 0); }});
1642742Sksewell@umich.edu                }
1652742Sksewell@umich.edu
1662742Sksewell@umich.edu                format BranchLikely {
1672742Sksewell@umich.edu                    //MIPS obsolete instructions
1682742Sksewell@umich.edu                    0x2: bltzl({{ cond = (Rs.sw < 0); }});
1692742Sksewell@umich.edu                    0x3: bgezl({{ cond = (Rs.sw >= 0); }});
1702742Sksewell@umich.edu                }
1712101SN/A            }
1722084SN/A
1732025SN/A            0x1: decode REGIMM_LO {
1742495SN/A                format Trap {
1752495SN/A                    0x0: tgei( {{ cond = (Rs.sw >= INTIMM); }});
1762495SN/A                    0x1: tgeiu({{ cond = (Rs.uw >= INTIMM); }});
1772616SN/A                    0x2: tlti( {{ cond = (Rs.sw < INTIMM); }});
1782495SN/A                    0x3: tltiu({{ cond = (Rs.uw < INTIMM); }});
1792616SN/A                    0x4: teqi( {{ cond = (Rs.sw == INTIMM);}});
1802495SN/A                    0x6: tnei( {{ cond = (Rs.sw != INTIMM);}});
1812495SN/A                }
1822495SN/A            }
1832495SN/A
1842495SN/A            0x2: decode REGIMM_LO {
1852495SN/A                format Branch {
1862101SN/A                    0x0: bltzal({{ cond = (Rs.sw < 0); }}, IsCall,IsReturn);
1872043SN/A                    0x1: bgezal({{ cond = (Rs.sw >= 0); }}, IsCall,IsReturn);
1882025SN/A                }
1892495SN/A
1902495SN/A                format BranchLikely {
1912495SN/A                    //Will be removed in future MIPS releases
1922495SN/A                    0x2: bltzall({{ cond = (Rs.sw < 0); }}, IsCall, IsReturn);
1932495SN/A                    0x3: bgezall({{ cond = (Rs.sw >= 0); }}, IsCall, IsReturn);
1942495SN/A                }
1952101SN/A            }
1962084SN/A
1972024SN/A            0x3: decode REGIMM_LO {
1982043SN/A                format WarnUnimpl {
1992239SN/A                    0x7: synci();
2002239SN/A                }
2012101SN/A            }
2022101SN/A        }
2032101SN/A
2042101SN/A        format Jump {
2052101SN/A            0x2: j({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2);}});
2062101SN/A
2072043SN/A            0x3: jal({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2); }},IsCall,IsReturn);
2082043SN/A        }
2092025SN/A
2102043SN/A        format Branch {
2112043SN/A            0x4: beq({{ cond = (Rs.sw == Rt.sw); }});
2122101SN/A            0x5: bne({{ cond = (Rs.sw != Rt.sw); }});
2132101SN/A            0x6: blez({{ cond = (Rs.sw <= 0); }});
2142101SN/A            0x7: bgtz({{ cond = (Rs.sw > 0); }});
2152686Sksewell@umich.edu        }
2162686Sksewell@umich.edu    }
2172101SN/A
2182043SN/A    0x1: decode OPCODE_LO {
2192025SN/A        format IntOp {
2202043SN/A            0x0: addi({{ Rt.sw = Rs.sw + imm; /*Trap If Overflow*/}});
2212239SN/A            0x1: addiu({{ Rt.sw = Rs.sw + imm;}});
2222101SN/A            0x2: slti({{ Rt.sw = ( Rs.sw < imm) ? 1 : 0 }});
2232104SN/A            0x3: sltiu({{ Rt.sw = ( Rs.sw < imm ) ? 1 : 0 }});
2242101SN/A            0x4: andi({{ Rt.sw = Rs.sw & INTIMM;}});
2252101SN/A            0x5: ori({{ Rt.sw = Rs.sw | INTIMM;}});
2262101SN/A            0x6: xori({{ Rt.sw = Rs.sw ^ INTIMM;}});
2272101SN/A            0x7: lui({{ Rt = INTIMM << 16}});
2282101SN/A        }
2292043SN/A    }
2302043SN/A
2312043SN/A    0x2: decode OPCODE_LO {
2322101SN/A
2332686Sksewell@umich.edu        //Table A-11 MIPS32 COP0 Encoding of rs Field
2342686Sksewell@umich.edu        0x0: decode RS_MSB {
2352686Sksewell@umich.edu            0x0: decode RS {
2362686Sksewell@umich.edu                format System {
2372686Sksewell@umich.edu                    0x0: mfc0({{
2382686Sksewell@umich.edu                        //uint64_t reg_num = Rd.uw;
2392686Sksewell@umich.edu
2402101SN/A                        Rt = xc->readMiscReg(RD << 5 | SEL);
2412043SN/A                    }});
2422043SN/A
2432043SN/A                    0x4: mtc0({{
2442101SN/A                        //uint64_t reg_num = Rd.uw;
2452101SN/A
2462101SN/A                        xc->setMiscReg(RD << 5 | SEL,Rt);
2472043SN/A                    }});
2482043SN/A
2492043SN/A                    0x8: mftr({{
2502123SN/A                        //The contents of the coprocessor 0 register specified by the
2512239SN/A                        //combination of rd and sel are loaded into general register
2522686Sksewell@umich.edu                        //rt. Note that not all coprocessor 0 registers support the
2532686Sksewell@umich.edu                        //sel field. In those instances, the sel field must be zero.
2542043SN/A
2552043SN/A                        //MT Code Needed Here
2562100SN/A                    }});
2572686Sksewell@umich.edu
2582686Sksewell@umich.edu                    0xC: mttr({{
2592686Sksewell@umich.edu                        //The contents of the coprocessor 0 register specified by the
2602686Sksewell@umich.edu                        //combination of rd and sel are loaded into general register
2612239SN/A                        //rt. Note that not all coprocessor 0 registers support the
2622686Sksewell@umich.edu                        //sel field. In those instances, the sel field must be zero.
2632686Sksewell@umich.edu
2642043SN/A                        //MT Code Needed Here
2652084SN/A                    }});
2662024SN/A
2672101SN/A
2682686Sksewell@umich.edu                    0xA: rdpgpr({{
2692239SN/A                        //Accessing Previous Shadow Set Register Number
2702239SN/A                        //uint64_t prev = xc->readMiscReg(SRSCtl)/*[PSS]*/;
2712239SN/A                        //uint64_t reg_num = Rt.uw;
2722495SN/A
2732495SN/A                        //Rd = xc->regs.IntRegFile[prev];
2742495SN/A                       //Rd = xc->shadowIntRegFile[prev][reg_num];
2752495SN/A                    }});
2762495SN/A
2772495SN/A                    0xB: decode RD {
2782495SN/A
2792495SN/A                        0x0: decode SC {
2802084SN/A                            0x0: dvpe({{
2812084SN/A                                Rt.sw = xc->readMiscReg(MVPControl);
2822024SN/A                                xc->setMiscReg(MVPControl,0);
2832101SN/A                            }});
2842101SN/A
2852101SN/A                            0x1: evpe({{
2862101SN/A                                Rt.sw = xc->readMiscReg(MVPControl);
2872686Sksewell@umich.edu                                xc->setMiscReg(MVPControl,1);
2882686Sksewell@umich.edu                            }});
2892686Sksewell@umich.edu                        }
2902686Sksewell@umich.edu
2912052SN/A                        0x1: decode SC {
2922686Sksewell@umich.edu                            0x0: dmt({{
2932686Sksewell@umich.edu                                Rt.sw = xc->readMiscReg(VPEControl);
2942686Sksewell@umich.edu                                xc->setMiscReg(VPEControl,0);
2952101SN/A                            }});
2962101SN/A
2972686Sksewell@umich.edu                            0x1: emt({{
2982686Sksewell@umich.edu                                Rt.sw = xc->readMiscReg(VPEControl);
2992101SN/A                                xc->setMiscReg(VPEControl,1);
3002101SN/A                            }});
3012686Sksewell@umich.edu                        }
3022686Sksewell@umich.edu
3032686Sksewell@umich.edu                        0xC: decode SC {
3042686Sksewell@umich.edu                            0x0: di({{
3052686Sksewell@umich.edu                                Rt.sw = xc->readMiscReg(Status);
3062686Sksewell@umich.edu                                xc->setMiscReg(Status,0);
3072101SN/A                            }});
3082101SN/A
3092686Sksewell@umich.edu                            0x1: ei({{
3102027SN/A                                Rt.sw = xc->readMiscReg(Status);
3112686Sksewell@umich.edu                                xc->setMiscReg(Status,1);
3122686Sksewell@umich.edu                            }});
3132686Sksewell@umich.edu                        }
3142101SN/A                    }
3152101SN/A
3162101SN/A                    0xE: wrpgpr({{
3172101SN/A                        //Accessing Previous Shadow Set Register Number
3182101SN/A                        //uint64_t prev = xc->readMiscReg(SRSCtl/*[PSS]*/);
3192686Sksewell@umich.edu                        //uint64_t reg_num = Rd.uw;
3202686Sksewell@umich.edu
3212686Sksewell@umich.edu                        //xc->regs.IntRegFile[prev];
3222686Sksewell@umich.edu                        //xc->shadowIntRegFile[prev][reg_num] = Rt;
3232686Sksewell@umich.edu                    }});
3242101SN/A                }
3252101SN/A            }
3262101SN/A
3272101SN/A            //Table A-12 MIPS32 COP0 Encoding of Function Field When rs=CO
3282101SN/A            0x1: decode FUNCTION {
3292101SN/A                format System {
3302043SN/A                    0x01: tlbr({{ }});
3312027SN/A                    0x02: tlbwi({{ }});
3322101SN/A                    0x06: tlbwr({{ }});
3332101SN/A                    0x08: tlbp({{ }});
3342041SN/A                }
3352101SN/A
3362101SN/A                format WarnUnimpl {
3372686Sksewell@umich.edu                    0x18: eret();
3382742Sksewell@umich.edu                    0x1F: deret();
3392495SN/A                    0x20: wait();
3402495SN/A                }
3412573SN/A            }
3422573SN/A        }
3432573SN/A
3442616SN/A        //Table A-13 MIPS32 COP1 Encoding of rs Field
3452573SN/A        0x1: decode RS_MSB {
3462573SN/A
3472616SN/A            0x0: decode RS_HI {
3482573SN/A                0x0: decode RS_LO {
3492573SN/A                    format FloatOp {
3502616SN/A                        0x0: mfc1({{ /*Rt.uw = Fs.ud<31:0>;*/ }});
3512573SN/A                        0x2: cfc1({{ /*Rt.uw = xc->readMiscReg(FPCR[Fs]);*/}});
3522573SN/A                        0x3: mfhc1({{ /*Rt.uw = Fs.ud<63:32>*/;}});
3532616SN/A                        0x4: mtc1({{ /*Fs = Rt.uw*/}});
3542573SN/A                        0x6: ctc1({{ /*xc->setMiscReg(FPCR[Fs],Rt);*/}});
3552573SN/A                        0x7: mthc1({{ /*Fs<63:32> = Rt.uw*/}});
3562616SN/A                    }
3572573SN/A                }
3582573SN/A
3592686Sksewell@umich.edu                0x1: decode ND {
3602573SN/A                    0x0: decode TF {
3612573SN/A                        format Branch {
3622573SN/A                            0x0: bc1f({{ cond = (xc->readMiscReg(FPCR) == 0); }});
3632686Sksewell@umich.edu                            0x1: bc1t({{ cond = (xc->readMiscReg(FPCR) == 1); }});
3642686Sksewell@umich.edu                        }
3652686Sksewell@umich.edu                    }
3662686Sksewell@umich.edu
3672573SN/A                    0x1: decode TF {
3682573SN/A                        format BranchLikely {
3692573SN/A                            0x0: bc1fl({{ cond = (xc->readMiscReg(FPCR) == 0); }});
3702573SN/A                            0x1: bc1tl({{ cond = (xc->readMiscReg(FPCR) == 1); }});
3712616SN/A                        }
3722616SN/A                    }
3732616SN/A                }
3742573SN/A            }
3752573SN/A
3762573SN/A            0x1: decode RS_HI {
3772616SN/A                0x2: decode RS_LO {
3782573SN/A
3792616SN/A                    //Table A-14 MIPS32 COP1 Encoding of Function Field When rs=S
3802573SN/A                    //(( single-word ))
3812616SN/A                    0x0: decode RS_HI {
3822573SN/A                        0x0: decode RS_LO {
3832573SN/A                            format FloatOp {
3842573SN/A                                0x0: adds({{ Fd.sf = Fs.sf + Ft.sf;}});
3852616SN/A                                0x1: subs({{ Fd.sf = Fs.sf - Ft.sf;}});
3862573SN/A                                0x2: muls({{ Fd.sf = Fs.sf * Ft.sf;}});
3872616SN/A                                0x3: divs({{ Fd.sf = Fs.sf / Ft.sf;}});
3882573SN/A                                0x4: sqrts({{ Fd.sf = sqrt(Fs.sf);}});
3892616SN/A                                0x5: abss({{ Fd.sf = fabs(Fs.sf);}});
3902573SN/A                                0x6: movs({{ Fd.sf = Fs.sf;}});
3912573SN/A                                0x7: negs({{ Fd.sf = -1 * Fs.sf;}});
3922573SN/A                            }
3932573SN/A                        }
3942616SN/A
3952573SN/A                        0x1: decode RS_LO {
3962573SN/A                            //only legal for 64 bit-FP
3972573SN/A                            format Float64Op {
3982495SN/A                                0x0: round_l_s({{ Fd = convert_and_round(Fs.sf,RND_NEAREST,FP_LONG,FP_SINGLE);}});
3992616SN/A                                0x1: trunc_l_s({{ Fd = convert_and_round(Fs.sf,RND_ZERO,FP_LONG,FP_SINGLE);}});
4002495SN/A                                0x2: ceil_l_s({{ Fd = convert_and_round(Fs.sf,RND_UP,FP_LONG,FP_SINGLE);}});
4012495SN/A                                0x3: floor_l_s({{ Fd = convert_and_round(Fs.sf,RND_DOWN,FP_LONG,FP_SINGLE);}});
4022686Sksewell@umich.edu                            }
4032686Sksewell@umich.edu
4042686Sksewell@umich.edu                            format FloatOp {
4052686Sksewell@umich.edu                                0x4: round_w_s({{ Fd = convert_and_round(Fs.sf,RND_NEAREST,FP_WORD,FP_SINGLE);}});
4062686Sksewell@umich.edu                                0x5: trunc_w_s({{ Fd = convert_and_round(Fs.sf,RND_ZERO,FP_WORD,FP_SINGLE);}});
4072686Sksewell@umich.edu                                0x6: ceil_w_s({{  Fd = convert_and_round(Fs.sf,RND_UP,FP_WORD,FP_SINGLE);}});
4082686Sksewell@umich.edu                                0x7: floor_w_s({{ Fd = convert_and_round(Fs.sf,RND_DOWN,FP_WORD,FP_SINGLE);}});
4092101SN/A                            }
4102101SN/A                        }
4112025SN/A
4122101SN/A                        0x2: decode RS_LO {
4132686Sksewell@umich.edu                            0x1: decode MOVCF {
4142686Sksewell@umich.edu                                format FloatOp {
4152686Sksewell@umich.edu                                    0x0: movfs({{if (xc->readMiscReg(FPCR) != CC) Fd = Fs; }});
4162686Sksewell@umich.edu                                    0x1: movts({{if (xc->readMiscReg(FPCR) == CC) Fd = Fs;}});
4172686Sksewell@umich.edu                                }
4182686Sksewell@umich.edu                            }
4192101SN/A
4202686Sksewell@umich.edu                            format BasicOp {
4212686Sksewell@umich.edu                                0x2: movzs({{ if (Rt == 0) Fd = Fs; }});
4222686Sksewell@umich.edu                                0x3: movns({{ if (Rt != 0) Fd = Fs; }});
4232686Sksewell@umich.edu                            }
4242686Sksewell@umich.edu
4252101SN/A                            format Float64Op {
4262101SN/A                                0x5: recips({{ Fd = 1 / Fs; }});
4272101SN/A                                0x6: rsqrts({{ Fd = 1 / sqrt((double)Fs.ud);}});
4282043SN/A                            }
4292027SN/A                        }
4302101SN/A
4312101SN/A                        0x4: decode RS_LO {
4322101SN/A
4332686Sksewell@umich.edu                            format FloatOp {
4342572SN/A                                0x1: cvt_d_s({{ int rnd_mode = xc->readMiscReg(FCSR);
4352572SN/A                                Fd = convert_and_round(Fs.sf,rnd_mode,FP_DOUBLE,FP_SINGLE);
4362101SN/A                                }});
4372601SN/A
4382601SN/A                                0x4: cvt_w_s({{ int rnd_mode = xc->readMiscReg(FCSR);
4392601SN/A                                Fd = convert_and_round(Fs.sf,rnd_mode,FP_WORD,FP_SINGLE);
4402601SN/A                                }});
4412601SN/A                            }
4422601SN/A
4432686Sksewell@umich.edu                            //only legal for 64 bit
4442101SN/A                            format Float64Op {
4452742Sksewell@umich.edu                                0x5: cvt_l_s({{ int rnd_mode = xc->readMiscReg(FCSR);
4462742Sksewell@umich.edu                                Fd = convert_and_round(Fs.sf,rnd_mode,FP_LONG,FP_SINGLE);
4472101SN/A                                }});
4482027SN/A
4492572SN/A                                0x6: cvt_ps_s({{ /*Fd.df = Fs.df<31:0> | Ft.df<31:0>;*/ }});
4502686Sksewell@umich.edu                            }
4512686Sksewell@umich.edu                        }
4522686Sksewell@umich.edu                    }
4532686Sksewell@umich.edu
4542686Sksewell@umich.edu                    //Table A-15 MIPS32 COP1 Encoding of Function Field When rs=D
4552686Sksewell@umich.edu                    0x1: decode RS_HI {
4562686Sksewell@umich.edu                        0x0: decode RS_LO {
4572686Sksewell@umich.edu                            format FloatOp {
4582686Sksewell@umich.edu                                0x0: addd({{ Fd.df = Fs.df + Ft.df;}});
4592686Sksewell@umich.edu                                0x1: subd({{ Fd.df = Fs.df - Ft.df;}});
4602686Sksewell@umich.edu                                0x2: muld({{ Fd.df = Fs.df * Ft.df;}});
4612686Sksewell@umich.edu                                0x3: divd({{ Fd.df = Fs.df / Ft.df;}});
4622686Sksewell@umich.edu                                0x4: sqrtd({{ Fd.df = sqrt(Fs.df);}});
4632686Sksewell@umich.edu                                0x5: absd({{ Fd.df = fabs(Fs.df);}});
4642686Sksewell@umich.edu                                0x6: movd({{ Fd.df = Fs.df;}});
4652686Sksewell@umich.edu                                0x7: negd({{ Fd.df = -1 * Fs.df;}});
4662686Sksewell@umich.edu                            }
4672101SN/A                        }
4682101SN/A
4692027SN/A                        0x1: decode RS_LO {
4702572SN/A                            //only legal for 64 bit
4712101SN/A                            format Float64Op {
4722686Sksewell@umich.edu                                0x0: round_l_d({{ Fd = convert_and_round(Fs.df,RND_NEAREST,FP_LONG,FP_DOUBLE); }});
4732686Sksewell@umich.edu                                0x1: trunc_l_d({{ Fd = convert_and_round(Fs.df,RND_ZERO,FP_LONG,FP_DOUBLE);}});
4742686Sksewell@umich.edu                                0x2: ceil_l_d({{ Fd = convert_and_round(Fs.df,RND_UP,FP_LONG,FP_DOUBLE);}});
4752101SN/A                                0x3: floor_l_d({{ Fd = convert_and_round(Fs.df,RND_DOWN,FP_LONG,FP_DOUBLE);}});
4762101SN/A                            }
4772027SN/A
4782686Sksewell@umich.edu                            format FloatOp {
4792686Sksewell@umich.edu                                0x4: round_w_d({{ Fd = convert_and_round(Fs.df,RND_NEAREST,FP_LONG,FP_DOUBLE); }});
4802686Sksewell@umich.edu                                0x5: trunc_w_d({{ Fd = convert_and_round(Fs.df,RND_ZERO,FP_LONG,FP_DOUBLE); }});
4812686Sksewell@umich.edu                                0x6: ceil_w_d({{  Fd = convert_and_round(Fs.df,RND_UP,FP_LONG,FP_DOUBLE); }});
4822686Sksewell@umich.edu                                0x7: floor_w_d({{ Fd = convert_and_round(Fs.df,RND_DOWN,FP_LONG,FP_DOUBLE); }});
4832602SN/A                            }
4842602SN/A                        }
4852602SN/A
4862101SN/A                        0x2: decode RS_LO {
4872101SN/A                            0x1: decode MOVCF {
4882027SN/A                                format FloatOp {
4892572SN/A                                    0x0: movfd({{if (xc->readMiscReg(FPCR) != CC) Fd.df = Fs.df; }});
4902603SN/A                                    0x1: movtd({{if (xc->readMiscReg(FPCR) == CC) Fd.df = Fs.df; }});
4912686Sksewell@umich.edu                                }
4922686Sksewell@umich.edu                            }
4932686Sksewell@umich.edu
4942101SN/A                            format BasicOp {
4952055SN/A                                0x2: movzd({{ if (Rt == 0) Fd.df = Fs.df; }});
4962686Sksewell@umich.edu                                0x3: movnd({{ if (Rt != 0) Fd.df = Fs.df; }});
4972686Sksewell@umich.edu                            }
4982686Sksewell@umich.edu
4992101SN/A                            format Float64Op {
5002101SN/A                                0x5: recipd({{ Fd.df = 1 / Fs.df}});
5012602SN/A                                0x6: rsqrtd({{ Fd.df = 1 / sqrt(Fs.df) }});
5022602SN/A                            }
5032603SN/A                        }
5042686Sksewell@umich.edu
5052686Sksewell@umich.edu                        0x4: decode RS_LO {
5062686Sksewell@umich.edu                            format FloatOp {
5072686Sksewell@umich.edu                                0x0: cvt_s_d({{
5082686Sksewell@umich.edu                                    int rnd_mode = xc->readMiscReg(FCSR);
5092686Sksewell@umich.edu                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_DOUBLE);
5102686Sksewell@umich.edu                                }});
5112686Sksewell@umich.edu
5122686Sksewell@umich.edu                                0x4: cvt_w_d({{
5132686Sksewell@umich.edu                                    int rnd_mode = xc->readMiscReg(FCSR);
5142686Sksewell@umich.edu                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_WORD,FP_DOUBLE);
5152686Sksewell@umich.edu                                }});
5162686Sksewell@umich.edu                            }
5172686Sksewell@umich.edu
5182686Sksewell@umich.edu                            //only legal for 64 bit
5192686Sksewell@umich.edu                            format Float64Op {
5202602SN/A                                0x5: cvt_l_d({{
5212602SN/A                                    int rnd_mode = xc->readMiscReg(FCSR);
5222602SN/A                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_LONG,FP_DOUBLE);
5232602SN/A                                }});
5242686Sksewell@umich.edu                            }
5252686Sksewell@umich.edu                        }
5262686Sksewell@umich.edu                    }
5272686Sksewell@umich.edu
5282686Sksewell@umich.edu                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=W
5292686Sksewell@umich.edu                    0x4: decode FUNCTION {
5302686Sksewell@umich.edu                        format FloatOp {
5312686Sksewell@umich.edu                            0x20: cvt_s({{
5322686Sksewell@umich.edu                                int rnd_mode = xc->readMiscReg(FCSR);
5332686Sksewell@umich.edu                                Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_WORD);
5342686Sksewell@umich.edu                            }});
5352686Sksewell@umich.edu
5362686Sksewell@umich.edu                            0x21: cvt_d({{
5372686Sksewell@umich.edu                                int rnd_mode = xc->readMiscReg(FCSR);
5382686Sksewell@umich.edu                                Fd = convert_and_round(Fs.df,rnd_mode,FP_DOUBLE,FP_WORD);
5392686Sksewell@umich.edu                            }});
5402686Sksewell@umich.edu                        }
5412602SN/A                    }
5422602SN/A
5432101SN/A                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=L1
5442055SN/A                    //Note: "1. Format type L is legal only if 64-bit floating point operations
5452101SN/A                    //are enabled."
5462572SN/A                    0x5: decode FUNCTION_HI {
5472572SN/A                        format FloatOp {
5482101SN/A                            0x10: cvt_s_l({{
5492686Sksewell@umich.edu                                int rnd_mode = xc->readMiscReg(FCSR);
5502686Sksewell@umich.edu                                Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_LONG);
5512686Sksewell@umich.edu                            }});
5522686Sksewell@umich.edu
5532686Sksewell@umich.edu                            0x11: cvt_d_l({{
5542686Sksewell@umich.edu                                int rnd_mode = xc->readMiscReg(FCSR);
5552686Sksewell@umich.edu                                Fd = convert_and_round(Fs.df,rnd_mode,FP_DOUBLE,FP_LONG);
5562101SN/A                            }});
5572742Sksewell@umich.edu                        }
5582742Sksewell@umich.edu                    }
5592101SN/A
5602027SN/A                    //Table A-17 MIPS64 COP1 Encoding of Function Field When rs=PS1
5612572SN/A                    //Note: "1. Format type PS is legal only if 64-bit floating point operations
5622686Sksewell@umich.edu                    //are enabled. "
5632686Sksewell@umich.edu                    0x6: decode RS_HI {
5642686Sksewell@umich.edu                        0x0: decode RS_LO {
5652686Sksewell@umich.edu                            format Float64Op {
5662686Sksewell@umich.edu                                0x0: addps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
5672686Sksewell@umich.edu                                    //Lower Halves Independently but we take simulator shortcut
5682686Sksewell@umich.edu                                    Fd.df = Fs.df + Ft.df;
5692686Sksewell@umich.edu                                }});
5702686Sksewell@umich.edu
5712686Sksewell@umich.edu                                0x1: subps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
5722686Sksewell@umich.edu                                    //Lower Halves Independently but we take simulator shortcut
5732686Sksewell@umich.edu                                    Fd.df = Fs.df - Ft.df;
5742686Sksewell@umich.edu                                }});
5752686Sksewell@umich.edu
5762686Sksewell@umich.edu                                0x2: mulps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
5772686Sksewell@umich.edu                                    //Lower Halves Independently but we take simulator shortcut
5782686Sksewell@umich.edu                                    Fd.df = Fs.df * Ft.df;
5792101SN/A                                }});
5802101SN/A
5812027SN/A                                0x5: absps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
5822572SN/A                                    //Lower Halves Independently but we take simulator shortcut
5832101SN/A                                    Fd.df = fabs(Fs.df);
5842686Sksewell@umich.edu                                }});
5852686Sksewell@umich.edu
5862686Sksewell@umich.edu                                0x6: movps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
5872686Sksewell@umich.edu                                    //Lower Halves Independently but we take simulator shortcut
5882686Sksewell@umich.edu                                    //Fd.df = Fs<31:0> |  Ft<31:0>;
5892686Sksewell@umich.edu                                }});
5902686Sksewell@umich.edu
5912101SN/A                                0x7: negps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
5922101SN/A                                    //Lower Halves Independently but we take simulator shortcut
5932027SN/A                                    Fd.df = -1 * Fs.df;
5942101SN/A                                }});
5952686Sksewell@umich.edu                            }
5962686Sksewell@umich.edu                        }
5972101SN/A
5982027SN/A                        0x2: decode RS_LO {
5992605SN/A                            0x1: decode MOVCF {
6002686Sksewell@umich.edu                                format Float64Op {
6012605SN/A                                    0x0: movfps({{if (xc->readMiscReg(FPCR) != CC) Fd = Fs;}});
6022101SN/A                                    0x1: movtps({{if (xc->readMiscReg(FPCR) == CC) Fd = Fs;}});
6032101SN/A                                }
6042027SN/A                            }
6052572SN/A
6062686Sksewell@umich.edu                            format BasicOp {
6072686Sksewell@umich.edu                                0x2: movzps({{if (xc->readMiscReg(FPCR) != CC) Fd = Fs; }});
6082686Sksewell@umich.edu                                0x3: movnps({{if (xc->readMiscReg(FPCR) == CC) Fd = Fs; }});
6092686Sksewell@umich.edu                            }
6102101SN/A
6112101SN/A                        }
6122602SN/A
6132602SN/A                        0x4: decode RS_LO {
6142604SN/A                            0x0: Float64Op::cvt_s_pu({{
6152686Sksewell@umich.edu                                int rnd_mode = xc->readMiscReg(FCSR);
6162686Sksewell@umich.edu                                Fd = convert_and_round(Fs.df,rnd_mode,FP_DOUBLE,FP_PS_HI);
6172686Sksewell@umich.edu                            }});
6182686Sksewell@umich.edu                        }
6192686Sksewell@umich.edu
6202686Sksewell@umich.edu                        0x5: decode RS_LO {
6212686Sksewell@umich.edu                            format Float64Op {
6222686Sksewell@umich.edu                                0x0: cvt_s_pl({{
6232686Sksewell@umich.edu                                    int rnd_mode = xc->readMiscReg(FCSR);
6242686Sksewell@umich.edu                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_PS_LO);
6252686Sksewell@umich.edu                                }});
6262686Sksewell@umich.edu                                0x4: pll({{ /*Fd.df = Fs<31:0> | Ft<31:0>*/}});
6272686Sksewell@umich.edu                                0x5: plu({{ /*Fd.df = Fs<31:0> | Ft<63:32>*/}});
6282686Sksewell@umich.edu                                0x6: pul({{ /*Fd.df = Fs<63:32> | Ft<31:0>*/}});
6292686Sksewell@umich.edu                                0x7: puu({{ /*Fd.df = Fs<63:32 | Ft<63:32>*/}});
6302686Sksewell@umich.edu                            }
6312602SN/A                        }
6322602SN/A                    }
6332602SN/A                }
6342602SN/A            }
6352686Sksewell@umich.edu        }
6362686Sksewell@umich.edu
6372686Sksewell@umich.edu        //Table A-19 MIPS32 COP2 Encoding of rs Field
6382686Sksewell@umich.edu        0x2: decode RS_MSB {
6392686Sksewell@umich.edu            0x0: decode RS_HI {
6402686Sksewell@umich.edu                0x0: decode RS_LO {
6412686Sksewell@umich.edu                    format WarnUnimpl {
6422686Sksewell@umich.edu                        0x0: mfc2();
6432686Sksewell@umich.edu                        0x2: cfc2();
6442686Sksewell@umich.edu                        0x3: mfhc2();
6452686Sksewell@umich.edu                        0x4: mtc2();
6462686Sksewell@umich.edu                        0x6: ctc2();
6472686Sksewell@umich.edu                        0x7: mftc2();
6482686Sksewell@umich.edu                    }
6492686Sksewell@umich.edu                }
6502686Sksewell@umich.edu
6512686Sksewell@umich.edu                0x1: decode ND {
6522602SN/A                    0x0: decode TF {
6532602SN/A                        format WarnUnimpl {
6542101SN/A                            0x0: bc2f();
6552027SN/A                            0x1: bc2t();
6562101SN/A                        }
6572101SN/A                    }
6582605SN/A
6592686Sksewell@umich.edu                    0x1: decode TF {
6602686Sksewell@umich.edu                        format WarnUnimpl {
6612686Sksewell@umich.edu                            0x0: bc2fl();
6622101SN/A                            0x1: bc2tl();
6632101SN/A                        }
6642027SN/A                    }
6652101SN/A                }
6662101SN/A            }
6672101SN/A        }
6682101SN/A
6692686Sksewell@umich.edu        //Table A-20 MIPS64 COP1X Encoding of Function Field 1
6702686Sksewell@umich.edu        //Note: "COP1X instructions are legal only if 64-bit floating point
6712686Sksewell@umich.edu        //operations are enabled."
6722686Sksewell@umich.edu        0x3: decode FUNCTION_HI {
6732101SN/A            0x0: decode FUNCTION_LO {
6742101SN/A                format LoadMemory2 {
6752101SN/A                    0x0: lwxc1({{ EA = Rs + Rt; }},{{ /*F_t<31:0> = Mem.sf; */}});
6762101SN/A                    0x1: ldxc1({{ EA = Rs + Rt; }},{{ /*F_t<63:0> = Mem.df;*/ }});
6772101SN/A                    0x5: luxc1({{ //Need to make EA<2:0> = 0
6782101SN/A                        EA = Rs + Rt;
6792572SN/A                    }},
6802572SN/A                {{ /*F_t<31:0> = Mem.df; */}});
6812101SN/A                }
6822605SN/A            }
6832607SN/A
6842607SN/A            0x1: decode FUNCTION_LO {
6852101SN/A                format StoreMemory2 {
6862605SN/A                    0x0: swxc1({{ EA = Rs + Rt; }},{{ /*Mem.sf = Ft<31:0>; */}});
6872607SN/A                    0x1: sdxc1({{ EA = Rs + Rt; }},{{ /*Mem.df = Ft<63:0> */}});
6882607SN/A                    0x5: suxc1({{ //Need to make EA<2:0> = 0
6892101SN/A                        EA = Rs + Rt;
6902605SN/A                    }},
6912607SN/A                {{ /*Mem.df = F_t<63:0>;*/}});
6922607SN/A                }
6932101SN/A
6942605SN/A                0x7: WarnUnimpl::prefx();
6952607SN/A            }
6962607SN/A
6972101SN/A            format FloatOp {
6982605SN/A                0x3: WarnUnimpl::alnv_ps();
6992607SN/A
7002607SN/A                format BasicOp {
7012101SN/A                    0x4: decode FUNCTION_LO {
7022605SN/A                        0x0: madd_s({{ Fd.sf = (Fs.sf * Fs.sf) + Fr.sf; }});
7032686Sksewell@umich.edu                        0x1: madd_d({{ Fd.df = (Fs.df * Fs.df) + Fr.df; }});
7042686Sksewell@umich.edu                        0x6: madd_ps({{
7052101SN/A                            //Must Check for Exception Here... Supposed to Operate on Upper and
7062101SN/A                            //Lower Halves Independently but we take simulator shortcut
7072101SN/A                            Fd.df = (Fs.df * Fs.df) + Fr.df;
7082101SN/A                        }});
7092572SN/A                    }
7102101SN/A
7112101SN/A                    0x5: decode FUNCTION_LO {
7122607SN/A                        0x0: msub_s({{ Fd.sf = (Fs.sf * Fs.sf) - Fr.sf; }});
7132686Sksewell@umich.edu                        0x1: msub_d({{ Fd.df = (Fs.df * Fs.df) - Fr.df; }});
7142686Sksewell@umich.edu                        0x6: msub_ps({{
7152686Sksewell@umich.edu                            //Must Check for Exception Here... Supposed to Operate on Upper and
7162686Sksewell@umich.edu                            //Lower Halves Independently but we take simulator shortcut
7172607SN/A                            Fd.df = (Fs.df * Fs.df) - Fr.df;
7182607SN/A                        }});
7192686Sksewell@umich.edu                    }
7202686Sksewell@umich.edu
7212686Sksewell@umich.edu                    0x6: decode FUNCTION_LO {
7222686Sksewell@umich.edu                        0x0: nmadd_s({{ Fd.sf = (-1 * Fs.sf * Fs.sf) - Fr.sf; }});
7232607SN/A                        0x1: nmadd_d({{ Fd.df = (-1 * Fs.df * Fs.df) + Fr.df; }});
7242101SN/A                        0x6: nmadd_ps({{
7252101SN/A                            //Must Check for Exception Here... Supposed to Operate on Upper and
7262101SN/A                            //Lower Halves Independently but we take simulator shortcut
7272605SN/A                            Fd.df = (-1 * Fs.df * Fs.df) + Fr.df;
7282607SN/A                        }});
7292686Sksewell@umich.edu                    }
7302686Sksewell@umich.edu
7312686Sksewell@umich.edu                    0x7: decode FUNCTION_LO {
7322686Sksewell@umich.edu                        0x0: nmsub_s({{ Fd.sf = (-1 * Fs.sf * Fs.sf) - Fr.sf; }});
7332607SN/A                        0x1: nmsub_d({{ Fd.df = (-1 * Fs.df * Fs.df) - Fr.df; }});
7342607SN/A                        0x6: nmsub_ps({{
7352686Sksewell@umich.edu                            //Must Check for Exception Here... Supposed to Operate on Upper and
7362686Sksewell@umich.edu                            //Lower Halves Independently but we take simulator shortcut
7372686Sksewell@umich.edu                            Fd.df = (-1 * Fs.df * Fs.df) + Fr.df;
7382686Sksewell@umich.edu                        }});
7392607SN/A                    }
7402135SN/A                }
7412135SN/A            }
7422101SN/A        }
7432101SN/A
7442572SN/A        //MIPS obsolete instructions
7452686Sksewell@umich.edu        format BranchLikely {
7462101SN/A            0x4: beql({{ cond = (Rs.sw == 0); }});
7472101SN/A            0x5: bnel({{ cond = (Rs.sw != 0); }});
7482572SN/A            0x6: blezl({{ cond = (Rs.sw <= 0); }});
7492686Sksewell@umich.edu            0x7: bgtzl({{ cond = (Rs.sw > 0); }});
7502686Sksewell@umich.edu        }
7512101SN/A    }
7522686Sksewell@umich.edu
7532686Sksewell@umich.edu    0x3: decode OPCODE_LO default FailUnimpl::reserved() {
7542686Sksewell@umich.edu
7552686Sksewell@umich.edu        //Table A-5 MIPS32 SPECIAL2 Encoding of Function Field
7562686Sksewell@umich.edu        0x4: decode FUNCTION_HI {
7572686Sksewell@umich.edu
7582686Sksewell@umich.edu            0x0: decode FUNCTION_LO {
7592686Sksewell@umich.edu                format IntOp {
7602686Sksewell@umich.edu                    0x0: madd({{
7612686Sksewell@umich.edu                        int64_t temp1 = xc->readMiscReg(Hi) << 32 | xc->readMiscReg(Lo) >> 32;
7622686Sksewell@umich.edu                        temp1 = temp1 + (Rs.sw * Rt.sw);
7632686Sksewell@umich.edu                        xc->setMiscReg(Hi,temp1<63:32>);
7642101SN/A                        xc->setMiscReg(Lo,temp1<31:0>);
7652101SN/A                            }});
7662602SN/A
7672602SN/A                    0x1: maddu({{
7682608SN/A                        int64_t temp1 = xc->readMiscReg(Hi) << 32 | xc->readMiscReg(Lo) >> 32;
7692686Sksewell@umich.edu                        temp1 = temp1 + (Rs.uw * Rt.uw);
7702686Sksewell@umich.edu                        xc->setMiscReg(Hi,temp1<63:32>);
7712686Sksewell@umich.edu                        xc->setMiscReg(Lo,temp1<31:0>);
7722686Sksewell@umich.edu                            }});
7732686Sksewell@umich.edu
7742686Sksewell@umich.edu                    0x2: mul({{ Rd.sw = Rs.sw * Rt.sw; 	}});
7752686Sksewell@umich.edu
7762686Sksewell@umich.edu                    0x4: msub({{
7772686Sksewell@umich.edu                        int64_t temp1 = xc->readMiscReg(Hi) << 32 | xc->readMiscReg(Lo) >> 32;
7782686Sksewell@umich.edu                        temp1 = temp1 - (Rs.sw * Rt.sw);
7792686Sksewell@umich.edu                        xc->setMiscReg(Hi,temp1<63:32>);
7802686Sksewell@umich.edu                        xc->setMiscReg(Lo,temp1<31:0>);
7812686Sksewell@umich.edu                            }});
7822686Sksewell@umich.edu
7832686Sksewell@umich.edu                    0x5: msubu({{
7842686Sksewell@umich.edu                        int64_t temp1 = xc->readMiscReg(Hi) << 32 | xc->readMiscReg(Lo) >> 32;
7852686Sksewell@umich.edu                        temp1 = temp1 - (Rs.uw * Rt.uw);
7862686Sksewell@umich.edu                        xc->setMiscReg(Hi,temp1<63:32>);
7872686Sksewell@umich.edu                        xc->setMiscReg(Lo,temp1<31:0>);
7882686Sksewell@umich.edu                            }});
7892686Sksewell@umich.edu                }
7902686Sksewell@umich.edu            }
7912602SN/A
7922602SN/A            0x4: decode FUNCTION_LO {
7932602SN/A                format BasicOp {
7942602SN/A                    0x0: clz({{
7952686Sksewell@umich.edu                        /*int cnt = 0;
7962686Sksewell@umich.edu                        int idx = 0;
7972686Sksewell@umich.edu                        while ( Rs.uw<idx> != 1) {
7982686Sksewell@umich.edu                            cnt++;
7992686Sksewell@umich.edu                            idx--;
8002686Sksewell@umich.edu                        }
8012686Sksewell@umich.edu
8022686Sksewell@umich.edu                        Rd.uw = cnt;*/
8032686Sksewell@umich.edu                    }});
8042686Sksewell@umich.edu
8052686Sksewell@umich.edu                    0x1: clo({{
8062686Sksewell@umich.edu                        /*int cnt = 0;
8072686Sksewell@umich.edu                        int idx = 0;
8082686Sksewell@umich.edu                        while ( Rs.uw<idx> != 0) {
8092686Sksewell@umich.edu                            cnt++;
8102686Sksewell@umich.edu                            idx--;
8112686Sksewell@umich.edu                        }
8122686Sksewell@umich.edu
8132686Sksewell@umich.edu                        Rd.uw = cnt;*/
8142686Sksewell@umich.edu                    }});
8152686Sksewell@umich.edu                }
8162686Sksewell@umich.edu            }
8172686Sksewell@umich.edu
8182686Sksewell@umich.edu            0x7: decode FUNCTION_LO {
8192602SN/A                0x7: WarnUnimpl::sdbbp();
8202602SN/A            }
8212101SN/A        }
8222101SN/A
8232101SN/A        //Table A-6 MIPS32 SPECIAL3 Encoding of Function Field for Release 2 of the Architecture
8242101SN/A        0x7: decode FUNCTION_HI {
8252101SN/A
8262101SN/A            0x0: decode FUNCTION_LO {
8272101SN/A                format WarnUnimpl {
8282686Sksewell@umich.edu                    0x1: ext();
8292686Sksewell@umich.edu                    0x4: ins();
8302686Sksewell@umich.edu                }
8312101SN/A            }
8322101SN/A
8332101SN/A            0x1: decode FUNCTION_LO {
8342101SN/A                format WarnUnimpl {
8352101SN/A                    0x0: fork();
8362101SN/A                    0x1: yield();
8372101SN/A                }
8382101SN/A            }
8392686Sksewell@umich.edu
8402686Sksewell@umich.edu
8412101SN/A            //Table A-10 MIPS32 BSHFL Encoding of sa Field
8422101SN/A            0x4: decode SA {
8432101SN/A
8442101SN/A                0x02: WarnUnimpl::wsbh();
8452686Sksewell@umich.edu
8462101SN/A                format BasicOp {
8472101SN/A                    0x10: seb({{ Rd.sw = /* sext32(Rt<7>,24)  | */ Rt<7:0>}});
8482101SN/A                    0x18: seh({{ Rd.sw = /* sext32(Rt<15>,16) | */ Rt<15:0>}});
8492101SN/A                }
8502101SN/A            }
8512101SN/A
8522101SN/A            0x6: decode FUNCTION_LO {
8532101SN/A                0x7: BasicOp::rdhwr({{ /*Rt = xc->hwRegs[RD];*/ }});
8542101SN/A            }
8552101SN/A        }
8562101SN/A    }
8572101SN/A
8582101SN/A    0x4: decode OPCODE_LO default FailUnimpl::reserved() {
8592686Sksewell@umich.edu        format LoadMemory {
8602742Sksewell@umich.edu            0x0: lb({{ Rt.sw = Mem.sb; }});
8612742Sksewell@umich.edu            0x1: lh({{ Rt.sw = Mem.sh; }});
8622750Sksewell@umich.edu            0x2: lwl({{ Rt.sw = Mem.sw; }});//, WordAlign);
8632742Sksewell@umich.edu            0x3: lw({{ Rt.sw = Mem.sb; }});
8642101SN/A            0x4: lbu({{ Rt.uw = Mem.ub; }});
8652043SN/A            0x5: lhu({{ Rt.uw = Mem.uh; }});
8662027SN/A            0x6: lwr({{ Rt.uw = Mem.uw; }});//, WordAlign);
8672101SN/A        }
8682686Sksewell@umich.edu
8692742Sksewell@umich.edu        0x7: FailUnimpl::reserved();
8702742Sksewell@umich.edu    }
8712742Sksewell@umich.edu
8722742Sksewell@umich.edu    0x5: decode OPCODE_LO default FailUnimpl::reserved() {
8732046SN/A        format StoreMemory {
8742084SN/A            0x0: sb({{ Mem.ub = Rt<7:0>; }});
8752686Sksewell@umich.edu            0x1: sh({{ Mem.uh = Rt<15:0>; }});
8762101SN/A            0x2: swl({{ Mem.ub = Rt<31:0>; }});//,WordAlign);
8772027SN/A            0x3: sw({{ Mem.ub = Rt<31:0>; }});
8782686Sksewell@umich.edu            0x6: swr({{ Mem.ub = Rt<31:0>; }});//,WordAlign);
8792686Sksewell@umich.edu        }
8802686Sksewell@umich.edu
8812686Sksewell@umich.edu        format WarnUnimpl {
8822686Sksewell@umich.edu            0x7: cache();
8832686Sksewell@umich.edu        }
8842686Sksewell@umich.edu
8852686Sksewell@umich.edu    }
8862686Sksewell@umich.edu
8872686Sksewell@umich.edu    0x6: decode OPCODE_LO default FailUnimpl::reserved() {
8882686Sksewell@umich.edu        0x0: WarnUnimpl::ll();
8892686Sksewell@umich.edu
8902686Sksewell@umich.edu        format LoadMemory {
8912686Sksewell@umich.edu            0x1: lwc1({{ /*F_t<31:0> = Mem.sf; */}});
8922686Sksewell@umich.edu            0x5: ldc1({{ /*F_t<63:0> = Mem.df; */}});
8932686Sksewell@umich.edu        }
8942027SN/A    }
8952686Sksewell@umich.edu
8962686Sksewell@umich.edu
8972686Sksewell@umich.edu    0x7: decode OPCODE_LO default FailUnimpl::reserved() {
8982686Sksewell@umich.edu        0x0: WarnUnimpl::sc();
8992686Sksewell@umich.edu
9002686Sksewell@umich.edu        format StoreMemory {
9012686Sksewell@umich.edu            0x1: swc1({{ //Mem.sf = Ft<31:0>; }});
9022686Sksewell@umich.edu            0x5: sdc1({{ //Mem.df = Ft<63:0>; }});
9032686Sksewell@umich.edu        }
9042027SN/A    }
9052686Sksewell@umich.edu}
9062686Sksewell@umich.edu
9072686Sksewell@umich.edu
9082686Sksewell@umich.edu