Skip to content

Commit

Permalink
detect_inouts: collect uses and defs for custom regs
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Aug 16, 2024
1 parent f199af8 commit 6ccf3f2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions seal5/transform/detect_inouts/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,37 @@ def run(args):
elif op_name in context.writes:
if seal5.model.Seal5OperandAttribute.OUT not in instr_def.attributes:
op_def.attributes[seal5.model.Seal5OperandAttribute.OUT] = []
print("---")
print("instr_def.scalars.keys()", instr_def.scalars.keys())
for reg_name in context.reads:
print("reg_name1", reg_name)
if reg_name in instr_def.operands.keys():
continue
if reg_name in instr_def.scalars.keys():
continue
# TODO: how about register groups
# TODO: handle other architectural state vars here (PC,...)
assert reg_name in set_def.registers
uses = instr_def.attributes.get(seal5.model.Seal5InstrAttribute.USES, [])
uses.append(reg_name)
# TODO: drop duplicates?
instr_def.attributes[seal5.model.Seal5InstrAttribute.USES] = uses
for reg_name in context.writes:
print("reg_name2", reg_name)
if reg_name in instr_def.operands.keys():
continue
if reg_name in instr_def.scalars.keys():
continue
# TODO: how about register groups
# TODO: handle other architectural state vars here (PC,...)
assert reg_name in set_def.registers
defs = instr_def.attributes.get(seal5.model.Seal5InstrAttribute.DEFS, [])
defs.append(reg_name)
# TODO: drop duplicates?
instr_def.attributes[seal5.model.Seal5InstrAttribute.DEFS] = defs
print("instr_def.operands_", instr_def.operands)
print("instr_def.attributes", instr_def.attributes)
# input("999")

logger.info("dumping model")
with open(model_path, "wb") as f:
Expand Down

0 comments on commit 6ccf3f2

Please sign in to comment.