res.append((os.path.join(insns_dir, fname), insn))
return res
-intpatterns = ['WRITE_RD', 'RS1', 'RS2', 'RS3']
+cintpatterns = [ 'WRITE_RVC_RS1S', 'WRITE_RVC_RS2S',
+ 'RVC_RS1', 'RVC_RS2', 'RVC_RS1S', 'RVC_RS2S', ]
+cfloatpatterns = [ 'WRITE_RVC_FRS2S', 'RVC_FRS2 ', 'RVC_FRS2S ']
+intpatterns = ['WRITE_RD' , 'RS1', 'RS2', 'RS3']
floatpatterns = ['WRITE_FRD', 'FRS1', 'FRS2', 'FRS3']
patterns = intpatterns + floatpatterns
+patterns += cintpatterns
+patterns += cfloatpatterns
+
+allfloats = floatpatterns + cfloatpatterns
+floatmask = (1<<len(allfloats)-1)
+allints = intpatterns + cintpatterns[2:]
def find_registers(fname):
res = []
- isintfloat = 0x0 + 0xf << 4
+ isintfloat = 0x0 + floatmask << len(allints)
with open(fname) as f:
f = f.read()
for pattern in patterns:
# botch-job/hack: RS1 also matches against FRS1 (etc.)
# check letter before match: if "F", skip it.
continue
+ if pattern.startswith('R') and x != 0 and f[x-1] == '_':
+ # RS1 also matches against RVC_RS1 (etc.)
+ # check letter before match: if "_", skip it.
+ continue
+ if pattern.startswith('FR') and x != 0 and f[x-1] == '_':
+ # RS1 also matches against RVC_FRS1 (etc.)
+ # check letter before match: if "_", skip it.
+ continue
+ if 'RVC_' in pattern and f[x+len(pattern)] == 'S':
+ # RVC_RS2S also matches against RVC_RS2 (etc.)
+ # check letter at end of match: if "S", skip it.
+ continue
p = pattern
if p.startswith('WRITE_'):
p = p[6:]
- if pattern in intpatterns:
- idx = intpatterns.index(pattern)
+ if pattern in allints:
+ idx = allints.index(pattern)
isintfloat += 1 << idx
- if pattern in floatpatterns:
- idx = floatpatterns.index(pattern)
- isintfloat &= ~(1 << (idx+4))
+ if pattern in allfloats:
+ idx = allfloats.index(pattern)
+ isintfloat &= ~(1 << (idx+len(allints)))
res.append('#define USING_REG_%s' % p)
if not res:
return '#define USING_NOREGS\n' \