branch.isa revision 2022
1////////////////////////////////////////////////////////////////////
2//
3// Branch instructions
4//
5
6output header {{
7        /**
8         * Base class for integer operations.
9         */
10        class Branch : public SparcStaticInst
11        {
12                protected:
13
14                /// Constructor
15                Branch(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 Branch::generateDisassembly(Addr pc, const SymbolTable *symtab) const
25        {
26                return "Disassembly of integer instruction\n";
27        }
28}};
29
30def template BranchExecute {{
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                        checkPriv;
37
38                        %(op_decl)s;
39                        %(op_rd)s;
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 Branch(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 = BranchExecute.subst(iop)
66}};
67