Skip to content

Instantly share code, notes, and snippets.

@ostannard
Created January 22, 2024 18:45
Show Gist options
  • Save ostannard/a919cf7c0da5a6971c1e345be1928ef0 to your computer and use it in GitHub Desktop.
Save ostannard/a919cf7c0da5a6971c1e345be1928ef0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
from pprint import pprint
from sys import exit
with open("aarch64.json", "r") as f:
records = json.load(f)
def has_float_reg(record):
operands = record["InOperandList"]["args"] + record["OutOperandList"]["args"]
for op in operands:
regclass = op[0].get("def", "")
if regclass.startswith("FPR") or regclass in ("V64", "V128"):
return True
return False
def has_float_reg_alias(record):
operands = record["ResultInst"]["args"]
for op in operands:
if not isinstance(op[0], dict):
continue
regclass = op[0].get("def", "")
if regclass.startswith("FPR") or regclass in ("V64", "V128"):
return True
return False
def has_predicate(record):
return bool(record.get("Predicates", []))
def check_instruction(record):
if has_float_reg(record) and not has_predicate(record):
print(record["!loc"], record["!name"], record["AsmString"])
def check_inst_alias(record):
if has_float_reg_alias(record) and not has_predicate(record):
print(record["!loc"], record["!name"], record["AsmString"])
def check_all():
for name, record in records.items():
if name.startswith("!"):
continue
if "Instruction" in record.get("!superclasses", ""):
check_instruction(record)
elif "InstAlias" in record.get("!superclasses", ""):
check_inst_alias(record)
check_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment