2006-01-29 23:25:54 +01:00
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Mem instructions
|
|
|
|
//
|
|
|
|
|
|
|
|
output header {{
|
|
|
|
/**
|
2006-04-01 03:31:53 +02:00
|
|
|
* Base class for memory operations.
|
2006-01-29 23:25:54 +01:00
|
|
|
*/
|
|
|
|
class Mem : 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
|
|
|
Mem(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
|
2006-03-07 10:33:10 +01:00
|
|
|
SparcStaticInst(mnem, _machInst, __opClass)
|
|
|
|
{
|
|
|
|
}
|
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-01-29 23:25:54 +01:00
|
|
|
};
|
2006-04-01 03:31:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for memory operations which use an immediate offset.
|
|
|
|
*/
|
|
|
|
class MemImm : public Mem
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
MemImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
|
|
|
|
Mem(mnem, _machInst, __opClass), imm(SIMM13)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string generateDisassembly(Addr pc,
|
|
|
|
const SymbolTable *symtab) const;
|
|
|
|
|
|
|
|
int imm;
|
|
|
|
};
|
2006-01-29 23:25:54 +01:00
|
|
|
}};
|
|
|
|
|
|
|
|
output decoder {{
|
2006-04-01 03:31:53 +02:00
|
|
|
std::string Mem::generateDisassembly(Addr pc,
|
|
|
|
const SymbolTable *symtab) const
|
2006-01-29 23:25:54 +01:00
|
|
|
{
|
2006-04-01 03:31:53 +02:00
|
|
|
std::stringstream response;
|
|
|
|
bool load = (_numDestRegs == 1);
|
|
|
|
|
|
|
|
printMnemonic(response, mnemonic);
|
|
|
|
if(!load)
|
|
|
|
{
|
|
|
|
printReg(response, _srcRegIdx[0]);
|
|
|
|
ccprintf(response, ", ");
|
|
|
|
}
|
|
|
|
ccprintf(response, "[ ");
|
|
|
|
printReg(response, _srcRegIdx[load ? 0 : 1]);
|
|
|
|
ccprintf(response, " + ");
|
|
|
|
printReg(response, _srcRegIdx[load ? 1 : 2]);
|
|
|
|
ccprintf(response, " ]");
|
|
|
|
if(load)
|
|
|
|
{
|
|
|
|
ccprintf(response, ", ");
|
|
|
|
printReg(response, _destRegIdx[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return response.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string MemImm::generateDisassembly(Addr pc,
|
|
|
|
const SymbolTable *symtab) const
|
|
|
|
{
|
|
|
|
std::stringstream response;
|
|
|
|
bool load = (_numDestRegs == 1);
|
|
|
|
|
|
|
|
printMnemonic(response, mnemonic);
|
|
|
|
if(!load)
|
|
|
|
{
|
|
|
|
printReg(response, _srcRegIdx[0]);
|
|
|
|
ccprintf(response, ", ");
|
|
|
|
}
|
|
|
|
ccprintf(response, "[ ");
|
|
|
|
printReg(response, _srcRegIdx[load ? 0 : 1]);
|
|
|
|
ccprintf(response, " + 0x%x ]", imm);
|
|
|
|
if(load)
|
|
|
|
{
|
|
|
|
ccprintf(response, ", ");
|
|
|
|
printReg(response, _destRegIdx[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return response.str();
|
2006-01-29 23:25:54 +01:00
|
|
|
}
|
|
|
|
}};
|
|
|
|
|
|
|
|
def template MemExecute {{
|
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-07 10:33:10 +01:00
|
|
|
Fault fault = NoFault;
|
2006-03-28 22:13:57 +02:00
|
|
|
Addr EA;
|
2006-03-07 10:33:10 +01:00
|
|
|
%(op_decl)s;
|
|
|
|
%(op_rd)s;
|
2006-03-28 22:13:57 +02:00
|
|
|
%(ea_code)s;
|
2006-03-07 10:33:10 +01:00
|
|
|
%(code)s;
|
2006-01-29 23:25:54 +01:00
|
|
|
|
2006-03-07 10:33:10 +01:00
|
|
|
if(fault == NoFault)
|
|
|
|
{
|
2006-01-29 23:25:54 +01:00
|
|
|
//Write the resulting state to the execution context
|
|
|
|
%(op_wb)s;
|
2006-03-07 10:33:10 +01:00
|
|
|
}
|
2006-01-29 23:25:54 +01:00
|
|
|
|
2006-03-07 10:33:10 +01:00
|
|
|
return fault;
|
2006-01-29 23:25:54 +01:00
|
|
|
}
|
|
|
|
}};
|
|
|
|
|
2006-04-01 03:31:53 +02:00
|
|
|
// Primary format for memory instructions:
|
2006-01-29 23:25:54 +01:00
|
|
|
def format Mem(code, *opt_flags) {{
|
2006-04-01 03:31:53 +02:00
|
|
|
addrCalcReg = 'EA = Rs1 + Rs2;'
|
|
|
|
addrCalcImm = 'EA = Rs1 + SIMM13;'
|
|
|
|
iop = genCompositeIop(code, name, Name, 'Mem',
|
|
|
|
opt_flags, ea_code=addrCalcReg)
|
|
|
|
iop_imm = genCompositeIop(code, name, Name + 'Imm', 'MemImm',
|
|
|
|
opt_flags, ea_code=addrCalcImm)
|
|
|
|
header_output = BasicDeclare.subst(iop) + BasicDeclare.subst(iop_imm)
|
|
|
|
decoder_output = BasicConstructor.subst(iop) + BasicConstructor.subst(iop_imm)
|
|
|
|
decode_block = ROrImmDecode.subst(iop)
|
|
|
|
exec_output = MemExecute.subst(iop) + MemExecute.subst(iop_imm)
|
2006-01-29 23:25:54 +01:00
|
|
|
}};
|