From nobody Sun May 19 07:11:58 2024 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=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1684939369; cv=none; d=zohomail.com; s=zohoarc; b=BtP7IiPl9ridFSLZw/6ae1+VweFUEjMtXMcbJaZkvjnw1zFSTx6UUqwYRUc83wvcsNXq6s9JXXwM1+aWqKp2j/yrNDv6fdWC/B5tTookSLvE68SkhXKLuNgtNOtYaEzWeo9N6x/rCqPGk2znPl9XMkF+o7Od0MPH833C0FsxrDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684939369; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dsMmg5OuF/Z9H3h+K9bWdBUa912BCnkCvFUV5yA6cj0=; b=HTDxkM1RzhvkKQqqK8+cT+ocn7fxl7Vy0dnu0hiZKV0t05p5MNYPJl0dgVTu1/RK6PjIK9Pq8Cofi97Q9vwyAIZs+xw8LRMe819vrHUbWyCkqakjzQRzrxamUokNdBVHlv5GOUtsjlXJC5ykDX0vxG9sR9IncP7UM0g4jAm3S1g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684939369367820.4434975939603; Wed, 24 May 2023 07:42:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1pgd-0001Rp-86; Wed, 24 May 2023 10:41:59 -0400 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 1q1pgb-0001RH-CN for qemu-devel@nongnu.org; Wed, 24 May 2023 10:41:57 -0400 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 1q1pgX-0000d9-Ts for qemu-devel@nongnu.org; Wed, 24 May 2023 10:41:57 -0400 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34OA6Zr9016222; Wed, 24 May 2023 14:41:52 GMT Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qs42ut1a4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 14:41:52 +0000 Received: from pps.filterd (NALASPPMTA02.qualcomm.com [127.0.0.1]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 34OEadPE020153; Wed, 24 May 2023 14:41:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 3qrduqchbh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 14:41:50 +0000 Received: from NALASPPMTA02.qualcomm.com (NALASPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34OEfooc025348; Wed, 24 May 2023 14:41:50 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-mathbern-lv.qualcomm.com [10.47.235.147]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 34OEfnFD025336 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 14:41:50 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 4229910) id C33F4744A; Wed, 24 May 2023 11:41:49 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=qcppdkim1; bh=dsMmg5OuF/Z9H3h+K9bWdBUa912BCnkCvFUV5yA6cj0=; b=eagIqWTvwbmhVafaSLuima09xeb3w1vJdVDf16rjxboT7V8lKLUd35gA697Uc3e+LrxH z/lgrJ+1xwJnh8t5ojiDkdYnLVv+54gLYaFWSVIKJZqhY1TzI0tNrcN035RxvyBJ53F4 zGzHy7YhBRznEM/C0JPUWYZYoAopAEtZDR4uRbjR6SAVlK3WQPXkjQKr8SpdHrQxEWm7 dPBoEJH0UUzEqA8RPunUQYkhjcvuoSeLZKvWgUvkYzZY4yr1Y/vevYR6gjekd6SErjF9 tvwqAv0FULtWw90IkVtvfuzld/PZ0j8mPEla5hm2w7V50lIdjlYsEKbpIrid7uYS3Uvo ew== From: Matheus Tavares Bernardino To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, bcain@quicinc.com, quic_mliebel@quicinc.com, Alessandro Di Federico , Anton Johansson Subject: [PATCH v2 1/2] target/hexagon/*.py: clean up used 'toss' and 'numregs' vars Date: Wed, 24 May 2023 11:41:47 -0300 Message-Id: <3ffd4ccb972879f57f499705c624e8eaba7f8b52.1684939078.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: UNmLTivz5ROfkQzo5TjVN9xoKbOxZ9mD X-Proofpoint-GUID: UNmLTivz5ROfkQzo5TjVN9xoKbOxZ9mD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-24_09,2023-05-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=826 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305240120 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=mathbern@qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 @quicinc.com) X-ZM-MESSAGEID: 1684939371655100002 Content-Type: text/plain; charset="utf-8" Many Hexagon python scripts call hex_common.get_tagregs(), but only one call site use the full reg structure given by this function. To make the code cleaner, let's make get_tagregs() filter out the unused fields (i.e. 'toss' and 'numregs'), properly removed the unused variables at the call sites. The hex_common.bad_register() function is also adjusted to work exclusively with 'regtype' and 'regid' args. For the single call site that does use toss/numregs, we provide an optional parameter to get_tagregs() which will restore the old full behavior. Suggested-by: Taylor Simpson Signed-off-by: Matheus Tavares Bernardino Reviewed-by: Taylor Simpson Tested-by: Taylor Simpson --- target/hexagon/gen_analyze_funcs.py | 10 +++--- target/hexagon/gen_helper_funcs.py | 30 ++++++++-------- target/hexagon/gen_helper_protos.py | 22 ++++++------ target/hexagon/gen_idef_parser_funcs.py | 4 +-- target/hexagon/gen_op_regs.py | 4 +-- target/hexagon/gen_tcg_funcs.py | 46 ++++++++++++------------- target/hexagon/hex_common.py | 24 ++++++------- 7 files changed, 70 insertions(+), 70 deletions(-) diff --git a/target/hexagon/gen_analyze_funcs.py b/target/hexagon/gen_analy= ze_funcs.py index 00868cc6cb..c3b521abef 100755 --- a/target/hexagon/gen_analyze_funcs.py +++ b/target/hexagon/gen_analyze_funcs.py @@ -165,7 +165,7 @@ def analyze_opn_new(f, tag, regtype, regid, regno): hex_common.bad_register(regtype, regid) =20 =20 -def analyze_opn(f, tag, regtype, regid, toss, numregs, i): +def analyze_opn(f, tag, regtype, regid, i): if hex_common.is_pair(regid): analyze_opn_old(f, tag, regtype, regid, i) elif hex_common.is_single(regid): @@ -174,9 +174,9 @@ def analyze_opn(f, tag, regtype, regid, toss, numregs, = i): elif hex_common.is_new_val(regtype, regid, tag): analyze_opn_new(f, tag, regtype, regid, i) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 ## @@ -202,8 +202,8 @@ def gen_analyze_func(f, tag, regs, imms): =20 i =3D 0 ## Analyze all the registers - for regtype, regid, toss, numregs in regs: - analyze_opn(f, tag, regtype, regid, toss, numregs, i) + for regtype, regid in regs: + analyze_opn(f, tag, regtype, regid, i) i +=3D 1 =20 has_generated_helper =3D not hex_common.skip_qemu_helper( diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper= _funcs.py index e80550f94e..ce21d3b688 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -87,9 +87,9 @@ def gen_helper_arg_opn(f, regtype, regid, i, tag): elif hex_common.is_new_val(regtype, regid, tag): gen_helper_arg_new(f, regtype, regid, i) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 def gen_helper_arg_imm(f, immlett): @@ -135,7 +135,7 @@ def gen_helper_dest_decl_opn(f, regtype, regid, i): else: gen_helper_dest_decl(f, regtype, regid, i) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 def gen_helper_src_var_ext(f, regtype, regid): @@ -185,7 +185,7 @@ def gen_helper_return_opn(f, regtype, regid, i): else: gen_helper_return(f, regtype, regid, i) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 ## @@ -208,7 +208,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): numresults =3D 0 numscalarresults =3D 0 numscalarreadwrite =3D 0 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): numresults +=3D 1 if hex_common.is_scalar_reg(regtype): @@ -226,7 +226,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): ## The return type of the function is the type of the destination ## register (if scalar) i =3D 0 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): if hex_common.is_pair(regid): if hex_common.is_hvx_reg(regtype): @@ -239,7 +239,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): else: gen_helper_return_type(f, regtype, regid, i) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) i +=3D 1 =20 if numscalarresults =3D=3D 0: @@ -248,7 +248,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): =20 ## Arguments include the vector destination operands i =3D 1 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): if hex_common.is_pair(regid): if hex_common.is_hvx_reg(regtype): @@ -262,12 +262,12 @@ def gen_helper_function(f, tag, tagregs, tagimms): # This is the return value of the function continue else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) i +=3D 1 =20 ## For conditional instructions, we pass in the destination regist= er if "A_CONDEXEC" in hex_common.attribdict[tag]: - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_writeonly(regid) and not hex_common.is_hv= x_reg( regtype ): @@ -275,7 +275,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): i +=3D 1 =20 ## Arguments to the helper function are the source regs and immedi= ates - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_read(regid): if hex_common.is_hvx_reg(regtype) and hex_common.is_readwr= ite(regid): continue @@ -315,12 +315,12 @@ def gen_helper_function(f, tag, tagregs, tagimms): ## Declare the return variable i =3D 0 if "A_CONDEXEC" not in hex_common.attribdict[tag]: - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_writeonly(regid): gen_helper_dest_decl_opn(f, regtype, regid, i) i +=3D 1 =20 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_read(regid): if hex_common.is_pair(regid): if hex_common.is_hvx_reg(regtype): @@ -329,7 +329,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): if hex_common.is_hvx_reg(regtype): gen_helper_src_var_ext(f, regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 if hex_common.need_slot(tag): if "A_LOAD" in hex_common.attribdict[tag]: @@ -345,7 +345,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): f.write(" arch_fpop_end(env);\n") =20 ## Save/return the return variable - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): gen_helper_return_opn(f, regtype, regid, i) f.write("}\n\n") diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helpe= r_protos.py index 3dedd76cb4..131043795a 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -46,13 +46,13 @@ } =20 =20 -def gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i): +def gen_def_helper_opn(f, tag, regtype, regid, i): if hex_common.is_pair(regid): f.write(f", {def_helper_types_pair[regtype]}") elif hex_common.is_single(regid): f.write(f", {def_helper_types[regtype]}") else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 ## @@ -68,7 +68,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): numresults =3D 0 numscalarresults =3D 0 numscalarreadwrite =3D 0 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): numresults +=3D 1 if hex_common.is_scalar_reg(regtype): @@ -124,10 +124,10 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): ## - Emit the scalar result ## - Emit the vector result i =3D 0 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): if not hex_common.is_hvx_reg(regtype): - gen_def_helper_opn(f, tag, regtype, regid, toss, numre= gs, i) + gen_def_helper_opn(f, tag, regtype, regid, i) i +=3D 1 =20 ## Put the env between the outputs and inputs @@ -135,27 +135,27 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): i +=3D 1 =20 # Second pass - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): if hex_common.is_hvx_reg(regtype): - gen_def_helper_opn(f, tag, regtype, regid, toss, numre= gs, i) + gen_def_helper_opn(f, tag, regtype, regid, i) i +=3D 1 =20 ## For conditional instructions, we pass in the destination regist= er if "A_CONDEXEC" in hex_common.attribdict[tag]: - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_writeonly(regid) and not hex_common.is_hv= x_reg( regtype ): - gen_def_helper_opn(f, tag, regtype, regid, toss, numre= gs, i) + gen_def_helper_opn(f, tag, regtype, regid, i) i +=3D 1 =20 ## Generate the qemu type for each input operand (regs and immedia= tes) - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_read(regid): if hex_common.is_hvx_reg(regtype) and hex_common.is_readwr= ite(regid): continue - gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, = i) + gen_def_helper_opn(f, tag, regtype, regid, i) i +=3D 1 for immlett, bits, immshift in imms: f.write(", s32") diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_i= def_parser_funcs.py index 29160fcb1d..f4518e653f 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -131,7 +131,7 @@ def main(): imms =3D tagimms[tag] =20 arguments =3D [] - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: prefix =3D "in " if hex_common.is_read(regid) else "" =20 is_pair =3D hex_common.is_pair(regid) @@ -147,7 +147,7 @@ def main(): elif is_single_new: arguments.append(f"{prefix}{regtype}{regid}N") else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 for immlett, bits, immshift in imms: arguments.append(hex_common.imm_name(immlett)) diff --git a/target/hexagon/gen_op_regs.py b/target/hexagon/gen_op_regs.py index 42972c7f9e..a8a7712129 100755 --- a/target/hexagon/gen_op_regs.py +++ b/target/hexagon/gen_op_regs.py @@ -70,7 +70,7 @@ def strip_reg_prefix(x): def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) - tagregs =3D hex_common.get_tagregs() + tagregs =3D hex_common.get_tagregs(full=3DTrue) tagimms =3D hex_common.get_tagimms() =20 with open(sys.argv[3], "w") as f: @@ -79,7 +79,7 @@ def main(): rregs =3D [] wregs =3D [] regids =3D "" - for regtype, regid, toss, numregs in regs: + for regtype, regid, _, numregs in regs: if hex_common.is_read(regid): if regid[0] not in regids: regids +=3D regid[0] diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs= .py index c73467b840..fe29d83d4d 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -223,7 +223,7 @@ def genptr_decl_new(f, tag, regtype, regid, regno): hex_common.bad_register(regtype, regid) =20 =20 -def genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i): +def genptr_decl_opn(f, tag, regtype, regid, i): if hex_common.is_pair(regid): genptr_decl(f, tag, regtype, regid, i) elif hex_common.is_single(regid): @@ -232,9 +232,9 @@ def genptr_decl_opn(f, tag, regtype, regid, toss, numre= gs, i): elif hex_common.is_new_val(regtype, regid, tag): genptr_decl_new(f, tag, regtype, regid, i) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 def genptr_decl_imm(f, immlett): @@ -354,12 +354,12 @@ def genptr_src_read_opn(f, regtype, regid, tag): elif hex_common.is_new_val(regtype, regid, tag): genptr_src_read_new(f, regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 -def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i): +def gen_helper_call_opn(f, tag, regtype, regid, i): if i > 0: f.write(", ") if hex_common.is_pair(regid): @@ -370,9 +370,9 @@ def gen_helper_call_opn(f, tag, regtype, regid, toss, n= umregs, i): elif hex_common.is_new_val(regtype, regid, tag): f.write(f"{regtype}{regid}N") else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 def gen_helper_decl_imm(f, immlett): @@ -468,7 +468,7 @@ def genptr_dst_write_opn(f, regtype, regid, tag): else: genptr_dst_write(f, tag, regtype, regid) else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 =20 ## @@ -502,8 +502,8 @@ def gen_tcg_func(f, tag, regs, imms): gen_decl_ea_tcg(f, tag) i =3D 0 ## Declare all the operands (regs and immediates) - for regtype, regid, toss, numregs in regs: - genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i) + for regtype, regid in regs: + genptr_decl_opn(f, tag, regtype, regid, i) i +=3D 1 for immlett, bits, immshift in imms: genptr_decl_imm(f, immlett) @@ -514,14 +514,14 @@ def gen_tcg_func(f, tag, regs, imms): f.write(" fCHECKFORGUEST();\n") =20 ## Read all the inputs - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_read(regid): genptr_src_read_opn(f, regtype, regid, tag) =20 if hex_common.is_idef_parser_enabled(tag): declared =3D [] ## Handle registers - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_pair(regid) or ( hex_common.is_single(regid) and hex_common.is_old_val(regtype, regid, tag) @@ -532,7 +532,7 @@ def gen_tcg_func(f, tag, regs, imms): elif hex_common.is_new_val(regtype, regid, tag): declared.append(f"{regtype}{regid}N") else: - hex_common.bad_register(regtype, regid, toss, numregs) + hex_common.bad_register(regtype, regid) =20 ## Handle immediates for immlett, bits, immshift in imms: @@ -564,11 +564,11 @@ def gen_tcg_func(f, tag, regs, imms): f.write(f" gen_helper_{tag}(") i =3D 0 ## If there is a scalar result, it is the return type - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): if hex_common.is_hvx_reg(regtype): continue - gen_helper_call_opn(f, tag, regtype, regid, toss, numregs,= i) + gen_helper_call_opn(f, tag, regtype, regid, i) i +=3D 1 if i > 0: f.write(", ") @@ -576,23 +576,23 @@ def gen_tcg_func(f, tag, regs, imms): i =3D 1 ## For conditional instructions, we pass in the destination regist= er if "A_CONDEXEC" in hex_common.attribdict[tag]: - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_writeonly(regid) and not hex_common.is_hv= x_reg( regtype ): - gen_helper_call_opn(f, tag, regtype, regid, toss, numr= egs, i) + gen_helper_call_opn(f, tag, regtype, regid, i) i +=3D 1 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): if not hex_common.is_hvx_reg(regtype): continue - gen_helper_call_opn(f, tag, regtype, regid, toss, numregs,= i) + gen_helper_call_opn(f, tag, regtype, regid, i) i +=3D 1 - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_read(regid): if hex_common.is_hvx_reg(regtype) and hex_common.is_readwr= ite(regid): continue - gen_helper_call_opn(f, tag, regtype, regid, toss, numregs,= i) + gen_helper_call_opn(f, tag, regtype, regid, i) i +=3D 1 for immlett, bits, immshift in imms: gen_helper_call_imm(f, immlett) @@ -612,7 +612,7 @@ def gen_tcg_func(f, tag, regs, imms): f.write(");\n") =20 ## Write all the outputs - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if hex_common.is_written(regid): genptr_dst_write_opn(f, regtype, regid, tag) =20 diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index f3aac55db0..dce1b852a7 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -30,9 +30,8 @@ overrides =3D {} # tags with helper overrides idef_parser_enabled =3D {} # tags enabled for idef-parser =20 -def bad_register(*args): - args_str =3D ", ".join(map(str, args)) - raise Exception(f"Bad register parse: {args_str}") +def bad_register(regtype, regid): + raise Exception(f"Bad register parse: regtype '{regtype}' regid '{regi= d}'") =20 # We should do this as a hash for performance, # but to keep order let's keep it as a list. @@ -124,7 +123,7 @@ def calculate_attribs(): tagregs =3D get_tagregs() for tag in tags: regs =3D tagregs[tag] - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if regtype =3D=3D "P" and is_written(regid): attribdict[tag].add("A_WRITES_PRED_REG") # Mark conditional jumps and calls @@ -170,10 +169,11 @@ def MACROATTRIB(macname, beh, attribstring): attribs =3D [] macros[macname] =3D Macro(macname, beh, attribs) =20 - -def compute_tag_regs(tag): - return uniquify(regre.findall(behdict[tag])) - +def compute_tag_regs(tag, full): + tagregs =3D regre.findall(behdict[tag]) + if not full: + tagregs =3D map(lambda reg: reg[:2], tagregs) + return uniquify(tagregs) =20 def compute_tag_immediates(tag): return uniquify(immre.findall(behdict[tag])) @@ -200,9 +200,9 @@ def compute_tag_immediates(tag): ## x, y read-write register ## xx, yy read-write register pair ## -def get_tagregs(): - return dict(zip(tags, list(map(compute_tag_regs, tags)))) - +def get_tagregs(full=3DFalse): + compute_func =3D lambda tag: compute_tag_regs(tag, full) + return dict(zip(tags, list(map(compute_func, tags)))) =20 def get_tagimms(): return dict(zip(tags, list(map(compute_tag_immediates, tags)))) @@ -285,7 +285,7 @@ def need_pkt_need_commit(tag): =20 def need_condexec_reg(tag, regs): if "A_CONDEXEC" in attribdict[tag]: - for regtype, regid, toss, numregs in regs: + for regtype, regid in regs: if is_writeonly(regid) and not is_hvx_reg(regtype): return True return False --=20 2.37.2 From nobody Sun May 19 07:11:58 2024 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=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1684939346; cv=none; d=zohomail.com; s=zohoarc; b=lFpdjZtlOhu3tFdzN30C1JjMyzxn/lAsekPhQp7Y76DC/yq13Cvh8f+QkyphmKk+niOlTKQjEiJHTaP3dkD0PqLkhRjfIC1xdP2Du3CDkQ0jRKaHlOSvKZ+W5Y/ONjmKtmA7NA2CdCv14LvBdow30hu01J+3syPLwtcPxlffFLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684939346; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LyMUZewBARAdqxQ2wrazrfhfVR30f4zG1AFUvyUSQ2k=; b=d7slkoB2ng1y3U9uU/+rutUIhGWkmSQdMUh3x1XfPzHYO62wNc4oZjR4Rv3F0mSqoCg4ATE0BSEdWhNF9DxxKhGz/H5zJ0MEv+cvzQkTrDjFWdd/IdfYluiEzoAvn0UstSCZBtgaN14imcI23l75WkUjp0Rs/ANp+ow613zd094= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684939346761516.6686308916715; Wed, 24 May 2023 07:42:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1pgc-0001RR-4q; Wed, 24 May 2023 10:41:58 -0400 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 1q1pga-0001Qm-D6 for qemu-devel@nongnu.org; Wed, 24 May 2023 10:41:56 -0400 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 1q1pgX-0000d5-U6 for qemu-devel@nongnu.org; Wed, 24 May 2023 10:41:56 -0400 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34OCdSoR032308 for ; Wed, 24 May 2023 14:41:52 GMT Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qs05sas5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 24 May 2023 14:41:51 +0000 Received: from pps.filterd (NALASPPMTA04.qualcomm.com [127.0.0.1]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 34OEfo3l026643 for ; Wed, 24 May 2023 14:41:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 3qpq9m0pr2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 24 May 2023 14:41:50 +0000 Received: from NALASPPMTA04.qualcomm.com (NALASPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34OEfogx026633 for ; Wed, 24 May 2023 14:41:50 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-mathbern-lv.qualcomm.com [10.47.235.147]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 34OEfno6026629 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 14:41:50 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 4229910) id D4357744B; Wed, 24 May 2023 11:41:49 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=qcppdkim1; bh=LyMUZewBARAdqxQ2wrazrfhfVR30f4zG1AFUvyUSQ2k=; b=i1BnkRRfPEJhXIPB2pVMf2H3E/OjVn/5655okR+FCTvKn1zXi7J87iC10Cq6f1m6FAlj aHs0RPSSTxRl03YvDX3LKyyD+tTUYt72mojZMI8OTjhYifLuIrn1nswAdLG4Resz1DK9 sYLg10sTly/7ZAAOntoe+w3WKFLaUBAagtU5gXgFw3QBiXxzNUB86lUA1QzxuGz92I7i lyvNvkBhrfFpIf1uAl0GtLi1MbQx7RyI0lKIq6tmLpJRKv6Zu7xVtcWmBP9V9lARQBl5 sF5B7WmCfbRLYbWFinEEYZ6Y4QMFi7mfQbLNmHjzoUNCM/prLBlw/IYfdHrFRvAUklcZ 3g== From: Matheus Tavares Bernardino To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, bcain@quicinc.com, quic_mliebel@quicinc.com Subject: [PATCH v2 2/2] Hexagon: fix outdated `hex_new_*` comments Date: Wed, 24 May 2023 11:41:48 -0300 Message-Id: <8e1689e28dd7b1318369b55127cf47b82ab75921.1684939078.git.quic_mathbern@quicinc.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: uSVlFXvvVXGNG-UurvHerwr3BXgQKbXa X-Proofpoint-ORIG-GUID: uSVlFXvvVXGNG-UurvHerwr3BXgQKbXa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-24_09,2023-05-24_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 clxscore=1015 bulkscore=0 mlxlogscore=621 priorityscore=1501 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305240120 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=mathbern@qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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 @quicinc.com) X-ZM-MESSAGEID: 1684939354409100001 Content-Type: text/plain; charset="utf-8" Some code comments refer to hex_new_value and hex_new_pred_value, which have been transferred to DisasContext and, in the case of hex_new_value, should now be accessed through get_result_gpr(). In order to fix this outdated comments and also avoid having to tweak them whenever we make a variable name change in the future, let's replace them with pseudocode. Suggested-by: Taylor Simpson Signed-off-by: Matheus Tavares Bernardino Reviewed-by: Taylor Simpson --- target/hexagon/genptr.c | 26 ++++++++++++-------------- target/hexagon/translate.c | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index cb2aa28a19..bcb287dd8b 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -878,9 +878,9 @@ static void gen_endloop0(DisasContext *ctx) */ if (!ctx->is_tight_loop) { /* - * if (hex_gpr[HEX_REG_LC0] > 1) { - * PC =3D hex_gpr[HEX_REG_SA0]; - * hex_new_value[HEX_REG_LC0] =3D hex_gpr[HEX_REG_LC0] - 1; + * if (LC0 > 1) { + * PC =3D SA0; + * LC0--; * } */ TCGLabel *label3 =3D gen_new_label(); @@ -897,9 +897,9 @@ static void gen_endloop0(DisasContext *ctx) static void gen_endloop1(DisasContext *ctx) { /* - * if (hex_gpr[HEX_REG_LC1] > 1) { - * PC =3D hex_gpr[HEX_REG_SA1]; - * hex_new_value[HEX_REG_LC1] =3D hex_gpr[HEX_REG_LC1] - 1; + * if (LC1 > 1) { + * PC =3D SA1; + * LC1--; * } */ TCGLabel *label =3D gen_new_label(); @@ -946,14 +946,12 @@ static void gen_endloop01(DisasContext *ctx) gen_set_label(label2); =20 /* - * if (hex_gpr[HEX_REG_LC0] > 1) { - * PC =3D hex_gpr[HEX_REG_SA0]; - * hex_new_value[HEX_REG_LC0] =3D hex_gpr[HEX_REG_LC0] - 1; - * } else { - * if (hex_gpr[HEX_REG_LC1] > 1) { - * hex_next_pc =3D hex_gpr[HEX_REG_SA1]; - * hex_new_value[HEX_REG_LC1] =3D hex_gpr[HEX_REG_LC1] - 1; - * } + * if (LC0 > 1) { + * PC =3D SA0; + * LC0--; + * } else if (LC1 > 1) { + * PC =3D SA1; + * LC1--; * } */ tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3); diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index b18f1a9051..8838ab2364 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -556,7 +556,7 @@ static void gen_start_packet(DisasContext *ctx) } =20 /* - * Preload the predicated pred registers into hex_new_pred_value[pred_= num] + * Preload the predicated pred registers into ctx->new_pred_value[pred= _num] * Only endloop instructions conditionally write to pred registers */ if (ctx->need_commit && pkt->pkt_has_endloop) { --=20 2.37.2