Simplify storing of opcode to description mapping
This commit is contained in:
@@ -299,21 +299,21 @@ template = """// Auto-generated file -- do not modify!
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
entries = defaultdict(list)
|
entries = []
|
||||||
with open(sys.argv[1], "r") as f:
|
with open(sys.argv[1], "r") as f:
|
||||||
for line in f.read().splitlines():
|
for line in f.read().splitlines():
|
||||||
if line and line[0] != "#":
|
if line and line[0] != "#":
|
||||||
opcode_string, desc = tuple(line.split(maxsplit=1))
|
opcode_string, desc = tuple(line.split(maxsplit=1))
|
||||||
for opcode in parse_opcode(opcode_string):
|
for opcode in parse_opcode(opcode_string):
|
||||||
entries[opcode].append(InstrDesc.parse(desc))
|
entries.append((opcode, InstrDesc.parse(desc)))
|
||||||
|
|
||||||
mnemonics = sorted({desc.mnemonic for descs in entries.values() for desc in descs})
|
mnemonics = sorted({desc.mnemonic for _, desc in entries})
|
||||||
mnemonics_lut = {name: mnemonics.index(name) for name in mnemonics}
|
mnemonics_lut = {name: mnemonics.index(name) for name in mnemonics}
|
||||||
|
|
||||||
table32 = Table()
|
table32 = Table()
|
||||||
table64 = Table()
|
table64 = Table()
|
||||||
masks = "ONLY64", "ONLY32"
|
masks = "ONLY64", "ONLY32"
|
||||||
for opcode, descs in entries.items():
|
for opcode, desc in entries:
|
||||||
for desc in descs:
|
|
||||||
if "ONLY64" not in desc.flags:
|
if "ONLY64" not in desc.flags:
|
||||||
table32.add_opcode(opcode, desc.encode(mnemonics_lut))
|
table32.add_opcode(opcode, desc.encode(mnemonics_lut))
|
||||||
if "ONLY32" not in desc.flags:
|
if "ONLY32" not in desc.flags:
|
||||||
|
|||||||
Reference in New Issue
Block a user