mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-22 06:33:03 +00:00
tools/reg_filter.py: Tool to add IMPDEF sysreg names to a disasm
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
ecb6c82e75
commit
4652ac2098
1 changed files with 23 additions and 0 deletions
23
tools/reg_filter.py
Normal file
23
tools/reg_filter.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import json, sys, re
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("regfile")
|
||||
args = parser.parse_args()
|
||||
|
||||
data = json.load(open(args.regfile))
|
||||
|
||||
name_map = {}
|
||||
|
||||
for reg in data:
|
||||
name = reg['name']
|
||||
enc = reg['enc']
|
||||
name_map[f"s{enc[0]}_{enc[1]}_c{enc[2]}_c{enc[3]}_{enc[4]}"] = name
|
||||
|
||||
def reg_lookup(m):
|
||||
s = m.group(0)
|
||||
return name_map.get(s, s)
|
||||
|
||||
for line in sys.stdin:
|
||||
line = re.sub(r"s(\d+)_(\d+)_c(\d+)_c(\d+)_(\d+)", reg_lookup, line)
|
||||
sys.stdout.write(line)
|
Loading…
Reference in a new issue