Inspired by #71 this is an auto-generated tracker for the implementation state of all the AArch64 registers:
Key:
Currently this only tracks the existence of a register or field, but it would also be useful to actually check the offset and width of each subfield as well. It also only recognises ConstantField and ConditionalField types, which might miss some fields.
Code for generating this list
import json
import os
names = []
regs = set()
with open("./Registers.json") as f:
j = json.loads(f.read())
for r in j:
if r["_type"] != "Register" or r["state"] != "AArch64":
continue
name = r["name"].lower()
if name[-4:] not in ["_el0", "_el1", "_el2", "_el3"]:
continue
mrs = [a for a in r["accessors"] if a["name"] == "A64.MRS"]
msr = [a for a in r["accessors"] if a["name"] == "A64.MSRregister"]
can_read = len(mrs) > 0
can_write = len(msr) > 0
kind = None
if can_write and can_read:
kind = "rw"
elif can_write and not can_read:
kind = "wo"
elif not can_write and can_read:
kind = "ro"
enc = None
if len(msr) > 0:
enc = msr[0]["encoding"][0]["encodings"]
if len(mrs) > 0:
enc = mrs[0]["encoding"][0]["encodings"]
if enc:
crm = int(enc["CRm"]["value"].replace("'", ""), 2)
crn = int(enc["CRn"]["value"].replace("'", ""), 2)
op0 = int(enc["op0"]["value"].replace("'", ""), 2)
op1 = int(enc["op1"]["value"].replace("'", ""), 2)
op2 = int(enc["op2"]["value"].replace("'", ""), 2)
enc = (crm, crn, op1, op2, op0)
else:
continue
if name in regs:
continue
regs.add(name)
subfields = []
fs = r["fieldsets"]
if len(fs) == 0:
continue
fs0 = fs[0]
vals = fs0["values"]
for v in vals:
if v["_type"] == "Fields.Reserved":
continue
if v["_type"] == "Fields.Field":
continue
if v["_type"] == "Fields.ImplementationDefined":
continue
if v["_type"] == "Fields.Array":
continue
if v["_type"] == "Fields.Dynamic":
continue
if v["_type"] == "Fields.Vector":
continue
if v["_type"] == "Fields.ConstantField":
name1 = v["name"]
start = v["rangeset"][0]["start"]
width = v["rangeset"][0]["width"]
values = []
if "constraints" in v["value"]:
xx = v["value"]["constraints"]
if xx is not None:
for val in xx["values"]:
if val["_type"] != "Values.Value":
continue
a = int(val["value"].replace("'", ""), 2)
values += [a]
elif v["_type"] == "Fields.ConditionalField":
cfs = [x for x in v["fields"] if x["field"]["_type"] == "Fields.ConstantField"]
if len(cfs) == 0:
continue
name1 = cfs[0]["field"]["name"]
start = v["rangeset"][0]["start"]
width = v["rangeset"][0]["width"]
values = []
else:
exit(0)
sf = {}
sf["name"] = name1
sf["start"] = start
sf["width"] = width
sf["values"] = values
subfields += [sf]
names += [(name, enc, kind, subfields)]
BASE_PATH = "/home/cub3d/projects/aarch64-cpu"
print("-"*32)
for (n, enc, kind, subfields) in names:
pth = f"{BASE_PATH}/src/registers/{n}.rs"
exists = os.path.exists(pth)
if exists:
with open(pth) as f:
content = f.read()
out = ""
any_missing = False
for s in subfields:
name = s["name"]
present = (name + " OFFSET") in content
check = "x" if present else " "
out += f"- - [{check}] {name}\n"
if not present:
any_missing = True
if any_missing:
print(f"- [ ] {n}")
print(out.rstrip())
else:
print(f"- [x] {n}")
else:
print(f"- [ ] {n}")
Registers:
Inspired by #71 this is an auto-generated tracker for the implementation state of all the AArch64 registers:
Key:
Currently this only tracks the existence of a register or field, but it would also be useful to actually check the offset and width of each subfield as well. It also only recognises
ConstantFieldandConditionalFieldtypes, which might miss some fields.Code for generating this list
Registers: