From nobody Mon Feb 9 16:56:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1734063634; cv=none; d=zohomail.com; s=zohoarc; b=GZ0DYY9KRc6qP57h+4CmyRtnVR7hi2b10Kj55Dzi2QVvi+d9aedAVT6aXHMxHK2X3l/MaDgnkDM3gvkXK/zcn7I34BkzvxLb/6fyuztKaB/9QluR62VftzoprjN86tABUbo6N0WIDi+QCQY2vSxcZvu9zxZ71KjdLz92moLSoAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734063634; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jFN2KrPddaWoK465RuaqilrI8aTRieIcfTQH9VOUXT4=; b=B4wW3PghLLt1VlYDSX3UAEuNqzPHZ3oAKbWLdaNAhDhpyY1Qu2U8y8NC8RUQhDhq1SRBaoY+u5kYQggAEzOQQ+7XGTIgtaClm5AeqD5I4QpdwLz/DBmadqEcBmYsoVwn8m2RK3ARVVIqchaVZse+7Fkpt37S7fPrUQ6ZVJS/Sis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734063634124191.6525781327083; Thu, 12 Dec 2024 20:20:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLx8r-0006bu-Hq; Thu, 12 Dec 2024 23:19:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8o-0006aB-G6 for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8m-00082v-1W for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BCI0ECZ029980 for ; Fri, 13 Dec 2024 04:18:59 GMT Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43dxw4ddyt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 13 Dec 2024 04:18:58 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-725eaaf8914so1773305b3a.1 for ; Thu, 12 Dec 2024 20:18:58 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725deac1daasm9451938b3a.171.2024.12.12.20.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:18:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= jFN2KrPddaWoK465RuaqilrI8aTRieIcfTQH9VOUXT4=; b=O5qEA8/XZ4+Prhwv 2kJIXN3IAzfqMLZswxpqQ53fyFcfPbJN2wy+B1D15TuPpf0RNI9G4vEeA1vzvgOG cQ/GSo3+9/DqCZxW1nWmodK41nWmdJtdhss5caAEqea2SAAf8tTWfJIeECR45ktD rWvTvW0wWpjjd6eKfCy5JRFKlhgQ/sLcmemEisYhQ97MInlZihKbzJ/E4GWBM5tE JeCiZP22WJKVdDznso+yrfoRt3cvsgLMe7GfvdBbSyoAlsqWfXK/NXttBNMRm7Fe Wew48Lg7Al5jIekjp4CEWDeSdHxqZREQU1BirUeLWMGscduFcDdWoUkbbiFk3G7+ y+T5zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734063537; x=1734668337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jFN2KrPddaWoK465RuaqilrI8aTRieIcfTQH9VOUXT4=; b=W5W/c1MDZLM4SSqOjYqHVEqD86eaMx/9b6KGoBl8Ie8Te8fuAWYVND/zrdmq13ne9o Qi26fSfxYCag4ADLa/+MTlKKjcquT0Hp29qyj/ogu7gIjQ873uk4KewalrGIRKB4y/om p598bfR8cGeBX6NwuPZ/uwMs9Jyu9EZN6J9FHf5H6F6/Qlwam1uov7Yj+4F59DIEb729 oq46kV0wo7ixMCfJqHe93UJ/vtRkGQzQ0GFv5Jj65ZA05qd3Ll6Hlu1Ww+5FD1gvixyS BfHmILGQzIYzaFPvV//dXRd6HJvcR1xDplTB9fPhSQbaHSrqmEsgcddvDEu1IDRyZqoU WUzQ== X-Gm-Message-State: AOJu0YzQxEwbUvMZVFlSiL0Gwe2VngrCdR51F/I6Zl4sdyqgJ8iUD330 JNkXXCZ2yw8QixmjDQde7hiVzMDB7E5ae+TZ2sKeOeZk+ZUgz1dO59/6RbHe/3WEF+Ez5uqkdv2 0ECNoiomSGzXneymd3JEwELiztc/Q2rSZ6+JneSSvuBEQactBhrHnc/PChfiSMw== X-Gm-Gg: ASbGnct6mYyAKDAxZICckI40BA/tajKbMerr05dV8mGb/sGCjnIu4tcskmrMzTdg4jW Sd6mcWzjG8pz6tytm5wmC/3U00mkSf0cVtNIkFHJrYJELyFFGjD0gjAj2btc0I2mp8CHDAnh16x msbPjnr4ZYNgola/cDLcIK2ufxCgwJejP7cmYMsZ5veEdJf3MsGKg0GHjVoI6B79z6+O69l3Ir7 zxV5Ssr3+NoCtZfMHoECk7Xjb0ucU6n2nHqXtaLnvu6tMiCGapUsyNCZQmFsmP5yUoBXV/4DG8G 4c+Jj2j5hIIs8cyJ+/WDcCrm1lUQRg== X-Received: by 2002:a05:6a00:4f89:b0:725:eb85:f7ef with SMTP id d2e1a72fcca58-7290c1b290bmr1913519b3a.14.1734063536980; Thu, 12 Dec 2024 20:18:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH+iGQP0b5ao7QudoB8228qKitYfn2o2qkTNgFM9T7yw/nQBFGRZIjEDLkoLIr7F+QMxNKdw== X-Received: by 2002:a05:6a00:4f89:b0:725:eb85:f7ef with SMTP id d2e1a72fcca58-7290c1b290bmr1913479b3a.14.1734063536535; Thu, 12 Dec 2024 20:18:56 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, peter.maydell@linaro.org, quic_mathbern@quicinc.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com, ltaylorsimpson@gmail.com, Brian Cain Subject: [PULL 4/5] target/hexagon: Use argparse in all python scripts Date: Thu, 12 Dec 2024 20:18:35 -0800 Message-Id: <20241213041836.39986-5-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> References: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: BlKl96_V7_KD_Yfn5OL0swswcEsOrxKs X-Proofpoint-GUID: BlKl96_V7_KD_Yfn5OL0swswcEsOrxKs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412130030 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @qualcomm.com) X-ZM-MESSAGEID: 1734063635154116600 From: Anton Johansson 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 Reviewed-by: Brian Cain Signed-off-by: Brian Cain --- target/hexagon/gen_analyze_funcs.py | 6 +++-- target/hexagon/gen_decodetree.py | 19 +++++++++++--- target/hexagon/gen_helper_funcs.py | 7 +++--- target/hexagon/gen_helper_protos.py | 7 +++--- target/hexagon/gen_idef_parser_funcs.py | 11 +++++++-- target/hexagon/gen_op_attribs.py | 11 +++++++-- target/hexagon/gen_opcodes_def.py | 11 +++++++-- target/hexagon/gen_printinsn.py | 11 +++++++-- target/hexagon/gen_tcg_func_table.py | 11 +++++++-- target/hexagon/gen_tcg_funcs.py | 9 ++++--- target/hexagon/gen_trans_funcs.py | 18 +++++++++++--- target/hexagon/hex_common.py | 33 ++++++++++++------------- target/hexagon/meson.build | 2 +- 13 files changed, 109 insertions(+), 47 deletions(-) diff --git a/target/hexagon/gen_analyze_funcs.py b/target/hexagon/gen_analy= ze_funcs.py index 54bac19724..3ac7cc2cfe 100755 --- a/target/hexagon/gen_analyze_funcs.py +++ b/target/hexagon/gen_analyze_funcs.py @@ -78,11 +78,13 @@ def gen_analyze_func(f, tag, regs, imms): =20 =20 def main(): - hex_common.read_common_files() + args =3D hex_common.parse_common_args( + "Emit functions analyzing register accesses" + ) tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[-1], "w") as f: + with open(args.out, "w") as f: f.write("#ifndef HEXAGON_ANALYZE_FUNCS_C_INC\n") f.write("#define HEXAGON_ANALYZE_FUNCS_C_INC\n\n") =20 diff --git a/target/hexagon/gen_decodetree.py b/target/hexagon/gen_decodetr= ee.py index a4fcd622c5..ce703af41d 100755 --- a/target/hexagon/gen_decodetree.py +++ b/target/hexagon/gen_decodetree.py @@ -24,6 +24,7 @@ import textwrap import iset import hex_common +import argparse =20 encs =3D { tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", ""))) @@ -191,8 +192,18 @@ def gen_decodetree_file(f, class_to_decode): f.write(f"{tag}\t{enc_str} @{tag}\n") =20 =20 +def main(): + parser =3D argparse.ArgumentParser( + description=3D"Emit opaque macro calls with instruction semantics" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("class_to_decode", help=3D"instruction class to de= code") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + + hex_common.read_semantics_file(args.semantics) + with open(args.out, "w") as f: + gen_decodetree_file(f, args.class_to_decode) + if __name__ =3D=3D "__main__": - hex_common.read_semantics_file(sys.argv[1]) - class_to_decode =3D sys.argv[2] - with open(sys.argv[3], "w") as f: - gen_decodetree_file(f, class_to_decode) + main() diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper= _funcs.py index e9685bff2f..c1f806ac4b 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -102,12 +102,13 @@ def gen_helper_function(f, tag, tagregs, tagimms): =20 =20 def main(): - hex_common.read_common_files() + args =3D hex_common.parse_common_args( + "Emit helper function definitions for each instruction" + ) tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - output_file =3D sys.argv[-1] - with open(output_file, "w") as f: + with open(args.out, "w") as f: for tag in hex_common.tags: ## Skip the priv instructions if "A_PRIV" in hex_common.attribdict[tag]: diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helpe= r_protos.py index fd2bfd0f36..77f8e0a6a3 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -52,12 +52,13 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): =20 =20 def main(): - hex_common.read_common_files() + args =3D hex_common.parse_common_args( + "Emit helper function prototypes for each instruction" + ) tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - output_file =3D sys.argv[-1] - with open(output_file, "w") as f: + with open(args.out, "w") as f: for tag in hex_common.tags: ## Skip the priv instructions if "A_PRIV" in hex_common.attribdict[tag]: diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_i= def_parser_funcs.py index 72f11c68ca..2f6e826f76 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -20,6 +20,7 @@ import sys import re import string +import argparse from io import StringIO =20 import hex_common @@ -43,13 +44,19 @@ ## them are inputs ("in" prefix), while some others are outputs. ## def main(): - hex_common.read_semantics_file(sys.argv[1]) + parser =3D argparse.ArgumentParser( + "Emit instruction implementations that can be fed to idef-parser" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + hex_common.read_semantics_file(args.semantics) hex_common.calculate_attribs() hex_common.init_registers() tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[-1], "w") as f: + with open(args.out, "w") as f: f.write('#include "macros.h.inc"\n\n') =20 for tag in hex_common.tags: diff --git a/target/hexagon/gen_op_attribs.py b/target/hexagon/gen_op_attri= bs.py index 99448220da..bbbb02df3a 100755 --- a/target/hexagon/gen_op_attribs.py +++ b/target/hexagon/gen_op_attribs.py @@ -21,16 +21,23 @@ import re import string import hex_common +import argparse =20 =20 def main(): - hex_common.read_semantics_file(sys.argv[1]) + parser =3D argparse.ArgumentParser( + "Emit opaque macro calls containing instruction attributes" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + hex_common.read_semantics_file(args.semantics) hex_common.calculate_attribs() =20 ## ## Generate all the attributes associated with each instruction ## - with open(sys.argv[-1], "w") as f: + with open(args.out, "w") as f: for tag in hex_common.tags: f.write( f"OP_ATTRIB({tag},ATTRIBS(" diff --git a/target/hexagon/gen_opcodes_def.py b/target/hexagon/gen_opcodes= _def.py index 536f0eb68a..94a19ff412 100755 --- a/target/hexagon/gen_opcodes_def.py +++ b/target/hexagon/gen_opcodes_def.py @@ -21,15 +21,22 @@ import re import string import hex_common +import argparse =20 =20 def main(): - hex_common.read_semantics_file(sys.argv[1]) + parser =3D argparse.ArgumentParser( + description=3D"Emit opaque macro calls with instruction names" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + hex_common.read_semantics_file(args.semantics) =20 ## ## Generate a list of all the opcodes ## - with open(sys.argv[-1], "w") as f: + with open(args.out, "w") as f: for tag in hex_common.tags: f.write(f"OPCODE({tag}),\n") =20 diff --git a/target/hexagon/gen_printinsn.py b/target/hexagon/gen_printinsn= .py index 8bf4d0985c..d5f969960a 100755 --- a/target/hexagon/gen_printinsn.py +++ b/target/hexagon/gen_printinsn.py @@ -21,6 +21,7 @@ import re import string import hex_common +import argparse =20 =20 ## @@ -96,11 +97,17 @@ def spacify(s): =20 =20 def main(): - hex_common.read_semantics_file(sys.argv[1]) + parser =3D argparse.ArgumentParser( + "Emit opaque macro calls with information for printing string repr= esentations of instrucions" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + hex_common.read_semantics_file(args.semantics) =20 immext_casere =3D re.compile(r"IMMEXT\(([A-Za-z])") =20 - with open(sys.argv[-1], "w") as f: + with open(args.out, "w") as f: for tag in hex_common.tags: if not hex_common.behdict[tag]: continue diff --git a/target/hexagon/gen_tcg_func_table.py b/target/hexagon/gen_tcg_= func_table.py index 978ac1819b..299a39b1aa 100755 --- a/target/hexagon/gen_tcg_func_table.py +++ b/target/hexagon/gen_tcg_func_table.py @@ -21,15 +21,22 @@ import re import string import hex_common +import argparse =20 =20 def main(): - hex_common.read_semantics_file(sys.argv[1]) + parser =3D argparse.ArgumentParser( + "Emit opaque macro calls with instruction semantics" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + hex_common.read_semantics_file(args.semantics) hex_common.calculate_attribs() tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[-1], "w") as f: + with open(args.out, "w") as f: f.write("#ifndef HEXAGON_FUNC_TABLE_H\n") f.write("#define HEXAGON_FUNC_TABLE_H\n\n") =20 diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs= .py index 05aa0a7855..c2ba91ddc0 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -108,15 +108,16 @@ def gen_def_tcg_func(f, tag, tagregs, tagimms): =20 =20 def main(): - is_idef_parser_enabled =3D hex_common.read_common_files() + args =3D hex_common.parse_common_args( + "Emit functions calling generated code implementing instruction se= mantics (helpers, idef-parser)" + ) tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - output_file =3D sys.argv[-1] - with open(output_file, "w") as f: + with open(args.out, "w") as f: f.write("#ifndef HEXAGON_TCG_FUNCS_H\n") f.write("#define HEXAGON_TCG_FUNCS_H\n\n") - if is_idef_parser_enabled: + if args.idef_parser: f.write('#include "idef-generated-emitter.h.inc"\n\n') =20 for tag in hex_common.tags: diff --git a/target/hexagon/gen_trans_funcs.py b/target/hexagon/gen_trans_f= uncs.py index 30f0c73e0c..45da1b7b5d 100755 --- a/target/hexagon/gen_trans_funcs.py +++ b/target/hexagon/gen_trans_funcs.py @@ -24,6 +24,7 @@ import textwrap import iset import hex_common +import argparse =20 encs =3D { tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", ""))) @@ -136,8 +137,19 @@ def gen_trans_funcs(f): """)) =20 =20 -if __name__ =3D=3D "__main__": - hex_common.read_semantics_file(sys.argv[1]) +def main(): + parser =3D argparse.ArgumentParser( + description=3D"Emit trans_*() functions to be called by " \ + "instruction decoder" + ) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("out", help=3D"output file") + args =3D parser.parse_args() + hex_common.read_semantics_file(args.semantics) hex_common.init_registers() - with open(sys.argv[2], "w") as f: + with open(args.out, "w") as f: gen_trans_funcs(f) + + +if __name__ =3D=3D "__main__": + main() diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index 15ed4980e4..758e5fd12d 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -21,6 +21,7 @@ import re import string import textwrap +import argparse =20 behdict =3D {} # tag ->behavior semdict =3D {} # tag -> semantics @@ -1181,22 +1182,20 @@ def helper_args(tag, regs, imms): return args =20 =20 -def read_common_files(): - read_semantics_file(sys.argv[1]) - read_overrides_file(sys.argv[2]) - read_overrides_file(sys.argv[3]) - ## Whether or not idef-parser is enabled is - ## determined by the number of arguments to - ## this script: - ## - ## 4 args. -> not enabled, - ## 5 args. -> idef-parser enabled. - ## - ## The 5:th arg. then holds a list of the successfully - ## parsed instructions. - is_idef_parser_enabled =3D len(sys.argv) > 5 - if is_idef_parser_enabled: - read_idef_parser_enabled_file(sys.argv[4]) +def parse_common_args(desc): + parser =3D argparse.ArgumentParser(desc) + parser.add_argument("semantics", help=3D"semantics file") + parser.add_argument("overrides", help=3D"overrides file") + parser.add_argument("overrides_vec", help=3D"vector overrides file") + parser.add_argument("out", help=3D"output file") + parser.add_argument("--idef-parser", + help=3D"file of instructions translated by idef-pa= rser") + args =3D parser.parse_args() + read_semantics_file(args.semantics) + read_overrides_file(args.overrides) + read_overrides_file(args.overrides_vec) + if args.idef_parser: + read_idef_parser_enabled_file(args.idef_parser) calculate_attribs() init_registers() - return is_idef_parser_enabled + return args diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index f1723778a6..bb4ebaae81 100644 --- a/target/hexagon/meson.build +++ b/target/hexagon/meson.build @@ -346,7 +346,7 @@ if idef_parser_enabled and 'hexagon-linux-user' in targ= et_dirs # Setup input and dependencies for the next step, this depends on whet= her or # not idef-parser is enabled helper_dep =3D [semantics_generated, idef_generated_tcg_c, idef_genera= ted_tcg] - helper_in =3D [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, idef_gen= erated_list] + helper_in =3D [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, '--idef-= parser', idef_generated_list] else # Setup input and dependencies for the next step, this depends on whet= her or # not idef-parser is enabled --=20 2.34.1