basic.isa revision 2239
114185Sgabeblack@google.com// -*- mode:c++ -*-
214185Sgabeblack@google.com
314185Sgabeblack@google.com// Declarations for execute() methods.
414185Sgabeblack@google.comdef template BasicExecDeclare {{
514185Sgabeblack@google.com        Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const;
614185Sgabeblack@google.com}};
714185Sgabeblack@google.com
814185Sgabeblack@google.com// Basic instruction class declaration template.
914185Sgabeblack@google.comdef template BasicDeclare {{
1014185Sgabeblack@google.com        /**
1114185Sgabeblack@google.com         * Static instruction class for "%(mnemonic)s".
1214185Sgabeblack@google.com         */
1314185Sgabeblack@google.com        class %(class_name)s : public %(base_class)s
1414185Sgabeblack@google.com        {
1514185Sgabeblack@google.com        public:
1614185Sgabeblack@google.com                /// Constructor.
1714185Sgabeblack@google.com                %(class_name)s(MachInst machInst);
1814185Sgabeblack@google.com                %(BasicExecDeclare)s
1914185Sgabeblack@google.com    };
2014185Sgabeblack@google.com}};
2114185Sgabeblack@google.com
2214185Sgabeblack@google.com// Basic instruction class constructor template.
2314185Sgabeblack@google.comdef template BasicConstructor {{
2414185Sgabeblack@google.com        inline %(class_name)s::%(class_name)s(MachInst machInst)  : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
2514185Sgabeblack@google.com        {
2614185Sgabeblack@google.com                %(constructor)s;
2714185Sgabeblack@google.com        }
2814185Sgabeblack@google.com}};
2914185Sgabeblack@google.com
3014185Sgabeblack@google.com// Basic instruction class execute method template.
3114185Sgabeblack@google.comdef template BasicExecute {{
3214185Sgabeblack@google.com        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
3314185Sgabeblack@google.com        {
3414185Sgabeblack@google.com                Fault fault = NoFault;
3514185Sgabeblack@google.com
3614185Sgabeblack@google.com                %(fp_enable_check)s;
3714185Sgabeblack@google.com                %(op_decl)s;
3814185Sgabeblack@google.com                %(op_rd)s;
3914185Sgabeblack@google.com                %(code)s;
4014185Sgabeblack@google.com
4114185Sgabeblack@google.com                if(fault == NoFault)
4214185Sgabeblack@google.com                {
4314185Sgabeblack@google.com                    %(op_wb)s;
4414185Sgabeblack@google.com                }
4514185Sgabeblack@google.com                return fault;
4614185Sgabeblack@google.com        }
4714185Sgabeblack@google.com}};
4814185Sgabeblack@google.com
4914185Sgabeblack@google.com// Basic decode template.
5014185Sgabeblack@google.comdef template BasicDecode {{
5114185Sgabeblack@google.com        return new %(class_name)s(machInst);
5214185Sgabeblack@google.com}};
5314185Sgabeblack@google.com
5414185Sgabeblack@google.com// Basic decode template, passing mnemonic in as string arg to constructor.
5514185Sgabeblack@google.comdef template BasicDecodeWithMnemonic {{
5614185Sgabeblack@google.com        return new %(class_name)s("%(mnemonic)s", machInst);
5714185Sgabeblack@google.com}};
5814185Sgabeblack@google.com
5914185Sgabeblack@google.com// The most basic instruction format... used only for a few misc. insts
6014185Sgabeblack@google.comdef format BasicOp(code, *flags) {{
6114185Sgabeblack@google.com        iop = InstObjParams(name, Name, 'MipsStaticInst', CodeBlock(code), flags)
6214185Sgabeblack@google.com        header_output = BasicDeclare.subst(iop)
6314185Sgabeblack@google.com        decoder_output = BasicConstructor.subst(iop)
6414185Sgabeblack@google.com        decode_block = BasicDecode.subst(iop)
6514185Sgabeblack@google.com        exec_output = BasicExecute.subst(iop)
66}};
67