decoder.isa revision 2124
12SN/A// -*- mode:c++ -*-
29448SAndreas.Sandberg@ARM.com
39920Syasuko.eckert@amd.com////////////////////////////////////////////////////////////////////
47338SAli.Saidi@ARM.com//
57338SAli.Saidi@ARM.com// The actual MIPS32 ISA decoder
67338SAli.Saidi@ARM.com// -----------------------------
77338SAli.Saidi@ARM.com// The following instructions are specified in the MIPS32 ISA
87338SAli.Saidi@ARM.com// Specification. Decoding closely follows the style specified
97338SAli.Saidi@ARM.com// in the MIPS32 ISAthe specification document starting with Table
107338SAli.Saidi@ARM.com// A-2 (document available @ www.mips.com)
117338SAli.Saidi@ARM.com//
127338SAli.Saidi@ARM.com//@todo: Distinguish "unknown/future" use insts from "reserved"
137338SAli.Saidi@ARM.com// ones
147338SAli.Saidi@ARM.comdecode OPCODE_HI default Unknown::unknown() {
151762SN/A
162SN/A    // Derived From ... Table A-2 MIPS32 ISA Manual
172SN/A    0x0: decode OPCODE_LO {
182SN/A
192SN/A        0x0: decode FUNCTION_HI {
202SN/A            0x0: decode FUNCTION_LO {
212SN/A                0x1: decode MOVCI {
222SN/A                    format BasicOp {
232SN/A                        0: movf({{ if( xc->miscRegs.fpcr == 0) Rd = Rs}});
242SN/A                        1: movt({{ if( xc->miscRegs.fpcr == 1) Rd = Rs}});
252SN/A                    }
262SN/A                }
272SN/A
282SN/A                format BasicOp {
292SN/A
302SN/A                    //Table A-3 Note: "1. Specific encodings of the rt, rd, and sa fields
312SN/A                    //are used to distinguish among the SLL, NOP, SSNOP and EHB functions."
322SN/A
332SN/A                    0x0: sll({{ Rd = Rt.uw << SA; }});
342SN/A
352SN/A                    0x2: decode SRL {
362SN/A                        0: srl({{ Rd = Rt.uw >> SA; }});
372SN/A
382SN/A                        //Hardcoded assuming 32-bit ISA, probably need parameter here
392SN/A                        1: rotr({{ Rd = (Rt.uw << (32 - SA)) | (Rt.uw >> SA);}});
402665Ssaidi@eecs.umich.edu                    }
412665Ssaidi@eecs.umich.edu
422SN/A                    0x3: sra({{ Rd = Rt.sw >> SA; }});
432SN/A
448779Sgblack@eecs.umich.edu                    0x4: sllv({{ Rd = Rt.uw << Rs<4:0>; }});
458779Sgblack@eecs.umich.edu
468779Sgblack@eecs.umich.edu                    0x6: decode SRLV {
472439SN/A                        0: srlv({{ Rd = Rt.uw >> Rs<4:0>; }});
488779Sgblack@eecs.umich.edu
498229Snate@binkert.org                        //Hardcoded assuming 32-bit ISA, probably need parameter here
506216Snate@binkert.org                        1: rotrv({{ Rd = (Rt.uw << (32 - Rs<4:0>)) | (Rt.uw >> Rs<4:0>);}});
51146SN/A                    }
52146SN/A
53146SN/A                    0x7: srav({{ Rd = Rt.sw >> Rs<4:0>; }});
54146SN/A                }
55146SN/A            }
566216Snate@binkert.org
576658Snate@binkert.org            0x1: decode FUNCTION_LO {
588229Snate@binkert.org
591717SN/A                //Table A-3 Note: "Specific encodings of the hint field are used
608887Sgeoffrey.blake@arm.com                //to distinguish JR from JR.HB and JALR from JALR.HB"
618887Sgeoffrey.blake@arm.com                format Jump {
62146SN/A                    0x0: decode HINT {
631977SN/A                        0:jr({{ NNPC = Rs; }},IsReturn);
642683Sktlim@umich.edu
651717SN/A                        1:jr_hb({{ NNPC = Rs; clear_exe_inst_hazards(); }},IsReturn);
66146SN/A                    }
672683Sktlim@umich.edu
688232Snate@binkert.org                    0x1: decode HINT {
698232Snate@binkert.org                        0: jalr({{ NNPC = Rs; }},IsCall,IsReturn);
708232Snate@binkert.org
718779Sgblack@eecs.umich.edu                        1: jalr_hb({{ NNPC = Rs; clear_exe_inst_hazards();}},IsCall,IsReturn);
723348Sbinkertn@umich.edu                    }
736105Ssteve.reinhardt@amd.com                }
746216Snate@binkert.org
752036SN/A                format BasicOp {
76146SN/A                    0x2: movz({{ if (Rt == 0) Rd = Rs; }});
778817Sgblack@eecs.umich.edu                    0x3: movn({{ if (Rt != 0) Rd = Rs; }});
788793Sgblack@eecs.umich.edu                }
7956SN/A
8056SN/A                format WarnUnimpl {
81695SN/A                    0x4: syscall();//{{ xc->syscall()}},IsNonSpeculative
822901Ssaidi@eecs.umich.edu                    0x5: break();
832SN/A                    0x7: sync();
842SN/A                }
852449SN/A            }
861355SN/A
875529Snate@binkert.org            0x2: decode FUNCTION_LO {
889023Sgblack@eecs.umich.edu                format BasicOp {
89224SN/A                    0x0: mfhi({{ Rd = xc->miscRegs.hi; }});
908793Sgblack@eecs.umich.edu                    0x1: mthi({{ xc->miscRegs.hi = Rs; }});
919384SAndreas.Sandberg@arm.com                    0x2: mflo({{ Rd = xc->miscRegs.lo; }});
929384SAndreas.Sandberg@arm.com                    0x3: mtlo({{ xc->miscRegs.lo = Rs; }});
938793Sgblack@eecs.umich.edu                }
948820Sgblack@eecs.umich.edu            }
959384SAndreas.Sandberg@arm.com
962SN/A            0x3: decode FUNCTION_LO {
976029Ssteve.reinhardt@amd.com                format IntOp {
982672Sktlim@umich.edu                    0x0: mult({{
992683Sktlim@umich.edu                        INT64 temp1 = Rs.sw * Rt.sw;
1002SN/A                        xc->miscRegs.hi->temp1<63:32>;
1018733Sgeoffrey.blake@arm.com                        xc->miscRegs.lo->temp1<31:0>;
1028733Sgeoffrey.blake@arm.com                    }});
1038733Sgeoffrey.blake@arm.com
1048733Sgeoffrey.blake@arm.com                    0x1: multu({{
1058733Sgeoffrey.blake@arm.com                        INT64 temp1 = Rs.uw * Rt.uw;
1068733Sgeoffrey.blake@arm.com                        xc->miscRegs.hi->temp1<63:32>;
1078733Sgeoffrey.blake@arm.com                        xc->miscRegs.lo->temp1<31:0>
1088733Sgeoffrey.blake@arm.com                            Rd.sw = Rs.uw * Rt.uw;
1098733Sgeoffrey.blake@arm.com                    }});
1108733Sgeoffrey.blake@arm.com
1118733Sgeoffrey.blake@arm.com                    0x2: div({{
1122SN/A                        xc->miscRegs.hi = Rs.sw % Rt.sw;
113334SN/A                        xc->miscRegs.lo = Rs.sw / Rt.sw;
1148834Satgutier@umich.edu                    }});
1158834Satgutier@umich.edu
116140SN/A                    0x3: divu({{
117334SN/A                        xc->miscRegs.hi = Rs.uw % Rt.uw;
1182SN/A                        xc->miscRegs.lo = Rs.uw / Rt.uw;
1192SN/A                    }});
1202SN/A                }
1212680Sktlim@umich.edu            }
1224377Sgblack@eecs.umich.edu
1235169Ssaidi@eecs.umich.edu            0x4: decode FUNCTION_LO {
1244377Sgblack@eecs.umich.edu                format IntOp {
1254377Sgblack@eecs.umich.edu                    0x0: add({{  Rd.sw = Rs.sw + Rt.sw;}});
1262SN/A                    0x1: addu({{ Rd.uw = Rs.uw + Rt.uw;}});
1272SN/A                    0x2: sub({{ Rd.sw = Rs.sw - Rt.sw;}});
1282623SN/A                    0x3: subu({{ Rd.uw = Rs.uw - Rt.uw;}});
1292SN/A                    0x4: and({{ Rd.sw = Rs.uw & Rt.uw;}});
1302SN/A                    0x5: or({{ Rd.sw = Rs.uw | Rt.uw;}});
1312SN/A                    0x6: xor({{ Rd.sw = Rs.uw ^ Rt.uw;}});
132180SN/A                    0x7: nor({{ Rd.sw = ~(Rs.uw | Rt.uw);}});
1338737Skoansin.tan@gmail.com                }
134393SN/A            }
135393SN/A
136393SN/A            0x5: decode FUNCTION_LO {
137393SN/A                format IntOp{
138384SN/A                    0x2: slt({{  Rd.sw = ( Rs.sw < Rt.sw ) ? 1 : 0}});
139384SN/A                    0x3: sltu({{ Rd.uw = ( Rs.uw < Rt.uw ) ? 1 : 0}});
140393SN/A                }
1418737Skoansin.tan@gmail.com            }
142393SN/A
143393SN/A            0x6: decode FUNCTION_LO {
144393SN/A                format Trap {
145393SN/A                    0x0: tge({{ cond = (Rs.sw >= Rt.sw); }});
146384SN/A                    0x1: tgeu({{ cond = (Rs.uw >= Rt.uw); }});
147189SN/A                    0x2: tlt({{ cond = (Rs.sw < Rt.sw); }});
148189SN/A                    0x3: tltu({{ cond = (Rs.uw >= Rt.uw); }});
1492623SN/A                    0x4: teq({{ cond = (Rs.sw == Rt.sw); }});
1502SN/A                    0x6: tne({{ cond = (Rs.sw != Rt.sw); }});
151729SN/A                }
152334SN/A            }
1532SN/A        }
1542SN/A
1552SN/A        0x1: decode REGIMM_HI {
1568834Satgutier@umich.edu            0x0: decode REGIMM_LO {
1578834Satgutier@umich.edu                format Branch {
1588834Satgutier@umich.edu                    0x0: bltz({{ cond = (Rs.sw < 0); }});
1598834Satgutier@umich.edu                    0x1: bgez({{ cond = (Rs.sw >= 0); }});
1608834Satgutier@umich.edu                }
1618834Satgutier@umich.edu
1628834Satgutier@umich.edu                format BranchLikely {
1632SN/A                    //MIPS obsolete instructions
1642SN/A                    0x2: bltzl({{ cond = (Rs.sw < 0); }});
1657897Shestness@cs.utexas.edu                    0x3: bgezl({{ cond = (Rs.sw >= 0); }});
1667897Shestness@cs.utexas.edu                }
1677897Shestness@cs.utexas.edu            }
1687897Shestness@cs.utexas.edu
1697897Shestness@cs.utexas.edu            0x1: decode REGIMM_LO {
1707897Shestness@cs.utexas.edu                format Trap {
1717897Shestness@cs.utexas.edu                    0x0: tgei( {{ cond = (Rs.sw >= INTIMM); }});
1727897Shestness@cs.utexas.edu                    0x1: tgeiu({{ cond = (Rs.uw >= INTIMM); }});
1737897Shestness@cs.utexas.edu                    0x2: tlti( {{ cond = (Rs.sw < INTIMM); }});
1747897Shestness@cs.utexas.edu                    0x3: tltiu({{ cond = (Rs.uw < INTIMM); }});
1757897Shestness@cs.utexas.edu                    0x4: teqi( {{ cond = (Rs.sw == INTIMM);}});
1767897Shestness@cs.utexas.edu                    0x6: tnei( {{ cond = (Rs.sw != INTIMM);}});
1777897Shestness@cs.utexas.edu                }
1787897Shestness@cs.utexas.edu            }
1797897Shestness@cs.utexas.edu
1807897Shestness@cs.utexas.edu            0x2: decode REGIMM_LO {
1817897Shestness@cs.utexas.edu                format Branch {
1827897Shestness@cs.utexas.edu                    0x0: bltzal({{ cond = (Rs.sw < 0); }}, IsLink);
1837897Shestness@cs.utexas.edu                    0x1: bgezal({{ cond = (Rs.sw >= 0); }}, IsLink);
1847897Shestness@cs.utexas.edu                }
1857897Shestness@cs.utexas.edu
1867897Shestness@cs.utexas.edu                format BranchLikely {
1877897Shestness@cs.utexas.edu                    //Will be removed in future MIPS releases
1887897Shestness@cs.utexas.edu                    0x2: bltzall({{ cond = (Rs.sw < 0); }}, IsLink);
1897897Shestness@cs.utexas.edu                    0x3: bgezall({{ cond = (Rs.sw >= 0); }}, IsLink);
1907897Shestness@cs.utexas.edu                }
1917897Shestness@cs.utexas.edu            }
1927897Shestness@cs.utexas.edu
1937897Shestness@cs.utexas.edu            0x3: decode REGIMM_LO {
1947897Shestness@cs.utexas.edu                format WarnUnimpl {
1957897Shestness@cs.utexas.edu                    0x7: synci();
1967897Shestness@cs.utexas.edu                }
1977897Shestness@cs.utexas.edu            }
1987897Shestness@cs.utexas.edu        }
1997897Shestness@cs.utexas.edu
2007897Shestness@cs.utexas.edu        format Jump {
2017897Shestness@cs.utexas.edu            0x2: j({{ NNPC = (NPC & 0xF0000000) & (0x00000000 & JMPTARG << 2);}});
2027897Shestness@cs.utexas.edu
2037897Shestness@cs.utexas.edu            0x3: jal({{ NNPC = (NPC & 0xF0000000) & (0x00000000 & JMPTARG << 2);}},IsCall,IsReturn);
2047897Shestness@cs.utexas.edu        }
2057897Shestness@cs.utexas.edu
2067897Shestness@cs.utexas.edu        format Branch {
2077897Shestness@cs.utexas.edu            0x4: beq({{ cond = (Rs.sw == 0); }});
2087897Shestness@cs.utexas.edu            0x5: bne({{ cond = (Rs.sw !=  0); }});
2097897Shestness@cs.utexas.edu            0x6: blez({{ cond = (Rs.sw <= 0); }});
2107897Shestness@cs.utexas.edu            0x7: bgtz({{ cond = (Rs.sw > 0); }});
2117897Shestness@cs.utexas.edu        }
2127897Shestness@cs.utexas.edu    }
2137897Shestness@cs.utexas.edu
2147897Shestness@cs.utexas.edu    0x1: decode OPCODE_LO {
2159920Syasuko.eckert@amd.com        format IntOp {
2169920Syasuko.eckert@amd.com            0x0: addi({{ Rt.sw = Rs.sw + INTIMM; }});
2179920Syasuko.eckert@amd.com            0x1: addiu({{ Rt.uw = Rs.uw + INTIMM;}});
2189920Syasuko.eckert@amd.com            0x2: slti({{ Rt.sw = ( Rs.sw < INTIMM ) ? 1 : 0 }});
2199920Syasuko.eckert@amd.com            0x3: sltiu({{ Rt.uw = ( Rs.uw < INTIMM ) ? 1 : 0 }});
2209920Syasuko.eckert@amd.com            0x4: andi({{ Rt.sw = Rs.sw & INTIMM;}});
2219920Syasuko.eckert@amd.com            0x5: ori({{ Rt.sw = Rs.sw | INTIMM;}});
2229920Syasuko.eckert@amd.com            0x6: xori({{ Rt.sw = Rs.sw ^ INTIMM;}});
2239920Syasuko.eckert@amd.com            0x7: lui({{ Rt = INTIMM << 16}});
2249920Syasuko.eckert@amd.com        }
2259920Syasuko.eckert@amd.com    }
2269920Syasuko.eckert@amd.com
2272SN/A    0x2: decode OPCODE_LO {
2287897Shestness@cs.utexas.edu
2297897Shestness@cs.utexas.edu        //Table A-11 MIPS32 COP0 Encoding of rs Field
2307897Shestness@cs.utexas.edu        0x0: decode RS_MSB {
2317897Shestness@cs.utexas.edu            0x0: decode RS {
2327897Shestness@cs.utexas.edu                format BasicOp {
2337897Shestness@cs.utexas.edu                    0x0: mfc0({{
2347897Shestness@cs.utexas.edu                        //The contents of the coprocessor 0 register specified by the
2357897Shestness@cs.utexas.edu                        //combination of rd and sel are loaded into general register
2367897Shestness@cs.utexas.edu                        //rt. Note that not all coprocessor 0 registers support the
2377897Shestness@cs.utexas.edu                        //sel field. In those instances, the sel field must be zero.
2387897Shestness@cs.utexas.edu
2397897Shestness@cs.utexas.edu                        if (SEL > 0)
2402SN/A                            panic("Can't Handle Cop0 with register select yet\n");
2412SN/A
2421001SN/A                        uint64_t reg_num = Rd.uw;
2431001SN/A
2441001SN/A                        Rt = xc->miscRegs.cop0[reg_num];
2451001SN/A                    }});
2461001SN/A
2472SN/A                    0x4: mtc0({{
2482SN/A                        //The contents of the coprocessor 0 register specified by the
2492SN/A                        //combination of rd and sel are loaded into general register
2502SN/A                        //rt. Note that not all coprocessor 0 registers support the
2512SN/A                        //sel field. In those instances, the sel field must be zero.
2527897Shestness@cs.utexas.edu
2537897Shestness@cs.utexas.edu                        if (SEL > 0)
2547897Shestness@cs.utexas.edu                            panic("Can't Handle Cop0 with register select yet\n");
2557897Shestness@cs.utexas.edu
2567897Shestness@cs.utexas.edu                        uint64_t reg_num = Rd.uw;
2577897Shestness@cs.utexas.edu
2587897Shestness@cs.utexas.edu                        xc->miscRegs.cop0[reg_num] = Rt;
2597897Shestness@cs.utexas.edu                    }});
2607897Shestness@cs.utexas.edu
2617897Shestness@cs.utexas.edu                    0x8: mftr({{
2622SN/A                        //The contents of the coprocessor 0 register specified by the
2632SN/A                        //combination of rd and sel are loaded into general register
2642SN/A                        //rt. Note that not all coprocessor 0 registers support the
2652SN/A                        //sel field. In those instances, the sel field must be zero.
2662SN/A
2672SN/A                        //MT Code Needed Here
2682SN/A                    }});
2692SN/A
2702SN/A                    0xC: mttr({{
2712SN/A                        //The contents of the coprocessor 0 register specified by the
2722SN/A                        //combination of rd and sel are loaded into general register
2732SN/A                        //rt. Note that not all coprocessor 0 registers support the
2742390SN/A                        //sel field. In those instances, the sel field must be zero.
2752390SN/A
2762390SN/A                        //MT Code Needed Here
2772390SN/A                    }});
2782390SN/A
2792390SN/A
2802390SN/A                    0xA: rdpgpr({{
2812390SN/A                        //Accessing Previous Shadow Set Register Number
2822390SN/A                        uint64_t prev = xc->miscRegs.cop0[SRSCtl][PSS];
2832390SN/A                        uint64_t reg_num = Rt.uw;
2842390SN/A
2852390SN/A                        Rd = xc->shadowIntRegFile[prev][reg_num];
286385SN/A                    }});
2877897Shestness@cs.utexas.edu
2887897Shestness@cs.utexas.edu                    0xB: decode RD {
2892SN/A
2902SN/A                        0x0: decode SC {
2912SN/A                            0x0: dvpe({{
2922623SN/A                                Rt.sw = xc->miscRegs.cop0.MVPControl;
293334SN/A                                xc->miscRegs.cop0.MVPControl[EVP] = 0;
2942361SN/A                            }});
2955496Ssaidi@eecs.umich.edu
296334SN/A                            0x1: evpe({{
297334SN/A                                Rt.sw = xc->miscRegs.cop0.MVPControl;
298334SN/A                                xc->miscRegs.cop0.MVPControl[EVP] = 1;
2999448SAndreas.Sandberg@ARM.com                            }});
3002SN/A                        }
3019448SAndreas.Sandberg@ARM.com
3029448SAndreas.Sandberg@ARM.com                        0x1: decode SC {
3039448SAndreas.Sandberg@ARM.com                            0x0: dmt({{
3042683Sktlim@umich.edu                                Rt.sw = xc->miscRegs.cop0.VPEControl;
3052SN/A                                xc->miscRegs.cop0.VPEControl[THREAD_ENABLE] = 0;
3062SN/A                            }});
3072SN/A
3089448SAndreas.Sandberg@ARM.com                            0x1: emt({{
3099448SAndreas.Sandberg@ARM.com                                Rt.sw = xc->miscRegs.cop0.VPEControl;
3102SN/A                                xc->miscRegs.cop0.VPEControl[THREAD_ENABLE] = 1;
3119448SAndreas.Sandberg@ARM.com                            }});
3129448SAndreas.Sandberg@ARM.com                        }
3139448SAndreas.Sandberg@ARM.com
3142SN/A                        0xC: decode SC {
3152SN/A                            0x0: di({{
3162SN/A                                Rt.sw = xc->miscRegs.cop0.Status;
3176221Snate@binkert.org                                xc->miscRegs.cop0.Status[INTERRUPT_ENABLE] = 0;
3182SN/A                            }});
3192SN/A
3202SN/A                            0x1: ei({{
3212SN/A                                Rt.sw = xc->miscRegs.cop0.Status;
3222623SN/A                                xc->miscRegs.cop0.Status[INTERRUPT_ENABLE] = 1;
3232SN/A                            }});
3242680Sktlim@umich.edu                        }
3252SN/A                    }
3262SN/A
3272SN/A                    0xE: wrpgpr({{
3285807Snate@binkert.org                        //Accessing Previous Shadow Set Register Number
3292SN/A                        uint64_t prev = xc->miscRegs.cop0[SRSCtl][PSS];
3305807Snate@binkert.org                        uint64_t reg_num = Rd.uw;
3315807Snate@binkert.org
3322SN/A                        xc->shadowIntRegFile[prev][reg_num] = Rt;
3335807Snate@binkert.org                    }});
3345807Snate@binkert.org                }
3352SN/A            }
3362SN/A
3372SN/A            //Table A-12 MIPS32 COP0 Encoding of Function Field When rs=CO
3382623SN/A            0x1: decode FUNCTION {
3392SN/A                format Trap {
3405704Snate@binkert.org                    0x01: tlbr({{ }});
3415647Sgblack@eecs.umich.edu                    0x02: tlbwi({{ }});
3422SN/A                    0x06: tlbwr({{ }});
3433520Sgblack@eecs.umich.edu                    0x08: tlbp({{ }});
3447338SAli.Saidi@ARM.com                }
3455647Sgblack@eecs.umich.edu
3463520Sgblack@eecs.umich.edu                format WarnUnimpl {
3479023Sgblack@eecs.umich.edu                    0x18: eret();
3482SN/A                    0x1F: deret();
3492SN/A                    0x20: wait();
3502623SN/A                }
3512SN/A            }
3522623SN/A        }
3535894Sgblack@eecs.umich.edu
3542662Sstever@eecs.umich.edu        //Table A-13 MIPS32 COP1 Encoding of rs Field
3552623SN/A        0x1: decode RS_MSB {
3567720Sgblack@eecs.umich.edu
3574495Sacolyte@umich.edu            0x0: decode RS_HI {
3582623SN/A                0x0: decode RS_LO {
3597720Sgblack@eecs.umich.edu                    format FloatOp {
3602623SN/A                        0x0: mfc1({{ Rt = Fs<31:0>; }});
3617720Sgblack@eecs.umich.edu                        0x2: cfc1({{ Rt = xc->miscRegs.fpcr[Fs];}});
3628832SAli.Saidi@ARM.com                        0x3: mfhc1({{ Rt = Fs<63:32>;}});
3638832SAli.Saidi@ARM.com                        0x4: mtc1({{ Fs<31:0> = Rt}});
3642623SN/A                        0x6: ctc1({{ xc->miscRegs.fpcr[Fs] = Rt;}});
3652623SN/A                        0x7: mftc1({{ Fs<63:32> = Rt}});
3662623SN/A                    }
3672623SN/A                }
3682623SN/A
3692623SN/A                0x1: decode ND {
3702SN/A                    0x0: decode TF {
3712683Sktlim@umich.edu                        format Branch {
3722427SN/A                            0x0: bc1f({{ cond = (xc->miscRegs.fpcr == 0); }});
3732683Sktlim@umich.edu                            0x1: bc1t({{ cond = (xc->miscRegs.fpcr == 1); }});
3742427SN/A                        }
3752SN/A                    }
3762623SN/A
3772623SN/A                    0x1: decode TF {
3787897Shestness@cs.utexas.edu                        format BranchLikely {
3792SN/A                            0x0: bc1fl({{ cond = (xc->miscRegs.fpcr == 0); }});
3802623SN/A                            0x1: bc1tl({{ cond = (xc->miscRegs.fpcr == 1); }});
3812623SN/A                        }
3824377Sgblack@eecs.umich.edu                    }
3837720Sgblack@eecs.umich.edu                }
3844377Sgblack@eecs.umich.edu            }
3857720Sgblack@eecs.umich.edu
3865665Sgblack@eecs.umich.edu            0x1: decode RS_HI {
3877720Sgblack@eecs.umich.edu                0x2: decode RS_LO {
3887720Sgblack@eecs.umich.edu
3895665Sgblack@eecs.umich.edu                    //Table A-14 MIPS32 COP1 Encoding of Function Field When rs=S
3905665Sgblack@eecs.umich.edu                    //(( single-word ))
3914181Sgblack@eecs.umich.edu                    0x0: decode RS_HI {
3924181Sgblack@eecs.umich.edu                        0x0: decode RS_LO {
3939023Sgblack@eecs.umich.edu                            format FloatOp {
3949023Sgblack@eecs.umich.edu                                0x0: adds({{ Fd.sf = Fs.sf + Ft.sf;}});
3954181Sgblack@eecs.umich.edu                                0x1: subs({{ Fd.sf = Fs.sf - Ft.sf;}});
3964182Sgblack@eecs.umich.edu                                0x2: muls({{ Fd.sf = Fs.sf * Ft.sf;}});
3977720Sgblack@eecs.umich.edu                                0x3: divs({{ Fd.sf = Fs.sf / Ft.sf;}});
3989023Sgblack@eecs.umich.edu                                0x4: sqrts({{ Fd.sf = sqrt(Fs.sf);}});
3999023Sgblack@eecs.umich.edu                                0x5: abss({{ Fd.sf = abs(Fs.sf);}});
4004593Sgblack@eecs.umich.edu                                0x6: movs({{ Fd.sf = Fs.sf;}});
4019023Sgblack@eecs.umich.edu                                0x7: negs({{ Fd.sf = -1 * Fs.sf;}});
4024377Sgblack@eecs.umich.edu                            }
4039023Sgblack@eecs.umich.edu                        }
4044377Sgblack@eecs.umich.edu
4059023Sgblack@eecs.umich.edu                        0x1: decode RS_LO {
4069023Sgblack@eecs.umich.edu                            //only legal for 64 bit-FP
4074377Sgblack@eecs.umich.edu                            format Float64Op {
4087720Sgblack@eecs.umich.edu                                0x0: round_l_s({{ Fd = convert_and_round(Fs.sf,RND_NEAREST,FP_LONG,FP_SINGLE);}});
4094377Sgblack@eecs.umich.edu                                0x1: trunc_l_s({{ Fd = convert_and_round(Fs.sf,RND_ZERO,FP_LONG,FP_SINGLE);}});
4104377Sgblack@eecs.umich.edu                                0x2: ceil_l_s({{ Fd = convert_and_round(Fs.sf,RND_UP,FP_LONG,FP_SINGLE);}});
4114377Sgblack@eecs.umich.edu                                0x3: floor_l_s({{ Fd = convert_and_round(Fs.sf,RND_DOWN,FP_LONG,FP_SINGLE);}});
4124377Sgblack@eecs.umich.edu                            }
4134181Sgblack@eecs.umich.edu
4144181Sgblack@eecs.umich.edu                            format FloatOp {
4154181Sgblack@eecs.umich.edu                                0x4: round_w_s({{ Fd = convert_and_round(Fs.sf,RND_NEAREST,FP_WORD,FP_SINGLE);}});
4164539Sgblack@eecs.umich.edu                                0x5: trunc_w_s({{ Fd = convert_and_round(Fs.sf,RND_ZERO,FP_WORD,FP_SINGLE);}});
4173276Sgblack@eecs.umich.edu                                0x6: ceil_w_s({{  Fd = convert_and_round(Fs.sf,RND_UP,FP_WORD,FP_SINGLE);}});
4187720Sgblack@eecs.umich.edu                                0x7: floor_w_s({{ Fd = convert_and_round(Fs.sf,RND_DOWN,FP_WORD,FP_SINGLE);}});
4193280Sgblack@eecs.umich.edu                            }
4203280Sgblack@eecs.umich.edu                        }
4213276Sgblack@eecs.umich.edu
4223276Sgblack@eecs.umich.edu                        0x2: decode RS_LO {
4233276Sgblack@eecs.umich.edu                            0x1: decode MOVCF {
4247720Sgblack@eecs.umich.edu                                format FloatOp {
4253276Sgblack@eecs.umich.edu                                    0x0: movfs({{ if ( FPConditionCode(CC) == 0 ) Fd = Fs; }});
4263276Sgblack@eecs.umich.edu                                    0x1: movts({{ if ( FPConditionCode(CC) == 1 ) Fd = Fs;}});
4274181Sgblack@eecs.umich.edu                                }
4288955Sgblack@eecs.umich.edu                            }
4294522Ssaidi@eecs.umich.edu
4307823Ssteve.reinhardt@amd.com                            format BasicOp {
4317720Sgblack@eecs.umich.edu                                0x2: movzs({{ if (Rt == 0) Fd = Fs; }});
4322470SN/A                                0x3: movns({{ if (Rt != 0) Fd = Fs; }});
4338955Sgblack@eecs.umich.edu                            }
4344181Sgblack@eecs.umich.edu
4354522Ssaidi@eecs.umich.edu                            format Float64Op {
4364181Sgblack@eecs.umich.edu                                0x2: recips({{ Fd = 1 / Fs; }});
4372623SN/A                                0x3: rsqrts({{ Fd = 1 / sqrt(Fs.ud);}});
4382623SN/A                            }
4392623SN/A                        }
4402623SN/A
4412623SN/A                        0x4: decode RS_LO {
4427720Sgblack@eecs.umich.edu
4437720Sgblack@eecs.umich.edu                            format FloatOp {
4447720Sgblack@eecs.umich.edu                                0x1: cvt_d_s({{ int rnd_mode = xc->miscRegs.fcsr;
4457720Sgblack@eecs.umich.edu                                Fd = convert_and_round(Fs.sf,rnd_mode,FP_DOUBLE,FP_SINGLE);
4468780Sgblack@eecs.umich.edu                                }});
4473577Sgblack@eecs.umich.edu
4487720Sgblack@eecs.umich.edu                                0x4: cvt_w_s({{ int rnd_mode = xc->miscRegs.fcsr;
4495086Sgblack@eecs.umich.edu                                Fd = convert_and_round(Fs.sf,rnd_mode,FP_WORD,FP_SINGLE);
4502623SN/A                                }});
4512683Sktlim@umich.edu                            }
4522623SN/A
4532SN/A                            //only legal for 64 bit
4542623SN/A                            format Float64Op {
4552623SN/A                                0x5: cvt_l_s({{ int rnd_mode = xc->miscRegs.fcsr;
4562SN/A                                Fd = convert_and_round(Fs.sf,rnd_mode,FP_LONG,FP_SINGLE);
4572SN/A                                }});
4582623SN/A
4592623SN/A                                0x6: cvt_ps_s({{ Fd.df = Fs.df<31:0> | Ft.df<31:0>; }});
4602623SN/A                            }
4612623SN/A                        }
4622SN/A                    }
4635953Ssaidi@eecs.umich.edu
4647720Sgblack@eecs.umich.edu                    //Table A-15 MIPS32 COP1 Encoding of Function Field When rs=D
4655953Ssaidi@eecs.umich.edu                    0x1: decode RS_HI {
4665953Ssaidi@eecs.umich.edu                        0x0: decode RS_LO {
4677897Shestness@cs.utexas.edu                            format FloatOp {
4687897Shestness@cs.utexas.edu                                0x0: addd({{ Fd.df = Fs.df + Ft.df;}});
4697897Shestness@cs.utexas.edu                                0x1: subd({{ Fd.df = Fs.df - Ft.df;}});
4707897Shestness@cs.utexas.edu                                0x2: muld({{ Fd.df = Fs.df * Ft.df;}});
4717897Shestness@cs.utexas.edu                                0x3: divd({{ Fd.df = Fs.df / Ft.df;}});
4727897Shestness@cs.utexas.edu                                0x4: sqrtd({{ Fd.df = sqrt(Fs.df);}});
4737897Shestness@cs.utexas.edu                                0x5: absd({{ Fd.df = abs(Fs.df);}});
4747897Shestness@cs.utexas.edu                                0x6: movd({{ Fd.df = Fs.df;}});
4757897Shestness@cs.utexas.edu                                0x7: negd({{ Fd.df = -1 * Fs.df;}});
4767897Shestness@cs.utexas.edu                            }
4777897Shestness@cs.utexas.edu                        }
4787897Shestness@cs.utexas.edu
4797897Shestness@cs.utexas.edu                        0x1: decode RS_LO {
4807897Shestness@cs.utexas.edu                            //only legal for 64 bit
4817897Shestness@cs.utexas.edu                            format Float64Op {
4827897Shestness@cs.utexas.edu                                0x0: round_l_d({{ Fd = convert_and_round(Fs.df,RND_NEAREST,FP_LONG,FP_DOUBLE); }});
4837897Shestness@cs.utexas.edu                                0x1: trunc_l_d({{ Fd = convert_and_round(Fs.df,RND_ZERO,FP_LONG,FP_DOUBLE);}});
4847897Shestness@cs.utexas.edu                                0x2: ceil_l_d({{ Fd = convert_and_round(Fs.df,RND_UP,FP_LONG,FP_DOUBLE);}});
4857897Shestness@cs.utexas.edu                                0x3: floor_l_d({{ Fd = convert_and_round(Fs.df,RND_DOWN,FP_LONG,FP_DOUBLE);}});
4867897Shestness@cs.utexas.edu                            }
4877897Shestness@cs.utexas.edu
4887897Shestness@cs.utexas.edu                            format FloatOp {
4897897Shestness@cs.utexas.edu                                0x4: round_w_d({{ Fd = convert_and_round(Fs.df,RND_NEAREST,FP_LONG,FP_DOUBLE); }});
4907897Shestness@cs.utexas.edu                                0x5: trunc_w_d({{ Fd = convert_and_round(Fs.df,RND_ZERO,FP_LONG,FP_DOUBLE); }});
4917897Shestness@cs.utexas.edu                                0x6: ceil_w_d({{  Fd = convert_and_round(Fs.df,RND_UP,FP_LONG,FP_DOUBLE); }});
4927897Shestness@cs.utexas.edu                                0x7: floor_w_d({{ Fd = convert_and_round(Fs.df,RND_DOWN,FP_LONG,FP_DOUBLE); }});
4937897Shestness@cs.utexas.edu                            }
4947897Shestness@cs.utexas.edu                        }
4957897Shestness@cs.utexas.edu
4967897Shestness@cs.utexas.edu                        0x2: decode RS_LO {
4977897Shestness@cs.utexas.edu                            0x1: decode MOVCF {
4987897Shestness@cs.utexas.edu                                format FloatOp {
4997897Shestness@cs.utexas.edu                                    0x0: movfd({{ if (FPConditionCode(CC) == 0) Fd.df = Fs.df; }});
5008780Sgblack@eecs.umich.edu                                    0x1: movtd({{ if (FPConditionCode(CC) == 1) Fd.df = Fs.df; }});
5018780Sgblack@eecs.umich.edu                                }
5022644Sstever@eecs.umich.edu                            }
5032644Sstever@eecs.umich.edu
5044046Sbinkertn@umich.edu                            format BasicOp {
5054046Sbinkertn@umich.edu                                0x2: movz({{ if (Rt == 0) Fd.df = Fs.df; }});
5064046Sbinkertn@umich.edu                                0x3: movn({{ if (Rt != 0) Fd.df = Fs.df; }});
5072644Sstever@eecs.umich.edu                            }
5082623SN/A
5092SN/A                            format Float64Op {
5102SN/A                                0x5: recipd({{ Fd.df = 1 / Fs.df}});
5112623SN/A                                0x6: rsqrtd({{ Fd.df = 1 / sqrt(Fs.df) }});
5122623SN/A                            }
5132623SN/A                        }
5144377Sgblack@eecs.umich.edu
5154377Sgblack@eecs.umich.edu                        0x4: decode RS_LO {
5162090SN/A                            format FloatOp {
5173905Ssaidi@eecs.umich.edu                                0x0: cvt_s_d({{
5187678Sgblack@eecs.umich.edu                                    int rnd_mode = xc->miscRegs.fcsr;
5199023Sgblack@eecs.umich.edu                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_DOUBLE);
5204377Sgblack@eecs.umich.edu                                }});
5217720Sgblack@eecs.umich.edu
5227720Sgblack@eecs.umich.edu                                0x4: cvt_w_d({{
5237720Sgblack@eecs.umich.edu                                    int rnd_mode = xc->miscRegs.fcsr;
5247720Sgblack@eecs.umich.edu                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_WORD,FP_DOUBLE);
5257720Sgblack@eecs.umich.edu                                }});
5267720Sgblack@eecs.umich.edu                            }
5273276Sgblack@eecs.umich.edu
5282SN/A                            //only legal for 64 bit
5292SN/A                            format Float64Op {
5302SN/A                                0x5: cvt_l_d({{
5319461Snilay@cs.wisc.edu                                    int rnd_mode = xc->miscRegs.fcsr;
5329461Snilay@cs.wisc.edu                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_LONG,FP_DOUBLE);
5339461Snilay@cs.wisc.edu                                }});
5349461Snilay@cs.wisc.edu                            }
5359461Snilay@cs.wisc.edu                        }
5369461Snilay@cs.wisc.edu                    }
537
538                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=W
539                    0x4: decode FUNCTION {
540                        format FloatOp {
541                            0x10: cvt_s({{
542                                int rnd_mode = xc->miscRegs.fcsr;
543                                Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_WORD);
544                            }});
545
546                            0x10: cvt_d({{
547                                int rnd_mode = xc->miscRegs.fcsr;
548                                Fd = convert_and_round(Fs.df,rnd_mode,FP_DOUBLE,FP_WORD);
549                            }});
550                        }
551                    }
552
553                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=L1
554                    //Note: "1. Format type L is legal only if 64-bit floating point operations
555                    //are enabled."
556                    0x5: decode FUNCTION_HI {
557                        format FloatOp {
558                            0x10: cvt_s_l({{
559                                int rnd_mode = xc->miscRegs.fcsr;
560                                Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_LONG);
561                            }});
562
563                            0x11: cvt_d_l({{
564                                int rnd_mode = xc->miscRegs.fcsr;
565                                Fd = convert_and_round(Fs.df,rnd_mode,FP_DOUBLE,FP_LONG);
566                            }});
567                        }
568                    }
569
570                    //Table A-17 MIPS64 COP1 Encoding of Function Field When rs=PS1
571                    //Note: "1. Format type PS is legal only if 64-bit floating point operations
572                    //are enabled. "
573                    0x6: decode RS_HI {
574                        0x0: decode RS_LO {
575                            format Float64Op {
576                                0x0: addps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
577                                    //Lower Halves Independently but we take simulator shortcut
578                                    Fd.df = Fs.df + Ft.df;
579                                }});
580
581                                0x1: subps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
582                                    //Lower Halves Independently but we take simulator shortcut
583                                    Fd.df = Fs.df - Ft.df;
584                                }});
585
586                                0x2: mulps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
587                                    //Lower Halves Independently but we take simulator shortcut
588                                    Fd.df = Fs.df * Ft.df;
589                                }});
590
591                                0x5: absps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
592                                    //Lower Halves Independently but we take simulator shortcut
593                                    Fd.df = abs(Fs.df);
594                                }});
595
596                                0x6: movps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
597                                    //Lower Halves Independently but we take simulator shortcut
598                                    Fd.df = Fs<31:0> |  Ft<31:0>;
599                                }});
600
601                                0x7: negps({{ //Must Check for Exception Here... Supposed to Operate on Upper and
602                                    //Lower Halves Independently but we take simulator shortcut
603                                    Fd.df = -1 * Fs.df;
604                                }});
605                            }
606                        }
607
608                        0x2: decode RS_LO {
609                            0x1: decode MOVCF {
610                                format Float64Op {
611                                    0x0: movfps({{ if ( FPConditionCode(CC) == 0) Fd = Fs;}});
612                                    0x1: movtps({{ if ( FPConditionCode(CC) == 0) Fd = Fs;}});
613                                }
614                            }
615
616                        }
617
618                        0x4: decode RS_LO {
619                            0x0: Float64Op::cvt_s_pu({{
620                                int rnd_mode = xc->miscRegs.fcsr;
621                                Fd = convert_and_round(Fs.df,rnd_mode,FP_DOUBLE,FP_PS_HI);
622                            }});
623                        }
624
625                        0x5: decode RS_LO {
626                            format Float64Op {
627                                0x0: cvt_s_pl({{
628                                    int rnd_mode = xc->miscRegs.fcsr;
629                                    Fd = convert_and_round(Fs.df,rnd_mode,FP_SINGLE,FP_PS_LO);
630                                }});
631                                0x4: pll({{ Fd.df = Fs<31:0> | Ft<31:0>}});
632                                0x5: plu({{ Fd.df = Fs<31:0> | Ft<63:32>}});
633                                0x6: pul({{ Fd.df = Fs<63:32> | Ft<31:0>}});
634                                0x7: puu({{ Fd.df = Fs<63:32 | Ft<63:32>}});
635                            }
636                        }
637                    }
638                }
639            }
640        }
641
642        //Table A-19 MIPS32 COP2 Encoding of rs Field
643        0x2: decode RS_MSB {
644            0x0: decode RS_HI {
645                0x0: decode RS_LO {
646                    format WarnUnimpl {
647                        0x0: mfc2();
648                        0x2: cfc2();
649                        0x3: mfhc2();
650                        0x4: mtc2();
651                        0x6: ctc2();
652                        0x7: mftc2();
653                    }
654                }
655
656                0x1: decode ND {
657                    0x0: decode TF {
658                        format WarnUnimpl {
659                            0x0: bc2f();
660                            0x1: bc2t();
661                        }
662                    }
663
664                    0x1: decode TF {
665                        format WarnUnimpl {
666                            0x0: bc2fl();
667                            0x1: bc2tl();
668                        }
669                    }
670                }
671            }
672        }
673
674        //Table A-20 MIPS64 COP1X Encoding of Function Field 1
675        //Note: "COP1X instructions are legal only if 64-bit floating point
676        //operations are enabled."
677        0x3: decode FUNCTION_HI {
678            0x0: decode FUNCTION_LO {
679                format LoadMemory2 {
680                    0x0: lwxc1({{ EA = Rs + Rt; }},{{ Ft<31:0> = Mem.sf; }});
681                    0x1: ldxc1({{ EA = Rs + Rt; }},{{ Ft<63:0> = Mem.df; }});
682                    0x5: luxc1({{ //Need to make EA<2:0> = 0
683                        EA = Rs + Rt;
684                    }},
685                {{ Ft<31:0> = Mem.df; }});
686                }
687            }
688
689            0x1: decode FUNCTION_LO {
690                format StoreMemory2 {
691                    0x0: swxc1({{ EA = Rs + Rt; }},{{ Mem.sf = Ft<31:0>; }});
692                    0x1: sdxc1({{ EA = Rs + Rt; }},{{ Mem.df = Ft<63:0>}});
693                    0x5: suxc1({{ //Need to make EA<2:0> = 0
694                        EA = Rs + Rt;
695                    }},
696                {{ Mem.df = Ft<63:0>;}});
697                }
698
699                0x7: WarnUnimpl::prefx();
700            }
701
702            format FloatOp {
703                0x3: WarnUnimpl::alnv_ps();
704
705                format BasicOp {
706                    0x4: decode FUNCTION_LO {
707                        0x0: madd_s({{ Fd.sf = (Fs.sf * Fs.sf) + Fr.sf; }});
708                        0x1: madd_d({{ Fd.df = (Fs.df * Fs.df) + Fr.df; }});
709                        0x6: madd_ps({{
710                            //Must Check for Exception Here... Supposed to Operate on Upper and
711                            //Lower Halves Independently but we take simulator shortcut
712                            Fd.df = (Fs.df * Fs.df) + Fr.df;
713                        }});
714                    }
715
716                    0x5: decode FUNCTION_LO {
717                        0x0: msub_s({{ Fd.sf = (Fs.sf * Fs.sf) - Fr.sf; }});
718                        0x1: msub_d({{ Fd.df = (Fs.df * Fs.df) - Fr.df; }});
719                        0x6: msub_ps({{
720                            //Must Check for Exception Here... Supposed to Operate on Upper and
721                            //Lower Halves Independently but we take simulator shortcut
722                            Fd.df = (Fs.df * Fs.df) - Fr.df;
723                        }});
724                    }
725
726                    0x6: decode FUNCTION_LO {
727                        0x0: nmadd_s({{ Fd.sf = (-1 * Fs.sf * Fs.sf) - Fr.sf; }});
728                        0x1: nmadd_d({{ Fd.df = (-1 * Fs.df * Fs.df) + Fr.df; }});
729                        0x6: nmadd_ps({{
730                            //Must Check for Exception Here... Supposed to Operate on Upper and
731                            //Lower Halves Independently but we take simulator shortcut
732                            Fd.df = (-1 * Fs.df * Fs.df) + Fr.df;
733                        }});
734                    }
735
736                    0x7: decode FUNCTION_LO {
737                        0x0: nmsub_s({{ Fd.sf = (-1 * Fs.sf * Fs.sf) - Fr.sf; }});
738                        0x1: nmsub_d({{ Fd.df = (-1 * Fs.df * Fs.df) - Fr.df; }});
739                        0x6: nmsub_ps({{
740                            //Must Check for Exception Here... Supposed to Operate on Upper and
741                            //Lower Halves Independently but we take simulator shortcut
742                            Fd.df = (-1 * Fs.df * Fs.df) + Fr.df;
743                        }});
744                    }
745                }
746            }
747        }
748
749        //MIPS obsolete instructions
750        format BranchLikely {
751            0x4: beql({{ cond = (Rs.sw == 0); }});
752            0x5: bnel({{ cond = (Rs.sw != 0); }});
753            0x6: blezl({{ cond = (Rs.sw <= 0); }});
754            0x7: bgtzl({{ cond = (Rs.sw > 0); }});
755        }
756    }
757
758    0x3: decode OPCODE_LO default FailUnimpl::reserved() {
759
760        //Table A-5 MIPS32 SPECIAL2 Encoding of Function Field
761        0x4: decode FUNCTION_HI {
762
763            0x0: decode FUNCTION_LO {
764                format IntOp {
765                    0x0: madd({{
766                        INT64 temp1 = Hi.sw << 32 | Lo.sw >> 32;
767                        temp1 = temp1 + (Rs.sw * Rt.sw);
768                        xc->miscRegs.hi->temp1<63:32>;
769                        xc->miscRegs.lo->temp1<31:0>
770                            }});
771
772                    0x1: maddu({{
773                        INT64 temp1 = Hi.uw << 32 | Lo.uw >> 32;
774                        temp1 = temp1 + (Rs.uw * Rt.uw);
775                        xc->miscRegs.hi->temp1<63:32>;
776                        xc->miscRegs.lo->temp1<31:0>
777                            }});
778
779                    0x2: mul({{ 	Rd.sw = Rs.sw * Rt.sw; 	}});
780
781                    0x4: msub({{
782                        INT64 temp1 = Hi.sw << 32 | Lo.sw >> 32;
783                        temp1 = temp1 - (Rs.sw * Rt.sw);
784                        xc->miscRegs.hi->temp1<63:32>;
785                        xc->miscRegs.lo->temp1<31:0>
786                            }});
787
788                    0x5: msubu({{
789                        INT64 temp1 = Hi.uw << 32 | Lo.uw >> 32;
790                        temp1 = temp1 - (Rs.uw * Rt.uw);
791                        xc->miscRegs.hi->temp1<63:32>;
792                        xc->miscRegs.lo->temp1<31:0>
793                            }});
794                }
795            }
796
797            0x4: decode FUNCTION_LO {
798                format BasicOp {
799                    0x0: clz({{
800                        int cnt = 0;
801                        int idx = 0;
802                        while ( Rs.uw<idx>!= 1) {
803                            cnt++;
804                            idx--;
805                        }
806
807                        Rd.uw = cnt;
808                    }});
809
810                    0x1: clo({{
811                        int cnt = 0;
812                        int idx = 0;
813                        while ( Rs.uw<idx>!= 0) {
814                            cnt++;
815                            idx--;
816                        }
817
818                        Rd.uw = cnt;
819                    }});
820                }
821            }
822
823            0x7: decode FUNCTION_LO {
824                0x7: WarnUnimpl::sdbbp();
825            }
826        }
827
828        //Table A-6 MIPS32 SPECIAL3 Encoding of Function Field for Release 2 of the Architecture
829        0x7: decode FUNCTION_HI {
830
831            0x0: decode FUNCTION_LO {
832                format WarnUnimpl {
833                    0x1: ext();
834                    0x4: ins();
835                }
836            }
837
838            0x1: decode FUNCTION_LO {
839                format WarnUnimpl {
840                    0x0: fork();
841                    0x1: yield();
842                }
843            }
844
845
846            //Table A-10 MIPS32 BSHFL Encoding of sa Field
847            0x4: decode SA {
848
849                0x02: WarnUnimpl::wsbh();
850
851                format BasicOp {
852                    0x10: seb({{ Rd.sw = /* sext32(Rt<7>,24)  | */ Rt<7:0>}});
853                    0x18: seh({{ Rd.sw = /* sext32(Rt<15>,16) | */ Rt<15:0>}});
854                }
855            }
856
857            0x6: decode FUNCTION_LO {
858                0x7: BasicOp::rdhwr({{ Rt = xc->hwRegs[RD];}});
859            }
860        }
861    }
862
863    0x4: decode OPCODE_LO default FailUnimpl::reserved() {
864        format LoadMemory {
865            0x0: lb({{ Rb.sw = Mem.sb; }});
866            0x1: lh({{ Rb.sw = Mem.sh; }});
867            0x2: lwl({{ Rb.sw = Mem.sw; }});//, WordAlign);
868            0x3: lw({{ Rb.uq = Mem.sb; }});
869            0x4: lbu({{ Rb.uw = Mem.ub; }});
870            0x5: lhu({{ Rb.uw = Mem.uh; }});
871            0x6: lwr({{ Rb.uw = Mem.uw; }});//, WordAlign);
872        }
873
874        0x7: FailUnimpl::reserved();
875    }
876
877    0x5: decode OPCODE_LO default FailUnimpl::reserved() {
878        format StoreMemory {
879            0x0: sb({{ Mem.ub = Rt<7:0>; }});
880            0x1: sh({{ Mem.uh = Rt<15:0>; }});
881            0x2: swl({{ Mem.ub = Rt<31:0>; }});//,WordAlign);
882            0x3: sw({{ Mem.ub = Rt<31:0>; }});
883            0x6: swr({{ Mem.ub = Rt<31:0>; }});//,WordAlign);
884        }
885
886        format WarnUnimpl {
887            0x7: cache();
888        }
889
890    }
891
892    0x6: decode OPCODE_LO default FailUnimpl::reserved() {
893        0x0: WarnUnimpl::ll();
894
895        format LoadMemory {
896            0x1: lwc1({{ Ft<31:0> = Mem.sf; }});
897            0x5: ldc1({{ Ft<63:0> = Mem.df; }});
898        }
899    }
900
901    0x7: decode OPCODE_LO default FailUnimpl::reserved() {
902        0x0: WarnUnimpl::sc();
903
904        format StoreMemory {
905            0x1: swc1({{ Mem.sf = Ft<31:0>; }});
906            0x5: sdc1({{ Mem.df = Ft<63:0>; }});
907        }
908
909    }
910}
911
912
913