decoder.isa revision 2686
12810SN/A// -*- mode:c++ -*-
212724Snikos.nikoleris@arm.com
38856Sandreas.hansson@arm.com////////////////////////////////////////////////////////////////////
48856Sandreas.hansson@arm.com//
58856Sandreas.hansson@arm.com// The actual MIPS32 ISA decoder
68856Sandreas.hansson@arm.com// -----------------------------
78856Sandreas.hansson@arm.com// The following instructions are specified in the MIPS32 ISA
88856Sandreas.hansson@arm.com// Specification. Decoding closely follows the style specified
98856Sandreas.hansson@arm.com// in the MIPS32 ISA specification document starting with Table
108856Sandreas.hansson@arm.com// A-2 (document available @ www.mips.com)
118856Sandreas.hansson@arm.com//
128856Sandreas.hansson@arm.comdecode OPCODE_HI default Unknown::unknown() {
138856Sandreas.hansson@arm.com    //Table A-2
142810SN/A    0x0: decode OPCODE_LO {
152810SN/A        0x0: decode FUNCTION_HI {
162810SN/A            0x0: decode FUNCTION_LO {
172810SN/A                0x1: decode MOVCI {
182810SN/A                    format BasicOp {
192810SN/A                        0: movf({{ Rd = (getCondCode(FCSR, CC) == 0) ? Rd : Rs; }});
202810SN/A                        1: movt({{ Rd = (getCondCode(FCSR, CC) == 1) ? Rd : Rs; }});
212810SN/A                    }
222810SN/A                }
232810SN/A
242810SN/A                format BasicOp {
252810SN/A                    //Table A-3 Note: "Specific encodings of the rd, rs, and
262810SN/A                    //rt fields are used to distinguish SLL, SSNOP, and EHB
272810SN/A                    //functions
282810SN/A                    0x0: decode RS  {
292810SN/A                        0x0: decode RT_RD {
302810SN/A                            0x0: decode SA default Nop::nop(){
312810SN/A                                0x1: WarnUnimpl::ssnop();
322810SN/A                                0x3: WarnUnimpl::ehb();
332810SN/A                            }
342810SN/A                            default: sll({{ Rd = Rt.uw << SA; }});
352810SN/A                        }
362810SN/A                    }
372810SN/A
382810SN/A                    0x2: decode RS_SRL {
392810SN/A                        0x0:decode SRL {
402810SN/A                            0: srl({{ Rd = Rt.uw >> SA; }});
4112724Snikos.nikoleris@arm.com
422810SN/A                            //Hardcoded assuming 32-bit ISA, probably need parameter here
432810SN/A                            1: rotr({{ Rd = (Rt.uw << (32 - SA)) | (Rt.uw >> SA);}});
442810SN/A                        }
452810SN/A                    }
462810SN/A
472810SN/A                    0x3: decode RS {
482810SN/A                        0x0: sra({{
4911486Snikos.nikoleris@arm.com                            uint32_t temp = Rt >> SA;
5011486Snikos.nikoleris@arm.com                            if ( (Rt & 0x80000000) > 0 ) {
5112724Snikos.nikoleris@arm.com                                uint32_t mask = 0x80000000;
5212724Snikos.nikoleris@arm.com                                for(int i=0; i < SA; i++) {
538232Snate@binkert.org                                    temp |= mask;
5412724Snikos.nikoleris@arm.com                                    mask = mask >> 1;
5512724Snikos.nikoleris@arm.com                                }
5611486Snikos.nikoleris@arm.com                            }
5712724Snikos.nikoleris@arm.com                            Rd = temp;
5812724Snikos.nikoleris@arm.com                        }});
5912724Snikos.nikoleris@arm.com                    }
6012724Snikos.nikoleris@arm.com
6112724Snikos.nikoleris@arm.com                    0x4: sllv({{ Rd = Rt.uw << Rs<4:0>; }});
6212724Snikos.nikoleris@arm.com
6312724Snikos.nikoleris@arm.com                    0x6: decode SRLV {
642810SN/A                        0: srlv({{ Rd = Rt.uw >> Rs<4:0>; }});
652810SN/A
662810SN/A                        //Hardcoded assuming 32-bit ISA, probably need parameter here
678856Sandreas.hansson@arm.com                        1: rotrv({{ Rd = (Rt.uw << (32 - Rs<4:0>)) | (Rt.uw >> Rs<4:0>);}});
688856Sandreas.hansson@arm.com                    }
698856Sandreas.hansson@arm.com
708922Swilliam.wang@arm.com                    0x7: srav({{
7112084Sspwilson2@wisc.edu                        int shift_amt = Rs<4:0>;
7212084Sspwilson2@wisc.edu
738856Sandreas.hansson@arm.com                        uint32_t temp = Rt >> shift_amt;
748856Sandreas.hansson@arm.com
754475SN/A                        if ( (Rt & 0x80000000) > 0 ) {
7611053Sandreas.hansson@arm.com                                uint32_t mask = 0x80000000;
775034SN/A                                for(int i=0; i < shift_amt; i++) {
7812724Snikos.nikoleris@arm.com                                    temp |= mask;
7912724Snikos.nikoleris@arm.com                                    mask = mask >> 1;
8011377Sandreas.hansson@arm.com                                }
8111377Sandreas.hansson@arm.com                            }
8212724Snikos.nikoleris@arm.com
8312724Snikos.nikoleris@arm.com                        Rd = temp;
8412724Snikos.nikoleris@arm.com                    }});
8512724Snikos.nikoleris@arm.com                }
8612724Snikos.nikoleris@arm.com            }
8712724Snikos.nikoleris@arm.com
8812724Snikos.nikoleris@arm.com            0x1: decode FUNCTION_LO {
8912724Snikos.nikoleris@arm.com                //Table A-3 Note: "Specific encodings of the hint field are
9011053Sandreas.hansson@arm.com                //used to distinguish JR from JR.HB and JALR from JALR.HB"
9111722Ssophiane.senni@gmail.com                format Jump {
9211722Ssophiane.senni@gmail.com                    0x0: decode HINT {
9311722Ssophiane.senni@gmail.com                        0x1: jr_hb({{ NNPC = Rs & ~1; }}, IsReturn, ClearHazards);
9411722Ssophiane.senni@gmail.com                        default: jr({{ NNPC = Rs & ~1; }}, IsReturn);
959263Smrinmoy.ghosh@arm.com                    }
965034SN/A
9711331Sandreas.hansson@arm.com                    0x1: decode HINT {
9812724Snikos.nikoleris@arm.com                        0x1: jalr_hb({{ Rd = NNPC; NNPC = Rs; }}, IsCall, Link
9910884Sandreas.hansson@arm.com                                     , ClearHazards);
1004626SN/A                        default: jalr({{ Rd = NNPC; NNPC = Rs; }}, IsCall,
10110360Sandreas.hansson@arm.com                                      Link);
10211484Snikos.nikoleris@arm.com                    }
1035034SN/A                }
1048883SAli.Saidi@ARM.com
1058833Sdam.sunwoo@arm.com                format BasicOp {
1064458SN/A                    0x2: movz({{ Rd = (Rt == 0) ? Rs : Rd; }});
10711377Sandreas.hansson@arm.com                    0x3: movn({{ Rd = (Rt != 0) ? Rs : Rd; }});
10811377Sandreas.hansson@arm.com                    0x4: syscall({{ xc->syscall(R2); }}, IsNonSpeculative);
10911377Sandreas.hansson@arm.com                    0x7: sync({{ ; }}, IsMemBarrier);
11011377Sandreas.hansson@arm.com                }
11111377Sandreas.hansson@arm.com
11211377Sandreas.hansson@arm.com                format FailUnimpl {
11311331Sandreas.hansson@arm.com                    0x5: break();
11411331Sandreas.hansson@arm.com                }
11512724Snikos.nikoleris@arm.com            }
11612730Sodanrc@yahoo.com.br
11712724Snikos.nikoleris@arm.com            0x2: decode FUNCTION_LO {
11812724Snikos.nikoleris@arm.com                format HiLoMiscOp {
11912724Snikos.nikoleris@arm.com                    0x0: mfhi({{ Rd = HI; }});
12012724Snikos.nikoleris@arm.com                    0x1: mthi({{ HI = Rs; }});
12112724Snikos.nikoleris@arm.com                    0x2: mflo({{ Rd = LO; }});
12212724Snikos.nikoleris@arm.com                    0x3: mtlo({{ LO = Rs; }});
12312724Snikos.nikoleris@arm.com                }
12412724Snikos.nikoleris@arm.com            }
12512724Snikos.nikoleris@arm.com
12612724Snikos.nikoleris@arm.com            0x3: decode FUNCTION_LO {
12712724Snikos.nikoleris@arm.com                format HiLoOp {
1282810SN/A                    0x0: mult({{ val = Rs.sd * Rt.sd; }});
1292810SN/A                    0x1: multu({{ val = Rs.ud * Rt.ud; }});
1303013SN/A                }
1318856Sandreas.hansson@arm.com
1322810SN/A                format HiLoMiscOp {
1333013SN/A                    0x2: div({{
13410714Sandreas.hansson@arm.com                        HI = Rs.sd % Rt.sd;
1352810SN/A                        LO = Rs.sd / Rt.sd;
1369614Srene.dejong@arm.com                    }});
1379614Srene.dejong@arm.com                    0x3: divu({{
1389614Srene.dejong@arm.com                        HI = Rs.ud % Rt.ud;
13910345SCurtis.Dunham@arm.com                        LO = Rs.ud / Rt.ud;
14010714Sandreas.hansson@arm.com                    }});
14110345SCurtis.Dunham@arm.com                }
1429614Srene.dejong@arm.com            }
1432810SN/A
1442810SN/A            0x4: decode HINT {
1452810SN/A                0x0: decode FUNCTION_LO {
1468856Sandreas.hansson@arm.com                    format IntOp {
1472810SN/A                        0x0: add({{  Rd.sw = Rs.sw + Rt.sw; /*Trap on Overflow*/}});
1483013SN/A                        0x1: addu({{ Rd.sw = Rs.sw + Rt.sw;}});
14910714Sandreas.hansson@arm.com                        0x2: sub({{ Rd.sw = Rs.sw - Rt.sw;  /*Trap on Overflow*/}});
1503013SN/A                        0x3: subu({{ Rd.sw = Rs.sw - Rt.sw;}});
1518856Sandreas.hansson@arm.com                        0x4: and({{ Rd = Rs & Rt;}});
15210714Sandreas.hansson@arm.com                        0x5: or({{ Rd = Rs | Rt;}});
1538922Swilliam.wang@arm.com                        0x6: xor({{ Rd = Rs ^ Rt;}});
1542897SN/A                        0x7: nor({{ Rd = ~(Rs | Rt);}});
1552810SN/A                    }
1562810SN/A                }
15710344Sandreas.hansson@arm.com            }
15810344Sandreas.hansson@arm.com
15910344Sandreas.hansson@arm.com            0x5: decode HINT {
16010714Sandreas.hansson@arm.com                0x0: decode FUNCTION_LO {
16110344Sandreas.hansson@arm.com                    format IntOp{
16210344Sandreas.hansson@arm.com                        0x2: slt({{  Rd.sw = ( Rs.sw < Rt.sw ) ? 1 : 0}});
16310344Sandreas.hansson@arm.com                        0x3: sltu({{ Rd.uw = ( Rs.uw < Rt.uw ) ? 1 : 0}});
16410713Sandreas.hansson@arm.com                    }
16510344Sandreas.hansson@arm.com                }
1662844SN/A            }
16712730Sodanrc@yahoo.com.br
16812730Sodanrc@yahoo.com.br            0x6: decode FUNCTION_LO {
16912730Sodanrc@yahoo.com.br                format Trap {
17012730Sodanrc@yahoo.com.br                    0x0: tge({{  cond = (Rs.sw >= Rt.sw); }});
17112730Sodanrc@yahoo.com.br                    0x1: tgeu({{ cond = (Rs.uw >= Rt.uw); }});
17212730Sodanrc@yahoo.com.br                    0x2: tlt({{ cond = (Rs.sw < Rt.sw); }});
17312730Sodanrc@yahoo.com.br                    0x3: tltu({{ cond = (Rs.uw >= Rt.uw); }});
17412730Sodanrc@yahoo.com.br                    0x4: teq({{ cond = (Rs.sw == Rt.sw); }});
17512730Sodanrc@yahoo.com.br                    0x6: tne({{ cond = (Rs.sw != Rt.sw); }});
17612730Sodanrc@yahoo.com.br                }
1772810SN/A            }
1782858SN/A        }
1792858SN/A
18012724Snikos.nikoleris@arm.com        0x1: decode REGIMM_HI {
1818922Swilliam.wang@arm.com            0x0: decode REGIMM_LO {
18212724Snikos.nikoleris@arm.com                format Branch {
18312724Snikos.nikoleris@arm.com                    0x0: bltz({{ cond = (Rs.sw < 0); }});
1842858SN/A                    0x1: bgez({{ cond = (Rs.sw >= 0); }});
1852858SN/A                    0x2: bltzl({{ cond = (Rs.sw < 0); }}, Likely);
1869294Sandreas.hansson@arm.com                    0x3: bgezl({{ cond = (Rs.sw >= 0); }}, Likely);
1879294Sandreas.hansson@arm.com                }
1888922Swilliam.wang@arm.com            }
1898922Swilliam.wang@arm.com
19012724Snikos.nikoleris@arm.com            0x1: decode REGIMM_LO {
1918922Swilliam.wang@arm.com                format Trap {
1928922Swilliam.wang@arm.com                    0x0: tgei( {{ cond = (Rs.sw >= INTIMM); }});
1938922Swilliam.wang@arm.com                    0x1: tgeiu({{ cond = (Rs.uw >= INTIMM); }});
1948922Swilliam.wang@arm.com                    0x2: tlti( {{ cond = (Rs.sw < INTIMM); }});
1958922Swilliam.wang@arm.com                    0x3: tltiu({{ cond = (Rs.uw < INTIMM); }});
1969294Sandreas.hansson@arm.com                    0x4: teqi( {{ cond = (Rs.sw == INTIMM);}});
1979294Sandreas.hansson@arm.com                    0x6: tnei( {{ cond = (Rs.sw != INTIMM);}});
1988922Swilliam.wang@arm.com                }
1998922Swilliam.wang@arm.com            }
20012724Snikos.nikoleris@arm.com
2018922Swilliam.wang@arm.com            0x2: decode REGIMM_LO {
2028922Swilliam.wang@arm.com                format Branch {
2038922Swilliam.wang@arm.com                    0x0: bltzal({{ cond = (Rs.sw < 0); }}, Link);
2048922Swilliam.wang@arm.com                    0x1: decode RS {
2054628SN/A                        0x0: bal ({{ cond = 1; }}, IsCall, Link);
20610821Sandreas.hansson@arm.com                        default: bgezal({{ cond = (Rs.sw >= 0); }}, Link);
20710821Sandreas.hansson@arm.com                    }
20810821Sandreas.hansson@arm.com                    0x2: bltzall({{ cond = (Rs.sw < 0); }}, Link, Likely);
20910821Sandreas.hansson@arm.com                    0x3: bgezall({{ cond = (Rs.sw >= 0); }}, Link, Likely);
21010821Sandreas.hansson@arm.com                }
21110821Sandreas.hansson@arm.com            }
21210821Sandreas.hansson@arm.com
21310821Sandreas.hansson@arm.com            0x3: decode REGIMM_LO {
21410821Sandreas.hansson@arm.com                format WarnUnimpl {
21510821Sandreas.hansson@arm.com                    0x7: synci();
21610821Sandreas.hansson@arm.com                }
2172858SN/A            }
21812724Snikos.nikoleris@arm.com        }
21912724Snikos.nikoleris@arm.com
22012724Snikos.nikoleris@arm.com        format Jump {
22112724Snikos.nikoleris@arm.com            0x2: j({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2);}});
22212724Snikos.nikoleris@arm.com            0x3: jal({{ NNPC = (NPC & 0xF0000000) | (JMPTARG << 2); }}, IsCall,
22312724Snikos.nikoleris@arm.com                     Link);
22412724Snikos.nikoleris@arm.com        }
22512724Snikos.nikoleris@arm.com
22612724Snikos.nikoleris@arm.com        format Branch {
22712724Snikos.nikoleris@arm.com            0x4: decode RS_RT  {
22812724Snikos.nikoleris@arm.com                0x0: b({{ cond = 1; }});
22912724Snikos.nikoleris@arm.com                default: beq({{ cond = (Rs.sw == Rt.sw); }});
23012724Snikos.nikoleris@arm.com            }
23112724Snikos.nikoleris@arm.com            0x5: bne({{ cond = (Rs.sw != Rt.sw); }});
23212724Snikos.nikoleris@arm.com            0x6: blez({{ cond = (Rs.sw <= 0); }});
23312724Snikos.nikoleris@arm.com            0x7: bgtz({{ cond = (Rs.sw > 0); }});
23412724Snikos.nikoleris@arm.com        }
23512724Snikos.nikoleris@arm.com    }
23612724Snikos.nikoleris@arm.com
23712724Snikos.nikoleris@arm.com    0x1: decode OPCODE_LO {
23812724Snikos.nikoleris@arm.com        format IntImmOp {
23912724Snikos.nikoleris@arm.com            0x0: addi({{ Rt.sw = Rs.sw + imm; /*Trap If Overflow*/}});
24012724Snikos.nikoleris@arm.com            0x1: addiu({{ Rt.sw = Rs.sw + imm;}});
24112724Snikos.nikoleris@arm.com            0x2: slti({{ Rt.sw = ( Rs.sw < imm) ? 1 : 0 }});
24212724Snikos.nikoleris@arm.com            0x3: sltiu({{ Rt.uw = ( Rs.uw < (uint32_t)sextImm ) ? 1 : 0 }});
24312724Snikos.nikoleris@arm.com            0x4: andi({{ Rt.sw = Rs.sw & zextImm;}});
24412724Snikos.nikoleris@arm.com            0x5: ori({{ Rt.sw = Rs.sw | zextImm;}});
24512724Snikos.nikoleris@arm.com            0x6: xori({{ Rt.sw = Rs.sw ^ zextImm;}});
24612724Snikos.nikoleris@arm.com
24712724Snikos.nikoleris@arm.com            0x7: decode RS {
24812724Snikos.nikoleris@arm.com                0x0: lui({{ Rt = imm << 16}});
24912724Snikos.nikoleris@arm.com            }
25012724Snikos.nikoleris@arm.com        }
25112724Snikos.nikoleris@arm.com    }
25212724Snikos.nikoleris@arm.com
25312724Snikos.nikoleris@arm.com    0x2: decode OPCODE_LO {
25412724Snikos.nikoleris@arm.com        //Table A-11 MIPS32 COP0 Encoding of rs Field
25512724Snikos.nikoleris@arm.com        0x0: decode RS_MSB {
25612724Snikos.nikoleris@arm.com            0x0: decode RS {
25712724Snikos.nikoleris@arm.com                format CP0Control {
25812724Snikos.nikoleris@arm.com                    0x0: mfc0({{ Rt = xc->readMiscReg(RD << 5 | SEL); }});
25912724Snikos.nikoleris@arm.com                    0x4: mtc0({{ xc->setMiscReg(RD << 5 | SEL, Rt); }});
26012724Snikos.nikoleris@arm.com                }
26112724Snikos.nikoleris@arm.com
26212724Snikos.nikoleris@arm.com                format MipsMT {
26312724Snikos.nikoleris@arm.com                    0x8: mftr();
26412724Snikos.nikoleris@arm.com                    0xC: mttr();
26512724Snikos.nikoleris@arm.com                    0xB: decode RD {
26612724Snikos.nikoleris@arm.com                        0x0: decode SC {
26712724Snikos.nikoleris@arm.com                            0x0: dvpe();
26812724Snikos.nikoleris@arm.com                            0x1: evpe();
26912724Snikos.nikoleris@arm.com                        }
27012724Snikos.nikoleris@arm.com                        0x1: decode SC {
27112724Snikos.nikoleris@arm.com                            0x0: dmt();
27212724Snikos.nikoleris@arm.com                            0x1: emt();
27312724Snikos.nikoleris@arm.com                            0xC: decode SC {
27412724Snikos.nikoleris@arm.com                                0x0: di();
27512724Snikos.nikoleris@arm.com                                0x1: ei();
27612724Snikos.nikoleris@arm.com                            }
27712724Snikos.nikoleris@arm.com                        }
27812724Snikos.nikoleris@arm.com                    }
27912724Snikos.nikoleris@arm.com                }
28012724Snikos.nikoleris@arm.com
28112724Snikos.nikoleris@arm.com                format FailUnimpl {
28212724Snikos.nikoleris@arm.com                    0xA: rdpgpr();
28312724Snikos.nikoleris@arm.com                    0xE: wrpgpr();
28412724Snikos.nikoleris@arm.com                }
28512724Snikos.nikoleris@arm.com            }
28612724Snikos.nikoleris@arm.com
28712724Snikos.nikoleris@arm.com            //Table A-12 MIPS32 COP0 Encoding of Function Field When rs=CO
28812724Snikos.nikoleris@arm.com            0x1: decode FUNCTION {
28912724Snikos.nikoleris@arm.com                format FailUnimpl {
29012724Snikos.nikoleris@arm.com                    0x01: tlbr();
29112724Snikos.nikoleris@arm.com                    0x02: tlbwi();
29212724Snikos.nikoleris@arm.com                    0x06: tlbwr();
29312724Snikos.nikoleris@arm.com                    0x08: tlbp();
29412724Snikos.nikoleris@arm.com
29512724Snikos.nikoleris@arm.com                    0x18: eret();
29612724Snikos.nikoleris@arm.com                    0x1F: deret();
29712724Snikos.nikoleris@arm.com                    0x20: wait();
29812724Snikos.nikoleris@arm.com                }
29912724Snikos.nikoleris@arm.com            }
30012724Snikos.nikoleris@arm.com        }
30112724Snikos.nikoleris@arm.com
30212724Snikos.nikoleris@arm.com        //Table A-13 MIPS32 COP1 Encoding of rs Field
30312724Snikos.nikoleris@arm.com        0x1: decode RS_MSB {
30412724Snikos.nikoleris@arm.com
30512724Snikos.nikoleris@arm.com            0x0: decode RS_HI {
30612724Snikos.nikoleris@arm.com                0x0: decode RS_LO {
30712724Snikos.nikoleris@arm.com                    format CP1Control {
30812724Snikos.nikoleris@arm.com                        0x0: mfc1 ({{ Rt.uw = Fs.uw<31:0>; }});
30912724Snikos.nikoleris@arm.com
31012724Snikos.nikoleris@arm.com                        0x2: cfc1({{
31112724Snikos.nikoleris@arm.com                            switch (FS)
31212724Snikos.nikoleris@arm.com                            {
31312724Snikos.nikoleris@arm.com                              case 0:
31412724Snikos.nikoleris@arm.com                                Rt = FIR;
31512724Snikos.nikoleris@arm.com                                break;
31612724Snikos.nikoleris@arm.com                              case 25:
31712724Snikos.nikoleris@arm.com                                Rt = 0 | (FCSR & 0xFE000000) >> 24 | (FCSR & 0x00800000) >> 23;
31812724Snikos.nikoleris@arm.com                                break;
31912724Snikos.nikoleris@arm.com                              case 26:
32012724Snikos.nikoleris@arm.com                                Rt = 0 | (FCSR & 0x0003F07C);
32112724Snikos.nikoleris@arm.com                                break;
32212724Snikos.nikoleris@arm.com                              case 28:
32312724Snikos.nikoleris@arm.com                                Rt = 0 | (FCSR & 0x00000F80) | (FCSR & 0x01000000) >> 21 | (FCSR & 0x00000003);
32412724Snikos.nikoleris@arm.com                                break;
32512724Snikos.nikoleris@arm.com                              case 31:
32612724Snikos.nikoleris@arm.com                                Rt = FCSR;
32712724Snikos.nikoleris@arm.com                                break;
32812724Snikos.nikoleris@arm.com                              default:
32912724Snikos.nikoleris@arm.com                                panic("FP Control Value (%d) Not Valid");
33012724Snikos.nikoleris@arm.com                            }
33112724Snikos.nikoleris@arm.com                        }});
33212724Snikos.nikoleris@arm.com
33312724Snikos.nikoleris@arm.com                        0x3: mfhc1({{ Rt.uw = Fs.ud<63:32>;}});
33412724Snikos.nikoleris@arm.com
33512724Snikos.nikoleris@arm.com                        0x4: mtc1 ({{ Fs.uw = Rt.uw;       }});
33612724Snikos.nikoleris@arm.com
33712724Snikos.nikoleris@arm.com                        0x6: ctc1({{
33812724Snikos.nikoleris@arm.com                            switch (FS)
33912724Snikos.nikoleris@arm.com                            {
34012724Snikos.nikoleris@arm.com                              case 25:
34112724Snikos.nikoleris@arm.com                                FCSR = 0 | (Rt.uw<7:1> << 25) // move 31...25
34212724Snikos.nikoleris@arm.com                                    | (FCSR & 0x01000000) // bit 24
34312724Snikos.nikoleris@arm.com                                    | (FCSR & 0x004FFFFF);// bit 22...0
34412724Snikos.nikoleris@arm.com                                break;
34512724Snikos.nikoleris@arm.com
34612724Snikos.nikoleris@arm.com                              case 26:
34712724Snikos.nikoleris@arm.com                                FCSR = 0 | (FCSR & 0xFFFC0000) // move 31...18
34812724Snikos.nikoleris@arm.com                                    | Rt.uw<17:12> << 12           // bit 17...12
34912724Snikos.nikoleris@arm.com                                    | (FCSR & 0x00000F80) << 7// bit 11...7
35012724Snikos.nikoleris@arm.com                                    | Rt.uw<6:2> << 2              // bit 6...2
35112724Snikos.nikoleris@arm.com                                    | (FCSR & 0x00000002);     // bit 1...0
35212724Snikos.nikoleris@arm.com                                break;
35312724Snikos.nikoleris@arm.com
35412724Snikos.nikoleris@arm.com                              case 28:
35512724Snikos.nikoleris@arm.com                                FCSR = 0 | (FCSR & 0xFE000000) // move 31...25
35612724Snikos.nikoleris@arm.com                                    | Rt.uw<2:2> << 24       // bit 24
35712724Snikos.nikoleris@arm.com                                    | (FCSR & 0x00FFF000) << 23// bit 23...12
35812724Snikos.nikoleris@arm.com                                    | Rt.uw<11:7> << 7       // bit 24
35912724Snikos.nikoleris@arm.com                                    | (FCSR & 0x000007E)
36012724Snikos.nikoleris@arm.com                                    | Rt.uw<1:0>;// bit 22...0
36112724Snikos.nikoleris@arm.com                                break;
36212724Snikos.nikoleris@arm.com
36312724Snikos.nikoleris@arm.com                              case 31:
36412724Snikos.nikoleris@arm.com                                FCSR  = Rt.uw;
36512724Snikos.nikoleris@arm.com                                break;
36612724Snikos.nikoleris@arm.com
36712724Snikos.nikoleris@arm.com                              default:
36812724Snikos.nikoleris@arm.com                                panic("FP Control Value (%d) Not Available. Ignoring Access to"
36912724Snikos.nikoleris@arm.com                                      "Floating Control Status Register", FS);
37012724Snikos.nikoleris@arm.com                            }
37112724Snikos.nikoleris@arm.com                        }});
37212724Snikos.nikoleris@arm.com
37312724Snikos.nikoleris@arm.com                        0x7: mthc1({{
37412724Snikos.nikoleris@arm.com                             uint64_t fs_hi = Rt.uw;
37512724Snikos.nikoleris@arm.com                             uint64_t fs_lo = Fs.ud & 0x0FFFFFFFF;
37612724Snikos.nikoleris@arm.com                             Fs.ud = (fs_hi << 32) | fs_lo;
37712724Snikos.nikoleris@arm.com                        }});
37812724Snikos.nikoleris@arm.com
37912724Snikos.nikoleris@arm.com                    }
38012724Snikos.nikoleris@arm.com                }
38112724Snikos.nikoleris@arm.com
38212724Snikos.nikoleris@arm.com                0x1: decode ND {
38312724Snikos.nikoleris@arm.com                    format Branch {
38412724Snikos.nikoleris@arm.com                        0x0: decode TF {
38512724Snikos.nikoleris@arm.com                            0x0: bc1f({{ cond = getCondCode(FCSR, BRANCH_CC) == 0;
38612724Snikos.nikoleris@arm.com                                      }});
38712724Snikos.nikoleris@arm.com                            0x1: bc1t({{ cond = getCondCode(FCSR, BRANCH_CC) == 1;
38812724Snikos.nikoleris@arm.com                                      }});
38912724Snikos.nikoleris@arm.com                        }
39012724Snikos.nikoleris@arm.com                        0x1: decode TF {
39112724Snikos.nikoleris@arm.com                            0x0: bc1fl({{ cond = getCondCode(FCSR, BRANCH_CC) == 0;
39212724Snikos.nikoleris@arm.com                                       }}, Likely);
39312724Snikos.nikoleris@arm.com                            0x1: bc1tl({{ cond = getCondCode(FCSR, BRANCH_CC) == 1;
39412724Snikos.nikoleris@arm.com                                       }}, Likely);
39512724Snikos.nikoleris@arm.com                        }
39612724Snikos.nikoleris@arm.com                    }
39712724Snikos.nikoleris@arm.com                }
39812724Snikos.nikoleris@arm.com            }
39912724Snikos.nikoleris@arm.com
40012724Snikos.nikoleris@arm.com            0x1: decode RS_HI {
40112724Snikos.nikoleris@arm.com                0x2: decode RS_LO {
40212724Snikos.nikoleris@arm.com                    //Table A-14 MIPS32 COP1 Encoding of Function Field When rs=S
40312724Snikos.nikoleris@arm.com                    //(( single-precision floating point))
40412724Snikos.nikoleris@arm.com                    0x0: decode FUNCTION_HI {
40512724Snikos.nikoleris@arm.com                        0x0: decode FUNCTION_LO {
40612724Snikos.nikoleris@arm.com                            format FloatOp {
40712724Snikos.nikoleris@arm.com                                0x0: add_s({{ Fd.sf = Fs.sf + Ft.sf;}});
40812724Snikos.nikoleris@arm.com                                0x1: sub_s({{ Fd.sf = Fs.sf - Ft.sf;}});
40912724Snikos.nikoleris@arm.com                                0x2: mul_s({{ Fd.sf = Fs.sf * Ft.sf;}});
41012724Snikos.nikoleris@arm.com                                0x3: div_s({{ Fd.sf = Fs.sf / Ft.sf;}});
41112724Snikos.nikoleris@arm.com                                0x4: sqrt_s({{ Fd.sf = sqrt(Fs.sf);}});
41212724Snikos.nikoleris@arm.com                                0x5: abs_s({{ Fd.sf = fabs(Fs.sf);}});
41312724Snikos.nikoleris@arm.com                                0x6: mov_s({{ Fd.sf = Fs.sf;}});
41412724Snikos.nikoleris@arm.com                                0x7: neg_s({{ Fd.sf = -Fs.sf;}});
41512724Snikos.nikoleris@arm.com                            }
41612724Snikos.nikoleris@arm.com                        }
41712724Snikos.nikoleris@arm.com
41812724Snikos.nikoleris@arm.com                        0x1: decode FUNCTION_LO {
41912724Snikos.nikoleris@arm.com                            format FloatConvertOp {
42012724Snikos.nikoleris@arm.com                                0x0: round_l_s({{ val = Fs.sf; }}, ToLong,
42112724Snikos.nikoleris@arm.com                                               Round);
42212724Snikos.nikoleris@arm.com                                0x1: trunc_l_s({{ val = Fs.sf; }}, ToLong,
42312724Snikos.nikoleris@arm.com                                               Trunc);
42412724Snikos.nikoleris@arm.com                                0x2: ceil_l_s({{ val = Fs.sf; }}, ToLong,
42512724Snikos.nikoleris@arm.com                                               Ceil);
42612724Snikos.nikoleris@arm.com                                0x3: floor_l_s({{ val = Fs.sf; }}, ToLong,
42712724Snikos.nikoleris@arm.com                                               Floor);
42812724Snikos.nikoleris@arm.com                                0x4: round_w_s({{ val = Fs.sf; }}, ToWord,
42912724Snikos.nikoleris@arm.com                                               Round);
43012724Snikos.nikoleris@arm.com                                0x5: trunc_w_s({{ val = Fs.sf; }}, ToWord,
43112724Snikos.nikoleris@arm.com                                               Trunc);
43212724Snikos.nikoleris@arm.com                                0x6: ceil_w_s({{ val = Fs.sf; }}, ToWord,
43312724Snikos.nikoleris@arm.com                                               Ceil);
43412724Snikos.nikoleris@arm.com                                0x7: floor_w_s({{ val = Fs.sf; }}, ToWord,
43512724Snikos.nikoleris@arm.com                                               Floor);
43612724Snikos.nikoleris@arm.com                            }
43712724Snikos.nikoleris@arm.com                        }
43812724Snikos.nikoleris@arm.com
43912724Snikos.nikoleris@arm.com                        0x2: decode FUNCTION_LO {
44012724Snikos.nikoleris@arm.com                            0x1: decode MOVCF {
44112724Snikos.nikoleris@arm.com                                format BasicOp {
44212724Snikos.nikoleris@arm.com                                    0x0: movf_s({{ Fd = (getCondCode(FCSR,CC) == 0) ? Fs : Fd; }});
44312724Snikos.nikoleris@arm.com                                    0x1: movt_s({{ Fd = (getCondCode(FCSR,CC) == 1) ? Fs : Fd; }});
44412724Snikos.nikoleris@arm.com                                }
44512724Snikos.nikoleris@arm.com                            }
44612724Snikos.nikoleris@arm.com
44712724Snikos.nikoleris@arm.com                            format BasicOp {
44812724Snikos.nikoleris@arm.com                                0x2: movz_s({{ Fd = (Rt == 0) ? Fs : Fd; }});
44912724Snikos.nikoleris@arm.com                                0x3: movn_s({{ Fd = (Rt != 0) ? Fs : Fd; }});
45012724Snikos.nikoleris@arm.com                            }
45112724Snikos.nikoleris@arm.com
45212724Snikos.nikoleris@arm.com                            format FloatOp {
45312724Snikos.nikoleris@arm.com                                0x5: recip_s({{ Fd = 1 / Fs; }});
45412724Snikos.nikoleris@arm.com                                0x6: rsqrt_s({{ Fd = 1 / sqrt(Fs);}});
45512724Snikos.nikoleris@arm.com                            }
45612724Snikos.nikoleris@arm.com                        }
45712724Snikos.nikoleris@arm.com
45812724Snikos.nikoleris@arm.com                        0x4: decode FUNCTION_LO {
45912724Snikos.nikoleris@arm.com                            format FloatConvertOp {
46012724Snikos.nikoleris@arm.com                                0x1: cvt_d_s({{ val = Fs.sf; }}, ToDouble);
46112724Snikos.nikoleris@arm.com                                0x4: cvt_w_s({{ val = Fs.sf; }}, ToWord);
46212724Snikos.nikoleris@arm.com                                0x5: cvt_l_s({{ val = Fs.sf; }}, ToLong);
46312724Snikos.nikoleris@arm.com                            }
46412724Snikos.nikoleris@arm.com
46512724Snikos.nikoleris@arm.com                            0x6: FloatOp::cvt_ps_s({{
46612724Snikos.nikoleris@arm.com                                    Fd.ud = (uint64_t) Fs.uw << 32 |
46712724Snikos.nikoleris@arm.com                                            (uint64_t) Ft.uw;
46812724Snikos.nikoleris@arm.com                                }});
46912724Snikos.nikoleris@arm.com                        }
47012724Snikos.nikoleris@arm.com
47112724Snikos.nikoleris@arm.com                        0x6: decode FUNCTION_LO {
47212724Snikos.nikoleris@arm.com                            format FloatCompareOp {
47312724Snikos.nikoleris@arm.com                                0x0: c_f_s({{ cond = 0; }}, SinglePrecision,
47412724Snikos.nikoleris@arm.com                                           UnorderedFalse);
47512724Snikos.nikoleris@arm.com                                0x1: c_un_s({{ cond = 0; }}, SinglePrecision,
47612724Snikos.nikoleris@arm.com                                            UnorderedTrue);
47712724Snikos.nikoleris@arm.com                                0x2: c_eq_s({{ cond = (Fs.sf == Ft.sf); }},
47812724Snikos.nikoleris@arm.com                                            UnorderedFalse);
47912724Snikos.nikoleris@arm.com                                0x3: c_ueq_s({{ cond = (Fs.sf == Ft.sf); }},
48012724Snikos.nikoleris@arm.com                                             UnorderedTrue);
48112724Snikos.nikoleris@arm.com                                0x4: c_olt_s({{ cond = (Fs.sf < Ft.sf);	}},
48212724Snikos.nikoleris@arm.com                                             UnorderedFalse);
48312724Snikos.nikoleris@arm.com                                0x5: c_ult_s({{ cond = (Fs.sf < Ft.sf); }},
48412724Snikos.nikoleris@arm.com                                             UnorderedTrue);
48512724Snikos.nikoleris@arm.com                                0x6: c_ole_s({{ cond = (Fs.sf <= Ft.sf); }},
48612724Snikos.nikoleris@arm.com                                             UnorderedFalse);
48712724Snikos.nikoleris@arm.com                                0x7: c_ule_s({{ cond = (Fs.sf <= Ft.sf); }},
48812724Snikos.nikoleris@arm.com                                             UnorderedTrue);
48912724Snikos.nikoleris@arm.com                            }
49012724Snikos.nikoleris@arm.com                        }
49112724Snikos.nikoleris@arm.com
49212724Snikos.nikoleris@arm.com                        0x7: decode FUNCTION_LO {
49312724Snikos.nikoleris@arm.com                            format FloatCompareOp {
49412794Snikos.nikoleris@arm.com                                0x0: c_sf_s({{ cond = 0; }}, SinglePrecision,
49512794Snikos.nikoleris@arm.com                                            UnorderedFalse, QnanException);
49612794Snikos.nikoleris@arm.com                                0x1: c_ngle_s({{ cond = 0; }}, SinglePrecision,
49712794Snikos.nikoleris@arm.com                                              UnorderedTrue, QnanException);
49812794Snikos.nikoleris@arm.com                                0x2: c_seq_s({{ cond = (Fs.sf == Ft.sf);}},
49912794Snikos.nikoleris@arm.com                                             UnorderedFalse, QnanException);
50012724Snikos.nikoleris@arm.com                                0x3: c_ngl_s({{ cond = (Fs.sf == Ft.sf); }},
50112724Snikos.nikoleris@arm.com                                             UnorderedTrue, QnanException);
50212724Snikos.nikoleris@arm.com                                0x4: c_lt_s({{ cond = (Fs.sf < Ft.sf); }},
50312724Snikos.nikoleris@arm.com                                            UnorderedFalse, QnanException);
50412724Snikos.nikoleris@arm.com                                0x5: c_nge_s({{ cond = (Fs.sf < Ft.sf); }},
50512724Snikos.nikoleris@arm.com                                             UnorderedTrue, QnanException);
50612724Snikos.nikoleris@arm.com                                0x6: c_le_s({{ cond = (Fs.sf <= Ft.sf); }},
50712724Snikos.nikoleris@arm.com                                            UnorderedFalse, QnanException);
50812724Snikos.nikoleris@arm.com                                0x7: c_ngt_s({{ cond = (Fs.sf <= Ft.sf); }},
50912724Snikos.nikoleris@arm.com                                             UnorderedTrue, QnanException);
51012724Snikos.nikoleris@arm.com                            }
51112724Snikos.nikoleris@arm.com                        }
51212724Snikos.nikoleris@arm.com                    }
51312724Snikos.nikoleris@arm.com
51412724Snikos.nikoleris@arm.com                    //Table A-15 MIPS32 COP1 Encoding of Function Field When rs=D
51512724Snikos.nikoleris@arm.com                    0x1: decode FUNCTION_HI {
51612724Snikos.nikoleris@arm.com                        0x0: decode FUNCTION_LO {
51712724Snikos.nikoleris@arm.com                            format FloatOp {
51812724Snikos.nikoleris@arm.com                                0x0: add_d({{ Fd.df = Fs.df + Ft.df; }});
51912724Snikos.nikoleris@arm.com                                0x1: sub_d({{ Fd.df = Fs.df - Ft.df; }});
52012724Snikos.nikoleris@arm.com                                0x2: mul_d({{ Fd.df = Fs.df * Ft.df; }});
52112724Snikos.nikoleris@arm.com                                0x3: div_d({{ Fd.df = Fs.df / Ft.df; }});
52212724Snikos.nikoleris@arm.com                                0x4: sqrt_d({{ Fd.df = sqrt(Fs.df);  }});
52312724Snikos.nikoleris@arm.com                                0x5: abs_d({{ Fd.df = fabs(Fs.df);   }});
52412724Snikos.nikoleris@arm.com                                0x6: mov_d({{ Fd.df = Fs.df;         }});
52512724Snikos.nikoleris@arm.com                                0x7: neg_d({{ Fd.df = -1 * Fs.df;    }});
52612724Snikos.nikoleris@arm.com                            }
52712724Snikos.nikoleris@arm.com                        }
52812724Snikos.nikoleris@arm.com
52912724Snikos.nikoleris@arm.com                        0x1: decode FUNCTION_LO {
53012724Snikos.nikoleris@arm.com                            format FloatConvertOp {
53112724Snikos.nikoleris@arm.com                                0x0: round_l_d({{ val = Fs.df; }}, ToLong,
53212724Snikos.nikoleris@arm.com                                               Round);
53312724Snikos.nikoleris@arm.com                                0x1: trunc_l_d({{ val = Fs.df; }}, ToLong,
53412724Snikos.nikoleris@arm.com                                               Trunc);
53512724Snikos.nikoleris@arm.com                                0x2: ceil_l_d({{ val = Fs.df; }}, ToLong,
53612724Snikos.nikoleris@arm.com                                               Ceil);
53712724Snikos.nikoleris@arm.com                                0x3: floor_l_d({{ val = Fs.df; }}, ToLong,
53812724Snikos.nikoleris@arm.com                                               Floor);
53912724Snikos.nikoleris@arm.com                                0x4: round_w_d({{ val = Fs.df; }}, ToWord,
54012724Snikos.nikoleris@arm.com                                               Round);
54112724Snikos.nikoleris@arm.com                                0x5: trunc_w_d({{ val = Fs.df; }}, ToWord,
54212724Snikos.nikoleris@arm.com                                               Trunc);
54312724Snikos.nikoleris@arm.com                                0x6: ceil_w_d({{ val = Fs.df; }}, ToWord,
54412724Snikos.nikoleris@arm.com                                               Ceil);
54512724Snikos.nikoleris@arm.com                                0x7: floor_w_d({{ val = Fs.df; }}, ToWord,
54612724Snikos.nikoleris@arm.com                                               Floor);
54712724Snikos.nikoleris@arm.com                            }
54812724Snikos.nikoleris@arm.com                        }
54912724Snikos.nikoleris@arm.com
55012724Snikos.nikoleris@arm.com                        0x2: decode FUNCTION_LO {
55112724Snikos.nikoleris@arm.com                            0x1: decode MOVCF {
55212724Snikos.nikoleris@arm.com                                format BasicOp {
55312724Snikos.nikoleris@arm.com                                    0x0: movf_d({{ Fd.df = (getCondCode(FCSR,CC) == 0) ?
55412724Snikos.nikoleris@arm.com                                                       Fs.df : Fd.df;
55512724Snikos.nikoleris@arm.com                                                }});
55612724Snikos.nikoleris@arm.com                                    0x1: movt_d({{ Fd.df = (getCondCode(FCSR,CC) == 1) ?
55712724Snikos.nikoleris@arm.com                                                       Fs.df : Fd.df;
55812724Snikos.nikoleris@arm.com                                                }});
55912724Snikos.nikoleris@arm.com                                }
56012724Snikos.nikoleris@arm.com                            }
56112724Snikos.nikoleris@arm.com
56212724Snikos.nikoleris@arm.com                            format BasicOp {
56312724Snikos.nikoleris@arm.com                                0x2: movz_d({{ Fd.df = (Rt == 0) ? Fs.df : Fd.df; }});
56412724Snikos.nikoleris@arm.com                                0x3: movn_d({{ Fd.df = (Rt != 0) ? Fs.df : Fd.df; }});
56512724Snikos.nikoleris@arm.com                            }
56612724Snikos.nikoleris@arm.com
56712724Snikos.nikoleris@arm.com                            format FloatOp {
56812724Snikos.nikoleris@arm.com                                0x5: recip_d({{ Fd.df = 1 / Fs.df }});
56912724Snikos.nikoleris@arm.com                                0x6: rsqrt_d({{ Fd.df = 1 / sqrt(Fs.df) }});
57012724Snikos.nikoleris@arm.com                            }
57112724Snikos.nikoleris@arm.com                        }
57212724Snikos.nikoleris@arm.com
57312724Snikos.nikoleris@arm.com                        0x4: decode FUNCTION_LO {
57412724Snikos.nikoleris@arm.com                            format FloatConvertOp {
57512724Snikos.nikoleris@arm.com                                0x0: cvt_s_d({{ val = Fs.df; }}, ToSingle);
57612724Snikos.nikoleris@arm.com                                0x4: cvt_w_d({{ val = Fs.df; }}, ToWord);
57712724Snikos.nikoleris@arm.com                                0x5: cvt_l_d({{ val = Fs.df; }}, ToLong);
57812724Snikos.nikoleris@arm.com                            }
57912724Snikos.nikoleris@arm.com                        }
58012724Snikos.nikoleris@arm.com
58112724Snikos.nikoleris@arm.com                        0x6: decode FUNCTION_LO {
58212724Snikos.nikoleris@arm.com                            format FloatCompareOp {
58312724Snikos.nikoleris@arm.com                                0x0: c_f_d({{ cond = 0; }}, DoublePrecision,
58412724Snikos.nikoleris@arm.com                                           UnorderedFalse);
58512724Snikos.nikoleris@arm.com                                0x1: c_un_d({{ cond = 0; }}, DoublePrecision,
58612724Snikos.nikoleris@arm.com                                            UnorderedTrue);
58712724Snikos.nikoleris@arm.com                                0x2: c_eq_d({{ cond = (Fs.df == Ft.df); }},
58812724Snikos.nikoleris@arm.com                                            UnorderedFalse);
58912724Snikos.nikoleris@arm.com                                0x3: c_ueq_d({{ cond = (Fs.df == Ft.df); }},
59012724Snikos.nikoleris@arm.com                                             UnorderedTrue);
59112724Snikos.nikoleris@arm.com                                0x4: c_olt_d({{ cond = (Fs.df < Ft.df);	}},
59212724Snikos.nikoleris@arm.com                                             UnorderedFalse);
59312724Snikos.nikoleris@arm.com                                0x5: c_ult_d({{ cond = (Fs.df < Ft.df); }},
59412724Snikos.nikoleris@arm.com                                             UnorderedTrue);
59512724Snikos.nikoleris@arm.com                                0x6: c_ole_d({{ cond = (Fs.df <= Ft.df); }},
59612724Snikos.nikoleris@arm.com                                             UnorderedFalse);
59712724Snikos.nikoleris@arm.com                                0x7: c_ule_d({{ cond = (Fs.df <= Ft.df); }},
59812724Snikos.nikoleris@arm.com                                             UnorderedTrue);
59912724Snikos.nikoleris@arm.com                            }
60012724Snikos.nikoleris@arm.com                        }
60112724Snikos.nikoleris@arm.com
60212724Snikos.nikoleris@arm.com                        0x7: decode FUNCTION_LO {
60312724Snikos.nikoleris@arm.com                            format FloatCompareOp {
60412724Snikos.nikoleris@arm.com                                0x0: c_sf_d({{ cond = 0; }}, DoublePrecision,
60512724Snikos.nikoleris@arm.com                                            UnorderedFalse, QnanException);
60612724Snikos.nikoleris@arm.com                                0x1: c_ngle_d({{ cond = 0; }}, DoublePrecision,
60712724Snikos.nikoleris@arm.com                                              UnorderedTrue, QnanException);
60812724Snikos.nikoleris@arm.com                                0x2: c_seq_d({{ cond = (Fs.df == Ft.df); }},
60912724Snikos.nikoleris@arm.com                                             UnorderedFalse, QnanException);
61012724Snikos.nikoleris@arm.com                                0x3: c_ngl_d({{ cond = (Fs.df == Ft.df); }},
61112724Snikos.nikoleris@arm.com                                             UnorderedTrue, QnanException);
61212724Snikos.nikoleris@arm.com                                0x4: c_lt_d({{ cond = (Fs.df < Ft.df); }},
61312724Snikos.nikoleris@arm.com                                            UnorderedFalse, QnanException);
61412724Snikos.nikoleris@arm.com                                0x5: c_nge_d({{ cond = (Fs.df < Ft.df); }},
61512724Snikos.nikoleris@arm.com                                             UnorderedTrue, QnanException);
61612724Snikos.nikoleris@arm.com                                0x6: c_le_d({{ cond = (Fs.df <= Ft.df); }},
61712724Snikos.nikoleris@arm.com                                            UnorderedFalse, QnanException);
61812724Snikos.nikoleris@arm.com                                0x7: c_ngt_d({{ cond = (Fs.df <= Ft.df); }},
61912724Snikos.nikoleris@arm.com                                             UnorderedTrue, QnanException);
62012724Snikos.nikoleris@arm.com                            }
62112724Snikos.nikoleris@arm.com                        }
62212724Snikos.nikoleris@arm.com                    }
62312724Snikos.nikoleris@arm.com
62412724Snikos.nikoleris@arm.com                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=W
62512724Snikos.nikoleris@arm.com                    0x4: decode FUNCTION {
62612724Snikos.nikoleris@arm.com                        format FloatConvertOp {
62712724Snikos.nikoleris@arm.com                            0x20: cvt_s_w({{ val = Fs.uw; }}, ToSingle);
62812724Snikos.nikoleris@arm.com                            0x21: cvt_d_w({{ val = Fs.uw; }}, ToDouble);
62912724Snikos.nikoleris@arm.com                            0x26: FailUnimpl::cvt_ps_w();
63012724Snikos.nikoleris@arm.com                        }
63112724Snikos.nikoleris@arm.com                    }
63212724Snikos.nikoleris@arm.com
63312724Snikos.nikoleris@arm.com                    //Table A-16 MIPS32 COP1 Encoding of Function Field When rs=L1
63412724Snikos.nikoleris@arm.com                    //Note: "1. Format type L is legal only if 64-bit floating point operations
63512724Snikos.nikoleris@arm.com                    //are enabled."
63612724Snikos.nikoleris@arm.com                    0x5: decode FUNCTION_HI {
63712724Snikos.nikoleris@arm.com                        format FloatConvertOp {
63812724Snikos.nikoleris@arm.com                            0x20: cvt_s_l({{ val = Fs.ud; }}, ToSingle);
63912724Snikos.nikoleris@arm.com                            0x21: cvt_d_l({{ val = Fs.ud; }}, ToDouble);
64012724Snikos.nikoleris@arm.com                            0x26: FailUnimpl::cvt_ps_l();
64112724Snikos.nikoleris@arm.com                        }
64212724Snikos.nikoleris@arm.com                    }
64312724Snikos.nikoleris@arm.com
64412724Snikos.nikoleris@arm.com                    //Table A-17 MIPS64 COP1 Encoding of Function Field When rs=PS1
64512724Snikos.nikoleris@arm.com                    //Note: "1. Format type PS is legal only if 64-bit floating point operations
64612724Snikos.nikoleris@arm.com                    //are enabled. "
64712724Snikos.nikoleris@arm.com                    0x6: decode FUNCTION_HI {
64812724Snikos.nikoleris@arm.com                        0x0: decode FUNCTION_LO {
64912724Snikos.nikoleris@arm.com                            format Float64Op {
65012724Snikos.nikoleris@arm.com                                0x0: add_ps({{
65112724Snikos.nikoleris@arm.com                                    Fd1.sf = Fs1.sf + Ft2.sf;
65212724Snikos.nikoleris@arm.com                                    Fd2.sf = Fs2.sf + Ft2.sf;
65312724Snikos.nikoleris@arm.com                                }});
65412724Snikos.nikoleris@arm.com                                0x1: sub_ps({{
65512724Snikos.nikoleris@arm.com                                    Fd1.sf = Fs1.sf - Ft2.sf;
65612724Snikos.nikoleris@arm.com                                    Fd2.sf = Fs2.sf - Ft2.sf;
65712724Snikos.nikoleris@arm.com                                }});
65812724Snikos.nikoleris@arm.com                                0x2: mul_ps({{
65912724Snikos.nikoleris@arm.com                                    Fd1.sf = Fs1.sf * Ft2.sf;
66012724Snikos.nikoleris@arm.com                                    Fd2.sf = Fs2.sf * Ft2.sf;
66112724Snikos.nikoleris@arm.com                                }});
66212724Snikos.nikoleris@arm.com                                0x5: abs_ps({{
66312724Snikos.nikoleris@arm.com                                    Fd1.sf = fabs(Fs1.sf);
66412724Snikos.nikoleris@arm.com                                    Fd2.sf = fabs(Fs2.sf);
66512724Snikos.nikoleris@arm.com                                }});
66612724Snikos.nikoleris@arm.com                                0x6: mov_ps({{
66712724Snikos.nikoleris@arm.com                                    Fd1.sf = Fs1.sf;
66812724Snikos.nikoleris@arm.com                                    Fd2.sf = Fs2.sf;
66912724Snikos.nikoleris@arm.com                                }});
67012724Snikos.nikoleris@arm.com                                0x7: neg_ps({{
67112724Snikos.nikoleris@arm.com                                    Fd1.sf = -(Fs1.sf);
67212724Snikos.nikoleris@arm.com                                    Fd2.sf = -(Fs2.sf);
67312724Snikos.nikoleris@arm.com                                }});
67412724Snikos.nikoleris@arm.com                            }
67512724Snikos.nikoleris@arm.com                        }
67612724Snikos.nikoleris@arm.com
67712724Snikos.nikoleris@arm.com                        0x2: decode FUNCTION_LO {
67812724Snikos.nikoleris@arm.com                            0x1: decode MOVCF {
67912724Snikos.nikoleris@arm.com                                format Float64Op {
68012724Snikos.nikoleris@arm.com                                    0x0: movf_ps({{
68112724Snikos.nikoleris@arm.com                                        Fd1 = (getCondCode(FCSR, CC) == 0) ?
68212724Snikos.nikoleris@arm.com                                            Fs1 : Fd1;
68312724Snikos.nikoleris@arm.com                                        Fd2 = (getCondCode(FCSR, CC+1) == 0) ?
68412724Snikos.nikoleris@arm.com                                            Fs2 : Fd2;
68512724Snikos.nikoleris@arm.com                                    }});
68612724Snikos.nikoleris@arm.com                                    0x1: movt_ps({{
68712724Snikos.nikoleris@arm.com                                        Fd2 = (getCondCode(FCSR, CC) == 1) ?
68812724Snikos.nikoleris@arm.com                                            Fs1 : Fd1;
68912724Snikos.nikoleris@arm.com                                        Fd2 = (getCondCode(FCSR, CC+1) == 1) ?
69012724Snikos.nikoleris@arm.com                                            Fs2 : Fd2;
69112724Snikos.nikoleris@arm.com                                    }});
69212724Snikos.nikoleris@arm.com                                }
69312724Snikos.nikoleris@arm.com                            }
69412724Snikos.nikoleris@arm.com
69512724Snikos.nikoleris@arm.com                            format Float64Op {
69612724Snikos.nikoleris@arm.com                                0x2: movz_ps({{
69712724Snikos.nikoleris@arm.com                                    Fd1 = (getCondCode(FCSR, CC) == 0) ?
69812724Snikos.nikoleris@arm.com                                        Fs1 : Fd1;
69912724Snikos.nikoleris@arm.com                                    Fd2 = (getCondCode(FCSR, CC) == 0) ?
70012724Snikos.nikoleris@arm.com                                        Fs2 : Fd2;
70112724Snikos.nikoleris@arm.com                                }});
70212724Snikos.nikoleris@arm.com                                0x3: movn_ps({{
70312724Snikos.nikoleris@arm.com                                    Fd1 = (getCondCode(FCSR, CC) == 1) ?
70412724Snikos.nikoleris@arm.com                                        Fs1 : Fd1;
70512724Snikos.nikoleris@arm.com                                    Fd2 = (getCondCode(FCSR, CC) == 1) ?
70612724Snikos.nikoleris@arm.com                                        Fs2 : Fd2;
70712724Snikos.nikoleris@arm.com                                }});
70812724Snikos.nikoleris@arm.com                            }
70912724Snikos.nikoleris@arm.com
71012724Snikos.nikoleris@arm.com                        }
71112724Snikos.nikoleris@arm.com
71212724Snikos.nikoleris@arm.com                        0x4: decode FUNCTION_LO {
71312724Snikos.nikoleris@arm.com                            0x0: FloatOp::cvt_s_pu({{ Fd.sf = Fs2.sf; }});
71412724Snikos.nikoleris@arm.com                        }
71512724Snikos.nikoleris@arm.com
71612724Snikos.nikoleris@arm.com                        0x5: decode FUNCTION_LO {
71712724Snikos.nikoleris@arm.com                            0x0: FloatOp::cvt_s_pl({{ Fd.sf = Fs1.sf; }});
71812724Snikos.nikoleris@arm.com
71912724Snikos.nikoleris@arm.com                            format Float64Op {
72012724Snikos.nikoleris@arm.com                                0x4: pll({{ Fd.ud = (uint64_t) Fs1.uw << 32 |
72112724Snikos.nikoleris@arm.com                                                    Ft1.uw;
72212724Snikos.nikoleris@arm.com                                         }});
72312724Snikos.nikoleris@arm.com                                0x5: plu({{ Fd.ud = (uint64_t) Fs1.uw << 32 |
72412724Snikos.nikoleris@arm.com                                                    Ft2.uw;
72512724Snikos.nikoleris@arm.com                                         }});
72612724Snikos.nikoleris@arm.com                                0x6: pul({{ Fd.ud = (uint64_t) Fs2.uw << 32 |
72712724Snikos.nikoleris@arm.com                                                    Ft1.uw;
72812724Snikos.nikoleris@arm.com                                         }});
72912724Snikos.nikoleris@arm.com                                0x7: puu({{ Fd.ud = (uint64_t) Fs2.uw << 32 |
73012724Snikos.nikoleris@arm.com                                                    Ft2.uw;
73112724Snikos.nikoleris@arm.com                                         }});
73212724Snikos.nikoleris@arm.com                            }
73312724Snikos.nikoleris@arm.com                        }
73412724Snikos.nikoleris@arm.com
73512724Snikos.nikoleris@arm.com                        0x6: decode FUNCTION_LO {
73612724Snikos.nikoleris@arm.com                            format FloatPSCompareOp {
73712724Snikos.nikoleris@arm.com                                0x0: c_f_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
73812724Snikos.nikoleris@arm.com                                            UnorderedFalse);
73912724Snikos.nikoleris@arm.com                                0x1: c_un_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
74012724Snikos.nikoleris@arm.com                                             UnorderedTrue);
74112724Snikos.nikoleris@arm.com                                0x2: c_eq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
74212724Snikos.nikoleris@arm.com                                             {{ cond2 = (Fs2.sf == Ft2.sf); }},
74312724Snikos.nikoleris@arm.com                                             UnorderedFalse);
74412724Snikos.nikoleris@arm.com                                0x3: c_ueq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
74512724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
74612724Snikos.nikoleris@arm.com                                              UnorderedTrue);
74712724Snikos.nikoleris@arm.com                                0x4: c_olt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
74812724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
74912724Snikos.nikoleris@arm.com                                              UnorderedFalse);
75012724Snikos.nikoleris@arm.com                                0x5: c_ult_ps({{ cond1 = (Fs.sf < Ft.sf); }},
75112724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
75212724Snikos.nikoleris@arm.com                                              UnorderedTrue);
75312724Snikos.nikoleris@arm.com                                0x6: c_ole_ps({{ cond1 = (Fs.sf <= Ft.sf); }},
75412724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
75512724Snikos.nikoleris@arm.com                                              UnorderedFalse);
75612724Snikos.nikoleris@arm.com                                0x7: c_ule_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
75712724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
75812724Snikos.nikoleris@arm.com                                              UnorderedTrue);
75912724Snikos.nikoleris@arm.com                            }
76012724Snikos.nikoleris@arm.com                        }
76112724Snikos.nikoleris@arm.com
76212724Snikos.nikoleris@arm.com                        0x7: decode FUNCTION_LO {
76312724Snikos.nikoleris@arm.com                            format FloatPSCompareOp {
76412724Snikos.nikoleris@arm.com                                0x0: c_sf_ps({{ cond1 = 0; }}, {{ cond2 = 0; }},
76512724Snikos.nikoleris@arm.com                                             UnorderedFalse, QnanException);
76612724Snikos.nikoleris@arm.com                                0x1: c_ngle_ps({{ cond1 = 0; }},
76712724Snikos.nikoleris@arm.com                                               {{ cond2 = 0; }},
76812724Snikos.nikoleris@arm.com                                               UnorderedTrue, QnanException);
76912724Snikos.nikoleris@arm.com                                0x2: c_seq_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
77012724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
77112724Snikos.nikoleris@arm.com                                              UnorderedFalse, QnanException);
77212724Snikos.nikoleris@arm.com                                0x3: c_ngl_ps({{ cond1 = (Fs1.sf == Ft1.sf); }},
77312724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf == Ft2.sf); }},
77412724Snikos.nikoleris@arm.com                                              UnorderedTrue, QnanException);
77512724Snikos.nikoleris@arm.com                                0x4: c_lt_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
77612724Snikos.nikoleris@arm.com                                             {{ cond2 = (Fs2.sf < Ft2.sf); }},
77712724Snikos.nikoleris@arm.com                                             UnorderedFalse, QnanException);
77812724Snikos.nikoleris@arm.com                                0x5: c_nge_ps({{ cond1 = (Fs1.sf < Ft1.sf); }},
77912724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf < Ft2.sf); }},
78012724Snikos.nikoleris@arm.com                                              UnorderedTrue, QnanException);
78112724Snikos.nikoleris@arm.com                                0x6: c_le_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
78212724Snikos.nikoleris@arm.com                                             {{ cond2 = (Fs2.sf <= Ft2.sf); }},
78312724Snikos.nikoleris@arm.com                                             UnorderedFalse, QnanException);
78412724Snikos.nikoleris@arm.com                                0x7: c_ngt_ps({{ cond1 = (Fs1.sf <= Ft1.sf); }},
78512724Snikos.nikoleris@arm.com                                              {{ cond2 = (Fs2.sf <= Ft2.sf); }},
78612724Snikos.nikoleris@arm.com                                              UnorderedTrue, QnanException);
78712724Snikos.nikoleris@arm.com                            }
78812724Snikos.nikoleris@arm.com                        }
78912724Snikos.nikoleris@arm.com                    }
79012724Snikos.nikoleris@arm.com                }
79112724Snikos.nikoleris@arm.com            }
79212724Snikos.nikoleris@arm.com        }
79312724Snikos.nikoleris@arm.com
79412724Snikos.nikoleris@arm.com        //Table A-19 MIPS32 COP2 Encoding of rs Field
79512724Snikos.nikoleris@arm.com        0x2: decode RS_MSB {
79612724Snikos.nikoleris@arm.com            format FailUnimpl {
79712724Snikos.nikoleris@arm.com                0x0: decode RS_HI {
79812724Snikos.nikoleris@arm.com                    0x0: decode RS_LO {
79912724Snikos.nikoleris@arm.com                        0x0: mfc2();
80012724Snikos.nikoleris@arm.com                        0x2: cfc2();
80112724Snikos.nikoleris@arm.com                        0x3: mfhc2();
80212724Snikos.nikoleris@arm.com                        0x4: mtc2();
80312724Snikos.nikoleris@arm.com                        0x6: ctc2();
80412724Snikos.nikoleris@arm.com                        0x7: mftc2();
80512724Snikos.nikoleris@arm.com                    }
80612724Snikos.nikoleris@arm.com
80712724Snikos.nikoleris@arm.com                    0x1: decode ND {
80812724Snikos.nikoleris@arm.com                        0x0: decode TF {
80912724Snikos.nikoleris@arm.com                            0x0: bc2f();
81012724Snikos.nikoleris@arm.com                            0x1: bc2t();
81112724Snikos.nikoleris@arm.com                        }
81212724Snikos.nikoleris@arm.com
81312724Snikos.nikoleris@arm.com                        0x1: decode TF {
81412724Snikos.nikoleris@arm.com                            0x0: bc2fl();
81512724Snikos.nikoleris@arm.com                            0x1: bc2tl();
81612724Snikos.nikoleris@arm.com                        }
81712724Snikos.nikoleris@arm.com                    }
81812724Snikos.nikoleris@arm.com                }
81912724Snikos.nikoleris@arm.com            }
82012724Snikos.nikoleris@arm.com        }
82112724Snikos.nikoleris@arm.com
82212724Snikos.nikoleris@arm.com        //Table A-20 MIPS64 COP1X Encoding of Function Field 1
82312724Snikos.nikoleris@arm.com        //Note: "COP1X instructions are legal only if 64-bit floating point
82412724Snikos.nikoleris@arm.com        //operations are enabled."
82512724Snikos.nikoleris@arm.com        0x3: decode FUNCTION_HI {
82612724Snikos.nikoleris@arm.com            0x0: decode FUNCTION_LO {
82712724Snikos.nikoleris@arm.com                format LoadIndexedMemory {
82812724Snikos.nikoleris@arm.com                    0x0: lwxc1({{ Ft.uw = Mem.uw;}});
82912724Snikos.nikoleris@arm.com                    0x1: ldxc1({{ Ft.ud = Mem.ud;}});
83012724Snikos.nikoleris@arm.com                    0x5: luxc1({{ Ft.uw = Mem.ud;}});
83112724Snikos.nikoleris@arm.com                }
83212724Snikos.nikoleris@arm.com            }
83312724Snikos.nikoleris@arm.com
83412724Snikos.nikoleris@arm.com            0x1: decode FUNCTION_LO {
83512724Snikos.nikoleris@arm.com                format StoreIndexedMemory {
83612724Snikos.nikoleris@arm.com                    0x0: swxc1({{ Mem.uw = Ft.uw;}});
83712724Snikos.nikoleris@arm.com                    0x1: sdxc1({{ Mem.ud = Ft.ud;}});
83812724Snikos.nikoleris@arm.com                    0x5: suxc1({{ Mem.ud = Ft.ud;}});
83912724Snikos.nikoleris@arm.com                }
84012724Snikos.nikoleris@arm.com
84112724Snikos.nikoleris@arm.com                0x7: Prefetch::prefx({{ EA = Rs + Rt; }});
84212724Snikos.nikoleris@arm.com            }
84312724Snikos.nikoleris@arm.com
84412724Snikos.nikoleris@arm.com            0x3: decode FUNCTION_LO {
84512766Sqtt2@cornell.edu                0x6: Float64Op::alnv_ps({{ if (Rs<2:0> == 0) {
84612766Sqtt2@cornell.edu                                               Fd.ud = Fs.ud;
84712766Sqtt2@cornell.edu                                           } else if (Rs<2:0> == 4) {
84812766Sqtt2@cornell.edu                                             #if BYTE_ORDER == BIG_ENDIAN
84912766Sqtt2@cornell.edu                                               Fd.ud = Fs.ud<31:0> << 32 |
85012766Sqtt2@cornell.edu                                                       Ft.ud<63:32>;
85112766Sqtt2@cornell.edu                                             #elif BYTE_ORDER == LITTLE_ENDIAN
85212766Sqtt2@cornell.edu                                               Fd.ud = Ft.ud<31:0> << 32 |
85312766Sqtt2@cornell.edu                                                       Fs.ud<63:32>;
85412766Sqtt2@cornell.edu                                             #endif
85512766Sqtt2@cornell.edu                                           } else {
85612766Sqtt2@cornell.edu                                               Fd.ud = Fd.ud;
85712766Sqtt2@cornell.edu                                           }
85812766Sqtt2@cornell.edu                                        }});
85912766Sqtt2@cornell.edu            }
86012766Sqtt2@cornell.edu
86112724Snikos.nikoleris@arm.com            format FloatAccOp {
86212724Snikos.nikoleris@arm.com                0x4: decode FUNCTION_LO {
86312724Snikos.nikoleris@arm.com                    0x0: madd_s({{ Fd.sf = (Fs.sf * Ft.sf) + Fr.sf; }});
86412724Snikos.nikoleris@arm.com                    0x1: madd_d({{ Fd.df = (Fs.df * Ft.df) + Fr.df; }});
86512724Snikos.nikoleris@arm.com                    0x6: madd_ps({{
86612724Snikos.nikoleris@arm.com                        Fd1.sf = (Fs1.df * Ft1.df) + Fr1.df;
86712724Snikos.nikoleris@arm.com                        Fd2.sf = (Fs2.df * Ft2.df) + Fr2.df;
86812724Snikos.nikoleris@arm.com                    }});
86912724Snikos.nikoleris@arm.com                }
87012724Snikos.nikoleris@arm.com
87112724Snikos.nikoleris@arm.com                0x5: decode FUNCTION_LO {
87212724Snikos.nikoleris@arm.com                    0x0: msub_s({{ Fd.sf = (Fs.sf * Ft.sf) - Fr.sf; }});
87312724Snikos.nikoleris@arm.com                    0x1: msub_d({{ Fd.df = (Fs.df * Ft.df) - Fr.df; }});
87412724Snikos.nikoleris@arm.com                    0x6: msub_ps({{
87512724Snikos.nikoleris@arm.com                        Fd1.sf = (Fs1.df * Ft1.df) - Fr1.df;
87612724Snikos.nikoleris@arm.com                        Fd2.sf = (Fs2.df * Ft2.df) - Fr2.df;
87712724Snikos.nikoleris@arm.com                    }});
87812724Snikos.nikoleris@arm.com                }
87912724Snikos.nikoleris@arm.com
88012724Snikos.nikoleris@arm.com                0x6: decode FUNCTION_LO {
88112724Snikos.nikoleris@arm.com                    0x0: nmadd_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }});
88212724Snikos.nikoleris@arm.com                    0x1: nmadd_d({{ Fd.df = (-1 * Fs.df * Ft.df) + Fr.df; }});
88312724Snikos.nikoleris@arm.com                    0x6: nmadd_ps({{
88412724Snikos.nikoleris@arm.com                        Fd1.sf = -((Fs1.df * Ft1.df) + Fr1.df);
88512724Snikos.nikoleris@arm.com                        Fd2.sf = -((Fs2.df * Ft2.df) + Fr2.df);
88612724Snikos.nikoleris@arm.com                    }});
88712724Snikos.nikoleris@arm.com                }
88812724Snikos.nikoleris@arm.com
88912724Snikos.nikoleris@arm.com                0x7: decode FUNCTION_LO {
89012724Snikos.nikoleris@arm.com                    0x0: nmsub_s({{ Fd.sf = (-1 * Fs.sf * Ft.sf) - Fr.sf; }});
89112724Snikos.nikoleris@arm.com                    0x1: nmsub_d({{ Fd.df = (-1 * Fs.df * Ft.df) - Fr.df; }});
89212724Snikos.nikoleris@arm.com                    0x6: nmsub_ps({{
89312724Snikos.nikoleris@arm.com                        Fd1.sf = -((Fs1.df * Ft1.df) - Fr1.df);
89412724Snikos.nikoleris@arm.com                        Fd2.sf = -((Fs2.df * Ft2.df) - Fr2.df);
89512724Snikos.nikoleris@arm.com                    }});
89612794Snikos.nikoleris@arm.com                }
89712794Snikos.nikoleris@arm.com
89812724Snikos.nikoleris@arm.com            }
89912724Snikos.nikoleris@arm.com        }
90012724Snikos.nikoleris@arm.com
90112724Snikos.nikoleris@arm.com        format Branch {
90212724Snikos.nikoleris@arm.com            0x4: beql({{ cond = (Rs.sw == Rt.sw); }}, Likely);
90312724Snikos.nikoleris@arm.com            0x5: bnel({{ cond = (Rs.sw != Rt.sw); }}, Likely);
90412724Snikos.nikoleris@arm.com            0x6: blezl({{ cond = (Rs.sw <= 0); }}, Likely);
90512724Snikos.nikoleris@arm.com            0x7: bgtzl({{ cond = (Rs.sw > 0); }}, Likely);
90612724Snikos.nikoleris@arm.com        }
90712724Snikos.nikoleris@arm.com    }
90812724Snikos.nikoleris@arm.com
90912724Snikos.nikoleris@arm.com    0x3: decode OPCODE_LO {
91012724Snikos.nikoleris@arm.com        //Table A-5 MIPS32 SPECIAL2 Encoding of Function Field
91112724Snikos.nikoleris@arm.com        0x4: decode FUNCTION_HI {
91212724Snikos.nikoleris@arm.com            0x0: decode FUNCTION_LO {
91312724Snikos.nikoleris@arm.com                0x2: IntOp::mul({{ int64_t temp1 = Rs.sd * Rt.sd;
91412724Snikos.nikoleris@arm.com                                   Rd.sw = temp1<31:0>
91512724Snikos.nikoleris@arm.com                                }});
91612724Snikos.nikoleris@arm.com
91712724Snikos.nikoleris@arm.com                format HiLoOp {
91812724Snikos.nikoleris@arm.com                    0x0: madd({{ val = ((int64_t) HI << 32 | LO) +
91912724Snikos.nikoleris@arm.com                                       (Rs.sd * Rt.sd);
92012724Snikos.nikoleris@arm.com                              }});
92112724Snikos.nikoleris@arm.com                    0x1: maddu({{ val = ((uint64_t) HI << 32 | LO) +
92212724Snikos.nikoleris@arm.com                                        (Rs.ud * Rt.ud);
92312724Snikos.nikoleris@arm.com                               }});
92412724Snikos.nikoleris@arm.com                    0x4: msub({{ val = ((int64_t) HI << 32 | LO) -
92512724Snikos.nikoleris@arm.com                                       (Rs.sd * Rt.sd);
92612724Snikos.nikoleris@arm.com                              }});
92712724Snikos.nikoleris@arm.com                    0x5: msubu({{ val = ((uint64_t) HI << 32 | LO) -
92812724Snikos.nikoleris@arm.com                                        (Rs.ud * Rt.ud);
92912724Snikos.nikoleris@arm.com                               }});
93012724Snikos.nikoleris@arm.com                }
93112724Snikos.nikoleris@arm.com            }
93212724Snikos.nikoleris@arm.com
93312724Snikos.nikoleris@arm.com            0x4: decode FUNCTION_LO {
93412724Snikos.nikoleris@arm.com                format BasicOp {
93512724Snikos.nikoleris@arm.com                    0x0: clz({{ int cnt = 32;
93612724Snikos.nikoleris@arm.com                                for (int idx = 31; idx >= 0; idx--) {
93712724Snikos.nikoleris@arm.com                                    if( Rs<idx:idx> == 1) {
93812724Snikos.nikoleris@arm.com                                        cnt = 31 - idx;
93912724Snikos.nikoleris@arm.com                                        break;
94012724Snikos.nikoleris@arm.com                                    }
94112724Snikos.nikoleris@arm.com                                }
94212724Snikos.nikoleris@arm.com                                Rd.uw = cnt;
94312724Snikos.nikoleris@arm.com                             }});
94412724Snikos.nikoleris@arm.com                    0x1: clo({{ int cnt = 32;
94512724Snikos.nikoleris@arm.com                                for (int idx = 31; idx >= 0; idx--) {
94612724Snikos.nikoleris@arm.com                                    if( Rs<idx:idx> == 0) {
94712724Snikos.nikoleris@arm.com                                        cnt = 31 - idx;
94812724Snikos.nikoleris@arm.com                                        break;
94912724Snikos.nikoleris@arm.com                                    }
95012724Snikos.nikoleris@arm.com                                }
95112724Snikos.nikoleris@arm.com                                Rd.uw = cnt;
95212724Snikos.nikoleris@arm.com                             }});
95312724Snikos.nikoleris@arm.com                }
95412724Snikos.nikoleris@arm.com            }
95512724Snikos.nikoleris@arm.com
95612724Snikos.nikoleris@arm.com            0x7: decode FUNCTION_LO {
95712724Snikos.nikoleris@arm.com                0x7: FailUnimpl::sdbbp();
95812724Snikos.nikoleris@arm.com            }
95912724Snikos.nikoleris@arm.com        }
96012724Snikos.nikoleris@arm.com
96112724Snikos.nikoleris@arm.com        //Table A-6 MIPS32 SPECIAL3 Encoding of Function Field for Release 2
96212724Snikos.nikoleris@arm.com        //of the Architecture
96312724Snikos.nikoleris@arm.com        0x7: decode FUNCTION_HI {
96412724Snikos.nikoleris@arm.com            0x0: decode FUNCTION_LO {
96512724Snikos.nikoleris@arm.com                format BasicOp {
96612724Snikos.nikoleris@arm.com                    0x1: ext({{ Rt.uw = bits(Rs.uw, MSB+LSB, LSB); }});
96712724Snikos.nikoleris@arm.com                    0x4: ins({{ Rt.uw = bits(Rt.uw, 31, MSB+1) << (MSB+1) |
96812724Snikos.nikoleris@arm.com                                        bits(Rs.uw, MSB-LSB, 0) << LSB |
96912724Snikos.nikoleris@arm.com                                        bits(Rt.uw, LSB-1, 0);
97012724Snikos.nikoleris@arm.com                             }});
97112724Snikos.nikoleris@arm.com                }
97212724Snikos.nikoleris@arm.com            }
97312724Snikos.nikoleris@arm.com
97412724Snikos.nikoleris@arm.com            0x1: decode FUNCTION_LO {
97512724Snikos.nikoleris@arm.com                format MipsMT {
97612724Snikos.nikoleris@arm.com                    0x0: fork();
97712724Snikos.nikoleris@arm.com                    0x1: yield();
97812724Snikos.nikoleris@arm.com                }
97912724Snikos.nikoleris@arm.com            }
98012724Snikos.nikoleris@arm.com
98112724Snikos.nikoleris@arm.com            //Table A-10 MIPS32 BSHFL Encoding of sa Field
98212724Snikos.nikoleris@arm.com            0x4: decode SA {
98312724Snikos.nikoleris@arm.com                format BasicOp {
98412724Snikos.nikoleris@arm.com                    0x02: wsbh({{ Rd.uw = Rt.uw<23:16> << 24 |
98512724Snikos.nikoleris@arm.com                                          Rt.uw<31:24> << 16 |
98612724Snikos.nikoleris@arm.com                                          Rt.uw<7:0>   << 8  |
98712724Snikos.nikoleris@arm.com                                          Rt.uw<15:8>;
98812724Snikos.nikoleris@arm.com                    }});
98912724Snikos.nikoleris@arm.com                    0x10: seb({{ Rd.sw = Rt.sw<7:0>}});
99012724Snikos.nikoleris@arm.com                    0x18: seh({{ Rd.sw = Rt.sw<15:0>}});
99112724Snikos.nikoleris@arm.com                }
99212724Snikos.nikoleris@arm.com            }
99312724Snikos.nikoleris@arm.com
99412724Snikos.nikoleris@arm.com            0x6: decode FUNCTION_LO {
99512724Snikos.nikoleris@arm.com                0x7: FailUnimpl::rdhwr();
99612754Sodanrc@yahoo.com.br            }
99712724Snikos.nikoleris@arm.com        }
99812724Snikos.nikoleris@arm.com    }
99912724Snikos.nikoleris@arm.com
100012724Snikos.nikoleris@arm.com    0x4: decode OPCODE_LO {
100112724Snikos.nikoleris@arm.com        format LoadMemory {
100212724Snikos.nikoleris@arm.com            0x0: lb({{ Rt.sw = Mem.sb; }});
100312724Snikos.nikoleris@arm.com            0x1: lh({{ Rt.sw = Mem.sh; }});
100412724Snikos.nikoleris@arm.com            0x3: lw({{ Rt.sw = Mem.sw; }});
100512724Snikos.nikoleris@arm.com            0x4: lbu({{ Rt.uw = Mem.ub; }});
100612724Snikos.nikoleris@arm.com            0x5: lhu({{ Rt.uw = Mem.uh; }});
100712724Snikos.nikoleris@arm.com        }
100812724Snikos.nikoleris@arm.com
100912724Snikos.nikoleris@arm.com        format LoadUnalignedMemory {
101012724Snikos.nikoleris@arm.com            0x2: lwl({{ uint32_t mem_shift = 24 - (8 * byte_offset);
101112724Snikos.nikoleris@arm.com                        Rt.uw = mem_word << mem_shift |
101212724Snikos.nikoleris@arm.com                                Rt.uw & mask(mem_shift);
101312724Snikos.nikoleris@arm.com                     }});
101412724Snikos.nikoleris@arm.com            0x6: lwr({{ uint32_t mem_shift = 8 * byte_offset;
101512724Snikos.nikoleris@arm.com                        Rt.uw = Rt.uw & (mask(mem_shift) << (32 - mem_shift)) |
101612724Snikos.nikoleris@arm.com                                mem_word >> mem_shift;
101712724Snikos.nikoleris@arm.com                     }});
101812724Snikos.nikoleris@arm.com        }
101912724Snikos.nikoleris@arm.com    }
102012724Snikos.nikoleris@arm.com
102112724Snikos.nikoleris@arm.com    0x5: decode OPCODE_LO {
102212724Snikos.nikoleris@arm.com        format StoreMemory {
102312724Snikos.nikoleris@arm.com            0x0: sb({{ Mem.ub = Rt<7:0>; }});
102412724Snikos.nikoleris@arm.com            0x1: sh({{ Mem.uh = Rt<15:0>; }});
102512724Snikos.nikoleris@arm.com            0x3: sw({{ Mem.uw = Rt<31:0>; }});
102612724Snikos.nikoleris@arm.com        }
102712724Snikos.nikoleris@arm.com
102812724Snikos.nikoleris@arm.com        format StoreUnalignedMemory {
102912724Snikos.nikoleris@arm.com            0x2: swl({{ uint32_t reg_shift = 24 - (8 * byte_offset);
103012724Snikos.nikoleris@arm.com                        uint32_t mem_shift = 32 - reg_shift;
103112724Snikos.nikoleris@arm.com                        mem_word = mem_word & (mask(reg_shift) << mem_shift) |
103212724Snikos.nikoleris@arm.com                                   Rt.uw >> reg_shift;
103312724Snikos.nikoleris@arm.com                     }});
103412724Snikos.nikoleris@arm.com            0x6: swr({{ uint32_t reg_shift = 8 * byte_offset;
103512724Snikos.nikoleris@arm.com                        mem_word = Rt.uw << reg_shift |
103612724Snikos.nikoleris@arm.com                                   mem_word & (mask(reg_shift));
103712724Snikos.nikoleris@arm.com                     }});
103812724Snikos.nikoleris@arm.com        }
103912724Snikos.nikoleris@arm.com
104012724Snikos.nikoleris@arm.com        0x7: FailUnimpl::cache();
104112724Snikos.nikoleris@arm.com    }
104212724Snikos.nikoleris@arm.com
104312724Snikos.nikoleris@arm.com    0x6: decode OPCODE_LO {
104412724Snikos.nikoleris@arm.com        format LoadMemory {
104512724Snikos.nikoleris@arm.com            0x0: ll({{ Rt.uw = Mem.uw; }}, mem_flags=LOCKED);
104612724Snikos.nikoleris@arm.com            0x1: lwc1({{ Ft.uw = Mem.uw; }});
104712724Snikos.nikoleris@arm.com            0x5: ldc1({{ Ft.ud = Mem.ud; }});
104812724Snikos.nikoleris@arm.com        }
104912724Snikos.nikoleris@arm.com
105012724Snikos.nikoleris@arm.com        0x3: Prefetch::pref();
105112724Snikos.nikoleris@arm.com    }
105212724Snikos.nikoleris@arm.com
105312754Sodanrc@yahoo.com.br
105412724Snikos.nikoleris@arm.com    0x7: decode OPCODE_LO {
105512724Snikos.nikoleris@arm.com        0x0: StoreCond::sc({{ Mem.uw = Rt.uw;}},
105612724Snikos.nikoleris@arm.com                           {{ uint64_t tmp = write_result;
105712724Snikos.nikoleris@arm.com                              Rt.uw = (tmp == 0 || tmp == 1) ? tmp : Rt.uw;
105812724Snikos.nikoleris@arm.com                           }}, mem_flags=LOCKED);
105912724Snikos.nikoleris@arm.com
106012724Snikos.nikoleris@arm.com        format StoreMemory {
106112724Snikos.nikoleris@arm.com            0x1: swc1({{ Mem.uw = Ft.uw; }});
106212724Snikos.nikoleris@arm.com            0x5: sdc1({{ Mem.ud = Ft.ud; }});
106312724Snikos.nikoleris@arm.com        }
106412724Snikos.nikoleris@arm.com    }
106512724Snikos.nikoleris@arm.com}
106612724Snikos.nikoleris@arm.com
106712724Snikos.nikoleris@arm.com
106812724Snikos.nikoleris@arm.com