import math
instruction_info = namedtuple('instruction_info',
- 'func read_regs uninit_regs write_regs op_fields form asmregs')
+ 'func read_regs uninit_regs write_regs ' + \
+ 'special_regs op_fields form asmregs')
def create_args(reglist, extra=None):
info = self.instrs[name]
yield from self.prep_namespace(info.form, info.op_fields)
- input_names = create_args(info.read_regs | info.uninit_regs)
+ input_names = create_args(info.read_regs | info.uninit_regs |
+ info.special_regs)
print(input_names)
inputs = []
self.assertEqual(sim.gpr(2), SelectableInt(0x10008, 64))
self.assertEqual(sim.gpr(3), SelectableInt(0x1000c, 64))
+ def test_mtcrf(self):
+ lst = ["addi 1, 0, 0xffffffff",
+ "mtcrf 1, 0x1",
+ ]
+ with Program(lst) as program:
+ sim = self.run_tst_program(program)
+ print ("cr", sim.cr)
+ self.assertEqual(sim.cr, SelectableInt(0xffffffff, 32))
+
def run_tst_program(self, prog, initial_regs=[0] * 32):
simulator = self.run_tst(prog, initial_regs)
simulator.gpr.dump()
regsused = {'read_regs': gsc.parser.read_regs,
'write_regs': gsc.parser.write_regs,
'uninit_regs': gsc.parser.uninit_regs,
+ 'special_regs': gsc.parser.special_regs,
'op_fields': gsc.parser.op_fields }
return astor.to_source(tree), regsused
self.read_regs = OrderedSet()
self.uninit_regs = OrderedSet()
self.write_regs = OrderedSet()
+ self.special_regs = OrderedSet() # see p_atom_name
# The grammar comments come from Python's Grammar/Grammar file
name = p[1]
if name in self.available_op_fields:
self.op_fields.add(name)
+ if name in ['CR', 'LR', 'CTR', 'TAR', 'FPSCR']:
+ self.special_regs.add(name)
p[0] = ast.Name(id=name, ctx=ast.Load())
def p_atom_number(self, p):
iinfo_template = """instruction_info(func=%s,
read_regs=%s,
uninit_regs=%s, write_regs=%s,
- op_fields=%s, form='%s',
+ special_regs=%s, op_fields=%s,
+ form='%s',
asmregs=%s)"""
class PyISAWriter(ISA):
iinfo = iinfo_template % (op_fname, rused['read_regs'],
rused['uninit_regs'],
rused['write_regs'],
+ rused['special_regs'],
ops, d.form, d.regs)
iinf += " %s_instrs['%s'] = %s\n" % (pagename, page, iinfo)
# write out initialisation of info, for ISACaller to use
sources = sys.argv[1:]
for source in sources:
isa.write_pysource(source)
- isa.write_isa_class()
+ #isa.write_isa_class()