branch.isa revision 2469
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            // Constructor
14            Branch(const char *mnem, MachInst _machInst, OpClass __opClass) :
15                SparcStaticInst(mnem, _machInst, __opClass)
16            {
17            }
18
19            std::string generateDisassembly(Addr pc,
20                    const SymbolTable *symtab) const;
21        };
22}};
23
24output decoder {{
25        std::string Branch::generateDisassembly(Addr pc, const SymbolTable *symtab) const
26        {
27                return "Branch instruction\n";
28        }
29}};
30
31def template BranchExecute {{
32        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
33                Trace::InstRecord *traceData) const
34        {
35            //Attempt to execute the instruction
36            Fault fault = NoFault;
37
38            %(op_decl)s;
39            %(op_rd)s;
40            %(code)s;
41
42            if(fault == NoFault)
43            {
44                //Write the resulting state to the execution context
45                %(op_wb)s;
46            }
47
48            return fault;
49        }
50}};
51
52// Primary format for integer operate instructions:
53def format Branch(code, *opt_flags) {{
54        orig_code = code
55        cblk = CodeBlock(code)
56        iop = InstObjParams(name, Name, 'SparcStaticInst', cblk, opt_flags)
57        header_output = BasicDeclare.subst(iop)
58        decoder_output = BasicConstructor.subst(iop)
59        decode_block = BasicDecode.subst(iop)
60        exec_output = BranchExecute.subst(iop)
61}};
62