fp.isa revision 2038
1////////////////////////////////////////////////////////////////////
2//
3// Floating Point operate instructions
4//
5
6output header {{
7        /**
8         * Base class for integer operations.
9         */
10        class FPOp : public MipsStaticInst
11        {
12                protected:
13
14                /// Constructor
15                FPOp(const char *mnem, MachInst _machInst, OpClass __opClass) : MipsStaticInst(mnem, _machInst, __opClass)
16                {
17                }
18
19                std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
20        };
21}};
22
23output decoder {{
24        std::string FPOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
25        {
26                return "Disassembly of integer instruction\n";
27        }
28}};
29
30def template IntegerExecute {{
31        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
32        {
33                //These are set to constants when the execute method
34                //is generated
35                bool useCc = ;
36                bool checkPriv = ;
37
38                //Attempt to execute the instruction
39                try
40                {
41                        checkPriv;
42
43                        %(op_decl)s;
44                        %(op_rd)s;
45                        %(code)s;
46                }
47                //If we have an exception for some reason,
48                //deal with it
49                catch(MipsException except)
50                {
51                        //Deal with exception
52                        return No_Fault;
53                }
54
55                //Write the resulting state to the execution context
56                %(op_wb)s;
57                if(useCc)
58                {
59                        xc->regs.miscRegFile.ccrFields.iccFields.n = Rd & (1 << 63);
60                        xc->regs.miscRegFile.ccrFields.iccFields.z = (Rd == 0);
61                        xc->regs.miscRegFile.ccrFields.iccFields.v = ivValue;
62                        xc->regs.miscRegFile.ccrFields.iccFields.c = icValue;
63                        xc->regs.miscRegFile.ccrFields.xccFields.n = Rd & (1 << 31);
64                        xc->regs.miscRegFile.ccrFields.xccFields.z = ((Rd & 0xFFFFFFFF) == 0);
65                        xc->regs.miscRegFile.ccrFields.xccFields.v = xvValue;
66                        xc->regs.miscRegFile.ccrFields.xccFields.c = xcValue;
67                }
68                return No_Fault;
69        }
70}};
71
72// Primary format for integer operate instructions:
73def format FPOp(code, *opt_flags) {{
74        orig_code = code
75        cblk = CodeBlock(code)
76        checkPriv = (code.find('checkPriv') != -1)
77        code.replace('checkPriv', '')
78        if checkPriv:
79                code.replace('checkPriv;', 'if(!xc->regs.miscRegFile.pstateFields.priv) throw privileged_opcode;')
80        else:
81                code.replace('checkPriv;', '')
82        for (marker, value) in (('ivValue', '0'), ('icValue', '0'),
83                       ('xvValue', '0'), ('xcValue', '0')):
84                code.replace(marker, value)
85        iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
86        header_output = BasicDeclare.subst(iop)
87        decoder_output = BasicConstructor.subst(iop)
88        decode_block = BasicDecodeWithMnemonic.subst(iop)
89        exec_output = IntegerExecute.subst(iop)
90}};
91
92// Primary format for integer operate instructions:
93def format FPOpCc(code, icValue, ivValue, xcValue, xvValue, *opt_flags) {{
94        orig_code = code
95        cblk = CodeBlock(code)
96        checkPriv = (code.find('checkPriv') != -1)
97        code.replace('checkPriv', '')
98        if checkPriv:
99                code.replace('checkPriv;', 'if(!xc->regs.miscRegFile.pstateFields.priv) throw privileged_opcode;')
100        else:
101                code.replace('checkPriv;', '')
102        for (marker, value) in (('ivValue', ivValue), ('icValue', icValue),
103                       ('xvValue', xvValue), ('xcValue', xcValue)):
104                code.replace(marker, value)
105        iop = InstObjParams(name, Name, 'MipsStaticInst', cblk, opt_flags)
106        header_output = BasicDeclare.subst(iop)
107        decoder_output = BasicConstructor.subst(iop)
108        decode_block = BasicDecodeWithMnemonic.subst(iop)
109        exec_output = IntegerExecute.subst(iop)
110}};
111