imm = yield self.dec2.e.imm_data.data
inputs.append(SelectableInt(imm, 64))
assert len(outputs) >= 1
- output = outputs[0]
- gts = [(x > output) for x in inputs]
+ print ("outputs", repr(outputs))
+ if isinstance(outputs, list) or isinstance(outputs, tuple):
+ output = outputs[0]
+ else:
+ output = outputs
+ gts = []
+ for x in inputs:
+ print ("gt input", x, output)
+ gt = (x > output)
+ gts.append(gt)
print(gts)
cy = 1 if any(gts) else 0
if not (1 & already_done):
print ("inputs", inputs)
# 32 bit carry
- gts = [(x[32:64] > output[32:64]) == SelectableInt(1, 1)
- for x in inputs]
+ gts = []
+ for x in inputs:
+ print ("input", x, output)
+ gt = (x[32:64] > output[32:64]) == SelectableInt(1, 1)
+ gts.append(gt)
cy32 = 1 if any(gts) else 0
if not (2 & already_done):
self.spr['XER'][XER_bits['CA32']] = cy32
("left", "INVERT"),
)
- def __init__(self, form):
+ def __init__(self, form, include_carry_in_write=False):
+ self.include_ca_in_write = include_carry_in_write
self.gprs = {}
form = self.sd.sigforms[form]
print(form)
self.declared_vars = set()
for rname in ['RA', 'RB', 'RC', 'RT', 'RS']:
self.gprs[rname] = None
+ self.declared_vars.add(rname)
self.available_op_fields = set()
for k in formkeys:
if k not in self.gprs:
name = p[1]
if name in self.available_op_fields:
self.op_fields.add(name)
- if name in ['CA', 'CA32']:
- self.write_regs.add(name)
+ if self.include_ca_in_write:
+ if name in ['CA', 'CA32']:
+ self.write_regs.add(name)
if name in ['CR', 'LR', 'CTR', 'TAR', 'FPSCR', 'MSR']:
self.special_regs.add(name)
self.write_regs.add(name) # and add to list to write
class GardenSnakeParser(PowerParser):
- def __init__(self, lexer=None, debug=False, form=None):
+ def __init__(self, lexer=None, debug=False, form=None, incl_carry=False):
self.sd = create_pdecode()
- PowerParser.__init__(self, form)
+ PowerParser.__init__(self, form, incl_carry)
self.debug = debug
if lexer is None:
lexer = IndentLexer(debug=0)
#from compiler import misc, syntax, pycodegen
class GardenSnakeCompiler(object):
- def __init__(self, debug=False, form=None):
- self.parser = GardenSnakeParser(debug=debug, form=form)
+ def __init__(self, debug=False, form=None, incl_carry=False):
+ self.parser = GardenSnakeParser(debug=debug, form=form,
+ incl_carry=incl_carry)
def compile(self, code, mode="exec", filename="<string>"):
tree = self.parser.parse(code)