target/hexagon: Use argparse in all python scripts

QOL commit, all the various gen_* python scripts take a large set
arguments where order is implicit.  Using argparse we also get decent
error messages if a field is missing or too many are added.

Signed-off-by: Anton Johansson <anjo@rev.ng>
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
This commit is contained in:
Anton Johansson 2024-12-06 17:01:02 +01:00 committed by Brian Cain
parent f0db9f5759
commit e295796726
13 changed files with 109 additions and 47 deletions

View file

@ -20,6 +20,7 @@
import sys
import re
import string
import argparse
from io import StringIO
import hex_common
@ -43,13 +44,19 @@ import hex_common
## them are inputs ("in" prefix), while some others are outputs.
##
def main():
hex_common.read_semantics_file(sys.argv[1])
parser = argparse.ArgumentParser(
"Emit instruction implementations that can be fed to idef-parser"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
hex_common.calculate_attribs()
hex_common.init_registers()
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
f.write('#include "macros.h.inc"\n\n')
for tag in hex_common.tags: