class InstObjParams:
def __init__(self, mnem, class_name, base_class = '',
- code = None, opt_args = [], *extras):
+ code = None, opt_args = [], extras = {}):
self.mnemonic = mnem
self.class_name = class_name
self.base_class = base_class
else:
origCode = code
codeBlock = CodeBlock(code)
- compositeCode = '\n'.join([origCode] +
- [pair[1] for pair in extras])
+ stringExtras = {}
+ otherExtras = {}
+ for (k, v) in extras.items():
+ if type(v) == str:
+ stringExtras[k] = v
+ else:
+ otherExtras[k] = v
+ compositeCode = "\n".join([origCode] + stringExtras.values())
+ # compositeCode = '\n'.join([origCode] +
+ # [pair[1] for pair in extras])
compositeBlock = CodeBlock(compositeCode)
for code_attr in compositeBlock.__dict__.keys():
setattr(self, code_attr, getattr(compositeBlock, code_attr))
- for (key, snippet) in extras:
+ for (key, snippet) in stringExtras.items():
setattr(self, key, CodeBlock(snippet).code)
+ for (key, item) in otherExtras.items():
+ setattr(self, key, item)
self.code = codeBlock.code
self.orig_code = origCode
else:
//Constructor
%(class_name)s(MachInst machInst);
+ protected:
class %(class_name)s_0 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_0(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[0]",
class %(class_name)s_1 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_1(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[1]",
class %(class_name)s_2 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_2(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[2]",
class %(class_name)s_3 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_3(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[3]",
class %(class_name)s_4 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_4(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[4]",
class %(class_name)s_5 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_5(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[5]",
class %(class_name)s_6 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_6(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[6]",
class %(class_name)s_7 : public %(base_class)sMicro
{
+ public:
//Constructor
%(class_name)s_7(MachInst machInst) :
%(base_class)sMicro("%(mnemonic)s[7]",
: %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
{
%(constructor)s;
- microOps =
- {new %(class_name)s_0(machInst),
- new %(class_name)s_1(machInst),
- new %(class_name)s_2(machInst),
- new %(class_name)s_3(machInst),
- new %(class_name)s_4(machInst),
- new %(class_name)s_5(machInst),
- new %(class_name)s_6(machInst),
- new %(class_name)s_7(machInst)}
+ microOps[0] = new %(class_name)s_0(machInst);
+ microOps[1] = new %(class_name)s_1(machInst);
+ microOps[2] = new %(class_name)s_2(machInst);
+ microOps[3] = new %(class_name)s_3(machInst);
+ microOps[4] = new %(class_name)s_4(machInst);
+ microOps[5] = new %(class_name)s_5(machInst);
+ microOps[6] = new %(class_name)s_6(machInst);
+ microOps[7] = new %(class_name)s_7(machInst);
}
}};
return new MemAddressNotAligned;'''
addrCalcReg = 'EA = Rs1 + Rs2 + offset;'
addrCalcImm = 'EA = Rs1 + imm + offset;'
- iop = InstObjParams(name, Name, 'Mem', code, opt_flags)
- iop_imm = InstObjParams(name, Name + 'Imm', 'MemImm', code, opt_flags)
+ iop = InstObjParams(name, Name, 'BlockMem', code, opt_flags)
+ iop_imm = InstObjParams(name, Name + 'Imm', 'BlockMemImm', code, opt_flags)
header_output = BlockMemDeclare.subst(iop) + BlockMemDeclare.subst(iop_imm)
decoder_output = BlockMemConstructor.subst(iop) + BlockMemConstructor.subst(iop_imm)
decode_block = ROrImmDecode.subst(iop)
+ matcher = re.compile(r'Frd_N')
+ exec_output = ''
for microPC in range(8):
- pcedCode = code % ("micro_pc", microPC)
- iop = InstObjParams(name, Name, 'Mem', pcedCode,
- opt_flags, ("ea_code", addrCalcReg),
- ("fault_check", faultCheck), ("micro_pc", microPC))
- iop_imm = InstObjParams(name, Name + 'Imm', 'MemImm', pcedCode,
- opt_flags, ("ea_code", addrCalcImm),
- ("fault_check", faultCheck), ("micro_pc", microPC))
+ pcedCode = matcher.sub("Frd_%d" % microPC, code)
+ iop = InstObjParams(name, Name, 'BlockMem', pcedCode,
+ opt_flags, {"ea_code": addrCalcReg,
+ "fault_check": faultCheck, "micro_pc": microPC})
+ iop_imm = InstObjParams(name, Name + 'Imm', 'BlockMemImm', pcedCode,
+ opt_flags, {"ea_code": addrCalcImm,
+ "fault_check": faultCheck, "micro_pc": microPC})
exec_output += execute.subst(iop)
exec_output += execute.subst(iop_imm)
faultCheck = ''
(usesImm, code, immCode,
rString, iString) = splitOutImm(code)
iop = InstObjParams(name, Name, 'IntOp', code,
- opt_flags, ("cc_code", ccCode))
+ opt_flags, {"cc_code": ccCode})
header_output = BasicDeclare.subst(iop)
decoder_output = BasicConstructor.subst(iop)
exec_output = IntOpExecute.subst(iop)
if usesImm:
imm_iop = InstObjParams(name, Name + 'Imm', 'IntOpImm' + iString,
- immCode, opt_flags, ("cc_code", ccCode))
+ immCode, opt_flags, {"cc_code": ccCode})
header_output += BasicDeclare.subst(imm_iop)
decoder_output += BasicConstructor.subst(imm_iop)
exec_output += IntOpExecute.subst(imm_iop)
def format SetHi(code, *opt_flags) {{
iop = InstObjParams(name, Name, 'SetHi',
- code, opt_flags, ("cc_code", ''))
+ code, opt_flags, {"cc_code": ''})
header_output = BasicDeclare.subst(iop)
decoder_output = BasicConstructor.subst(iop)
exec_output = IntOpExecute.subst(iop)