decoder.isa revision 6376
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 {
1236376Sgblack@eecs.umich.edu                        0x1: jr_hb({{
1246376Sgblack@eecs.umich.edu                            Config1Reg config1 = Config1;
1256376Sgblack@eecs.umich.edu                            if (config1.ca == 0) {
1266376Sgblack@eecs.umich.edu                                NNPC = Rs;
1276376Sgblack@eecs.umich.edu                            } else {
1286376Sgblack@eecs.umich.edu                                panic("MIPS16e not supported\n");
1296376Sgblack@eecs.umich.edu                            }
1306376Sgblack@eecs.umich.edu                        }}, IsReturn, ClearHazards);
1316376Sgblack@eecs.umich.edu                        default: jr({{
1326376Sgblack@eecs.umich.edu                            Config1Reg config1 = Config1;
1336376Sgblack@eecs.umich.edu                            if (config1.ca == 0) {
1346376Sgblack@eecs.umich.edu                                NNPC = Rs;
1356376Sgblack@eecs.umich.edu                            } else {
1366376Sgblack@eecs.umich.edu                                panic("MIPS16e not supported\n");
1376376Sgblack@eecs.umich.edu                            }
1386376Sgblack@eecs.umich.edu                        }}, IsReturn);
1392101SN/A                    }
1402042SN/A
1412101SN/A                    0x1: decode HINT {
1424661Sksewell@umich.edu                        0x1: jalr_hb({{ Rd = NNPC; NNPC = Rs; }}, IsCall
1432686Sksewell@umich.edu                                     , ClearHazards);
1444661Sksewell@umich.edu                        default: jalr({{ Rd = NNPC; NNPC = Rs; }}, IsCall);
1452101SN/A                    }
1462101SN/A                }
1472042SN/A
1482101SN/A                format BasicOp {
1492686Sksewell@umich.edu                    0x2: movz({{ Rd = (Rt == 0) ? Rs : Rd; }});
1502686Sksewell@umich.edu                    0x3: movn({{ Rd = (Rt != 0) ? Rs : Rd; }});
1515222Sksewell@umich.edu#if FULL_SYSTEM
1526036Sksewell@umich.edu                    0x4: syscall({{
1535222Sksewell@umich.edu                                   fault = new SystemCallFault();
1545222Sksewell@umich.edu                                 }});
1555222Sksewell@umich.edu#else
1562965Sksewell@umich.edu                    0x4: syscall({{ xc->syscall(R2); }},
1576037Sksewell@umich.edu                                 IsSerializeAfter, IsNonSpeculative);
1585222Sksewell@umich.edu#endif
1592686Sksewell@umich.edu                    0x7: sync({{ ; }}, IsMemBarrier);
1605222Sksewell@umich.edu                    0x5: break({{fault = new BreakpointFault();}});
1612101SN/A                }
1622083SN/A
1632043SN/A            }
1642025SN/A
1652043SN/A            0x2: decode FUNCTION_LO {
1665222Sksewell@umich.edu                0x0: HiLoRsSelOp::mfhi({{ Rd = HI_RS_SEL; }}, IntMultOp, IsIprAccess);
1674661Sksewell@umich.edu                0x1: HiLoRdSelOp::mthi({{ HI_RD_SEL = Rs; }});
1685222Sksewell@umich.edu                0x2: HiLoRsSelOp::mflo({{ Rd = LO_RS_SEL; }}, IntMultOp, IsIprAccess);
1694661Sksewell@umich.edu                0x3: HiLoRdSelOp::mtlo({{ LO_RD_SEL = Rs; }});
1702083SN/A            }
1712025SN/A
1722043SN/A            0x3: decode FUNCTION_LO {
1734661Sksewell@umich.edu                format HiLoRdSelValOp {
1745222Sksewell@umich.edu                    0x0: mult({{ val = Rs.sd * Rt.sd; }}, IntMultOp);
1755222Sksewell@umich.edu                    0x1: multu({{ val = Rs.ud * Rt.ud; }}, IntMultOp);
1764661Sksewell@umich.edu                }
1774661Sksewell@umich.edu
1782686Sksewell@umich.edu                format HiLoOp {
1794661Sksewell@umich.edu                    0x2: div({{ if (Rt.sd != 0) {
1804661Sksewell@umich.edu                        HI0 = Rs.sd % Rt.sd;
1814661Sksewell@umich.edu                        LO0 = Rs.sd / Rt.sd;
1824661Sksewell@umich.edu                    }
1835222Sksewell@umich.edu                    }}, IntDivOp);
1845222Sksewell@umich.edu
1854661Sksewell@umich.edu                    0x3: divu({{ if (Rt.ud != 0) {
1864661Sksewell@umich.edu                        HI0 = Rs.ud % Rt.ud;
1874661Sksewell@umich.edu                        LO0 = Rs.ud / Rt.ud;
1884661Sksewell@umich.edu                    }
1895222Sksewell@umich.edu                    }}, IntDivOp);
1902101SN/A                }
1912084SN/A            }
1922025SN/A
1932495SN/A            0x4: decode HINT {
1942495SN/A                0x0: decode FUNCTION_LO {
1952495SN/A                    format IntOp {
1965222Sksewell@umich.edu                      0x0: add({{  /* More complicated since an ADD can cause an arithmetic overflow exception */
1975222Sksewell@umich.edu                                     int64_t Src1 = Rs.sw;
1985222Sksewell@umich.edu                                     int64_t Src2 = Rt.sw;
1995222Sksewell@umich.edu                                     int64_t temp_result;
2005222Sksewell@umich.edu#if  FULL_SYSTEM
2015222Sksewell@umich.edu                                     if(((Src1 >> 31) & 1) == 1)
2025222Sksewell@umich.edu                                       Src1 |= 0x100000000LL;
2035222Sksewell@umich.edu#endif
2045222Sksewell@umich.edu                                     temp_result = Src1 + Src2;
2055222Sksewell@umich.edu#if  FULL_SYSTEM
2065222Sksewell@umich.edu                                     if(((temp_result >> 31) & 1) == ((temp_result >> 32) & 1)){
2075222Sksewell@umich.edu#endif
2085222Sksewell@umich.edu                                       Rd.sw = temp_result;
2095222Sksewell@umich.edu#if  FULL_SYSTEM
2105222Sksewell@umich.edu                                     } else{
2115222Sksewell@umich.edu                                       fault = new ArithmeticFault();
2125222Sksewell@umich.edu                                     }
2135222Sksewell@umich.edu#endif
2145222Sksewell@umich.edu
2155222Sksewell@umich.edu                                   }});
2162495SN/A                        0x1: addu({{ Rd.sw = Rs.sw + Rt.sw;}});
2175222Sksewell@umich.edu                        0x2: sub({{
2185222Sksewell@umich.edu                                     /* More complicated since an SUB can cause an arithmetic overflow exception */
2195222Sksewell@umich.edu                                     int64_t Src1 = Rs.sw;
2205222Sksewell@umich.edu                                     int64_t Src2 = Rt.sw;
2215222Sksewell@umich.edu                                     int64_t temp_result = Src1 - Src2;
2225222Sksewell@umich.edu#if  FULL_SYSTEM
2235222Sksewell@umich.edu                                     if(((temp_result >> 31) & 1) == ((temp_result>>32) & 1)){
2245222Sksewell@umich.edu#endif
2255222Sksewell@umich.edu                                       Rd.sw = temp_result;
2265222Sksewell@umich.edu#if  FULL_SYSTEM
2275222Sksewell@umich.edu                                     } else{
2285222Sksewell@umich.edu                                       fault = new ArithmeticFault();
2295222Sksewell@umich.edu                                     }
2305222Sksewell@umich.edu#endif
2315222Sksewell@umich.edu                                   }});
2322495SN/A                        0x3: subu({{ Rd.sw = Rs.sw - Rt.sw;}});
2332495SN/A                        0x4: and({{ Rd = Rs & Rt;}});
2342495SN/A                        0x5: or({{ Rd = Rs | Rt;}});
2352495SN/A                        0x6: xor({{ Rd = Rs ^ Rt;}});
2362495SN/A                        0x7: nor({{ Rd = ~(Rs | Rt);}});
2372495SN/A                    }
2382101SN/A                }
2392043SN/A            }
2402025SN/A
2412495SN/A            0x5: decode HINT {
2422495SN/A                0x0: decode FUNCTION_LO {
2432495SN/A                    format IntOp{
2442495SN/A                        0x2: slt({{  Rd.sw = ( Rs.sw < Rt.sw ) ? 1 : 0}});
2452495SN/A                        0x3: sltu({{ Rd.uw = ( Rs.uw < Rt.uw ) ? 1 : 0}});
2462495SN/A                    }
2472101SN/A                }
2482084SN/A            }
2492024SN/A
2502043SN/A            0x6: decode FUNCTION_LO {
2512239SN/A                format Trap {
2522239SN/A                    0x0: tge({{  cond = (Rs.sw >= Rt.sw); }});
2532101SN/A                    0x1: tgeu({{ cond = (Rs.uw >= Rt.uw); }});
2542101SN/A                    0x2: tlt({{ cond = (Rs.sw < Rt.sw); }});
2555222Sksewell@umich.edu                    0x3: tltu({{ cond = (Rs.uw < Rt.uw); }});
2562101SN/A                    0x4: teq({{ cond = (Rs.sw == Rt.sw); }});
2572101SN/A                    0x6: tne({{ cond = (Rs.sw != Rt.sw); }});
2582101SN/A                }
2592043SN/A            }
2602043SN/A        }
2612025SN/A
2622043SN/A        0x1: decode REGIMM_HI {
2632043SN/A            0x0: decode REGIMM_LO {
2642101SN/A                format Branch {
2652101SN/A                    0x0: bltz({{ cond = (Rs.sw < 0); }});
2662101SN/A                    0x1: bgez({{ cond = (Rs.sw >= 0); }});
2672686Sksewell@umich.edu                    0x2: bltzl({{ cond = (Rs.sw < 0); }}, Likely);
2682686Sksewell@umich.edu                    0x3: bgezl({{ cond = (Rs.sw >= 0); }}, Likely);
2692101SN/A                }
2702043SN/A            }
2712025SN/A
2722043SN/A            0x1: decode REGIMM_LO {
2735222Sksewell@umich.edu                format TrapImm {
2745222Sksewell@umich.edu                    0x0: tgei( {{ cond = (Rs.sw >= (int16_t)INTIMM); }});
2755222Sksewell@umich.edu                    0x1: tgeiu({{ cond = (Rs.uw >= (uint32_t)((int32_t)((int16_t)INTIMM))); }});
2765222Sksewell@umich.edu                    0x2: tlti( {{ cond = (Rs.sw < (int16_t)INTIMM); }});
2775222Sksewell@umich.edu                    0x3: tltiu({{ cond = (Rs.uw < (uint32_t)((int32_t)((int16_t)INTIMM))); }});
2785222Sksewell@umich.edu                    0x4: teqi( {{ cond = (Rs.sw == (int16_t)INTIMM);}});
2795222Sksewell@umich.edu                    0x6: tnei( {{ cond = (Rs.sw != (int16_t)INTIMM);}});
2802101SN/A                }
2812043SN/A            }
2822043SN/A
2832043SN/A            0x2: decode REGIMM_LO {
2842101SN/A                format Branch {
2852686Sksewell@umich.edu                    0x0: bltzal({{ cond = (Rs.sw < 0); }}, Link);
2862686Sksewell@umich.edu                    0x1: decode RS {
2872686Sksewell@umich.edu                        0x0: bal ({{ cond = 1; }}, IsCall, Link);
2882686Sksewell@umich.edu                        default: bgezal({{ cond = (Rs.sw >= 0); }}, Link);
2892686Sksewell@umich.edu                    }
2902686Sksewell@umich.edu                    0x2: bltzall({{ cond = (Rs.sw < 0); }}, Link, Likely);
2912686Sksewell@umich.edu                    0x3: bgezall({{ cond = (Rs.sw >= 0); }}, Link, Likely);
2922101SN/A                }
2932043SN/A            }
2942043SN/A
2952043SN/A            0x3: decode REGIMM_LO {
2964661Sksewell@umich.edu                // from Table 5-4 MIPS32 REGIMM Encoding of rt Field (DSP ASE MANUAL)
2974661Sksewell@umich.edu                0x4: DspBranch::bposge32({{ cond = (dspctl<5:0> >= 32); }});
2982101SN/A                format WarnUnimpl {
2992101SN/A                    0x7: synci();
3002101SN/A                }
3012043SN/A            }
3022043SN/A        }
3032043SN/A
3042123SN/A        format Jump {
3052239SN/A            0x2: j({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2);}});
3062686Sksewell@umich.edu            0x3: jal({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2); }}, IsCall,
3072686Sksewell@umich.edu                     Link);
3082043SN/A        }
3092043SN/A
3102100SN/A        format Branch {
3112686Sksewell@umich.edu            0x4: decode RS_RT  {
3122686Sksewell@umich.edu                0x0: b({{ cond = 1; }});
3132686Sksewell@umich.edu                default: beq({{ cond = (Rs.sw == Rt.sw); }});
3142686Sksewell@umich.edu            }
3152239SN/A            0x5: bne({{ cond = (Rs.sw != Rt.sw); }});
3162686Sksewell@umich.edu            0x6: blez({{ cond = (Rs.sw <= 0); }});
3172686Sksewell@umich.edu            0x7: bgtz({{ cond = (Rs.sw > 0); }});
3182043SN/A        }
3192084SN/A    }
3202024SN/A
3212101SN/A    0x1: decode OPCODE_LO {
3222686Sksewell@umich.edu        format IntImmOp {
3235222Sksewell@umich.edu            0x0: addi({{
3245222Sksewell@umich.edu                          int64_t Src1 = Rs.sw;
3255222Sksewell@umich.edu                          int64_t Src2 = imm;
3265222Sksewell@umich.edu                          int64_t temp_result;
3275222Sksewell@umich.edu#if  FULL_SYSTEM
3285222Sksewell@umich.edu                          if(((Src1 >> 31) & 1) == 1)
3295222Sksewell@umich.edu                            Src1 |= 0x100000000LL;
3305222Sksewell@umich.edu#endif
3315222Sksewell@umich.edu                          temp_result = Src1 + Src2;
3325222Sksewell@umich.edu#if  FULL_SYSTEM
3335222Sksewell@umich.edu                          if(((temp_result >> 31) & 1) == ((temp_result >> 32) & 1)){
3345222Sksewell@umich.edu#endif
3355222Sksewell@umich.edu                            Rt.sw = temp_result;
3365222Sksewell@umich.edu#if  FULL_SYSTEM
3375222Sksewell@umich.edu                          } else{
3385222Sksewell@umich.edu                            fault = new ArithmeticFault();
3395222Sksewell@umich.edu                          }
3405222Sksewell@umich.edu#endif
3415222Sksewell@umich.edu                        }});
3422239SN/A            0x1: addiu({{ Rt.sw = Rs.sw + imm;}});
3432239SN/A            0x2: slti({{ Rt.sw = ( Rs.sw < imm) ? 1 : 0 }});
3444661Sksewell@umich.edu
3454661Sksewell@umich.edu            //Edited to include MIPS AVP Pass/Fail instructions and
3464661Sksewell@umich.edu            //default to the sltiu instruction
3474661Sksewell@umich.edu            0x3: decode RS_RT_INTIMM {
3484661Sksewell@umich.edu                0xabc1: BasicOp::fail({{ exitSimLoop("AVP/SRVP Test Failed"); }});
3494661Sksewell@umich.edu                0xabc2: BasicOp::pass({{ exitSimLoop("AVP/SRVP Test Passed"); }});
3504661Sksewell@umich.edu              default: sltiu({{ Rt.uw = ( Rs.uw < (uint32_t)sextImm ) ? 1 : 0 }});
3514661Sksewell@umich.edu            }
3524661Sksewell@umich.edu
3532495SN/A            0x4: andi({{ Rt.sw = Rs.sw & zextImm;}});
3542495SN/A            0x5: ori({{ Rt.sw = Rs.sw | zextImm;}});
3552495SN/A            0x6: xori({{ Rt.sw = Rs.sw ^ zextImm;}});
3562495SN/A
3572495SN/A            0x7: decode RS {
3582495SN/A                0x0: lui({{ Rt = imm << 16}});
3592495SN/A            }
3602084SN/A        }
3612084SN/A    }
3622024SN/A
3632101SN/A    0x2: decode OPCODE_LO {
3642101SN/A        //Table A-11 MIPS32 COP0 Encoding of rs Field
3652101SN/A        0x0: decode RS_MSB {
3662101SN/A            0x0: decode RS {
3675222Sksewell@umich.edu                 format CP0Control {
3686376Sgblack@eecs.umich.edu                  0x0: mfc0({{
3696376Sgblack@eecs.umich.edu                      Config3Reg config3 = Config3;
3706376Sgblack@eecs.umich.edu                      PageGrainReg pageGrain = PageGrain;
3716376Sgblack@eecs.umich.edu                      Rt = CP0_RD_SEL;
3726376Sgblack@eecs.umich.edu                      /* Hack for PageMask */
3736376Sgblack@eecs.umich.edu                      if (RD == 5) {
3746376Sgblack@eecs.umich.edu                          // PageMask
3756376Sgblack@eecs.umich.edu                          if(config3.sp == 0 || pageGrain.esp == 0)
3766376Sgblack@eecs.umich.edu                              Rt &= 0xFFFFE7FF;
3776376Sgblack@eecs.umich.edu                      }
3786376Sgblack@eecs.umich.edu                  }});
3796376Sgblack@eecs.umich.edu                  0x4: mtc0({{ 
3806376Sgblack@eecs.umich.edu                      CP0_RD_SEL = Rt;
3816376Sgblack@eecs.umich.edu                      CauseReg cause = Cause;
3826376Sgblack@eecs.umich.edu                      IntCtlReg intCtl = IntCtl;
3836376Sgblack@eecs.umich.edu                      if (RD == 11) {
3846376Sgblack@eecs.umich.edu                          // Compare
3856376Sgblack@eecs.umich.edu                          if (cause.ti == 1) {
3866376Sgblack@eecs.umich.edu                              cause.ti = 0;
3876376Sgblack@eecs.umich.edu                              int offset = 10; // corresponding to cause.ip0
3886376Sgblack@eecs.umich.edu                              offset += intCtl.ipti - 2;
3896376Sgblack@eecs.umich.edu                              replaceBits(cause, offset, offset, 0);
3906376Sgblack@eecs.umich.edu                          }
3916376Sgblack@eecs.umich.edu                      }
3926376Sgblack@eecs.umich.edu                      Cause = cause;
3936376Sgblack@eecs.umich.edu                  }});
3945222Sksewell@umich.edu                 }
3955222Sksewell@umich.edu                 format CP0Unimpl {
3965222Sksewell@umich.edu                   0x1: dmfc0();
3975222Sksewell@umich.edu                   0x5: dmtc0();
3985222Sksewell@umich.edu                   default: unknown();
3995222Sksewell@umich.edu                 }
4004661Sksewell@umich.edu                format MT_MFTR { // Decode MIPS MT MFTR instruction into sub-instructions
4014661Sksewell@umich.edu                    0x8: decode MT_U {
4026376Sgblack@eecs.umich.edu                        0x0: mftc0({{
4036376Sgblack@eecs.umich.edu                            data = xc->readRegOtherThread((RT << 3 | SEL) +
4046376Sgblack@eecs.umich.edu                                                          Ctrl_Base_DepTag);
4056376Sgblack@eecs.umich.edu                        }});
4064661Sksewell@umich.edu                        0x1: decode SEL {
4074661Sksewell@umich.edu                            0x0: mftgpr({{ data = xc->readRegOtherThread(RT); }});
4084661Sksewell@umich.edu                            0x1: decode RT {
4094661Sksewell@umich.edu                                0x0: mftlo_dsp0({{ data = xc->readRegOtherThread(MipsISA::DSPLo0); }});
4104661Sksewell@umich.edu                                0x1: mfthi_dsp0({{ data = xc->readRegOtherThread(MipsISA::DSPHi0); }});
4114661Sksewell@umich.edu                                0x2: mftacx_dsp0({{ data = xc->readRegOtherThread(MipsISA::DSPACX0); }});
4124661Sksewell@umich.edu                                0x4: mftlo_dsp1({{ data = xc->readRegOtherThread(MipsISA::DSPLo1); }});
4134661Sksewell@umich.edu                                0x5: mfthi_dsp1({{ data = xc->readRegOtherThread(MipsISA::DSPHi1); }});
4144661Sksewell@umich.edu                                0x6: mftacx_dsp1({{ data = xc->readRegOtherThread(MipsISA::DSPACX1); }});
4154661Sksewell@umich.edu                                0x8: mftlo_dsp2({{ data = xc->readRegOtherThread(MipsISA::DSPLo2); }});
4164661Sksewell@umich.edu                                0x9: mfthi_dsp2({{ data = xc->readRegOtherThread(MipsISA::DSPHi2); }});
4174661Sksewell@umich.edu                                0x10: mftacx_dsp2({{ data = xc->readRegOtherThread(MipsISA::DSPACX2); }});
4184661Sksewell@umich.edu                                0x12: mftlo_dsp3({{ data = xc->readRegOtherThread(MipsISA::DSPLo3); }});
4194661Sksewell@umich.edu                                0x13: mfthi_dsp3({{ data = xc->readRegOtherThread(MipsISA::DSPHi3); }});
4204661Sksewell@umich.edu                                0x14: mftacx_dsp3({{ data = xc->readRegOtherThread(MipsISA::DSPACX3); }});
4214661Sksewell@umich.edu                                0x16: mftdsp({{ data = xc->readRegOtherThread(MipsISA::DSPControl); }});
4225222Sksewell@umich.edu                               default: CP0Unimpl::unknown();
4232686Sksewell@umich.edu                            }
4244661Sksewell@umich.edu                            0x2: decode MT_H {
4254661Sksewell@umich.edu                                0x0: mftc1({{ data = xc->readRegOtherThread(RT +
4264661Sksewell@umich.edu                                                                            FP_Base_DepTag);
4274661Sksewell@umich.edu                                           }});
4284661Sksewell@umich.edu                                0x1: mfthc1({{ data = xc->readRegOtherThread(RT +
4294661Sksewell@umich.edu                                                                             FP_Base_DepTag);
4304661Sksewell@umich.edu                                           }});
4315222Sksewell@umich.edu                               }
4324661Sksewell@umich.edu                            0x3: cftc1({{ uint32_t fcsr_val = xc->readRegOtherThread(MipsISA::FCSR +
4334661Sksewell@umich.edu                                                                            FP_Base_DepTag);
4344661Sksewell@umich.edu                                          switch (RT)
4354661Sksewell@umich.edu                                          {
4364661Sksewell@umich.edu                                               case 0:
4374661Sksewell@umich.edu                                                 data = xc->readRegOtherThread(MipsISA::FIR +
4384661Sksewell@umich.edu                                                                               Ctrl_Base_DepTag);
4394661Sksewell@umich.edu                                                 break;
4404661Sksewell@umich.edu                                               case 25:
4415570Snate@binkert.org                                                 data = (fcsr_val & 0xFE000000 >> 24)
4425570Snate@binkert.org                                                     | (fcsr_val & 0x00800000 >> 23);
4434661Sksewell@umich.edu                                                 break;
4444661Sksewell@umich.edu                                               case 26:
4455570Snate@binkert.org                                                 data = fcsr_val & 0x0003F07C;
4464661Sksewell@umich.edu                                                 break;
4474661Sksewell@umich.edu                                               case 28:
4485570Snate@binkert.org                                                 data = (fcsr_val & 0x00000F80)
4495570Snate@binkert.org                                                     | (fcsr_val & 0x01000000 >> 21)
4505570Snate@binkert.org                                                     | (fcsr_val & 0x00000003);
4514661Sksewell@umich.edu                                                 break;
4524661Sksewell@umich.edu                                               case 31:
4534661Sksewell@umich.edu                                                 data = fcsr_val;
4544661Sksewell@umich.edu                                                 break;
4554661Sksewell@umich.edu                                               default:
4564661Sksewell@umich.edu                                                 fatal("FP Control Value (%d) Not Valid");
4574661Sksewell@umich.edu                                          }
4584661Sksewell@umich.edu                                        }});
4595222Sksewell@umich.edu                           default: CP0Unimpl::unknown();
4602101SN/A                        }
4615222Sksewell@umich.edu                  }
4622686Sksewell@umich.edu                }
4632027SN/A
4644661Sksewell@umich.edu                format MT_MTTR { // Decode MIPS MT MTTR instruction into sub-instructions
4654661Sksewell@umich.edu                    0xC: decode MT_U {
4664661Sksewell@umich.edu                        0x0: mttc0({{ xc->setRegOtherThread((RD << 3 | SEL) + Ctrl_Base_DepTag,
4674661Sksewell@umich.edu                                                            Rt);
4684661Sksewell@umich.edu                                   }});
4694661Sksewell@umich.edu                        0x1: decode SEL {
4704661Sksewell@umich.edu                            0x0: mttgpr({{ xc->setRegOtherThread(RD, Rt); }});
4714661Sksewell@umich.edu                            0x1: decode RT {
4724661Sksewell@umich.edu                                0x0: mttlo_dsp0({{ xc->setRegOtherThread(MipsISA::DSPLo0, Rt);
4734661Sksewell@umich.edu                                                }});
4744661Sksewell@umich.edu                                0x1: mtthi_dsp0({{ xc->setRegOtherThread(MipsISA::DSPHi0,
4754661Sksewell@umich.edu                                                                         Rt);
4764661Sksewell@umich.edu                                                }});
4774661Sksewell@umich.edu                                0x2: mttacx_dsp0({{ xc->setRegOtherThread(MipsISA::DSPACX0,
4784661Sksewell@umich.edu                                                                          Rt);
4794661Sksewell@umich.edu                                                 }});
4804661Sksewell@umich.edu                                0x4: mttlo_dsp1({{ xc->setRegOtherThread(MipsISA::DSPLo1,
4814661Sksewell@umich.edu                                                                         Rt);
4824661Sksewell@umich.edu                                                }});
4834661Sksewell@umich.edu                                0x5: mtthi_dsp1({{ xc->setRegOtherThread(MipsISA::DSPHi1,
4844661Sksewell@umich.edu                                                                         Rt);
4854661Sksewell@umich.edu                                                }});
4864661Sksewell@umich.edu                                0x6: mttacx_dsp1({{ xc->setRegOtherThread(MipsISA::DSPACX1,
4874661Sksewell@umich.edu                                                                          Rt);
4884661Sksewell@umich.edu                                                 }});
4894661Sksewell@umich.edu                                0x8: mttlo_dsp2({{ xc->setRegOtherThread(MipsISA::DSPLo2,
4904661Sksewell@umich.edu                                                                         Rt);
4914661Sksewell@umich.edu                                                }});
4924661Sksewell@umich.edu                                0x9: mtthi_dsp2({{ xc->setRegOtherThread(MipsISA::DSPHi2,
4934661Sksewell@umich.edu                                                                         Rt);
4944661Sksewell@umich.edu                                                }});
4954661Sksewell@umich.edu                                0x10: mttacx_dsp2({{ xc->setRegOtherThread(MipsISA::DSPACX2,
4964661Sksewell@umich.edu                                                                           Rt);
4974661Sksewell@umich.edu                                                  }});
4984661Sksewell@umich.edu                                0x12: mttlo_dsp3({{ xc->setRegOtherThread(MipsISA::DSPLo3,
4994661Sksewell@umich.edu                                                                          Rt);
5004661Sksewell@umich.edu                                                 }});
5014661Sksewell@umich.edu                                0x13: mtthi_dsp3({{ xc->setRegOtherThread(MipsISA::DSPHi3,
5024661Sksewell@umich.edu                                                                          Rt);
5034661Sksewell@umich.edu                                                 }});
5044661Sksewell@umich.edu                                0x14: mttacx_dsp3({{ xc->setRegOtherThread(MipsISA::DSPACX3, Rt);
5054661Sksewell@umich.edu                                                  }});
5064661Sksewell@umich.edu                                0x16: mttdsp({{ xc->setRegOtherThread(MipsISA::DSPControl, Rt); }});
5075222Sksewell@umich.edu                               default: CP0Unimpl::unknown();
5085222Sksewell@umich.edu
5094661Sksewell@umich.edu                            }
5104661Sksewell@umich.edu                            0x2: mttc1({{ uint64_t data = xc->readRegOtherThread(RD +
5114661Sksewell@umich.edu                                                                                FP_Base_DepTag);
5124661Sksewell@umich.edu                                          data = insertBits(data, top_bit, bottom_bit, Rt);
5134661Sksewell@umich.edu                                          xc->setRegOtherThread(RD + FP_Base_DepTag, data);
5144661Sksewell@umich.edu                                       }});
5154661Sksewell@umich.edu                            0x3: cttc1({{ uint32_t data;
5164661Sksewell@umich.edu                                          switch (RD)
5174661Sksewell@umich.edu                                          {
5184661Sksewell@umich.edu                                            case 25:
5194661Sksewell@umich.edu                                              data = 0 | (Rt.uw<7:1> << 25) // move 31...25
5204661Sksewell@umich.edu                                                  | (FCSR & 0x01000000) // bit 24
5214661Sksewell@umich.edu                                                  | (FCSR & 0x004FFFFF);// bit 22...0
5224661Sksewell@umich.edu                                              break;
5234661Sksewell@umich.edu
5244661Sksewell@umich.edu                                            case 26:
5254661Sksewell@umich.edu                                              data = 0 | (FCSR & 0xFFFC0000) // move 31...18
5264661Sksewell@umich.edu                                                  | Rt.uw<17:12> << 12           // bit 17...12
5274661Sksewell@umich.edu                                                  | (FCSR & 0x00000F80) << 7// bit 11...7
5284661Sksewell@umich.edu                                                  | Rt.uw<6:2> << 2              // bit 6...2
5294661Sksewell@umich.edu                                                  | (FCSR & 0x00000002);     // bit 1...0
5304661Sksewell@umich.edu                                              break;
5314661Sksewell@umich.edu
5324661Sksewell@umich.edu                                            case 28:
5334661Sksewell@umich.edu                                              data = 0 | (FCSR & 0xFE000000) // move 31...25
5344661Sksewell@umich.edu                                                  | Rt.uw<2:2> << 24       // bit 24
5354661Sksewell@umich.edu                                                  | (FCSR & 0x00FFF000) << 23// bit 23...12
5364661Sksewell@umich.edu                                                  | Rt.uw<11:7> << 7       // bit 24
5374661Sksewell@umich.edu                                                  | (FCSR & 0x000007E)
5384661Sksewell@umich.edu                                                  | Rt.uw<1:0>;// bit 22...0
5394661Sksewell@umich.edu                                              break;
5404661Sksewell@umich.edu
5414661Sksewell@umich.edu                                            case 31:
5424661Sksewell@umich.edu                                              data  = Rt.uw;
5434661Sksewell@umich.edu                                              break;
5444661Sksewell@umich.edu
5454661Sksewell@umich.edu                                            default:
5464661Sksewell@umich.edu                                              panic("FP Control Value (%d) Not Available. Ignoring Access to"
5474661Sksewell@umich.edu                                                    "Floating Control Status Register", FS);
5484661Sksewell@umich.edu                                          }
5494661Sksewell@umich.edu                                          xc->setRegOtherThread(FCSR, data);
5504661Sksewell@umich.edu                                       }});
5515222Sksewell@umich.edu                               default: CP0Unimpl::unknown();
5524661Sksewell@umich.edu                        }
5534661Sksewell@umich.edu                    }
5542101SN/A                }
5554661Sksewell@umich.edu
5564661Sksewell@umich.edu
5574661Sksewell@umich.edu                0xB: decode RD {
5584661Sksewell@umich.edu                    format MT_Control {
5594661Sksewell@umich.edu                        0x0: decode POS {
5604661Sksewell@umich.edu                            0x0: decode SEL {
5614661Sksewell@umich.edu                                0x1: decode SC {
5626376Sgblack@eecs.umich.edu                                    0x0: dvpe({{
5636376Sgblack@eecs.umich.edu                                        MVPControlReg mvpControl = MVPControl;
5646376Sgblack@eecs.umich.edu                                        VPEConf0Reg vpeConf0 = VPEConf0;
5656376Sgblack@eecs.umich.edu                                        Rt = MVPControl;
5666376Sgblack@eecs.umich.edu                                        if (vpeConf0.mvp == 1)
5676376Sgblack@eecs.umich.edu                                            mvpControl.evp = 0;
5686376Sgblack@eecs.umich.edu                                        MVPControl = mvpControl;
5696376Sgblack@eecs.umich.edu                                    }});
5706376Sgblack@eecs.umich.edu                                    0x1: evpe({{
5716376Sgblack@eecs.umich.edu                                        MVPControlReg mvpControl = MVPControl;
5726376Sgblack@eecs.umich.edu                                        VPEConf0Reg vpeConf0 = VPEConf0;
5736376Sgblack@eecs.umich.edu                                        Rt = MVPControl;
5746376Sgblack@eecs.umich.edu                                        if (vpeConf0.mvp == 1)
5756376Sgblack@eecs.umich.edu                                            mvpControl.evp = 1;
5766376Sgblack@eecs.umich.edu                                        MVPControl = mvpControl;
5776376Sgblack@eecs.umich.edu                                    }});
5785222Sksewell@umich.edu                                   default:CP0Unimpl::unknown();
5794661Sksewell@umich.edu                                }
5805222Sksewell@umich.edu                               default:CP0Unimpl::unknown();
5814661Sksewell@umich.edu                            }
5825222Sksewell@umich.edu                        default:CP0Unimpl::unknown();
5835222Sksewell@umich.edu                      }
5844661Sksewell@umich.edu
5854661Sksewell@umich.edu                        0x1: decode POS {
5864661Sksewell@umich.edu                            0xF: decode SEL {
5874661Sksewell@umich.edu                                0x1: decode SC {
5886376Sgblack@eecs.umich.edu                                    0x0: dmt({{
5896376Sgblack@eecs.umich.edu                                        VPEControlReg vpeControl = VPEControl;
5906376Sgblack@eecs.umich.edu                                        Rt = vpeControl;
5916376Sgblack@eecs.umich.edu                                        vpeControl.te = 0;
5926376Sgblack@eecs.umich.edu                                        VPEControl = vpeControl;
5936376Sgblack@eecs.umich.edu                                    }});
5946376Sgblack@eecs.umich.edu                                    0x1: emt({{
5956376Sgblack@eecs.umich.edu                                        VPEControlReg vpeControl = VPEControl;
5966376Sgblack@eecs.umich.edu                                        Rt = vpeControl;
5976376Sgblack@eecs.umich.edu                                        vpeControl.te = 1;
5986376Sgblack@eecs.umich.edu                                        VPEControl = vpeControl;
5996376Sgblack@eecs.umich.edu                                    }});
6005222Sksewell@umich.edu                                   default:CP0Unimpl::unknown();
6014661Sksewell@umich.edu                                }
6025222Sksewell@umich.edu                               default:CP0Unimpl::unknown();
6034661Sksewell@umich.edu                            }
6045222Sksewell@umich.edu                            default:CP0Unimpl::unknown();
6054661Sksewell@umich.edu                        }
6064661Sksewell@umich.edu                    }
6074661Sksewell@umich.edu                    0xC: decode POS {
6084661Sksewell@umich.edu                      0x0: decode SC {
6094661Sksewell@umich.edu                        0x0: CP0Control::di({{
6106376Sgblack@eecs.umich.edu                            StatusReg status = Status;
6116376Sgblack@eecs.umich.edu                            ConfigReg config = Config;
6126376Sgblack@eecs.umich.edu                            // Rev 2.0 or beyond?
6136376Sgblack@eecs.umich.edu                            if (config.ar >= 1) {
6146376Sgblack@eecs.umich.edu                                Rt = status;
6156376Sgblack@eecs.umich.edu                                status.ie = 0;
6166376Sgblack@eecs.umich.edu                            } else {
6176376Sgblack@eecs.umich.edu                                   // Enable this else branch once we
6186376Sgblack@eecs.umich.edu                                   // actually set values for Config on init
6194661Sksewell@umich.edu                                fault = new ReservedInstructionFault();
6206376Sgblack@eecs.umich.edu                            }
6216376Sgblack@eecs.umich.edu                            Status = status;
6226376Sgblack@eecs.umich.edu                        }});
6234661Sksewell@umich.edu                        0x1: CP0Control::ei({{
6246376Sgblack@eecs.umich.edu                            StatusReg status = Status;
6256376Sgblack@eecs.umich.edu                            ConfigReg config = Config;
6266376Sgblack@eecs.umich.edu                            if (config.ar >= 1) {
6276376Sgblack@eecs.umich.edu                                Rt = status;
6286376Sgblack@eecs.umich.edu                                status.ie = 1;
6296376Sgblack@eecs.umich.edu                            } else {
6304661Sksewell@umich.edu                                fault = new ReservedInstructionFault();
6316376Sgblack@eecs.umich.edu                            }
6326376Sgblack@eecs.umich.edu                        }});
6335222Sksewell@umich.edu                        default:CP0Unimpl::unknown();
6344661Sksewell@umich.edu                      }
6354661Sksewell@umich.edu                    }
6365222Sksewell@umich.edu                default: CP0Unimpl::unknown();
6374661Sksewell@umich.edu                }
6384661Sksewell@umich.edu                format CP0Control {
6394661Sksewell@umich.edu                    0xA: rdpgpr({{
6406376Sgblack@eecs.umich.edu                        ConfigReg config = Config;
6416376Sgblack@eecs.umich.edu                        if (config.ar >= 1) {
6426376Sgblack@eecs.umich.edu                            // Rev 2 of the architecture
6436376Sgblack@eecs.umich.edu                            panic("Shadow Sets Not Fully Implemented.\n");
6446376Sgblack@eecs.umich.edu                        } else {
6454661Sksewell@umich.edu                          fault = new ReservedInstructionFault();
6464661Sksewell@umich.edu                        }
6476376Sgblack@eecs.umich.edu                    }});
6484661Sksewell@umich.edu                    0xE: wrpgpr({{
6496376Sgblack@eecs.umich.edu                        ConfigReg config = Config;
6506376Sgblack@eecs.umich.edu                        if (config.ar >= 1) {
6516376Sgblack@eecs.umich.edu                            // Rev 2 of the architecture
6526376Sgblack@eecs.umich.edu                            panic("Shadow Sets Not Fully Implemented.\n");
6536376Sgblack@eecs.umich.edu                        } else {
6546376Sgblack@eecs.umich.edu                            fault = new ReservedInstructionFault();
6554661Sksewell@umich.edu                        }
6566376Sgblack@eecs.umich.edu                    }});
6574661Sksewell@umich.edu                }
6584661Sksewell@umich.edu
6595222Sksewell@umich.edu               }
6602101SN/A
6612101SN/A            //Table A-12 MIPS32 COP0 Encoding of Function Field When rs=CO
6622101SN/A            0x1: decode FUNCTION {
6634661Sksewell@umich.edu              format CP0Control {
6644661Sksewell@umich.edu                0x18: eret({{
6656376Sgblack@eecs.umich.edu                    StatusReg status = Status;
6666376Sgblack@eecs.umich.edu                    ConfigReg config = Config;
6676376Sgblack@eecs.umich.edu                    SRSCtlReg srsCtl = SRSCtl;
6686376Sgblack@eecs.umich.edu                    DPRINTF(MipsPRA,"Restoring PC - %x\n",EPC);
6696376Sgblack@eecs.umich.edu                    if (status.erl == 1) {
6706376Sgblack@eecs.umich.edu                        status.erl = 0;
6716376Sgblack@eecs.umich.edu                        NPC = ErrorEPC;
6726376Sgblack@eecs.umich.edu                        // Need to adjust NNPC, otherwise things break
6736376Sgblack@eecs.umich.edu                        NNPC = ErrorEPC + sizeof(MachInst);
6746376Sgblack@eecs.umich.edu                    } else {
6756376Sgblack@eecs.umich.edu                        NPC = EPC;
6766376Sgblack@eecs.umich.edu                        // Need to adjust NNPC, otherwise things break
6776376Sgblack@eecs.umich.edu                        NNPC = EPC + sizeof(MachInst);
6786376Sgblack@eecs.umich.edu                        status.exl = 0;
6796376Sgblack@eecs.umich.edu                        if (config.ar >=1 &&
6806376Sgblack@eecs.umich.edu                                srsCtl.hss > 0 &&
6816376Sgblack@eecs.umich.edu                                status.bev == 0) {
6826376Sgblack@eecs.umich.edu                            srsCtl.css = srsCtl.pss;
6836376Sgblack@eecs.umich.edu                            //xc->setShadowSet(srsCtl.pss);
6846376Sgblack@eecs.umich.edu                        }
6854661Sksewell@umich.edu                    }
6866376Sgblack@eecs.umich.edu                    LLFlag = 0;
6876376Sgblack@eecs.umich.edu                    Status = status;
6886376Sgblack@eecs.umich.edu                    SRSCtl = srsCtl;
6896376Sgblack@eecs.umich.edu                }},IsReturn,IsSerializing,IsERET);
6905222Sksewell@umich.edu
6915222Sksewell@umich.edu                0x1F: deret({{
6926376Sgblack@eecs.umich.edu                    DebugReg debug = Debug;
6936376Sgblack@eecs.umich.edu                    if (debug.dm == 1) {
6946376Sgblack@eecs.umich.edu                        debug.dm = 1;
6956376Sgblack@eecs.umich.edu                        debug.iexi = 0;
6966376Sgblack@eecs.umich.edu                        NPC = DEPC;
6976376Sgblack@eecs.umich.edu                    } else {
6986376Sgblack@eecs.umich.edu                        // Undefined;
6995222Sksewell@umich.edu                    }
7006376Sgblack@eecs.umich.edu                    Debug = debug;
7016376Sgblack@eecs.umich.edu                }}, IsReturn, IsSerializing, IsERET);
7025222Sksewell@umich.edu              }
7035222Sksewell@umich.edu              format CP0TLB {
7045222Sksewell@umich.edu                0x01: tlbr({{
7055222Sksewell@umich.edu                    MipsISA::PTE *PTEntry = xc->tcBase()->getITBPtr()->getEntry(Index & 0x7FFFFFFF);
7065222Sksewell@umich.edu                    if(PTEntry == NULL)
7075222Sksewell@umich.edu                      {
7085222Sksewell@umich.edu                        fatal("Invalid PTE Entry received on a TLBR instruction\n");
7095222Sksewell@umich.edu                      }
7105222Sksewell@umich.edu                    /* Setup PageMask */
7115222Sksewell@umich.edu                    PageMask = (PTEntry->Mask << 11); // If 1KB pages are not enabled, a read of PageMask must return 0b00 in bits 12, 11
7125222Sksewell@umich.edu                    /* Setup EntryHi */
7135222Sksewell@umich.edu                    EntryHi = ((PTEntry->VPN << 11) | (PTEntry->asid));
7145222Sksewell@umich.edu                    /* Setup Entry Lo0 */
7155222Sksewell@umich.edu                    EntryLo0 = ((PTEntry->PFN0 << 6) | (PTEntry->C0 << 3) | (PTEntry->D0 << 2) | (PTEntry->V0 << 1) | PTEntry->G);
7165222Sksewell@umich.edu                    /* Setup Entry Lo1 */
7175222Sksewell@umich.edu                    EntryLo1 = ((PTEntry->PFN1 << 6) | (PTEntry->C1 << 3) | (PTEntry->D1 << 2) | (PTEntry->V1 << 1) | PTEntry->G);
7185222Sksewell@umich.edu                }}); // Need to hook up to TLB
7195222Sksewell@umich.edu
7205222Sksewell@umich.edu                0x02: tlbwi({{
7216376Sgblack@eecs.umich.edu                    //Create PTE
7226376Sgblack@eecs.umich.edu                    MipsISA::PTE NewEntry;
7236376Sgblack@eecs.umich.edu                    //Write PTE
7246376Sgblack@eecs.umich.edu                    NewEntry.Mask = (Addr)(PageMask >> 11);
7256376Sgblack@eecs.umich.edu                    NewEntry.VPN = (Addr)(EntryHi >> 11);
7266376Sgblack@eecs.umich.edu                    /*  PageGrain _ ESP                    Config3 _ SP */
7276376Sgblack@eecs.umich.edu                    if(((PageGrain>>28) & 1) == 0 || ((Config3>>4)&1) ==0) {
7286376Sgblack@eecs.umich.edu                        // If 1KB pages are *NOT* enabled, lowest bits of the
7296376Sgblack@eecs.umich.edu                        // mask are 0b11 for TLB writes
7306376Sgblack@eecs.umich.edu                        NewEntry.Mask |= 0x3;
7316376Sgblack@eecs.umich.edu                        // Reset bits 0 and 1 if 1KB pages are not enabled
7326376Sgblack@eecs.umich.edu                        NewEntry.VPN &= 0xFFFFFFFC;
7336376Sgblack@eecs.umich.edu                    }
7346376Sgblack@eecs.umich.edu                    NewEntry.asid = (uint8_t)(EntryHi & 0xFF);
7355222Sksewell@umich.edu
7366376Sgblack@eecs.umich.edu                    NewEntry.PFN0 = (Addr)(EntryLo0 >> 6);
7376376Sgblack@eecs.umich.edu                    NewEntry.PFN1 = (Addr)(EntryLo1 >> 6);
7386376Sgblack@eecs.umich.edu                    NewEntry.D0 = (bool)((EntryLo0 >> 2) & 1);
7396376Sgblack@eecs.umich.edu                    NewEntry.D1 = (bool)((EntryLo1 >> 2) & 1);
7406376Sgblack@eecs.umich.edu                    NewEntry.V1 = (bool)((EntryLo1 >> 1) & 1);
7416376Sgblack@eecs.umich.edu                    NewEntry.V0 = (bool)((EntryLo0 >> 1) & 1);
7426376Sgblack@eecs.umich.edu                    NewEntry.G = (bool)((EntryLo0 & EntryLo1) & 1);
7436376Sgblack@eecs.umich.edu                    NewEntry.C0 = (uint8_t)((EntryLo0 >> 3) & 0x7);
7446376Sgblack@eecs.umich.edu                    NewEntry.C1 = (uint8_t)((EntryLo1 >> 3) & 0x7);
7456376Sgblack@eecs.umich.edu                    /* Now, compute the AddrShiftAmount and OffsetMask - TLB
7466376Sgblack@eecs.umich.edu                       optimizations */
7476376Sgblack@eecs.umich.edu                    /* Addr Shift Amount for 1KB or larger pages */
7486376Sgblack@eecs.umich.edu                    if ((NewEntry.Mask & 0xFFFF) == 3) {
7496376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 12;
7506376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFFF) == 0x0000) {
7516376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 10;
7526376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFFC) == 0x000C) {
7536376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 14;
7546376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFF0) == 0x0030) {
7556376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 16;
7566376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFC0) == 0x00C0) {
7576376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 18;
7586376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFF00) == 0x0300) {
7596376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 20;
7606376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFC00) == 0x0C00) {
7616376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 22;
7626376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xF000) == 0x3000) {
7636376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 24;
7646376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xC000) == 0xC000) {
7656376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 26;
7666376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0x30000) == 0x30000) {
7676376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 28;
7686376Sgblack@eecs.umich.edu                    } else {
7696376Sgblack@eecs.umich.edu                        fatal("Invalid Mask Pattern Detected!\n");
7706376Sgblack@eecs.umich.edu                    }
7716376Sgblack@eecs.umich.edu                    NewEntry.OffsetMask = ((1<<NewEntry.AddrShiftAmount)-1);
7725222Sksewell@umich.edu
7736376Sgblack@eecs.umich.edu                    MipsISA::TLB *Ptr = xc->tcBase()->getITBPtr();
7746376Sgblack@eecs.umich.edu                    Config3Reg config3 = Config3
7756376Sgblack@eecs.umich.edu                    PageGrainReg pageGrain = PageGrain;
7766376Sgblack@eecs.umich.edu                    int SP = 0;
7776376Sgblack@eecs.umich.edu                    if (bits(config3, config3.sp) == 1 &&
7786376Sgblack@eecs.umich.edu                        bits(pageGrain, pageGrain.esp) == 1) {
7796376Sgblack@eecs.umich.edu                        SP = 1;
7806376Sgblack@eecs.umich.edu                    }
7816376Sgblack@eecs.umich.edu                    IndexReg index = Index;
7826376Sgblack@eecs.umich.edu                    Ptr->insertAt(NewEntry, Index & 0x7FFFFFFF, SP);
7835222Sksewell@umich.edu              }});
7845222Sksewell@umich.edu                0x06: tlbwr({{
7856376Sgblack@eecs.umich.edu                    //Create PTE
7866376Sgblack@eecs.umich.edu                    MipsISA::PTE NewEntry;
7876376Sgblack@eecs.umich.edu                    //Write PTE
7886376Sgblack@eecs.umich.edu                    NewEntry.Mask = (Addr)(PageMask >> 11);
7896376Sgblack@eecs.umich.edu                    NewEntry.VPN = (Addr)(EntryHi >> 11);
7906376Sgblack@eecs.umich.edu                    /*  PageGrain _ ESP                    Config3 _ SP */
7916376Sgblack@eecs.umich.edu                    if (((PageGrain >> 28) & 1) == 0 ||
7926376Sgblack@eecs.umich.edu                        (( Config3 >> 4) & 1) ==0) {
7936376Sgblack@eecs.umich.edu                        // If 1KB pages are *NOT* enabled, lowest bits of
7946376Sgblack@eecs.umich.edu                        // the mask are 0b11 for TLB writes
7956376Sgblack@eecs.umich.edu                        NewEntry.Mask |= 0x3;
7966376Sgblack@eecs.umich.edu                        // Reset bits 0 and 1 if 1KB pages are not enabled
7976376Sgblack@eecs.umich.edu                        NewEntry.VPN &= 0xFFFFFFFC;
7986376Sgblack@eecs.umich.edu                    }
7996376Sgblack@eecs.umich.edu                    NewEntry.asid = (uint8_t)(EntryHi & 0xFF);
8005222Sksewell@umich.edu
8016376Sgblack@eecs.umich.edu                    NewEntry.PFN0 = (Addr)(EntryLo0 >> 6);
8026376Sgblack@eecs.umich.edu                    NewEntry.PFN1 = (Addr)(EntryLo1 >> 6);
8036376Sgblack@eecs.umich.edu                    NewEntry.D0 = (bool)((EntryLo0 >> 2) & 1);
8046376Sgblack@eecs.umich.edu                    NewEntry.D1 = (bool)((EntryLo1 >> 2) & 1);
8056376Sgblack@eecs.umich.edu                    NewEntry.V1 = (bool)((EntryLo1 >> 1) & 1);
8066376Sgblack@eecs.umich.edu                    NewEntry.V0 = (bool)((EntryLo0 >> 1) & 1);
8076376Sgblack@eecs.umich.edu                    NewEntry.G = (bool)((EntryLo0 & EntryLo1) & 1);
8086376Sgblack@eecs.umich.edu                    NewEntry.C0 = (uint8_t)((EntryLo0 >> 3) & 0x7);
8096376Sgblack@eecs.umich.edu                    NewEntry.C1 = (uint8_t)((EntryLo1 >> 3) & 0x7);
8106376Sgblack@eecs.umich.edu                    /* Now, compute the AddrShiftAmount and OffsetMask -
8116376Sgblack@eecs.umich.edu                       TLB optimizations */
8126376Sgblack@eecs.umich.edu                    /* Addr Shift Amount for 1KB or larger pages */
8136376Sgblack@eecs.umich.edu                    if ((NewEntry.Mask & 0xFFFF) == 3){
8146376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 12;
8156376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFFF) == 0x0000) {
8166376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 10;
8176376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFFC) == 0x000C) {
8186376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 14;
8196376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFFF0) == 0x0030) {
8206376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 16;
8216376Sgblack@eecs.umich.edu                    }   else if ((NewEntry.Mask & 0xFFC0) == 0x00C0) {
8226376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 18;
8236376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFF00) == 0x0300) {
8246376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 20;
8256376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xFC00) == 0x0C00) {
8266376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 22;
8276376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xF000) == 0x3000) {
8286376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 24;
8296376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0xC000) == 0xC000) {
8306376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 26;
8316376Sgblack@eecs.umich.edu                    } else if ((NewEntry.Mask & 0x30000) == 0x30000) {
8326376Sgblack@eecs.umich.edu                        NewEntry.AddrShiftAmount = 28;
8336376Sgblack@eecs.umich.edu                    } else {
8346376Sgblack@eecs.umich.edu                        fatal("Invalid Mask Pattern Detected!\n");
8356376Sgblack@eecs.umich.edu                    }
8366376Sgblack@eecs.umich.edu                    NewEntry.OffsetMask = ((1 << NewEntry.AddrShiftAmount) - 1);
8375222Sksewell@umich.edu
8386376Sgblack@eecs.umich.edu                    MipsISA::TLB *Ptr = xc->tcBase()->getITBPtr();
8396376Sgblack@eecs.umich.edu                    Config3Reg config3 = Config3
8406376Sgblack@eecs.umich.edu                    PageGrainReg pageGrain = PageGrain;
8416376Sgblack@eecs.umich.edu                    int SP = 0;
8426376Sgblack@eecs.umich.edu                    if (bits(config3, config3.sp) == 1 &&
8436376Sgblack@eecs.umich.edu                        bits(pageGrain, pageGrain.esp) == 1) {
8446376Sgblack@eecs.umich.edu                        SP = 1;
8456376Sgblack@eecs.umich.edu                    }
8466376Sgblack@eecs.umich.edu                    IndexReg index = Index;
8476376Sgblack@eecs.umich.edu                    Ptr->insertAt(NewEntry, Random, SP);
8484661Sksewell@umich.edu                }});
8492101SN/A
8505222Sksewell@umich.edu                0x08: tlbp({{
8516376Sgblack@eecs.umich.edu                    Config3Reg config3 = Config3;
8526376Sgblack@eecs.umich.edu                    PageGrainReg pageGrain = PageGrain;
8536376Sgblack@eecs.umich.edu                    EntryHiReg entryHi = EntryHi;
8546376Sgblack@eecs.umich.edu                    int TLB_Index;
8556376Sgblack@eecs.umich.edu                    Addr VPN;
8566376Sgblack@eecs.umich.edu                    if (pageGrain.esp == 1 && config3.sp ==1) {
8576376Sgblack@eecs.umich.edu                        VPN = EntryHi >> 11;
8586376Sgblack@eecs.umich.edu                    } else {
8596376Sgblack@eecs.umich.edu                        // Mask off lower 2 bits
8606376Sgblack@eecs.umich.edu                        VPN = ((EntryHi >> 11) & 0xFFFFFFFC);
8616376Sgblack@eecs.umich.edu                    }
8626376Sgblack@eecs.umich.edu                    TLB_Index = xc->tcBase()->getITBPtr()->
8636376Sgblack@eecs.umich.edu                                 probeEntry(VPN, entryHi.asid);
8646376Sgblack@eecs.umich.edu                    // Check TLB for entry matching EntryHi
8656376Sgblack@eecs.umich.edu                    if (TLB_Index != -1) {
8666376Sgblack@eecs.umich.edu                        Index = TLB_Index;
8676376Sgblack@eecs.umich.edu                    } else {
8686376Sgblack@eecs.umich.edu                        // else, set Index = 1 << 31
8696376Sgblack@eecs.umich.edu                        Index = (1 << 31);
8706376Sgblack@eecs.umich.edu                    }
8716376Sgblack@eecs.umich.edu                }});
8724661Sksewell@umich.edu              }
8735222Sksewell@umich.edu              format CP0Unimpl {
8745222Sksewell@umich.edu                0x20: wait();
8755222Sksewell@umich.edu              }
8765222Sksewell@umich.edu               default: CP0Unimpl::unknown();
8774661Sksewell@umich.edu
8782101SN/A            }
8792043SN/A        }
8802027SN/A
8812101SN/A        //Table A-13 MIPS32 COP1 Encoding of rs Field
8822101SN/A        0x1: decode RS_MSB {
8832041SN/A
8842101SN/A            0x0: decode RS_HI {
8852101SN/A                0x0: decode RS_LO {
8862686Sksewell@umich.edu                    format CP1Control {
8872742Sksewell@umich.edu                        0x0: mfc1 ({{ Rt.uw = Fs.uw; }});
8882495SN/A
8892495SN/A                        0x2: cfc1({{
8902573SN/A                            switch (FS)
8912573SN/A                            {
8922573SN/A                              case 0:
8932616SN/A                                Rt = FIR;
8942573SN/A                                break;
8952573SN/A                              case 25:
8962616SN/A                                Rt = 0 | (FCSR & 0xFE000000) >> 24 | (FCSR & 0x00800000) >> 23;
8972573SN/A                                break;
8982573SN/A                              case 26:
8992616SN/A                                Rt = 0 | (FCSR & 0x0003F07C);
9002573SN/A                                break;
9012573SN/A                              case 28:
9022616SN/A                                Rt = 0 | (FCSR & 0x00000F80) | (FCSR & 0x01000000) >> 21 | (FCSR & 0x00000003);
9032573SN/A                                break;
9042573SN/A                              case 31:
9052616SN/A                                Rt = FCSR;
9062573SN/A                                break;
9072573SN/A                              default:
9085222Sksewell@umich.edu                                warn("FP Control Value (%d) Not Valid");
9092573SN/A                            }
9105222Sksewell@umich.edu                            //			    warn("FCSR: %x, FS: %d, FIR: %x, Rt: %x\n",FCSR, FS, FIR, Rt);
9112573SN/A                        }});
9122573SN/A
9132686Sksewell@umich.edu                        0x3: mfhc1({{ Rt.uw = Fs.ud<63:32>;}});
9142686Sksewell@umich.edu
9152686Sksewell@umich.edu                        0x4: mtc1 ({{ Fs.uw = Rt.uw;       }});
9162686Sksewell@umich.edu
9172573SN/A                        0x6: ctc1({{
9182573SN/A                            switch (FS)
9192573SN/A                            {
9202573SN/A                              case 25:
9212616SN/A                                FCSR = 0 | (Rt.uw<7:1> << 25) // move 31...25
9222616SN/A                                    | (FCSR & 0x01000000) // bit 24
9232616SN/A                                    | (FCSR & 0x004FFFFF);// bit 22...0
9242573SN/A                                break;
9252573SN/A
9262573SN/A                              case 26:
9272616SN/A                                FCSR = 0 | (FCSR & 0xFFFC0000) // move 31...18
9282573SN/A                                    | Rt.uw<17:12> << 12           // bit 17...12
9292616SN/A                                    | (FCSR & 0x00000F80) << 7// bit 11...7
9302573SN/A                                    | Rt.uw<6:2> << 2              // bit 6...2
9312616SN/A                                    | (FCSR & 0x00000002);     // bit 1...0
9322573SN/A                                break;
9332573SN/A
9342573SN/A                              case 28:
9352616SN/A                                FCSR = 0 | (FCSR & 0xFE000000) // move 31...25
9362573SN/A                                    | Rt.uw<2:2> << 24       // bit 24
9372616SN/A                                    | (FCSR & 0x00FFF000) << 23// bit 23...12
9382573SN/A                                    | Rt.uw<11:7> << 7       // bit 24
9392616SN/A                                    | (FCSR & 0x000007E)
9402573SN/A                                    | Rt.uw<1:0>;// bit 22...0
9412573SN/A                                break;
9422573SN/A
9432573SN/A                              case 31:
9442616SN/A                                FCSR  = Rt.uw;
9452573SN/A                                break;
9462573SN/A
9472573SN/A                              default:
9482495SN/A                                panic("FP Control Value (%d) Not Available. Ignoring Access to"
9492616SN/A                                      "Floating Control Status Register", FS);
9502495SN/A                            }
9512495SN/A                        }});
9522686Sksewell@umich.edu
9532686Sksewell@umich.edu                        0x7: mthc1({{
9542686Sksewell@umich.edu                             uint64_t fs_hi = Rt.uw;
9552686Sksewell@umich.edu                             uint64_t fs_lo = Fs.ud & 0x0FFFFFFFF;
9562686Sksewell@umich.edu                             Fs.ud = (fs_hi << 32) | fs_lo;
9572686Sksewell@umich.edu                        }});
9582686Sksewell@umich.edu
9592101SN/A                    }
9605222Sksewell@umich.edu                    format CP1Unimpl {
9615222Sksewell@umich.edu                      0x1: dmfc1();
9625222Sksewell@umich.edu                      0x5: dmtc1();
9635222Sksewell@umich.edu                    }
9645222Sksewell@umich.edu                   }
9652025SN/A
9665222Sksewell@umich.edu                0x1:
9675222Sksewell@umich.edu                   decode RS_LO {
9685222Sksewell@umich.edu                     0x0:
9695222Sksewell@umich.edu                     decode ND {
9705222Sksewell@umich.edu                       format Branch {
9715222Sksewell@umich.edu                         0x0: decode TF {
9725222Sksewell@umich.edu                           0x0: bc1f({{ cond = getCondCode(FCSR, BRANCH_CC) == 0;
9735222Sksewell@umich.edu                                       }});
9745222Sksewell@umich.edu                           0x1: bc1t({{ cond = getCondCode(FCSR, BRANCH_CC) == 1;
9755222Sksewell@umich.edu                                       }});
9765222Sksewell@umich.edu                         }
9775222Sksewell@umich.edu                         0x1: decode TF {
9785222Sksewell@umich.edu                           0x0: bc1fl({{ cond = getCondCode(FCSR, BRANCH_CC) == 0;
9795222Sksewell@umich.edu                                        }}, Likely);
9805222Sksewell@umich.edu                           0x1: bc1tl({{ cond = getCondCode(FCSR, BRANCH_CC) == 1;
9815222Sksewell@umich.edu                                        }}, Likely);
9825222Sksewell@umich.edu                         }
9835222Sksewell@umich.edu                       }
9845222Sksewell@umich.edu                     }
9855222Sksewell@umich.edu                   format CP1Unimpl {
9865222Sksewell@umich.edu                     0x1: bc1any2();
9875222Sksewell@umich.edu                     0x2: bc1any4();
9885222Sksewell@umich.edu                     default: unknown();
9895222Sksewell@umich.edu                   }
9905222Sksewell@umich.edu                   }
9912043SN/A            }
9922027SN/A
9932101SN/A            0x1: decode RS_HI {
9942101SN/A                0x2: decode RS_LO {
9952101SN/A                    //Table A-14 MIPS32 COP1 Encoding of Function Field When rs=S
9962686Sksewell@umich.edu                    //(( single-precision floating point))
9972572SN/A                    0x0: decode FUNCTION_HI {
9982572SN/A                        0x0: decode FUNCTION_LO {
9992101SN/A                            format FloatOp {
10002601SN/A                                0x0: add_s({{ Fd.sf = Fs.sf + Ft.sf;}});
10012601SN/A                                0x1: sub_s({{ Fd.sf = Fs.sf - Ft.sf;}});
10022601SN/A                                0x2: mul_s({{ Fd.sf = Fs.sf * Ft.sf;}});
10032601SN/A                                0x3: div_s({{ Fd.sf = Fs.sf / Ft.sf;}});
10042601SN/A                                0x4: sqrt_s({{ Fd.sf = sqrt(Fs.sf);}});
10052601SN/A                                0x5: abs_s({{ Fd.sf = fabs(Fs.sf);}});
10062686Sksewell@umich.edu                                0x7: neg_s({{ Fd.sf = -Fs.sf;}});
10072101SN/A                            }
10082742Sksewell@umich.edu
10092742Sksewell@umich.edu                            0x6: BasicOp::mov_s({{ Fd.sf = Fs.sf;}});
10102101SN/A                        }
10112027SN/A
10122572SN/A                        0x1: decode FUNCTION_LO {
10132686Sksewell@umich.edu                            format FloatConvertOp {
10142686Sksewell@umich.edu                                0x0: round_l_s({{ val = Fs.sf; }}, ToLong,
10152686Sksewell@umich.edu                                               Round);
10162686Sksewell@umich.edu                                0x1: trunc_l_s({{ val = Fs.sf; }}, ToLong,
10172686Sksewell@umich.edu                                               Trunc);
10182686Sksewell@umich.edu                                0x2: ceil_l_s({{ val = Fs.sf; }}, ToLong,
10192686Sksewell@umich.edu                                               Ceil);
10202686Sksewell@umich.edu                                0x3: floor_l_s({{ val = Fs.sf; }}, ToLong,
10212686Sksewell@umich.edu                                               Floor);
10222686Sksewell@umich.edu                                0x4: round_w_s({{ val = Fs.sf; }}, ToWord,
10232686Sksewell@umich.edu                                               Round);
10242686Sksewell@umich.edu                                0x5: trunc_w_s({{ val = Fs.sf; }}, ToWord,
10252686Sksewell@umich.edu                                               Trunc);
10262686Sksewell@umich.edu                                0x6: ceil_w_s({{ val = Fs.sf; }}, ToWord,
10272686Sksewell@umich.edu                                               Ceil);
10282686Sksewell@umich.edu                                0x7: floor_w_s({{ val = Fs.sf; }}, ToWord,
10292686Sksewell@umich.edu                                               Floor);
10302101SN/A                            }
10312101SN/A                        }
10322027SN/A
10332572SN/A                        0x2: decode FUNCTION_LO {
10342101SN/A                            0x1: decode MOVCF {
10352686Sksewell@umich.edu                                format BasicOp {
10362686Sksewell@umich.edu                                    0x0: movf_s({{ Fd = (getCondCode(FCSR,CC) == 0) ? Fs : Fd; }});
10372686Sksewell@umich.edu                                    0x1: movt_s({{ Fd = (getCondCode(FCSR,CC) == 1) ? Fs : Fd; }});
10382101SN/A                                }
10392101SN/A                            }
10402027SN/A
10412686Sksewell@umich.edu                            format BasicOp {
10422686Sksewell@umich.edu                                0x2: movz_s({{ Fd = (Rt == 0) ? Fs : Fd; }});
10432686Sksewell@umich.edu                                0x3: movn_s({{ Fd = (Rt != 0) ? Fs : Fd; }});
10442686Sksewell@umich.edu                            }
10452686Sksewell@umich.edu
10462602SN/A                            format FloatOp {
10472602SN/A                                0x5: recip_s({{ Fd = 1 / Fs; }});
10482602SN/A                                0x6: rsqrt_s({{ Fd = 1 / sqrt(Fs);}});
10492101SN/A                            }
10505222Sksewell@umich.edu                            format CP1Unimpl {
10515222Sksewell@umich.edu                              default: unknown();
10525222Sksewell@umich.edu                            }
10532101SN/A                        }
10545222Sksewell@umich.edu                        0x3: CP1Unimpl::unknown();
10552027SN/A
10562572SN/A                        0x4: decode FUNCTION_LO {
10572603SN/A                            format FloatConvertOp {
10582686Sksewell@umich.edu                                0x1: cvt_d_s({{ val = Fs.sf; }}, ToDouble);
10592686Sksewell@umich.edu                                0x4: cvt_w_s({{ val = Fs.sf; }}, ToWord);
10602686Sksewell@umich.edu                                0x5: cvt_l_s({{ val = Fs.sf; }}, ToLong);
10612101SN/A                            }
10622055SN/A
10632686Sksewell@umich.edu                            0x6: FloatOp::cvt_ps_s({{
10642686Sksewell@umich.edu                                    Fd.ud = (uint64_t) Fs.uw << 32 |
10652686Sksewell@umich.edu                                            (uint64_t) Ft.uw;
10662101SN/A                                }});
10675222Sksewell@umich.edu                            format CP1Unimpl {
10685222Sksewell@umich.edu                              default: unknown();
10695222Sksewell@umich.edu                            }
10702101SN/A                        }
10715222Sksewell@umich.edu                        0x5: CP1Unimpl::unknown();
10722602SN/A
10732602SN/A                        0x6: decode FUNCTION_LO {
10742603SN/A                            format FloatCompareOp {
10752686Sksewell@umich.edu                                0x0: c_f_s({{ cond = 0; }}, SinglePrecision,
10762686Sksewell@umich.edu                                           UnorderedFalse);
10772686Sksewell@umich.edu                                0x1: c_un_s({{ cond = 0; }}, SinglePrecision,
10782686Sksewell@umich.edu                                            UnorderedTrue);
10792686Sksewell@umich.edu                                0x2: c_eq_s({{ cond = (Fs.sf == Ft.sf); }},
10802686Sksewell@umich.edu                                            UnorderedFalse);
10812686Sksewell@umich.edu                                0x3: c_ueq_s({{ cond = (Fs.sf == Ft.sf); }},
10822686Sksewell@umich.edu                                             UnorderedTrue);
10832686Sksewell@umich.edu                                0x4: c_olt_s({{ cond = (Fs.sf < Ft.sf);	}},
10842686Sksewell@umich.edu                                             UnorderedFalse);
10852686Sksewell@umich.edu                                0x5: c_ult_s({{ cond = (Fs.sf < Ft.sf); }},
10862686Sksewell@umich.edu                                             UnorderedTrue);
10872686Sksewell@umich.edu                                0x6: c_ole_s({{ cond = (Fs.sf <= Ft.sf); }},
10882686Sksewell@umich.edu                                             UnorderedFalse);
10892686Sksewell@umich.edu                                0x7: c_ule_s({{ cond = (Fs.sf <= Ft.sf); }},
10902686Sksewell@umich.edu                                             UnorderedTrue);
10912602SN/A                            }
10922602SN/A                        }
10932602SN/A
10942602SN/A                        0x7: decode FUNCTION_LO {
10952686Sksewell@umich.edu                            format FloatCompareOp {
10962686Sksewell@umich.edu                                0x0: c_sf_s({{ cond = 0; }}, SinglePrecision,
10972686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
10982686Sksewell@umich.edu                                0x1: c_ngle_s({{ cond = 0; }}, SinglePrecision,
10992686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
11002686Sksewell@umich.edu                                0x2: c_seq_s({{ cond = (Fs.sf == Ft.sf);}},
11012686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
11022686Sksewell@umich.edu                                0x3: c_ngl_s({{ cond = (Fs.sf == Ft.sf); }},
11032686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
11042686Sksewell@umich.edu                                0x4: c_lt_s({{ cond = (Fs.sf < Ft.sf); }},
11052686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
11062686Sksewell@umich.edu                                0x5: c_nge_s({{ cond = (Fs.sf < Ft.sf); }},
11072686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
11082686Sksewell@umich.edu                                0x6: c_le_s({{ cond = (Fs.sf <= Ft.sf); }},
11092686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
11102686Sksewell@umich.edu                                0x7: c_ngt_s({{ cond = (Fs.sf <= Ft.sf); }},
11112686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
11122602SN/A                            }
11132602SN/A                        }
11142101SN/A                    }
11152055SN/A
11162101SN/A                    //Table A-15 MIPS32 COP1 Encoding of Function Field When rs=D
11172572SN/A                    0x1: decode FUNCTION_HI {
11182572SN/A                        0x0: decode FUNCTION_LO {
11192101SN/A                            format FloatOp {
11202686Sksewell@umich.edu                                0x0: add_d({{ Fd.df = Fs.df + Ft.df; }});
11212686Sksewell@umich.edu                                0x1: sub_d({{ Fd.df = Fs.df - Ft.df; }});
11222686Sksewell@umich.edu                                0x2: mul_d({{ Fd.df = Fs.df * Ft.df; }});
11232686Sksewell@umich.edu                                0x3: div_d({{ Fd.df = Fs.df / Ft.df; }});
11242686Sksewell@umich.edu                                0x4: sqrt_d({{ Fd.df = sqrt(Fs.df);  }});
11252686Sksewell@umich.edu                                0x5: abs_d({{ Fd.df = fabs(Fs.df);   }});
11262686Sksewell@umich.edu                                0x7: neg_d({{ Fd.df = -1 * Fs.df;    }});
11272101SN/A                            }
11282742Sksewell@umich.edu
11292742Sksewell@umich.edu                            0x6: BasicOp::mov_d({{ Fd.df = Fs.df;    }});
11302101SN/A                        }
11312027SN/A
11322572SN/A                        0x1: decode FUNCTION_LO {
11332686Sksewell@umich.edu                            format FloatConvertOp {
11342686Sksewell@umich.edu                                0x0: round_l_d({{ val = Fs.df; }}, ToLong,
11352686Sksewell@umich.edu                                               Round);
11362686Sksewell@umich.edu                                0x1: trunc_l_d({{ val = Fs.df; }}, ToLong,
11372686Sksewell@umich.edu                                               Trunc);
11382686Sksewell@umich.edu                                0x2: ceil_l_d({{ val = Fs.df; }}, ToLong,
11392686Sksewell@umich.edu                                               Ceil);
11402686Sksewell@umich.edu                                0x3: floor_l_d({{ val = Fs.df; }}, ToLong,
11412686Sksewell@umich.edu                                               Floor);
11422686Sksewell@umich.edu                                0x4: round_w_d({{ val = Fs.df; }}, ToWord,
11432686Sksewell@umich.edu                                               Round);
11442686Sksewell@umich.edu                                0x5: trunc_w_d({{ val = Fs.df; }}, ToWord,
11452686Sksewell@umich.edu                                               Trunc);
11462686Sksewell@umich.edu                                0x6: ceil_w_d({{ val = Fs.df; }}, ToWord,
11472686Sksewell@umich.edu                                               Ceil);
11482686Sksewell@umich.edu                                0x7: floor_w_d({{ val = Fs.df; }}, ToWord,
11492686Sksewell@umich.edu                                               Floor);
11502101SN/A                            }
11512101SN/A                        }
11522027SN/A
11532572SN/A                        0x2: decode FUNCTION_LO {
11542101SN/A                            0x1: decode MOVCF {
11552686Sksewell@umich.edu                                format BasicOp {
11562686Sksewell@umich.edu                                    0x0: movf_d({{ Fd.df = (getCondCode(FCSR,CC) == 0) ?
11572686Sksewell@umich.edu                                                       Fs.df : Fd.df;
11582686Sksewell@umich.edu                                                }});
11592686Sksewell@umich.edu                                    0x1: movt_d({{ Fd.df = (getCondCode(FCSR,CC) == 1) ?
11602686Sksewell@umich.edu                                                       Fs.df : Fd.df;
11612686Sksewell@umich.edu                                                }});
11622101SN/A                                }
11632101SN/A                            }
11642027SN/A
11652101SN/A                            format BasicOp {
11662686Sksewell@umich.edu                                0x2: movz_d({{ Fd.df = (Rt == 0) ? Fs.df : Fd.df; }});
11672686Sksewell@umich.edu                                0x3: movn_d({{ Fd.df = (Rt != 0) ? Fs.df : Fd.df; }});
11682101SN/A                            }
11692027SN/A
11702605SN/A                            format FloatOp {
11712686Sksewell@umich.edu                                0x5: recip_d({{ Fd.df = 1 / Fs.df }});
11722605SN/A                                0x6: rsqrt_d({{ Fd.df = 1 / sqrt(Fs.df) }});
11732101SN/A                            }
11745222Sksewell@umich.edu                            format CP1Unimpl {
11755222Sksewell@umich.edu                              default: unknown();
11765222Sksewell@umich.edu                            }
11775222Sksewell@umich.edu
11782101SN/A                        }
11792572SN/A                        0x4: decode FUNCTION_LO {
11802686Sksewell@umich.edu                            format FloatConvertOp {
11812686Sksewell@umich.edu                                0x0: cvt_s_d({{ val = Fs.df; }}, ToSingle);
11822686Sksewell@umich.edu                                0x4: cvt_w_d({{ val = Fs.df; }}, ToWord);
11832686Sksewell@umich.edu                                0x5: cvt_l_d({{ val = Fs.df; }}, ToLong);
11842101SN/A                            }
11855222Sksewell@umich.edu                           default: CP1Unimpl::unknown();
11862101SN/A                        }
11872602SN/A
11882602SN/A                        0x6: decode FUNCTION_LO {
11892604SN/A                            format FloatCompareOp {
11902686Sksewell@umich.edu                                0x0: c_f_d({{ cond = 0; }}, DoublePrecision,
11912686Sksewell@umich.edu                                           UnorderedFalse);
11922686Sksewell@umich.edu                                0x1: c_un_d({{ cond = 0; }}, DoublePrecision,
11932686Sksewell@umich.edu                                            UnorderedTrue);
11942686Sksewell@umich.edu                                0x2: c_eq_d({{ cond = (Fs.df == Ft.df); }},
11952686Sksewell@umich.edu                                            UnorderedFalse);
11962686Sksewell@umich.edu                                0x3: c_ueq_d({{ cond = (Fs.df == Ft.df); }},
11972686Sksewell@umich.edu                                             UnorderedTrue);
11982686Sksewell@umich.edu                                0x4: c_olt_d({{ cond = (Fs.df < Ft.df);	}},
11992686Sksewell@umich.edu                                             UnorderedFalse);
12002686Sksewell@umich.edu                                0x5: c_ult_d({{ cond = (Fs.df < Ft.df); }},
12012686Sksewell@umich.edu                                             UnorderedTrue);
12022686Sksewell@umich.edu                                0x6: c_ole_d({{ cond = (Fs.df <= Ft.df); }},
12032686Sksewell@umich.edu                                             UnorderedFalse);
12042686Sksewell@umich.edu                                0x7: c_ule_d({{ cond = (Fs.df <= Ft.df); }},
12052686Sksewell@umich.edu                                             UnorderedTrue);
12062602SN/A                            }
12072602SN/A                        }
12082602SN/A
12092602SN/A                        0x7: decode FUNCTION_LO {
12102686Sksewell@umich.edu                            format FloatCompareOp {
12112686Sksewell@umich.edu                                0x0: c_sf_d({{ cond = 0; }}, DoublePrecision,
12122686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
12132686Sksewell@umich.edu                                0x1: c_ngle_d({{ cond = 0; }}, DoublePrecision,
12142686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
12152686Sksewell@umich.edu                                0x2: c_seq_d({{ cond = (Fs.df == Ft.df); }},
12162686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
12172686Sksewell@umich.edu                                0x3: c_ngl_d({{ cond = (Fs.df == Ft.df); }},
12182686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
12192686Sksewell@umich.edu                                0x4: c_lt_d({{ cond = (Fs.df < Ft.df); }},
12202686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
12212686Sksewell@umich.edu                                0x5: c_nge_d({{ cond = (Fs.df < Ft.df); }},
12222686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
12232686Sksewell@umich.edu                                0x6: c_le_d({{ cond = (Fs.df <= Ft.df); }},
12242686Sksewell@umich.edu                                            UnorderedFalse, QnanException);
12252686Sksewell@umich.edu                                0x7: c_ngt_d({{ cond = (Fs.df <= Ft.df); }},
12262686Sksewell@umich.edu                                             UnorderedTrue, QnanException);
12272602SN/A                            }
12282602SN/A                        }
12295222Sksewell@umich.edu                       default: CP1Unimpl::unknown();
12302101SN/A                    }
12315222Sksewell@umich.edu                    0x2: CP1Unimpl::unknown();
12325222Sksewell@umich.edu                    0x3: CP1Unimpl::unknown();
12335222Sksewell@umich.edu                    0x7: CP1Unimpl::unknown();
12342027SN/A
12352101SN/A                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=W
12362101SN/A                    0x4: decode FUNCTION {
12372605SN/A                        format FloatConvertOp {
12382686Sksewell@umich.edu                            0x20: cvt_s_w({{ val = Fs.uw; }}, ToSingle);
12392686Sksewell@umich.edu                            0x21: cvt_d_w({{ val = Fs.uw; }}, ToDouble);
12405222Sksewell@umich.edu                            0x26: CP1Unimpl::cvt_ps_w();
12412101SN/A                        }
12425222Sksewell@umich.edu                       default: CP1Unimpl::unknown();
12432101SN/A                    }
12442027SN/A
12452101SN/A                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=L1
12462101SN/A                    //Note: "1. Format type L is legal only if 64-bit floating point operations
12472101SN/A                    //are enabled."
12482101SN/A                    0x5: decode FUNCTION_HI {
12492686Sksewell@umich.edu                        format FloatConvertOp {
12502686Sksewell@umich.edu                            0x20: cvt_s_l({{ val = Fs.ud; }}, ToSingle);
12512686Sksewell@umich.edu                            0x21: cvt_d_l({{ val = Fs.ud; }}, ToDouble);
12525222Sksewell@umich.edu                            0x26: CP1Unimpl::cvt_ps_l();
12532101SN/A                        }
12545222Sksewell@umich.edu                       default: CP1Unimpl::unknown();
12552101SN/A                    }
12562101SN/A
12572101SN/A                    //Table A-17 MIPS64 COP1 Encoding of Function Field When rs=PS1
12582101SN/A                    //Note: "1. Format type PS is legal only if 64-bit floating point operations
12592101SN/A                    //are enabled. "
12602572SN/A                    0x6: decode FUNCTION_HI {
12612572SN/A                        0x0: decode FUNCTION_LO {
12622101SN/A                            format Float64Op {
12632605SN/A                                0x0: add_ps({{
12642607SN/A                                    Fd1.sf = Fs1.sf + Ft2.sf;
12652607SN/A                                    Fd2.sf = Fs2.sf + Ft2.sf;
12662101SN/A                                }});
12672605SN/A                                0x1: sub_ps({{
12682607SN/A                                    Fd1.sf = Fs1.sf - Ft2.sf;
12692607SN/A                                    Fd2.sf = Fs2.sf - Ft2.sf;
12702101SN/A                                }});
12712605SN/A                                0x2: mul_ps({{
12722607SN/A                                    Fd1.sf = Fs1.sf * Ft2.sf;
12732607SN/A                                    Fd2.sf = Fs2.sf * Ft2.sf;
12742101SN/A                                }});
12752605SN/A                                0x5: abs_ps({{
12762607SN/A                                    Fd1.sf = fabs(Fs1.sf);
12772607SN/A                                    Fd2.sf = fabs(Fs2.sf);
12782101SN/A                                }});
12792605SN/A                                0x6: mov_ps({{
12802607SN/A                                    Fd1.sf = Fs1.sf;
12812607SN/A                                    Fd2.sf = Fs2.sf;
12822101SN/A                                }});
12832605SN/A                                0x7: neg_ps({{
12842686Sksewell@umich.edu                                    Fd1.sf = -(Fs1.sf);
12852686Sksewell@umich.edu                                    Fd2.sf = -(Fs2.sf);
12862101SN/A                                }});
12875222Sksewell@umich.edu                            default: CP1Unimpl::unknown();
12882101SN/A                            }
12892101SN/A                        }
12905222Sksewell@umich.edu                        0x1: CP1Unimpl::unknown();
12912572SN/A                        0x2: decode FUNCTION_LO {
12922101SN/A                            0x1: decode MOVCF {
12932101SN/A                                format Float64Op {
12942607SN/A                                    0x0: movf_ps({{
12952686Sksewell@umich.edu                                        Fd1 = (getCondCode(FCSR, CC) == 0) ?
12962686Sksewell@umich.edu                                            Fs1 : Fd1;
12972686Sksewell@umich.edu                                        Fd2 = (getCondCode(FCSR, CC+1) == 0) ?
12982686Sksewell@umich.edu                                            Fs2 : Fd2;
12992607SN/A                                    }});
13002607SN/A                                    0x1: movt_ps({{
13012686Sksewell@umich.edu                                        Fd2 = (getCondCode(FCSR, CC) == 1) ?
13022686Sksewell@umich.edu                                            Fs1 : Fd1;
13032686Sksewell@umich.edu                                        Fd2 = (getCondCode(FCSR, CC+1) == 1) ?
13042686Sksewell@umich.edu                                            Fs2 : Fd2;
13052607SN/A                                    }});
13062101SN/A                                }
13072101SN/A                            }
13082101SN/A
13092605SN/A                            format Float64Op {
13102607SN/A                                0x2: movz_ps({{
13112686Sksewell@umich.edu                                    Fd1 = (getCondCode(FCSR, CC) == 0) ?
13122686Sksewell@umich.edu                                        Fs1 : Fd1;
13132686Sksewell@umich.edu                                    Fd2 = (getCondCode(FCSR, CC) == 0) ?
13142686Sksewell@umich.edu                                        Fs2 : Fd2;
13152607SN/A                                }});
13162607SN/A                                0x3: movn_ps({{
13172686Sksewell@umich.edu                                    Fd1 = (getCondCode(FCSR, CC) == 1) ?
13182686Sksewell@umich.edu                                        Fs1 : Fd1;
13192686Sksewell@umich.edu                                    Fd2 = (getCondCode(FCSR, CC) == 1) ?
13202686Sksewell@umich.edu                                        Fs2 : Fd2;
13212607SN/A                                }});
13222135SN/A                            }
13235222Sksewell@umich.edu                           default: CP1Unimpl::unknown();
13242135SN/A
13252101SN/A                        }
13265222Sksewell@umich.edu                        0x3: CP1Unimpl::unknown();
13272572SN/A                        0x4: decode FUNCTION_LO {
13282686Sksewell@umich.edu                            0x0: FloatOp::cvt_s_pu({{ Fd.sf = Fs2.sf; }});
13295222Sksewell@umich.edu                            default: CP1Unimpl::unknown();
13302101SN/A                        }
13312101SN/A
13322572SN/A                        0x5: decode FUNCTION_LO {
13332686Sksewell@umich.edu                            0x0: FloatOp::cvt_s_pl({{ Fd.sf = Fs1.sf; }});
13342686Sksewell@umich.edu
13352101SN/A                            format Float64Op {
13362686Sksewell@umich.edu                                0x4: pll({{ Fd.ud = (uint64_t) Fs1.uw << 32 |
13372686Sksewell@umich.edu                                                    Ft1.uw;
13382686Sksewell@umich.edu                                         }});
13392686Sksewell@umich.edu                                0x5: plu({{ Fd.ud = (uint64_t) Fs1.uw << 32 |
13402686Sksewell@umich.edu                                                    Ft2.uw;
13412686Sksewell@umich.edu                                         }});
13422686Sksewell@umich.edu                                0x6: pul({{ Fd.ud = (uint64_t) Fs2.uw << 32 |
13432686Sksewell@umich.edu                                                    Ft1.uw;
13442686Sksewell@umich.edu                                         }});
13452686Sksewell@umich.edu                                0x7: puu({{ Fd.ud = (uint64_t) Fs2.uw << 32 |
13462686Sksewell@umich.edu                                                    Ft2.uw;
13472686Sksewell@umich.edu                                         }});
13482101SN/A                            }
13495222Sksewell@umich.edu                            default: CP1Unimpl::unknown();
13502101SN/A                        }
13512602SN/A
13522602SN/A                        0x6: decode FUNCTION_LO {
13532608SN/A                            format FloatPSCompareOp {
13542686Sksewell@umich.edu                                0x0: c_f_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
13552686Sksewell@umich.edu                                            UnorderedFalse);
13562686Sksewell@umich.edu                                0x1: c_un_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
13572686Sksewell@umich.edu                                             UnorderedTrue);
13582686Sksewell@umich.edu                                0x2: c_eq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13592686Sksewell@umich.edu                                             {{ cond2 = (Fs2.sf == Ft2.sf); }},
13602686Sksewell@umich.edu                                             UnorderedFalse);
13612686Sksewell@umich.edu                                0x3: c_ueq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13622686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
13632686Sksewell@umich.edu                                              UnorderedTrue);
13642686Sksewell@umich.edu                                0x4: c_olt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
13652686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
13662686Sksewell@umich.edu                                              UnorderedFalse);
13672686Sksewell@umich.edu                                0x5: c_ult_ps({{ cond1 = (Fs.sf < Ft.sf); }},
13682686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
13692686Sksewell@umich.edu                                              UnorderedTrue);
13702686Sksewell@umich.edu                                0x6: c_ole_ps({{ cond1 = (Fs.sf <= Ft.sf); }},
13712686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
13722686Sksewell@umich.edu                                              UnorderedFalse);
13732686Sksewell@umich.edu                                0x7: c_ule_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
13742686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
13752686Sksewell@umich.edu                                              UnorderedTrue);
13762602SN/A                            }
13772602SN/A                        }
13782602SN/A
13792602SN/A                        0x7: decode FUNCTION_LO {
13802686Sksewell@umich.edu                            format FloatPSCompareOp {
13812686Sksewell@umich.edu                                0x0: c_sf_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
13822686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
13832686Sksewell@umich.edu                                0x1: c_ngle_ps({{ cond1 = 0; }},
13842686Sksewell@umich.edu                                               {{ cond2 = 0; }},
13852686Sksewell@umich.edu                                               UnorderedTrue, QnanException);
13862686Sksewell@umich.edu                                0x2: c_seq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13872686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
13882686Sksewell@umich.edu                                              UnorderedFalse, QnanException);
13892686Sksewell@umich.edu                                0x3: c_ngl_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
13902686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
13912686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
13922686Sksewell@umich.edu                                0x4: c_lt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
13932686Sksewell@umich.edu                                             {{ cond2 = (Fs2.sf < Ft2.sf); }},
13942686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
13952686Sksewell@umich.edu                                0x5: c_nge_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
13962686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
13972686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
13982686Sksewell@umich.edu                                0x6: c_le_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
13992686Sksewell@umich.edu                                             {{ cond2 = (Fs2.sf <= Ft2.sf); }},
14002686Sksewell@umich.edu                                             UnorderedFalse, QnanException);
14012686Sksewell@umich.edu                                0x7: c_ngt_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
14022686Sksewell@umich.edu                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
14032686Sksewell@umich.edu                                              UnorderedTrue, QnanException);
14042602SN/A                            }
14052602SN/A                        }
14062101SN/A                    }
14072101SN/A                }
14085222Sksewell@umich.edu               default: CP1Unimpl::unknown();
14092101SN/A            }
14102101SN/A        }
14112101SN/A
14122101SN/A        //Table A-19 MIPS32 COP2 Encoding of rs Field
14132101SN/A        0x2: decode RS_MSB {
14145222Sksewell@umich.edu            format CP2Unimpl {
14152686Sksewell@umich.edu                0x0: decode RS_HI {
14162686Sksewell@umich.edu                    0x0: decode RS_LO {
14172101SN/A                        0x0: mfc2();
14182101SN/A                        0x2: cfc2();
14192101SN/A                        0x3: mfhc2();
14202101SN/A                        0x4: mtc2();
14212101SN/A                        0x6: ctc2();
14222101SN/A                        0x7: mftc2();
14235222Sksewell@umich.edu                       default: unknown();
14242101SN/A                    }
14252101SN/A
14262686Sksewell@umich.edu                    0x1: decode ND {
14272686Sksewell@umich.edu                        0x0: decode TF {
14282101SN/A                            0x0: bc2f();
14292101SN/A                            0x1: bc2t();
14305222Sksewell@umich.edu                           default: unknown();
14312101SN/A                        }
14322101SN/A
14332686Sksewell@umich.edu                        0x1: decode TF {
14342101SN/A                            0x0: bc2fl();
14352101SN/A                            0x1: bc2tl();
14365222Sksewell@umich.edu                           default: unknown();
14372101SN/A                        }
14385222Sksewell@umich.edu                       default: unknown();
14395222Sksewell@umich.edu
14405222Sksewell@umich.edu                       }
14415222Sksewell@umich.edu              default: unknown();
14425222Sksewell@umich.edu
14435222Sksewell@umich.edu              }
14445222Sksewell@umich.edu            default: unknown();
14452101SN/A            }
14462101SN/A        }
14472101SN/A
14482101SN/A        //Table A-20 MIPS64 COP1X Encoding of Function Field 1
14492101SN/A        //Note: "COP1X instructions are legal only if 64-bit floating point
14502101SN/A        //operations are enabled."
14512101SN/A        0x3: decode FUNCTION_HI {
14522101SN/A            0x0: decode FUNCTION_LO {
14532686Sksewell@umich.edu                format LoadIndexedMemory {
14542742Sksewell@umich.edu                    0x0: lwxc1({{ Fd.uw = Mem.uw;}});
14552742Sksewell@umich.edu                    0x1: ldxc1({{ Fd.ud = Mem.ud;}});
14562750Sksewell@umich.edu                    0x5: luxc1({{ Fd.ud = Mem.ud;}},
14572742Sksewell@umich.edu                               {{ EA = (Rs + Rt) & ~7; }});
14582101SN/A                }
14592043SN/A            }
14602027SN/A
14612101SN/A            0x1: decode FUNCTION_LO {
14622686Sksewell@umich.edu                format StoreIndexedMemory {
14632742Sksewell@umich.edu                    0x0: swxc1({{ Mem.uw = Fs.uw;}});
14642742Sksewell@umich.edu                    0x1: sdxc1({{ Mem.ud = Fs.ud;}});
14652742Sksewell@umich.edu                    0x5: suxc1({{ Mem.ud = Fs.ud;}},
14662742Sksewell@umich.edu                               {{ EA = (Rs + Rt) & ~7; }});
14672046SN/A                }
14682084SN/A
14692686Sksewell@umich.edu                0x7: Prefetch::prefx({{ EA = Rs + Rt; }});
14702101SN/A            }
14712027SN/A
14722686Sksewell@umich.edu            0x3: decode FUNCTION_LO {
14732686Sksewell@umich.edu                0x6: Float64Op::alnv_ps({{ if (Rs<2:0> == 0) {
14742686Sksewell@umich.edu                                               Fd.ud = Fs.ud;
14752686Sksewell@umich.edu                                           } else if (Rs<2:0> == 4) {
14762686Sksewell@umich.edu                                             #if BYTE_ORDER == BIG_ENDIAN
14772686Sksewell@umich.edu                                               Fd.ud = Fs.ud<31:0> << 32 |
14782686Sksewell@umich.edu                                                       Ft.ud<63:32>;
14792686Sksewell@umich.edu                                             #elif BYTE_ORDER == LITTLE_ENDIAN
14802686Sksewell@umich.edu                                               Fd.ud = Ft.ud<31:0> << 32 |
14812686Sksewell@umich.edu                                                       Fs.ud<63:32>;
14822686Sksewell@umich.edu                                             #endif
14832686Sksewell@umich.edu                                           } else {
14842686Sksewell@umich.edu                                               Fd.ud = Fd.ud;
14852686Sksewell@umich.edu                                           }
14862686Sksewell@umich.edu                                        }});
14872686Sksewell@umich.edu            }
14882027SN/A
14892686Sksewell@umich.edu            format FloatAccOp {
14902686Sksewell@umich.edu                0x4: decode FUNCTION_LO {
14912686Sksewell@umich.edu                    0x0: madd_s({{ Fd.sf = (Fs.sf * Ft.sf) + Fr.sf; }});
14922686Sksewell@umich.edu                    0x1: madd_d({{ Fd.df = (Fs.df * Ft.df) + Fr.df; }});
14932686Sksewell@umich.edu                    0x6: madd_ps({{
14942686Sksewell@umich.edu                        Fd1.sf = (Fs1.df * Ft1.df) + Fr1.df;
14952686Sksewell@umich.edu                        Fd2.sf = (Fs2.df * Ft2.df) + Fr2.df;
14962686Sksewell@umich.edu                    }});
14972686Sksewell@umich.edu                }
14982027SN/A
14992686Sksewell@umich.edu                0x5: decode FUNCTION_LO {
15002686Sksewell@umich.edu                    0x0: msub_s({{ Fd.sf = (Fs.sf * Ft.sf) - Fr.sf; }});
15012686Sksewell@umich.edu                    0x1: msub_d({{ Fd.df = (Fs.df * Ft.df) - Fr.df; }});
15022686Sksewell@umich.edu                    0x6: msub_ps({{
15032686Sksewell@umich.edu                        Fd1.sf = (Fs1.df * Ft1.df) - Fr1.df;
15042686Sksewell@umich.edu                        Fd2.sf = (Fs2.df * Ft2.df) - Fr2.df;
15052686Sksewell@umich.edu                    }});
15062686Sksewell@umich.edu                }
15072027SN/A
15082686Sksewell@umich.edu                0x6: decode FUNCTION_LO {
15092686Sksewell@umich.edu                    0x0: nmadd_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }});
15102686Sksewell@umich.edu                    0x1: nmadd_d({{ Fd.df = (-1 * Fs.df * Ft.df) + Fr.df; }});
15112686Sksewell@umich.edu                    0x6: nmadd_ps({{
15122686Sksewell@umich.edu                        Fd1.sf = -((Fs1.df * Ft1.df) + Fr1.df);
15132686Sksewell@umich.edu                        Fd2.sf = -((Fs2.df * Ft2.df) + Fr2.df);
15142686Sksewell@umich.edu                    }});
15152686Sksewell@umich.edu                }
15162027SN/A
15172686Sksewell@umich.edu                0x7: decode FUNCTION_LO {
15182686Sksewell@umich.edu                    0x0: nmsub_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }});
15192686Sksewell@umich.edu                    0x1: nmsub_d({{ Fd.df = (-1 * Fs.df * Ft.df) - Fr.df; }});
15202686Sksewell@umich.edu                    0x6: nmsub_ps({{
15212686Sksewell@umich.edu                        Fd1.sf = -((Fs1.df * Ft1.df) - Fr1.df);
15222686Sksewell@umich.edu                        Fd2.sf = -((Fs2.df * Ft2.df) - Fr2.df);
15232686Sksewell@umich.edu                    }});
15242046SN/A                }
15252686Sksewell@umich.edu
15262101SN/A            }
15272043SN/A        }
15282025SN/A
15292686Sksewell@umich.edu        format Branch {
15302686Sksewell@umich.edu            0x4: beql({{ cond = (Rs.sw == Rt.sw); }}, Likely);
15312686Sksewell@umich.edu            0x5: bnel({{ cond = (Rs.sw != Rt.sw); }}, Likely);
15322686Sksewell@umich.edu            0x6: blezl({{ cond = (Rs.sw <= 0); }}, Likely);
15332686Sksewell@umich.edu            0x7: bgtzl({{ cond = (Rs.sw > 0); }}, Likely);
15342046SN/A        }
15352084SN/A    }
15362024SN/A
15372686Sksewell@umich.edu    0x3: decode OPCODE_LO {
15382043SN/A        //Table A-5 MIPS32 SPECIAL2 Encoding of Function Field
15392043SN/A        0x4: decode FUNCTION_HI {
15402686Sksewell@umich.edu            0x0: decode FUNCTION_LO {
15412686Sksewell@umich.edu                0x2: IntOp::mul({{ int64_t temp1 = Rs.sd * Rt.sd;
15424661Sksewell@umich.edu                                   Rd.sw = temp1<31:0>;
15435222Sksewell@umich.edu                                }}, IntMultOp);
15442027SN/A
15454661Sksewell@umich.edu                format HiLoRdSelValOp {
15465222Sksewell@umich.edu                  0x0: madd({{ val = ((int64_t)HI_RD_SEL << 32 | LO_RD_SEL) + (Rs.sd * Rt.sd); }}, IntMultOp);
15475222Sksewell@umich.edu                    0x1: maddu({{ val = ((uint64_t)HI_RD_SEL << 32 | LO_RD_SEL) + (Rs.ud * Rt.ud); }}, IntMultOp);
15485222Sksewell@umich.edu                    0x4: msub({{ val = ((int64_t)HI_RD_SEL << 32 | LO_RD_SEL) - (Rs.sd * Rt.sd); }}, IntMultOp);
15495222Sksewell@umich.edu                    0x5: msubu({{ val = ((uint64_t)HI_RD_SEL << 32 | LO_RD_SEL) - (Rs.ud * Rt.ud); }}, IntMultOp);
15502043SN/A                }
15512043SN/A            }
15522027SN/A
15532043SN/A            0x4: decode FUNCTION_LO {
15542101SN/A                format BasicOp {
15552686Sksewell@umich.edu                    0x0: clz({{ int cnt = 32;
15564661Sksewell@umich.edu                          for (int idx = 31; idx >= 0; idx--) {
15574661Sksewell@umich.edu                              if( Rs<idx:idx> == 1) {
15584661Sksewell@umich.edu                                  cnt = 31 - idx;
15594661Sksewell@umich.edu                                  break;
15604661Sksewell@umich.edu                              }
15614661Sksewell@umich.edu                          }
15624661Sksewell@umich.edu                          Rd.uw = cnt;
15634661Sksewell@umich.edu                       }});
15642686Sksewell@umich.edu                    0x1: clo({{ int cnt = 32;
15654661Sksewell@umich.edu                          for (int idx = 31; idx >= 0; idx--) {
15664661Sksewell@umich.edu                              if( Rs<idx:idx> == 0) {
15674661Sksewell@umich.edu                                  cnt = 31 - idx;
15684661Sksewell@umich.edu                                  break;
15694661Sksewell@umich.edu                              }
15704661Sksewell@umich.edu                          }
15714661Sksewell@umich.edu                          Rd.uw = cnt;
15724661Sksewell@umich.edu                        }});
15732101SN/A                }
15742043SN/A            }
15752027SN/A
15762043SN/A            0x7: decode FUNCTION_LO {
15772686Sksewell@umich.edu                0x7: FailUnimpl::sdbbp();
15782043SN/A            }
15792043SN/A        }
15802024SN/A
15812686Sksewell@umich.edu        //Table A-6 MIPS32 SPECIAL3 Encoding of Function Field for Release 2
15822686Sksewell@umich.edu        //of the Architecture
15832043SN/A        0x7: decode FUNCTION_HI {
15842101SN/A            0x0: decode FUNCTION_LO {
15852686Sksewell@umich.edu                format BasicOp {
15862742Sksewell@umich.edu                    0x0: ext({{ Rt.uw = bits(Rs.uw, MSB+LSB, LSB); }});
15872686Sksewell@umich.edu                    0x4: ins({{ Rt.uw = bits(Rt.uw, 31, MSB+1) << (MSB+1) |
15882686Sksewell@umich.edu                                        bits(Rs.uw, MSB-LSB, 0) << LSB |
15892686Sksewell@umich.edu                                        bits(Rt.uw, LSB-1, 0);
15902686Sksewell@umich.edu                             }});
15912046SN/A                }
15922101SN/A            }
15932026SN/A
15942101SN/A            0x1: decode FUNCTION_LO {
15954661Sksewell@umich.edu                format MT_Control {
15964661Sksewell@umich.edu                    0x0: fork({{ forkThread(xc->tcBase(), fault, RD, Rs, Rt); }},
15974661Sksewell@umich.edu                              UserMode);
15984661Sksewell@umich.edu                    0x1: yield({{ Rd.sw = yieldThread(xc->tcBase(), fault, Rs.sw, YQMask); }},
15994661Sksewell@umich.edu                               UserMode);
16004661Sksewell@umich.edu                }
16014661Sksewell@umich.edu
16024661Sksewell@umich.edu                //Table 5-9 MIPS32 LX Encoding of the op Field (DSP ASE MANUAL)
16034661Sksewell@umich.edu                0x2: decode OP_HI {
16044661Sksewell@umich.edu                    0x0: decode OP_LO {
16054661Sksewell@umich.edu                        format LoadIndexedMemory {
16064661Sksewell@umich.edu                            0x0: lwx({{ Rd.sw = Mem.sw; }});
16074661Sksewell@umich.edu                            0x4: lhx({{ Rd.sw = Mem.sh; }});
16084661Sksewell@umich.edu                            0x6: lbux({{ Rd.uw = Mem.ub; }});
16094661Sksewell@umich.edu                        }
16104661Sksewell@umich.edu                    }
16114661Sksewell@umich.edu                }
16124661Sksewell@umich.edu                0x4: DspIntOp::insv({{ int pos = dspctl<5:0>;
16134661Sksewell@umich.edu                                       int size = dspctl<12:7>-1;
16144661Sksewell@umich.edu                                       Rt.uw = insertBits( Rt.uw, pos+size, pos, Rs.uw<size:0> ); }});
16154661Sksewell@umich.edu            }
16164661Sksewell@umich.edu
16174661Sksewell@umich.edu            0x2: decode FUNCTION_LO {
16184661Sksewell@umich.edu
16194661Sksewell@umich.edu                //Table 5-5 MIPS32 ADDU.QB Encoding of the op Field (DSP ASE MANUAL)
16204661Sksewell@umich.edu                0x0: decode OP_HI {
16214661Sksewell@umich.edu                    0x0: decode OP_LO {
16224661Sksewell@umich.edu                        format DspIntOp {
16234661Sksewell@umich.edu                            0x0: addu_qb({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_QB,
16244661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
16254661Sksewell@umich.edu                            0x1: subu_qb({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_QB,
16264661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
16274661Sksewell@umich.edu                            0x4: addu_s_qb({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_QB,
16284661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
16294661Sksewell@umich.edu                            0x5: subu_s_qb({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_QB,
16304661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
16314661Sksewell@umich.edu                            0x6: muleu_s_ph_qbl({{ Rd.uw = dspMuleu( Rs.uw, Rt.uw,
16325222Sksewell@umich.edu                                                                     MODE_L, &dspctl ); }}, IntMultOp);
16334661Sksewell@umich.edu                            0x7: muleu_s_ph_qbr({{ Rd.uw = dspMuleu( Rs.uw, Rt.uw,
16345222Sksewell@umich.edu                                                                     MODE_R, &dspctl ); }}, IntMultOp);
16354661Sksewell@umich.edu                        }
16364661Sksewell@umich.edu                    }
16374661Sksewell@umich.edu                    0x1: decode OP_LO {
16384661Sksewell@umich.edu                        format DspIntOp {
16394661Sksewell@umich.edu                            0x0: addu_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
16404661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
16414661Sksewell@umich.edu                            0x1: subu_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
16424661Sksewell@umich.edu                                                            NOSATURATE, UNSIGNED, &dspctl ); }});
16434661Sksewell@umich.edu                            0x2: addq_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
16444661Sksewell@umich.edu                                                            NOSATURATE, SIGNED, &dspctl ); }});
16454661Sksewell@umich.edu                            0x3: subq_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
16464661Sksewell@umich.edu                                                            NOSATURATE, SIGNED, &dspctl ); }});
16474661Sksewell@umich.edu                            0x4: addu_s_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
16484661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
16494661Sksewell@umich.edu                            0x5: subu_s_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
16504661Sksewell@umich.edu                                                              SATURATE, UNSIGNED, &dspctl ); }});
16514661Sksewell@umich.edu                            0x6: addq_s_ph({{ Rd.uw = dspAdd( Rs.uw, Rt.uw, SIMD_FMT_PH,
16524661Sksewell@umich.edu                                                              SATURATE, SIGNED, &dspctl ); }});
16534661Sksewell@umich.edu                            0x7: subq_s_ph({{ Rd.uw = dspSub( Rs.uw, Rt.uw, SIMD_FMT_PH,
16544661Sksewell@umich.edu                                                              SATURATE, SIGNED, &dspctl ); }});
16554661Sksewell@umich.edu                        }
16564661Sksewell@umich.edu                    }
16574661Sksewell@umich.edu                    0x2: decode OP_LO {
16584661Sksewell@umich.edu                        format DspIntOp {
16594661Sksewell@umich.edu                            0x0: addsc({{ int64_t dresult;
16604661Sksewell@umich.edu                                          dresult = Rs.ud + Rt.ud;
16614661Sksewell@umich.edu                                          Rd.sw = dresult<31:0>;
16624661Sksewell@umich.edu                                          dspctl = insertBits( dspctl, 13, 13,
16634661Sksewell@umich.edu                                                               dresult<32:32> ); }});
16644661Sksewell@umich.edu                            0x1: addwc({{ int64_t dresult;
16654661Sksewell@umich.edu                                          dresult = Rs.sd + Rt.sd + dspctl<13:13>;
16664661Sksewell@umich.edu                                          Rd.sw = dresult<31:0>;
16674661Sksewell@umich.edu                                          if( dresult<32:32> != dresult<31:31> )
16684661Sksewell@umich.edu                                              dspctl = insertBits( dspctl, 20, 20, 1 ); }});
16694661Sksewell@umich.edu                            0x2: modsub({{ Rd.sw = (Rs.sw == 0) ? Rt.sw<23:8> : Rs.sw - Rt.sw<7:0>; }});
16704661Sksewell@umich.edu                            0x4: raddu_w_qb({{ Rd.uw = Rs.uw<31:24> + Rs.uw<23:16> +
16714661Sksewell@umich.edu                                                   Rs.uw<15:8> + Rs.uw<7:0>; }});
16724661Sksewell@umich.edu                            0x6: addq_s_w({{ Rd.sw = dspAdd( Rs.sw, Rt.sw, SIMD_FMT_W,
16734661Sksewell@umich.edu                                                             SATURATE, SIGNED, &dspctl ); }});
16744661Sksewell@umich.edu                            0x7: subq_s_w({{ Rd.sw = dspSub( Rs.sw, Rt.sw, SIMD_FMT_W,
16754661Sksewell@umich.edu                                                             SATURATE, SIGNED, &dspctl ); }});
16764661Sksewell@umich.edu                        }
16774661Sksewell@umich.edu                    }
16784661Sksewell@umich.edu                    0x3: decode OP_LO {
16794661Sksewell@umich.edu                        format DspIntOp {
16804661Sksewell@umich.edu                            0x4: muleq_s_w_phl({{ Rd.sw = dspMuleq( Rs.sw, Rt.sw,
16815222Sksewell@umich.edu                                                                    MODE_L, &dspctl ); }}, IntMultOp);
16824661Sksewell@umich.edu                            0x5: muleq_s_w_phr({{ Rd.sw = dspMuleq( Rs.sw, Rt.sw,
16835222Sksewell@umich.edu                                                                    MODE_R, &dspctl ); }}, IntMultOp);
16844661Sksewell@umich.edu                            0x6: mulq_s_ph({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_PH,
16855222Sksewell@umich.edu                                                               SATURATE, NOROUND, &dspctl ); }}, IntMultOp);
16864661Sksewell@umich.edu                            0x7: mulq_rs_ph({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_PH,
16875222Sksewell@umich.edu                                                                SATURATE, ROUND, &dspctl ); }}, IntMultOp);
16884661Sksewell@umich.edu                        }
16894661Sksewell@umich.edu                    }
16904661Sksewell@umich.edu                }
16914661Sksewell@umich.edu
16924661Sksewell@umich.edu                //Table 5-6 MIPS32 CMPU_EQ_QB Encoding of the op Field (DSP ASE MANUAL)
16934661Sksewell@umich.edu                0x1: decode OP_HI {
16944661Sksewell@umich.edu                    0x0: decode OP_LO {
16954661Sksewell@umich.edu                        format DspIntOp {
16964661Sksewell@umich.edu                            0x0: cmpu_eq_qb({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_QB,
16974661Sksewell@umich.edu                                                       UNSIGNED, CMP_EQ, &dspctl ); }});
16984661Sksewell@umich.edu                            0x1: cmpu_lt_qb({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_QB,
16994661Sksewell@umich.edu                                                       UNSIGNED, CMP_LT, &dspctl ); }});
17004661Sksewell@umich.edu                            0x2: cmpu_le_qb({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_QB,
17014661Sksewell@umich.edu                                                       UNSIGNED, CMP_LE, &dspctl ); }});
17024661Sksewell@umich.edu                            0x3: pick_qb({{ Rd.uw = dspPick( Rs.uw, Rt.uw,
17034661Sksewell@umich.edu                                                             SIMD_FMT_QB, &dspctl ); }});
17044661Sksewell@umich.edu                            0x4: cmpgu_eq_qb({{ Rd.uw = dspCmpg( Rs.uw, Rt.uw, SIMD_FMT_QB,
17054661Sksewell@umich.edu                                                                 UNSIGNED, CMP_EQ ); }});
17064661Sksewell@umich.edu                            0x5: cmpgu_lt_qb({{ Rd.uw = dspCmpg( Rs.uw, Rt.uw, SIMD_FMT_QB,
17074661Sksewell@umich.edu                                                                 UNSIGNED, CMP_LT ); }});
17084661Sksewell@umich.edu                            0x6: cmpgu_le_qb({{ Rd.uw = dspCmpg( Rs.uw, Rt.uw, SIMD_FMT_QB,
17094661Sksewell@umich.edu                                                                 UNSIGNED, CMP_LE ); }});
17104661Sksewell@umich.edu                        }
17114661Sksewell@umich.edu                    }
17124661Sksewell@umich.edu                    0x1: decode OP_LO {
17134661Sksewell@umich.edu                        format DspIntOp {
17144661Sksewell@umich.edu                            0x0: cmp_eq_ph({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_PH,
17154661Sksewell@umich.edu                                                      SIGNED, CMP_EQ, &dspctl ); }});
17164661Sksewell@umich.edu                            0x1: cmp_lt_ph({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_PH,
17174661Sksewell@umich.edu                                                      SIGNED, CMP_LT, &dspctl ); }});
17184661Sksewell@umich.edu                            0x2: cmp_le_ph({{ dspCmp( Rs.uw, Rt.uw, SIMD_FMT_PH,
17194661Sksewell@umich.edu                                                      SIGNED, CMP_LE, &dspctl ); }});
17204661Sksewell@umich.edu                            0x3: pick_ph({{ Rd.uw = dspPick( Rs.uw, Rt.uw,
17214661Sksewell@umich.edu                                                             SIMD_FMT_PH, &dspctl ); }});
17224661Sksewell@umich.edu                            0x4: precrq_qb_ph({{ Rd.uw = Rs.uw<31:24> << 24 |
17234661Sksewell@umich.edu                                                         Rs.uw<15:8> << 16 |
17244661Sksewell@umich.edu                                                         Rt.uw<31:24> << 8 |
17254661Sksewell@umich.edu                                                         Rt.uw<15:8>; }});
17264661Sksewell@umich.edu                            0x5: precr_qb_ph({{ Rd.uw = Rs.uw<23:16> << 24 |
17274661Sksewell@umich.edu                                                         Rs.uw<7:0> << 16 |
17284661Sksewell@umich.edu                                                         Rt.uw<23:16> << 8 |
17294661Sksewell@umich.edu                                                         Rt.uw<7:0>; }});
17304661Sksewell@umich.edu                            0x6: packrl_ph({{ Rd.uw = dspPack( Rs.uw, Rt.uw,
17314661Sksewell@umich.edu                                                               SIMD_FMT_PH ); }});
17324661Sksewell@umich.edu                            0x7: precrqu_s_qb_ph({{ Rd.uw = dspPrecrqu( Rs.uw, Rt.uw, &dspctl ); }});
17334661Sksewell@umich.edu                        }
17344661Sksewell@umich.edu                    }
17354661Sksewell@umich.edu                    0x2: decode OP_LO {
17364661Sksewell@umich.edu                        format DspIntOp {
17374661Sksewell@umich.edu                            0x4: precrq_ph_w({{ Rd.uw = Rs.uw<31:16> << 16 | Rt.uw<31:16>; }});
17384661Sksewell@umich.edu                            0x5: precrq_rs_ph_w({{ Rd.uw = dspPrecrq( Rs.uw, Rt.uw, SIMD_FMT_W, &dspctl ); }});
17394661Sksewell@umich.edu                        }
17404661Sksewell@umich.edu                    }
17414661Sksewell@umich.edu                    0x3: decode OP_LO {
17424661Sksewell@umich.edu                        format DspIntOp {
17434661Sksewell@umich.edu                            0x0: cmpgdu_eq_qb({{ Rd.uw = dspCmpgd( Rs.uw, Rt.uw, SIMD_FMT_QB,
17444661Sksewell@umich.edu                                                                   UNSIGNED, CMP_EQ, &dspctl ); }});
17454661Sksewell@umich.edu                            0x1: cmpgdu_lt_qb({{ Rd.uw = dspCmpgd( Rs.uw, Rt.uw, SIMD_FMT_QB,
17464661Sksewell@umich.edu                                                                   UNSIGNED, CMP_LT, &dspctl  ); }});
17474661Sksewell@umich.edu                            0x2: cmpgdu_le_qb({{ Rd.uw = dspCmpgd( Rs.uw, Rt.uw, SIMD_FMT_QB,
17484661Sksewell@umich.edu                                                                   UNSIGNED, CMP_LE, &dspctl ); }});
17494661Sksewell@umich.edu                            0x6: precr_sra_ph_w({{ Rt.uw = dspPrecrSra( Rt.uw, Rs.uw, RD,
17504661Sksewell@umich.edu                                                                        SIMD_FMT_W, NOROUND ); }});
17514661Sksewell@umich.edu                            0x7: precr_sra_r_ph_w({{ Rt.uw = dspPrecrSra( Rt.uw, Rs.uw, RD,
17524661Sksewell@umich.edu                                                                        SIMD_FMT_W, ROUND ); }});
17534661Sksewell@umich.edu                        }
17544661Sksewell@umich.edu                    }
17554661Sksewell@umich.edu                }
17564661Sksewell@umich.edu
17574661Sksewell@umich.edu                //Table 5-7 MIPS32 ABSQ_S.PH Encoding of the op Field (DSP ASE MANUAL)
17584661Sksewell@umich.edu                0x2: decode OP_HI {
17594661Sksewell@umich.edu                    0x0: decode OP_LO {
17604661Sksewell@umich.edu                        format DspIntOp {
17614661Sksewell@umich.edu                            0x1: absq_s_qb({{ Rd.sw = dspAbs( Rt.sw, SIMD_FMT_QB, &dspctl );}});
17624661Sksewell@umich.edu                            0x2: repl_qb({{ Rd.uw = RS_RT<7:0> << 24 |
17634661Sksewell@umich.edu                                                    RS_RT<7:0> << 16 |
17644661Sksewell@umich.edu                                                    RS_RT<7:0> << 8 |
17654661Sksewell@umich.edu                                                    RS_RT<7:0>; }});
17664661Sksewell@umich.edu                            0x3: replv_qb({{ Rd.sw = Rt.uw<7:0> << 24 |
17674661Sksewell@umich.edu                                                     Rt.uw<7:0> << 16 |
17684661Sksewell@umich.edu                                                     Rt.uw<7:0> << 8 |
17694661Sksewell@umich.edu                                                     Rt.uw<7:0>; }});
17704661Sksewell@umich.edu                            0x4: precequ_ph_qbl({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17714661Sksewell@umich.edu                                                                     SIMD_FMT_PH, SIGNED, MODE_L ); }});
17724661Sksewell@umich.edu                            0x5: precequ_ph_qbr({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17734661Sksewell@umich.edu                                                                     SIMD_FMT_PH, SIGNED, MODE_R ); }});
17744661Sksewell@umich.edu                            0x6: precequ_ph_qbla({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17754661Sksewell@umich.edu                                                                      SIMD_FMT_PH, SIGNED, MODE_LA ); }});
17764661Sksewell@umich.edu                            0x7: precequ_ph_qbra({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
17774661Sksewell@umich.edu                                                                      SIMD_FMT_PH, SIGNED, MODE_RA ); }});
17784661Sksewell@umich.edu                        }
17794661Sksewell@umich.edu                    }
17804661Sksewell@umich.edu                    0x1: decode OP_LO {
17814661Sksewell@umich.edu                        format DspIntOp {
17824661Sksewell@umich.edu                            0x1: absq_s_ph({{ Rd.sw = dspAbs( Rt.sw, SIMD_FMT_PH, &dspctl ); }});
17834661Sksewell@umich.edu                            0x2: repl_ph({{ Rd.uw = (sext<10>(RS_RT))<15:0> << 16 |
17844661Sksewell@umich.edu                                                    (sext<10>(RS_RT))<15:0>; }});
17854661Sksewell@umich.edu                            0x3: replv_ph({{ Rd.uw = Rt.uw<15:0> << 16 |
17864661Sksewell@umich.edu                                                     Rt.uw<15:0>; }});
17874661Sksewell@umich.edu                            0x4: preceq_w_phl({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_PH, SIGNED,
17884661Sksewell@umich.edu                                                                   SIMD_FMT_W, SIGNED, MODE_L ); }});
17894661Sksewell@umich.edu                            0x5: preceq_w_phr({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_PH, SIGNED,
17904661Sksewell@umich.edu                                                                   SIMD_FMT_W, SIGNED, MODE_R ); }});
17914661Sksewell@umich.edu                        }
17924661Sksewell@umich.edu                    }
17934661Sksewell@umich.edu                    0x2: decode OP_LO {
17944661Sksewell@umich.edu                        format DspIntOp {
17954661Sksewell@umich.edu                            0x1: absq_s_w({{ Rd.sw = dspAbs( Rt.sw, SIMD_FMT_W, &dspctl ); }});
17964661Sksewell@umich.edu                        }
17974661Sksewell@umich.edu                    }
17984661Sksewell@umich.edu                    0x3: decode OP_LO {
17994661Sksewell@umich.edu                        0x3: IntOp::bitrev({{ Rd.uw = bitrev( Rt.uw<15:0> ); }});
18004661Sksewell@umich.edu                        format DspIntOp {
18014661Sksewell@umich.edu                            0x4: preceu_ph_qbl({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
18024661Sksewell@umich.edu                                                                    SIMD_FMT_PH, UNSIGNED, MODE_L ); }});
18034661Sksewell@umich.edu                            0x5: preceu_ph_qbr({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
18044661Sksewell@umich.edu                                                                    SIMD_FMT_PH, UNSIGNED, MODE_R ); }});
18054661Sksewell@umich.edu                            0x6: preceu_ph_qbla({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
18064661Sksewell@umich.edu                                                                     SIMD_FMT_PH, UNSIGNED, MODE_LA ); }});
18074661Sksewell@umich.edu                            0x7: preceu_ph_qbra({{ Rd.uw = dspPrece( Rt.uw, SIMD_FMT_QB, UNSIGNED,
18084661Sksewell@umich.edu                                                                     SIMD_FMT_PH, UNSIGNED, MODE_RA ); }});
18094661Sksewell@umich.edu                        }
18104661Sksewell@umich.edu                    }
18114661Sksewell@umich.edu                }
18124661Sksewell@umich.edu
18134661Sksewell@umich.edu                //Table 5-8 MIPS32 SHLL.QB Encoding of the op Field (DSP ASE MANUAL)
18144661Sksewell@umich.edu                0x3: decode OP_HI {
18154661Sksewell@umich.edu                    0x0: decode OP_LO {
18164661Sksewell@umich.edu                        format DspIntOp {
18174661Sksewell@umich.edu                            0x0: shll_qb({{ Rd.sw = dspShll( Rt.sw, RS, SIMD_FMT_QB,
18184661Sksewell@umich.edu                                                             NOSATURATE, UNSIGNED, &dspctl ); }});
18194661Sksewell@umich.edu                            0x1: shrl_qb({{ Rd.sw = dspShrl( Rt.sw, RS, SIMD_FMT_QB,
18204661Sksewell@umich.edu                                                             UNSIGNED ); }});
18214661Sksewell@umich.edu                            0x2: shllv_qb({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_QB,
18224661Sksewell@umich.edu                                                              NOSATURATE, UNSIGNED, &dspctl ); }});
18234661Sksewell@umich.edu                            0x3: shrlv_qb({{ Rd.sw = dspShrl( Rt.sw, Rs.sw, SIMD_FMT_QB,
18244661Sksewell@umich.edu                                                              UNSIGNED ); }});
18254661Sksewell@umich.edu                            0x4: shra_qb({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_QB,
18264661Sksewell@umich.edu                                                             NOROUND, SIGNED, &dspctl ); }});
18274661Sksewell@umich.edu                            0x5: shra_r_qb({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_QB,
18284661Sksewell@umich.edu                                                               ROUND, SIGNED, &dspctl ); }});
18294661Sksewell@umich.edu                            0x6: shrav_qb({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_QB,
18304661Sksewell@umich.edu                                                              NOROUND, SIGNED, &dspctl ); }});
18314661Sksewell@umich.edu                            0x7: shrav_r_qb({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_QB,
18324661Sksewell@umich.edu                                                                ROUND, SIGNED, &dspctl ); }});
18334661Sksewell@umich.edu                        }
18344661Sksewell@umich.edu                    }
18354661Sksewell@umich.edu                    0x1: decode OP_LO {
18364661Sksewell@umich.edu                        format DspIntOp {
18374661Sksewell@umich.edu                            0x0: shll_ph({{ Rd.uw = dspShll( Rt.uw, RS, SIMD_FMT_PH,
18384661Sksewell@umich.edu                                                             NOSATURATE, SIGNED, &dspctl ); }});
18394661Sksewell@umich.edu                            0x1: shra_ph({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_PH,
18404661Sksewell@umich.edu                                                             NOROUND, SIGNED, &dspctl ); }});
18414661Sksewell@umich.edu                            0x2: shllv_ph({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_PH,
18424661Sksewell@umich.edu                                                              NOSATURATE, SIGNED, &dspctl ); }});
18434661Sksewell@umich.edu                            0x3: shrav_ph({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_PH,
18444661Sksewell@umich.edu                                                              NOROUND, SIGNED, &dspctl ); }});
18454661Sksewell@umich.edu                            0x4: shll_s_ph({{ Rd.sw = dspShll( Rt.sw, RS, SIMD_FMT_PH,
18464661Sksewell@umich.edu                                                               SATURATE, SIGNED, &dspctl ); }});
18474661Sksewell@umich.edu                            0x5: shra_r_ph({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_PH,
18484661Sksewell@umich.edu                                                               ROUND, SIGNED, &dspctl ); }});
18494661Sksewell@umich.edu                            0x6: shllv_s_ph({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_PH,
18504661Sksewell@umich.edu                                                                SATURATE, SIGNED, &dspctl ); }});
18514661Sksewell@umich.edu                            0x7: shrav_r_ph({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_PH,
18524661Sksewell@umich.edu                                                                ROUND, SIGNED, &dspctl ); }});
18534661Sksewell@umich.edu                        }
18544661Sksewell@umich.edu                    }
18554661Sksewell@umich.edu                    0x2: decode OP_LO {
18564661Sksewell@umich.edu                        format DspIntOp {
18574661Sksewell@umich.edu                            0x4: shll_s_w({{ Rd.sw = dspShll( Rt.sw, RS, SIMD_FMT_W,
18584661Sksewell@umich.edu                                                              SATURATE, SIGNED, &dspctl ); }});
18594661Sksewell@umich.edu                            0x5: shra_r_w({{ Rd.sw = dspShra( Rt.sw, RS, SIMD_FMT_W,
18604661Sksewell@umich.edu                                                              ROUND, SIGNED, &dspctl ); }});
18614661Sksewell@umich.edu                            0x6: shllv_s_w({{ Rd.sw = dspShll( Rt.sw, Rs.sw, SIMD_FMT_W,
18624661Sksewell@umich.edu                                                               SATURATE, SIGNED, &dspctl ); }});
18634661Sksewell@umich.edu                            0x7: shrav_r_w({{ Rd.sw = dspShra( Rt.sw, Rs.sw, SIMD_FMT_W,
18644661Sksewell@umich.edu                                                               ROUND, SIGNED, &dspctl ); }});
18654661Sksewell@umich.edu                        }
18664661Sksewell@umich.edu                    }
18674661Sksewell@umich.edu                    0x3: decode OP_LO {
18684661Sksewell@umich.edu                        format DspIntOp {
18694661Sksewell@umich.edu                            0x1: shrl_ph({{ Rd.sw = dspShrl( Rt.sw, RS, SIMD_FMT_PH,
18704661Sksewell@umich.edu                                                             UNSIGNED ); }});
18714661Sksewell@umich.edu                            0x3: shrlv_ph({{ Rd.sw = dspShrl( Rt.sw, Rs.sw, SIMD_FMT_PH,
18724661Sksewell@umich.edu                                                              UNSIGNED ); }});
18734661Sksewell@umich.edu                        }
18744661Sksewell@umich.edu                    }
18754661Sksewell@umich.edu                }
18764661Sksewell@umich.edu            }
18774661Sksewell@umich.edu
18784661Sksewell@umich.edu            0x3: decode FUNCTION_LO {
18794661Sksewell@umich.edu
18804661Sksewell@umich.edu                //Table 3.12 MIPS32 ADDUH.QB Encoding of the op Field (DSP ASE Rev2 Manual)
18814661Sksewell@umich.edu                0x0: decode OP_HI {
18824661Sksewell@umich.edu                    0x0: decode OP_LO {
18834661Sksewell@umich.edu                        format DspIntOp {
18844661Sksewell@umich.edu                            0x0: adduh_qb({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18854661Sksewell@umich.edu                                                              NOROUND, UNSIGNED ); }});
18864661Sksewell@umich.edu                            0x1: subuh_qb({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18874661Sksewell@umich.edu                                                              NOROUND, UNSIGNED ); }});
18884661Sksewell@umich.edu                            0x2: adduh_r_qb({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18894661Sksewell@umich.edu                                                                ROUND, UNSIGNED ); }});
18904661Sksewell@umich.edu                            0x3: subuh_r_qb({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_QB,
18914661Sksewell@umich.edu                                                                ROUND, UNSIGNED ); }});
18924661Sksewell@umich.edu                        }
18934661Sksewell@umich.edu                    }
18944661Sksewell@umich.edu                    0x1: decode OP_LO {
18954661Sksewell@umich.edu                        format DspIntOp {
18964661Sksewell@umich.edu                            0x0: addqh_ph({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_PH,
18974661Sksewell@umich.edu                                                              NOROUND, SIGNED ); }});
18984661Sksewell@umich.edu                            0x1: subqh_ph({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_PH,
18994661Sksewell@umich.edu                                                              NOROUND, SIGNED ); }});
19004661Sksewell@umich.edu                            0x2: addqh_r_ph({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_PH,
19014661Sksewell@umich.edu                                                                ROUND, SIGNED ); }});
19024661Sksewell@umich.edu                            0x3: subqh_r_ph({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_PH,
19034661Sksewell@umich.edu                                                                ROUND, SIGNED ); }});
19044661Sksewell@umich.edu                            0x4: mul_ph({{ Rd.sw = dspMul( Rs.sw, Rt.sw, SIMD_FMT_PH,
19055222Sksewell@umich.edu                                                           NOSATURATE, &dspctl ); }}, IntMultOp);
19064661Sksewell@umich.edu                            0x6: mul_s_ph({{ Rd.sw = dspMul( Rs.sw, Rt.sw, SIMD_FMT_PH,
19075222Sksewell@umich.edu                                                             SATURATE, &dspctl ); }}, IntMultOp);
19085222Sksewell@umich.edu
19094661Sksewell@umich.edu                        }
19104661Sksewell@umich.edu                    }
19114661Sksewell@umich.edu                    0x2: decode OP_LO {
19124661Sksewell@umich.edu                        format DspIntOp {
19134661Sksewell@umich.edu                            0x0: addqh_w({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_W,
19144661Sksewell@umich.edu                                                             NOROUND, SIGNED ); }});
19154661Sksewell@umich.edu                            0x1: subqh_w({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_W,
19164661Sksewell@umich.edu                                                             NOROUND, SIGNED ); }});
19174661Sksewell@umich.edu                            0x2: addqh_r_w({{ Rd.uw = dspAddh( Rs.sw, Rt.sw, SIMD_FMT_W,
19184661Sksewell@umich.edu                                                               ROUND, SIGNED ); }});
19194661Sksewell@umich.edu                            0x3: subqh_r_w({{ Rd.uw = dspSubh( Rs.sw, Rt.sw, SIMD_FMT_W,
19204661Sksewell@umich.edu                                                               ROUND, SIGNED ); }});
19214661Sksewell@umich.edu                            0x6: mulq_s_w({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_W,
19225222Sksewell@umich.edu                                                              SATURATE, NOROUND, &dspctl ); }}, IntMultOp);
19234661Sksewell@umich.edu                            0x7: mulq_rs_w({{ Rd.sw = dspMulq( Rs.sw, Rt.sw, SIMD_FMT_W,
19245222Sksewell@umich.edu                                                               SATURATE, ROUND, &dspctl ); }}, IntMultOp);
19254661Sksewell@umich.edu                        }
19264661Sksewell@umich.edu                    }
19272061SN/A                }
19282101SN/A            }
19292061SN/A
19302101SN/A            //Table A-10 MIPS32 BSHFL Encoding of sa Field
19312101SN/A            0x4: decode SA {
19322046SN/A                format BasicOp {
19332686Sksewell@umich.edu                    0x02: wsbh({{ Rd.uw = Rt.uw<23:16> << 24 |
19344661Sksewell@umich.edu                                      Rt.uw<31:24> << 16 |
19354661Sksewell@umich.edu                                      Rt.uw<7:0>   << 8  |
19364661Sksewell@umich.edu                                      Rt.uw<15:8>;
19372686Sksewell@umich.edu                    }});
19382742Sksewell@umich.edu                    0x10: seb({{ Rd.sw = Rt.sb; }});
19392742Sksewell@umich.edu                    0x18: seh({{ Rd.sw = Rt.sh; }});
19402046SN/A                }
19412101SN/A            }
19422043SN/A
19432101SN/A            0x6: decode FUNCTION_LO {
19444661Sksewell@umich.edu
19454661Sksewell@umich.edu                //Table 5-10 MIPS32 DPAQ.W.PH Encoding of the op Field (DSP ASE MANUAL)
19464661Sksewell@umich.edu                0x0: decode OP_HI {
19474661Sksewell@umich.edu                    0x0: decode OP_LO {
19484661Sksewell@umich.edu                        format DspHiLoOp {
19494661Sksewell@umich.edu                            0x0: dpa_w_ph({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19505222Sksewell@umich.edu                                                             SIMD_FMT_PH, SIGNED, MODE_L ); }}, IntMultOp);
19514661Sksewell@umich.edu                            0x1: dps_w_ph({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19525222Sksewell@umich.edu                                                             SIMD_FMT_PH, SIGNED, MODE_L ); }}, IntMultOp);
19534661Sksewell@umich.edu                            0x2: mulsa_w_ph({{ dspac = dspMulsa( dspac, Rs.sw, Rt.sw,
19545222Sksewell@umich.edu                                                                 ACDST, SIMD_FMT_PH ); }}, IntMultOp);
19554661Sksewell@umich.edu                            0x3: dpau_h_qbl({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19565222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_L ); }}, IntMultOp);
19574661Sksewell@umich.edu                            0x4: dpaq_s_w_ph({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19585222Sksewell@umich.edu                                                                 SIMD_FMT_W, NOSATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19594661Sksewell@umich.edu                            0x5: dpsq_s_w_ph({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19605222Sksewell@umich.edu                                                                 SIMD_FMT_W, NOSATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19614661Sksewell@umich.edu                            0x6: mulsaq_s_w_ph({{ dspac = dspMulsaq( dspac, Rs.sw, Rt.sw,
19625222Sksewell@umich.edu                                                                     ACDST, SIMD_FMT_PH, &dspctl ); }}, IntMultOp);
19634661Sksewell@umich.edu                            0x7: dpau_h_qbr({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19645222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_R ); }}, IntMultOp);
19654661Sksewell@umich.edu                        }
19664661Sksewell@umich.edu                    }
19674661Sksewell@umich.edu                    0x1: decode OP_LO {
19684661Sksewell@umich.edu                        format DspHiLoOp {
19694661Sksewell@umich.edu                            0x0: dpax_w_ph({{ dspac = dspDpa( dspac, Rs.sw, Rt.sw, ACDST,
19705222Sksewell@umich.edu                                                              SIMD_FMT_PH, SIGNED, MODE_X ); }}, IntMultOp);
19714661Sksewell@umich.edu                            0x1: dpsx_w_ph({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19725222Sksewell@umich.edu                                                              SIMD_FMT_PH, SIGNED, MODE_X ); }}, IntMultOp);
19734661Sksewell@umich.edu                            0x3: dpsu_h_qbl({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19745222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_L ); }}, IntMultOp);
19754661Sksewell@umich.edu                            0x4: dpaq_sa_l_w({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_W,
19765222Sksewell@umich.edu                                                                 SIMD_FMT_L, SATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19774661Sksewell@umich.edu                            0x5: dpsq_sa_l_w({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_W,
19785222Sksewell@umich.edu                                                                 SIMD_FMT_L, SATURATE, MODE_L, &dspctl ); }}, IntMultOp);
19794661Sksewell@umich.edu                            0x7: dpsu_h_qbr({{ dspac = dspDps( dspac, Rs.sw, Rt.sw, ACDST,
19805222Sksewell@umich.edu                                                               SIMD_FMT_QB, UNSIGNED, MODE_R ); }}, IntMultOp);
19814661Sksewell@umich.edu                        }
19824661Sksewell@umich.edu                    }
19834661Sksewell@umich.edu                    0x2: decode OP_LO {
19844661Sksewell@umich.edu                        format DspHiLoOp {
19854661Sksewell@umich.edu                            0x0: maq_sa_w_phl({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19865222Sksewell@umich.edu                                                                 MODE_L, SATURATE, &dspctl ); }}, IntMultOp);
19874661Sksewell@umich.edu                            0x2: maq_sa_w_phr({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19885222Sksewell@umich.edu                                                                 MODE_R, SATURATE, &dspctl ); }}, IntMultOp);
19894661Sksewell@umich.edu                            0x4: maq_s_w_phl({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19905222Sksewell@umich.edu                                                                 MODE_L, NOSATURATE, &dspctl ); }}, IntMultOp);
19914661Sksewell@umich.edu                            0x6: maq_s_w_phr({{ dspac = dspMaq( dspac, Rs.uw, Rt.uw, ACDST, SIMD_FMT_PH,
19925222Sksewell@umich.edu                                                                 MODE_R, NOSATURATE, &dspctl ); }}, IntMultOp);
19934661Sksewell@umich.edu                        }
19944661Sksewell@umich.edu                    }
19954661Sksewell@umich.edu                    0x3: decode OP_LO {
19964661Sksewell@umich.edu                        format DspHiLoOp {
19974661Sksewell@umich.edu                            0x0: dpaqx_s_w_ph({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
19985222Sksewell@umich.edu                                                                  SIMD_FMT_W, NOSATURATE, MODE_X, &dspctl ); }}, IntMultOp);
19994661Sksewell@umich.edu                            0x1: dpsqx_s_w_ph({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
20005222Sksewell@umich.edu                                                                  SIMD_FMT_W, NOSATURATE, MODE_X, &dspctl ); }}, IntMultOp);
20014661Sksewell@umich.edu                            0x2: dpaqx_sa_w_ph({{ dspac = dspDpaq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
20025222Sksewell@umich.edu                                                                   SIMD_FMT_W, SATURATE, MODE_X, &dspctl ); }}, IntMultOp);
20034661Sksewell@umich.edu                            0x3: dpsqx_sa_w_ph({{ dspac = dspDpsq( dspac, Rs.sw, Rt.sw, ACDST, SIMD_FMT_PH,
20045222Sksewell@umich.edu                                                                   SIMD_FMT_W, SATURATE, MODE_X, &dspctl ); }}, IntMultOp);
20054661Sksewell@umich.edu                        }
20064661Sksewell@umich.edu                    }
20074661Sksewell@umich.edu                }
20084661Sksewell@umich.edu
20094661Sksewell@umich.edu                //Table 3.3 MIPS32 APPEND Encoding of the op Field
20104661Sksewell@umich.edu                0x1: decode OP_HI {
20114661Sksewell@umich.edu                    0x0: decode OP_LO {
20124661Sksewell@umich.edu                        format IntOp {
20134661Sksewell@umich.edu                            0x0: append({{ Rt.uw = (Rt.uw << RD) | bits(Rs.uw,RD-1,0); }});
20145570Snate@binkert.org                            0x1: prepend({{ Rt.uw = (Rt.uw >> RD) | (bits(Rs.uw, RD - 1, 0) << (32 - RD)); }});
20154661Sksewell@umich.edu                        }
20164661Sksewell@umich.edu                    }
20174661Sksewell@umich.edu                    0x2: decode OP_LO {
20184661Sksewell@umich.edu                        format IntOp {
20194661Sksewell@umich.edu                            0x0: balign({{ Rt.uw = (Rt.uw << (8*BP)) | (Rs.uw >> (8*(4-BP))); }});
20204661Sksewell@umich.edu                        }
20214661Sksewell@umich.edu                    }
20224661Sksewell@umich.edu                }
20234661Sksewell@umich.edu
20242101SN/A            }
20254661Sksewell@umich.edu            0x7: decode FUNCTION_LO {
20264661Sksewell@umich.edu
20274661Sksewell@umich.edu                //Table 5-11 MIPS32 EXTR.W Encoding of the op Field (DSP ASE MANUAL)
20284661Sksewell@umich.edu                0x0: decode OP_HI {
20294661Sksewell@umich.edu                    0x0: decode OP_LO {
20304661Sksewell@umich.edu                        format DspHiLoOp {
20314661Sksewell@umich.edu                            0x0: extr_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, RS,
20324661Sksewell@umich.edu                                                            NOROUND, NOSATURATE, &dspctl ); }});
20334661Sksewell@umich.edu                            0x1: extrv_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, Rs.uw,
20344661Sksewell@umich.edu                                                             NOROUND, NOSATURATE, &dspctl ); }});
20354661Sksewell@umich.edu                            0x2: extp({{ Rt.uw = dspExtp( dspac, RS, &dspctl ); }});
20364661Sksewell@umich.edu                            0x3: extpv({{ Rt.uw = dspExtp( dspac, Rs.uw, &dspctl ); }});
20374661Sksewell@umich.edu                            0x4: extr_r_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, RS,
20384661Sksewell@umich.edu                                                              ROUND, NOSATURATE, &dspctl ); }});
20394661Sksewell@umich.edu                            0x5: extrv_r_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, Rs.uw,
20404661Sksewell@umich.edu                                                               ROUND, NOSATURATE, &dspctl ); }});
20414661Sksewell@umich.edu                            0x6: extr_rs_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, RS,
20424661Sksewell@umich.edu                                                               ROUND, SATURATE, &dspctl ); }});
20434661Sksewell@umich.edu                            0x7: extrv_rs_w({{ Rt.uw = dspExtr( dspac, SIMD_FMT_W, Rs.uw,
20444661Sksewell@umich.edu                                                                ROUND, SATURATE, &dspctl ); }});
20454661Sksewell@umich.edu                        }
20464661Sksewell@umich.edu                    }
20474661Sksewell@umich.edu                    0x1: decode OP_LO {
20484661Sksewell@umich.edu                        format DspHiLoOp {
20494661Sksewell@umich.edu                            0x2: extpdp({{ Rt.uw = dspExtpd( dspac, RS, &dspctl ); }});
20504661Sksewell@umich.edu                            0x3: extpdpv({{ Rt.uw = dspExtpd( dspac, Rs.uw, &dspctl ); }});
20514661Sksewell@umich.edu                            0x6: extr_s_h({{ Rt.uw = dspExtr( dspac, SIMD_FMT_PH, RS,
20524661Sksewell@umich.edu                                                              NOROUND, SATURATE, &dspctl ); }});
20534661Sksewell@umich.edu                            0x7: extrv_s_h({{ Rt.uw = dspExtr( dspac, SIMD_FMT_PH, Rs.uw,
20544661Sksewell@umich.edu                                                               NOROUND, SATURATE, &dspctl ); }});
20554661Sksewell@umich.edu                        }
20564661Sksewell@umich.edu                    }
20574661Sksewell@umich.edu                    0x2: decode OP_LO {
20584661Sksewell@umich.edu                        format DspIntOp {
20594661Sksewell@umich.edu                            0x2: rddsp({{ Rd.uw = readDSPControl( &dspctl, RDDSPMASK ); }});
20604661Sksewell@umich.edu                            0x3: wrdsp({{ writeDSPControl( &dspctl, Rs.uw, WRDSPMASK ); }});
20614661Sksewell@umich.edu                        }
20624661Sksewell@umich.edu                    }
20634661Sksewell@umich.edu                    0x3: decode OP_LO {
20644661Sksewell@umich.edu                        format DspHiLoOp {
20654661Sksewell@umich.edu                            0x2: shilo({{ if( sext<6>(HILOSA) < 0 )
20664661Sksewell@umich.edu                                              dspac = (uint64_t)dspac << -sext<6>(HILOSA);
20674661Sksewell@umich.edu                                          else
20684661Sksewell@umich.edu                                              dspac = (uint64_t)dspac >> sext<6>(HILOSA); }});
20694661Sksewell@umich.edu                            0x3: shilov({{ if( sext<6>(Rs.sw<5:0>) < 0 )
20704661Sksewell@umich.edu                                              dspac = (uint64_t)dspac << -sext<6>(Rs.sw<5:0>);
20714661Sksewell@umich.edu                                           else
20724661Sksewell@umich.edu                                              dspac = (uint64_t)dspac >> sext<6>(Rs.sw<5:0>); }});
20734661Sksewell@umich.edu                            0x7: mthlip({{ dspac = dspac << 32;
20744661Sksewell@umich.edu                                           dspac |= Rs.uw;
20754661Sksewell@umich.edu                                           dspctl = insertBits( dspctl, 5, 0,
20764661Sksewell@umich.edu                                                                dspctl<5:0>+32 ); }});
20774661Sksewell@umich.edu                        }
20784661Sksewell@umich.edu                    }
20794661Sksewell@umich.edu                }
20805222Sksewell@umich.edu                0x3: decode OP_HI {
20815222Sksewell@umich.edu                    0x2: decode OP_LO {
20825222Sksewell@umich.edu                        0x3: FailUnimpl::rdhwr();
20835222Sksewell@umich.edu                    }
20845222Sksewell@umich.edu                }
20854661Sksewell@umich.edu            }
20862043SN/A        }
20872084SN/A    }
20882024SN/A
20892686Sksewell@umich.edu    0x4: decode OPCODE_LO {
20902124SN/A        format LoadMemory {
20915222Sksewell@umich.edu          0x0: lb({{ Rt.sw = Mem.sb; }}, mem_flags = NO_ALIGN_FAULT);
20925222Sksewell@umich.edu          0x1: lh({{ Rt.sw = Mem.sh; }}, mem_flags = NO_HALF_WORD_ALIGN_FAULT);
20932479SN/A            0x3: lw({{ Rt.sw = Mem.sw; }});
20945222Sksewell@umich.edu            0x4: lbu({{ Rt.uw = Mem.ub;}}, mem_flags = NO_ALIGN_FAULT);
20955222Sksewell@umich.edu            0x5: lhu({{ Rt.uw = Mem.uh; }}, mem_flags = NO_HALF_WORD_ALIGN_FAULT);
20962686Sksewell@umich.edu        }
20972495SN/A
20982686Sksewell@umich.edu        format LoadUnalignedMemory {
20992686Sksewell@umich.edu            0x2: lwl({{ uint32_t mem_shift = 24 - (8 * byte_offset);
21002686Sksewell@umich.edu                        Rt.uw = mem_word << mem_shift |
21015570Snate@binkert.org                            (Rt.uw & mask(mem_shift));
21022686Sksewell@umich.edu                     }});
21032686Sksewell@umich.edu            0x6: lwr({{ uint32_t mem_shift = 8 * byte_offset;
21045570Snate@binkert.org                        Rt.uw = (Rt.uw & (mask(mem_shift) << (32 - mem_shift))) |
21055570Snate@binkert.org                            (mem_word >> mem_shift);
21062686Sksewell@umich.edu                     }});
21074661Sksewell@umich.edu      }
21082084SN/A    }
21092024SN/A
21102686Sksewell@umich.edu    0x5: decode OPCODE_LO {
21112124SN/A        format StoreMemory {
21125222Sksewell@umich.edu            0x0: sb({{ Mem.ub = Rt<7:0>; }}, mem_flags = NO_ALIGN_FAULT);
21135222Sksewell@umich.edu            0x1: sh({{ Mem.uh = Rt<15:0>; }}, mem_flags = NO_HALF_WORD_ALIGN_FAULT);
21142479SN/A            0x3: sw({{ Mem.uw = Rt<31:0>; }});
21152084SN/A        }
21162024SN/A
21172686Sksewell@umich.edu        format StoreUnalignedMemory {
21182686Sksewell@umich.edu            0x2: swl({{ uint32_t reg_shift = 24 - (8 * byte_offset);
21192686Sksewell@umich.edu                        uint32_t mem_shift = 32 - reg_shift;
21205570Snate@binkert.org                        mem_word = (mem_word & (mask(reg_shift) << mem_shift)) |
21215570Snate@binkert.org                            (Rt.uw >> reg_shift);
21222686Sksewell@umich.edu                     }});
21232686Sksewell@umich.edu            0x6: swr({{ uint32_t reg_shift = 8 * byte_offset;
21242686Sksewell@umich.edu                        mem_word = Rt.uw << reg_shift |
21255570Snate@binkert.org                            (mem_word & (mask(reg_shift)));
21262686Sksewell@umich.edu                     }});
21272084SN/A        }
21285222Sksewell@umich.edu        format CP0Control {
21295222Sksewell@umich.edu            0x7: cache({{
21305254Sksewell@umich.edu                //Addr CacheEA = Rs.uw + OFFSET;
21315250Sksewell@umich.edu                           //fault = xc->CacheOp((uint8_t)CACHE_OP,(Addr) CacheEA);
21325222Sksewell@umich.edu                         }});
21335222Sksewell@umich.edu        }
21342084SN/A    }
21352024SN/A
21362686Sksewell@umich.edu    0x6: decode OPCODE_LO {
21372686Sksewell@umich.edu        format LoadMemory {
21386076Sgblack@eecs.umich.edu            0x0: ll({{ Rt.uw = Mem.uw; }}, mem_flags=LLSC);
21392686Sksewell@umich.edu            0x1: lwc1({{ Ft.uw = Mem.uw; }});
21402573SN/A            0x5: ldc1({{ Ft.ud = Mem.ud; }});
21412084SN/A        }
21425222Sksewell@umich.edu        0x2: CP2Unimpl::lwc2();
21435222Sksewell@umich.edu        0x6: CP2Unimpl::ldc2();
21442686Sksewell@umich.edu        0x3: Prefetch::pref();
21452084SN/A    }
21462024SN/A
21472239SN/A
21482686Sksewell@umich.edu    0x7: decode OPCODE_LO {
21492686Sksewell@umich.edu        0x0: StoreCond::sc({{ Mem.uw = Rt.uw;}},
21502686Sksewell@umich.edu                           {{ uint64_t tmp = write_result;
21512686Sksewell@umich.edu                              Rt.uw = (tmp == 0 || tmp == 1) ? tmp : Rt.uw;
21526076Sgblack@eecs.umich.edu                           }}, mem_flags=LLSC, inst_flags = IsStoreConditional);
21532055SN/A
21542686Sksewell@umich.edu        format StoreMemory {
21555222Sksewell@umich.edu          0x1: swc1({{ Mem.uw = Ft.uw;}});
21565222Sksewell@umich.edu          0x5: sdc1({{ Mem.ud = Ft.ud;}});
21572084SN/A        }
21585222Sksewell@umich.edu
21595222Sksewell@umich.edu        0x2: CP2Unimpl::swc2();
21605222Sksewell@umich.edu        0x6: CP2Unimpl::sdc2();
21615222Sksewell@umich.edu
21622027SN/A    }
21632024SN/A}
21642022SN/A
21652027SN/A
2166