From 95fc8e9fb9535296cc674ec2744877d7c360c044 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 24 Sep 2018 03:03:58 +0100 Subject: [PATCH] add function identifying the registers in each emulated instruction --- id_regs.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/id_regs.py b/id_regs.py index c6c34ff..d74f088 100644 --- a/id_regs.py +++ b/id_regs.py @@ -24,7 +24,25 @@ def list_insns(): res.append(os.path.join(insns_dir, fname)) return res +patterns = ['WRITE_RD', 'RS1', 'RS2', 'RS3', + 'WRITE_FRD', 'FRS1', 'FRS2', 'FRS3'] + +def find_registers(fname): + res = [] + with open(fname) as f: + f = f.read() + for pattern in patterns: + x = f.find(pattern) + if x == -1: + continue + if pattern.startswith('R') and x != 0 and f[x-1] == 'F': + # botch-job/hack: RS1 also matches against FRS1 (etc.) + # check letter before match: if "F", skip it. + continue + res.append('REG_%s' % pattern) + return ' | '.join(res) + if __name__ == '__main__': files = list_insns() - for f in files: - print f + for fname in files: + print fname, find_registers(fname) -- 2.30.2