| 16 | return int(s.replace("0b", ""), 2) |
| 17 | |
| 18 | def parse_one(regs, xml): |
| 19 | t = ElementTree.parse(xml) |
| 20 | |
| 21 | for reg in t.findall('registers/register'): |
| 22 | data = {} |
| 23 | |
| 24 | name = reg.find('reg_short_name').text |
| 25 | fullname = reg.find('reg_long_name').text |
| 26 | |
| 27 | if name.startswith("S3_") or name.startswith("SYS S1_"): |
| 28 | continue |
| 29 | |
| 30 | array = reg.find('reg_array') |
| 31 | |
| 32 | start = end = 0 |
| 33 | |
| 34 | if array: |
| 35 | start = int(array.find("reg_array_start").text) |
| 36 | end = int(array.find("reg_array_end").text) |
| 37 | |
| 38 | encs = {} |
| 39 | accessors = {} |
| 40 | |
| 41 | for am in reg.findall('access_mechanisms/access_mechanism'): |
| 42 | accessor = am.attrib["accessor"] |
| 43 | if accessor.startswith("MSRimmediate"): |
| 44 | continue |
| 45 | ins = am.find("encoding/access_instruction").text.split(" ")[0] |
| 46 | regname = accessor.split(" ", 1)[1] |
| 47 | enc = {} |
| 48 | for e in am.findall("encoding/enc"): |
| 49 | enc[e.attrib["n"]] = e.attrib["v"] |
| 50 | |
| 51 | enc = enc["op0"], enc["op1"], enc["CRn"], enc["CRm"], enc["op2"] |
| 52 | if regname in encs: |
| 53 | assert encs[regname] == enc |
| 54 | encs[regname] = enc |
| 55 | accessors.setdefault(regname, set()).add(ins) |
| 56 | |
| 57 | if not encs: |
| 58 | continue |
| 59 | |
| 60 | fieldsets = [] |
| 61 | |
| 62 | width = None |
| 63 | |
| 64 | for fields_elem in reg.findall('reg_fieldsets/fields'): |
| 65 | |
| 66 | fieldset = {} |
| 67 | |
| 68 | if (instance_elem := fields_elem.find('fields_instance')) is not None: |
| 69 | fieldset["instance"] = instance_elem.text |
| 70 | |
| 71 | fields = [] |
| 72 | |
| 73 | set_width = int(fields_elem.attrib["length"]) |
| 74 | |
| 75 | if width is None: |