fp.isa revision 2084
12968SN/A////////////////////////////////////////////////////////////////////
22968SN/A//
32968SN/A// Floating Point operate instructions
49988Snilay@cs.wisc.edu//
58835SAli.Saidi@ARM.com
69988Snilay@cs.wisc.eduoutput header {{
77935SN/A        /**
87935SN/A         * Base class for integer operations.
97935SN/A         */
102968SN/A        class FPOp : public MipsStaticInst
112968SN/A        {
122968SN/A                protected:
1310315Snilay@cs.wisc.edu
144463SN/A                /// Constructor
152968SN/A                FPOp(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass)
169885Sstever@gmail.com                {
179885Sstever@gmail.com                }
1810315Snilay@cs.wisc.edu
199988Snilay@cs.wisc.edu                std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
202968SN/A        };
2110315Snilay@cs.wisc.edu}};
2210315Snilay@cs.wisc.edu
237670SN/Aoutput decoder {{
2410315Snilay@cs.wisc.edu        std::string FPOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
252968SN/A        {
269481Snilay@cs.wisc.edu                return "Disassembly of integer instruction\n";
278721SN/A        }
288721SN/A}};
2910315Snilay@cs.wisc.edu
3010315Snilay@cs.wisc.edudef template FloatingPointExecute {{
313140SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
322968SN/A        {
332968SN/A                //These are set to constants when the execute method
347935SN/A                //is generated
357935SN/A                bool useCc = ;
367935SN/A                bool checkPriv = ;
377935SN/A
387935SN/A                //Attempt to execute the instruction
397935SN/A                try
407935SN/A                {
418983Snate@binkert.org                        checkPriv;
422968SN/A
432968SN/A                        %(op_decl)s;
442968SN/A                        %(op_rd)s;
459885Sstever@gmail.com                        %(code)s;
464463SN/A                }
479988Snilay@cs.wisc.edu                //If we have an exception for some reason,
488721SN/A                //deal with it
498721SN/A                catch(MipsException except)
508721SN/A                {
518983Snate@binkert.org                        //Deal with exception
528983Snate@binkert.org                        return No_Fault;
532968SN/A                }
549885Sstever@gmail.com
559885Sstever@gmail.com                //Write the resulting state to the execution context
569885Sstever@gmail.com                %(op_wb)s;
5710315Snilay@cs.wisc.edu                if(useCc)
589988Snilay@cs.wisc.edu                {
5910315Snilay@cs.wisc.edu                        xc->regs.miscRegFile.ccrFields.iccFields.n = Rd & (1 << 63);
609885Sstever@gmail.com                        xc->regs.miscRegFile.ccrFields.iccFields.z = (Rd == 0);
619885Sstever@gmail.com                        xc->regs.miscRegFile.ccrFields.iccFields.v = ivValue;
622968SN/A                        xc->regs.miscRegFile.ccrFields.iccFields.c = icValue;
632968SN/A                        xc->regs.miscRegFile.ccrFields.xccFields.n = Rd & (1 << 31);
649481Snilay@cs.wisc.edu                        xc->regs.miscRegFile.ccrFields.xccFields.z = ((Rd & 0xFFFFFFFF) == 0);
6510315Snilay@cs.wisc.edu                        xc->regs.miscRegFile.ccrFields.xccFields.v = xvValue;
665876SN/A                        xc->regs.miscRegFile.ccrFields.xccFields.c = xcValue;
679885Sstever@gmail.com                }
683171SN/A                return No_Fault;
693638SN/A        }
703638SN/A}};
713638SN/A
722968SN/A// Primary format for integer operate instructions:
739988Snilay@cs.wisc.edudef format FloatOp(code, *opt_flags) {{
748983Snate@binkert.org        orig_code = code
752968SN/A        cblk = CodeBlock(code)
762968SN/A        checkPriv = (code.find('checkPriv') != -1)
775723SN/A        code.replace('checkPriv', '')
789481Snilay@cs.wisc.edu        if checkPriv:
792968SN/A                code.replace('checkPriv;', 'if(!xc->regs.miscRegFile.pstateFields.priv) throw privileged_opcode;')
802968SN/A        else:
812968SN/A                code.replace('checkPriv;', '')
822968SN/A        for (marker, value) in (('ivValue', '0'), ('icValue', '0'),
832968SN/A                       ('xvValue', '0'), ('xcValue', '0')):
845575SN/A                code.replace(marker, value)
852968SN/A        iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
863140SN/A        header_output = BasicDeclare.subst(iop)
879885Sstever@gmail.com        decoder_output = BasicConstructor.subst(iop)
885509SN/A        decode_block = BasicDecodeWithMnemonic.subst(iop)
895509SN/A        exec_output = FloatingPointExecute.subst(iop)
9010315Snilay@cs.wisc.edu}};
919481Snilay@cs.wisc.edu
922968SN/A// Primary format for integer operate instructions:
934938SN/Adef format Float64Op(code, *opt_flags) {{
942968SN/A        orig_code = code
958835SAli.Saidi@ARM.com        cblk = CodeBlock(code)
964463SN/A        checkPriv = (code.find('checkPriv') != -1)
974463SN/A        code.replace('checkPriv', '')
984463SN/A        if checkPriv:
994463SN/A                code.replace('checkPriv;', 'if(!xc->regs.miscRegFile.pstateFields.priv) throw privileged_opcode;')
1004463SN/A        else:
1019885Sstever@gmail.com                code.replace('checkPriv;', '')
1028983Snate@binkert.org        for (marker, value) in (('ivValue', '0'), ('icValue', '0'),
1034463SN/A                       ('xvValue', '0'), ('xcValue', '0')):
1049885Sstever@gmail.com                code.replace(marker, value)
10510636Snilay@cs.wisc.edu        iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
1069988Snilay@cs.wisc.edu        header_output = BasicDeclare.subst(iop)
1076123SN/A        decoder_output = BasicConstructor.subst(iop)
1089481Snilay@cs.wisc.edu        decode_block = BasicDecodeWithMnemonic.subst(iop)
1098241SN/A        exec_output = FloatingPointExecute.subst(iop)
1104463SN/A}};
1114463SN/A
1125876SN/A// Primary format for integer operate instructions:
1138835SAli.Saidi@ARM.comdef format FPOpCc(code, icValue, ivValue, xcValue, xvValue, *opt_flags) {{
1149481Snilay@cs.wisc.edu        orig_code = code
11510036SAli.Saidi@ARM.com
1164463SN/A        cblk = CodeBlock(code)
1178835SAli.Saidi@ARM.com        checkPriv = (code.find('checkPriv') != -1)
1189885Sstever@gmail.com        code.replace('checkPriv', '')
1199481Snilay@cs.wisc.edu        if checkPriv:
1204463SN/A                code.replace('checkPriv;', 'if(!xc->regs.miscRegFile.pstateFields.priv) throw privileged_opcode;')
1214463SN/A        else:
1224463SN/A                code.replace('checkPriv;', '')
1238983Snate@binkert.org        for (marker, value) in (('ivValue', ivValue), ('icValue', icValue),
1244463SN/A                       ('xvValue', xvValue), ('xcValue', xcValue)):
1259885Sstever@gmail.com                code.replace(marker, value)
1269885Sstever@gmail.com        iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
1279885Sstever@gmail.com        header_output = BasicDeclare.subst(iop)
1289885Sstever@gmail.com        decoder_output = BasicConstructor.subst(iop)
1299885Sstever@gmail.com        decode_block = BasicDecodeWithMnemonic.subst(iop)
1309988Snilay@cs.wisc.edu        exec_output = IntegerExecute.subst(iop)
1319885Sstever@gmail.com}};
13210036SAli.Saidi@ARM.com