trap.isa revision 2488
12447SN/A////////////////////////////////////////////////////////////////////
22447SN/A//
34181Sgblack@eecs.umich.edu// Trap instructions
42447SN/A//
52447SN/A
62447SN/Aoutput header {{
72447SN/A        /**
82447SN/A         * Base class for trap instructions,
92447SN/A         * or instructions that always fault.
102447SN/A         */
112447SN/A        class Trap : public SparcStaticInst
122447SN/A        {
132447SN/A          protected:
142447SN/A
152447SN/A            // Constructor
162447SN/A            Trap(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
172447SN/A                SparcStaticInst(mnem, _machInst, __opClass)
182447SN/A            {
192447SN/A            }
202447SN/A
212447SN/A            std::string generateDisassembly(Addr pc,
222447SN/A                    const SymbolTable *symtab) const;
232447SN/A        };
242447SN/A}};
252447SN/A
262447SN/Aoutput decoder {{
272447SN/A        std::string Trap::generateDisassembly(Addr pc,
282632Sstever@eecs.umich.edu                const SymbolTable *symtab) const
292632Sstever@eecs.umich.edu        {
302632Sstever@eecs.umich.edu            return "Trap instruction\n";
314181Sgblack@eecs.umich.edu        }
322447SN/A}};
332447SN/A
342447SN/Adef template TrapExecute {{
352447SN/A        Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
362447SN/A                Trace::InstRecord *traceData) const
372597SN/A        {
384661Sksewell@umich.edu            Fault fault = NoFault;
392597SN/A            %(op_decl)s;
402980Sgblack@eecs.umich.edu            %(op_rd)s;
412972Sgblack@eecs.umich.edu            %(code)s
422980Sgblack@eecs.umich.edu            return fault;
432597SN/A        }
442597SN/A}};
454661Sksewell@umich.edu
464661Sksewell@umich.edudef format Trap(code, *opt_flags) {{
472980Sgblack@eecs.umich.edu        orig_code = code
482980Sgblack@eecs.umich.edu        cblk = CodeBlock(code)
492597SN/A        iop = InstObjParams(name, Name, 'SparcStaticInst', cblk, opt_flags)
502597SN/A        header_output = BasicDeclare.subst(iop)
514826Ssaidi@eecs.umich.edu        decoder_output = BasicConstructor.subst(iop)
524826Ssaidi@eecs.umich.edu        decode_block = BasicDecode.subst(iop)
534826Ssaidi@eecs.umich.edu        exec_output = TrapExecute.subst(iop)
544826Ssaidi@eecs.umich.edu}};
552686Sksewell@umich.edu