f6a45ca4834a40a57f275b6653c50978cfe47f8d
[gem5.git] / arch / sparc / isa / formats / trap.isa
1 ////////////////////////////////////////////////////////////////////
2 //
3 // Trap instructions
4 //
5
6 output header {{
7 /**
8 * Base class for trap instructions,
9 * or instructions that always fault.
10 */
11 class Trap : public SparcStaticInst
12 {
13 protected:
14
15 // Constructor
16 Trap(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
17 SparcStaticInst(mnem, _machInst, __opClass), trapNum(SW_TRAP)
18 {
19 }
20
21 std::string generateDisassembly(Addr pc,
22 const SymbolTable *symtab) const;
23
24 int trapNum;
25 };
26 }};
27
28 output decoder {{
29 std::string Trap::generateDisassembly(Addr pc,
30 const SymbolTable *symtab) const
31 {
32 std::stringstream response;
33
34 printMnemonic(response, mnemonic);
35 ccprintf(response, " ");
36 printReg(response, _srcRegIdx[0]);
37 ccprintf(response, ", 0x%x", trapNum);
38 ccprintf(response, ", or ");
39 printReg(response, _srcRegIdx[1]);
40 return response.str();
41 }
42 }};
43
44 def template TrapExecute {{
45 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
46 Trace::InstRecord *traceData) const
47 {
48 Fault fault = NoFault;
49 %(op_decl)s;
50 %(op_rd)s;
51 %(code)s
52 return fault;
53 }
54 }};
55
56 def format Trap(code, *opt_flags) {{
57 orig_code = code
58 cblk = CodeBlock(code)
59 iop = InstObjParams(name, Name, 'Trap', cblk, opt_flags)
60 header_output = BasicDeclare.subst(iop)
61 decoder_output = BasicConstructor.subst(iop)
62 decode_block = BasicDecode.subst(iop)
63 exec_output = TrapExecute.subst(iop)
64 }};