mem.isa revision 2022
1////////////////////////////////////////////////////////////////////
2//
3// Mem instructions
4//
5
6output header {{
7        /**
8         * Base class for integer operations.
9         */
10        class Mem : public SparcStaticInst
11        {
12                protected:
13
14                /// Constructor
15                Mem(const char *mnem, MachInst _machInst, OpClass __opClass) : SparcStaticInst(mnem, _machInst, __opClass)
16                {
17                }
18
19                std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
20        };
21}};
22
23output decoder {{
24        std::string Mem::generateDisassembly(Addr pc, const SymbolTable *symtab) const
25        {
26                return "Disassembly of integer instruction\n";
27        }
28}};
29
30def template MemExecute {{
31        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
32        {
33                //Attempt to execute the instruction
34                try
35                {
36
37                        %(op_decl)s;
38                        %(op_rd)s;
39                        ea_code
40                        %(code)s;
41                }
42                //If we have an exception for some reason,
43                //deal with it
44                catch(SparcException except)
45                {
46                        //Deal with exception
47                        return No_Fault;
48                }
49
50                //Write the resulting state to the execution context
51                %(op_wb)s;
52
53                return No_Fault;
54        }
55}};
56
57// Primary format for integer operate instructions:
58def format Mem(code, *opt_flags) {{
59        orig_code = code
60        cblk = CodeBlock(code)
61        iop = InstObjParams(name, Name, 'SparcStaticInst', cblk, opt_flags)
62        header_output = BasicDeclare.subst(iop)
63        decoder_output = BasicConstructor.subst(iop)
64        decode_block = BasicDecodeWithMnemonic.subst(iop)
65        exec_output = MemExecute.subst(iop)
66        exec_output.replace('ea_code', 'EA = I ? (R1 + SIMM13) : R1 + R2;');
67}};
68
69def format Cas(code, *opt_flags) {{
70        orig_code = code
71        cblk = CodeBlock(code)
72        iop = InstObjParams(name, Name, 'SparcStaticInst', cblk, opt_flags)
73        header_output = BasicDeclare.subst(iop)
74        decoder_output = BasicConstructor.subst(iop)
75        decode_block = BasicDecodeWithMnemonic.subst(iop)
76        exec_output = MemExecute.subst(iop)
77        exec_output.replace('ea_code', 'EA = R1;');
78}};
79