basic.isa revision 2632:1bb2f91485ea
1// -*- mode:c++ -*-
2
3// Declarations for execute() methods.
4def template BasicExecDeclare {{
5        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
6}};
7
8// Basic instruction class declaration template.
9def template BasicDeclare {{
10        /**
11         * Static instruction class for "%(mnemonic)s".
12         */
13        class %(class_name)s : public %(base_class)s
14        {
15        public:
16                /// Constructor.
17                %(class_name)s(MachInst machInst);
18                %(BasicExecDeclare)s
19    };
20}};
21
22// Basic instruction class constructor template.
23def template BasicConstructor {{
24        inline %(class_name)s::%(class_name)s(MachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
25        {
26                %(constructor)s;
27        }
28}};
29
30// Basic instruction class execute method template.
31def template BasicExecute {{
32        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
33        {
34                Fault fault = NoFault;
35
36                %(fp_enable_check)s;
37                %(op_decl)s;
38                %(op_rd)s;
39                %(code)s;
40
41                if(fault == NoFault)
42                {
43                    %(op_wb)s;
44                }
45                return fault;
46        }
47}};
48
49// Basic decode template.
50def template BasicDecode {{
51        return new %(class_name)s(machInst);
52}};
53
54// Basic decode template, passing mnemonic in as string arg to constructor.
55def template BasicDecodeWithMnemonic {{
56        return new %(class_name)s("%(mnemonic)s", machInst);
57}};
58
59// The most basic instruction format... used only for a few misc. insts
60def format BasicOp(code, *flags) {{
61        iop = InstObjParams(name, Name, 'MipsStaticInst', CodeBlock(code), flags)
62        header_output = BasicDeclare.subst(iop)
63        decoder_output = BasicConstructor.subst(iop)
64        decode_block = BasicDecode.subst(iop)
65        exec_output = BasicExecute.subst(iop)
66}};
67