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)