From 6ccf3f28c13b854ff6704bcd78c2a1e6b542c5e0 Mon Sep 17 00:00:00 2001 From: Philipp van Kempen Date: Sat, 1 Jun 2024 11:18:38 +0200 Subject: [PATCH] detect_inouts: collect uses and defs for custom regs --- seal5/transform/detect_inouts/collect.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/seal5/transform/detect_inouts/collect.py b/seal5/transform/detect_inouts/collect.py index 7c163882..c73656ab 100644 --- a/seal5/transform/detect_inouts/collect.py +++ b/seal5/transform/detect_inouts/collect.py @@ -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: