decoder.isa revision 5254
12686Sksewell@umich.edu// -*- mode:c++ -*-
22100SN/A
35254Sksewell@umich.edu// Copyright (c) 2007 MIPS Technologies, Inc.
45254Sksewell@umich.edu// All rights reserved.
55254Sksewell@umich.edu//
65254Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without
75254Sksewell@umich.edu// modification, are permitted provided that the following conditions are
85254Sksewell@umich.edu// met: redistributions of source code must retain the above copyright
95254Sksewell@umich.edu// notice, this list of conditions and the following disclaimer;
105254Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright
115254Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the
125254Sksewell@umich.edu// documentation and/or other materials provided with the distribution;
135254Sksewell@umich.edu// neither the name of the copyright holders nor the names of its
145254Sksewell@umich.edu// contributors may be used to endorse or promote products derived from
155254Sksewell@umich.edu// this software without specific prior written permission.
165254Sksewell@umich.edu//
175254Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
185254Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
195254Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
205254Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
215254Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
225254Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
235254Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
245254Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
255254Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
265254Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
275254Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
285254Sksewell@umich.edu//
295254Sksewell@umich.edu// Authors: Korey Sewell
305254Sksewell@umich.edu//          Brett Miller
315254Sksewell@umich.edu//          Jaidev Patwardhan
322706Sksewell@umich.edu
332022SN/A////////////////////////////////////////////////////////////////////
342022SN/A//
352043SN/A// The actual MIPS32 ISA decoder
362024SN/A// -----------------------------
372024SN/A// The following instructions are specified in the MIPS32 ISA
382043SN/A// Specification. Decoding closely follows the style specified
392686Sksewell@umich.edu// in the MIPS32 ISA specification document starting with Table
404661Sksewell@umich.edu// A-2 (document available @ http://www.mips.com)
412022SN/A//
422083SN/Adecode OPCODE_HI default Unknown::unknown() {
432686Sksewell@umich.edu    //Table A-2
442101SN/A    0x0: decode OPCODE_LO {
452043SN/A        0x0: decode FUNCTION_HI {
462043SN/A            0x0: decode FUNCTION_LO {
472101SN/A                0x1: decode MOVCI {
482101SN/A                    format BasicOp {
492686Sksewell@umich.edu                        0: movf({{ Rd = (getCondCode(FCSR, CC) == 0) ? Rd : Rs; }});
502686Sksewell@umich.edu                        1: movt({{ Rd = (getCondCode(FCSR, CC) == 1) ? Rd : Rs; }});
512101SN/A                    }
522101SN/A                }
532101SN/A
542046SN/A                format BasicOp {
552686Sksewell@umich.edu                    //Table A-3 Note: "Specific encodings of the rd, rs, and
562686Sksewell@umich.edu                    //rt fields are used to distinguish SLL, SSNOP, and EHB
572686Sksewell@umich.edu                    //functions
582470SN/A                    0x0: decode RS  {
592686Sksewell@umich.edu                        0x0: decode RT_RD {
604661Sksewell@umich.edu                            0x0: decode SA default Nop::nop() {
615222Sksewell@umich.edu                                 0x1: ssnop({{;}});
625222Sksewell@umich.edu                                 0x3: ehb({{;}});
632686Sksewell@umich.edu                            }
642686Sksewell@umich.edu                            default: sll({{ Rd = Rt.uw << SA; }});
652470SN/A                        }
662241SN/A                    }
672101SN/A
682495SN/A                    0x2: decode RS_SRL {
692495SN/A                        0x0:decode SRL {
702495SN/A                            0: srl({{ Rd = Rt.uw >> SA; }});
712101SN/A
722495SN/A                            //Hardcoded assuming 32-bit ISA, probably need parameter here
732495SN/A                            1: rotr({{ Rd = (Rt.uw << (32 - SA)) | (Rt.uw >> SA);}});
742495SN/A                        }
752101SN/A                    }
762101SN/A
772495SN/A                    0x3: decode RS {
782495SN/A                        0x0: sra({{
792495SN/A                            uint32_t temp = Rt >> SA;
802495SN/A                            if ( (Rt & 0x80000000) > 0 ) {
812495SN/A                                uint32_t mask = 0x80000000;
822495SN/A                                for(int i=0; i < SA; i++) {
832495SN/A                                    temp |= mask;
842495SN/A                                    mask = mask >> 1;
852495SN/A                                }
862495SN/A                            }
872495SN/A                            Rd = temp;
882495SN/A                        }});
892495SN/A                    }
902101SN/A
912101SN/A                    0x4: sllv({{ Rd = Rt.uw << Rs<4:0>; }});
922101SN/A
932101SN/A                    0x6: decode SRLV {
942101SN/A                        0: srlv({{ Rd = Rt.uw >> Rs<4:0>; }});
952101SN/A
962101SN/A                        //Hardcoded assuming 32-bit ISA, probably need parameter here
972101SN/A                        1: rotrv({{ Rd = (Rt.uw << (32 - Rs<4:0>)) | (Rt.uw >> Rs<4:0>);}});
982101SN/A                    }
992101SN/A
1002495SN/A                    0x7: srav({{
1012495SN/A                        int shift_amt = Rs<4:0>;
1022495SN/A
1032495SN/A                        uint32_t temp = Rt >> shift_amt;
1042495SN/A
1052495SN/A                        if ( (Rt & 0x80000000) > 0 ) {
1062495SN/A                                uint32_t mask = 0x80000000;
1072495SN/A                                for(int i=0; i < shift_amt; i++) {
1082495SN/A                                    temp |= mask;
1092495SN/A                                    mask = mask >> 1;
1102495SN/A                                }
1112495SN/A                            }
1122495SN/A
1132495SN/A                        Rd = temp;
1142495SN/A                    }});
1152043SN/A                }
1162043SN/A            }
1172025SN/A
1182043SN/A            0x1: decode FUNCTION_LO {
1192686Sksewell@umich.edu                //Table A-3 Note: "Specific encodings of the hint field are
1202686Sksewell@umich.edu                //used to distinguish JR from JR.HB and JALR from JALR.HB"
1212123SN/A                format Jump {
1222101SN/A                    0x0: decode HINT {
1235222Sksewell@umich.edu                        0x1: jr_hb({{ if(Config1_CA == 0){NNPC = Rs;}else{panic("MIPS16e not supported\n");}; }}, IsReturn, ClearHazards);
1245222Sksewell@umich.edu                        default: jr({{ if(Config1_CA == 0){NNPC = Rs;}else{panic("MIPS16e not supported\n");};}}, IsReturn);
1252101SN/A                    }
1262042SN/A
1272101SN/A                    0x1: decode HINT {
1284661Sksewell@umich.edu                        0x1: jalr_hb({{ Rd = NNPC; NNPC = Rs; }}, IsCall
1292686Sksewell@umich.edu                                     , ClearHazards);
1304661Sksewell@umich.edu                        default: jalr({{ Rd = NNPC; NNPC = Rs; }}, IsCall);
1312101SN/A                    }
1322101SN/A                }
1332042SN/A
1342101SN/A                format BasicOp {
1352686Sksewell@umich.edu                    0x2: movz({{ Rd = (Rt == 0) ? Rs : Rd; }});
1362686Sksewell@umich.edu                    0x3: movn({{ Rd = (Rt != 0) ? Rs : Rd; }});
1375222Sksewell@umich.edu#if FULL_SYSTEM
1385222Sksewell@umich.edu                  0x4: syscall({{
1395222Sksewell@umich.edu                                   fault = new SystemCallFault();
1405222Sksewell@umich.edu                                 }});
1415222Sksewell@umich.edu#else
1422965Sksewell@umich.edu                    0x4: syscall({{ xc->syscall(R2); }},
1435222Sksewell@umich.edu                                 IsSerializing, IsNonSpeculative);
1445222Sksewell@umich.edu#endif
1452686Sksewell@umich.edu                    0x7: sync({{ ; }}, IsMemBarrier);
1465222Sksewell@umich.edu                    0x5: break({{fault = new BreakpointFault();}});
1472101SN/A                }
1482083SN/A
1492043SN/A            }
1502025SN/A
1512043SN/A            0x2: decode FUNCTION_LO {
1525222Sksewell@umich.edu                0x0: HiLoRsSelOp::mfhi({{ Rd = HI_RS_SEL; }}, IntMultOp, IsIprAccess);
1534661Sksewell@umich.edu                0x1: HiLoRdSelOp::mthi({{ HI_RD_SEL = Rs; }});
1545222Sksewell@umich.edu                0x2: HiLoRsSelOp::mflo({{ Rd = LO_RS_SEL; }}, IntMultOp, IsIprAccess);
1554661Sksewell@umich.edu                0x3: HiLoRdSelOp::mtlo({{ LO_RD_SEL = Rs; }});
1562083SN/A            }
1572025SN/A
1582043SN/A            0x3: decode FUNCTION_LO {
1594661Sksewell@umich.edu                format HiLoRdSelValOp {
1605222Sksewell@umich.edu                    0x0: mult({{ val = Rs.sd * Rt.sd; }}, IntMultOp);
1615222Sksewell@umich.edu                    0x1: multu({{ val = Rs.ud * Rt.ud; }}, IntMultOp);
1624661Sksewell@umich.edu                }
1634661Sksewell@umich.edu
1642686Sksewell@umich.edu                format HiLoOp {
1654661Sksewell@umich.edu                    0x2: div({{ if (Rt.sd != 0) {
1664661Sksewell@umich.edu                        HI0 = Rs.sd % Rt.sd;
1674661Sksewell@umich.edu                        LO0 = Rs.sd / Rt.sd;
1684661Sksewell@umich.edu                    }
1695222Sksewell@umich.edu                    }}, IntDivOp);
1705222Sksewell@umich.edu
1714661Sksewell@umich.edu                    0x3: divu({{ if (Rt.ud != 0) {
1724661Sksewell@umich.edu                        HI0 = Rs.ud % Rt.ud;
1734661Sksewell@umich.edu                        LO0 = Rs.ud / Rt.ud;
1744661Sksewell@umich.edu                    }
1755222Sksewell@umich.edu                    }}, IntDivOp);
1762101SN/A                }
1772084SN/A            }
1782025SN/A
1792495SN/A            0x4: decode HINT {
1802495SN/A                0x0: decode FUNCTION_LO {
1812495SN/A                    format IntOp {
1825222Sksewell@umich.edu                      0x0: add({{  /* More complicated since an ADD can cause an arithmetic overflow exception */
1835222Sksewell@umich.edu                                     int64_t Src1 = Rs.sw;
1845222Sksewell@umich.edu                                     int64_t Src2 = Rt.sw;
1855222Sksewell@umich.edu                                     int64_t temp_result;
1865222Sksewell@umich.edu#if  FULL_SYSTEM
1875222Sksewell@umich.edu                                     if(((Src1 >> 31) & 1) == 1)
1885222Sksewell@umich.edu                                       Src1 |= 0x100000000LL;
1895222Sksewell@umich.edu#endif
1905222Sksewell@umich.edu                                     temp_result = Src1 + Src2;
1915222Sksewell@umich.edu#if  FULL_SYSTEM
1925222Sksewell@umich.edu                                     if(((temp_result >> 31) & 1) == ((temp_result >> 32) & 1)){
1935222Sksewell@umich.edu#endif
1945222Sksewell@umich.edu                                       Rd.sw = temp_result;
1955222Sksewell@umich.edu#if  FULL_SYSTEM
1965222Sksewell@umich.edu                                     } else{
1975222Sksewell@umich.edu                                       fault = new ArithmeticFault();
1985222Sksewell@umich.edu                                     }
1995222Sksewell@umich.edu#endif
2005222Sksewell@umich.edu
2015222Sksewell@umich.edu                                   }});
2022495SN/A                        0x1: addu({{ Rd.sw = Rs.sw + Rt.sw;}});
2035222Sksewell@umich.edu                        0x2: sub({{
2045222Sksewell@umich.edu                                     /* More complicated since an SUB can cause an arithmetic overflow exception */
2055222Sksewell@umich.edu                                     int64_t Src1 = Rs.sw;
2065222Sksewell@umich.edu                                     int64_t Src2 = Rt.sw;
2075222Sksewell@umich.edu                                     int64_t temp_result = Src1 - Src2;
2085222Sksewell@umich.edu#if  FULL_SYSTEM
2095222Sksewell@umich.edu                                     if(((temp_result >> 31) & 1) == ((temp_result>>32) & 1)){
2105222Sksewell@umich.edu#endif
2115222Sksewell@umich.edu                                       Rd.sw = temp_result;
2125222Sksewell@umich.edu#if  FULL_SYSTEM
2135222Sksewell@umich.edu                                     } else{
2145222Sksewell@umich.edu                                       fault = new ArithmeticFault();
2155222Sksewell@umich.edu                                     }
2165222Sksewell@umich.edu#endif
2175222Sksewell@umich.edu                                   }});
2182495SN/A                        0x3: subu({{ Rd.sw = Rs.sw - Rt.sw;}});
2192495SN/A                        0x4: and({{ Rd = Rs & Rt;}});
2202495SN/A                        0x5: or({{ Rd = Rs | Rt;}});
2212495SN/A                        0x6: xor({{ Rd = Rs ^ Rt;}});
2222495SN/A                        0x7: nor({{ Rd = ~(Rs | Rt);}});
2232495SN/A                    }
2242101SN/A                }
2252043SN/A            }
2262025SN/A
2272495SN/A            0x5: decode HINT {
2282495SN/A                0x0: decode FUNCTION_LO {
2292495SN/A                    format IntOp{
2302495SN/A                        0x2: slt({{  Rd.sw = ( Rs.sw < Rt.sw ) ? 1 : 0}});
2312495SN/A                        0x3: sltu({{ Rd.uw = ( Rs.uw < Rt.uw ) ? 1 : 0}});
2322495SN/A                    }
2332101SN/A                }
2342084SN/A            }
2352024SN/A
2362043SN/A            0x6: decode FUNCTION_LO {
2372239SN/A                format Trap {
2382239SN/A                    0x0: tge({{  cond = (Rs.sw >= Rt.sw); }});
2392101SN/A                    0x1: tgeu({{ cond = (Rs.uw >= Rt.uw); }});
2402101SN/A                    0x2: tlt({{ cond = (Rs.sw < Rt.sw); }});
2415222Sksewell@umich.edu                    0x3: tltu({{ cond = (Rs.uw < Rt.uw); }});
2422101SN/A                    0x4: teq({{ cond = (Rs.sw == Rt.sw); }});
2432101SN/A                    0x6: tne({{ cond = (Rs.sw != Rt.sw); }});
2442101SN/A                }
2452043SN/A            }
2462043SN/A        }
2472025SN/A
2482043SN/A        0x1: decode REGIMM_HI {
2492043SN/A            0x0: decode REGIMM_LO {
2502101SN/A                format Branch {
2512101SN/A                    0x0: bltz({{ cond = (Rs.sw < 0); }});
2522101SN/A                    0x1: bgez({{ cond = (Rs.sw >= 0); }});
2532686Sksewell@umich.edu                    0x2: bltzl({{ cond = (Rs.sw < 0); }}, Likely);
2542686Sksewell@umich.edu                    0x3: bgezl({{ cond = (Rs.sw >= 0); }}, Likely);
2552101SN/A                }
2562043SN/A            }
2572025SN/A
2582043SN/A            0x1: decode REGIMM_LO {
2595222Sksewell@umich.edu                format TrapImm {
2605222Sksewell@umich.edu                    0x0: tgei( {{ cond = (Rs.sw >= (int16_t)INTIMM); }});
2615222Sksewell@umich.edu                    0x1: tgeiu({{ cond = (Rs.uw >= (uint32_t)((int32_t)((int16_t)INTIMM))); }});
2625222Sksewell@umich.edu                    0x2: tlti( {{ cond = (Rs.sw < (int16_t)INTIMM); }});
2635222Sksewell@umich.edu                    0x3: tltiu({{ cond = (Rs.uw < (uint32_t)((int32_t)((int16_t)INTIMM))); }});
2645222Sksewell@umich.edu                    0x4: teqi( {{ cond = (Rs.sw == (int16_t)INTIMM);}});
2655222Sksewell@umich.edu                    0x6: tnei( {{ cond = (Rs.sw != (int16_t)INTIMM);}});
2662101SN/A                }
2672043SN/A            }
2682043SN/A
2692043SN/A            0x2: decode REGIMM_LO {
2702101SN/A                format Branch {
2712686Sksewell@umich.edu                    0x0: bltzal({{ cond = (Rs.sw < 0); }}, Link);
2722686Sksewell@umich.edu                    0x1: decode RS {
2732686Sksewell@umich.edu                        0x0: bal ({{ cond = 1; }}, IsCall, Link);
2742686Sksewell@umich.edu                        default: bgezal({{ cond = (Rs.sw >= 0); }}, Link);
2752686Sksewell@umich.edu                    }
2762686Sksewell@umich.edu                    0x2: bltzall({{ cond = (Rs.sw < 0); }}, Link, Likely);
2772686Sksewell@umich.edu                    0x3: bgezall({{ cond = (Rs.sw >= 0); }}, Link, Likely);
2782101SN/A                }
2792043SN/A            }
2802043SN/A
2812043SN/A            0x3: decode REGIMM_LO {
2824661Sksewell@umich.edu                // from Table 5-4 MIPS32 REGIMM Encoding of rt Field (DSP ASE MANUAL)
2834661Sksewell@umich.edu                0x4: DspBranch::bposge32({{ cond = (dspctl<5:0> >= 32); }});
2842101SN/A                format WarnUnimpl {
2852101SN/A                    0x7: synci();
2862101SN/A                }
2872043SN/A            }
2882043SN/A        }
2892043SN/A
2902123SN/A        format Jump {
2912239SN/A            0x2: j({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2);}});
2922686Sksewell@umich.edu            0x3: jal({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2); }}, IsCall,
2932686Sksewell@umich.edu                     Link);
2942043SN/A        }
2952043SN/A
2962100SN/A        format Branch {
2972686Sksewell@umich.edu            0x4: decode RS_RT  {
2982686Sksewell@umich.edu                0x0: b({{ cond = 1; }});
2992686Sksewell@umich.edu                default: beq({{ cond = (Rs.sw == Rt.sw); }});
3002686Sksewell@umich.edu            }
3012239SN/A            0x5: bne({{ cond = (Rs.sw != Rt.sw); }});
3022686Sksewell@umich.edu            0x6: blez({{ cond = (Rs.sw <= 0); }});
3032686Sksewell@umich.edu            0x7: bgtz({{ cond = (Rs.sw > 0); }});
3042043SN/A        }
3052084SN/A    }
3062024SN/A
3072101SN/A    0x1: decode OPCODE_LO {
3082686Sksewell@umich.edu        format IntImmOp {
3095222Sksewell@umich.edu            0x0: addi({{
3105222Sksewell@umich.edu                          int64_t Src1 = Rs.sw;
3115222Sksewell@umich.edu                          int64_t Src2 = imm;
3125222Sksewell@umich.edu                          int64_t temp_result;
3135222Sksewell@umich.edu#if  FULL_SYSTEM
3145222Sksewell@umich.edu                          if(((Src1 >> 31) & 1) == 1)
3155222Sksewell@umich.edu                            Src1 |= 0x100000000LL;
3165222Sksewell@umich.edu#endif
3175222Sksewell@umich.edu                          temp_result = Src1 + Src2;
3185222Sksewell@umich.edu#if  FULL_SYSTEM
3195222Sksewell@umich.edu                          if(((temp_result >> 31) & 1) == ((temp_result >> 32) & 1)){
3205222Sksewell@umich.edu#endif
3215222Sksewell@umich.edu                            Rt.sw = temp_result;
3225222Sksewell@umich.edu#if  FULL_SYSTEM
3235222Sksewell@umich.edu                          } else{
3245222Sksewell@umich.edu                            fault = new ArithmeticFault();
3255222Sksewell@umich.edu                          }
3265222Sksewell@umich.edu#endif
3275222Sksewell@umich.edu                        }});
3282239SN/A            0x1: addiu({{ Rt.sw = Rs.sw + imm;}});
3292239SN/A            0x2: slti({{ Rt.sw = ( Rs.sw < imm) ? 1 : 0 }});
3304661Sksewell@umich.edu
3314661Sksewell@umich.edu            //Edited to include MIPS AVP Pass/Fail instructions and
3324661Sksewell@umich.edu            //default to the sltiu instruction
3334661Sksewell@umich.edu            0x3: decode RS_RT_INTIMM {
3344661Sksewell@umich.edu                0xabc1: BasicOp::fail({{ exitSimLoop("AVP/SRVP Test Failed"); }});
3354661Sksewell@umich.edu                0xabc2: BasicOp::pass({{ exitSimLoop("AVP/SRVP Test Passed"); }});
3364661Sksewell@umich.edu              default: sltiu({{ Rt.uw = ( Rs.uw < (uint32_t)sextImm ) ? 1 : 0 }});
3374661Sksewell@umich.edu            }
3384661Sksewell@umich.edu
3392495SN/A            0x4: andi({{ Rt.sw = Rs.sw & zextImm;}});
3402495SN/A            0x5: ori({{ Rt.sw = Rs.sw | zextImm;}});
3412495SN/A            0x6: xori({{ Rt.sw = Rs.sw ^ zextImm;}});
3422495SN/A
3432495SN/A            0x7: decode RS {
3442495SN/A                0x0: lui({{ Rt = imm << 16}});
3452495SN/A            }
3462084SN/A        }
3472084SN/A    }
3482024SN/A
3492101SN/A    0x2: decode OPCODE_LO {
3502101SN/A        //Table A-11 MIPS32 COP0 Encoding of rs Field
3512101SN/A        0x0: decode RS_MSB {
3522101SN/A            0x0: decode RS {
3535222Sksewell@umich.edu                 format CP0Control {
3545222Sksewell@umich.edu                  0x0: mfc0({{  Rt = CP0_RD_SEL;
3555222Sksewell@umich.edu                                /* Hack for PageMask */
3565222Sksewell@umich.edu                                if(RD == 5) // PageMask
3575222Sksewell@umich.edu                                  if(Config3_SP == 0 || PageGrain_ESP == 0)
3585222Sksewell@umich.edu                                    Rt &= 0xFFFFE7FF;
3595222Sksewell@umich.edu                              }});
3605222Sksewell@umich.edu                  0x4: mtc0({{  CP0_RD_SEL = Rt;
3612052SN/A
3625222Sksewell@umich.edu                                if(RD == 11) // Compare{
3635222Sksewell@umich.edu                                  if(Cause_TI == 1){
3645222Sksewell@umich.edu                                    Cause_TI = 0;
3655222Sksewell@umich.edu                                    MiscReg cause = xc->readMiscRegNoEffect(MipsISA::Cause);
3665222Sksewell@umich.edu                                    int Offset = 10; // corresponding to Cause_IP0
3675222Sksewell@umich.edu                                    Offset += ((IntCtl_IPTI) - 2);
3685222Sksewell@umich.edu                                    replaceBits(cause,Offset,Offset,0);
3695222Sksewell@umich.edu                                    xc->setMiscRegNoEffect(MipsISA::Cause,cause);
3705222Sksewell@umich.edu                                  }
3714661Sksewell@umich.edu
3725222Sksewell@umich.edu                              }});
3735222Sksewell@umich.edu                 }
3745222Sksewell@umich.edu                 format CP0Unimpl {
3755222Sksewell@umich.edu                   0x1: dmfc0();
3765222Sksewell@umich.edu                   0x5: dmtc0();
3775222Sksewell@umich.edu                   default: unknown();
3785222Sksewell@umich.edu                 }
3794661Sksewell@umich.edu                format MT_MFTR { // Decode MIPS MT MFTR instruction into sub-instructions
3804661Sksewell@umich.edu                    0x8: decode MT_U {
3814661Sksewell@umich.edu                        0x0: mftc0({{ data = xc->readRegOtherThread((RT << 3 | SEL) +
3824661Sksewell@umich.edu                                                                    Ctrl_Base_DepTag);
3834661Sksewell@umich.edu                                   }});
3844661Sksewell@umich.edu                        0x1: decode SEL {
3854661Sksewell@umich.edu                            0x0: mftgpr({{ data = xc->readRegOtherThread(RT); }});
3864661Sksewell@umich.edu                            0x1: decode RT {
3874661Sksewell@umich.edu                                0x0: mftlo_dsp0({{ data = xc->readRegOtherThread(MipsISA::DSPLo0); }});
3884661Sksewell@umich.edu                                0x1: mfthi_dsp0({{ data = xc->readRegOtherThread(MipsISA::DSPHi0); }});
3894661Sksewell@umich.edu                                0x2: mftacx_dsp0({{ data = xc->readRegOtherThread(MipsISA::DSPACX0); }});
3904661Sksewell@umich.edu                                0x4: mftlo_dsp1({{ data = xc->readRegOtherThread(MipsISA::DSPLo1); }});
3914661Sksewell@umich.edu                                0x5: mfthi_dsp1({{ data = xc->readRegOtherThread(MipsISA::DSPHi1); }});
3924661Sksewell@umich.edu                                0x6: mftacx_dsp1({{ data = xc->readRegOtherThread(MipsISA::DSPACX1); }});
3934661Sksewell@umich.edu                                0x8: mftlo_dsp2({{ data = xc->readRegOtherThread(MipsISA::DSPLo2); }});
3944661Sksewell@umich.edu                                0x9: mfthi_dsp2({{ data = xc->readRegOtherThread(MipsISA::DSPHi2); }});
3954661Sksewell@umich.edu                                0x10: mftacx_dsp2({{ data = xc->readRegOtherThread(MipsISA::DSPACX2); }});
3964661Sksewell@umich.edu                                0x12: mftlo_dsp3({{ data = xc->readRegOtherThread(MipsISA::DSPLo3); }});
3974661Sksewell@umich.edu                                0x13: mfthi_dsp3({{ data = xc->readRegOtherThread(MipsISA::DSPHi3); }});
3984661Sksewell@umich.edu                                0x14: mftacx_dsp3({{ data = xc->readRegOtherThread(MipsISA::DSPACX3); }});
3994661Sksewell@umich.edu                                0x16: mftdsp({{ data = xc->readRegOtherThread(MipsISA::DSPControl); }});
4005222Sksewell@umich.edu                               default: CP0Unimpl::unknown();
4012686Sksewell@umich.edu                            }
4024661Sksewell@umich.edu                            0x2: decode MT_H {
4034661Sksewell@umich.edu                                0x0: mftc1({{ data = xc->readRegOtherThread(RT +
4044661Sksewell@umich.edu                                                                            FP_Base_DepTag);
4054661Sksewell@umich.edu                                           }});
4064661Sksewell@umich.edu                                0x1: mfthc1({{ data = xc->readRegOtherThread(RT +
4074661Sksewell@umich.edu                                                                             FP_Base_DepTag);
4084661Sksewell@umich.edu                                           }});
4095222Sksewell@umich.edu                               }
4104661Sksewell@umich.edu                            0x3: cftc1({{ uint32_t fcsr_val = xc->readRegOtherThread(MipsISA::FCSR +
4114661Sksewell@umich.edu                                                                            FP_Base_DepTag);
4124661Sksewell@umich.edu                                          switch (RT)
4134661Sksewell@umich.edu                                          {
4144661Sksewell@umich.edu                                               case 0:
4154661Sksewell@umich.edu                                                 data = xc->readRegOtherThread(MipsISA::FIR +
4164661Sksewell@umich.edu                                                                               Ctrl_Base_DepTag);
4174661Sksewell@umich.edu                                                 break;
4184661Sksewell@umich.edu                                               case 25:
4194661Sksewell@umich.edu                                                 data = 0 | fcsr_val & 0xFE000000 >> 24
4204661Sksewell@umich.edu                                                          | fcsr_val & 0x00800000 >> 23;
4214661Sksewell@umich.edu                                                 break;
4224661Sksewell@umich.edu                                               case 26:
4234661Sksewell@umich.edu                                                 data = 0 | fcsr_val & 0x0003F07C;
4244661Sksewell@umich.edu                                                 break;
4254661Sksewell@umich.edu                                               case 28:
4264661Sksewell@umich.edu                                                 data = 0 | fcsr_val & 0x00000F80
4274661Sksewell@umich.edu                                                          | fcsr_val & 0x01000000 >> 21
4284661Sksewell@umich.edu                                                          | fcsr_val & 0x00000003;
4294661Sksewell@umich.edu                                                 break;
4304661Sksewell@umich.edu                                               case 31:
4314661Sksewell@umich.edu                                                 data = fcsr_val;
4324661Sksewell@umich.edu                                                 break;
4334661Sksewell@umich.edu                                               default:
4344661Sksewell@umich.edu                                                 fatal("FP Control Value (%d) Not Valid");
4354661Sksewell@umich.edu                                          }
4364661Sksewell@umich.edu                                        }});
4375222Sksewell@umich.edu                           default: CP0Unimpl::unknown();
4382101SN/A                        }
4395222Sksewell@umich.edu                  }
4402686Sksewell@umich.edu                }
4412027SN/A
4424661Sksewell@umich.edu                format MT_MTTR { // Decode MIPS MT MTTR instruction into sub-instructions
4434661Sksewell@umich.edu                    0xC: decode MT_U {
4444661Sksewell@umich.edu                        0x0: mttc0({{ xc->setRegOtherThread((RD << 3 | SEL) + Ctrl_Base_DepTag,
4454661Sksewell@umich.edu                                                            Rt);
4464661Sksewell@umich.edu                                   }});
4474661Sksewell@umich.edu                        0x1: decode SEL {
4484661Sksewell@umich.edu                            0x0: mttgpr({{ xc->setRegOtherThread(RD, Rt); }});
4494661Sksewell@umich.edu                            0x1: decode RT {
4504661Sksewell@umich.edu                                0x0: mttlo_dsp0({{ xc->setRegOtherThread(MipsISA::DSPLo0, Rt);
4514661Sksewell@umich.edu                                                }});
4524661Sksewell@umich.edu                                0x1: mtthi_dsp0({{ xc->setRegOtherThread(MipsISA::DSPHi0,
4534661Sksewell@umich.edu                                                                         Rt);
4544661Sksewell@umich.edu                                                }});
4554661Sksewell@umich.edu                                0x2: mttacx_dsp0({{ xc->setRegOtherThread(MipsISA::DSPACX0,
4564661Sksewell@umich.edu                                                                          Rt);
4574661Sksewell@umich.edu                                                 }});
4584661Sksewell@umich.edu                                0x4: mttlo_dsp1({{ xc->setRegOtherThread(MipsISA::DSPLo1,
4594661Sksewell@umich.edu                                                                         Rt);
4604661Sksewell@umich.edu                                                }});
4614661Sksewell@umich.edu                                0x5: mtthi_dsp1({{ xc->setRegOtherThread(MipsISA::DSPHi1,
4624661Sksewell@umich.edu                                                                         Rt);
4634661Sksewell@umich.edu                                                }});
4644661Sksewell@umich.edu                                0x6: mttacx_dsp1({{ xc->setRegOtherThread(MipsISA::DSPACX1,
4654661Sksewell@umich.edu                                                                          Rt);
4664661Sksewell@umich.edu                                                 }});
4674661Sksewell@umich.edu                                0x8: mttlo_dsp2({{ xc->setRegOtherThread(MipsISA::DSPLo2,
4684661Sksewell@umich.edu                                                                         Rt);
4694661Sksewell@umich.edu                                                }});
4704661Sksewell@umich.edu                                0x9: mtthi_dsp2({{ xc->setRegOtherThread(MipsISA::DSPHi2,
4714661Sksewell@umich.edu                                                                         Rt);
4724661Sksewell@umich.edu                                                }});
4734661Sksewell@umich.edu                                0x10: mttacx_dsp2({{ xc->setRegOtherThread(MipsISA::DSPACX2,
4744661Sksewell@umich.edu                                                                           Rt);
4754661Sksewell@umich.edu                                                  }});
4764661Sksewell@umich.edu                                0x12: mttlo_dsp3({{ xc->setRegOtherThread(MipsISA::DSPLo3,
4774661Sksewell@umich.edu                                                                          Rt);
4784661Sksewell@umich.edu                                                 }});
4794661Sksewell@umich.edu                                0x13: mtthi_dsp3({{ xc->setRegOtherThread(MipsISA::DSPHi3,
4804661Sksewell@umich.edu                                                                          Rt);
4814661Sksewell@umich.edu                                                 }});
4824661Sksewell@umich.edu                                0x14: mttacx_dsp3({{ xc->setRegOtherThread(MipsISA::DSPACX3, Rt);
4834661Sksewell@umich.edu                                                  }});
4844661Sksewell@umich.edu                                0x16: mttdsp({{ xc->setRegOtherThread(MipsISA::DSPControl, Rt); }});
4855222Sksewell@umich.edu                               default: CP0Unimpl::unknown();
4865222Sksewell@umich.edu
4874661Sksewell@umich.edu                            }
4884661Sksewell@umich.edu                            0x2: mttc1({{ uint64_t data = xc->readRegOtherThread(RD +
4894661Sksewell@umich.edu                                                                                FP_Base_DepTag);
4904661Sksewell@umich.edu                                          data = insertBits(data, top_bit, bottom_bit, Rt);
4914661Sksewell@umich.edu                                          xc->setRegOtherThread(RD + FP_Base_DepTag, data);
4924661Sksewell@umich.edu                                       }});
4934661Sksewell@umich.edu                            0x3: cttc1({{ uint32_t data;
4944661Sksewell@umich.edu                                          switch (RD)
4954661Sksewell@umich.edu                                          {
4964661Sksewell@umich.edu                                            case 25:
4974661Sksewell@umich.edu                                              data = 0 | (Rt.uw<7:1> << 25) // move 31...25
4984661Sksewell@umich.edu                                                  | (FCSR & 0x01000000) // bit 24
4994661Sksewell@umich.edu                                                  | (FCSR & 0x004FFFFF);// bit 22...0
5004661Sksewell@umich.edu                                              break;
5014661Sksewell@umich.edu
5024661Sksewell@umich.edu                                            case 26:
5034661Sksewell@umich.edu                                              data = 0 | (FCSR & 0xFFFC0000) // move 31...18
5044661Sksewell@umich.edu                                                  | Rt.uw<17:12> << 12           // bit 17...12
5054661Sksewell@umich.edu                                                  | (FCSR & 0x00000F80) << 7// bit 11...7
5064661Sksewell@umich.edu                                                  | Rt.uw<6:2> << 2              // bit 6...2
5074661Sksewell@umich.edu                                                  | (FCSR & 0x00000002);     // bit 1...0
5084661Sksewell@umich.edu                                              break;
5094661Sksewell@umich.edu
5104661Sksewell@umich.edu                                            case 28:
5114661Sksewell@umich.edu                                              data = 0 | (FCSR & 0xFE000000) // move 31...25
5124661Sksewell@umich.edu                                                  | Rt.uw<2:2> << 24       // bit 24
5134661Sksewell@umich.edu                                                  | (FCSR & 0x00FFF000) << 23// bit 23...12
5144661Sksewell@umich.edu                                                  | Rt.uw<11:7> << 7       // bit 24
5154661Sksewell@umich.edu                                                  | (FCSR & 0x000007E)
5164661Sksewell@umich.edu                                                  | Rt.uw<1:0>;// bit 22...0
5174661Sksewell@umich.edu                                              break;
5184661Sksewell@umich.edu
5194661Sksewell@umich.edu                                            case 31:
5204661Sksewell@umich.edu                                              data  = Rt.uw;
5214661Sksewell@umich.edu                                              break;
5224661Sksewell@umich.edu
5234661Sksewell@umich.edu                                            default:
5244661Sksewell@umich.edu                                              panic("FP Control Value (%d) Not Available. Ignoring Access to"
5254661Sksewell@umich.edu                                                    "Floating Control Status Register", FS);
5264661Sksewell@umich.edu                                          }
5274661Sksewell@umich.edu                                          xc->setRegOtherThread(FCSR, data);
5284661Sksewell@umich.edu                                       }});
5295222Sksewell@umich.edu                               default: CP0Unimpl::unknown();
5304661Sksewell@umich.edu                        }
5314661Sksewell@umich.edu                    }
5322101SN/A                }
5334661Sksewell@umich.edu
5344661Sksewell@umich.edu
5354661Sksewell@umich.edu                0xB: decode RD {
5364661Sksewell@umich.edu                    format MT_Control {
5374661Sksewell@umich.edu                        0x0: decode POS {
5384661Sksewell@umich.edu                            0x0: decode SEL {
5394661Sksewell@umich.edu                                0x1: decode SC {
5404661Sksewell@umich.edu                                    0x0: dvpe({{ Rt = MVPControl;
5414661Sksewell@umich.edu                                                 if (VPEConf0<VPEC0_MVP:> == 1) {
5424661Sksewell@umich.edu                                                     MVPControl = insertBits(MVPControl, MVPC_EVP, 0);
5434661Sksewell@umich.edu                                                 }
5444661Sksewell@umich.edu                                              }});
5454661Sksewell@umich.edu                                    0x1: evpe({{ Rt = MVPControl;
5464661Sksewell@umich.edu                                                 if (VPEConf0<VPEC0_MVP:> == 1) {
5474661Sksewell@umich.edu                                                     MVPControl = insertBits(MVPControl, MVPC_EVP, 1);
5484661Sksewell@umich.edu                                                 }
5494661Sksewell@umich.edu                                              }});
5505222Sksewell@umich.edu                                   default:CP0Unimpl::unknown();
5514661Sksewell@umich.edu                                }
5525222Sksewell@umich.edu                               default:CP0Unimpl::unknown();
5534661Sksewell@umich.edu                            }
5545222Sksewell@umich.edu                        default:CP0Unimpl::unknown();
5555222Sksewell@umich.edu                      }
5564661Sksewell@umich.edu
5574661Sksewell@umich.edu                        0x1: decode POS {
5584661Sksewell@umich.edu                            0xF: decode SEL {
5594661Sksewell@umich.edu                                0x1: decode SC {
5604661Sksewell@umich.edu                                    0x0: dmt({{ Rt = VPEControl;
5614661Sksewell@umich.edu                                                VPEControl = insertBits(VPEControl, VPEC_TE, 0);
5624661Sksewell@umich.edu                                         }});
5634661Sksewell@umich.edu                                    0x1: emt({{ Rt = VPEControl;
5644661Sksewell@umich.edu                                                VPEControl = insertBits(VPEControl, VPEC_TE, 1);
5654661Sksewell@umich.edu                                         }});
5665222Sksewell@umich.edu                                   default:CP0Unimpl::unknown();
5674661Sksewell@umich.edu                                }
5685222Sksewell@umich.edu                               default:CP0Unimpl::unknown();
5694661Sksewell@umich.edu                            }
5705222Sksewell@umich.edu                            default:CP0Unimpl::unknown();
5714661Sksewell@umich.edu                        }
5724661Sksewell@umich.edu                    }
5734661Sksewell@umich.edu                    0xC: decode POS {
5744661Sksewell@umich.edu                      0x0: decode SC {
5754661Sksewell@umich.edu                        0x0: CP0Control::di({{
5764661Sksewell@umich.edu                            if(Config_AR >= 1) // Rev 2.0 or beyond?
5774661Sksewell@umich.edu                                {
5784661Sksewell@umich.edu                                  Rt = Status;
5794661Sksewell@umich.edu                                  Status_IE = 0;
5804661Sksewell@umich.edu                                }
5814661Sksewell@umich.edu                            else // Enable this else branch once we actually set values for Config on init
5824661Sksewell@umich.edu                              {
5834661Sksewell@umich.edu                                fault = new ReservedInstructionFault();
5844661Sksewell@umich.edu                              }
5854661Sksewell@umich.edu                          }});
5864661Sksewell@umich.edu                        0x1: CP0Control::ei({{
5874661Sksewell@umich.edu                            if(Config_AR >= 1)
5884661Sksewell@umich.edu                              {
5894661Sksewell@umich.edu                                Rt = Status;
5904661Sksewell@umich.edu                                Status_IE = 1;
5914661Sksewell@umich.edu                              }
5924661Sksewell@umich.edu                            else
5934661Sksewell@umich.edu                              {
5944661Sksewell@umich.edu                                fault = new ReservedInstructionFault();
5954661Sksewell@umich.edu                              }
5964661Sksewell@umich.edu                          }});
5975222Sksewell@umich.edu                        default:CP0Unimpl::unknown();
5984661Sksewell@umich.edu                      }
5994661Sksewell@umich.edu                    }
6005222Sksewell@umich.edu                default: CP0Unimpl::unknown();
6014661Sksewell@umich.edu                }
6024661Sksewell@umich.edu                format CP0Control {
6034661Sksewell@umich.edu                    0xA: rdpgpr({{
6044661Sksewell@umich.edu                      if(Config_AR >= 1)
6054661Sksewell@umich.edu                        { // Rev 2 of the architecture
6065222Sksewell@umich.edu                          Rd = xc->tcBase()->readIntReg(RT + NumIntRegs * SRSCtl_PSS);
6074661Sksewell@umich.edu                        }
6084661Sksewell@umich.edu                      else
6094661Sksewell@umich.edu                        {
6104661Sksewell@umich.edu                          fault = new ReservedInstructionFault();
6114661Sksewell@umich.edu                        }
6124661Sksewell@umich.edu                         }});
6134661Sksewell@umich.edu                    0xE: wrpgpr({{
6144661Sksewell@umich.edu                      if(Config_AR >= 1)
6154661Sksewell@umich.edu                        { // Rev 2 of the architecture
6165222Sksewell@umich.edu                          xc->tcBase()->setIntReg(RD + NumIntRegs * SRSCtl_PSS,Rt);
6175222Sksewell@umich.edu                          //			  warn("Writing %d to %d, PSS: %d, SRS: %x\n",Rt,RD + NumIntRegs * SRSCtl_PSS, SRSCtl_PSS,SRSCtl);
6184661Sksewell@umich.edu                        }
6194661Sksewell@umich.edu                      else
6204661Sksewell@umich.edu                        {
6214661Sksewell@umich.edu                          fault = new ReservedInstructionFault();
6224661Sksewell@umich.edu                        }
6234661Sksewell@umich.edu
6244661Sksewell@umich.edu                         }});
6254661Sksewell@umich.edu                }
6264661Sksewell@umich.edu
6275222Sksewell@umich.edu               }
6282101SN/A
6292101SN/A            //Table A-12 MIPS32 COP0 Encoding of Function Field When rs=CO
6302101SN/A            0x1: decode FUNCTION {
6314661Sksewell@umich.edu              format CP0Control {
6324661Sksewell@umich.edu                0x18: eret({{
6335222Sksewell@umich.edu                               DPRINTF(MipsPRA,"Restoring PC - %x\n",EPC);
6345222Sksewell@umich.edu                               // Ugly hack to get the value of Status_EXL
6355222Sksewell@umich.edu                               if(Status_EXL == 1){
6365222Sksewell@umich.edu                                 DPRINTF(MipsPRA,"ERET EXL Hack\n");
6375222Sksewell@umich.edu                               }
6384661Sksewell@umich.edu                  if(Status_ERL == 1){
6394661Sksewell@umich.edu                    Status_ERL = 0;
6404661Sksewell@umich.edu                    NPC = ErrorEPC;
6415222Sksewell@umich.edu                    NNPC = ErrorEPC + sizeof(MachInst); // Need to adjust NNPC, otherwise things break
6424661Sksewell@umich.edu                  }
6435222Sksewell@umich.edu                  else {
6444661Sksewell@umich.edu                    NPC = EPC;
6455222Sksewell@umich.edu                    NNPC = EPC + sizeof(MachInst); // Need to adjust NNPC, otherwise things break
6464661Sksewell@umich.edu                    Status_EXL = 0;
6475222Sksewell@umich.edu                    if(Config_AR >=1 && SRSCtl_HSS > 0 && Status_BEV == 0){
6484661Sksewell@umich.edu                      SRSCtl_CSS = SRSCtl_PSS;
6495250Sksewell@umich.edu                      //xc->setShadowSet(SRSCtl_PSS);
6504661Sksewell@umich.edu                    }
6514661Sksewell@umich.edu                  }
6525222Sksewell@umich.edu                  LLFlag = 0;
6535222Sksewell@umich.edu                 }},IsReturn,IsSerializing,IsERET);
6545222Sksewell@umich.edu
6555222Sksewell@umich.edu                0x1F: deret({{
6565222Sksewell@umich.edu                  // if(EJTagImplemented()) {
6575222Sksewell@umich.edu                  if(Debug_DM == 1){
6585222Sksewell@umich.edu                    Debug_DM = 1;
6595222Sksewell@umich.edu                    Debug_IEXI = 0;
6605222Sksewell@umich.edu                    NPC = DEPC;
6615222Sksewell@umich.edu                  }
6625222Sksewell@umich.edu                  else
6635222Sksewell@umich.edu                    {
6645222Sksewell@umich.edu                      // Undefined;
6655222Sksewell@umich.edu                    }
6665222Sksewell@umich.edu                  //} // EJTag Implemented
6675222Sksewell@umich.edu                  //else {
6685222Sksewell@umich.edu                  // Reserved Instruction Exception
6695222Sksewell@umich.edu                  //}
6705222Sksewell@umich.edu                 }},IsReturn,IsSerializing,IsERET);
6715222Sksewell@umich.edu              }
6725222Sksewell@umich.edu              format CP0TLB {
6735222Sksewell@umich.edu                0x01: tlbr({{
6745222Sksewell@umich.edu                    MipsISA::PTE *PTEntry = xc->tcBase()->getITBPtr()->getEntry(Index & 0x7FFFFFFF);
6755222Sksewell@umich.edu                    if(PTEntry == NULL)
6765222Sksewell@umich.edu                      {
6775222Sksewell@umich.edu                        fatal("Invalid PTE Entry received on a TLBR instruction\n");
6785222Sksewell@umich.edu                      }
6795222Sksewell@umich.edu                    /* Setup PageMask */
6805222Sksewell@umich.edu                    PageMask = (PTEntry->Mask << 11); // If 1KB pages are not enabled, a read of PageMask must return 0b00 in bits 12, 11
6815222Sksewell@umich.edu                    /* Setup EntryHi */
6825222Sksewell@umich.edu                    EntryHi = ((PTEntry->VPN << 11) | (PTEntry->asid));
6835222Sksewell@umich.edu                    /* Setup Entry Lo0 */
6845222Sksewell@umich.edu                    EntryLo0 = ((PTEntry->PFN0 << 6) | (PTEntry->C0 << 3) | (PTEntry->D0 << 2) | (PTEntry->V0 << 1) | PTEntry->G);
6855222Sksewell@umich.edu                    /* Setup Entry Lo1 */
6865222Sksewell@umich.edu                    EntryLo1 = ((PTEntry->PFN1 << 6) | (PTEntry->C1 << 3) | (PTEntry->D1 << 2) | (PTEntry->V1 << 1) | PTEntry->G);
6875222Sksewell@umich.edu                }}); // Need to hook up to TLB
6885222Sksewell@umich.edu
6895222Sksewell@umich.edu                0x02: tlbwi({{
6905222Sksewell@umich.edu                                //Create PTE
6915222Sksewell@umich.edu                                MipsISA::PTE NewEntry;
6925222Sksewell@umich.edu                                //Write PTE
6935222Sksewell@umich.edu                                NewEntry.Mask = (Addr)(PageMask >> 11);
6945222Sksewell@umich.edu                                NewEntry.VPN = (Addr)(EntryHi >> 11);
6955222Sksewell@umich.edu                                /*  PageGrain _ ESP                    Config3 _ SP */
6965222Sksewell@umich.edu                                if(((PageGrain>>28) & 1) == 0 || ((Config3>>4)&1) ==0) {
6975222Sksewell@umich.edu                                  NewEntry.Mask |= 0x3; // If 1KB pages are *NOT* enabled, lowest bits of the mask are 0b11 for TLB writes
6985222Sksewell@umich.edu                                  NewEntry.VPN &= 0xFFFFFFFC; // Reset bits 0 and 1 if 1KB pages are not enabled
6995222Sksewell@umich.edu                                }
7005222Sksewell@umich.edu                                NewEntry.asid = (uint8_t)(EntryHi & 0xFF);
7015222Sksewell@umich.edu
7025222Sksewell@umich.edu                                NewEntry.PFN0 = (Addr)(EntryLo0 >> 6);
7035222Sksewell@umich.edu                                NewEntry.PFN1 = (Addr)(EntryLo1 >> 6);
7045222Sksewell@umich.edu                                NewEntry.D0 = (bool)((EntryLo0 >> 2) & 1);
7055222Sksewell@umich.edu                                NewEntry.D1 = (bool)((EntryLo1 >> 2) & 1);
7065222Sksewell@umich.edu                                NewEntry.V1 = (bool)((EntryLo1 >> 1) & 1);
7075222Sksewell@umich.edu                                NewEntry.V0 = (bool)((EntryLo0 >> 1) & 1);
7085222Sksewell@umich.edu                                NewEntry.G = (bool)((EntryLo0 & EntryLo1) & 1);
7095222Sksewell@umich.edu                                NewEntry.C0 = (uint8_t)((EntryLo0 >> 3) & 0x7);
7105222Sksewell@umich.edu                                NewEntry.C1 = (uint8_t)((EntryLo1 >> 3) & 0x7);
7115222Sksewell@umich.edu                                /* Now, compute the AddrShiftAmount and OffsetMask - TLB optimizations */
7125222Sksewell@umich.edu                                /* Addr Shift Amount for 1KB or larger pages */
7135222Sksewell@umich.edu                                //	    warn("PTE->Mask: %x\n",pte->Mask);
7145222Sksewell@umich.edu                                if((NewEntry.Mask & 0xFFFF) == 3){
7155222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 12;
7165222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFFF) == 0x0000){
7175222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 10;
7185222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFFC) == 0x000C){
7195222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 14;
7205222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFF0) == 0x0030){
7215222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 16;
7225222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFC0) == 0x00C0){
7235222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 18;
7245222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFF00) == 0x0300){
7255222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 20;
7265222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFC00) == 0x0C00){
7275222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 22;
7285222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xF000) == 0x3000){
7295222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 24;
7305222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xC000) == 0xC000){
7315222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 26;
7325222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0x30000) == 0x30000){
7335222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 28;
7345222Sksewell@umich.edu                                } else {
7355222Sksewell@umich.edu                                  fatal("Invalid Mask Pattern Detected!\n");
7365222Sksewell@umich.edu                                }
7375222Sksewell@umich.edu                                NewEntry.OffsetMask = ((1<<NewEntry.AddrShiftAmount)-1);
7385222Sksewell@umich.edu
7395222Sksewell@umich.edu                                MipsISA::TLB *Ptr=xc->tcBase()->getITBPtr();
7405222Sksewell@umich.edu                                MiscReg c3=xc->readMiscReg(MipsISA::Config3);
7415222Sksewell@umich.edu                                MiscReg pg=xc->readMiscReg(MipsISA::PageGrain);
7425222Sksewell@umich.edu                                int SP=0;
7435222Sksewell@umich.edu                                if(bits(c3,Config3_SP)==1 && bits(pg,PageGrain_ESP)==1){
7445222Sksewell@umich.edu                                  SP=1;
7455222Sksewell@umich.edu                                }
7465222Sksewell@umich.edu                                Ptr->insertAt(NewEntry,Index & 0x7FFFFFFF,SP);
7475222Sksewell@umich.edu              }});
7485222Sksewell@umich.edu                0x06: tlbwr({{
7495222Sksewell@umich.edu                                //Create PTE
7505222Sksewell@umich.edu                                MipsISA::PTE NewEntry;
7515222Sksewell@umich.edu                                //Write PTE
7525222Sksewell@umich.edu                                NewEntry.Mask = (Addr)(PageMask >> 11);
7535222Sksewell@umich.edu                                NewEntry.VPN = (Addr)(EntryHi >> 11);
7545222Sksewell@umich.edu                                /*  PageGrain _ ESP                    Config3 _ SP */
7555222Sksewell@umich.edu                                if(((PageGrain>>28) & 1) == 0 || ((Config3>>4)&1) ==0) {
7565222Sksewell@umich.edu                                  NewEntry.Mask |= 0x3; // If 1KB pages are *NOT* enabled, lowest bits of the mask are 0b11 for TLB writes
7575222Sksewell@umich.edu                                  NewEntry.VPN &= 0xFFFFFFFC; // Reset bits 0 and 1 if 1KB pages are not enabled
7585222Sksewell@umich.edu                                }
7595222Sksewell@umich.edu                                NewEntry.asid = (uint8_t)(EntryHi & 0xFF);
7605222Sksewell@umich.edu
7615222Sksewell@umich.edu                                NewEntry.PFN0 = (Addr)(EntryLo0 >> 6);
7625222Sksewell@umich.edu                                NewEntry.PFN1 = (Addr)(EntryLo1 >> 6);
7635222Sksewell@umich.edu                                NewEntry.D0 = (bool)((EntryLo0 >> 2) & 1);
7645222Sksewell@umich.edu                                NewEntry.D1 = (bool)((EntryLo1 >> 2) & 1);
7655222Sksewell@umich.edu                                NewEntry.V1 = (bool)((EntryLo1 >> 1) & 1);
7665222Sksewell@umich.edu                                NewEntry.V0 = (bool)((EntryLo0 >> 1) & 1);
7675222Sksewell@umich.edu                                NewEntry.G = (bool)((EntryLo0 & EntryLo1) & 1);
7685222Sksewell@umich.edu                                NewEntry.C0 = (uint8_t)((EntryLo0 >> 3) & 0x7);
7695222Sksewell@umich.edu                                NewEntry.C1 = (uint8_t)((EntryLo1 >> 3) & 0x7);
7705222Sksewell@umich.edu                                /* Now, compute the AddrShiftAmount and OffsetMask - TLB optimizations */
7715222Sksewell@umich.edu                                /* Addr Shift Amount for 1KB or larger pages */
7725222Sksewell@umich.edu                                //	    warn("PTE->Mask: %x\n",pte->Mask);
7735222Sksewell@umich.edu                                if((NewEntry.Mask & 0xFFFF) == 3){
7745222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 12;
7755222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFFF) == 0x0000){
7765222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 10;
7775222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFFC) == 0x000C){
7785222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 14;
7795222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFF0) == 0x0030){
7805222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 16;
7815222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFFC0) == 0x00C0){
7825222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 18;
7835222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFF00) == 0x0300){
7845222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 20;
7855222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xFC00) == 0x0C00){
7865222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 22;
7875222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xF000) == 0x3000){
7885222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 24;
7895222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0xC000) == 0xC000){
7905222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 26;
7915222Sksewell@umich.edu                                } else if((NewEntry.Mask & 0x30000) == 0x30000){
7925222Sksewell@umich.edu                                  NewEntry.AddrShiftAmount = 28;
7935222Sksewell@umich.edu                                } else {
7945222Sksewell@umich.edu                                  fatal("Invalid Mask Pattern Detected!\n");
7955222Sksewell@umich.edu                                }
7965222Sksewell@umich.edu                                NewEntry.OffsetMask = ((1<<NewEntry.AddrShiftAmount)-1);
7975222Sksewell@umich.edu
7985222Sksewell@umich.edu                                MipsISA::TLB *Ptr=xc->tcBase()->getITBPtr();
7995222Sksewell@umich.edu                                MiscReg c3=xc->readMiscReg(MipsISA::Config3);
8005222Sksewell@umich.edu                                MiscReg pg=xc->readMiscReg(MipsISA::PageGrain);
8015222Sksewell@umich.edu                                int SP=0;
8025222Sksewell@umich.edu                                if(bits(c3,Config3_SP)==1 && bits(pg,PageGrain_ESP)==1){
8035222Sksewell@umich.edu                                  SP=1;
8045222Sksewell@umich.edu                                }
8055222Sksewell@umich.edu                                Ptr->insertAt(NewEntry,Random,SP);
8064661Sksewell@umich.edu                }});
8072101SN/A
8085222Sksewell@umich.edu                0x08: tlbp({{
8095222Sksewell@umich.edu                               int TLB_Index;
8105222Sksewell@umich.edu                               Addr VPN;
8115222Sksewell@umich.edu                               if(PageGrain_ESP == 1 && Config3_SP ==1){
8125222Sksewell@umich.edu                                 VPN = EntryHi >> 11;
8135222Sksewell@umich.edu                               } else {
8145222Sksewell@umich.edu                                 VPN = ((EntryHi >> 11) & 0xFFFFFFFC); // Mask off lower 2 bits
8155222Sksewell@umich.edu                               }
8165222Sksewell@umich.edu                               TLB_Index = xc->tcBase()->getITBPtr()->probeEntry(VPN,EntryHi_ASID);
8175222Sksewell@umich.edu                               if(TLB_Index != -1){  // Check TLB for entry matching EntryHi
8185222Sksewell@umich.edu                                 Index=TLB_Index;
8195222Sksewell@umich.edu                                 //			    warn("\ntlbp: Match Found!\n");
8205222Sksewell@umich.edu                               } else {// else, set Index = 1<<31
8215222Sksewell@umich.edu                                 Index = (1<<31);
8225222Sksewell@umich.edu                               }
8235222Sksewell@umich.edu                        }});
8244661Sksewell@umich.edu              }
8255222Sksewell@umich.edu              format CP0Unimpl {
8265222Sksewell@umich.edu                0x20: wait();
8275222Sksewell@umich.edu              }
8285222Sksewell@umich.edu               default: CP0Unimpl::unknown();
8294661Sksewell@umich.edu
8302101SN/A            }
8312043SN/A        }
8322027SN/A
8332101SN/A        //Table A-13 MIPS32 COP1 Encoding of rs Field
8342101SN/A        0x1: decode RS_MSB {
8352041SN/A
8362101SN/A            0x0: decode RS_HI {
8372101SN/A                0x0: decode RS_LO {
8382686Sksewell@umich.edu                    format CP1Control {
8392742Sksewell@umich.edu                        0x0: mfc1 ({{ Rt.uw = Fs.uw; }});
8402495SN/A
8412495SN/A                        0x2: cfc1({{
8422573SN/A                            switch (FS)
8432573SN/A                            {
8442573SN/A                              case 0:
8452616SN/A                                Rt = FIR;
8462573SN/A                                break;
8472573SN/A                              case 25:
8482616SN/A                                Rt = 0 | (FCSR & 0xFE000000) >> 24 | (FCSR & 0x00800000) >> 23;
8492573SN/A                                break;
8502573SN/A                              case 26:
8512616SN/A                                Rt = 0 | (FCSR & 0x0003F07C);
8522573SN/A                                break;
8532573SN/A                              case 28:
8542616SN/A                                Rt = 0 | (FCSR & 0x00000F80) | (FCSR & 0x01000000) >> 21 | (FCSR & 0x00000003);
8552573SN/A                                break;
8562573SN/A                              case 31:
8572616SN/A                                Rt = FCSR;
8582573SN/A                                break;
8592573SN/A                              default:
8605222Sksewell@umich.edu                                warn("FP Control Value (%d) Not Valid");
8612573SN/A                            }
8625222Sksewell@umich.edu                            //			    warn("FCSR: %x, FS: %d, FIR: %x, Rt: %x\n",FCSR, FS, FIR, Rt);
8632573SN/A                        }});
8642573SN/A
8652686Sksewell@umich.edu                        0x3: mfhc1({{ Rt.uw = Fs.ud<63:32>;}});
8662686Sksewell@umich.edu
8672686Sksewell@umich.edu                        0x4: mtc1 ({{ Fs.uw = Rt.uw;       }});
8682686Sksewell@umich.edu
8692573SN/A                        0x6: ctc1({{
8702573SN/A                            switch (FS)
8712573SN/A                            {
8722573SN/A                              case 25:
8732616SN/A                                FCSR = 0 | (Rt.uw<7:1> << 25) // move 31...25
8742616SN/A                                    | (FCSR & 0x01000000) // bit 24
8752616SN/A                                    | (FCSR & 0x004FFFFF);// bit 22...0
8762573SN/A                                break;
8772573SN/A
8782573SN/A                              case 26:
8792616SN/A                                FCSR = 0 | (FCSR & 0xFFFC0000) // move 31...18
8802573SN/A                                    | Rt.uw<17:12> << 12           // bit 17...12
8812616SN/A                                    | (FCSR & 0x00000F80) << 7// bit 11...7
8822573SN/A                                    | Rt.uw<6:2> << 2              // bit 6...2
8832616SN/A                                    | (FCSR & 0x00000002);     // bit 1...0
8842573SN/A                                break;
8852573SN/A
8862573SN/A                              case 28:
8872616SN/A                                FCSR = 0 | (FCSR & 0xFE000000) // move 31...25
8882573SN/A                                    | Rt.uw<2:2> << 24       // bit 24
8892616SN/A                                    | (FCSR & 0x00FFF000) << 23// bit 23...12
8902573SN/A                                    | Rt.uw<11:7> << 7       // bit 24
8912616SN/A                                    | (FCSR & 0x000007E)
8922573SN/A                                    | Rt.uw<1:0>;// bit 22...0
8932573SN/A                                break;
8942573SN/A
8952573SN/A                              case 31:
8962616SN/A                                FCSR  = Rt.uw;
8972573SN/A                                break;
8982573SN/A
8992573SN/A                              default:
9002495SN/A                                panic("FP Control Value (%d) Not Available. Ignoring Access to"
9012616SN/A                                      "Floating Control Status Register", FS);
9022495SN/A                            }
9032495SN/A                        }});
9042686Sksewell@umich.edu
9052686Sksewell@umich.edu                        0x7: mthc1({{
9062686Sksewell@umich.edu                             uint64_t fs_hi = Rt.uw;
9072686Sksewell@umich.edu                             uint64_t fs_lo = Fs.ud & 0x0FFFFFFFF;
9082686Sksewell@umich.edu                             Fs.ud = (fs_hi << 32) | fs_lo;
9092686Sksewell@umich.edu                        }});
9102686Sksewell@umich.edu
9112101SN/A                    }
9125222Sksewell@umich.edu                    format CP1Unimpl {
9135222Sksewell@umich.edu                      0x1: dmfc1();
9145222Sksewell@umich.edu                      0x5: dmtc1();
9155222Sksewell@umich.edu                    }
9165222Sksewell@umich.edu                   }
9172025SN/A
9185222Sksewell@umich.edu                0x1:
9195222Sksewell@umich.edu                   decode RS_LO {
9205222Sksewell@umich.edu                     0x0:
9215222Sksewell@umich.edu                     decode ND {
9225222Sksewell@umich.edu                       format Branch {
9235222Sksewell@umich.edu                         0x0: decode TF {
9245222Sksewell@umich.edu                           0x0: bc1f({{ cond = getCondCode(FCSR, BRANCH_CC) == 0;
9255222Sksewell@umich.edu                                       }});
9265222Sksewell@umich.edu                           0x1: bc1t({{ cond = getCondCode(FCSR, BRANCH_CC) == 1;
9275222Sksewell@umich.edu                                       }});
9285222Sksewell@umich.edu                         }
9295222Sksewell@umich.edu                         0x1: decode TF {
9305222Sksewell@umich.edu                           0x0: bc1fl({{ cond = getCondCode(FCSR, BRANCH_CC) == 0;
9315222Sksewell@umich.edu                                        }}, Likely);
9325222Sksewell@umich.edu                           0x1: bc1tl({{ cond = getCondCode(FCSR, BRANCH_CC) == 1;
9335222Sksewell@umich.edu                                        }}, Likely);
9345222Sksewell@umich.edu                         }
9355222Sksewell@umich.edu                       }
9365222Sksewell@umich.edu                     }
9375222Sksewell@umich.edu                   format CP1Unimpl {
9385222Sksewell@umich.edu                     0x1: bc1any2();
9395222Sksewell@umich.edu                     0x2: bc1any4();
9405222Sksewell@umich.edu                     default: unknown();
9415222Sksewell@umich.edu                   }
9425222Sksewell@umich.edu                   }
9432043SN/A            }
9442027SN/A
9452101SN/A            0x1: decode RS_HI {
9462101SN/A                0x2: decode RS_LO {
9472101SN/A                    //Table A-14 MIPS32 COP1 Encoding of Function Field When rs=S
9482686Sksewell@umich.edu                    //(( single-precision floating point))
9492572SN/A                    0x0: decode FUNCTION_HI {
9502572SN/A                        0x0: decode FUNCTION_LO {
9512101SN/A                            format FloatOp {
9522601SN/A                                0x0: add_s({{ Fd.sf = Fs.sf + Ft.sf;}});
9532601SN/A                                0x1: sub_s({{ Fd.sf = Fs.sf - Ft.sf;}});
9542601SN/A                                0x2: mul_s({{ Fd.sf = Fs.sf * Ft.sf;}});
9552601SN/A                                0x3: div_s({{ Fd.sf = Fs.sf / Ft.sf;}});
9562601SN/A                                0x4: sqrt_s({{ Fd.sf = sqrt(Fs.sf);}});
9572601SN/A                                0x5: abs_s({{ Fd.sf = fabs(Fs.sf);}});
9582686Sksewell@umich.edu                                0x7: neg_s({{ Fd.sf = -Fs.sf;}});
9592101SN/A                            }
9602742Sksewell@umich.edu
9612742Sksewell@umich.edu                            0x6: BasicOp::mov_s({{ Fd.sf = Fs.sf;}});
9622101SN/A                        }
9632027SN/A
9642572SN/A                        0x1: decode FUNCTION_LO {
9652686Sksewell@umich.edu                            format FloatConvertOp {
9662686Sksewell@umich.edu                                0x0: round_l_s({{ val = Fs.sf; }}, ToLong,
9672686Sksewell@umich.edu                                               Round);
9682686Sksewell@umich.edu                                0x1: trunc_l_s({{ val = Fs.sf; }}, ToLong,
9692686Sksewell@umich.edu                                               Trunc);
9702686Sksewell@umich.edu                                0x2: ceil_l_s({{ val = Fs.sf; }}, ToLong,
9712686Sksewell@umich.edu                                               Ceil);
9722686Sksewell@umich.edu                                0x3: floor_l_s({{ val = Fs.sf; }}, ToLong,
9732686Sksewell@umich.edu                                               Floor);
9742686Sksewell@umich.edu                                0x4: round_w_s({{ val = Fs.sf; }}, ToWord,
9752686Sksewell@umich.edu                                               Round);
9762686Sksewell@umich.edu                                0x5: trunc_w_s({{ val = Fs.sf; }}, ToWord,
9772686Sksewell@umich.edu                                               Trunc);
9782686Sksewell@umich.edu                                0x6: ceil_w_s({{ val = Fs.sf; }}, ToWord,
9792686Sksewell@umich.edu                                               Ceil);
9802686Sksewell@umich.edu                                0x7: floor_w_s({{ val = Fs.sf; }}, ToWord,
9812686Sksewell@umich.edu                                               Floor);
9822101SN/A                            }
9832101SN/A                        }
9842027SN/A
9852572SN/A                        0x2: decode FUNCTION_LO {
9862101SN/A                            0x1: decode MOVCF {
9872686Sksewell@umich.edu                                format BasicOp {
9882686Sksewell@umich.edu                                    0x0: movf_s({{ Fd = (getCondCode(FCSR,CC) == 0) ? Fs : Fd; }});
9892686Sksewell@umich.edu                                    0x1: movt_s({{ Fd = (getCondCode(FCSR,CC) == 1) ? Fs : Fd; }});
9902101SN/A                                }
9912101SN/A                            }
9922027SN/A
9932686Sksewell@umich.edu                            format BasicOp {
9942686Sksewell@umich.edu                                0x2: movz_s({{ Fd = (Rt == 0) ? Fs : Fd; }});
9952686Sksewell@umich.edu                                0x3: movn_s({{ Fd = (Rt != 0) ? Fs : Fd; }});
9962686Sksewell@umich.edu                            }
9972686Sksewell@umich.edu
9982602SN/A                            format FloatOp {
9992602SN/A                                0x5: recip_s({{ Fd = 1 / Fs; }});
10002602SN/A                                0x6: rsqrt_s({{ Fd = 1 / sqrt(Fs);}});
10012101SN/A                            }
10025222Sksewell@umich.edu                            format CP1Unimpl {
10035222Sksewell@umich.edu                              default: unknown();
10045222Sksewell@umich.edu                            }
10052101SN/A                        }
10065222Sksewell@umich.edu                        0x3: CP1Unimpl::unknown();
10072027SN/A
10082572SN/A                        0x4: decode FUNCTION_LO {
10092603SN/A                            format FloatConvertOp {
10102686Sksewell@umich.edu                                0x1: cvt_d_s({{ val = Fs.sf; }}, ToDouble);
10112686Sksewell@umich.edu                                0x4: cvt_w_s({{ val = Fs.sf; }}, ToWord);
10122686Sksewell@umich.edu                                0x5: cvt_l_s({{ val = Fs.sf; }}, ToLong);
10132101SN/A                            }
10142055SN/A
10152686Sksewell@umich.edu                            0x6: FloatOp::cvt_ps_s({{
10162686Sksewell@umich.edu                                    Fd.ud = (uint64_t) Fs.uw << 32 |
10172686Sksewell@umich.edu                                            (uint64_t) Ft.uw;
10182101SN/A                                }});
10195222Sksewell@umich.edu                            format CP1Unimpl {
10205222Sksewell@umich.edu                              default: unknown();
10215222Sksewell@umich.edu                            }
10222101SN/A                        }
10235222Sksewell@umich.edu                        0x5: CP1Unimpl::unknown();
10242602SN/A
10252602SN/A                        0x6: decode FUNCTION_LO {
10262603SN/A                            format FloatCompareOp {
10272686Sksewell@umich.edu                                0x0: c_f_s({{ cond = 0; }}, SinglePrecision,
10282686Sksewell@umich.edu                                           UnorderedFalse);
10292686Sksewell@umich.edu                                0x1: c_un_s({{ cond = 0; }}, SinglePrecision,
10302686Sksewell@umich.edu                                            UnorderedTrue);
10312686Sksewell@umich.edu                                0x2: c_eq_s({{ cond = (Fs.sf == Ft.sf); }},
10322686Sksewell@umich.edu                                            UnorderedFalse);
10332686Sksewell@umich.edu                                0x3: c_ueq_s({{ cond = (Fs.sf == Ft.sf); }},
10342686Sksewell@umich.edu                                             UnorderedTrue);
10352686Sksewell@umich.edu                                0x4: c_olt_s({{ cond = (Fs.sf < Ft.sf);	}},
10362686Sksewell@umich.edu                                             UnorderedFalse);
10372686Sksewell@umich.edu                                0x5: c_ult_s({{ cond = (Fs.sf < Ft.sf); }},
10382686Sksewell@umich.edu                                             UnorderedTrue);
10392686Sksewell@umich.edu                                0x6: c_ole_s({{ cond = (Fs.sf <= Ft.sf); }},
10402686Sksewell@umich.edu                                             UnorderedFalse);
10412686Sksewell@umich.edu                                0x7: c_ule_s({{ cond = (Fs.sf <= Ft.sf); }},
10422686Sksewell@umich.edu                                             UnorderedTrue);
10432602SN/A                            }
10442602SN/A                        }
10452602SN/A
10462602SN/A                        0x7: decode FUNCTION_LO {
10472686Sksewell@umich.edu                            format FloatCompareOp {
10482686Sksewell@umich.edu                                0x0: c_sf_s({{ cond = 0; }}, SinglePrecision,
10492686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
10502686Sksewell@umich.edu                                0x1: c_ngle_s({{ cond = 0; }}, SinglePrecision,
10512686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
10522686Sksewell@umich.edu                                0x2: c_seq_s({{ cond = (Fs.sf == Ft.sf);}},
10532686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
10542686Sksewell@umich.edu                                0x3: c_ngl_s({{ cond = (Fs.sf == Ft.sf); }},
10552686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
10562686Sksewell@umich.edu                                0x4: c_lt_s({{ cond = (Fs.sf < Ft.sf); }},
10572686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
10582686Sksewell@umich.edu                                0x5: c_nge_s({{ cond = (Fs.sf < Ft.sf); }},
10592686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
10602686Sksewell@umich.edu                                0x6: c_le_s({{ cond = (Fs.sf <= Ft.sf); }},
10612686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
10622686Sksewell@umich.edu                                0x7: c_ngt_s({{ cond = (Fs.sf <= Ft.sf); }},
10632686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
10642602SN/A                            }
10652602SN/A                        }
10662101SN/A                    }
10672055SN/A
10682101SN/A                    //Table A-15 MIPS32 COP1 Encoding of Function Field When rs=D
10692572SN/A                    0x1: decode FUNCTION_HI {
10702572SN/A                        0x0: decode FUNCTION_LO {
10712101SN/A                            format FloatOp {
10722686Sksewell@umich.edu                                0x0: add_d({{ Fd.df = Fs.df + Ft.df; }});
10732686Sksewell@umich.edu                                0x1: sub_d({{ Fd.df = Fs.df - Ft.df; }});
10742686Sksewell@umich.edu                                0x2: mul_d({{ Fd.df = Fs.df * Ft.df; }});
10752686Sksewell@umich.edu                                0x3: div_d({{ Fd.df = Fs.df / Ft.df; }});
10762686Sksewell@umich.edu                                0x4: sqrt_d({{ Fd.df = sqrt(Fs.df);  }});
10772686Sksewell@umich.edu                                0x5: abs_d({{ Fd.df = fabs(Fs.df);   }});
10782686Sksewell@umich.edu                                0x7: neg_d({{ Fd.df = -1 * Fs.df;    }});
10792101SN/A                            }
10802742Sksewell@umich.edu
10812742Sksewell@umich.edu                            0x6: BasicOp::mov_d({{ Fd.df = Fs.df;    }});
10822101SN/A                        }
10832027SN/A
10842572SN/A                        0x1: decode FUNCTION_LO {
10852686Sksewell@umich.edu                            format FloatConvertOp {
10862686Sksewell@umich.edu                                0x0: round_l_d({{ val = Fs.df; }}, ToLong,
10872686Sksewell@umich.edu                                               Round);
10882686Sksewell@umich.edu                                0x1: trunc_l_d({{ val = Fs.df; }}, ToLong,
10892686Sksewell@umich.edu                                               Trunc);
10902686Sksewell@umich.edu                                0x2: ceil_l_d({{ val = Fs.df; }}, ToLong,
10912686Sksewell@umich.edu                                               Ceil);
10922686Sksewell@umich.edu                                0x3: floor_l_d({{ val = Fs.df; }}, ToLong,
10932686Sksewell@umich.edu                                               Floor);
10942686Sksewell@umich.edu                                0x4: round_w_d({{ val = Fs.df; }}, ToWord,
10952686Sksewell@umich.edu                                               Round);
10962686Sksewell@umich.edu                                0x5: trunc_w_d({{ val = Fs.df; }}, ToWord,
10972686Sksewell@umich.edu                                               Trunc);
10982686Sksewell@umich.edu                                0x6: ceil_w_d({{ val = Fs.df; }}, ToWord,
10992686Sksewell@umich.edu                                               Ceil);
11002686Sksewell@umich.edu                                0x7: floor_w_d({{ val = Fs.df; }}, ToWord,
11012686Sksewell@umich.edu                                               Floor);
11022101SN/A                            }
11032101SN/A                        }
11042027SN/A
11052572SN/A                        0x2: decode FUNCTION_LO {
11062101SN/A                            0x1: decode MOVCF {
11072686Sksewell@umich.edu                                format BasicOp {
11082686Sksewell@umich.edu                                    0x0: movf_d({{ Fd.df = (getCondCode(FCSR,CC) == 0) ?
11092686Sksewell@umich.edu                                                       Fs.df : Fd.df;
11102686Sksewell@umich.edu                                                }});
11112686Sksewell@umich.edu                                    0x1: movt_d({{ Fd.df = (getCondCode(FCSR,CC) == 1) ?
11122686Sksewell@umich.edu                                                       Fs.df : Fd.df;
11132686Sksewell@umich.edu                                                }});
11142101SN/A                                }
11152101SN/A                            }
11162027SN/A
11172101SN/A                            format BasicOp {
11182686Sksewell@umich.edu                                0x2: movz_d({{ Fd.df = (Rt == 0) ? Fs.df : Fd.df; }});
11192686Sksewell@umich.edu                                0x3: movn_d({{ Fd.df = (Rt != 0) ? Fs.df : Fd.df; }});
11202101SN/A                            }
11212027SN/A
11222605SN/A                            format FloatOp {
11232686Sksewell@umich.edu                                0x5: recip_d({{ Fd.df = 1 / Fs.df }});
11242605SN/A                                0x6: rsqrt_d({{ Fd.df = 1 / sqrt(Fs.df) }});
11252101SN/A                            }
11265222Sksewell@umich.edu                            format CP1Unimpl {
11275222Sksewell@umich.edu                              default: unknown();
11285222Sksewell@umich.edu                            }
11295222Sksewell@umich.edu
11302101SN/A                        }
11312572SN/A                        0x4: decode FUNCTION_LO {
11322686Sksewell@umich.edu                            format FloatConvertOp {
11332686Sksewell@umich.edu                                0x0: cvt_s_d({{ val = Fs.df; }}, ToSingle);
11342686Sksewell@umich.edu                                0x4: cvt_w_d({{ val = Fs.df; }}, ToWord);
11352686Sksewell@umich.edu                                0x5: cvt_l_d({{ val = Fs.df; }}, ToLong);
11362101SN/A                            }
11375222Sksewell@umich.edu                           default: CP1Unimpl::unknown();
11382101SN/A                        }
11392602SN/A
11402602SN/A                        0x6: decode FUNCTION_LO {
11412604SN/A                            format FloatCompareOp {
11422686Sksewell@umich.edu                                0x0: c_f_d({{ cond = 0; }}, DoublePrecision,
11432686Sksewell@umich.edu                                           UnorderedFalse);
11442686Sksewell@umich.edu                                0x1: c_un_d({{ cond = 0; }}, DoublePrecision,
11452686Sksewell@umich.edu                                            UnorderedTrue);
11462686Sksewell@umich.edu                                0x2: c_eq_d({{ cond = (Fs.df == Ft.df); }},
11472686Sksewell@umich.edu                                            UnorderedFalse);
11482686Sksewell@umich.edu                                0x3: c_ueq_d({{ cond = (Fs.df == Ft.df); }},
11492686Sksewell@umich.edu                                             UnorderedTrue);
11502686Sksewell@umich.edu                                0x4: c_olt_d({{ cond = (Fs.df < Ft.df);	}},
11512686Sksewell@umich.edu                                             UnorderedFalse);
11522686Sksewell@umich.edu                                0x5: c_ult_d({{ cond = (Fs.df < Ft.df); }},
11532686Sksewell@umich.edu                                             UnorderedTrue);
11542686Sksewell@umich.edu                                0x6: c_ole_d({{ cond = (Fs.df <= Ft.df); }},
11552686Sksewell@umich.edu                                             UnorderedFalse);
11562686Sksewell@umich.edu                                0x7: c_ule_d({{ cond = (Fs.df <= Ft.df); }},
11572686Sksewell@umich.edu                                             UnorderedTrue);
11582602SN/A                            }
11592602SN/A                        }
11602602SN/A
11612602SN/A                        0x7: decode FUNCTION_LO {
11622686Sksewell@umich.edu                            format FloatCompareOp {
11632686Sksewell@umich.edu                                0x0: c_sf_d({{ cond = 0; }}, DoublePrecision,
11642686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
11652686Sksewell@umich.edu                                0x1: c_ngle_d({{ cond = 0; }}, DoublePrecision,
11662686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
11672686Sksewell@umich.edu                                0x2: c_seq_d({{ cond = (Fs.df == Ft.df); }},
11682686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
11692686Sksewell@umich.edu                                0x3: c_ngl_d({{ cond = (Fs.df == Ft.df); }},
11702686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
11712686Sksewell@umich.edu                                0x4: c_lt_d({{ cond = (Fs.df < Ft.df); }},
11722686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
11732686Sksewell@umich.edu                                0x5: c_nge_d({{ cond = (Fs.df < Ft.df); }},
11742686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
11752686Sksewell@umich.edu                                0x6: c_le_d({{ cond = (Fs.df <= Ft.df); }},
11762686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
11772686Sksewell@umich.edu                                0x7: c_ngt_d({{ cond = (Fs.df <= Ft.df); }},
11782686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
11792602SN/A                            }
11802602SN/A                        }
11815222Sksewell@umich.edu                       default: CP1Unimpl::unknown();
11822101SN/A                    }
11835222Sksewell@umich.edu                    0x2: CP1Unimpl::unknown();
11845222Sksewell@umich.edu                    0x3: CP1Unimpl::unknown();
11855222Sksewell@umich.edu                    0x7: CP1Unimpl::unknown();
11862027SN/A
11872101SN/A                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=W
11882101SN/A                    0x4: decode FUNCTION {
11892605SN/A                        format FloatConvertOp {
11902686Sksewell@umich.edu                            0x20: cvt_s_w({{ val = Fs.uw; }}, ToSingle);
11912686Sksewell@umich.edu                            0x21: cvt_d_w({{ val = Fs.uw; }}, ToDouble);
11925222Sksewell@umich.edu                            0x26: CP1Unimpl::cvt_ps_w();
11932101SN/A                        }
11945222Sksewell@umich.edu                       default: CP1Unimpl::unknown();
11952101SN/A                    }
11962027SN/A
11972101SN/A                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=L1
11982101SN/A                    //Note: "1. Format type L is legal only if 64-bit floating point operations
11992101SN/A                    //are enabled."
12002101SN/A                    0x5: decode FUNCTION_HI {
12012686Sksewell@umich.edu                        format FloatConvertOp {
12022686Sksewell@umich.edu                            0x20: cvt_s_l({{ val = Fs.ud; }}, ToSingle);
12032686Sksewell@umich.edu                            0x21: cvt_d_l({{ val = Fs.ud; }}, ToDouble);
12045222Sksewell@umich.edu                            0x26: CP1Unimpl::cvt_ps_l();
12052101SN/A                        }
12065222Sksewell@umich.edu                       default: CP1Unimpl::unknown();
12072101SN/A                    }
12082101SN/A
12092101SN/A                    //Table A-17 MIPS64 COP1 Encoding of Function Field When rs=PS1
12102101SN/A                    //Note: "1. Format type PS is legal only if 64-bit floating point operations
12112101SN/A                    //are enabled. "
12122572SN/A                    0x6: decode FUNCTION_HI {
12132572SN/A                        0x0: decode FUNCTION_LO {
12142101SN/A                            format Float64Op {
12152605SN/A                                0x0: add_ps({{
12162607SN/A                                    Fd1.sf = Fs1.sf + Ft2.sf;
12172607SN/A                                    Fd2.sf = Fs2.sf + Ft2.sf;
12182101SN/A                                }});
12192605SN/A                                0x1: sub_ps({{
12202607SN/A                                    Fd1.sf = Fs1.sf - Ft2.sf;
12212607SN/A                                    Fd2.sf = Fs2.sf - Ft2.sf;
12222101SN/A                                }});
12232605SN/A                                0x2: mul_ps({{
12242607SN/A                                    Fd1.sf = Fs1.sf * Ft2.sf;
12252607SN/A                                    Fd2.sf = Fs2.sf * Ft2.sf;
12262101SN/A                                }});
12272605SN/A                                0x5: abs_ps({{
12282607SN/A                                    Fd1.sf = fabs(Fs1.sf);
12292607SN/A                                    Fd2.sf = fabs(Fs2.sf);
12302101SN/A                                }});
12312605SN/A                                0x6: mov_ps({{
12322607SN/A                                    Fd1.sf = Fs1.sf;
12332607SN/A                                    Fd2.sf = Fs2.sf;
12342101SN/A                                }});
12352605SN/A                                0x7: neg_ps({{
12362686Sksewell@umich.edu                                    Fd1.sf = -(Fs1.sf);
12372686Sksewell@umich.edu                                    Fd2.sf = -(Fs2.sf);
12382101SN/A                                }});
12395222Sksewell@umich.edu                            default: CP1Unimpl::unknown();
12402101SN/A                            }
12412101SN/A                        }
12425222Sksewell@umich.edu                        0x1: CP1Unimpl::unknown();
12432572SN/A                        0x2: decode FUNCTION_LO {
12442101SN/A                            0x1: decode MOVCF {
12452101SN/A                                format Float64Op {
12462607SN/A                                    0x0: movf_ps({{
12472686Sksewell@umich.edu                                        Fd1 = (getCondCode(FCSR, CC) == 0) ?
12482686Sksewell@umich.edu                                            Fs1 : Fd1;
12492686Sksewell@umich.edu                                        Fd2 = (getCondCode(FCSR, CC+1) == 0) ?
12502686Sksewell@umich.edu                                            Fs2 : Fd2;
12512607SN/A                                    }});
12522607SN/A                                    0x1: movt_ps({{
12532686Sksewell@umich.edu                                        Fd2 = (getCondCode(FCSR, CC) == 1) ?
12542686Sksewell@umich.edu                                            Fs1 : Fd1;
12552686Sksewell@umich.edu                                        Fd2 = (getCondCode(FCSR, CC+1) == 1) ?
12562686Sksewell@umich.edu                                            Fs2 : Fd2;
12572607SN/A                                    }});
12582101SN/A                                }
12592101SN/A                            }
12602101SN/A
12612605SN/A                            format Float64Op {
12622607SN/A                                0x2: movz_ps({{
12632686Sksewell@umich.edu                                    Fd1 = (getCondCode(FCSR, CC) == 0) ?
12642686Sksewell@umich.edu                                        Fs1 : Fd1;
12652686Sksewell@umich.edu                                    Fd2 = (getCondCode(FCSR, CC) == 0) ?
12662686Sksewell@umich.edu                                        Fs2 : Fd2;
12672607SN/A                                }});
12682607SN/A                                0x3: movn_ps({{
12692686Sksewell@umich.edu                                    Fd1 = (getCondCode(FCSR, CC) == 1) ?
12702686Sksewell@umich.edu                                        Fs1 : Fd1;
12712686Sksewell@umich.edu                                    Fd2 = (getCondCode(FCSR, CC) == 1) ?
12722686Sksewell@umich.edu                                        Fs2 : Fd2;
12732607SN/A                                }});
12742135SN/A                            }
12755222Sksewell@umich.edu                           default: CP1Unimpl::unknown();
12762135SN/A
12772101SN/A                        }
12785222Sksewell@umich.edu                        0x3: CP1Unimpl::unknown();
12792572SN/A                        0x4: decode FUNCTION_LO {
12802686Sksewell@umich.edu                            0x0: FloatOp::cvt_s_pu({{ Fd.sf = Fs2.sf; }});
12815222Sksewell@umich.edu                            default: CP1Unimpl::unknown();
12822101SN/A                        }
12832101SN/A
12842572SN/A                        0x5: decode FUNCTION_LO {
12852686Sksewell@umich.edu                            0x0: FloatOp::cvt_s_pl({{ Fd.sf = Fs1.sf; }});
12862686Sksewell@umich.edu
12872101SN/A                            format Float64Op {
12882686Sksewell@umich.edu                                0x4: pll({{ Fd.ud = (uint64_t) Fs1.uw << 32 |
12892686Sksewell@umich.edu                                                    Ft1.uw;
12902686Sksewell@umich.edu                                         }});
12912686Sksewell@umich.edu                                0x5: plu({{ Fd.ud = (uint64_t) Fs1.uw << 32 |
12922686Sksewell@umich.edu                                                    Ft2.uw;
12932686Sksewell@umich.edu                                         }});
12942686Sksewell@umich.edu                                0x6: pul({{ Fd.ud = (uint64_t) Fs2.uw << 32 |
12952686Sksewell@umich.edu                                                    Ft1.uw;
12962686Sksewell@umich.edu                                         }});
12972686Sksewell@umich.edu                                0x7: puu({{ Fd.ud = (uint64_t) Fs2.uw << 32 |
12982686Sksewell@umich.edu                                                    Ft2.uw;
12992686Sksewell@umich.edu                                         }});
13002101SN/A                            }
13015222Sksewell@umich.edu                            default: CP1Unimpl::unknown();
13022101SN/A                        }
13032602SN/A
13042602SN/A                        0x6: decode FUNCTION_LO {
13052608SN/A                            format FloatPSCompareOp {
13062686Sksewell@umich.edu                                0x0: c_f_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
13072686Sksewell@umich.edu                                            UnorderedFalse);
13082686Sksewell@umich.edu                                0x1: c_un_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
13092686Sksewell@umich.edu                                             UnorderedTrue);
13102686Sksewell@umich.edu                                0x2: c_eq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13112686Sksewell@umich.edu                                             {{ cond2 = (Fs2.sf == Ft2.sf); }},
13122686Sksewell@umich.edu                                             UnorderedFalse);
13132686Sksewell@umich.edu                                0x3: c_ueq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13142686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
13152686Sksewell@umich.edu                                              UnorderedTrue);
13162686Sksewell@umich.edu                                0x4: c_olt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
13172686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
13182686Sksewell@umich.edu                                              UnorderedFalse);
13192686Sksewell@umich.edu                                0x5: c_ult_ps({{ cond1 = (Fs.sf < Ft.sf); }},
13202686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
13212686Sksewell@umich.edu                                              UnorderedTrue);
13222686Sksewell@umich.edu                                0x6: c_ole_ps({{ cond1 = (Fs.sf <= Ft.sf); }},
13232686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
13242686Sksewell@umich.edu                                              UnorderedFalse);
13252686Sksewell@umich.edu                                0x7: c_ule_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
13262686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
13272686Sksewell@umich.edu                                              UnorderedTrue);
13282602SN/A                            }
13292602SN/A                        }
13302602SN/A
13312602SN/A                        0x7: decode FUNCTION_LO {
13322686Sksewell@umich.edu                            format FloatPSCompareOp {
13332686Sksewell@umich.edu                                0x0: c_sf_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
13342686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
13352686Sksewell@umich.edu                                0x1: c_ngle_ps({{ cond1 = 0; }},
13362686Sksewell@umich.edu                                               {{ cond2 = 0; }},
13372686Sksewell@umich.edu                                               UnorderedTrue, QnanException);
13382686Sksewell@umich.edu                                0x2: c_seq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13392686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
13402686Sksewell@umich.edu                                              UnorderedFalse, QnanException);
13412686Sksewell@umich.edu                                0x3: c_ngl_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13422686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
13432686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
13442686Sksewell@umich.edu                                0x4: c_lt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
13452686Sksewell@umich.edu                                             {{ cond2 = (Fs2.sf < Ft2.sf); }},
13462686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
13472686Sksewell@umich.edu                                0x5: c_nge_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
13482686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
13492686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
13502686Sksewell@umich.edu                                0x6: c_le_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
13512686Sksewell@umich.edu                                             {{ cond2 = (Fs2.sf <= Ft2.sf); }},
13522686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
13532686Sksewell@umich.edu                                0x7: c_ngt_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
13542686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
13552686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
13562602SN/A                            }
13572602SN/A                        }
13582101SN/A                    }
13592101SN/A                }
13605222Sksewell@umich.edu               default: CP1Unimpl::unknown();
13612101SN/A            }
13622101SN/A        }
13632101SN/A
13642101SN/A        //Table A-19 MIPS32 COP2 Encoding of rs Field
13652101SN/A        0x2: decode RS_MSB {
13665222Sksewell@umich.edu            format CP2Unimpl {
13672686Sksewell@umich.edu                0x0: decode RS_HI {
13682686Sksewell@umich.edu                    0x0: decode RS_LO {
13692101SN/A                        0x0: mfc2();
13702101SN/A                        0x2: cfc2();
13712101SN/A                        0x3: mfhc2();
13722101SN/A                        0x4: mtc2();
13732101SN/A                        0x6: ctc2();
13742101SN/A                        0x7: mftc2();
13755222Sksewell@umich.edu                       default: unknown();
13762101SN/A                    }
13772101SN/A
13782686Sksewell@umich.edu                    0x1: decode ND {
13792686Sksewell@umich.edu                        0x0: decode TF {
13802101SN/A                            0x0: bc2f();
13812101SN/A                            0x1: bc2t();
13825222Sksewell@umich.edu                           default: unknown();
13832101SN/A                        }
13842101SN/A
13852686Sksewell@umich.edu                        0x1: decode TF {
13862101SN/A                            0x0: bc2fl();
13872101SN/A                            0x1: bc2tl();
13885222Sksewell@umich.edu                           default: unknown();
13892101SN/A                        }
13905222Sksewell@umich.edu                       default: unknown();
13915222Sksewell@umich.edu
13925222Sksewell@umich.edu                       }
13935222Sksewell@umich.edu              default: unknown();
13945222Sksewell@umich.edu
13955222Sksewell@umich.edu              }
13965222Sksewell@umich.edu            default: unknown();
13972101SN/A            }
13982101SN/A        }
13992101SN/A
14002101SN/A        //Table A-20 MIPS64 COP1X Encoding of Function Field 1
14012101SN/A        //Note: "COP1X instructions are legal only if 64-bit floating point
14022101SN/A        //operations are enabled."
14032101SN/A        0x3: decode FUNCTION_HI {
14042101SN/A            0x0: decode FUNCTION_LO {
14052686Sksewell@umich.edu                format LoadIndexedMemory {
14062742Sksewell@umich.edu                    0x0: lwxc1({{ Fd.uw = Mem.uw;}});
14072742Sksewell@umich.edu                    0x1: ldxc1({{ Fd.ud = Mem.ud;}});
14082750Sksewell@umich.edu                    0x5: luxc1({{ Fd.ud = Mem.ud;}},
14092742Sksewell@umich.edu                               {{ EA = (Rs + Rt) & ~7; }});
14102101SN/A                }
14112043SN/A            }
14122027SN/A
14132101SN/A            0x1: decode FUNCTION_LO {
14142686Sksewell@umich.edu                format StoreIndexedMemory {
14152742Sksewell@umich.edu                    0x0: swxc1({{ Mem.uw = Fs.uw;}});
14162742Sksewell@umich.edu                    0x1: sdxc1({{ Mem.ud = Fs.ud;}});
14172742Sksewell@umich.edu                    0x5: suxc1({{ Mem.ud = Fs.ud;}},
14182742Sksewell@umich.edu                               {{ EA = (Rs + Rt) & ~7; }});
14192046SN/A                }
14202084SN/A
14212686Sksewell@umich.edu                0x7: Prefetch::prefx({{ EA = Rs + Rt; }});
14222101SN/A            }
14232027SN/A
14242686Sksewell@umich.edu            0x3: decode FUNCTION_LO {
14252686Sksewell@umich.edu                0x6: Float64Op::alnv_ps({{ if (Rs<2:0> == 0) {
14262686Sksewell@umich.edu                                               Fd.ud = Fs.ud;
14272686Sksewell@umich.edu                                           } else if (Rs<2:0> == 4) {
14282686Sksewell@umich.edu                                             #if BYTE_ORDER == BIG_ENDIAN
14292686Sksewell@umich.edu                                               Fd.ud = Fs.ud<31:0> << 32 |
14302686Sksewell@umich.edu                                                       Ft.ud<63:32>;
14312686Sksewell@umich.edu                                             #elif BYTE_ORDER == LITTLE_ENDIAN
14322686Sksewell@umich.edu                                               Fd.ud = Ft.ud<31:0> << 32 |
14332686Sksewell@umich.edu                                                       Fs.ud<63:32>;
14342686Sksewell@umich.edu                                             #endif
14352686Sksewell@umich.edu                                           } else {
14362686Sksewell@umich.edu                                               Fd.ud = Fd.ud;
14372686Sksewell@umich.edu                                           }
14382686Sksewell@umich.edu                                        }});
14392686Sksewell@umich.edu            }
14402027SN/A
14412686Sksewell@umich.edu            format FloatAccOp {
14422686Sksewell@umich.edu                0x4: decode FUNCTION_LO {
14432686Sksewell@umich.edu                    0x0: madd_s({{ Fd.sf = (Fs.sf * Ft.sf) + Fr.sf; }});
14442686Sksewell@umich.edu                    0x1: madd_d({{ Fd.df = (Fs.df * Ft.df) + Fr.df; }});
14452686Sksewell@umich.edu                    0x6: madd_ps({{
14462686Sksewell@umich.edu                        Fd1.sf = (Fs1.df * Ft1.df) + Fr1.df;
14472686Sksewell@umich.edu                        Fd2.sf = (Fs2.df * Ft2.df) + Fr2.df;
14482686Sksewell@umich.edu                    }});
14492686Sksewell@umich.edu                }
14502027SN/A
14512686Sksewell@umich.edu                0x5: decode FUNCTION_LO {
14522686Sksewell@umich.edu                    0x0: msub_s({{ Fd.sf = (Fs.sf * Ft.sf) - Fr.sf; }});
14532686Sksewell@umich.edu                    0x1: msub_d({{ Fd.df = (Fs.df * Ft.df) - Fr.df; }});
14542686Sksewell@umich.edu                    0x6: msub_ps({{
14552686Sksewell@umich.edu                        Fd1.sf = (Fs1.df * Ft1.df) - Fr1.df;
14562686Sksewell@umich.edu                        Fd2.sf = (Fs2.df * Ft2.df) - Fr2.df;
14572686Sksewell@umich.edu                    }});
14582686Sksewell@umich.edu                }
14592027SN/A
14602686Sksewell@umich.edu                0x6: decode FUNCTION_LO {
14612686Sksewell@umich.edu                    0x0: nmadd_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }});
14622686Sksewell@umich.edu                    0x1: nmadd_d({{ Fd.df = (-1 * Fs.df * Ft.df) + Fr.df; }});
14632686Sksewell@umich.edu                    0x6: nmadd_ps({{
14642686Sksewell@umich.edu                        Fd1.sf = -((Fs1.df * Ft1.df) + Fr1.df);
14652686Sksewell@umich.edu                        Fd2.sf = -((Fs2.df * Ft2.df) + Fr2.df);
14662686Sksewell@umich.edu                    }});
14672686Sksewell@umich.edu                }
14682027SN/A
14692686Sksewell@umich.edu                0x7: decode FUNCTION_LO {
14702686Sksewell@umich.edu                    0x0: nmsub_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }});
14712686Sksewell@umich.edu                    0x1: nmsub_d({{ Fd.df = (-1 * Fs.df * Ft.df) - Fr.df; }});
14722686Sksewell@umich.edu                    0x6: nmsub_ps({{
14732686Sksewell@umich.edu                        Fd1.sf = -((Fs1.df * Ft1.df) - Fr1.df);
14742686Sksewell@umich.edu                        Fd2.sf = -((Fs2.df * Ft2.df) - Fr2.df);
14752686Sksewell@umich.edu                    }});
14762046SN/A                }
14772686Sksewell@umich.edu
14782101SN/A            }
14792043SN/A        }
14802025SN/A
14812686Sksewell@umich.edu        format Branch {
14822686Sksewell@umich.edu            0x4: beql({{ cond = (Rs.sw == Rt.sw); }}, Likely);
14832686Sksewell@umich.edu            0x5: bnel({{ cond = (Rs.sw != Rt.sw); }}, Likely);
14842686Sksewell@umich.edu            0x6: blezl({{ cond = (Rs.sw <= 0); }}, Likely);
14852686Sksewell@umich.edu            0x7: bgtzl({{ cond = (Rs.sw > 0); }}, Likely);
14862046SN/A        }
14872084SN/A    }
14882024SN/A
14892686Sksewell@umich.edu    0x3: decode OPCODE_LO {
14902043SN/A        //Table A-5 MIPS32 SPECIAL2 Encoding of Function Field
14912043SN/A        0x4: decode FUNCTION_HI {
14922686Sksewell@umich.edu            0x0: decode FUNCTION_LO {
14932686Sksewell@umich.edu                0x2: IntOp::mul({{ int64_t temp1 = Rs.sd * Rt.sd;
14944661Sksewell@umich.edu                                   Rd.sw = temp1<31:0>;
14955222Sksewell@umich.edu                                }}, IntMultOp);
14962027SN/A
14974661Sksewell@umich.edu                format HiLoRdSelValOp {
14985222Sksewell@umich.edu                  0x0: madd({{ val = ((int64_t)HI_RD_SEL << 32 | LO_RD_SEL) + (Rs.sd * Rt.sd); }}, IntMultOp);
14995222Sksewell@umich.edu                    0x1: maddu({{ val = ((uint64_t)HI_RD_SEL << 32 | LO_RD_SEL) + (Rs.ud * Rt.ud); }}, IntMultOp);
15005222Sksewell@umich.edu                    0x4: msub({{ val = ((int64_t)HI_RD_SEL << 32 | LO_RD_SEL) - (Rs.sd * Rt.sd); }}, IntMultOp);
15015222Sksewell@umich.edu                    0x5: msubu({{ val = ((uint64_t)HI_RD_SEL << 32 | LO_RD_SEL) - (Rs.ud * Rt.ud); }}, IntMultOp);
15022043SN/A                }
15032043SN/A            }
15042027SN/A
15052043SN/A            0x4: decode FUNCTION_LO {
15062101SN/A                format BasicOp {
15072686Sksewell@umich.edu                    0x0: clz({{ int cnt = 32;
15084661Sksewell@umich.edu                          for (int idx = 31; idx >= 0; idx--) {
15094661Sksewell@umich.edu                              if( Rs<idx:idx> == 1) {
15104661Sksewell@umich.edu                                  cnt = 31 - idx;
15114661Sksewell@umich.edu                                  break;
15124661Sksewell@umich.edu                              }
15134661Sksewell@umich.edu                          }
15144661Sksewell@umich.edu                          Rd.uw = cnt;
15154661Sksewell@umich.edu                       }});
15162686Sksewell@umich.edu                    0x1: clo({{ int cnt = 32;
15174661Sksewell@umich.edu                          for (int idx = 31; idx >= 0; idx--) {
15184661Sksewell@umich.edu                              if( Rs<idx:idx> == 0) {
15194661Sksewell@umich.edu                                  cnt = 31 - idx;
15204661Sksewell@umich.edu                                  break;
15214661Sksewell@umich.edu                              }
15224661Sksewell@umich.edu                          }
15234661Sksewell@umich.edu                          Rd.uw = cnt;
15244661Sksewell@umich.edu                        }});
15252101SN/A                }
15262043SN/A            }
15272027SN/A
15282043SN/A            0x7: decode FUNCTION_LO {
15292686Sksewell@umich.edu                0x7: FailUnimpl::sdbbp();
15302043SN/A            }
15312043SN/A        }
15322024SN/A
15332686Sksewell@umich.edu        //Table A-6 MIPS32 SPECIAL3 Encoding of Function Field for Release 2
15342686Sksewell@umich.edu        //of the Architecture
15352043SN/A        0x7: decode FUNCTION_HI {
15362101SN/A            0x0: decode FUNCTION_LO {
15372686Sksewell@umich.edu                format BasicOp {
15382742Sksewell@umich.edu                    0x0: ext({{ Rt.uw = bits(Rs.uw, MSB+LSB, LSB); }});
15392686Sksewell@umich.edu                    0x4: ins({{ Rt.uw = bits(Rt.uw, 31, MSB+1) << (MSB+1) |
15402686Sksewell@umich.edu                                        bits(Rs.uw, MSB-LSB, 0) << LSB |
15412686Sksewell@umich.edu                                        bits(Rt.uw, LSB-1, 0);
15422686Sksewell@umich.edu                             }});
15432046SN/A                }
15442101SN/A            }
15452026SN/A
15462101SN/A            0x1: decode FUNCTION_LO {
15474661Sksewell@umich.edu                format MT_Control {
15484661Sksewell@umich.edu                    0x0: fork({{ forkThread(xc->tcBase(), fault, RD, Rs, Rt); }},
15494661Sksewell@umich.edu                              UserMode);
15504661Sksewell@umich.edu                    0x1: yield({{ Rd.sw = yieldThread(xc->tcBase(), fault, Rs.sw, YQMask); }},
15514661Sksewell@umich.edu                               UserMode);
15524661Sksewell@umich.edu                }
15534661Sksewell@umich.edu
15544661Sksewell@umich.edu                //Table 5-9 MIPS32 LX Encoding of the op Field (DSP ASE MANUAL)
15554661Sksewell@umich.edu                0x2: decode OP_HI {
15564661Sksewell@umich.edu                    0x0: decode OP_LO {
15574661Sksewell@umich.edu                        format LoadIndexedMemory {
15584661Sksewell@umich.edu                            0x0: lwx({{ Rd.sw = Mem.sw; }});
15594661Sksewell@umich.edu                            0x4: lhx({{ Rd.sw = Mem.sh; }});
15604661Sksewell@umich.edu                            0x6: lbux({{ Rd.uw = Mem.ub; }});
15614661Sksewell@umich.edu                        }
15624661Sksewell@umich.edu                    }
15634661Sksewell@umich.edu                }
15644661Sksewell@umich.edu                0x4: DspIntOp::insv({{ int pos = dspctl<5:0>;
15654661Sksewell@umich.edu                                       int size = dspctl<12:7>-1;
15664661Sksewell@umich.edu                                       Rt.uw = insertBits( Rt.uw, pos+size, pos, Rs.uw<size:0> ); }});
15674661Sksewell@umich.edu            }
15684661Sksewell@umich.edu
15694661Sksewell@umich.edu            0x2: decode FUNCTION_LO {
15704661Sksewell@umich.edu
15714661Sksewell@umich.edu                //Table 5-5 MIPS32 ADDU.QB Encoding of the op Field (DSP ASE MANUAL)
15724661Sksewell@umich.edu                0x0: decode OP_HI {
15734661Sksewell@umich.edu                    0x0: decode OP_LO {
15744661Sksewell@umich.edu                        format DspIntOp {
15754661Sksewell@umich.edu                            0x0: addu_qb({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_QB,
15764661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
15774661Sksewell@umich.edu                            0x1: subu_qb({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_QB,
15784661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
15794661Sksewell@umich.edu                            0x4: addu_s_qb({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_QB,
15804661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
15814661Sksewell@umich.edu                            0x5: subu_s_qb({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_QB,
15824661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
15834661Sksewell@umich.edu                            0x6: muleu_s_ph_qbl({{ Rd.uw = dspMuleu( Rs.uw, Rt.uw,
15845222Sksewell@umich.edu                                                                     MODE_L, &dspctl ); }}, IntMultOp);
15854661Sksewell@umich.edu                            0x7: muleu_s_ph_qbr({{ Rd.uw = dspMuleu( Rs.uw, Rt.uw,
15865222Sksewell@umich.edu                                                                     MODE_R, &dspctl ); }}, IntMultOp);
15874661Sksewell@umich.edu                        }
15884661Sksewell@umich.edu                    }
15894661Sksewell@umich.edu                    0x1: decode OP_LO {
15904661Sksewell@umich.edu                        format DspIntOp {
15914661Sksewell@umich.edu                            0x0: addu_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
15924661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
15934661Sksewell@umich.edu                            0x1: subu_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
15944661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
15954661Sksewell@umich.edu                            0x2: addq_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
15964661Sksewell@umich.edu                                                            NOSATURATE, SIGNED, &dspctl ); }});
15974661Sksewell@umich.edu                            0x3: subq_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
15984661Sksewell@umich.edu                                                            NOSATURATE, SIGNED, &dspctl ); }});
15994661Sksewell@umich.edu                            0x4: addu_s_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
16004661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
16014661Sksewell@umich.edu                            0x5: subu_s_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
16024661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
16034661Sksewell@umich.edu                            0x6: addq_s_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
16044661Sksewell@umich.edu                                                              SATURATE, SIGNED, &dspctl ); }});
16054661Sksewell@umich.edu                            0x7: subq_s_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
16064661Sksewell@umich.edu                                                              SATURATE, SIGNED, &dspctl ); }});
16074661Sksewell@umich.edu                        }
16084661Sksewell@umich.edu                    }
16094661Sksewell@umich.edu                    0x2: decode OP_LO {
16104661Sksewell@umich.edu                        format DspIntOp {
16114661Sksewell@umich.edu                            0x0: addsc({{ int64_t dresult;
16124661Sksewell@umich.edu                                          dresult = Rs.ud + Rt.ud;
16134661Sksewell@umich.edu                                          Rd.sw = dresult<31:0>;
16144661Sksewell@umich.edu                                          dspctl = insertBits( dspctl, 13, 13,
16154661Sksewell@umich.edu                                                               dresult<32:32> ); }});
16164661Sksewell@umich.edu                            0x1: addwc({{ int64_t dresult;
16174661Sksewell@umich.edu                                          dresult = Rs.sd + Rt.sd + dspctl<13:13>;
16184661Sksewell@umich.edu                                          Rd.sw = dresult<31:0>;
16194661Sksewell@umich.edu                                          if( dresult<32:32> != dresult<31:31> )
16204661Sksewell@umich.edu                                              dspctl = insertBits( dspctl, 20, 20, 1 ); }});
16214661Sksewell@umich.edu                            0x2: modsub({{ Rd.sw = (Rs.sw == 0) ? Rt.sw<23:8> : Rs.sw - Rt.sw<7:0>; }});
16224661Sksewell@umich.edu                            0x4: raddu_w_qb({{ Rd.uw = Rs.uw<31:24> + Rs.uw<23:16> +
16234661Sksewell@umich.edu                                                   Rs.uw<15:8> + Rs.uw<7:0>; }});
16244661Sksewell@umich.edu                            0x6: addq_s_w({{ Rd.sw = dspAdd( Rs.sw, Rt.sw, SIMD_FMT_W,
16254661Sksewell@umich.edu                                                             SATURATE, SIGNED, &dspctl ); }});
16264661Sksewell@umich.edu                            0x7: subq_s_w({{ Rd.sw = dspSub( Rs.sw, Rt.sw, SIMD_FMT_W,
16274661Sksewell@umich.edu                                                             SATURATE, SIGNED, &dspctl ); }});
16284661Sksewell@umich.edu                        }
16294661Sksewell@umich.edu                    }
16304661Sksewell@umich.edu                    0x3: decode OP_LO {
16314661Sksewell@umich.edu                        format DspIntOp {
16324661Sksewell@umich.edu                            0x4: muleq_s_w_phl({{ Rd.sw = dspMuleq( Rs.sw, Rt.sw,
16335222Sksewell@umich.edu                                                                    MODE_L, &dspctl ); }}, IntMultOp);
16344661Sksewell@umich.edu                            0x5: muleq_s_w_phr({{ Rd.sw = dspMuleq( Rs.sw, Rt.sw,
16355222Sksewell@umich.edu                                                                    MODE_R, &dspctl ); }}, IntMultOp);
16364661Sksewell@umich.edu                            0x6: mulq_s_ph({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_PH,
16375222Sksewell@umich.edu                                                               SATURATE, NOROUND, &dspctl ); }}, IntMultOp);
16384661Sksewell@umich.edu                            0x7: mulq_rs_ph({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_PH,
16395222Sksewell@umich.edu                                                                SATURATE, ROUND, &dspctl ); }}, IntMultOp);
16404661Sksewell@umich.edu                        }
16414661Sksewell@umich.edu                    }
16424661Sksewell@umich.edu                }
16434661Sksewell@umich.edu
16444661Sksewell@umich.edu                //Table 5-6 MIPS32 CMPU_EQ_QB Encoding of the op Field (DSP ASE MANUAL)
16454661Sksewell@umich.edu                0x1: decode OP_HI {
16464661Sksewell@umich.edu                    0x0: decode OP_LO {
16474661Sksewell@umich.edu                        format DspIntOp {
16484661Sksewell@umich.edu                            0x0: cmpu_eq_qb({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_QB,
16494661Sksewell@umich.edu                                                       UNSIGNED, CMP_EQ, &dspctl ); }});
16504661Sksewell@umich.edu                            0x1: cmpu_lt_qb({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_QB,
16514661Sksewell@umich.edu                                                       UNSIGNED, CMP_LT, &dspctl ); }});
16524661Sksewell@umich.edu                            0x2: cmpu_le_qb({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_QB,
16534661Sksewell@umich.edu                                                       UNSIGNED, CMP_LE, &dspctl ); }});
16544661Sksewell@umich.edu                            0x3: pick_qb({{ Rd.uw = dspPick( Rs.uw, Rt.uw,
16554661Sksewell@umich.edu                                                             SIMD_FMT_QB, &dspctl ); }});
16564661Sksewell@umich.edu                            0x4: cmpgu_eq_qb({{ Rd.uw = dspCmpg( Rs.uw, Rt.uw, SIMD_FMT_QB,
16574661Sksewell@umich.edu                                                                 UNSIGNED, CMP_EQ ); }});
16584661Sksewell@umich.edu                            0x5: cmpgu_lt_qb({{ Rd.uw = dspCmpg( Rs.uw, Rt.uw, SIMD_FMT_QB,
16594661Sksewell@umich.edu                                                                 UNSIGNED, CMP_LT ); }});
16604661Sksewell@umich.edu                            0x6: cmpgu_le_qb({{ Rd.uw = dspCmpg( Rs.uw, Rt.uw, SIMD_FMT_QB,
16614661Sksewell@umich.edu                                                                 UNSIGNED, CMP_LE ); }});
16624661Sksewell@umich.edu                        }
16634661Sksewell@umich.edu                    }
16644661Sksewell@umich.edu                    0x1: decode OP_LO {
16654661Sksewell@umich.edu                        format DspIntOp {
16664661Sksewell@umich.edu                            0x0: cmp_eq_ph({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_PH,
16674661Sksewell@umich.edu                                                      SIGNED, CMP_EQ, &dspctl ); }});
16684661Sksewell@umich.edu                            0x1: cmp_lt_ph({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_PH,
16694661Sksewell@umich.edu                                                      SIGNED, CMP_LT, &dspctl ); }});
16704661Sksewell@umich.edu                            0x2: cmp_le_ph({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_PH,
16714661Sksewell@umich.edu                                                      SIGNED, CMP_LE, &dspctl ); }});
16724661Sksewell@umich.edu                            0x3: pick_ph({{ Rd.uw = dspPick( Rs.uw, Rt.uw,
16734661Sksewell@umich.edu                                                             SIMD_FMT_PH, &dspctl ); }});
16744661Sksewell@umich.edu                            0x4: precrq_qb_ph({{ Rd.uw = Rs.uw<31:24> << 24 |
16754661Sksewell@umich.edu                                                         Rs.uw<15:8> << 16 |
16764661Sksewell@umich.edu                                                         Rt.uw<31:24> << 8 |
16774661Sksewell@umich.edu                                                         Rt.uw<15:8>; }});
16784661Sksewell@umich.edu                            0x5: precr_qb_ph({{ Rd.uw = Rs.uw<23:16> << 24 |
16794661Sksewell@umich.edu                                                         Rs.uw<7:0> << 16 |
16804661Sksewell@umich.edu                                                         Rt.uw<23:16> << 8 |
16814661Sksewell@umich.edu                                                         Rt.uw<7:0>; }});
16824661Sksewell@umich.edu                            0x6: packrl_ph({{ Rd.uw = dspPack( Rs.uw, Rt.uw,
16834661Sksewell@umich.edu                                                               SIMD_FMT_PH ); }});
16844661Sksewell@umich.edu                            0x7: precrqu_s_qb_ph({{ Rd.uw = dspPrecrqu( Rs.uw, Rt.uw, &dspctl ); }});
16854661Sksewell@umich.edu                        }
16864661Sksewell@umich.edu                    }
16874661Sksewell@umich.edu                    0x2: decode OP_LO {
16884661Sksewell@umich.edu                        format DspIntOp {
16894661Sksewell@umich.edu                            0x4: precrq_ph_w({{ Rd.uw = Rs.uw<31:16> << 16 | Rt.uw<31:16>; }});
16904661Sksewell@umich.edu                            0x5: precrq_rs_ph_w({{ Rd.uw = dspPrecrq( Rs.uw, Rt.uw, SIMD_FMT_W, &dspctl ); }});
16914661Sksewell@umich.edu                        }
16924661Sksewell@umich.edu                    }
16934661Sksewell@umich.edu                    0x3: decode OP_LO {
16944661Sksewell@umich.edu                        format DspIntOp {
16954661Sksewell@umich.edu                            0x0: cmpgdu_eq_qb({{ Rd.uw = dspCmpgd( Rs.uw, Rt.uw, SIMD_FMT_QB,
16964661Sksewell@umich.edu                                                                   UNSIGNED, CMP_EQ, &dspctl ); }});
16974661Sksewell@umich.edu                            0x1: cmpgdu_lt_qb({{ Rd.uw = dspCmpgd( Rs.uw, Rt.uw, SIMD_FMT_QB,
16984661Sksewell@umich.edu                                                                   UNSIGNED, CMP_LT, &dspctl  ); }});
16994661Sksewell@umich.edu                            0x2: cmpgdu_le_qb({{ Rd.uw = dspCmpgd( Rs.uw, Rt.uw, SIMD_FMT_QB,
17004661Sksewell@umich.edu                                                                   UNSIGNED, CMP_LE, &dspctl ); }});
17014661Sksewell@umich.edu                            0x6: precr_sra_ph_w({{ Rt.uw = dspPrecrSra( Rt.uw, Rs.uw, RD,
17024661Sksewell@umich.edu                                                                        SIMD_FMT_W, NOROUND ); }});
17034661Sksewell@umich.edu                            0x7: precr_sra_r_ph_w({{ Rt.uw = dspPrecrSra( Rt.uw, Rs.uw, RD,
17044661Sksewell@umich.edu                                                                        SIMD_FMT_W, ROUND ); }});
17054661Sksewell@umich.edu                        }
17064661Sksewell@umich.edu                    }
17074661Sksewell@umich.edu                }
17084661Sksewell@umich.edu
17094661Sksewell@umich.edu                //Table 5-7 MIPS32 ABSQ_S.PH Encoding of the op Field (DSP ASE MANUAL)
17104661Sksewell@umich.edu                0x2: decode OP_HI {
17114661Sksewell@umich.edu                    0x0: decode OP_LO {
17124661Sksewell@umich.edu                        format DspIntOp {
17134661Sksewell@umich.edu                            0x1: absq_s_qb({{ Rd.sw = dspAbs( Rt.sw, SIMD_FMT_QB, &dspctl );}});
17144661Sksewell@umich.edu                            0x2: repl_qb({{ Rd.uw = RS_RT<7:0> << 24 |
17154661Sksewell@umich.edu                                                    RS_RT<7:0> << 16 |
17164661Sksewell@umich.edu                                                    RS_RT<7:0> << 8 |
17174661Sksewell@umich.edu                                                    RS_RT<7:0>; }});
17184661Sksewell@umich.edu                            0x3: replv_qb({{ Rd.sw = Rt.uw<7:0> << 24 |
17194661Sksewell@umich.edu                                                     Rt.uw<7:0> << 16 |
17204661Sksewell@umich.edu                                                     Rt.uw<7:0> << 8 |
17214661Sksewell@umich.edu                                                     Rt.uw<7:0>; }});
17224661Sksewell@umich.edu                            0x4: precequ_ph_qbl({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17234661Sksewell@umich.edu                                                                     SIMD_FMT_PH, SIGNED, MODE_L ); }});
17244661Sksewell@umich.edu                            0x5: precequ_ph_qbr({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17254661Sksewell@umich.edu                                                                     SIMD_FMT_PH, SIGNED, MODE_R ); }});
17264661Sksewell@umich.edu                            0x6: precequ_ph_qbla({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17274661Sksewell@umich.edu                                                                      SIMD_FMT_PH, SIGNED, MODE_LA ); }});
17284661Sksewell@umich.edu                            0x7: precequ_ph_qbra({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17294661Sksewell@umich.edu                                                                      SIMD_FMT_PH, SIGNED, MODE_RA ); }});
17304661Sksewell@umich.edu                        }
17314661Sksewell@umich.edu                    }
17324661Sksewell@umich.edu                    0x1: decode OP_LO {
17334661Sksewell@umich.edu                        format DspIntOp {
17344661Sksewell@umich.edu                            0x1: absq_s_ph({{ Rd.sw = dspAbs( Rt.sw, SIMD_FMT_PH, &dspctl ); }});
17354661Sksewell@umich.edu                            0x2: repl_ph({{ Rd.uw = (sext<10>(RS_RT))<15:0> << 16 |
17364661Sksewell@umich.edu                                                    (sext<10>(RS_RT))<15:0>; }});
17374661Sksewell@umich.edu                            0x3: replv_ph({{ Rd.uw = Rt.uw<15:0> << 16 |
17384661Sksewell@umich.edu                                                     Rt.uw<15:0>; }});
17394661Sksewell@umich.edu                            0x4: preceq_w_phl({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_PH, SIGNED,
17404661Sksewell@umich.edu                                                                   SIMD_FMT_W, SIGNED, MODE_L ); }});
17414661Sksewell@umich.edu                            0x5: preceq_w_phr({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_PH, SIGNED,
17424661Sksewell@umich.edu                                                                   SIMD_FMT_W, SIGNED, MODE_R ); }});
17434661Sksewell@umich.edu                        }
17444661Sksewell@umich.edu                    }
17454661Sksewell@umich.edu                    0x2: decode OP_LO {
17464661Sksewell@umich.edu                        format DspIntOp {
17474661Sksewell@umich.edu                            0x1: absq_s_w({{ Rd.sw = dspAbs( Rt.sw, SIMD_FMT_W, &dspctl ); }});
17484661Sksewell@umich.edu                        }
17494661Sksewell@umich.edu                    }
17504661Sksewell@umich.edu                    0x3: decode OP_LO {
17514661Sksewell@umich.edu                        0x3: IntOp::bitrev({{ Rd.uw = bitrev( Rt.uw<15:0> ); }});
17524661Sksewell@umich.edu                        format DspIntOp {
17534661Sksewell@umich.edu                            0x4: preceu_ph_qbl({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17544661Sksewell@umich.edu                                                                    SIMD_FMT_PH, UNSIGNED, MODE_L ); }});
17554661Sksewell@umich.edu                            0x5: preceu_ph_qbr({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17564661Sksewell@umich.edu                                                                    SIMD_FMT_PH, UNSIGNED, MODE_R ); }});
17574661Sksewell@umich.edu                            0x6: preceu_ph_qbla({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17584661Sksewell@umich.edu                                                                     SIMD_FMT_PH, UNSIGNED, MODE_LA ); }});
17594661Sksewell@umich.edu                            0x7: preceu_ph_qbra({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17604661Sksewell@umich.edu                                                                     SIMD_FMT_PH, UNSIGNED, MODE_RA ); }});
17614661Sksewell@umich.edu                        }
17624661Sksewell@umich.edu                    }
17634661Sksewell@umich.edu                }
17644661Sksewell@umich.edu
17654661Sksewell@umich.edu                //Table 5-8 MIPS32 SHLL.QB Encoding of the op Field (DSP ASE MANUAL)
17664661Sksewell@umich.edu                0x3: decode OP_HI {
17674661Sksewell@umich.edu                    0x0: decode OP_LO {
17684661Sksewell@umich.edu                        format DspIntOp {
17694661Sksewell@umich.edu                            0x0: shll_qb({{ Rd.sw = dspShll( Rt.sw, RS, SIMD_FMT_QB,
17704661Sksewell@umich.edu                                                             NOSATURATE, UNSIGNED, &dspctl ); }});
17714661Sksewell@umich.edu                            0x1: shrl_qb({{ Rd.sw = dspShrl( Rt.sw, RS, SIMD_FMT_QB,
17724661Sksewell@umich.edu                                                             UNSIGNED ); }});
17734661Sksewell@umich.edu                            0x2: shllv_qb({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_QB,
17744661Sksewell@umich.edu                                                              NOSATURATE, UNSIGNED, &dspctl ); }});
17754661Sksewell@umich.edu                            0x3: shrlv_qb({{ Rd.sw = dspShrl( Rt.sw, Rs.sw, SIMD_FMT_QB,
17764661Sksewell@umich.edu                                                              UNSIGNED ); }});
17774661Sksewell@umich.edu                            0x4: shra_qb({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_QB,
17784661Sksewell@umich.edu                                                             NOROUND, SIGNED, &dspctl ); }});
17794661Sksewell@umich.edu                            0x5: shra_r_qb({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_QB,
17804661Sksewell@umich.edu                                                               ROUND, SIGNED, &dspctl ); }});
17814661Sksewell@umich.edu                            0x6: shrav_qb({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_QB,
17824661Sksewell@umich.edu                                                              NOROUND, SIGNED, &dspctl ); }});
17834661Sksewell@umich.edu                            0x7: shrav_r_qb({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_QB,
17844661Sksewell@umich.edu                                                                ROUND, SIGNED, &dspctl ); }});
17854661Sksewell@umich.edu                        }
17864661Sksewell@umich.edu                    }
17874661Sksewell@umich.edu                    0x1: decode OP_LO {
17884661Sksewell@umich.edu                        format DspIntOp {
17894661Sksewell@umich.edu                            0x0: shll_ph({{ Rd.uw = dspShll( Rt.uw, RS, SIMD_FMT_PH,
17904661Sksewell@umich.edu                                                             NOSATURATE, SIGNED, &dspctl ); }});
17914661Sksewell@umich.edu                            0x1: shra_ph({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_PH,
17924661Sksewell@umich.edu                                                             NOROUND, SIGNED, &dspctl ); }});
17934661Sksewell@umich.edu                            0x2: shllv_ph({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_PH,
17944661Sksewell@umich.edu                                                              NOSATURATE, SIGNED, &dspctl ); }});
17954661Sksewell@umich.edu                            0x3: shrav_ph({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_PH,
17964661Sksewell@umich.edu                                                              NOROUND, SIGNED, &dspctl ); }});
17974661Sksewell@umich.edu                            0x4: shll_s_ph({{ Rd.sw = dspShll( Rt.sw, RS, SIMD_FMT_PH,
17984661Sksewell@umich.edu                                                               SATURATE, SIGNED, &dspctl ); }});
17994661Sksewell@umich.edu                            0x5: shra_r_ph({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_PH,
18004661Sksewell@umich.edu                                                               ROUND, SIGNED, &dspctl ); }});
18014661Sksewell@umich.edu                            0x6: shllv_s_ph({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_PH,
18024661Sksewell@umich.edu                                                                SATURATE, SIGNED, &dspctl ); }});
18034661Sksewell@umich.edu                            0x7: shrav_r_ph({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_PH,
18044661Sksewell@umich.edu                                                                ROUND, SIGNED, &dspctl ); }});
18054661Sksewell@umich.edu                        }
18064661Sksewell@umich.edu                    }
18074661Sksewell@umich.edu                    0x2: decode OP_LO {
18084661Sksewell@umich.edu                        format DspIntOp {
18094661Sksewell@umich.edu                            0x4: shll_s_w({{ Rd.sw = dspShll( Rt.sw, RS, SIMD_FMT_W,
18104661Sksewell@umich.edu                                                              SATURATE, SIGNED, &dspctl ); }});
18114661Sksewell@umich.edu                            0x5: shra_r_w({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_W,
18124661Sksewell@umich.edu                                                              ROUND, SIGNED, &dspctl ); }});
18134661Sksewell@umich.edu                            0x6: shllv_s_w({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_W,
18144661Sksewell@umich.edu                                                               SATURATE, SIGNED, &dspctl ); }});
18154661Sksewell@umich.edu                            0x7: shrav_r_w({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_W,
18164661Sksewell@umich.edu                                                               ROUND, SIGNED, &dspctl ); }});
18174661Sksewell@umich.edu                        }
18184661Sksewell@umich.edu                    }
18194661Sksewell@umich.edu                    0x3: decode OP_LO {
18204661Sksewell@umich.edu                        format DspIntOp {
18214661Sksewell@umich.edu                            0x1: shrl_ph({{ Rd.sw = dspShrl( Rt.sw, RS, SIMD_FMT_PH,
18224661Sksewell@umich.edu                                                             UNSIGNED ); }});
18234661Sksewell@umich.edu                            0x3: shrlv_ph({{ Rd.sw = dspShrl( Rt.sw, Rs.sw, SIMD_FMT_PH,
18244661Sksewell@umich.edu                                                              UNSIGNED ); }});
18254661Sksewell@umich.edu                        }
18264661Sksewell@umich.edu                    }
18274661Sksewell@umich.edu                }
18284661Sksewell@umich.edu            }
18294661Sksewell@umich.edu
18304661Sksewell@umich.edu            0x3: decode FUNCTION_LO {
18314661Sksewell@umich.edu
18324661Sksewell@umich.edu                //Table 3.12 MIPS32 ADDUH.QB Encoding of the op Field (DSP ASE Rev2 Manual)
18334661Sksewell@umich.edu                0x0: decode OP_HI {
18344661Sksewell@umich.edu                    0x0: decode OP_LO {
18354661Sksewell@umich.edu                        format DspIntOp {
18364661Sksewell@umich.edu                            0x0: adduh_qb({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18374661Sksewell@umich.edu                                                              NOROUND, UNSIGNED ); }});
18384661Sksewell@umich.edu                            0x1: subuh_qb({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18394661Sksewell@umich.edu                                                              NOROUND, UNSIGNED ); }});
18404661Sksewell@umich.edu                            0x2: adduh_r_qb({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18414661Sksewell@umich.edu                                                                ROUND, UNSIGNED ); }});
18424661Sksewell@umich.edu                            0x3: subuh_r_qb({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18434661Sksewell@umich.edu                                                                ROUND, UNSIGNED ); }});
18444661Sksewell@umich.edu                        }
18454661Sksewell@umich.edu                    }
18464661Sksewell@umich.edu                    0x1: decode OP_LO {
18474661Sksewell@umich.edu                        format DspIntOp {
18484661Sksewell@umich.edu                            0x0: addqh_ph({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_PH,
18494661Sksewell@umich.edu                                                              NOROUND, SIGNED ); }});
18504661Sksewell@umich.edu                            0x1: subqh_ph({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_PH,
18514661Sksewell@umich.edu                                                              NOROUND, SIGNED ); }});
18524661Sksewell@umich.edu                            0x2: addqh_r_ph({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_PH,
18534661Sksewell@umich.edu                                                                ROUND, SIGNED ); }});
18544661Sksewell@umich.edu                            0x3: subqh_r_ph({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_PH,
18554661Sksewell@umich.edu                                                                ROUND, SIGNED ); }});
18564661Sksewell@umich.edu                            0x4: mul_ph({{ Rd.sw = dspMul( Rs.sw, Rt.sw, SIMD_FMT_PH,
18575222Sksewell@umich.edu                                                           NOSATURATE, &dspctl ); }}, IntMultOp);
18584661Sksewell@umich.edu                            0x6: mul_s_ph({{ Rd.sw = dspMul( Rs.sw, Rt.sw, SIMD_FMT_PH,
18595222Sksewell@umich.edu                                                             SATURATE, &dspctl ); }}, IntMultOp);
18605222Sksewell@umich.edu
18614661Sksewell@umich.edu                        }
18624661Sksewell@umich.edu                    }
18634661Sksewell@umich.edu                    0x2: decode OP_LO {
18644661Sksewell@umich.edu                        format DspIntOp {
18654661Sksewell@umich.edu                            0x0: addqh_w({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_W,
18664661Sksewell@umich.edu                                                             NOROUND, SIGNED ); }});
18674661Sksewell@umich.edu                            0x1: subqh_w({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_W,
18684661Sksewell@umich.edu                                                             NOROUND, SIGNED ); }});
18694661Sksewell@umich.edu                            0x2: addqh_r_w({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_W,
18704661Sksewell@umich.edu                                                               ROUND, SIGNED ); }});
18714661Sksewell@umich.edu                            0x3: subqh_r_w({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_W,
18724661Sksewell@umich.edu                                                               ROUND, SIGNED ); }});
18734661Sksewell@umich.edu                            0x6: mulq_s_w({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_W,
18745222Sksewell@umich.edu                                                              SATURATE, NOROUND, &dspctl ); }}, IntMultOp);
18754661Sksewell@umich.edu                            0x7: mulq_rs_w({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_W,
18765222Sksewell@umich.edu                                                               SATURATE, ROUND, &dspctl ); }}, IntMultOp);
18774661Sksewell@umich.edu                        }
18784661Sksewell@umich.edu                    }
18792061SN/A                }
18802101SN/A            }
18812061SN/A
18822101SN/A            //Table A-10 MIPS32 BSHFL Encoding of sa Field
18832101SN/A            0x4: decode SA {
18842046SN/A                format BasicOp {
18852686Sksewell@umich.edu                    0x02: wsbh({{ Rd.uw = Rt.uw<23:16> << 24 |
18864661Sksewell@umich.edu                                      Rt.uw<31:24> << 16 |
18874661Sksewell@umich.edu                                      Rt.uw<7:0>   << 8  |
18884661Sksewell@umich.edu                                      Rt.uw<15:8>;
18892686Sksewell@umich.edu                    }});
18902742Sksewell@umich.edu                    0x10: seb({{ Rd.sw = Rt.sb; }});
18912742Sksewell@umich.edu                    0x18: seh({{ Rd.sw = Rt.sh; }});
18922046SN/A                }
18932101SN/A            }
18942043SN/A
18952101SN/A            0x6: decode FUNCTION_LO {
18964661Sksewell@umich.edu
18974661Sksewell@umich.edu                //Table 5-10 MIPS32 DPAQ.W.PH Encoding of the op Field (DSP ASE MANUAL)
18984661Sksewell@umich.edu                0x0: decode OP_HI {
18994661Sksewell@umich.edu                    0x0: decode OP_LO {
19004661Sksewell@umich.edu                        format DspHiLoOp {
19014661Sksewell@umich.edu                            0x0: dpa_w_ph({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19025222Sksewell@umich.edu                                                             SIMD_FMT_PH, SIGNED, MODE_L ); }}, IntMultOp);
19034661Sksewell@umich.edu                            0x1: dps_w_ph({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19045222Sksewell@umich.edu                                                             SIMD_FMT_PH, SIGNED, MODE_L ); }}, IntMultOp);
19054661Sksewell@umich.edu                            0x2: mulsa_w_ph({{ dspac = dspMulsa( dspac, Rs.sw, Rt.sw,
19065222Sksewell@umich.edu                                                                 ACDST, SIMD_FMT_PH ); }}, IntMultOp);
19074661Sksewell@umich.edu                            0x3: dpau_h_qbl({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19085222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_L ); }}, IntMultOp);
19094661Sksewell@umich.edu                            0x4: dpaq_s_w_ph({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19105222Sksewell@umich.edu                                                                 SIMD_FMT_W, NOSATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19114661Sksewell@umich.edu                            0x5: dpsq_s_w_ph({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19125222Sksewell@umich.edu                                                                 SIMD_FMT_W, NOSATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19134661Sksewell@umich.edu                            0x6: mulsaq_s_w_ph({{ dspac = dspMulsaq( dspac, Rs.sw, Rt.sw,
19145222Sksewell@umich.edu                                                                     ACDST, SIMD_FMT_PH, &dspctl ); }}, IntMultOp);
19154661Sksewell@umich.edu                            0x7: dpau_h_qbr({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19165222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_R ); }}, IntMultOp);
19174661Sksewell@umich.edu                        }
19184661Sksewell@umich.edu                    }
19194661Sksewell@umich.edu                    0x1: decode OP_LO {
19204661Sksewell@umich.edu                        format DspHiLoOp {
19214661Sksewell@umich.edu                            0x0: dpax_w_ph({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19225222Sksewell@umich.edu                                                              SIMD_FMT_PH, SIGNED, MODE_X ); }}, IntMultOp);
19234661Sksewell@umich.edu                            0x1: dpsx_w_ph({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19245222Sksewell@umich.edu                                                              SIMD_FMT_PH, SIGNED, MODE_X ); }}, IntMultOp);
19254661Sksewell@umich.edu                            0x3: dpsu_h_qbl({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19265222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_L ); }}, IntMultOp);
19274661Sksewell@umich.edu                            0x4: dpaq_sa_l_w({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_W,
19285222Sksewell@umich.edu                                                                 SIMD_FMT_L, SATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19294661Sksewell@umich.edu                            0x5: dpsq_sa_l_w({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_W,
19305222Sksewell@umich.edu                                                                 SIMD_FMT_L, SATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19314661Sksewell@umich.edu                            0x7: dpsu_h_qbr({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19325222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_R ); }}, IntMultOp);
19334661Sksewell@umich.edu                        }
19344661Sksewell@umich.edu                    }
19354661Sksewell@umich.edu                    0x2: decode OP_LO {
19364661Sksewell@umich.edu                        format DspHiLoOp {
19374661Sksewell@umich.edu                            0x0: maq_sa_w_phl({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19385222Sksewell@umich.edu                                                                 MODE_L, SATURATE, &dspctl ); }}, IntMultOp);
19394661Sksewell@umich.edu                            0x2: maq_sa_w_phr({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19405222Sksewell@umich.edu                                                                 MODE_R, SATURATE, &dspctl ); }}, IntMultOp);
19414661Sksewell@umich.edu                            0x4: maq_s_w_phl({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19425222Sksewell@umich.edu                                                                 MODE_L, NOSATURATE, &dspctl ); }}, IntMultOp);
19434661Sksewell@umich.edu                            0x6: maq_s_w_phr({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19445222Sksewell@umich.edu                                                                 MODE_R, NOSATURATE, &dspctl ); }}, IntMultOp);
19454661Sksewell@umich.edu                        }
19464661Sksewell@umich.edu                    }
19474661Sksewell@umich.edu                    0x3: decode OP_LO {
19484661Sksewell@umich.edu                        format DspHiLoOp {
19494661Sksewell@umich.edu                            0x0: dpaqx_s_w_ph({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19505222Sksewell@umich.edu                                                                  SIMD_FMT_W, NOSATURATE, MODE_X, &dspctl ); }}, IntMultOp);
19514661Sksewell@umich.edu                            0x1: dpsqx_s_w_ph({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19525222Sksewell@umich.edu                                                                  SIMD_FMT_W, NOSATURATE, MODE_X, &dspctl ); }}, IntMultOp);
19534661Sksewell@umich.edu                            0x2: dpaqx_sa_w_ph({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19545222Sksewell@umich.edu                                                                   SIMD_FMT_W, SATURATE, MODE_X, &dspctl ); }}, IntMultOp);
19554661Sksewell@umich.edu                            0x3: dpsqx_sa_w_ph({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19565222Sksewell@umich.edu                                                                   SIMD_FMT_W, SATURATE, MODE_X, &dspctl ); }}, IntMultOp);
19574661Sksewell@umich.edu                        }
19584661Sksewell@umich.edu                    }
19594661Sksewell@umich.edu                }
19604661Sksewell@umich.edu
19614661Sksewell@umich.edu                //Table 3.3 MIPS32 APPEND Encoding of the op Field
19624661Sksewell@umich.edu                0x1: decode OP_HI {
19634661Sksewell@umich.edu                    0x0: decode OP_LO {
19644661Sksewell@umich.edu                        format IntOp {
19654661Sksewell@umich.edu                            0x0: append({{ Rt.uw = (Rt.uw << RD) | bits(Rs.uw,RD-1,0); }});
19664661Sksewell@umich.edu                            0x1: prepend({{ Rt.uw = (Rt.uw >> RD) | (bits(Rs.uw,RD-1,0) << 32-RD); }});
19674661Sksewell@umich.edu                        }
19684661Sksewell@umich.edu                    }
19694661Sksewell@umich.edu                    0x2: decode OP_LO {
19704661Sksewell@umich.edu                        format IntOp {
19714661Sksewell@umich.edu                            0x0: balign({{ Rt.uw = (Rt.uw << (8*BP)) | (Rs.uw >> (8*(4-BP))); }});
19724661Sksewell@umich.edu                        }
19734661Sksewell@umich.edu                    }
19744661Sksewell@umich.edu                }
19754661Sksewell@umich.edu
19762101SN/A            }
19774661Sksewell@umich.edu            0x7: decode FUNCTION_LO {
19784661Sksewell@umich.edu
19794661Sksewell@umich.edu                //Table 5-11 MIPS32 EXTR.W Encoding of the op Field (DSP ASE MANUAL)
19804661Sksewell@umich.edu                0x0: decode OP_HI {
19814661Sksewell@umich.edu                    0x0: decode OP_LO {
19824661Sksewell@umich.edu                        format DspHiLoOp {
19834661Sksewell@umich.edu                            0x0: extr_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, RS,
19844661Sksewell@umich.edu                                                            NOROUND, NOSATURATE, &dspctl ); }});
19854661Sksewell@umich.edu                            0x1: extrv_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, Rs.uw,
19864661Sksewell@umich.edu                                                             NOROUND, NOSATURATE, &dspctl ); }});
19874661Sksewell@umich.edu                            0x2: extp({{ Rt.uw = dspExtp( dspac, RS, &dspctl ); }});
19884661Sksewell@umich.edu                            0x3: extpv({{ Rt.uw = dspExtp( dspac, Rs.uw, &dspctl ); }});
19894661Sksewell@umich.edu                            0x4: extr_r_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, RS,
19904661Sksewell@umich.edu                                                              ROUND, NOSATURATE, &dspctl ); }});
19914661Sksewell@umich.edu                            0x5: extrv_r_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, Rs.uw,
19924661Sksewell@umich.edu                                                               ROUND, NOSATURATE, &dspctl ); }});
19934661Sksewell@umich.edu                            0x6: extr_rs_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, RS,
19944661Sksewell@umich.edu                                                               ROUND, SATURATE, &dspctl ); }});
19954661Sksewell@umich.edu                            0x7: extrv_rs_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, Rs.uw,
19964661Sksewell@umich.edu                                                                ROUND, SATURATE, &dspctl ); }});
19974661Sksewell@umich.edu                        }
19984661Sksewell@umich.edu                    }
19994661Sksewell@umich.edu                    0x1: decode OP_LO {
20004661Sksewell@umich.edu                        format DspHiLoOp {
20014661Sksewell@umich.edu                            0x2: extpdp({{ Rt.uw = dspExtpd( dspac, RS, &dspctl ); }});
20024661Sksewell@umich.edu                            0x3: extpdpv({{ Rt.uw = dspExtpd( dspac, Rs.uw, &dspctl ); }});
20034661Sksewell@umich.edu                            0x6: extr_s_h({{ Rt.uw = dspExtr( dspac, SIMD_FMT_PH, RS,
20044661Sksewell@umich.edu                                                              NOROUND, SATURATE, &dspctl ); }});
20054661Sksewell@umich.edu                            0x7: extrv_s_h({{ Rt.uw = dspExtr( dspac, SIMD_FMT_PH, Rs.uw,
20064661Sksewell@umich.edu                                                               NOROUND, SATURATE, &dspctl ); }});
20074661Sksewell@umich.edu                        }
20084661Sksewell@umich.edu                    }
20094661Sksewell@umich.edu                    0x2: decode OP_LO {
20104661Sksewell@umich.edu                        format DspIntOp {
20114661Sksewell@umich.edu                            0x2: rddsp({{ Rd.uw = readDSPControl( &dspctl, RDDSPMASK ); }});
20124661Sksewell@umich.edu                            0x3: wrdsp({{ writeDSPControl( &dspctl, Rs.uw, WRDSPMASK ); }});
20134661Sksewell@umich.edu                        }
20144661Sksewell@umich.edu                    }
20154661Sksewell@umich.edu                    0x3: decode OP_LO {
20164661Sksewell@umich.edu                        format DspHiLoOp {
20174661Sksewell@umich.edu                            0x2: shilo({{ if( sext<6>(HILOSA) < 0 )
20184661Sksewell@umich.edu                                              dspac = (uint64_t)dspac << -sext<6>(HILOSA);
20194661Sksewell@umich.edu                                          else
20204661Sksewell@umich.edu                                              dspac = (uint64_t)dspac >> sext<6>(HILOSA); }});
20214661Sksewell@umich.edu                            0x3: shilov({{ if( sext<6>(Rs.sw<5:0>) < 0 )
20224661Sksewell@umich.edu                                              dspac = (uint64_t)dspac << -sext<6>(Rs.sw<5:0>);
20234661Sksewell@umich.edu                                           else
20244661Sksewell@umich.edu                                              dspac = (uint64_t)dspac >> sext<6>(Rs.sw<5:0>); }});
20254661Sksewell@umich.edu                            0x7: mthlip({{ dspac = dspac << 32;
20264661Sksewell@umich.edu                                           dspac |= Rs.uw;
20274661Sksewell@umich.edu                                           dspctl = insertBits( dspctl, 5, 0,
20284661Sksewell@umich.edu                                                                dspctl<5:0>+32 ); }});
20294661Sksewell@umich.edu                        }
20304661Sksewell@umich.edu                    }
20314661Sksewell@umich.edu                }
20325222Sksewell@umich.edu                0x3: decode OP_HI {
20335222Sksewell@umich.edu                    0x2: decode OP_LO {
20345222Sksewell@umich.edu                        0x3: FailUnimpl::rdhwr();
20355222Sksewell@umich.edu                    }
20365222Sksewell@umich.edu                }
20374661Sksewell@umich.edu            }
20382043SN/A        }
20392084SN/A    }
20402024SN/A
20412686Sksewell@umich.edu    0x4: decode OPCODE_LO {
20422124SN/A        format LoadMemory {
20435222Sksewell@umich.edu          0x0: lb({{ Rt.sw = Mem.sb; }}, mem_flags = NO_ALIGN_FAULT);
20445222Sksewell@umich.edu          0x1: lh({{ Rt.sw = Mem.sh; }}, mem_flags = NO_HALF_WORD_ALIGN_FAULT);
20452479SN/A            0x3: lw({{ Rt.sw = Mem.sw; }});
20465222Sksewell@umich.edu            0x4: lbu({{ Rt.uw = Mem.ub;}}, mem_flags = NO_ALIGN_FAULT);
20475222Sksewell@umich.edu            0x5: lhu({{ Rt.uw = Mem.uh; }}, mem_flags = NO_HALF_WORD_ALIGN_FAULT);
20482686Sksewell@umich.edu        }
20492495SN/A
20502686Sksewell@umich.edu        format LoadUnalignedMemory {
20512686Sksewell@umich.edu            0x2: lwl({{ uint32_t mem_shift = 24 - (8 * byte_offset);
20522686Sksewell@umich.edu                        Rt.uw = mem_word << mem_shift |
20535222Sksewell@umich.edu                        Rt.uw & mask(mem_shift);
20542686Sksewell@umich.edu                     }});
20552686Sksewell@umich.edu            0x6: lwr({{ uint32_t mem_shift = 8 * byte_offset;
20562686Sksewell@umich.edu                        Rt.uw = Rt.uw & (mask(mem_shift) << (32 - mem_shift)) |
20575222Sksewell@umich.edu                        mem_word >> mem_shift;
20582686Sksewell@umich.edu                     }});
20594661Sksewell@umich.edu      }
20602084SN/A    }
20612024SN/A
20622686Sksewell@umich.edu    0x5: decode OPCODE_LO {
20632124SN/A        format StoreMemory {
20645222Sksewell@umich.edu            0x0: sb({{ Mem.ub = Rt<7:0>; }}, mem_flags = NO_ALIGN_FAULT);
20655222Sksewell@umich.edu            0x1: sh({{ Mem.uh = Rt<15:0>; }}, mem_flags = NO_HALF_WORD_ALIGN_FAULT);
20662479SN/A            0x3: sw({{ Mem.uw = Rt<31:0>; }});
20672084SN/A        }
20682024SN/A
20692686Sksewell@umich.edu        format StoreUnalignedMemory {
20702686Sksewell@umich.edu            0x2: swl({{ uint32_t reg_shift = 24 - (8 * byte_offset);
20712686Sksewell@umich.edu                        uint32_t mem_shift = 32 - reg_shift;
20722686Sksewell@umich.edu                        mem_word = mem_word & (mask(reg_shift) << mem_shift) |
20732686Sksewell@umich.edu                                   Rt.uw >> reg_shift;
20742686Sksewell@umich.edu                     }});
20752686Sksewell@umich.edu            0x6: swr({{ uint32_t reg_shift = 8 * byte_offset;
20762686Sksewell@umich.edu                        mem_word = Rt.uw << reg_shift |
20772686Sksewell@umich.edu                                   mem_word & (mask(reg_shift));
20782686Sksewell@umich.edu                     }});
20792084SN/A        }
20805222Sksewell@umich.edu        format CP0Control {
20815222Sksewell@umich.edu            0x7: cache({{
20825254Sksewell@umich.edu                //Addr CacheEA = Rs.uw + OFFSET;
20835250Sksewell@umich.edu                           //fault = xc->CacheOp((uint8_t)CACHE_OP,(Addr) CacheEA);
20845222Sksewell@umich.edu                         }});
20855222Sksewell@umich.edu        }
20862084SN/A    }
20872024SN/A
20882686Sksewell@umich.edu    0x6: decode OPCODE_LO {
20892686Sksewell@umich.edu        format LoadMemory {
20902686Sksewell@umich.edu            0x0: ll({{ Rt.uw = Mem.uw; }}, mem_flags=LOCKED);
20912686Sksewell@umich.edu            0x1: lwc1({{ Ft.uw = Mem.uw; }});
20922573SN/A            0x5: ldc1({{ Ft.ud = Mem.ud; }});
20932084SN/A        }
20945222Sksewell@umich.edu        0x2: CP2Unimpl::lwc2();
20955222Sksewell@umich.edu        0x6: CP2Unimpl::ldc2();
20962686Sksewell@umich.edu        0x3: Prefetch::pref();
20972084SN/A    }
20982024SN/A
20992239SN/A
21002686Sksewell@umich.edu    0x7: decode OPCODE_LO {
21012686Sksewell@umich.edu        0x0: StoreCond::sc({{ Mem.uw = Rt.uw;}},
21022686Sksewell@umich.edu                           {{ uint64_t tmp = write_result;
21032686Sksewell@umich.edu                              Rt.uw = (tmp == 0 || tmp == 1) ? tmp : Rt.uw;
21042935Sksewell@umich.edu                           }}, mem_flags=LOCKED, inst_flags = IsStoreConditional);
21052055SN/A
21062686Sksewell@umich.edu        format StoreMemory {
21075222Sksewell@umich.edu          0x1: swc1({{ Mem.uw = Ft.uw;}});
21085222Sksewell@umich.edu          0x5: sdc1({{ Mem.ud = Ft.ud;}});
21092084SN/A        }
21105222Sksewell@umich.edu
21115222Sksewell@umich.edu        0x2: CP2Unimpl::swc2();
21125222Sksewell@umich.edu        0x6: CP2Unimpl::sdc2();
21135222Sksewell@umich.edu
21142027SN/A    }
21152024SN/A}
21162022SN/A
21172027SN/A
2118