2006-01-29 23:25:54 +01:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Trap instructions
|
|
|
|
//
|
|
|
|
|
|
|
|
output header {{
|
|
|
|
/**
|
2006-03-16 19:58:50 +01:00
|
|
|
* Base class for trap instructions,
|
|
|
|
* or instructions that always fault.
|
2006-01-29 23:25:54 +01:00
|
|
|
*/
|
|
|
|
class Trap : public SparcStaticInst
|
|
|
|
{
|
2006-03-07 10:33:10 +01:00
|
|
|
protected:
|
2006-01-29 23:25:54 +01:00
|
|
|
|
2006-03-07 10:33:10 +01:00
|
|
|
// Constructor
|
2006-03-16 19:58:50 +01:00
|
|
|
Trap(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
|
2006-04-18 15:27:22 +02:00
|
|
|
SparcStaticInst(mnem, _machInst, __opClass), trapNum(SW_TRAP)
|
2006-03-07 10:33:10 +01:00
|
|
|
{
|
|
|
|
}
|
2006-01-29 23:25:54 +01:00
|
|
|
|
2006-03-07 10:33:10 +01:00
|
|
|
std::string generateDisassembly(Addr pc,
|
|
|
|
const SymbolTable *symtab) const;
|
2006-04-18 15:27:22 +02:00
|
|
|
|
|
|
|
int trapNum;
|
2006-01-29 23:25:54 +01:00
|
|
|
};
|
|
|
|
}};
|
|
|
|
|
|
|
|
output decoder {{
|
2006-03-07 10:33:10 +01:00
|
|
|
std::string Trap::generateDisassembly(Addr pc,
|
|
|
|
const SymbolTable *symtab) const
|
2006-01-29 23:25:54 +01:00
|
|
|
{
|
2006-04-18 15:27:22 +02:00
|
|
|
std::stringstream response;
|
|
|
|
|
|
|
|
printMnemonic(response, mnemonic);
|
|
|
|
ccprintf(response, " ");
|
|
|
|
printReg(response, _srcRegIdx[0]);
|
|
|
|
ccprintf(response, ", 0x%x", trapNum);
|
|
|
|
ccprintf(response, ", or ");
|
|
|
|
printReg(response, _srcRegIdx[1]);
|
|
|
|
return response.str();
|
2006-01-29 23:25:54 +01:00
|
|
|
}
|
|
|
|
}};
|
|
|
|
|
|
|
|
def template TrapExecute {{
|
2006-03-07 10:33:10 +01:00
|
|
|
Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
|
|
|
|
Trace::InstRecord *traceData) const
|
2006-01-29 23:25:54 +01:00
|
|
|
{
|
2006-03-16 19:58:50 +01:00
|
|
|
Fault fault = NoFault;
|
2006-03-28 22:13:57 +02:00
|
|
|
%(op_decl)s;
|
|
|
|
%(op_rd)s;
|
2006-03-16 19:58:50 +01:00
|
|
|
%(code)s
|
|
|
|
return fault;
|
2006-01-29 23:25:54 +01:00
|
|
|
}
|
|
|
|
}};
|
|
|
|
|
|
|
|
def format Trap(code, *opt_flags) {{
|
|
|
|
orig_code = code
|
|
|
|
cblk = CodeBlock(code)
|
2006-04-01 03:31:53 +02:00
|
|
|
iop = InstObjParams(name, Name, 'Trap', cblk, opt_flags)
|
2006-01-29 23:25:54 +01:00
|
|
|
header_output = BasicDeclare.subst(iop)
|
|
|
|
decoder_output = BasicConstructor.subst(iop)
|
2006-03-16 19:58:50 +01:00
|
|
|
decode_block = BasicDecode.subst(iop)
|
2006-01-29 23:25:54 +01:00
|
|
|
exec_output = TrapExecute.subst(iop)
|
|
|
|
}};
|