From nobody Fri May 17 10:13:45 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=1681961370; cv=none; d=zohomail.com; s=zohoarc; b=BKik9oZHv0NcjND35LH4kyPTXCd5/vgcFLF9ylAAxH62CkgKc03CraTNA4KJZy5JWuW7cvNEwjGUEQ6RfynH2ibeNXc0pf8bLxJnDtn3i2rFP4FNu/kHUGe48bIQ+lDvh0NTpcTAnl7SRGW4OrLi0Knuq7JcTlNyi6u9+sZucVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961370; h=Content-Type: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=IULUecdqOUMqOfBRqIM011h7Ehuy3VYgmfShtqRTYUE=; b=MJoHxOgwL96G3RcwqO9w7igidR71IDjs6xZD0XruDt7AQJCSvjSR4ZG8wE1c5LYDlG/gUbIGk/h0Zal4rnNYIUXnRfN+A4iF19tGNqQF98eOAkTp6fKeCqjdxn55QtdZ0EcO2DisQQ1jdYBWOD4dfHl8GjvAs5fllpDrZQWRN5M= 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 1681961370607740.787990912207; Wed, 19 Apr 2023 20:29:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKws-0003hT-JK; Wed, 19 Apr 2023 23:27:06 -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 1ppKwl-0003g2-6I for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:59 -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 1ppKwh-0000Ic-A8 for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -0400 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K2WsWE031210; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2hd9hnvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +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 33K3Qm9f018913; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 3pyn0mktbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +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 33K3QlTn018897; Thu, 20 Apr 2023 03:26:47 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 33K3Qlca018896 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id EFB433CB; Wed, 19 Apr 2023 20:26:46 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=IULUecdqOUMqOfBRqIM011h7Ehuy3VYgmfShtqRTYUE=; b=QIOMUyVb+ZAZUN4yYVk9F3OL6VXSM4ED6uUfbAQ2UKtuB7YysMRtfIdQuk1h028U4NPZ u8zwCcrYUJXeMPOAg/UiJSIM1yvyNnt/E2BrV+6D0PsBUEkX596eArJOk7pAbxlwJqCx gcXropqTxjCkQFPSi42NX7XM51b5UwQ4l120dHSkMZQmjveVeoFiddimxb4yHWDmBR3e Bf6CBVDbZOIs30uixeoVoBd8ybzrDiDu6FA4nGihXxjScj8BBMcs4v+2/+Xj/zNwmXv5 F0JxuJOsgMd9K5ExM0rMulCf8MaMGM0mAZlMqbRVNpB9aTet70fIZrg3auOGa1yVhD32 LQ== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 01/11] Hexagon (translate.c): avoid redundant PC updates on COF Date: Wed, 19 Apr 2023 20:26:24 -0700 Message-Id: <20230420032634.105311-2-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 3yHZ35793RKaviVXaSSUxYeAGxZH-K30 X-Proofpoint-ORIG-GUID: 3yHZ35793RKaviVXaSSUxYeAGxZH-K30 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=850 phishscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961371403100003 From: Matheus Tavares Bernardino When there is a conditional change of flow or an endloop instruction, we preload HEX_REG_PC with ctx->next_PC at gen_start_packet(). Nonetheless, we still generate TCG code to do this update again at gen_goto_tb() when the condition for the COF is not met, thus producing redundant instructions. This can be seen with the following packet: 0x004002e4: 0x5c20d000 { if (!P0) jump:t PC+0 } Which generates this TCG code: ---- 004002e4 -> mov_i32 pc,$0x4002e8 and_i32 loc9,p0,$0x1 mov_i32 branch_taken,loc9 add_i32 pkt_cnt,pkt_cnt,$0x2 add_i32 insn_cnt,insn_cnt,$0x2 brcond_i32 branch_taken,$0x0,ne,$L1 goto_tb $0x0 mov_i32 pc,$0x4002e4 exit_tb $0x7fb0c36e5200 set_label $L1 goto_tb $0x1 -> mov_i32 pc,$0x4002e8 exit_tb $0x7fb0c36e5201 set_label $L0 exit_tb $0x7fb0c36e5203 Note that even after optimizations, the redundant PC update is still present: ---- 004002e4 -> mov_i32 pc,$0x4002e8 sync: 0 dead: 0 1 pref=3D0xff= ff mov_i32 branch_taken,$0x1 sync: 0 dead: 0 1 pref=3D0xff= ff add_i32 pkt_cnt,pkt_cnt,$0x2 sync: 0 dead: 0 1 pref=3D0xff= ff add_i32 insn_cnt,insn_cnt,$0x2 sync: 0 dead: 0 1 2 pref=3D0x= ffff goto_tb $0x1 -> mov_i32 pc,$0x4002e8 sync: 0 dead: 0 1 pref=3D0xff= ff exit_tb $0x7fb0c36e5201 set_label $L0 exit_tb $0x7fb0c36e5203 With this patch, the second redundant update is properly discarded. Note that we need the additional "move_to_pc" flag instead of just avoiding the update whenever `dest =3D=3D ctx->next_PC`, as that could potentially skip updates from a COF with met condition, whose ctx->branch_dest just happens to be equal to ctx->next_PC. Signed-off-by: Matheus Tavares Bernardino Signed-off-by: Taylor Simpson Reviewed-by: Anton Johansson Reviewed-by: Taylor Simpson Message-Id: --- target/hexagon/translate.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 665476ab48..58d638f734 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -128,14 +128,19 @@ static bool use_goto_tb(DisasContext *ctx, target_ulo= ng dest) return translator_use_goto_tb(&ctx->base, dest); } =20 -static void gen_goto_tb(DisasContext *ctx, int idx, target_ulong dest) +static void gen_goto_tb(DisasContext *ctx, int idx, target_ulong dest, bool + move_to_pc) { if (use_goto_tb(ctx, dest)) { tcg_gen_goto_tb(idx); - tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest); + if (move_to_pc) { + tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest); + } tcg_gen_exit_tb(ctx->base.tb, idx); } else { - tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest); + if (move_to_pc) { + tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest); + } tcg_gen_lookup_and_goto_ptr(); } } @@ -150,11 +155,11 @@ static void gen_end_tb(DisasContext *ctx) if (ctx->branch_cond !=3D TCG_COND_ALWAYS) { TCGLabel *skip =3D gen_new_label(); tcg_gen_brcondi_tl(ctx->branch_cond, hex_branch_taken, 0, skip= ); - gen_goto_tb(ctx, 0, ctx->branch_dest); + gen_goto_tb(ctx, 0, ctx->branch_dest, true); gen_set_label(skip); - gen_goto_tb(ctx, 1, ctx->next_PC); + gen_goto_tb(ctx, 1, ctx->next_PC, false); } else { - gen_goto_tb(ctx, 0, ctx->branch_dest); + gen_goto_tb(ctx, 0, ctx->branch_dest, true); } } else if (ctx->is_tight_loop && pkt->insn[pkt->num_insns - 1].opcode =3D=3D J2_endloop0) { @@ -165,9 +170,9 @@ static void gen_end_tb(DisasContext *ctx) TCGLabel *skip =3D gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, skip); tcg_gen_subi_tl(hex_gpr[HEX_REG_LC0], hex_gpr[HEX_REG_LC0], 1); - gen_goto_tb(ctx, 0, ctx->base.tb->pc); + gen_goto_tb(ctx, 0, ctx->base.tb->pc, true); gen_set_label(skip); - gen_goto_tb(ctx, 1, ctx->next_PC); + gen_goto_tb(ctx, 1, ctx->next_PC, false); } else { tcg_gen_lookup_and_goto_ptr(); } --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961328; cv=none; d=zohomail.com; s=zohoarc; b=FGK8GL5C43r5bpJ17ZkaPVoTnjMIdahMFeDFbKOqxDMA6ZQdpltM1lCilZq39/JgCS9Y9UDlLPraex4leT4+wF3lLO9/GUfrYFotcEhZ4LiSMH71lkXt3LD+K6Z8J/fPV2cCdb1vdG9xLA8Iak4HTSXe0eZ2txu0LQEDzYod7Lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961328; h=Content-Type: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=g+DaXN5Ch1rxVDQcxtmuXj0sd98Wu6+pTgA8TTWS+c4=; b=LQKba+GfKhjNLeMIHk1tWI2Z13hTKO7FP+51nckbHqZl9GTcnY1WNahwYB1MmE4JCiIPagUWpsXlIlemk62E8jRkSv3QBT6ov1JlsQxZauhoF048yQohBh9SMAxDMwKoDEuN8viu+ZBWsz9jszz50U0eIHq1q4/qDczY9KFqis4= 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 1681961328015938.2697158506775; Wed, 19 Apr 2023 20:28:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwv-0003jN-AE; Wed, 19 Apr 2023 23:27:09 -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 1ppKwr-0003h0-UX for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:27:05 -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 1ppKwh-0000If-AW for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:27:01 -0400 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K0xNMQ006641; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2hd9hnvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: from pps.filterd (NALASPPMTA05.qualcomm.com [127.0.0.1]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3Qlrr021081; Thu, 20 Apr 2023 03:26:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 3q2e95vg1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: from NALASPPMTA05.qualcomm.com (NALASPPMTA05.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3Qln2021073; Thu, 20 Apr 2023 03:26:47 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 33K3QlN8021069 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id F297A687; Wed, 19 Apr 2023 20:26:46 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=g+DaXN5Ch1rxVDQcxtmuXj0sd98Wu6+pTgA8TTWS+c4=; b=bl5UQBzcmvJsNoAITdvMC3qp2NjN/UALjzYUKbi2WEPrq1ASZRqqfJZ3r705ppd8B3wU CDVvH0eV2tXooGoX5+w8rNZCV8iDQG7fkKio2JkTdEpuhQKTncrPu80HJaApKt4y7kFJ eY+PAIAE4g1tnYij7VPZ95GkrVFBZe2irAURFxXFlgsn5mE+sHmgZRg7t3Y64/33l9lv 2w20alFDOmI+96f1uFoc3Rzrrb+tEeDrtTDGw4g9d5CgHV7IzGb7UvTs4zRvyZv075KM hRsucEWQoeNpSzlfe7ehOUzfY1uk1eX84CVs2i4fRPO3DE1rSxCoHqerPMYjbrphPQ/W Mw== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 02/11] Use f-strings in python scripts Date: Wed, 19 Apr 2023 20:26:25 -0700 Message-Id: <20230420032634.105311-3-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: e4rix0Uq6AuAbUH9kjX1Q2qODP6rnQgN X-Proofpoint-ORIG-GUID: e4rix0Uq6AuAbUH9kjX1Q2qODP6rnQgN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=840 phishscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961328337100001 From: Marco Liebel Replace python 2 format string with f-strings Signed-off-by: Marco Liebel Signed-off-by: Taylor Simpson Reviewed-by: Taylor Simpson Tested-by: Taylor Simpson Message-Id: <20230320092533.2859433-2-quic_mliebel@quicinc.com> --- target/hexagon/gen_analyze_funcs.py | 115 ++++----- target/hexagon/gen_helper_funcs.py | 54 ++-- target/hexagon/gen_helper_protos.py | 10 +- target/hexagon/gen_idef_parser_funcs.py | 10 +- target/hexagon/gen_op_attribs.py | 6 +- target/hexagon/gen_op_regs.py | 12 +- target/hexagon/gen_opcodes_def.py | 4 +- target/hexagon/gen_printinsn.py | 16 +- target/hexagon/gen_shortcode.py | 4 +- target/hexagon/gen_tcg_func_table.py | 4 +- target/hexagon/gen_tcg_funcs.py | 317 +++++++++++------------- target/hexagon/hex_common.py | 4 +- 12 files changed, 250 insertions(+), 306 deletions(-) diff --git a/target/hexagon/gen_analyze_funcs.py b/target/hexagon/gen_analy= ze_funcs.py index ebd3e7afb9..1e246209e8 100755 --- a/target/hexagon/gen_analyze_funcs.py +++ b/target/hexagon/gen_analyze_funcs.py @@ -29,57 +29,49 @@ def is_predicated(tag): return 'A_CONDEXEC' in hex_common.attribdict[tag] =20 def analyze_opn_old(f, tag, regtype, regid, regno): - regN =3D "%s%sN" % (regtype, regid) + regN =3D f"{regtype}{regid}N" predicated =3D "true" if is_predicated(tag) else "false" if (regtype =3D=3D "R"): if (regid in {"ss", "tt"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"dd", "ee", "xx", "yy"}): - f.write(" const int %s =3D insn->regno[%d];\n" % (regN, reg= no)) - f.write(" ctx_log_reg_write_pair(ctx, %s, %s);\n" % \ - (regN, predicated)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" ctx_log_reg_write_pair(ctx, {regN}, {predicated}= );\n") elif (regid in {"s", "t", "u", "v"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"d", "e", "x", "y"}): - f.write(" const int %s =3D insn->regno[%d];\n" % (regN, reg= no)) - f.write(" ctx_log_reg_write(ctx, %s, %s);\n" % \ - (regN, predicated)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" ctx_log_reg_write(ctx, {regN}, {predicated});\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "P"): if (regid in {"s", "t", "u", "v"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"d", "e", "x"}): - f.write(" const int %s =3D insn->regno[%d];\n" % (regN, reg= no)) - f.write(" ctx_log_pred_write(ctx, %s);\n" % (regN)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" ctx_log_pred_write(ctx, {regN});\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "C"): if (regid =3D=3D "ss"): - f.write("// const int %s =3D insn->regno[%d] + HEX_REG_SA0;= \n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}] " + "+ HEX_REG_SA0;\n") elif (regid =3D=3D "dd"): - f.write(" const int %s =3D insn->regno[%d] + HEX_REG_SA0;\n= " % \ - (regN, regno)) - f.write(" ctx_log_reg_write_pair(ctx, %s, %s);\n" % \ - (regN, predicated)) + f.write(f" const int {regN} =3D insn->regno[{regno}] " + "+ HEX_REG_SA0;\n") + f.write(f" ctx_log_reg_write_pair(ctx, {regN}, {predicated}= );\n") elif (regid =3D=3D "s"): - f.write("// const int %s =3D insn->regno[%d] + HEX_REG_SA0;= \n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}] " + "+ HEX_REG_SA0;\n") elif (regid =3D=3D "d"): - f.write(" const int %s =3D insn->regno[%d] + HEX_REG_SA0;\n= " % \ - (regN, regno)) - f.write(" ctx_log_reg_write(ctx, %s, %s);\n" % \ - (regN, predicated)) + f.write(f" const int {regN} =3D insn->regno[{regno}] " + "+ HEX_REG_SA0;\n") + f.write(f" ctx_log_reg_write(ctx, {regN}, {predicated});\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "M"): if (regid =3D=3D "u"): - f.write("// const int %s =3D insn->regno[%d];\n"% \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "V"): @@ -89,84 +81,67 @@ def analyze_opn_old(f, tag, regtype, regid, regno): elif (hex_common.is_tmp_result(tag)): newv =3D "EXT_TMP" if (regid in {"dd", "xx"}): - f.write(" const int %s =3D insn->regno[%d];\n" %\ - (regN, regno)) - f.write(" ctx_log_vreg_write_pair(ctx, %s, %s, %s);\n" % \ - (regN, newv, predicated)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" ctx_log_vreg_write_pair(ctx, {regN}, {newv}, " + f"{predicated});\n") elif (regid in {"uu", "vv"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"s", "u", "v", "w"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"d", "x", "y"}): - f.write(" const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) - f.write(" ctx_log_vreg_write(ctx, %s, %s, %s);\n" % \ - (regN, newv, predicated)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" ctx_log_vreg_write(ctx, {regN}, {newv}, " + f"{predicated});\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "Q"): if (regid in {"d", "e", "x"}): - f.write(" const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) - f.write(" ctx_log_qreg_write(ctx, %s);\n" % (regN)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" ctx_log_qreg_write(ctx, {regN});\n") elif (regid in {"s", "t", "u", "v"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "G"): if (regid in {"dd"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"d"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"ss"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"s"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "S"): if (regid in {"dd"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"d"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"ss"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"s"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 def analyze_opn_new(f, tag, regtype, regid, regno): - regN =3D "%s%sN" % (regtype, regid) + regN =3D f"{regtype}{regid}N" if (regtype =3D=3D "N"): if (regid in {"s", "t"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "P"): if (regid in {"t", "u", "v"}): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "O"): if (regid =3D=3D "s"): - f.write("// const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) else: @@ -199,7 +174,7 @@ def analyze_opn(f, tag, regtype, regid, toss, numregs, = i): ## } ## def gen_analyze_func(f, tag, regs, imms): - f.write("static void analyze_%s(DisasContext *ctx)\n" %tag) + f.write(f"static void analyze_{tag}(DisasContext *ctx)\n") f.write('{\n') =20 f.write(" Insn *insn G_GNUC_UNUSED =3D ctx->insn;\n") diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper= _funcs.py index 7a224b66e6..dc67eaf716 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -38,23 +38,23 @@ def gen_helper_return_type_pair(f,regtype,regid,regno): =20 def gen_helper_arg(f,regtype,regid,regno): if regno > 0 : f.write(", " ) - f.write("int32_t %s%sV" % (regtype,regid)) + f.write(f"int32_t {regtype}{regid}V") =20 def gen_helper_arg_new(f,regtype,regid,regno): if regno >=3D 0 : f.write(", " ) - f.write("int32_t %s%sN" % (regtype,regid)) + f.write(f"int32_t {regtype}{regid}N") =20 def gen_helper_arg_pair(f,regtype,regid,regno): if regno >=3D 0 : f.write(", ") - f.write("int64_t %s%sV" % (regtype,regid)) + f.write(f"int64_t {regtype}{regid}V") =20 def gen_helper_arg_ext(f,regtype,regid,regno): if regno > 0 : f.write(", ") - f.write("void *%s%sV_void" % (regtype,regid)) + f.write(f"void *{regtype}{regid}V_void") =20 def gen_helper_arg_ext_pair(f,regtype,regid,regno): if regno > 0 : f.write(", ") - f.write("void *%s%sV_void" % (regtype,regid)) + f.write(f"void *{regtype}{regid}V_void") =20 def gen_helper_arg_opn(f,regtype,regid,i,tag): if (hex_common.is_pair(regid)): @@ -76,27 +76,25 @@ def gen_helper_arg_opn(f,regtype,regid,i,tag): print("Bad register parse: ",regtype,regid,toss,numregs) =20 def gen_helper_arg_imm(f,immlett): - f.write(", int32_t %s" % (hex_common.imm_name(immlett))) + f.write(f", int32_t {hex_common.imm_name(immlett)}") =20 def gen_helper_dest_decl(f,regtype,regid,regno,subfield=3D""): - f.write(" int32_t %s%sV%s =3D 0;\n" % \ - (regtype,regid,subfield)) + f.write(f" int32_t {regtype}{regid}V{subfield} =3D 0;\n") =20 def gen_helper_dest_decl_pair(f,regtype,regid,regno,subfield=3D""): - f.write(" int64_t %s%sV%s =3D 0;\n" % \ - (regtype,regid,subfield)) + f.write(f" int64_t {regtype}{regid}V{subfield} =3D 0;\n") =20 def gen_helper_dest_decl_ext(f,regtype,regid): if (regtype =3D=3D "Q"): - f.write(" /* %s%sV is *(MMQReg *)(%s%sV_void) */\n" % \ - (regtype,regid,regtype,regid)) + f.write(f" /* {regtype}{regid}V is *(MMQReg *)" + f"({regtype}{regid}V_void) */\n") else: - f.write(" /* %s%sV is *(MMVector *)(%s%sV_void) */\n" % \ - (regtype,regid,regtype,regid)) + f.write(f" /* {regtype}{regid}V is *(MMVector *)" + f"({regtype}{regid}V_void) */\n") =20 def gen_helper_dest_decl_ext_pair(f,regtype,regid,regno): - f.write(" /* %s%sV is *(MMVectorPair *))%s%sV_void) */\n" % \ - (regtype,regid,regtype, regid)) + f.write(f" /* {regtype}{regid}V is *(MMVectorPair *))" + f"{regtype}{regid}V_void) */\n") =20 def gen_helper_dest_decl_opn(f,regtype,regid,i): if (hex_common.is_pair(regid)): @@ -114,21 +112,21 @@ def gen_helper_dest_decl_opn(f,regtype,regid,i): =20 def gen_helper_src_var_ext(f,regtype,regid): if (regtype =3D=3D "Q"): - f.write(" /* %s%sV is *(MMQReg *)(%s%sV_void) */\n" % \ - (regtype,regid,regtype,regid)) + f.write(f" /* {regtype}{regid}V is *(MMQReg *)" + f"({regtype}{regid}V_void) */\n") else: - f.write(" /* %s%sV is *(MMVector *)(%s%sV_void) */\n" % \ - (regtype,regid,regtype,regid)) + f.write(f" /* {regtype}{regid}V is *(MMVector *)" + f"({regtype}{regid}V_void) */\n") =20 def gen_helper_src_var_ext_pair(f,regtype,regid,regno): - f.write(" /* %s%sV%s is *(MMVectorPair *)(%s%sV%s_void) */\n" % \ - (regtype,regid,regno,regtype,regid,regno)) + f.write(f" /* {regtype}{regid}V{regno} is *(MMVectorPair *)" + f"({regtype}{regid}V{regno}_void) */\n") =20 def gen_helper_return(f,regtype,regid,regno): - f.write(" return %s%sV;\n" % (regtype,regid)) + f.write(f" return {regtype}{regid}V;\n") =20 def gen_helper_return_pair(f,regtype,regid,regno): - f.write(" return %s%sV;\n" % (regtype,regid)) + f.write(f" return {regtype}{regid}V;\n") =20 def gen_helper_dst_write_ext(f,regtype,regid): return @@ -181,8 +179,8 @@ def gen_helper_function(f, tag, tagregs, tagimms): =20 if (numscalarresults > 1): ## The helper is bogus when there is more than one result - f.write("void HELPER(%s)(CPUHexagonState *env) { BOGUS_HELPER(%s);= }\n" - % (tag, tag)) + f.write(f"void HELPER({tag})(CPUHexagonState *env) " + f"{{ BOGUS_HELPER({tag}); }}\n") else: ## The return type of the function is the type of the destination ## register (if scalar) @@ -205,7 +203,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): =20 if (numscalarresults =3D=3D 0): f.write("void") - f.write(" HELPER(%s)(CPUHexagonState *env" % tag) + f.write(f" HELPER({tag})(CPUHexagonState *env") =20 ## Arguments include the vector destination operands i =3D 1 @@ -290,7 +288,7 @@ def gen_helper_function(f, tag, tagregs, tagimms): if 'A_FPOP' in hex_common.attribdict[tag]: f.write(' arch_fpop_start(env);\n'); =20 - f.write(" %s\n" % hex_common.semdict[tag]) + f.write(f" {hex_common.semdict[tag]}\n") =20 if 'A_FPOP' in hex_common.attribdict[tag]: f.write(' arch_fpop_end(env);\n'); diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helpe= r_protos.py index ddddc9e4f0..d795f32047 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -47,9 +47,9 @@ =20 def gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i): if (hex_common.is_pair(regid)): - f.write(", %s" % (def_helper_types_pair[regtype])) + f.write(f", {def_helper_types_pair[regtype]}") elif (hex_common.is_single(regid)): - f.write(", %s" % (def_helper_types[regtype])) + f.write(f", {def_helper_types[regtype]}") else: print("Bad register parse: ",regtype,regid,toss,numregs) =20 @@ -77,7 +77,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): =20 if (numscalarresults > 1): ## The helper is bogus when there is more than one result - f.write('DEF_HELPER_1(%s, void, env)\n' % tag) + f.write(f'DEF_HELPER_1({tag}, void, env)\n') else: ## Figure out how many arguments the helper will take if (numscalarresults =3D=3D 0): @@ -88,7 +88,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): if hex_common.need_PC(tag): def_helper_size +=3D 1 if hex_common.helper_needs_next_PC(tag): def_helper_size +=3D 1 if hex_common.need_condexec_reg(tag, regs): def_helper_size += =3D 1 - f.write('DEF_HELPER_%s(%s' % (def_helper_size, tag)) + f.write(f'DEF_HELPER_{def_helper_size}({tag}') ## The return type is void f.write(', void' ) else: @@ -99,7 +99,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): if hex_common.need_PC(tag): def_helper_size +=3D 1 if hex_common.need_condexec_reg(tag, regs): def_helper_size += =3D 1 if hex_common.helper_needs_next_PC(tag): def_helper_size +=3D 1 - f.write('DEF_HELPER_%s(%s' % (def_helper_size, tag)) + f.write(f'DEF_HELPER_{def_helper_size}({tag}') =20 ## Generate the qemu DEF_HELPER type for each result ## Iterate over this list twice diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_i= def_parser_funcs.py index 917753d6d8..1b1fdf9790 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2022 rev.ng Labs Srl. All Rights Reserved. +## Copyright(c) 2019-2023 rev.ng Labs Srl. All Rights Reserved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -110,20 +110,20 @@ def main(): and hex_common.is_new_val(regtype, regid,= tag)) =20 if is_pair or is_single_old: - arguments.append("%s%s%sV" % (prefix, regtype, regid)) + arguments.append(f"{prefix}{regtype}{regid}V") elif is_single_new: - arguments.append("%s%s%sN" % (prefix, regtype, regid)) + arguments.append(f"{prefix}{regtype}{regid}N") else: print("Bad register parse: ",regtype,regid,toss,numreg= s) =20 for immlett,bits,immshift in imms: arguments.append(hex_common.imm_name(immlett)) =20 - f.write("%s(%s) {\n" % (tag, ", ".join(arguments))) + f.write(f"{tag}({', '.join(arguments)}) {{\n") f.write(" "); if hex_common.need_ea(tag): f.write("size4u_t EA; "); - f.write("%s\n" % hex_common.semdict[tag]) + f.write(f"{hex_common.semdict[tag]}\n") f.write("}\n\n") =20 if __name__ =3D=3D "__main__": diff --git a/target/hexagon/gen_op_attribs.py b/target/hexagon/gen_op_attri= bs.py index 6a1a1ca21d..cf7b7f7656 100755 --- a/target/hexagon/gen_op_attribs.py +++ b/target/hexagon/gen_op_attribs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -32,8 +32,8 @@ def main(): ## with open(sys.argv[3], 'w') as f: for tag in hex_common.tags: - f.write('OP_ATTRIB(%s,ATTRIBS(%s))\n' % \ - (tag, ','.join(sorted(hex_common.attribdict[tag])))) + f.write(f'OP_ATTRIB({tag},ATTRIBS(' + f'{",".join(sorted(hex_common.attribdict[tag]))}))\n') =20 if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_op_regs.py b/target/hexagon/gen_op_regs.py index e8137d4a12..c0de9ad380 100755 --- a/target/hexagon/gen_op_regs.py +++ b/target/hexagon/gen_op_regs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -85,25 +85,25 @@ def main(): if hex_common.attribinfo[attrib]['wreg']: wregs.append(strip_reg_prefix(attribinfo[attrib]['wreg= '])) regids +=3D calculate_regid_letters(tag) - f.write('REGINFO(%s,"%s",\t/*RD:*/\t"%s",\t/*WR:*/\t"%s")\n' %= \ - (tag,regids,",".join(rregs),",".join(wregs))) + f.write(f'REGINFO({tag},"{regids}",\t/*RD:*/\t"{",".join(rregs= )}",' + f'\t/*WR:*/\t"{",".join(wregs)}")\n') =20 for tag in hex_common.tags: imms =3D tagimms[tag] - f.write( 'IMMINFO(%s' % tag) + f.write(f'IMMINFO({tag}') if not imms: f.write(''','u',0,0,'U',0,0''') for sign,size,shamt in imms: if sign =3D=3D 'r': sign =3D 's' if not shamt: shamt =3D "0" - f.write(''','%s',%s,%s''' % (sign,size,shamt)) + f.write(f''','{sign}',{size},{shamt}''') if len(imms) =3D=3D 1: if sign.isupper(): myu =3D 'u' else: myu =3D 'U' - f.write(''','%s',0,0''' % myu) + f.write(f''','{myu}',0,0''') f.write(')\n') =20 if __name__ =3D=3D "__main__": diff --git a/target/hexagon/gen_opcodes_def.py b/target/hexagon/gen_opcodes= _def.py index fa604a8db9..5eebc16898 100755 --- a/target/hexagon/gen_opcodes_def.py +++ b/target/hexagon/gen_opcodes_def.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ def main(): ## with open(sys.argv[3], 'w') as f: for tag in hex_common.tags: - f.write ( "OPCODE(%s),\n" % (tag) ) + f.write(f"OPCODE({tag}),\n") =20 if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_printinsn.py b/target/hexagon/gen_printinsn= .py index 12737bf8a0..4ec8dcabb0 100755 --- a/target/hexagon/gen_printinsn.py +++ b/target/hexagon/gen_printinsn.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -119,7 +119,7 @@ def main(): if ("A_VECX" in hex_common.attribdict[tag]): macname =3D "DEF_VECX_PRINTINFO" else: macname =3D "DEF_PRINTINFO" - f.write('%s(%s,"%s%%s"' % (macname,tag,beh)) + f.write(f'{macname}({tag},"{beh}%s"') regs_or_imms =3D \ hex_common.reg_or_immre.findall(hex_common.behdict[tag]) ri =3D 0 @@ -132,14 +132,14 @@ def main(): else: regno =3D ri if len(b) =3D=3D 1: - f.write(', insn->regno[%d]' % regno) + f.write(f', insn->regno[{regno}]') if 'S' in a: - f.write(', sreg2str(insn->regno[%d])' % regno) + f.write(f', sreg2str(insn->regno[{regno}])') elif 'C' in a: - f.write(', creg2str(insn->regno[%d])' % regno) + f.write(f', creg2str(insn->regno[{regno}])') elif len(b) =3D=3D 2: - f.write(', insn->regno[%d] + 1, insn->regno[%d]' %= \ - (regno,regno)) + f.write(f', insn->regno[{regno}] + 1' + f', insn->regno[{regno}]') else: print("Put some stuff to handle quads here") if b not in seenregs: @@ -165,7 +165,7 @@ def main(): else: f.write(',""') ii =3D 0 - f.write(', insn->immed[%d]' % ii) + f.write(f', insn->immed[{ii}]') # append empty string so there is at least one more arg f.write(',"")\n') =20 diff --git a/target/hexagon/gen_shortcode.py b/target/hexagon/gen_shortcode= .py index 9b589d0189..9a093a8902 100755 --- a/target/hexagon/gen_shortcode.py +++ b/target/hexagon/gen_shortcode.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import hex_common =20 def gen_shortcode(f, tag): - f.write('DEF_SHORTCODE(%s, %s)\n' % (tag, hex_common.semdict[tag])) + f.write(f'DEF_SHORTCODE({tag}, {hex_common.semdict[tag]})\n') =20 def main(): hex_common.read_semantics_file(sys.argv[1]) diff --git a/target/hexagon/gen_tcg_func_table.py b/target/hexagon/gen_tcg_= func_table.py index 4809d3273e..8319daf96a 100755 --- a/target/hexagon/gen_tcg_func_table.py +++ b/target/hexagon/gen_tcg_func_table.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ def main(): if ( tag =3D=3D "Y6_diag1" ) : continue =20 - f.write(" [%s] =3D generate_%s,\n" % (tag, tag)) + f.write(f" [{tag}] =3D generate_{tag},\n") f.write("};\n\n") =20 f.write("#endif /* HEXAGON_FUNC_TABLE_H */\n") diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs= .py index fa93e185ce..285b3abe3a 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -29,170 +29,151 @@ def gen_decl_ea_tcg(f, tag): f.write(" TCGv EA G_GNUC_UNUSED =3D tcg_temp_new();\n") =20 def genptr_decl_pair_writable(f, tag, regtype, regid, regno): - regN=3D"%s%sN" % (regtype,regid) + regN=3Df"{regtype}{regid}N" if (regtype =3D=3D "R"): - f.write(" const int %s =3D insn->regno[%d];\n" % (regN, regno)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") elif (regtype =3D=3D "C"): - f.write(" const int %s =3D insn->regno[%d] + HEX_REG_SA0;\n" % \ - (regN, regno)) + f.write(f" const int {regN} =3D insn->regno[{regno}] + HEX_REG_= SA0;\n") else: print("Bad register parse: ", regtype, regid) - f.write(" TCGv_i64 %s%sV =3D get_result_gpr_pair(ctx, %s);\n" % \ - (regtype, regid, regN)) + f.write(f" TCGv_i64 {regtype}{regid}V =3D " + f"get_result_gpr_pair(ctx, {regN});\n") =20 def genptr_decl_writable(f, tag, regtype, regid, regno): - regN=3D"%s%sN" % (regtype,regid) + regN=3Df"{regtype}{regid}N" if (regtype =3D=3D "R"): - f.write(" const int %s =3D insn->regno[%d];\n" % (regN, regno)) - f.write(" TCGv %s%sV =3D get_result_gpr(ctx, %s);\n" % \ - (regtype, regid, regN)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" TCGv {regtype}{regid}V =3D get_result_gpr(ctx, {regN= });\n") elif (regtype =3D=3D "C"): - f.write(" const int %s =3D insn->regno[%d] + HEX_REG_SA0;\n" % \ - (regN, regno)) - f.write(" TCGv %s%sV =3D get_result_gpr(ctx, %s);\n" % \ - (regtype, regid, regN)) + f.write(f" const int {regN} =3D insn->regno[{regno}] + HEX_REG_= SA0;\n") + f.write(f" TCGv {regtype}{regid}V =3D get_result_gpr(ctx, {regN= });\n") elif (regtype =3D=3D "P"): - f.write(" const int %s =3D insn->regno[%d];\n" % (regN, regno)) - f.write(" TCGv %s%sV =3D tcg_temp_new();\n" % \ - (regtype, regid)) + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") + f.write(f" TCGv {regtype}{regid}V =3D tcg_temp_new();\n") else: print("Bad register parse: ", regtype, regid) =20 def genptr_decl(f, tag, regtype, regid, regno): - regN=3D"%s%sN" % (regtype,regid) + regN=3Df"{regtype}{regid}N" if (regtype =3D=3D "R"): if (regid in {"ss", "tt"}): - f.write(" TCGv_i64 %s%sV =3D tcg_temp_new_i64();\n" % \ - (regtype, regid)) - f.write(" const int %s =3D insn->regno[%d];\n" % \ - (regN, regno)) + f.write(f" TCGv_i64 {regtype}{regid}V =3D tcg_temp_new_i64(= );\n") + f.write(f" const int {regN} =3D insn->regno[{regno}];\n") elif (regid in {"dd", "ee", "xx", "yy"}): genptr_decl_pair_writable(f, tag, regtype, regid, regno) elif (regid in {"s", "t", "u", "v"}): - f.write(" TCGv %s%sV =3D hex_gpr[insn->regno[%d]];\n" % \ - (regtype, regid, regno)) + f.write(f" TCGv {regtype}{regid}V =3D " + f"hex_gpr[insn->regno[{regno}]];\n") elif (regid in {"d", "e", "x", "y"}): genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "P"): if (regid in {"s", "t", "u", "v"}): - f.write(" TCGv %s%sV =3D hex_pred[insn->regno[%d]];\n" % \ - (regtype, regid, regno)) + f.write(f" TCGv {regtype}{regid}V =3D " + f"hex_pred[insn->regno[{regno}]];\n") elif (regid in {"d", "e", "x"}): genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "C"): if (regid =3D=3D "ss"): - f.write(" TCGv_i64 %s%sV =3D tcg_temp_new_i64();\n" % \ - (regtype, regid)) - f.write(" const int %s =3D insn->regno[%d] + HEX_REG_SA0;\n= " % \ - (regN, regno)) + f.write(f" TCGv_i64 {regtype}{regid}V =3D " + f"tcg_temp_new_i64();\n") + f.write(f" const int {regN} =3D insn->regno[{regno}] + " + "HEX_REG_SA0;\n") elif (regid =3D=3D "dd"): genptr_decl_pair_writable(f, tag, regtype, regid, regno) elif (regid =3D=3D "s"): - f.write(" TCGv %s%sV =3D tcg_temp_new();\n" % \ - (regtype, regid)) - f.write(" const int %s%sN =3D insn->regno[%d] + HEX_REG_SA0= ;\n" % \ - (regtype, regid, regno)) + f.write(f" TCGv {regtype}{regid}V =3D tcg_temp_new();\n") + f.write(f" const int {regtype}{regid}N =3D insn->regno[{reg= no}] + " + "HEX_REG_SA0;\n") elif (regid =3D=3D "d"): genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "M"): if (regid =3D=3D "u"): - f.write(" const int %s%sN =3D insn->regno[%d];\n"% \ - (regtype, regid, regno)) - f.write(" TCGv %s%sV =3D hex_gpr[%s%sN + HEX_REG_M0];\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" TCGv {regtype}{regid}V =3D hex_gpr[{regtype}{reg= id}N + " + "HEX_REG_M0];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "V"): if (regid in {"dd"}): - f.write(" const int %s%sN =3D insn->regno[%d];\n" %\ - (regtype, regid, regno)) - f.write(" const intptr_t %s%sV_off =3D\n" %\ - (regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") if (hex_common.is_tmp_result(tag)): - f.write(" ctx_tmp_vreg_off(ctx, %s%sN, 2, true);\n"= % \ - (regtype, regid)) + f.write(f" ctx_tmp_vreg_off(ctx, {regtype}{regid}N,= 2, " + "true);\n") else: - f.write(" ctx_future_vreg_off(ctx, %s%sN," % \ - (regtype, regid)) + f.write(f" ctx_future_vreg_off(ctx, {regtype}{regid= }N,") f.write(" 2, true);\n") if (not hex_common.skip_qemu_helper(tag)): - f.write(" TCGv_ptr %s%sV =3D tcg_temp_new_ptr();\n" % \ - (regtype, regid)) - f.write(" tcg_gen_addi_ptr(%s%sV, cpu_env, %s%sV_off);\= n" % \ - (regtype, regid, regtype, regid)) + f.write(f" TCGv_ptr {regtype}{regid}V =3D " + "tcg_temp_new_ptr();\n") + f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " + f"{regtype}{regid}V_off);\n") elif (regid in {"uu", "vv", "xx"}): - f.write(" const int %s%sN =3D insn->regno[%d];\n" % \ - (regtype, regid, regno)) - f.write(" const intptr_t %s%sV_off =3D\n" % \ - (regtype, regid)) - f.write(" offsetof(CPUHexagonState, %s%sV);\n" % \ - (regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") + f.write(f" offsetof(CPUHexagonState, {regtype}{regid}V)= ;\n") if (not hex_common.skip_qemu_helper(tag)): - f.write(" TCGv_ptr %s%sV =3D tcg_temp_new_ptr();\n" % \ - (regtype, regid)) - f.write(" tcg_gen_addi_ptr(%s%sV, cpu_env, %s%sV_off);\= n" % \ - (regtype, regid, regtype, regid)) + f.write(f" TCGv_ptr {regtype}{regid}V =3D " + "tcg_temp_new_ptr();\n") + f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " + f"{regtype}{regid}V_off);\n") elif (regid in {"s", "u", "v", "w"}): - f.write(" const int %s%sN =3D insn->regno[%d];\n" % \ - (regtype, regid, regno)) - f.write(" const intptr_t %s%sV_off =3D\n" % \ - (regtype, regid)) - f.write(" vreg_src_off(ctx, %s%sN);\n" % \ - (regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") + f.write(f" vreg_src_off(ctx, {regtype}{regid}N);\n") if (not hex_common.skip_qemu_helper(tag)): - f.write(" TCGv_ptr %s%sV =3D tcg_temp_new_ptr();\n" % \ - (regtype, regid)) + f.write(f" TCGv_ptr {regtype}{regid}V =3D " + "tcg_temp_new_ptr();\n") elif (regid in {"d", "x", "y"}): - f.write(" const int %s%sN =3D insn->regno[%d];\n" % \ - (regtype, regid, regno)) - f.write(" const intptr_t %s%sV_off =3D\n" % \ - (regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") if (regid =3D=3D "y"): f.write(" offsetof(CPUHexagonState, vtmp);\n") elif (hex_common.is_tmp_result(tag)): - f.write(" ctx_tmp_vreg_off(ctx, %s%sN, 1, true);\n"= % \ - (regtype, regid)) + f.write(f" ctx_tmp_vreg_off(ctx, {regtype}{regid}N,= 1, " + "true);\n") else: - f.write(" ctx_future_vreg_off(ctx, %s%sN," % \ - (regtype, regid)) + f.write(f" ctx_future_vreg_off(ctx, {regtype}{regid= }N,") f.write(" 1, true);\n"); =20 if (not hex_common.skip_qemu_helper(tag)): - f.write(" TCGv_ptr %s%sV =3D tcg_temp_new_ptr();\n" % \ - (regtype, regid)) - f.write(" tcg_gen_addi_ptr(%s%sV, cpu_env, %s%sV_off);\= n" % \ - (regtype, regid, regtype, regid)) + f.write(f" TCGv_ptr {regtype}{regid}V =3D " + "tcg_temp_new_ptr();\n") + f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " + f"{regtype}{regid}V_off);\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "Q"): if (regid in {"d", "e", "x"}): - f.write(" const int %s%sN =3D insn->regno[%d];\n" % \ - (regtype, regid, regno)) - f.write(" const intptr_t %s%sV_off =3D\n" % \ - (regtype, regid)) - f.write(" get_result_qreg(ctx, %s%sN);\n" % \ - (regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") + f.write(f" get_result_qreg(ctx, {regtype}{regid}N);\n") if (not hex_common.skip_qemu_helper(tag)): - f.write(" TCGv_ptr %s%sV =3D tcg_temp_new_ptr();\n" % \ - (regtype, regid)) - f.write(" tcg_gen_addi_ptr(%s%sV, cpu_env, %s%sV_off);\= n" % \ - (regtype, regid, regtype, regid)) + f.write(f" TCGv_ptr {regtype}{regid}V =3D " + "tcg_temp_new_ptr();\n") + f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " + f"{regtype}{regid}V_off);\n") elif (regid in {"s", "t", "u", "v"}): - f.write(" const int %s%sN =3D insn->regno[%d];\n" % \ - (regtype, regid, regno)) - f.write(" const intptr_t %s%sV_off =3D\n" %\ - (regtype, regid)) - f.write(" offsetof(CPUHexagonState, QRegs[%s%sN]);\n" %= \ - (regtype, regid)) + f.write(f" const int {regtype}{regid}N =3D " + f"insn->regno[{regno}];\n") + f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") + f.write(f" offsetof(CPUHexagonState, " + f"QRegs[{regtype}{regid}N]);\n") if (not hex_common.skip_qemu_helper(tag)): - f.write(" TCGv_ptr %s%sV =3D tcg_temp_new_ptr();\n" % \ - (regtype, regid)) + f.write(f" TCGv_ptr {regtype}{regid}V =3D " + "tcg_temp_new_ptr();\n") else: print("Bad register parse: ", regtype, regid) else: @@ -201,29 +182,28 @@ def genptr_decl(f, tag, regtype, regid, regno): def genptr_decl_new(f, tag, regtype, regid, regno): if (regtype =3D=3D "N"): if (regid in {"s", "t"}): - f.write(" TCGv %s%sN =3D hex_new_value[insn->regno[%d]];\n"= % \ - (regtype, regid, regno)) + f.write(f" TCGv {regtype}{regid}N =3D " + f"hex_new_value[insn->regno[{regno}]];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "P"): if (regid in {"t", "u", "v"}): - f.write(" TCGv %s%sN =3D hex_new_pred_value[insn->regno[%d]= ];\n" % \ - (regtype, regid, regno)) + f.write(f" TCGv {regtype}{regid}N =3D " + f"hex_new_pred_value[insn->regno[{regno}]];\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "O"): if (regid =3D=3D "s"): - f.write(" const intptr_t %s%sN_num =3D insn->regno[%d];\n" = % \ - (regtype, regid, regno)) + f.write(f" const intptr_t {regtype}{regid}N_num =3D " + f"insn->regno[{regno}];\n") if (hex_common.skip_qemu_helper(tag)): - f.write(" const intptr_t %s%sN_off =3D\n" % \ - (regtype, regid)) - f.write(" ctx_future_vreg_off(ctx, %s%sN_num," % \ - (regtype, regid)) + f.write(f" const intptr_t {regtype}{regid}N_off =3D\n") + f.write(" ctx_future_vreg_off(ctx, " + f"{regtype}{regid}N_num,") f.write(" 1, true);\n") else: - f.write(" TCGv %s%sN =3D tcg_constant_tl(%s%sN_num);\n"= % \ - (regtype, regid, regtype, regid)) + f.write(f" TCGv {regtype}{regid}N =3D " + f"tcg_constant_tl({regtype}{regid}N_num);\n") else: print("Bad register parse: ", regtype, regid) else: @@ -247,38 +227,37 @@ def genptr_decl_imm(f,immlett): i =3D 1 else: i =3D 0 - f.write(" int %s =3D insn->immed[%d];\n" % \ - (hex_common.imm_name(immlett), i)) + f.write(f" int {hex_common.imm_name(immlett)} =3D insn->immed[{i}];= \n") =20 def genptr_src_read(f, tag, regtype, regid): if (regtype =3D=3D "R"): if (regid in {"ss", "tt", "xx", "yy"}): - f.write(" tcg_gen_concat_i32_i64(%s%sV, hex_gpr[%s%sN],\n" = % \ - (regtype, regid, regtype, regid)) - f.write(" hex_gpr[%s%sN + 1]);= \n" % \ - (regtype, regid)) + f.write(f" tcg_gen_concat_i32_i64({regtype}{regid}V, " + f"hex_gpr[{regtype}{regid}N],\n") + f.write(f" hex_gpr[{regtype}" + f"{regid}N + 1]);\n") elif (regid in {"x", "y"}): ## For read/write registers, we need to get the original value= into ## the result TCGv. For conditional instructions, this is don= e in ## gen_start_packet. For unconditional instructions, we do it= here. if ('A_CONDEXEC' not in hex_common.attribdict[tag]): - f.write(" tcg_gen_mov_tl(%s%sV, hex_gpr[%s%sN]);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" tcg_gen_mov_tl({regtype}{regid}V, " + f"hex_gpr[{regtype}{regid}N]);\n") elif (regid not in {"s", "t", "u", "v"}): print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "P"): if (regid =3D=3D "x"): - f.write(" tcg_gen_mov_tl(%s%sV, hex_pred[%s%sN]);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" tcg_gen_mov_tl({regtype}{regid}V, " + f"hex_pred[{regtype}{regid}N]);\n") elif (regid not in {"s", "t", "u", "v"}): print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "C"): if (regid =3D=3D "ss"): - f.write(" gen_read_ctrl_reg_pair(ctx, %s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_read_ctrl_reg_pair(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n") elif (regid =3D=3D "s"): - f.write(" gen_read_ctrl_reg(ctx, %s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_read_ctrl_reg(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "M"): @@ -286,39 +265,32 @@ def genptr_src_read(f, tag, regtype, regid): print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "V"): if (regid in {"uu", "vv", "xx"}): - f.write(" tcg_gen_gvec_mov(MO_64, %s%sV_off,\n" % \ - (regtype, regid)) - f.write(" vreg_src_off(ctx, %s%sN),\n" % \ - (regtype, regid)) + f.write(f" tcg_gen_gvec_mov(MO_64, {regtype}{regid}V_off,\n= ") + f.write(f" vreg_src_off(ctx, {regtype}{regid}N),\n") f.write(" sizeof(MMVector), sizeof(MMVector));\n") f.write(" tcg_gen_gvec_mov(MO_64,\n") - f.write(" %s%sV_off + sizeof(MMVector),\n" % \ - (regtype, regid)) - f.write(" vreg_src_off(ctx, %s%sN ^ 1),\n" % \ - (regtype, regid)) + f.write(f" {regtype}{regid}V_off + sizeof(MMVector),\n") + f.write(f" vreg_src_off(ctx, {regtype}{regid}N ^ 1),\n") f.write(" sizeof(MMVector), sizeof(MMVector));\n") elif (regid in {"s", "u", "v", "w"}): if (not hex_common.skip_qemu_helper(tag)): - f.write(" tcg_gen_addi_ptr(%s%sV, cpu_env, %s%sV_off);\= n" % \ - (regtype, regid, regtype, regid)) + f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " + f"{regtype}{regid}V_off);\n") elif (regid in {"x", "y"}): - f.write(" tcg_gen_gvec_mov(MO_64, %s%sV_off,\n" % \ - (regtype, regid)) - f.write(" vreg_src_off(ctx, %s%sN),\n" % \ - (regtype, regid)) + f.write(f" tcg_gen_gvec_mov(MO_64, {regtype}{regid}V_off,\n= ") + f.write(f" vreg_src_off(ctx, {regtype}{regid}N),\n") f.write(" sizeof(MMVector), sizeof(MMVector));\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "Q"): if (regid in {"s", "t", "u", "v"}): if (not hex_common.skip_qemu_helper(tag)): - f.write(" tcg_gen_addi_ptr(%s%sV, cpu_env, %s%sV_off);\= n" % \ - (regtype, regid, regtype, regid)) + f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " + f"{regtype}{regid}V_off);\n") elif (regid in {"x"}): - f.write(" tcg_gen_gvec_mov(MO_64, %s%sV_off,\n" % \ - (regtype, regid)) - f.write(" offsetof(CPUHexagonState, QRegs[%s%sN]),\n" %= \ - (regtype, regid)) + f.write(f" tcg_gen_gvec_mov(MO_64, {regtype}{regid}V_off,\n= ") + f.write(f" offsetof(CPUHexagonState, " + f"QRegs[{regtype}{regid}N]),\n") f.write(" sizeof(MMQReg), sizeof(MMQReg));\n") else: print("Bad register parse: ", regtype, regid) @@ -354,50 +326,50 @@ def genptr_src_read_opn(f,regtype,regid,tag): def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i): if (i > 0): f.write(", ") if (hex_common.is_pair(regid)): - f.write("%s%sV" % (regtype,regid)) + f.write(f"{regtype}{regid}V") elif (hex_common.is_single(regid)): if hex_common.is_old_val(regtype, regid, tag): - f.write("%s%sV" % (regtype,regid)) + f.write(f"{regtype}{regid}V") elif hex_common.is_new_val(regtype, regid, tag): - f.write("%s%sN" % (regtype,regid)) + f.write(f"{regtype}{regid}N") else: print("Bad register parse: ",regtype,regid,toss,numregs) else: print("Bad register parse: ",regtype,regid,toss,numregs) =20 def gen_helper_decl_imm(f,immlett): - f.write(" TCGv tcgv_%s =3D tcg_constant_tl(%s);\n" % \ - (hex_common.imm_name(immlett), hex_common.imm_name(immlett))) + f.write(f" TCGv tcgv_{hex_common.imm_name(immlett)} =3D " + f"tcg_constant_tl({hex_common.imm_name(immlett)});\n") =20 def gen_helper_call_imm(f,immlett): - f.write(", tcgv_%s" % hex_common.imm_name(immlett)) + f.write(f", tcgv_{hex_common.imm_name(immlett)}") =20 def genptr_dst_write_pair(f, tag, regtype, regid): - f.write(" gen_log_reg_write_pair(%s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_log_reg_write_pair({regtype}{regid}N, " + f"{regtype}{regid}V);\n") =20 def genptr_dst_write(f, tag, regtype, regid): if (regtype =3D=3D "R"): if (regid in {"dd", "xx", "yy"}): genptr_dst_write_pair(f, tag, regtype, regid) elif (regid in {"d", "e", "x", "y"}): - f.write(" gen_log_reg_write(%s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_log_reg_write({regtype}{regid}N, " + f"{regtype}{regid}V);\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "P"): if (regid in {"d", "e", "x"}): - f.write(" gen_log_pred_write(ctx, %s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_log_pred_write(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n") else: print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "C"): if (regid =3D=3D "dd"): - f.write(" gen_write_ctrl_reg_pair(ctx, %s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_write_ctrl_reg_pair(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n") elif (regid =3D=3D "d"): - f.write(" gen_write_ctrl_reg(ctx, %s%sN, %s%sV);\n" % \ - (regtype, regid, regtype, regid)) + f.write(f" gen_write_ctrl_reg(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n") else: print("Bad register parse: ", regtype, regid) else: @@ -406,17 +378,16 @@ def genptr_dst_write(f, tag, regtype, regid): def genptr_dst_write_ext(f, tag, regtype, regid, newv=3D"EXT_DFL"): if (regtype =3D=3D "V"): if (regid in {"xx"}): - f.write(" gen_log_vreg_write_pair(ctx, %s%sV_off, %s%sN, " = % \ - (regtype, regid, regtype, regid)) - f.write("%s);\n" % \ - (newv)) + f.write(f" gen_log_vreg_write_pair(ctx, {regtype}{regid}V_o= ff, " + f"{regtype}{regid}N, {newv});\n") elif (regid in {"y"}): - f.write(" gen_log_vreg_write(ctx, %s%sV_off, %s%sN, %s);\n"= % \ - (regtype, regid, regtype, regid, newv)) + f.write(f" gen_log_vreg_write(ctx, {regtype}{regid}V_off, " + f"{regtype}{regid}N, {newv});\n") elif (regid not in {"dd", "d", "x"}): print("Bad register parse: ", regtype, regid) elif (regtype =3D=3D "Q"): if (regid not in {"d", "e", "x"}): + print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) @@ -465,7 +436,7 @@ def genptr_dst_write_opn(f,regtype, regid, tag): ## is gen_helper_A2_add(RdV, cpu_env, RsV, RtV); ## def gen_tcg_func(f, tag, regs, imms): - f.write("static void generate_%s(DisasContext *ctx)\n" %tag) + f.write(f"static void generate_{tag}(DisasContext *ctx)\n") f.write('{\n') =20 f.write(" Insn *insn __attribute__((unused)) =3D ctx->insn;\n") @@ -496,11 +467,11 @@ def gen_tcg_func(f, tag, regs, imms): if (hex_common.is_pair(regid) or (hex_common.is_single(regid) and hex_common.is_old_val(regtype, regid, tag))): - declared.append("%s%sV" % (regtype, regid)) + declared.append(f"{regtype}{regid}V") if regtype =3D=3D "M": - declared.append("%s%sN" % (regtype, regid)) + declared.append(f"{regtype}{regid}N") elif hex_common.is_new_val(regtype, regid, tag): - declared.append("%s%sN" % (regtype,regid)) + declared.append(f"{regtype}{regid}N") else: print("Bad register parse: ",regtype,regid,toss,numregs) =20 @@ -509,10 +480,10 @@ def gen_tcg_func(f, tag, regs, imms): declared.append(hex_common.imm_name(immlett)) =20 arguments =3D ", ".join(["ctx", "ctx->insn", "ctx->pkt"] + declare= d) - f.write(" emit_%s(%s);\n" % (tag, arguments)) + f.write(f" emit_{tag}({arguments});\n") =20 elif ( hex_common.skip_qemu_helper(tag) ): - f.write(" fGEN_TCG_%s(%s);\n" % (tag, hex_common.semdict[tag])) + f.write(f" fGEN_TCG_{tag}({hex_common.semdict[tag]});\n") else: ## Generate the call to the helper for immlett,bits,immshift in imms: @@ -528,7 +499,7 @@ def gen_tcg_func(f, tag, regs, imms): f.write(" TCGv PC =3D tcg_constant_tl(ctx->pkt->pc);\n") if hex_common.helper_needs_next_PC(tag): f.write(" TCGv next_PC =3D tcg_constant_tl(ctx->next_PC);\n= ") - f.write(" gen_helper_%s(" % (tag)) + f.write(f" gen_helper_{tag}(") i=3D0 ## If there is a scalar result, it is the return type for regtype,regid,toss,numregs in regs: diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index 0200a66cb6..9f9da81e20 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -55,7 +55,7 @@ def expand_macro_attribs(macro,allmac_re): for submacro in l: if not submacro: continue if not macros[submacro]: - raise Exception("Couldn't find macro: <%s>" % l) + raise Exception(f"Couldn't find macro: <{l}>") macro.attribs |=3D expand_macro_attribs( macros[submacro], allmac_re) finished_macros.add(macro.key) @@ -258,7 +258,7 @@ def is_idef_parser_enabled(tag): return tag in idef_parser_enabled =20 def imm_name(immlett): - return "%siV" % immlett + return f"{immlett}iV" =20 def read_semantics_file(name): eval_line =3D "" --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961323; cv=none; d=zohomail.com; s=zohoarc; b=I53kdSpbsOLtEK8grtJiKqj/Ly8u4nG0QpJMvljCoKWrafRssz8N7ibxFTfVbXG3ozM7PXtntVQM7/t7d2lbsP6Dl4Q+GBbAKMrcUQiv+fnu0jrIK67/eV8gxFhiDCZu4eNHm0fo2L+QXRoWGxMXJR8oXwFx9y55UQXi3ixWIVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961323; h=Content-Type: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=fOizwT7JTSTThDvv9YTjm2JysdLV+EOrOyZtJxnkp3o=; b=PZF+DOltaIum+BN7ZDfyRT4udisq+X0bdl6DiL7hQCWspGRLwSLJWZRupul64zzz90SUnhAeXiHxVtQKXvBP4c7Ki7Lh0VJqIBpaGpjgN9wcX3GzWTvX5yoP0pjneF4Rqrc/1sg5tHEZB3ToMKXLa5nJttOqkSiqU7uUgl4Wxhw= 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 1681961323422918.7277833870198; Wed, 19 Apr 2023 20:28:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKx0-0003lg-L1; Wed, 19 Apr 2023 23:27:14 -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 1ppKwv-0003jO-GG for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:27:09 -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 1ppKwn-0000Ir-T2 for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:27:09 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K3Obam017286; Thu, 20 Apr 2023 03:26:50 GMT Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2ryq0eqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +0000 Received: from pps.filterd (NALASPPMTA03.qualcomm.com [127.0.0.1]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3Qllp006570; Thu, 20 Apr 2023 03:26:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 3pyn0mbucd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: from NALASPPMTA03.qualcomm.com (NALASPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3QljY006561; Thu, 20 Apr 2023 03:26:47 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 33K3Ql3F006551 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 01C3868D; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=fOizwT7JTSTThDvv9YTjm2JysdLV+EOrOyZtJxnkp3o=; b=SZ+HLlcYIir9VmgOB6PfoXJF2/UAt0DpsjKPJNfXizyDGAg0eJVhNznQtYr/hX5ijFma BoBgvtACHeMmpbJg+NupcYvJoRQXM5N6neYMi7v/sxSxUSY41FfuCdW4upyN5l2mgmfZ jYx5FRoRtyUskSf+3oWpoi+V16+2M82HkfRvMMixlTQEtXxatDfLBJNv4En1933UEUTC +NKvbj22pT8UTy0WkQH5S3VoWH82GsJIoihTuBYzwVXXBkPulJ2IazopMBubQFc6vxut 0zOEktZhuQoRNTAo2vjZKN/WpxbDq0pA5AaE+47pvMLmNIllmyu2UiikLMaJvLRkKuEm 4A== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 03/11] Use black code style for python scripts Date: Wed, 19 Apr 2023 20:26:26 -0700 Message-Id: <20230420032634.105311-4-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: b38_T59RHT94HV05UGN_OnOJLkUzL6Vf X-Proofpoint-GUID: b38_T59RHT94HV05UGN_OnOJLkUzL6Vf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961325214100003 From: Marco Liebel Signed-off-by: Marco Liebel Signed-off-by: Taylor Simpson Acked-by: Taylor Simpson Tested-by: Taylor Simpson Message-Id: <20230320092533.2859433-3-quic_mliebel@quicinc.com> --- target/hexagon/dectree.py | 396 ++++++++------- target/hexagon/gen_analyze_funcs.py | 135 +++--- target/hexagon/gen_helper_funcs.py | 338 +++++++------ target/hexagon/gen_helper_protos.py | 165 ++++--- target/hexagon/gen_idef_parser_funcs.py | 75 +-- target/hexagon/gen_op_attribs.py | 10 +- target/hexagon/gen_op_regs.py | 77 +-- target/hexagon/gen_opcodes_def.py | 4 +- target/hexagon/gen_printinsn.py | 80 +-- target/hexagon/gen_shortcode.py | 17 +- target/hexagon/gen_tcg_func_table.py | 14 +- target/hexagon/gen_tcg_funcs.py | 614 +++++++++++++----------- target/hexagon/hex_common.py | 177 ++++--- 13 files changed, 1191 insertions(+), 911 deletions(-) diff --git a/target/hexagon/dectree.py b/target/hexagon/dectree.py index 29467ec7d7..3b32948a04 100755 --- a/target/hexagon/dectree.py +++ b/target/hexagon/dectree.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 =20 ## -## Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. +## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -23,94 +23,109 @@ import sys import iset =20 -encs =3D {tag : ''.join(reversed(iset.iset[tag]['enc'].replace(' ', ''))) - for tag in iset.tags if iset.iset[tag]['enc'] !=3D 'MISSING ENCODING'} +encs =3D { + tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", ""))) + for tag in iset.tags + if iset.iset[tag]["enc"] !=3D "MISSING ENCODING" +} =20 -enc_classes =3D set([iset.iset[tag]['enc_class'] for tag in encs.keys()]) -subinsn_enc_classes =3D \ - set([enc_class for enc_class in enc_classes \ - if enc_class.startswith('SUBINSN_')]) -ext_enc_classes =3D \ - set([enc_class for enc_class in enc_classes \ - if enc_class not in ('NORMAL', '16BIT') and \ - not enc_class.startswith('SUBINSN_')]) +enc_classes =3D set([iset.iset[tag]["enc_class"] for tag in encs.keys()]) +subinsn_enc_classes =3D set( + [enc_class for enc_class in enc_classes if enc_class.startswith("SUBIN= SN_")] +) +ext_enc_classes =3D set( + [ + enc_class + for enc_class in enc_classes + if enc_class not in ("NORMAL", "16BIT") and not enc_class.startswi= th("SUBINSN_") + ] +) =20 try: subinsn_groupings =3D iset.subinsn_groupings except AttributeError: subinsn_groupings =3D {} =20 -for (tag, subinsn_grouping) in subinsn_groupings.items(): - encs[tag] =3D ''.join(reversed(subinsn_grouping['enc'].replace(' ', ''= ))) +for tag, subinsn_grouping in subinsn_groupings.items(): + encs[tag] =3D "".join(reversed(subinsn_grouping["enc"].replace(" ", ""= ))) =20 -dectree_normal =3D {'leaves' : set()} -dectree_16bit =3D {'leaves' : set()} -dectree_subinsn_groupings =3D {'leaves' : set()} -dectree_subinsns =3D {name : {'leaves' : set()} for name in subinsn_enc_cl= asses} -dectree_extensions =3D {name : {'leaves' : set()} for name in ext_enc_clas= ses} +dectree_normal =3D {"leaves": set()} +dectree_16bit =3D {"leaves": set()} +dectree_subinsn_groupings =3D {"leaves": set()} +dectree_subinsns =3D {name: {"leaves": set()} for name in subinsn_enc_clas= ses} +dectree_extensions =3D {name: {"leaves": set()} for name in ext_enc_classe= s} =20 for tag in encs.keys(): if tag in subinsn_groupings: - dectree_subinsn_groupings['leaves'].add(tag) + dectree_subinsn_groupings["leaves"].add(tag) continue - enc_class =3D iset.iset[tag]['enc_class'] - if enc_class.startswith('SUBINSN_'): + enc_class =3D iset.iset[tag]["enc_class"] + if enc_class.startswith("SUBINSN_"): if len(encs[tag]) !=3D 32: - encs[tag] =3D encs[tag] + '0' * (32 - len(encs[tag])) - dectree_subinsns[enc_class]['leaves'].add(tag) - elif enc_class =3D=3D '16BIT': + encs[tag] =3D encs[tag] + "0" * (32 - len(encs[tag])) + dectree_subinsns[enc_class]["leaves"].add(tag) + elif enc_class =3D=3D "16BIT": if len(encs[tag]) !=3D 16: - raise Exception('Tag "{}" has enc_class "{}" and not an encodi= ng ' + - 'width of 16 bits!'.format(tag, enc_class)) - dectree_16bit['leaves'].add(tag) + raise Exception( + 'Tag "{}" has enc_class "{}" and not an encoding ' + + "width of 16 bits!".format(tag, enc_class) + ) + dectree_16bit["leaves"].add(tag) else: if len(encs[tag]) !=3D 32: - raise Exception('Tag "{}" has enc_class "{}" and not an encodi= ng ' + - 'width of 32 bits!'.format(tag, enc_class)) - if enc_class =3D=3D 'NORMAL': - dectree_normal['leaves'].add(tag) + raise Exception( + 'Tag "{}" has enc_class "{}" and not an encoding ' + + "width of 32 bits!".format(tag, enc_class) + ) + if enc_class =3D=3D "NORMAL": + dectree_normal["leaves"].add(tag) else: - dectree_extensions[enc_class]['leaves'].add(tag) + dectree_extensions[enc_class]["leaves"].add(tag) =20 faketags =3D set() -for (tag, enc) in iset.enc_ext_spaces.items(): +for tag, enc in iset.enc_ext_spaces.items(): faketags.add(tag) - encs[tag] =3D ''.join(reversed(enc.replace(' ', ''))) - dectree_normal['leaves'].add(tag) + encs[tag] =3D "".join(reversed(enc.replace(" ", ""))) + dectree_normal["leaves"].add(tag) =20 faketags |=3D set(subinsn_groupings.keys()) =20 + def every_bit_counts(bitset): for i in range(1, len(next(iter(bitset)))): - if len(set([bits[:i] + bits[i+1:] for bits in bitset])) =3D=3D len= (bitset): + if len(set([bits[:i] + bits[i + 1 :] for bits in bitset])) =3D=3D = len(bitset): return False return True =20 + def auto_separate(node): - tags =3D node['leaves'] + tags =3D node["leaves"] if len(tags) <=3D 1: return enc_width =3D len(encs[next(iter(tags))]) - opcode_bit_for_all =3D \ - [all([encs[tag][i] in '01' \ - for tag in tags]) for i in range(enc_width)] - opcode_bit_is_0_for_all =3D \ - [opcode_bit_for_all[i] and all([encs[tag][i] =3D=3D '0' \ - for tag in tags]) for i in range(enc_width)] - opcode_bit_is_1_for_all =3D \ - [opcode_bit_for_all[i] and all([encs[tag][i] =3D=3D '1' \ - for tag in tags]) for i in range(enc_width)] - differentiator_opcode_bit =3D \ - [opcode_bit_for_all[i] and \ - not (opcode_bit_is_0_for_all[i] or \ - opcode_bit_is_1_for_all[i]) \ - for i in range(enc_width)] + opcode_bit_for_all =3D [ + all([encs[tag][i] in "01" for tag in tags]) for i in range(enc_wid= th) + ] + opcode_bit_is_0_for_all =3D [ + opcode_bit_for_all[i] and all([encs[tag][i] =3D=3D "0" for tag in = tags]) + for i in range(enc_width) + ] + opcode_bit_is_1_for_all =3D [ + opcode_bit_for_all[i] and all([encs[tag][i] =3D=3D "1" for tag in = tags]) + for i in range(enc_width) + ] + differentiator_opcode_bit =3D [ + opcode_bit_for_all[i] + and not (opcode_bit_is_0_for_all[i] or opcode_bit_is_1_for_all[i]) + for i in range(enc_width) + ] best_width =3D 0 for width in range(4, 0, -1): for lsb in range(enc_width - width, -1, -1): - bitset =3D set([encs[tag][lsb:lsb+width] for tag in tags]) - if all(differentiator_opcode_bit[lsb:lsb+width]) and \ - (len(bitset) =3D=3D len(tags) or every_bit_counts(bitset)): + bitset =3D set([encs[tag][lsb : lsb + width] for tag in tags]) + if all(differentiator_opcode_bit[lsb : lsb + width]) and ( + len(bitset) =3D=3D len(tags) or every_bit_counts(bitset) + ): best_width =3D width best_lsb =3D lsb caught_all_tags =3D len(bitset) =3D=3D len(tags) @@ -118,33 +133,37 @@ def auto_separate(node): if best_width !=3D 0: break if best_width =3D=3D 0: - raise Exception('Could not find a way to differentiate the encodin= gs ' + - 'of the following tags:\n{}'.format('\n'.join(tag= s))) + raise Exception( + "Could not find a way to differentiate the encodings " + + "of the following tags:\n{}".format("\n".join(tags)) + ) if caught_all_tags: for width in range(1, best_width): for lsb in range(enc_width - width, -1, -1): - bitset =3D set([encs[tag][lsb:lsb+width] for tag in tags]) - if all(differentiator_opcode_bit[lsb:lsb+width]) and \ - len(bitset) =3D=3D len(tags): + bitset =3D set([encs[tag][lsb : lsb + width] for tag in ta= gs]) + if all(differentiator_opcode_bit[lsb : lsb + width]) and l= en( + bitset + ) =3D=3D len(tags): best_width =3D width best_lsb =3D lsb break else: continue break - node['separator_lsb'] =3D best_lsb - node['separator_width'] =3D best_width - node['children'] =3D [] - for value in range(2 ** best_width): + node["separator_lsb"] =3D best_lsb + node["separator_width"] =3D best_width + node["children"] =3D [] + for value in range(2**best_width): child =3D {} - bits =3D ''.join(reversed('{:0{}b}'.format(value, best_width))) - child['leaves'] =3D \ - set([tag for tag in tags \ - if encs[tag][best_lsb:best_lsb+best_width] =3D=3D bits]) - node['children'].append(child) - for child in node['children']: + bits =3D "".join(reversed("{:0{}b}".format(value, best_width))) + child["leaves"] =3D set( + [tag for tag in tags if encs[tag][best_lsb : best_lsb + best_w= idth] =3D=3D bits] + ) + node["children"].append(child) + for child in node["children"]: auto_separate(child) =20 + auto_separate(dectree_normal) auto_separate(dectree_16bit) if subinsn_groupings: @@ -157,144 +176,173 @@ def auto_separate(node): for tag in faketags: del encs[tag] =20 + def table_name(parents, node): path =3D parents + [node] root =3D path[0] - tag =3D next(iter(node['leaves'])) + tag =3D next(iter(node["leaves"])) if tag in subinsn_groupings: - enc_width =3D len(subinsn_groupings[tag]['enc'].replace(' ', '')) + enc_width =3D len(subinsn_groupings[tag]["enc"].replace(" ", "")) else: - tag =3D next(iter(node['leaves'] - faketags)) + tag =3D next(iter(node["leaves"] - faketags)) enc_width =3D len(encs[tag]) - determining_bits =3D ['_'] * enc_width - for (parent, child) in zip(path[:-1], path[1:]): - lsb =3D parent['separator_lsb'] - width =3D parent['separator_width'] - value =3D parent['children'].index(child) - determining_bits[lsb:lsb+width] =3D \ - list(reversed('{:0{}b}'.format(value, width))) + determining_bits =3D ["_"] * enc_width + for parent, child in zip(path[:-1], path[1:]): + lsb =3D parent["separator_lsb"] + width =3D parent["separator_width"] + value =3D parent["children"].index(child) + determining_bits[lsb : lsb + width] =3D list( + reversed("{:0{}b}".format(value, width)) + ) if tag in subinsn_groupings: - name =3D 'DECODE_ROOT_EE' + name =3D "DECODE_ROOT_EE" else: - enc_class =3D iset.iset[tag]['enc_class'] + enc_class =3D iset.iset[tag]["enc_class"] if enc_class in ext_enc_classes: - name =3D 'DECODE_EXT_{}'.format(enc_class) + name =3D "DECODE_EXT_{}".format(enc_class) elif enc_class in subinsn_enc_classes: - name =3D 'DECODE_SUBINSN_{}'.format(enc_class) + name =3D "DECODE_SUBINSN_{}".format(enc_class) else: - name =3D 'DECODE_ROOT_{}'.format(enc_width) + name =3D "DECODE_ROOT_{}".format(enc_width) if node !=3D root: - name +=3D '_' + ''.join(reversed(determining_bits)) + name +=3D "_" + "".join(reversed(determining_bits)) return name =20 + def print_node(f, node, parents): - if len(node['leaves']) <=3D 1: + if len(node["leaves"]) <=3D 1: return name =3D table_name(parents, node) - lsb =3D node['separator_lsb'] - width =3D node['separator_width'] - print('DECODE_NEW_TABLE({},{},DECODE_SEPARATOR_BITS({},{}))'.\ - format(name, 2 ** width, lsb, width), file=3Df) - for child in node['children']: - if len(child['leaves']) =3D=3D 0: - print('INVALID()', file=3Df) - elif len(child['leaves']) =3D=3D 1: - (tag,) =3D child['leaves'] + lsb =3D node["separator_lsb"] + width =3D node["separator_width"] + print( + "DECODE_NEW_TABLE({},{},DECODE_SEPARATOR_BITS({},{}))".format( + name, 2**width, lsb, width + ), + file=3Df, + ) + for child in node["children"]: + if len(child["leaves"]) =3D=3D 0: + print("INVALID()", file=3Df) + elif len(child["leaves"]) =3D=3D 1: + (tag,) =3D child["leaves"] if tag in subinsn_groupings: - class_a =3D subinsn_groupings[tag]['class_a'] - class_b =3D subinsn_groupings[tag]['class_b'] - enc =3D subinsn_groupings[tag]['enc'].replace(' ', '') - if 'RESERVED' in tag: - print('INVALID()', file=3Df) + class_a =3D subinsn_groupings[tag]["class_a"] + class_b =3D subinsn_groupings[tag]["class_b"] + enc =3D subinsn_groupings[tag]["enc"].replace(" ", "") + if "RESERVED" in tag: + print("INVALID()", file=3Df) else: - print('SUBINSNS({},{},{},"{}")'.\ - format(tag, class_a, class_b, enc), file=3Df) + print( + 'SUBINSNS({},{},{},"{}")'.format(tag, class_a, cla= ss_b, enc), + file=3Df, + ) elif tag in iset.enc_ext_spaces: - enc =3D iset.enc_ext_spaces[tag].replace(' ', '') + enc =3D iset.enc_ext_spaces[tag].replace(" ", "") print('EXTSPACE({},"{}")'.format(tag, enc), file=3Df) else: - enc =3D ''.join(reversed(encs[tag])) + enc =3D "".join(reversed(encs[tag])) print('TERMINAL({},"{}")'.format(tag, enc), file=3Df) else: - print('TABLE_LINK({})'.format(table_name(parents + [node], chi= ld)), - file=3Df) - print('DECODE_END_TABLE({},{},DECODE_SEPARATOR_BITS({},{}))'.\ - format(name, 2 ** width, lsb, width), file=3Df) + print("TABLE_LINK({})".format(table_name(parents + [node], chi= ld)), file=3Df) + print( + "DECODE_END_TABLE({},{},DECODE_SEPARATOR_BITS({},{}))".format( + name, 2**width, lsb, width + ), + file=3Df, + ) print(file=3Df) parents.append(node) - for child in node['children']: + for child in node["children"]: print_node(f, child, parents) parents.pop() =20 + def print_tree(f, tree): print_node(f, tree, []) =20 + def print_match_info(f): for tag in sorted(encs.keys(), key=3Diset.tags.index): - enc =3D ''.join(reversed(encs[tag])) - mask =3D int(re.sub(r'[^1]', r'0', enc.replace('0', '1')), 2) - match =3D int(re.sub(r'[^01]', r'0', enc), 2) - suffix =3D '' - print('DECODE{}_MATCH_INFO({},0x{:x}U,0x{:x}U)'.\ - format(suffix, tag, mask, match), file=3Df) + enc =3D "".join(reversed(encs[tag])) + mask =3D int(re.sub(r"[^1]", r"0", enc.replace("0", "1")), 2) + match =3D int(re.sub(r"[^01]", r"0", enc), 2) + suffix =3D "" + print( + "DECODE{}_MATCH_INFO({},0x{:x}U,0x{:x}U)".format(suffix, tag, = mask, match), + file=3Df, + ) + + +regre =3D re.compile(r"((? 1: - raise Exception('Tag "{}" has split register field!'.\ - format(tag)) + raise Exception('Tag "{}" has split register field!'.forma= t(tag)) reg_enc_field =3D reg_enc_fields[0] if 2 ** len(reg_enc_field) !=3D reg_num_choices: - raise Exception('Tag "{}" has incorrect register field wid= th!'.\ - format(tag)) - print(' DECODE_REG({},{},{})'.\ - format(regno, len(reg_enc_field), enc.index(reg_enc_field)= ), - file=3Df) - if reg_type in num_registers and \ - reg_num_choices !=3D num_registers[reg_type]: - print(' DECODE_MAPPED_REG({},{})'.\ - format(regno, reg_mapping), file=3Df) + raise Exception( + 'Tag "{}" has incorrect register field width!'.format(= tag) + ) + print( + " DECODE_REG({},{},{})".format( + regno, len(reg_enc_field), enc.index(reg_enc_field) + ), + file=3Df, + ) + if reg_type in num_registers and reg_num_choices !=3D num_regi= sters[reg_type]: + print( + " DECODE_MAPPED_REG({},{})".format(regno, reg_m= apping), + file=3Df, + ) regno +=3D 1 + def implicit_register_key(reg): return implicit_registers[reg] + for reg in sorted( - set([r for r in (iset.iset[tag]['rregs'].split(',') + \ - iset.iset[tag]['wregs'].split(',')) \ - if r in implicit_registers]), key=3Dimplicit_register_= key): - print(' DECODE_IMPL_REG({},{})'.\ - format(regno, implicit_registers[reg]), file=3Df) + set( + [ + r + for r in ( + iset.iset[tag]["rregs"].split(",") + + iset.iset[tag]["wregs"].split(",") + ) + if r in implicit_registers + ] + ), + key=3Dimplicit_register_key, + ): + print( + " DECODE_IMPL_REG({},{})".format(regno, implicit_re= gisters[reg]), + file=3Df, + ) regno +=3D 1 if imms and imms[0][0].isupper(): imms =3D reversed(imms) @@ -311,41 +359,45 @@ def implicit_register_key(reg): else: imm_shift =3D 0 if imm_type.islower(): - imm_letter =3D 'i' + imm_letter =3D "i" else: - imm_letter =3D 'I' + imm_letter =3D "I" remainder =3D imm_width - for m in reversed(list(re.finditer(imm_letter + '+', enc))): + for m in reversed(list(re.finditer(imm_letter + "+", enc))): remainder -=3D m.end() - m.start() - print(' DECODE_IMM({},{},{},{})'.\ - format(immno, m.end() - m.start(), m.start(), remainde= r), - file=3Df) + print( + " DECODE_IMM({},{},{},{})".format( + immno, m.end() - m.start(), m.start(), remainder + ), + file=3Df, + ) if remainder !=3D 0: if imm[2]: - imm[2] =3D ':' + imm[2] - raise Exception('Tag "{}" has an incorrect number of ' + \ - 'encoding bits for immediate "{}"'.\ - format(tag, ''.join(imm))) - if imm_type.lower() in 'sr': - print(' DECODE_IMM_SXT({},{})'.\ - format(immno, imm_width), file=3Df) - if imm_type.lower() =3D=3D 'n': - print(' DECODE_IMM_NEG({},{})'.\ - format(immno, imm_width), file=3Df) + imm[2] =3D ":" + imm[2] + raise Exception( + 'Tag "{}" has an incorrect number of ' + + 'encoding bits for immediate "{}"'.format(tag, "".jo= in(imm)) + ) + if imm_type.lower() in "sr": + print(" DECODE_IMM_SXT({},{})".format(immno, imm_wi= dth), file=3Df) + if imm_type.lower() =3D=3D "n": + print(" DECODE_IMM_NEG({},{})".format(immno, imm_wi= dth), file=3Df) if imm_shift: - print(' DECODE_IMM_SHIFT({},{})'.\ - format(immno, imm_shift), file=3Df) - print(')', file=3Df) + print( + " DECODE_IMM_SHIFT({},{})".format(immno, imm_sh= ift), file=3Df + ) + print(")", file=3Df) + =20 -if __name__ =3D=3D '__main__': - with open(sys.argv[1], 'w') as f: +if __name__ =3D=3D "__main__": + with open(sys.argv[1], "w") as f: print_tree(f, dectree_normal) print_tree(f, dectree_16bit) if subinsn_groupings: print_tree(f, dectree_subinsn_groupings) - for (name, dectree_subinsn) in sorted(dectree_subinsns.items()): + for name, dectree_subinsn in sorted(dectree_subinsns.items()): print_tree(f, dectree_subinsn) - for (name, dectree_ext) in sorted(dectree_extensions.items()): + for name, dectree_ext in sorted(dectree_extensions.items()): print_tree(f, dectree_ext) print_match_info(f) print_op_info(f) diff --git a/target/hexagon/gen_analyze_funcs.py b/target/hexagon/gen_analy= ze_funcs.py index 1e246209e8..c74443da78 100755 --- a/target/hexagon/gen_analyze_funcs.py +++ b/target/hexagon/gen_analyze_funcs.py @@ -22,137 +22,141 @@ import string import hex_common =20 + ## ## Helpers for gen_analyze_func ## def is_predicated(tag): - return 'A_CONDEXEC' in hex_common.attribdict[tag] + return "A_CONDEXEC" in hex_common.attribdict[tag] + =20 def analyze_opn_old(f, tag, regtype, regid, regno): regN =3D f"{regtype}{regid}N" predicated =3D "true" if is_predicated(tag) else "false" - if (regtype =3D=3D "R"): - if (regid in {"ss", "tt"}): + if regtype =3D=3D "R": + if regid in {"ss", "tt"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"dd", "ee", "xx", "yy"}): + elif regid in {"dd", "ee", "xx", "yy"}: f.write(f" const int {regN} =3D insn->regno[{regno}];\n") f.write(f" ctx_log_reg_write_pair(ctx, {regN}, {predicated}= );\n") - elif (regid in {"s", "t", "u", "v"}): + elif regid in {"s", "t", "u", "v"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"d", "e", "x", "y"}): + elif regid in {"d", "e", "x", "y"}: f.write(f" const int {regN} =3D insn->regno[{regno}];\n") f.write(f" ctx_log_reg_write(ctx, {regN}, {predicated});\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid in {"s", "t", "u", "v"}): + elif regtype =3D=3D "P": + if regid in {"s", "t", "u", "v"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"d", "e", "x"}): + elif regid in {"d", "e", "x"}: f.write(f" const int {regN} =3D insn->regno[{regno}];\n") f.write(f" ctx_log_pred_write(ctx, {regN});\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "C"): - if (regid =3D=3D "ss"): - f.write(f"// const int {regN} =3D insn->regno[{regno}] " - "+ HEX_REG_SA0;\n") - elif (regid =3D=3D "dd"): - f.write(f" const int {regN} =3D insn->regno[{regno}] " - "+ HEX_REG_SA0;\n") + elif regtype =3D=3D "C": + if regid =3D=3D "ss": + f.write( + f"// const int {regN} =3D insn->regno[{regno}] " "+ HEX= _REG_SA0;\n" + ) + elif regid =3D=3D "dd": + f.write(f" const int {regN} =3D insn->regno[{regno}] " "+ H= EX_REG_SA0;\n") f.write(f" ctx_log_reg_write_pair(ctx, {regN}, {predicated}= );\n") - elif (regid =3D=3D "s"): - f.write(f"// const int {regN} =3D insn->regno[{regno}] " - "+ HEX_REG_SA0;\n") - elif (regid =3D=3D "d"): - f.write(f" const int {regN} =3D insn->regno[{regno}] " - "+ HEX_REG_SA0;\n") + elif regid =3D=3D "s": + f.write( + f"// const int {regN} =3D insn->regno[{regno}] " "+ HEX= _REG_SA0;\n" + ) + elif regid =3D=3D "d": + f.write(f" const int {regN} =3D insn->regno[{regno}] " "+ H= EX_REG_SA0;\n") f.write(f" ctx_log_reg_write(ctx, {regN}, {predicated});\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "M"): - if (regid =3D=3D "u"): + elif regtype =3D=3D "M": + if regid =3D=3D "u": f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "V"): + elif regtype =3D=3D "V": newv =3D "EXT_DFL" - if (hex_common.is_new_result(tag)): + if hex_common.is_new_result(tag): newv =3D "EXT_NEW" - elif (hex_common.is_tmp_result(tag)): + elif hex_common.is_tmp_result(tag): newv =3D "EXT_TMP" - if (regid in {"dd", "xx"}): + if regid in {"dd", "xx"}: f.write(f" const int {regN} =3D insn->regno[{regno}];\n") - f.write(f" ctx_log_vreg_write_pair(ctx, {regN}, {newv}, " - f"{predicated});\n") - elif (regid in {"uu", "vv"}): + f.write( + f" ctx_log_vreg_write_pair(ctx, {regN}, {newv}, " f"{pr= edicated});\n" + ) + elif regid in {"uu", "vv"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"s", "u", "v", "w"}): + elif regid in {"s", "u", "v", "w"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"d", "x", "y"}): + elif regid in {"d", "x", "y"}: f.write(f" const int {regN} =3D insn->regno[{regno}];\n") - f.write(f" ctx_log_vreg_write(ctx, {regN}, {newv}, " - f"{predicated});\n") + f.write(f" ctx_log_vreg_write(ctx, {regN}, {newv}, " f"{pre= dicated});\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "Q"): - if (regid in {"d", "e", "x"}): + elif regtype =3D=3D "Q": + if regid in {"d", "e", "x"}: f.write(f" const int {regN} =3D insn->regno[{regno}];\n") f.write(f" ctx_log_qreg_write(ctx, {regN});\n") - elif (regid in {"s", "t", "u", "v"}): + elif regid in {"s", "t", "u", "v"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "G"): - if (regid in {"dd"}): + elif regtype =3D=3D "G": + if regid in {"dd"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"d"}): + elif regid in {"d"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"ss"}): + elif regid in {"ss"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"s"}): + elif regid in {"s"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "S"): - if (regid in {"dd"}): + elif regtype =3D=3D "S": + if regid in {"dd"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"d"}): + elif regid in {"d"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"ss"}): + elif regid in {"ss"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"s"}): + elif regid in {"s"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 + def analyze_opn_new(f, tag, regtype, regid, regno): regN =3D f"{regtype}{regid}N" - if (regtype =3D=3D "N"): - if (regid in {"s", "t"}): + if regtype =3D=3D "N": + if regid in {"s", "t"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid in {"t", "u", "v"}): + elif regtype =3D=3D "P": + if regid in {"t", "u", "v"}: f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "O"): - if (regid =3D=3D "s"): + elif regtype =3D=3D "O": + if regid =3D=3D "s": f.write(f"// const int {regN} =3D insn->regno[{regno}];\n") else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 + def analyze_opn(f, tag, regtype, regid, toss, numregs, i): - if (hex_common.is_pair(regid)): + if hex_common.is_pair(regid): analyze_opn_old(f, tag, regtype, regid, i) - elif (hex_common.is_single(regid)): + elif hex_common.is_single(regid): if hex_common.is_old_val(regtype, regid, tag): - analyze_opn_old(f,tag, regtype, regid, i) + analyze_opn_old(f, tag, regtype, regid, i) elif hex_common.is_new_val(regtype, regid, tag): analyze_opn_new(f, tag, regtype, regid, i) else: @@ -160,6 +164,7 @@ def analyze_opn(f, tag, regtype, regid, toss, numregs, = i): else: print("Bad register parse: ", regtype, regid, toss, numregs) =20 + ## ## Generate the code to analyze the instruction ## For A2_add: Rd32=3Dadd(Rs32,Rt32), { RdV=3DRsV+RtV;} @@ -175,24 +180,25 @@ def analyze_opn(f, tag, regtype, regid, toss, numregs= , i): ## def gen_analyze_func(f, tag, regs, imms): f.write(f"static void analyze_{tag}(DisasContext *ctx)\n") - f.write('{\n') + f.write("{\n") =20 f.write(" Insn *insn G_GNUC_UNUSED =3D ctx->insn;\n") =20 - i=3D0 + i =3D 0 ## Analyze all the registers for regtype, regid, toss, numregs in regs: analyze_opn(f, tag, regtype, regid, toss, numregs, i) i +=3D 1 =20 - has_generated_helper =3D (not hex_common.skip_qemu_helper(tag) and - not hex_common.is_idef_parser_enabled(tag)) - if (has_generated_helper and - 'A_SCALAR_LOAD' in hex_common.attribdict[tag]): + has_generated_helper =3D not hex_common.skip_qemu_helper( + tag + ) and not hex_common.is_idef_parser_enabled(tag) + if has_generated_helper and "A_SCALAR_LOAD" in hex_common.attribdict[t= ag]: f.write(" ctx->need_pkt_has_store_s1 =3D true;\n") =20 f.write("}\n\n") =20 + def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) @@ -214,7 +220,7 @@ def main(): tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[-1], 'w') as f: + with open(sys.argv[-1], "w") as f: f.write("#ifndef HEXAGON_TCG_FUNCS_H\n") f.write("#define HEXAGON_TCG_FUNCS_H\n\n") =20 @@ -223,5 +229,6 @@ def main(): =20 f.write("#endif /* HEXAGON_TCG_FUNCS_H */\n") =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper= _funcs.py index dc67eaf716..c4e04508f8 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -22,131 +22,171 @@ import string import hex_common =20 + ## ## Helpers for gen_helper_function ## def gen_decl_ea(f): f.write(" uint32_t EA;\n") =20 -def gen_helper_return_type(f,regtype,regid,regno): - if regno > 1 : f.write(", ") + +def gen_helper_return_type(f, regtype, regid, regno): + if regno > 1: + f.write(", ") f.write("int32_t") =20 -def gen_helper_return_type_pair(f,regtype,regid,regno): - if regno > 1 : f.write(", ") + +def gen_helper_return_type_pair(f, regtype, regid, regno): + if regno > 1: + f.write(", ") f.write("int64_t") =20 -def gen_helper_arg(f,regtype,regid,regno): - if regno > 0 : f.write(", " ) + +def gen_helper_arg(f, regtype, regid, regno): + if regno > 0: + f.write(", ") f.write(f"int32_t {regtype}{regid}V") =20 -def gen_helper_arg_new(f,regtype,regid,regno): - if regno >=3D 0 : f.write(", " ) + +def gen_helper_arg_new(f, regtype, regid, regno): + if regno >=3D 0: + f.write(", ") f.write(f"int32_t {regtype}{regid}N") =20 -def gen_helper_arg_pair(f,regtype,regid,regno): - if regno >=3D 0 : f.write(", ") + +def gen_helper_arg_pair(f, regtype, regid, regno): + if regno >=3D 0: + f.write(", ") f.write(f"int64_t {regtype}{regid}V") =20 -def gen_helper_arg_ext(f,regtype,regid,regno): - if regno > 0 : f.write(", ") + +def gen_helper_arg_ext(f, regtype, regid, regno): + if regno > 0: + f.write(", ") f.write(f"void *{regtype}{regid}V_void") =20 -def gen_helper_arg_ext_pair(f,regtype,regid,regno): - if regno > 0 : f.write(", ") + +def gen_helper_arg_ext_pair(f, regtype, regid, regno): + if regno > 0: + f.write(", ") f.write(f"void *{regtype}{regid}V_void") =20 -def gen_helper_arg_opn(f,regtype,regid,i,tag): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_arg_ext_pair(f,regtype,regid,i) + +def gen_helper_arg_opn(f, regtype, regid, i, tag): + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_arg_ext_pair(f, regtype, regid, i) else: - gen_helper_arg_pair(f,regtype,regid,i) - elif (hex_common.is_single(regid)): + gen_helper_arg_pair(f, regtype, regid, i) + elif hex_common.is_single(regid): if hex_common.is_old_val(regtype, regid, tag): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_arg_ext(f,regtype,regid,i) + if hex_common.is_hvx_reg(regtype): + gen_helper_arg_ext(f, regtype, regid, i) else: - gen_helper_arg(f,regtype,regid,i) + gen_helper_arg(f, regtype, regid, i) elif hex_common.is_new_val(regtype, regid, tag): - gen_helper_arg_new(f,regtype,regid,i) + gen_helper_arg_new(f, regtype, regid, i) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) =20 -def gen_helper_arg_imm(f,immlett): + +def gen_helper_arg_imm(f, immlett): f.write(f", int32_t {hex_common.imm_name(immlett)}") =20 -def gen_helper_dest_decl(f,regtype,regid,regno,subfield=3D""): + +def gen_helper_dest_decl(f, regtype, regid, regno, subfield=3D""): f.write(f" int32_t {regtype}{regid}V{subfield} =3D 0;\n") =20 -def gen_helper_dest_decl_pair(f,regtype,regid,regno,subfield=3D""): + +def gen_helper_dest_decl_pair(f, regtype, regid, regno, subfield=3D""): f.write(f" int64_t {regtype}{regid}V{subfield} =3D 0;\n") =20 -def gen_helper_dest_decl_ext(f,regtype,regid): - if (regtype =3D=3D "Q"): - f.write(f" /* {regtype}{regid}V is *(MMQReg *)" - f"({regtype}{regid}V_void) */\n") + +def gen_helper_dest_decl_ext(f, regtype, regid): + if regtype =3D=3D "Q": + f.write( + f" /* {regtype}{regid}V is *(MMQReg *)" f"({regtype}{regid}= V_void) */\n" + ) else: - f.write(f" /* {regtype}{regid}V is *(MMVector *)" - f"({regtype}{regid}V_void) */\n") + f.write( + f" /* {regtype}{regid}V is *(MMVector *)" + f"({regtype}{regid}V_void) */\n" + ) + =20 -def gen_helper_dest_decl_ext_pair(f,regtype,regid,regno): - f.write(f" /* {regtype}{regid}V is *(MMVectorPair *))" - f"{regtype}{regid}V_void) */\n") +def gen_helper_dest_decl_ext_pair(f, regtype, regid, regno): + f.write( + f" /* {regtype}{regid}V is *(MMVectorPair *))" + f"{regtype}{regid}V_void) */\n" + ) =20 -def gen_helper_dest_decl_opn(f,regtype,regid,i): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_dest_decl_ext_pair(f,regtype,regid, i) + +def gen_helper_dest_decl_opn(f, regtype, regid, i): + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_dest_decl_ext_pair(f, regtype, regid, i) else: - gen_helper_dest_decl_pair(f,regtype,regid,i) - elif (hex_common.is_single(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_dest_decl_ext(f,regtype,regid) + gen_helper_dest_decl_pair(f, regtype, regid, i) + elif hex_common.is_single(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_dest_decl_ext(f, regtype, regid) else: - gen_helper_dest_decl(f,regtype,regid,i) + gen_helper_dest_decl(f, regtype, regid, i) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) + =20 -def gen_helper_src_var_ext(f,regtype,regid): - if (regtype =3D=3D "Q"): - f.write(f" /* {regtype}{regid}V is *(MMQReg *)" - f"({regtype}{regid}V_void) */\n") +def gen_helper_src_var_ext(f, regtype, regid): + if regtype =3D=3D "Q": + f.write( + f" /* {regtype}{regid}V is *(MMQReg *)" f"({regtype}{regid}= V_void) */\n" + ) else: - f.write(f" /* {regtype}{regid}V is *(MMVector *)" - f"({regtype}{regid}V_void) */\n") + f.write( + f" /* {regtype}{regid}V is *(MMVector *)" + f"({regtype}{regid}V_void) */\n" + ) + + +def gen_helper_src_var_ext_pair(f, regtype, regid, regno): + f.write( + f" /* {regtype}{regid}V{regno} is *(MMVectorPair *)" + f"({regtype}{regid}V{regno}_void) */\n" + ) =20 -def gen_helper_src_var_ext_pair(f,regtype,regid,regno): - f.write(f" /* {regtype}{regid}V{regno} is *(MMVectorPair *)" - f"({regtype}{regid}V{regno}_void) */\n") =20 -def gen_helper_return(f,regtype,regid,regno): +def gen_helper_return(f, regtype, regid, regno): f.write(f" return {regtype}{regid}V;\n") =20 -def gen_helper_return_pair(f,regtype,regid,regno): + +def gen_helper_return_pair(f, regtype, regid, regno): f.write(f" return {regtype}{regid}V;\n") =20 -def gen_helper_dst_write_ext(f,regtype,regid): + +def gen_helper_dst_write_ext(f, regtype, regid): return =20 -def gen_helper_dst_write_ext_pair(f,regtype,regid): + +def gen_helper_dst_write_ext_pair(f, regtype, regid): return =20 + def gen_helper_return_opn(f, regtype, regid, i): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_dst_write_ext_pair(f,regtype,regid) + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_dst_write_ext_pair(f, regtype, regid) else: - gen_helper_return_pair(f,regtype,regid,i) - elif (hex_common.is_single(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_dst_write_ext(f,regtype,regid) + gen_helper_return_pair(f, regtype, regid, i) + elif hex_common.is_single(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_dst_write_ext(f, regtype, regid) else: - gen_helper_return(f,regtype,regid,i) + gen_helper_return(f, regtype, regid, i) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) + =20 ## ## Generate the TCG code to call the helper @@ -168,138 +208,145 @@ def gen_helper_function(f, tag, tagregs, tagimms): numresults =3D 0 numscalarresults =3D 0 numscalarreadwrite =3D 0 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): + for regtype, regid, toss, numregs in regs: + if hex_common.is_written(regid): numresults +=3D 1 - if (hex_common.is_scalar_reg(regtype)): + if hex_common.is_scalar_reg(regtype): numscalarresults +=3D 1 - if (hex_common.is_readwrite(regid)): - if (hex_common.is_scalar_reg(regtype)): + if hex_common.is_readwrite(regid): + if hex_common.is_scalar_reg(regtype): numscalarreadwrite +=3D 1 =20 - if (numscalarresults > 1): + if numscalarresults > 1: ## The helper is bogus when there is more than one result - f.write(f"void HELPER({tag})(CPUHexagonState *env) " - f"{{ BOGUS_HELPER({tag}); }}\n") + f.write( + f"void HELPER({tag})(CPUHexagonState *env) " f"{{ BOGUS_HELPER= ({tag}); }}\n" + ) else: ## The return type of the function is the type of the destination ## register (if scalar) - i=3D0 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): + i =3D 0 + for regtype, regid, toss, numregs in regs: + if hex_common.is_written(regid): + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): continue else: - gen_helper_return_type_pair(f,regtype,regid,i) - elif (hex_common.is_single(regid)): - if (hex_common.is_hvx_reg(regtype)): - continue + gen_helper_return_type_pair(f, regtype, regid, i) + elif hex_common.is_single(regid): + if hex_common.is_hvx_reg(regtype): + continue else: - gen_helper_return_type(f,regtype,regid,i) + gen_helper_return_type(f, regtype, regid, i) else: - print("Bad register parse: ",regtype,regid,toss,numreg= s) + print("Bad register parse: ", regtype, regid, toss, nu= mregs) i +=3D 1 =20 - if (numscalarresults =3D=3D 0): + if numscalarresults =3D=3D 0: f.write("void") f.write(f" HELPER({tag})(CPUHexagonState *env") =20 ## Arguments include the vector destination operands i =3D 1 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_arg_ext_pair(f,regtype,regid,i) + for regtype, regid, toss, numregs in regs: + if hex_common.is_written(regid): + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_arg_ext_pair(f, regtype, regid, i) else: continue - elif (hex_common.is_single(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_arg_ext(f,regtype,regid,i) + elif hex_common.is_single(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_arg_ext(f, regtype, regid, i) else: # This is the return value of the function continue else: - print("Bad register parse: ",regtype,regid,toss,numreg= s) + print("Bad register parse: ", regtype, regid, toss, nu= mregs) i +=3D 1 =20 ## For conditional instructions, we pass in the destination regist= er - if 'A_CONDEXEC' in hex_common.attribdict[tag]: + if "A_CONDEXEC" in hex_common.attribdict[tag]: for regtype, regid, toss, numregs in regs: - if (hex_common.is_writeonly(regid) and - not hex_common.is_hvx_reg(regtype)): + if hex_common.is_writeonly(regid) and not hex_common.is_hv= x_reg( + regtype + ): gen_helper_arg_opn(f, regtype, regid, i, tag) i +=3D 1 =20 ## Arguments to the helper function are the source regs and immedi= ates - for regtype,regid,toss,numregs in regs: - if (hex_common.is_read(regid)): - if (hex_common.is_hvx_reg(regtype) and - hex_common.is_readwrite(regid)): + for regtype, regid, toss, numregs 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_arg_opn(f,regtype,regid,i,tag) + gen_helper_arg_opn(f, regtype, regid, i, tag) i +=3D 1 - for immlett,bits,immshift in imms: - gen_helper_arg_imm(f,immlett) + for immlett, bits, immshift in imms: + gen_helper_arg_imm(f, immlett) i +=3D 1 =20 - if (hex_common.need_pkt_has_multi_cof(tag)): + if hex_common.need_pkt_has_multi_cof(tag): f.write(", uint32_t pkt_has_multi_cof") =20 if hex_common.need_PC(tag): - if i > 0: f.write(", ") + if i > 0: + f.write(", ") f.write("target_ulong PC") i +=3D 1 if hex_common.helper_needs_next_PC(tag): - if i > 0: f.write(", ") + if i > 0: + f.write(", ") f.write("target_ulong next_PC") i +=3D 1 if hex_common.need_slot(tag): - if i > 0: f.write(", ") + if i > 0: + f.write(", ") f.write("uint32_t slot") i +=3D 1 if hex_common.need_part1(tag): - if i > 0: f.write(", ") + if i > 0: + f.write(", ") f.write("uint32_t part1") f.write(")\n{\n") - if (not hex_common.need_slot(tag)): - f.write(" uint32_t slot __attribute__((unused)) =3D 4;\n" ) - if hex_common.need_ea(tag): gen_decl_ea(f) + if not hex_common.need_slot(tag): + f.write(" uint32_t slot __attribute__((unused)) =3D 4;\n") + if hex_common.need_ea(tag): + gen_decl_ea(f) ## Declare the return variable - i=3D0 - if 'A_CONDEXEC' not in hex_common.attribdict[tag]: - for regtype,regid,toss,numregs in regs: - if (hex_common.is_writeonly(regid)): - gen_helper_dest_decl_opn(f,regtype,regid,i) + i =3D 0 + if "A_CONDEXEC" not in hex_common.attribdict[tag]: + for regtype, regid, toss, numregs 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: - if (hex_common.is_read(regid)): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_src_var_ext_pair(f,regtype,regid,i) - elif (hex_common.is_single(regid)): - if (hex_common.is_hvx_reg(regtype)): - gen_helper_src_var_ext(f,regtype,regid) + for regtype, regid, toss, numregs in regs: + if hex_common.is_read(regid): + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_src_var_ext_pair(f, regtype, regid, i) + elif hex_common.is_single(regid): + if hex_common.is_hvx_reg(regtype): + gen_helper_src_var_ext(f, regtype, regid) else: - print("Bad register parse: ",regtype,regid,toss,numreg= s) + print("Bad register parse: ", regtype, regid, toss, nu= mregs) =20 - if 'A_FPOP' in hex_common.attribdict[tag]: - f.write(' arch_fpop_start(env);\n'); + if "A_FPOP" in hex_common.attribdict[tag]: + f.write(" arch_fpop_start(env);\n") =20 f.write(f" {hex_common.semdict[tag]}\n") =20 - if 'A_FPOP' in hex_common.attribdict[tag]: - f.write(' arch_fpop_end(env);\n'); + if "A_FPOP" in hex_common.attribdict[tag]: + f.write(" arch_fpop_end(env);\n") =20 ## Save/return the return variable - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): + for regtype, regid, toss, numregs in regs: + if hex_common.is_written(regid): gen_helper_return_opn(f, regtype, regid, i) f.write("}\n\n") ## End of the helper definition =20 + def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) @@ -322,27 +369,28 @@ def main(): tagimms =3D hex_common.get_tagimms() =20 output_file =3D sys.argv[-1] - with open(output_file, 'w') as f: + with open(output_file, "w") as f: for tag in hex_common.tags: ## Skip the priv instructions - if ( "A_PRIV" in hex_common.attribdict[tag] ) : + if "A_PRIV" in hex_common.attribdict[tag]: continue ## Skip the guest instructions - if ( "A_GUEST" in hex_common.attribdict[tag] ) : + if "A_GUEST" in hex_common.attribdict[tag]: continue ## Skip the diag instructions - if ( tag =3D=3D "Y6_diag" ) : + if tag =3D=3D "Y6_diag": continue - if ( tag =3D=3D "Y6_diag0" ) : + if tag =3D=3D "Y6_diag0": continue - if ( tag =3D=3D "Y6_diag1" ) : + if tag =3D=3D "Y6_diag1": continue - if ( hex_common.skip_qemu_helper(tag) ): + if hex_common.skip_qemu_helper(tag): continue - if ( hex_common.is_idef_parser_enabled(tag) ): + if hex_common.is_idef_parser_enabled(tag): continue =20 gen_helper_function(f, tag, tagregs, tagimms) =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helpe= r_protos.py index d795f32047..187cd6e04e 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -26,32 +26,34 @@ ## Helpers for gen_helper_prototype ## def_helper_types =3D { - 'N' : 's32', - 'O' : 's32', - 'P' : 's32', - 'M' : 's32', - 'C' : 's32', - 'R' : 's32', - 'V' : 'ptr', - 'Q' : 'ptr' + "N": "s32", + "O": "s32", + "P": "s32", + "M": "s32", + "C": "s32", + "R": "s32", + "V": "ptr", + "Q": "ptr", } =20 def_helper_types_pair =3D { - 'R' : 's64', - 'C' : 's64', - 'S' : 's64', - 'G' : 's64', - 'V' : 'ptr', - 'Q' : 'ptr' + "R": "s64", + "C": "s64", + "S": "s64", + "G": "s64", + "V": "ptr", + "Q": "ptr", } =20 + def gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i): - if (hex_common.is_pair(regid)): + if hex_common.is_pair(regid): f.write(f", {def_helper_types_pair[regtype]}") - elif (hex_common.is_single(regid)): + elif hex_common.is_single(regid): f.write(f", {def_helper_types[regtype]}") else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) + =20 ## ## Generate the DEF_HELPER prototype for an instruction @@ -66,90 +68,108 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): numresults =3D 0 numscalarresults =3D 0 numscalarreadwrite =3D 0 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): + for regtype, regid, toss, numregs in regs: + if hex_common.is_written(regid): numresults +=3D 1 - if (hex_common.is_scalar_reg(regtype)): + if hex_common.is_scalar_reg(regtype): numscalarresults +=3D 1 - if (hex_common.is_readwrite(regid)): - if (hex_common.is_scalar_reg(regtype)): + if hex_common.is_readwrite(regid): + if hex_common.is_scalar_reg(regtype): numscalarreadwrite +=3D 1 =20 - if (numscalarresults > 1): + if numscalarresults > 1: ## The helper is bogus when there is more than one result - f.write(f'DEF_HELPER_1({tag}, void, env)\n') + f.write(f"DEF_HELPER_1({tag}, void, env)\n") else: ## Figure out how many arguments the helper will take - if (numscalarresults =3D=3D 0): - def_helper_size =3D len(regs)+len(imms)+numscalarreadwrite+1 - if hex_common.need_pkt_has_multi_cof(tag): def_helper_size += =3D 1 - if hex_common.need_part1(tag): def_helper_size +=3D 1 - if hex_common.need_slot(tag): def_helper_size +=3D 1 - if hex_common.need_PC(tag): def_helper_size +=3D 1 - if hex_common.helper_needs_next_PC(tag): def_helper_size +=3D 1 - if hex_common.need_condexec_reg(tag, regs): def_helper_size += =3D 1 - f.write(f'DEF_HELPER_{def_helper_size}({tag}') + if numscalarresults =3D=3D 0: + def_helper_size =3D len(regs) + len(imms) + numscalarreadwrite= + 1 + if hex_common.need_pkt_has_multi_cof(tag): + def_helper_size +=3D 1 + if hex_common.need_part1(tag): + def_helper_size +=3D 1 + if hex_common.need_slot(tag): + def_helper_size +=3D 1 + if hex_common.need_PC(tag): + def_helper_size +=3D 1 + if hex_common.helper_needs_next_PC(tag): + def_helper_size +=3D 1 + if hex_common.need_condexec_reg(tag, regs): + def_helper_size +=3D 1 + f.write(f"DEF_HELPER_{def_helper_size}({tag}") ## The return type is void - f.write(', void' ) + f.write(", void") else: - def_helper_size =3D len(regs)+len(imms)+numscalarreadwrite - if hex_common.need_pkt_has_multi_cof(tag): def_helper_size += =3D 1 - if hex_common.need_part1(tag): def_helper_size +=3D 1 - if hex_common.need_slot(tag): def_helper_size +=3D 1 - if hex_common.need_PC(tag): def_helper_size +=3D 1 - if hex_common.need_condexec_reg(tag, regs): def_helper_size += =3D 1 - if hex_common.helper_needs_next_PC(tag): def_helper_size +=3D 1 - f.write(f'DEF_HELPER_{def_helper_size}({tag}') + def_helper_size =3D len(regs) + len(imms) + numscalarreadwrite + if hex_common.need_pkt_has_multi_cof(tag): + def_helper_size +=3D 1 + if hex_common.need_part1(tag): + def_helper_size +=3D 1 + if hex_common.need_slot(tag): + def_helper_size +=3D 1 + if hex_common.need_PC(tag): + def_helper_size +=3D 1 + if hex_common.need_condexec_reg(tag, regs): + def_helper_size +=3D 1 + if hex_common.helper_needs_next_PC(tag): + def_helper_size +=3D 1 + f.write(f"DEF_HELPER_{def_helper_size}({tag}") =20 ## Generate the qemu DEF_HELPER type for each result ## Iterate over this list twice ## - Emit the scalar result ## - Emit the vector result - i=3D0 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - if (not hex_common.is_hvx_reg(regtype)): + i =3D 0 + for regtype, regid, toss, numregs 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) i +=3D 1 =20 ## Put the env between the outputs and inputs - f.write(', env' ) + f.write(", env") i +=3D 1 =20 # Second pass - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - if (hex_common.is_hvx_reg(regtype)): + for regtype, regid, toss, numregs 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) i +=3D 1 =20 ## For conditional instructions, we pass in the destination regist= er - if 'A_CONDEXEC' in hex_common.attribdict[tag]: + if "A_CONDEXEC" in hex_common.attribdict[tag]: for regtype, regid, toss, numregs in regs: - if (hex_common.is_writeonly(regid) and - not hex_common.is_hvx_reg(regtype)): + 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) i +=3D 1 =20 ## Generate the qemu type for each input operand (regs and immedia= tes) - for regtype,regid,toss,numregs in regs: - if (hex_common.is_read(regid)): - if (hex_common.is_hvx_reg(regtype) and - hex_common.is_readwrite(regid)): + for regtype, regid, toss, numregs 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) i +=3D 1 - for immlett,bits,immshift in imms: + for immlett, bits, immshift in imms: f.write(", s32") =20 ## Add the arguments for the instruction pkt_has_multi_cof, slot a= nd ## part1 (if needed) - if hex_common.need_pkt_has_multi_cof(tag): f.write(', i32') - if hex_common.need_PC(tag): f.write(', i32') - if hex_common.helper_needs_next_PC(tag): f.write(', i32') - if hex_common.need_slot(tag): f.write(', i32' ) - if hex_common.need_part1(tag): f.write(' , i32' ) - f.write(')\n') + if hex_common.need_pkt_has_multi_cof(tag): + f.write(", i32") + if hex_common.need_PC(tag): + f.write(", i32") + if hex_common.helper_needs_next_PC(tag): + f.write(", i32") + if hex_common.need_slot(tag): + f.write(", i32") + if hex_common.need_part1(tag): + f.write(" , i32") + f.write(")\n") + =20 def main(): hex_common.read_semantics_file(sys.argv[1]) @@ -173,28 +193,29 @@ def main(): tagimms =3D hex_common.get_tagimms() =20 output_file =3D sys.argv[-1] - with open(output_file, 'w') as f: + with open(output_file, "w") as f: for tag in hex_common.tags: ## Skip the priv instructions - if ( "A_PRIV" in hex_common.attribdict[tag] ) : + if "A_PRIV" in hex_common.attribdict[tag]: continue ## Skip the guest instructions - if ( "A_GUEST" in hex_common.attribdict[tag] ) : + if "A_GUEST" in hex_common.attribdict[tag]: continue ## Skip the diag instructions - if ( tag =3D=3D "Y6_diag" ) : + if tag =3D=3D "Y6_diag": continue - if ( tag =3D=3D "Y6_diag0" ) : + if tag =3D=3D "Y6_diag0": continue - if ( tag =3D=3D "Y6_diag1" ) : + if tag =3D=3D "Y6_diag1": continue =20 - if ( hex_common.skip_qemu_helper(tag) ): + if hex_common.skip_qemu_helper(tag): continue - if ( hex_common.is_idef_parser_enabled(tag) ): + if hex_common.is_idef_parser_enabled(tag): continue =20 gen_helper_prototype(f, tag, tagregs, tagimms) =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_i= def_parser_funcs.py index 1b1fdf9790..afe68bdb6f 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -24,6 +24,7 @@ =20 import hex_common =20 + ## ## Generate code to be fed to the idef_parser ## @@ -48,83 +49,99 @@ def main(): tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: f.write('#include "macros.inc"\n\n') =20 for tag in hex_common.tags: ## Skip the priv instructions - if ( "A_PRIV" in hex_common.attribdict[tag] ) : + if "A_PRIV" in hex_common.attribdict[tag]: continue ## Skip the guest instructions - if ( "A_GUEST" in hex_common.attribdict[tag] ) : + if "A_GUEST" in hex_common.attribdict[tag]: continue ## Skip instructions that saturate in a ternary expression - if ( tag in {'S2_asr_r_r_sat', 'S2_asl_r_r_sat'} ) : + if tag in {"S2_asr_r_r_sat", "S2_asl_r_r_sat"}: continue ## Skip instructions using switch - if ( tag in {'S4_vrcrotate_acc', 'S4_vrcrotate'} ) : + if tag in {"S4_vrcrotate_acc", "S4_vrcrotate"}: continue ## Skip trap instructions - if ( tag in {'J2_trap0', 'J2_trap1'} ) : + if tag in {"J2_trap0", "J2_trap1"}: continue ## Skip 128-bit instructions - if ( tag in {'A7_croundd_ri', 'A7_croundd_rr'} ) : + if tag in {"A7_croundd_ri", "A7_croundd_rr"}: continue - if ( tag in {'M7_wcmpyrw', 'M7_wcmpyrwc', - 'M7_wcmpyiw', 'M7_wcmpyiwc', - 'M7_wcmpyrw_rnd', 'M7_wcmpyrwc_rnd', - 'M7_wcmpyiw_rnd', 'M7_wcmpyiwc_rnd'} ) : + if tag in { + "M7_wcmpyrw", + "M7_wcmpyrwc", + "M7_wcmpyiw", + "M7_wcmpyiwc", + "M7_wcmpyrw_rnd", + "M7_wcmpyrwc_rnd", + "M7_wcmpyiw_rnd", + "M7_wcmpyiwc_rnd", + }: continue ## Skip interleave/deinterleave instructions - if ( tag in {'S2_interleave', 'S2_deinterleave'} ) : + if tag in {"S2_interleave", "S2_deinterleave"}: continue ## Skip instructions using bit reverse - if ( tag in {'S2_brev', 'S2_brevp', 'S2_ct0', 'S2_ct1', - 'S2_ct0p', 'S2_ct1p', 'A4_tlbmatch'} ) : + if tag in { + "S2_brev", + "S2_brevp", + "S2_ct0", + "S2_ct1", + "S2_ct0p", + "S2_ct1p", + "A4_tlbmatch", + }: continue ## Skip other unsupported instructions - if ( tag =3D=3D 'S2_cabacdecbin' or tag =3D=3D 'A5_ACS' ) : + if tag =3D=3D "S2_cabacdecbin" or tag =3D=3D "A5_ACS": continue - if ( tag.startswith('Y') ) : + if tag.startswith("Y"): continue - if ( tag.startswith('V6_') ) : + if tag.startswith("V6_"): continue - if ( tag.startswith('F') ) : + if tag.startswith("F"): continue - if ( tag.endswith('_locked') ) : + if tag.endswith("_locked"): continue - if ( "A_COF" in hex_common.attribdict[tag] ) : + if "A_COF" in hex_common.attribdict[tag]: continue =20 regs =3D tagregs[tag] imms =3D tagimms[tag] =20 arguments =3D [] - for regtype,regid,toss,numregs in regs: + for regtype, regid, toss, numregs in regs: prefix =3D "in " if hex_common.is_read(regid) else "" =20 is_pair =3D hex_common.is_pair(regid) - is_single_old =3D (hex_common.is_single(regid) - and hex_common.is_old_val(regtype, regid,= tag)) - is_single_new =3D (hex_common.is_single(regid) - and hex_common.is_new_val(regtype, regid,= tag)) + is_single_old =3D hex_common.is_single(regid) and hex_comm= on.is_old_val( + regtype, regid, tag + ) + is_single_new =3D hex_common.is_single(regid) and hex_comm= on.is_new_val( + regtype, regid, tag + ) =20 if is_pair or is_single_old: arguments.append(f"{prefix}{regtype}{regid}V") elif is_single_new: arguments.append(f"{prefix}{regtype}{regid}N") else: - print("Bad register parse: ",regtype,regid,toss,numreg= s) + print("Bad register parse: ", regtype, regid, toss, nu= mregs) =20 - for immlett,bits,immshift in imms: + for immlett, bits, immshift in imms: arguments.append(hex_common.imm_name(immlett)) =20 f.write(f"{tag}({', '.join(arguments)}) {{\n") - f.write(" "); + f.write(" ") if hex_common.need_ea(tag): - f.write("size4u_t EA; "); + f.write("size4u_t EA; ") f.write(f"{hex_common.semdict[tag]}\n") f.write("}\n\n") =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_op_attribs.py b/target/hexagon/gen_op_attri= bs.py index cf7b7f7656..41074b8573 100755 --- a/target/hexagon/gen_op_attribs.py +++ b/target/hexagon/gen_op_attribs.py @@ -22,6 +22,7 @@ import string import hex_common =20 + def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) @@ -30,10 +31,13 @@ def main(): ## ## Generate all the attributes associated with each instruction ## - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: for tag in hex_common.tags: - f.write(f'OP_ATTRIB({tag},ATTRIBS(' - f'{",".join(sorted(hex_common.attribdict[tag]))}))\n') + f.write( + f"OP_ATTRIB({tag},ATTRIBS(" + f'{",".join(sorted(hex_common.attribdict[tag]))}))\n' + ) + =20 if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_op_regs.py b/target/hexagon/gen_op_regs.py index c0de9ad380..42972c7f9e 100755 --- a/target/hexagon/gen_op_regs.py +++ b/target/hexagon/gen_op_regs.py @@ -22,21 +22,25 @@ import string import hex_common =20 + ## ## Generate the register and immediate operands for each instruction ## def calculate_regid_reg(tag): - def letter_inc(x): return chr(ord(x)+1) - ordered_implregs =3D [ 'SP','FP','LR' ] - srcdst_lett =3D 'X' - src_lett =3D 'S' - dst_lett =3D 'D' + def letter_inc(x): + return chr(ord(x) + 1) + + ordered_implregs =3D ["SP", "FP", "LR"] + srcdst_lett =3D "X" + src_lett =3D "S" + dst_lett =3D "D" retstr =3D "" mapdict =3D {} for reg in ordered_implregs: reg_rd =3D 0 reg_wr =3D 0 - if ('A_IMPLICIT_WRITES_'+reg) in hex_common.attribdict[tag]: reg_w= r =3D 1 + if ("A_IMPLICIT_WRITES_" + reg) in hex_common.attribdict[tag]: + reg_wr =3D 1 if reg_rd and reg_wr: retstr +=3D srcdst_lett mapdict[srcdst_lett] =3D reg @@ -49,16 +53,19 @@ def letter_inc(x): return chr(ord(x)+1) retstr +=3D dst_lett mapdict[dst_lett] =3D reg dst_lett =3D letter_inc(dst_lett) - return retstr,mapdict + return retstr, mapdict + =20 def calculate_regid_letters(tag): - retstr,mapdict =3D calculate_regid_reg(tag) + retstr, mapdict =3D calculate_regid_reg(tag) return retstr =20 + def strip_reg_prefix(x): - y=3Dx.replace('UREG.','') - y=3Dy.replace('MREG.','') - return y.replace('GREG.','') + y =3D x.replace("UREG.", "") + y =3D y.replace("MREG.", "") + return y.replace("GREG.", "") + =20 def main(): hex_common.read_semantics_file(sys.argv[1]) @@ -66,45 +73,51 @@ def main(): tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: for tag in hex_common.tags: regs =3D tagregs[tag] rregs =3D [] wregs =3D [] regids =3D "" - for regtype,regid,toss,numregs in regs: + for regtype, regid, toss, numregs in regs: if hex_common.is_read(regid): - if regid[0] not in regids: regids +=3D regid[0] - rregs.append(regtype+regid+numregs) + if regid[0] not in regids: + regids +=3D regid[0] + rregs.append(regtype + regid + numregs) if hex_common.is_written(regid): - wregs.append(regtype+regid+numregs) - if regid[0] not in regids: regids +=3D regid[0] + wregs.append(regtype + regid + numregs) + if regid[0] not in regids: + regids +=3D regid[0] for attrib in hex_common.attribdict[tag]: - if hex_common.attribinfo[attrib]['rreg']: - rregs.append(strip_reg_prefix(attribinfo[attrib]['rreg= '])) - if hex_common.attribinfo[attrib]['wreg']: - wregs.append(strip_reg_prefix(attribinfo[attrib]['wreg= '])) + if hex_common.attribinfo[attrib]["rreg"]: + rregs.append(strip_reg_prefix(attribinfo[attrib]["rreg= "])) + if hex_common.attribinfo[attrib]["wreg"]: + wregs.append(strip_reg_prefix(attribinfo[attrib]["wreg= "])) regids +=3D calculate_regid_letters(tag) - f.write(f'REGINFO({tag},"{regids}",\t/*RD:*/\t"{",".join(rregs= )}",' - f'\t/*WR:*/\t"{",".join(wregs)}")\n') + f.write( + f'REGINFO({tag},"{regids}",\t/*RD:*/\t"{",".join(rregs)}",' + f'\t/*WR:*/\t"{",".join(wregs)}")\n' + ) =20 for tag in hex_common.tags: imms =3D tagimms[tag] - f.write(f'IMMINFO({tag}') + f.write(f"IMMINFO({tag}") if not imms: - f.write(''','u',0,0,'U',0,0''') - for sign,size,shamt in imms: - if sign =3D=3D 'r': sign =3D 's' + f.write(""",'u',0,0,'U',0,0""") + for sign, size, shamt in imms: + if sign =3D=3D "r": + sign =3D "s" if not shamt: shamt =3D "0" - f.write(f''','{sign}',{size},{shamt}''') + f.write(f""",'{sign}',{size},{shamt}""") if len(imms) =3D=3D 1: if sign.isupper(): - myu =3D 'u' + myu =3D "u" else: - myu =3D 'U' - f.write(f''','{myu}',0,0''') - f.write(')\n') + myu =3D "U" + f.write(f""",'{myu}',0,0""") + f.write(")\n") + =20 if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_opcodes_def.py b/target/hexagon/gen_opcodes= _def.py index 5eebc16898..cddd868fe3 100755 --- a/target/hexagon/gen_opcodes_def.py +++ b/target/hexagon/gen_opcodes_def.py @@ -22,15 +22,17 @@ import string import hex_common =20 + def main(): hex_common.read_semantics_file(sys.argv[1]) =20 ## ## Generate a list of all the opcodes ## - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: for tag in hex_common.tags: f.write(f"OPCODE({tag}),\n") =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_printinsn.py b/target/hexagon/gen_printinsn= .py index 4ec8dcabb0..e570bd7c6a 100755 --- a/target/hexagon/gen_printinsn.py +++ b/target/hexagon/gen_printinsn.py @@ -22,24 +22,26 @@ import string import hex_common =20 + ## ## Generate data for printing each instruction (format string + operan= ds) ## def regprinter(m): str =3D m.group(1) - str +=3D ":".join(["%d"]*len(m.group(2))) + str +=3D ":".join(["%d"] * len(m.group(2))) str +=3D m.group(3) - if ('S' in m.group(1)) and (len(m.group(2)) =3D=3D 1): + if ("S" in m.group(1)) and (len(m.group(2)) =3D=3D 1): str +=3D "/%s" - elif ('C' in m.group(1)) and (len(m.group(2)) =3D=3D 1): + elif ("C" in m.group(1)) and (len(m.group(2)) =3D=3D 1): str +=3D "/%s" return str =20 + def spacify(s): # Regular expression that matches any operator that contains '=3D' cha= racter: - opswithequal_re =3D '[-+^&|!<>=3D]?=3D' + opswithequal_re =3D "[-+^&|!<>=3D]?=3D" # Regular expression that matches any assignment operator. - assignment_re =3D '[-+^&|]?=3D' + assignment_re =3D "[-+^&|]?=3D" =20 # Out of the operators that contain the =3D sign, if the operator is a= lso an # assignment, spaces will be added around it, unless it's enclosed wit= hin @@ -54,9 +56,9 @@ def spacify(s): pc =3D 0 while i < slen: c =3D s[i] - if c =3D=3D '(': + if c =3D=3D "(": pc +=3D 1 - elif c =3D=3D ')': + elif c =3D=3D ")": pc -=3D 1 paren_count[i] =3D pc i +=3D 1 @@ -76,31 +78,33 @@ def spacify(s): if paren_count[ms] =3D=3D 0: # Check if the entire string t is an assignment. am =3D assign.match(t) - if am and len(am.group(0)) =3D=3D me-ms: + if am and len(am.group(0)) =3D=3D me - ms: # Don't add spaces if they are already there. - if ms > 0 and s[ms-1] !=3D ' ': - out.append(' ') + if ms > 0 and s[ms - 1] !=3D " ": + out.append(" ") out +=3D t - if me < slen and s[me] !=3D ' ': - out.append(' ') + if me < slen and s[me] !=3D " ": + out.append(" ") continue # If this is not an assignment, just append it to the output # string. out +=3D t =20 # Append the remaining part of the string. - out +=3D s[pos:len(s)] - return ''.join(out) + out +=3D s[pos : len(s)] + return "".join(out) + =20 def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) =20 - immext_casere =3D re.compile(r'IMMEXT\(([A-Za-z])') + immext_casere =3D re.compile(r"IMMEXT\(([A-Za-z])") =20 - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: for tag in hex_common.tags: - if not hex_common.behdict[tag]: continue + if not hex_common.behdict[tag]: + continue extendable_upper_imm =3D False extendable_lower_imm =3D False m =3D immext_casere.search(hex_common.semdict[tag]) @@ -110,46 +114,45 @@ def main(): else: extendable_lower_imm =3D True beh =3D hex_common.behdict[tag] - beh =3D hex_common.regre.sub(regprinter,beh) - beh =3D hex_common.absimmre.sub(r"#%s0x%x",beh) - beh =3D hex_common.relimmre.sub(r"PC+%s%d",beh) + beh =3D hex_common.regre.sub(regprinter, beh) + beh =3D hex_common.absimmre.sub(r"#%s0x%x", beh) + beh =3D hex_common.relimmre.sub(r"PC+%s%d", beh) beh =3D spacify(beh) # Print out a literal "%s" at the end, used to match empty str= ing # so C won't complain at us - if ("A_VECX" in hex_common.attribdict[tag]): + if "A_VECX" in hex_common.attribdict[tag]: macname =3D "DEF_VECX_PRINTINFO" - else: macname =3D "DEF_PRINTINFO" + else: + macname =3D "DEF_PRINTINFO" f.write(f'{macname}({tag},"{beh}%s"') - regs_or_imms =3D \ - hex_common.reg_or_immre.findall(hex_common.behdict[tag]) + regs_or_imms =3D hex_common.reg_or_immre.findall(hex_common.be= hdict[tag]) ri =3D 0 seenregs =3D {} - for allregs,a,b,c,d,allimm,immlett,bits,immshift in regs_or_im= ms: + for allregs, a, b, c, d, allimm, immlett, bits, immshift in re= gs_or_imms: if a: - #register + # register if b in seenregs: regno =3D seenregs[b] else: regno =3D ri if len(b) =3D=3D 1: - f.write(f', insn->regno[{regno}]') - if 'S' in a: - f.write(f', sreg2str(insn->regno[{regno}])') - elif 'C' in a: - f.write(f', creg2str(insn->regno[{regno}])') + f.write(f", insn->regno[{regno}]") + if "S" in a: + f.write(f", sreg2str(insn->regno[{regno}])") + elif "C" in a: + f.write(f", creg2str(insn->regno[{regno}])") elif len(b) =3D=3D 2: - f.write(f', insn->regno[{regno}] + 1' - f', insn->regno[{regno}]') + f.write(f", insn->regno[{regno}] + 1" f", insn->re= gno[{regno}]") else: print("Put some stuff to handle quads here") if b not in seenregs: seenregs[b] =3D ri ri +=3D 1 else: - #immediate - if (immlett.isupper()): + # immediate + if immlett.isupper(): if extendable_upper_imm: - if immlett in 'rR': + if immlett in "rR": f.write(',insn->extension_valid?"##":""') else: f.write(',insn->extension_valid?"#":""') @@ -158,16 +161,17 @@ def main(): ii =3D 1 else: if extendable_lower_imm: - if immlett in 'rR': + if immlett in "rR": f.write(',insn->extension_valid?"##":""') else: f.write(',insn->extension_valid?"#":""') else: f.write(',""') ii =3D 0 - f.write(f', insn->immed[{ii}]') + f.write(f", insn->immed[{ii}]") # append empty string so there is at least one more arg f.write(',"")\n') =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_shortcode.py b/target/hexagon/gen_shortcode= .py index 9a093a8902..deb94446c4 100755 --- a/target/hexagon/gen_shortcode.py +++ b/target/hexagon/gen_shortcode.py @@ -22,8 +22,10 @@ import string import hex_common =20 + def gen_shortcode(f, tag): - f.write(f'DEF_SHORTCODE({tag}, {hex_common.semdict[tag]})\n') + f.write(f"DEF_SHORTCODE({tag}, {hex_common.semdict[tag]})\n") + =20 def main(): hex_common.read_semantics_file(sys.argv[1]) @@ -32,29 +34,30 @@ def main(): tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: f.write("#ifndef DEF_SHORTCODE\n") f.write("#define DEF_SHORTCODE(TAG,SHORTCODE) /* Nothing */\n") f.write("#endif\n") =20 for tag in hex_common.tags: ## Skip the priv instructions - if ( "A_PRIV" in hex_common.attribdict[tag] ) : + if "A_PRIV" in hex_common.attribdict[tag]: continue ## Skip the guest instructions - if ( "A_GUEST" in hex_common.attribdict[tag] ) : + if "A_GUEST" in hex_common.attribdict[tag]: continue ## Skip the diag instructions - if ( tag =3D=3D "Y6_diag" ) : + if tag =3D=3D "Y6_diag": continue - if ( tag =3D=3D "Y6_diag0" ) : + if tag =3D=3D "Y6_diag0": continue - if ( tag =3D=3D "Y6_diag1" ) : + if tag =3D=3D "Y6_diag1": continue =20 gen_shortcode(f, tag) =20 f.write("#undef DEF_SHORTCODE\n") =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_tcg_func_table.py b/target/hexagon/gen_tcg_= func_table.py index 8319daf96a..f998ef0992 100755 --- a/target/hexagon/gen_tcg_func_table.py +++ b/target/hexagon/gen_tcg_func_table.py @@ -22,6 +22,7 @@ import string import hex_common =20 + def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) @@ -29,24 +30,24 @@ def main(): tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[3], 'w') as f: + with open(sys.argv[3], "w") as f: f.write("#ifndef HEXAGON_FUNC_TABLE_H\n") f.write("#define HEXAGON_FUNC_TABLE_H\n\n") =20 f.write("const SemanticInsn opcode_genptr[XX_LAST_OPCODE] =3D {\n") for tag in hex_common.tags: ## Skip the priv instructions - if ( "A_PRIV" in hex_common.attribdict[tag] ) : + if "A_PRIV" in hex_common.attribdict[tag]: continue ## Skip the guest instructions - if ( "A_GUEST" in hex_common.attribdict[tag] ) : + if "A_GUEST" in hex_common.attribdict[tag]: continue ## Skip the diag instructions - if ( tag =3D=3D "Y6_diag" ) : + if tag =3D=3D "Y6_diag": continue - if ( tag =3D=3D "Y6_diag0" ) : + if tag =3D=3D "Y6_diag0": continue - if ( tag =3D=3D "Y6_diag1" ) : + if tag =3D=3D "Y6_diag1": continue =20 f.write(f" [{tag}] =3D generate_{tag},\n") @@ -54,5 +55,6 @@ def main(): =20 f.write("#endif /* HEXAGON_FUNC_TABLE_H */\n") =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs= .py index 285b3abe3a..fcb3384480 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -22,249 +22,277 @@ import string import hex_common =20 + ## ## Helpers for gen_tcg_func ## def gen_decl_ea_tcg(f, tag): f.write(" TCGv EA G_GNUC_UNUSED =3D tcg_temp_new();\n") =20 + def genptr_decl_pair_writable(f, tag, regtype, regid, regno): - regN=3Df"{regtype}{regid}N" - if (regtype =3D=3D "R"): + regN =3D f"{regtype}{regid}N" + if regtype =3D=3D "R": f.write(f" const int {regN} =3D insn->regno[{regno}];\n") - elif (regtype =3D=3D "C"): + elif regtype =3D=3D "C": f.write(f" const int {regN} =3D insn->regno[{regno}] + HEX_REG_= SA0;\n") else: print("Bad register parse: ", regtype, regid) - f.write(f" TCGv_i64 {regtype}{regid}V =3D " - f"get_result_gpr_pair(ctx, {regN});\n") + f.write(f" TCGv_i64 {regtype}{regid}V =3D " f"get_result_gpr_pair(c= tx, {regN});\n") + =20 def genptr_decl_writable(f, tag, regtype, regid, regno): - regN=3Df"{regtype}{regid}N" - if (regtype =3D=3D "R"): + regN =3D f"{regtype}{regid}N" + if regtype =3D=3D "R": f.write(f" const int {regN} =3D insn->regno[{regno}];\n") f.write(f" TCGv {regtype}{regid}V =3D get_result_gpr(ctx, {regN= });\n") - elif (regtype =3D=3D "C"): + elif regtype =3D=3D "C": f.write(f" const int {regN} =3D insn->regno[{regno}] + HEX_REG_= SA0;\n") f.write(f" TCGv {regtype}{regid}V =3D get_result_gpr(ctx, {regN= });\n") - elif (regtype =3D=3D "P"): + elif regtype =3D=3D "P": f.write(f" const int {regN} =3D insn->regno[{regno}];\n") f.write(f" TCGv {regtype}{regid}V =3D tcg_temp_new();\n") else: print("Bad register parse: ", regtype, regid) =20 + def genptr_decl(f, tag, regtype, regid, regno): - regN=3Df"{regtype}{regid}N" - if (regtype =3D=3D "R"): - if (regid in {"ss", "tt"}): + regN =3D f"{regtype}{regid}N" + if regtype =3D=3D "R": + if regid in {"ss", "tt"}: f.write(f" TCGv_i64 {regtype}{regid}V =3D tcg_temp_new_i64(= );\n") f.write(f" const int {regN} =3D insn->regno[{regno}];\n") - elif (regid in {"dd", "ee", "xx", "yy"}): + elif regid in {"dd", "ee", "xx", "yy"}: genptr_decl_pair_writable(f, tag, regtype, regid, regno) - elif (regid in {"s", "t", "u", "v"}): - f.write(f" TCGv {regtype}{regid}V =3D " - f"hex_gpr[insn->regno[{regno}]];\n") - elif (regid in {"d", "e", "x", "y"}): + elif regid in {"s", "t", "u", "v"}: + f.write( + f" TCGv {regtype}{regid}V =3D " f"hex_gpr[insn->regno[{= regno}]];\n" + ) + elif regid in {"d", "e", "x", "y"}: genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid in {"s", "t", "u", "v"}): - f.write(f" TCGv {regtype}{regid}V =3D " - f"hex_pred[insn->regno[{regno}]];\n") - elif (regid in {"d", "e", "x"}): + elif regtype =3D=3D "P": + if regid in {"s", "t", "u", "v"}: + f.write( + f" TCGv {regtype}{regid}V =3D " f"hex_pred[insn->regno[= {regno}]];\n" + ) + elif regid in {"d", "e", "x"}: genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "C"): - if (regid =3D=3D "ss"): - f.write(f" TCGv_i64 {regtype}{regid}V =3D " - f"tcg_temp_new_i64();\n") - f.write(f" const int {regN} =3D insn->regno[{regno}] + " - "HEX_REG_SA0;\n") - elif (regid =3D=3D "dd"): + elif regtype =3D=3D "C": + if regid =3D=3D "ss": + f.write(f" TCGv_i64 {regtype}{regid}V =3D " f"tcg_temp_new_= i64();\n") + f.write(f" const int {regN} =3D insn->regno[{regno}] + " "H= EX_REG_SA0;\n") + elif regid =3D=3D "dd": genptr_decl_pair_writable(f, tag, regtype, regid, regno) - elif (regid =3D=3D "s"): + elif regid =3D=3D "s": f.write(f" TCGv {regtype}{regid}V =3D tcg_temp_new();\n") - f.write(f" const int {regtype}{regid}N =3D insn->regno[{reg= no}] + " - "HEX_REG_SA0;\n") - elif (regid =3D=3D "d"): + f.write( + f" const int {regtype}{regid}N =3D insn->regno[{regno}]= + " + "HEX_REG_SA0;\n" + ) + elif regid =3D=3D "d": genptr_decl_writable(f, tag, regtype, regid, regno) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "M"): - if (regid =3D=3D "u"): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") - f.write(f" TCGv {regtype}{regid}V =3D hex_gpr[{regtype}{reg= id}N + " - "HEX_REG_M0];\n") + elif regtype =3D=3D "M": + if regid =3D=3D "u": + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") + f.write( + f" TCGv {regtype}{regid}V =3D hex_gpr[{regtype}{regid}N= + " + "HEX_REG_M0];\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "V"): - if (regid in {"dd"}): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") + elif regtype =3D=3D "V": + if regid in {"dd"}: + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") - if (hex_common.is_tmp_result(tag)): - f.write(f" ctx_tmp_vreg_off(ctx, {regtype}{regid}N,= 2, " - "true);\n") + if hex_common.is_tmp_result(tag): + f.write( + f" ctx_tmp_vreg_off(ctx, {regtype}{regid}N, 2, = " "true);\n" + ) else: f.write(f" ctx_future_vreg_off(ctx, {regtype}{regid= }N,") f.write(" 2, true);\n") - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" TCGv_ptr {regtype}{regid}V =3D " - "tcg_temp_new_ptr();\n") - f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " - f"{regtype}{regid}V_off);\n") - elif (regid in {"uu", "vv", "xx"}): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") + if not hex_common.skip_qemu_helper(tag): + f.write(f" TCGv_ptr {regtype}{regid}V =3D " "tcg_temp_n= ew_ptr();\n") + f.write( + f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env, " + f"{regtype}{regid}V_off);\n" + ) + elif regid in {"uu", "vv", "xx"}: + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") f.write(f" offsetof(CPUHexagonState, {regtype}{regid}V)= ;\n") - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" TCGv_ptr {regtype}{regid}V =3D " - "tcg_temp_new_ptr();\n") - f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " - f"{regtype}{regid}V_off);\n") - elif (regid in {"s", "u", "v", "w"}): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") + if not hex_common.skip_qemu_helper(tag): + f.write(f" TCGv_ptr {regtype}{regid}V =3D " "tcg_temp_n= ew_ptr();\n") + f.write( + f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env, " + f"{regtype}{regid}V_off);\n" + ) + elif regid in {"s", "u", "v", "w"}: + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") f.write(f" vreg_src_off(ctx, {regtype}{regid}N);\n") - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" TCGv_ptr {regtype}{regid}V =3D " - "tcg_temp_new_ptr();\n") - elif (regid in {"d", "x", "y"}): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") + if not hex_common.skip_qemu_helper(tag): + f.write(f" TCGv_ptr {regtype}{regid}V =3D " "tcg_temp_n= ew_ptr();\n") + elif regid in {"d", "x", "y"}: + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") - if (regid =3D=3D "y"): + if regid =3D=3D "y": f.write(" offsetof(CPUHexagonState, vtmp);\n") - elif (hex_common.is_tmp_result(tag)): - f.write(f" ctx_tmp_vreg_off(ctx, {regtype}{regid}N,= 1, " - "true);\n") + elif hex_common.is_tmp_result(tag): + f.write( + f" ctx_tmp_vreg_off(ctx, {regtype}{regid}N, 1, = " "true);\n" + ) else: f.write(f" ctx_future_vreg_off(ctx, {regtype}{regid= }N,") - f.write(" 1, true);\n"); + f.write(" 1, true);\n") =20 - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" TCGv_ptr {regtype}{regid}V =3D " - "tcg_temp_new_ptr();\n") - f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " - f"{regtype}{regid}V_off);\n") + if not hex_common.skip_qemu_helper(tag): + f.write(f" TCGv_ptr {regtype}{regid}V =3D " "tcg_temp_n= ew_ptr();\n") + f.write( + f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env, " + f"{regtype}{regid}V_off);\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "Q"): - if (regid in {"d", "e", "x"}): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") + elif regtype =3D=3D "Q": + if regid in {"d", "e", "x"}: + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") f.write(f" get_result_qreg(ctx, {regtype}{regid}N);\n") - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" TCGv_ptr {regtype}{regid}V =3D " - "tcg_temp_new_ptr();\n") - f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " - f"{regtype}{regid}V_off);\n") - elif (regid in {"s", "t", "u", "v"}): - f.write(f" const int {regtype}{regid}N =3D " - f"insn->regno[{regno}];\n") + if not hex_common.skip_qemu_helper(tag): + f.write(f" TCGv_ptr {regtype}{regid}V =3D " "tcg_temp_n= ew_ptr();\n") + f.write( + f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env, " + f"{regtype}{regid}V_off);\n" + ) + elif regid in {"s", "t", "u", "v"}: + f.write(f" const int {regtype}{regid}N =3D " f"insn->regno[= {regno}];\n") f.write(f" const intptr_t {regtype}{regid}V_off =3D\n") - f.write(f" offsetof(CPUHexagonState, " - f"QRegs[{regtype}{regid}N]);\n") - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" TCGv_ptr {regtype}{regid}V =3D " - "tcg_temp_new_ptr();\n") + f.write( + f" offsetof(CPUHexagonState, " f"QRegs[{regtype}{re= gid}N]);\n" + ) + if not hex_common.skip_qemu_helper(tag): + f.write(f" TCGv_ptr {regtype}{regid}V =3D " "tcg_temp_n= ew_ptr();\n") else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 + def genptr_decl_new(f, tag, regtype, regid, regno): - if (regtype =3D=3D "N"): - if (regid in {"s", "t"}): - f.write(f" TCGv {regtype}{regid}N =3D " - f"hex_new_value[insn->regno[{regno}]];\n") + if regtype =3D=3D "N": + if regid in {"s", "t"}: + f.write( + f" TCGv {regtype}{regid}N =3D " + f"hex_new_value[insn->regno[{regno}]];\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid in {"t", "u", "v"}): - f.write(f" TCGv {regtype}{regid}N =3D " - f"hex_new_pred_value[insn->regno[{regno}]];\n") + elif regtype =3D=3D "P": + if regid in {"t", "u", "v"}: + f.write( + f" TCGv {regtype}{regid}N =3D " + f"hex_new_pred_value[insn->regno[{regno}]];\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "O"): - if (regid =3D=3D "s"): - f.write(f" const intptr_t {regtype}{regid}N_num =3D " - f"insn->regno[{regno}];\n") - if (hex_common.skip_qemu_helper(tag)): + elif regtype =3D=3D "O": + if regid =3D=3D "s": + f.write( + f" const intptr_t {regtype}{regid}N_num =3D " + f"insn->regno[{regno}];\n" + ) + if hex_common.skip_qemu_helper(tag): f.write(f" const intptr_t {regtype}{regid}N_off =3D\n") - f.write(" ctx_future_vreg_off(ctx, " - f"{regtype}{regid}N_num,") + f.write(" ctx_future_vreg_off(ctx, " f"{regtype}{r= egid}N_num,") f.write(" 1, true);\n") else: - f.write(f" TCGv {regtype}{regid}N =3D " - f"tcg_constant_tl({regtype}{regid}N_num);\n") + f.write( + f" TCGv {regtype}{regid}N =3D " + f"tcg_constant_tl({regtype}{regid}N_num);\n" + ) else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 + def genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i): - if (hex_common.is_pair(regid)): + if hex_common.is_pair(regid): genptr_decl(f, tag, regtype, regid, i) - elif (hex_common.is_single(regid)): + elif hex_common.is_single(regid): if hex_common.is_old_val(regtype, regid, tag): - genptr_decl(f,tag, regtype, regid, i) + genptr_decl(f, tag, regtype, regid, i) elif hex_common.is_new_val(regtype, regid, tag): genptr_decl_new(f, tag, regtype, regid, i) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) + =20 -def genptr_decl_imm(f,immlett): - if (immlett.isupper()): +def genptr_decl_imm(f, immlett): + if immlett.isupper(): i =3D 1 else: i =3D 0 f.write(f" int {hex_common.imm_name(immlett)} =3D insn->immed[{i}];= \n") =20 + def genptr_src_read(f, tag, regtype, regid): - if (regtype =3D=3D "R"): - if (regid in {"ss", "tt", "xx", "yy"}): - f.write(f" tcg_gen_concat_i32_i64({regtype}{regid}V, " - f"hex_gpr[{regtype}{regid}N],\n") - f.write(f" hex_gpr[{regtype}" - f"{regid}N + 1]);\n") - elif (regid in {"x", "y"}): + if regtype =3D=3D "R": + if regid in {"ss", "tt", "xx", "yy"}: + f.write( + f" tcg_gen_concat_i32_i64({regtype}{regid}V, " + f"hex_gpr[{regtype}{regid}N],\n" + ) + f.write( + f" hex_gpr[{regtype}" + f"{regid}N + 1]);\n" + ) + elif regid in {"x", "y"}: ## For read/write registers, we need to get the original value= into ## the result TCGv. For conditional instructions, this is don= e in ## gen_start_packet. For unconditional instructions, we do it= here. - if ('A_CONDEXEC' not in hex_common.attribdict[tag]): - f.write(f" tcg_gen_mov_tl({regtype}{regid}V, " - f"hex_gpr[{regtype}{regid}N]);\n") - elif (regid not in {"s", "t", "u", "v"}): + if "A_CONDEXEC" not in hex_common.attribdict[tag]: + f.write( + f" tcg_gen_mov_tl({regtype}{regid}V, " + f"hex_gpr[{regtype}{regid}N]);\n" + ) + elif regid not in {"s", "t", "u", "v"}: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid =3D=3D "x"): - f.write(f" tcg_gen_mov_tl({regtype}{regid}V, " - f"hex_pred[{regtype}{regid}N]);\n") - elif (regid not in {"s", "t", "u", "v"}): + elif regtype =3D=3D "P": + if regid =3D=3D "x": + f.write( + f" tcg_gen_mov_tl({regtype}{regid}V, " + f"hex_pred[{regtype}{regid}N]);\n" + ) + elif regid not in {"s", "t", "u", "v"}: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "C"): - if (regid =3D=3D "ss"): - f.write(f" gen_read_ctrl_reg_pair(ctx, {regtype}{regid}N, " - f"{regtype}{regid}V);\n") - elif (regid =3D=3D "s"): - f.write(f" gen_read_ctrl_reg(ctx, {regtype}{regid}N, " - f"{regtype}{regid}V);\n") + elif regtype =3D=3D "C": + if regid =3D=3D "ss": + f.write( + f" gen_read_ctrl_reg_pair(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n" + ) + elif regid =3D=3D "s": + f.write( + f" gen_read_ctrl_reg(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "M"): - if (regid !=3D "u"): + elif regtype =3D=3D "M": + if regid !=3D "u": print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "V"): - if (regid in {"uu", "vv", "xx"}): + elif regtype =3D=3D "V": + if regid in {"uu", "vv", "xx"}: f.write(f" tcg_gen_gvec_mov(MO_64, {regtype}{regid}V_off,\n= ") f.write(f" vreg_src_off(ctx, {regtype}{regid}N),\n") f.write(" sizeof(MMVector), sizeof(MMVector));\n") @@ -272,147 +300,174 @@ def genptr_src_read(f, tag, regtype, regid): f.write(f" {regtype}{regid}V_off + sizeof(MMVector),\n") f.write(f" vreg_src_off(ctx, {regtype}{regid}N ^ 1),\n") f.write(" sizeof(MMVector), sizeof(MMVector));\n") - elif (regid in {"s", "u", "v", "w"}): - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " - f"{regtype}{regid}V_off);\n") - elif (regid in {"x", "y"}): + elif regid in {"s", "u", "v", "w"}: + if not hex_common.skip_qemu_helper(tag): + f.write( + f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env, " + f"{regtype}{regid}V_off);\n" + ) + elif regid in {"x", "y"}: f.write(f" tcg_gen_gvec_mov(MO_64, {regtype}{regid}V_off,\n= ") f.write(f" vreg_src_off(ctx, {regtype}{regid}N),\n") f.write(" sizeof(MMVector), sizeof(MMVector));\n") else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "Q"): - if (regid in {"s", "t", "u", "v"}): - if (not hex_common.skip_qemu_helper(tag)): - f.write(f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env,= " - f"{regtype}{regid}V_off);\n") - elif (regid in {"x"}): + elif regtype =3D=3D "Q": + if regid in {"s", "t", "u", "v"}: + if not hex_common.skip_qemu_helper(tag): + f.write( + f" tcg_gen_addi_ptr({regtype}{regid}V, cpu_env, " + f"{regtype}{regid}V_off);\n" + ) + elif regid in {"x"}: f.write(f" tcg_gen_gvec_mov(MO_64, {regtype}{regid}V_off,\n= ") - f.write(f" offsetof(CPUHexagonState, " - f"QRegs[{regtype}{regid}N]),\n") + f.write( + f" offsetof(CPUHexagonState, " f"QRegs[{regtype}{re= gid}N]),\n" + ) f.write(" sizeof(MMQReg), sizeof(MMQReg));\n") else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 -def genptr_src_read_new(f,regtype,regid): - if (regtype =3D=3D "N"): - if (regid not in {"s", "t"}): + +def genptr_src_read_new(f, regtype, regid): + if regtype =3D=3D "N": + if regid not in {"s", "t"}: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid not in {"t", "u", "v"}): + elif regtype =3D=3D "P": + if regid not in {"t", "u", "v"}: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "O"): - if (regid !=3D "s"): + elif regtype =3D=3D "O": + if regid !=3D "s": print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 -def genptr_src_read_opn(f,regtype,regid,tag): - if (hex_common.is_pair(regid)): + +def genptr_src_read_opn(f, regtype, regid, tag): + if hex_common.is_pair(regid): genptr_src_read(f, tag, regtype, regid) - elif (hex_common.is_single(regid)): + elif hex_common.is_single(regid): if hex_common.is_old_val(regtype, regid, tag): genptr_src_read(f, tag, regtype, regid) elif hex_common.is_new_val(regtype, regid, tag): - genptr_src_read_new(f,regtype,regid) + genptr_src_read_new(f, regtype, regid) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) + =20 def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i): - if (i > 0): f.write(", ") - if (hex_common.is_pair(regid)): + if i > 0: + f.write(", ") + if hex_common.is_pair(regid): f.write(f"{regtype}{regid}V") - elif (hex_common.is_single(regid)): + elif hex_common.is_single(regid): if hex_common.is_old_val(regtype, regid, tag): f.write(f"{regtype}{regid}V") elif hex_common.is_new_val(regtype, regid, tag): f.write(f"{regtype}{regid}N") else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) =20 -def gen_helper_decl_imm(f,immlett): - f.write(f" TCGv tcgv_{hex_common.imm_name(immlett)} =3D " - f"tcg_constant_tl({hex_common.imm_name(immlett)});\n") =20 -def gen_helper_call_imm(f,immlett): +def gen_helper_decl_imm(f, immlett): + f.write( + f" TCGv tcgv_{hex_common.imm_name(immlett)} =3D " + f"tcg_constant_tl({hex_common.imm_name(immlett)});\n" + ) + + +def gen_helper_call_imm(f, immlett): f.write(f", tcgv_{hex_common.imm_name(immlett)}") =20 + def genptr_dst_write_pair(f, tag, regtype, regid): - f.write(f" gen_log_reg_write_pair({regtype}{regid}N, " - f"{regtype}{regid}V);\n") + f.write(f" gen_log_reg_write_pair({regtype}{regid}N, " f"{regtype}{= regid}V);\n") + =20 def genptr_dst_write(f, tag, regtype, regid): - if (regtype =3D=3D "R"): - if (regid in {"dd", "xx", "yy"}): + if regtype =3D=3D "R": + if regid in {"dd", "xx", "yy"}: genptr_dst_write_pair(f, tag, regtype, regid) - elif (regid in {"d", "e", "x", "y"}): - f.write(f" gen_log_reg_write({regtype}{regid}N, " - f"{regtype}{regid}V);\n") + elif regid in {"d", "e", "x", "y"}: + f.write( + f" gen_log_reg_write({regtype}{regid}N, " f"{regtype}{r= egid}V);\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "P"): - if (regid in {"d", "e", "x"}): - f.write(f" gen_log_pred_write(ctx, {regtype}{regid}N, " - f"{regtype}{regid}V);\n") + elif regtype =3D=3D "P": + if regid in {"d", "e", "x"}: + f.write( + f" gen_log_pred_write(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n" + ) else: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "C"): - if (regid =3D=3D "dd"): - f.write(f" gen_write_ctrl_reg_pair(ctx, {regtype}{regid}N, " - f"{regtype}{regid}V);\n") - elif (regid =3D=3D "d"): - f.write(f" gen_write_ctrl_reg(ctx, {regtype}{regid}N, " - f"{regtype}{regid}V);\n") + elif regtype =3D=3D "C": + if regid =3D=3D "dd": + f.write( + f" gen_write_ctrl_reg_pair(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n" + ) + elif regid =3D=3D "d": + f.write( + f" gen_write_ctrl_reg(ctx, {regtype}{regid}N, " + f"{regtype}{regid}V);\n" + ) else: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 + def genptr_dst_write_ext(f, tag, regtype, regid, newv=3D"EXT_DFL"): - if (regtype =3D=3D "V"): - if (regid in {"xx"}): - f.write(f" gen_log_vreg_write_pair(ctx, {regtype}{regid}V_o= ff, " - f"{regtype}{regid}N, {newv});\n") - elif (regid in {"y"}): - f.write(f" gen_log_vreg_write(ctx, {regtype}{regid}V_off, " - f"{regtype}{regid}N, {newv});\n") - elif (regid not in {"dd", "d", "x"}): + if regtype =3D=3D "V": + if regid in {"xx"}: + f.write( + f" gen_log_vreg_write_pair(ctx, {regtype}{regid}V_off, " + f"{regtype}{regid}N, {newv});\n" + ) + elif regid in {"y"}: + f.write( + f" gen_log_vreg_write(ctx, {regtype}{regid}V_off, " + f"{regtype}{regid}N, {newv});\n" + ) + elif regid not in {"dd", "d", "x"}: print("Bad register parse: ", regtype, regid) - elif (regtype =3D=3D "Q"): - if (regid not in {"d", "e", "x"}): - + elif regtype =3D=3D "Q": + if regid not in {"d", "e", "x"}: print("Bad register parse: ", regtype, regid) else: print("Bad register parse: ", regtype, regid) =20 -def genptr_dst_write_opn(f,regtype, regid, tag): - if (hex_common.is_pair(regid)): - if (hex_common.is_hvx_reg(regtype)): - if (hex_common.is_tmp_result(tag)): + +def genptr_dst_write_opn(f, regtype, regid, tag): + if hex_common.is_pair(regid): + if hex_common.is_hvx_reg(regtype): + if hex_common.is_tmp_result(tag): genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP") else: genptr_dst_write_ext(f, tag, regtype, regid) else: genptr_dst_write(f, tag, regtype, regid) - elif (hex_common.is_single(regid)): - if (hex_common.is_hvx_reg(regtype)): - if (hex_common.is_new_result(tag)): + elif hex_common.is_single(regid): + if hex_common.is_hvx_reg(regtype): + if hex_common.is_new_result(tag): genptr_dst_write_ext(f, tag, regtype, regid, "EXT_NEW") - elif (hex_common.is_tmp_result(tag)): + elif hex_common.is_tmp_result(tag): genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP") else: genptr_dst_write_ext(f, tag, regtype, regid, "EXT_DFL") else: genptr_dst_write(f, tag, regtype, regid) else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numregs) + =20 ## ## Generate the TCG code to call the helper @@ -437,57 +492,59 @@ def genptr_dst_write_opn(f,regtype, regid, tag): ## def gen_tcg_func(f, tag, regs, imms): f.write(f"static void generate_{tag}(DisasContext *ctx)\n") - f.write('{\n') + f.write("{\n") =20 f.write(" Insn *insn __attribute__((unused)) =3D ctx->insn;\n") =20 - if hex_common.need_ea(tag): gen_decl_ea_tcg(f, tag) - i=3D0 + if hex_common.need_ea(tag): + gen_decl_ea_tcg(f, tag) + i =3D 0 ## Declare all the operands (regs and immediates) - for regtype,regid,toss,numregs in regs: + for regtype, regid, toss, numregs in regs: genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i) i +=3D 1 - for immlett,bits,immshift in imms: - genptr_decl_imm(f,immlett) + for immlett, bits, immshift in imms: + genptr_decl_imm(f, immlett) =20 - if 'A_PRIV' in hex_common.attribdict[tag]: - f.write(' fCHECKFORPRIV();\n') - if 'A_GUEST' in hex_common.attribdict[tag]: - f.write(' fCHECKFORGUEST();\n') + if "A_PRIV" in hex_common.attribdict[tag]: + f.write(" fCHECKFORPRIV();\n") + if "A_GUEST" in hex_common.attribdict[tag]: + f.write(" fCHECKFORGUEST();\n") =20 ## Read all the inputs - for regtype,regid,toss,numregs in regs: - if (hex_common.is_read(regid)): - genptr_src_read_opn(f,regtype,regid,tag) + for regtype, regid, toss, numregs 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: - if (hex_common.is_pair(regid) - or (hex_common.is_single(regid) - and hex_common.is_old_val(regtype, regid, tag))): + for regtype, regid, toss, numregs in regs: + if hex_common.is_pair(regid) or ( + hex_common.is_single(regid) + and hex_common.is_old_val(regtype, regid, tag) + ): declared.append(f"{regtype}{regid}V") if regtype =3D=3D "M": declared.append(f"{regtype}{regid}N") elif hex_common.is_new_val(regtype, regid, tag): declared.append(f"{regtype}{regid}N") else: - print("Bad register parse: ",regtype,regid,toss,numregs) + print("Bad register parse: ", regtype, regid, toss, numreg= s) =20 ## Handle immediates - for immlett,bits,immshift in imms: + for immlett, bits, immshift in imms: declared.append(hex_common.imm_name(immlett)) =20 arguments =3D ", ".join(["ctx", "ctx->insn", "ctx->pkt"] + declare= d) f.write(f" emit_{tag}({arguments});\n") =20 - elif ( hex_common.skip_qemu_helper(tag) ): + elif hex_common.skip_qemu_helper(tag): f.write(f" fGEN_TCG_{tag}({hex_common.semdict[tag]});\n") else: ## Generate the call to the helper - for immlett,bits,immshift in imms: - gen_helper_decl_imm(f,immlett) + for immlett, bits, immshift in imms: + gen_helper_decl_imm(f, immlett) if hex_common.need_pkt_has_multi_cof(tag): f.write(" TCGv pkt_has_multi_cof =3D ") f.write("tcg_constant_tl(ctx->pkt->pkt_has_multi_cof);\n") @@ -500,62 +557,68 @@ def gen_tcg_func(f, tag, regs, imms): if hex_common.helper_needs_next_PC(tag): f.write(" TCGv next_PC =3D tcg_constant_tl(ctx->next_PC);\n= ") f.write(f" gen_helper_{tag}(") - i=3D0 + i =3D 0 ## If there is a scalar result, it is the return type - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - if (hex_common.is_hvx_reg(regtype)): + for regtype, regid, toss, numregs 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) i +=3D 1 - if (i > 0): f.write(", ") + if i > 0: + f.write(", ") f.write("cpu_env") - i=3D1 + i =3D 1 ## For conditional instructions, we pass in the destination regist= er - if 'A_CONDEXEC' in hex_common.attribdict[tag]: + if "A_CONDEXEC" in hex_common.attribdict[tag]: for regtype, regid, toss, numregs in regs: - if (hex_common.is_writeonly(regid) and - not hex_common.is_hvx_reg(regtype)): - gen_helper_call_opn(f, tag, regtype, regid, toss, \ - numregs, i) + 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) i +=3D 1 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - if (not hex_common.is_hvx_reg(regtype)): + for regtype, regid, toss, numregs 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) i +=3D 1 - for regtype,regid,toss,numregs in regs: - if (hex_common.is_read(regid)): - if (hex_common.is_hvx_reg(regtype) and - hex_common.is_readwrite(regid)): + for regtype, regid, toss, numregs 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) i +=3D 1 - for immlett,bits,immshift in imms: - gen_helper_call_imm(f,immlett) + for immlett, bits, immshift in imms: + gen_helper_call_imm(f, immlett) =20 if hex_common.need_pkt_has_multi_cof(tag): f.write(", pkt_has_multi_cof") - if hex_common.need_PC(tag): f.write(", PC") - if hex_common.helper_needs_next_PC(tag): f.write(", next_PC") - if hex_common.need_slot(tag): f.write(", slot") - if hex_common.need_part1(tag): f.write(", part1" ) + if hex_common.need_PC(tag): + f.write(", PC") + if hex_common.helper_needs_next_PC(tag): + f.write(", next_PC") + if hex_common.need_slot(tag): + f.write(", slot") + if hex_common.need_part1(tag): + f.write(", part1") f.write(");\n") =20 ## Write all the outputs - for regtype,regid,toss,numregs in regs: - if (hex_common.is_written(regid)): - genptr_dst_write_opn(f,regtype, regid, tag) + for regtype, regid, toss, numregs in regs: + if hex_common.is_written(regid): + genptr_dst_write_opn(f, regtype, regid, tag) =20 f.write("}\n\n") =20 + def gen_def_tcg_func(f, tag, tagregs, tagimms): regs =3D tagregs[tag] imms =3D tagimms[tag] =20 gen_tcg_func(f, tag, regs, imms) =20 + def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) @@ -578,30 +641,31 @@ def main(): tagimms =3D hex_common.get_tagimms() =20 output_file =3D sys.argv[-1] - with open(output_file, 'w') as f: + with open(output_file, "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: - f.write("#include \"idef-generated-emitter.h.inc\"\n\n") + f.write('#include "idef-generated-emitter.h.inc"\n\n') =20 for tag in hex_common.tags: ## Skip the priv instructions - if ( "A_PRIV" in hex_common.attribdict[tag] ) : + if "A_PRIV" in hex_common.attribdict[tag]: continue ## Skip the guest instructions - if ( "A_GUEST" in hex_common.attribdict[tag] ) : + if "A_GUEST" in hex_common.attribdict[tag]: continue ## Skip the diag instructions - if ( tag =3D=3D "Y6_diag" ) : + if tag =3D=3D "Y6_diag": continue - if ( tag =3D=3D "Y6_diag0" ) : + if tag =3D=3D "Y6_diag0": continue - if ( tag =3D=3D "Y6_diag1" ) : + if tag =3D=3D "Y6_diag1": continue =20 gen_def_tcg_func(f, tag, tagregs, tagimms) =20 f.write("#endif /* HEXAGON_TCG_FUNCS_H */\n") =20 + if __name__ =3D=3D "__main__": main() diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index 9f9da81e20..40f28ca933 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -21,14 +21,15 @@ import re import string =20 -behdict =3D {} # tag ->behavior -semdict =3D {} # tag -> semantics -attribdict =3D {} # tag -> attributes -macros =3D {} # macro -> macro information... -attribinfo =3D {} # Register information and misc -tags =3D [] # list of all tags -overrides =3D {} # tags with helper overrides -idef_parser_enabled =3D {} # tags enabled for idef-parser +behdict =3D {} # tag ->behavior +semdict =3D {} # tag -> semantics +attribdict =3D {} # tag -> attributes +macros =3D {} # macro -> macro information... +attribinfo =3D {} # Register information and misc +tags =3D [] # list of all tags +overrides =3D {} # tags with helper overrides +idef_parser_enabled =3D {} # tags enabled for idef-parser + =20 # We should do this as a hash for performance, # but to keep order let's keep it as a list. @@ -37,71 +38,77 @@ def uniquify(seq): seen_add =3D seen.add return [x for x in seq if x not in seen and not seen_add(x)] =20 -regre =3D re.compile( - r"((?") - macro.attribs |=3D expand_macro_attribs( - macros[submacro], allmac_re) + macro.attribs |=3D expand_macro_attribs(macros[submacro], allm= ac_re) finished_macros.add(macro.key) return macro.attribs =20 + # When qemu needs an attribute that isn't in the imported files, # we'll add it here. def add_qemu_macro_attrib(name, attrib): macros[name].attribs.add(attrib) =20 -immextre =3D re.compile(r'f(MUST_)?IMMEXT[(]([UuSsRr])') + +immextre =3D re.compile(r"f(MUST_)?IMMEXT[(]([UuSsRr])") + =20 def is_cond_jump(tag): - if tag =3D=3D 'J2_rte': + if tag =3D=3D "J2_rte": return False - if ('A_HWLOOP0_END' in attribdict[tag] or - 'A_HWLOOP1_END' in attribdict[tag]): + if "A_HWLOOP0_END" in attribdict[tag] or "A_HWLOOP1_END" in attribdict= [tag]: return False - return \ - re.compile(r"(if.*fBRANCH)|(if.*fJUMPR)").search(semdict[tag]) != =3D None + return re.compile(r"(if.*fBRANCH)|(if.*fJUMPR)").search(semdict[tag]) = !=3D None + =20 def is_cond_call(tag): return re.compile(r"(if.*fCALL)").search(semdict[tag]) !=3D None =20 + def calculate_attribs(): - add_qemu_macro_attrib('fREAD_PC', 'A_IMPLICIT_READS_PC') - add_qemu_macro_attrib('fTRAP', 'A_IMPLICIT_READS_PC') - add_qemu_macro_attrib('fWRITE_P0', 'A_WRITES_PRED_REG') - add_qemu_macro_attrib('fWRITE_P1', 'A_WRITES_PRED_REG') - add_qemu_macro_attrib('fWRITE_P2', 'A_WRITES_PRED_REG') - add_qemu_macro_attrib('fWRITE_P3', 'A_WRITES_PRED_REG') - add_qemu_macro_attrib('fSET_OVERFLOW', 'A_IMPLICIT_WRITES_USR') - add_qemu_macro_attrib('fSET_LPCFG', 'A_IMPLICIT_WRITES_USR') - add_qemu_macro_attrib('fLOAD', 'A_SCALAR_LOAD') - add_qemu_macro_attrib('fSTORE', 'A_SCALAR_STORE') + add_qemu_macro_attrib("fREAD_PC", "A_IMPLICIT_READS_PC") + add_qemu_macro_attrib("fTRAP", "A_IMPLICIT_READS_PC") + add_qemu_macro_attrib("fWRITE_P0", "A_WRITES_PRED_REG") + add_qemu_macro_attrib("fWRITE_P1", "A_WRITES_PRED_REG") + add_qemu_macro_attrib("fWRITE_P2", "A_WRITES_PRED_REG") + add_qemu_macro_attrib("fWRITE_P3", "A_WRITES_PRED_REG") + add_qemu_macro_attrib("fSET_OVERFLOW", "A_IMPLICIT_WRITES_USR") + add_qemu_macro_attrib("fSET_LPCFG", "A_IMPLICIT_WRITES_USR") + add_qemu_macro_attrib("fLOAD", "A_SCALAR_LOAD") + add_qemu_macro_attrib("fSTORE", "A_SCALAR_STORE") =20 # Recurse down macros, find attributes from sub-macros macroValues =3D list(macros.values()) - allmacros_restr =3D "|".join(set([ m.re.pattern for m in macroValues ]= )) + allmacros_restr =3D "|".join(set([m.re.pattern for m in macroValues])) allmacros_re =3D re.compile(allmacros_restr) for macro in macroValues: - expand_macro_attribs(macro,allmacros_re) + expand_macro_attribs(macro, allmacros_re) # Append attributes to all instructions for tag in tags: for macname in allmacros_re.findall(semdict[tag]): - if not macname: continue + if not macname: + continue macro =3D macros[macname] attribdict[tag] |=3D set(macro.attribs) # Figure out which instructions write predicate registers @@ -110,31 +117,34 @@ def calculate_attribs(): regs =3D tagregs[tag] for regtype, regid, toss, numregs in regs: if regtype =3D=3D "P" and is_written(regid): - attribdict[tag].add('A_WRITES_PRED_REG') + attribdict[tag].add("A_WRITES_PRED_REG") # Mark conditional jumps and calls # Not all instructions are properly marked with A_CONDEXEC for tag in tags: if is_cond_jump(tag) or is_cond_call(tag): - attribdict[tag].add('A_CONDEXEC') + attribdict[tag].add("A_CONDEXEC") + =20 def SEMANTICS(tag, beh, sem): - #print tag,beh,sem + # print tag,beh,sem behdict[tag] =3D beh semdict[tag] =3D sem attribdict[tag] =3D set() - tags.append(tag) # dicts have no order, this is for order + tags.append(tag) # dicts have no order, this is for order + =20 def ATTRIBUTES(tag, attribstring): - attribstring =3D \ - attribstring.replace("ATTRIBS","").replace("(","").replace(")","") + attribstring =3D attribstring.replace("ATTRIBS", "").replace("(", "").= replace(")", "") if not attribstring: return attribs =3D attribstring.split(",") for attrib in attribs: attribdict[tag].add(attrib.strip()) =20 + class Macro(object): - __slots__ =3D ['key','name', 'beh', 'attribs', 're'] + __slots__ =3D ["key", "name", "beh", "attribs", "re"] + def __init__(self, name, beh, attribs): self.key =3D name self.name =3D name @@ -142,20 +152,24 @@ def __init__(self, name, beh, attribs): self.attribs =3D set(attribs) self.re =3D re.compile("\\b" + name + "\\b") =20 -def MACROATTRIB(macname,beh,attribstring): - attribstring =3D attribstring.replace("(","").replace(")","") + +def MACROATTRIB(macname, beh, attribstring): + attribstring =3D attribstring.replace("(", "").replace(")", "") if attribstring: attribs =3D attribstring.split(",") else: attribs =3D [] - macros[macname] =3D Macro(macname,beh,attribs) + macros[macname] =3D Macro(macname, beh, attribs) + =20 def compute_tag_regs(tag): return uniquify(regre.findall(behdict[tag])) =20 + def compute_tag_immediates(tag): return uniquify(immre.findall(behdict[tag])) =20 + ## ## tagregs is the main data structure we'll use ## tagregs[tag] will contain the registers used by an instruction @@ -180,89 +194,113 @@ def compute_tag_immediates(tag): def get_tagregs(): return dict(zip(tags, list(map(compute_tag_regs, tags)))) =20 + def get_tagimms(): return dict(zip(tags, list(map(compute_tag_immediates, tags)))) =20 + def is_pair(regid): return len(regid) =3D=3D 2 =20 + def is_single(regid): return len(regid) =3D=3D 1 =20 + def is_written(regid): return regid[0] in "dexy" =20 + def is_writeonly(regid): return regid[0] in "de" =20 + def is_read(regid): return regid[0] in "stuvwxy" =20 + def is_readwrite(regid): return regid[0] in "xy" =20 + def is_scalar_reg(regtype): return regtype in "RPC" =20 + def is_hvx_reg(regtype): return regtype in "VQ" =20 + def is_old_val(regtype, regid, tag): - return regtype+regid+'V' in semdict[tag] + return regtype + regid + "V" in semdict[tag] + =20 def is_new_val(regtype, regid, tag): - return regtype+regid+'N' in semdict[tag] + return regtype + regid + "N" in semdict[tag] + =20 def need_slot(tag): - if (('A_CONDEXEC' in attribdict[tag] and - 'A_JUMP' not in attribdict[tag]) or - 'A_STORE' in attribdict[tag] or - 'A_LOAD' in attribdict[tag]): + if ( + ("A_CONDEXEC" in attribdict[tag] and "A_JUMP" not in attribdict[ta= g]) + or "A_STORE" in attribdict[tag] + or "A_LOAD" in attribdict[tag] + ): return 1 else: return 0 =20 + def need_part1(tag): return re.compile(r"fPART1").search(semdict[tag]) =20 + def need_ea(tag): return re.compile(r"\bEA\b").search(semdict[tag]) =20 + def need_PC(tag): - return 'A_IMPLICIT_READS_PC' in attribdict[tag] + return "A_IMPLICIT_READS_PC" in attribdict[tag] + =20 def helper_needs_next_PC(tag): - return 'A_CALL' in attribdict[tag] + return "A_CALL" in attribdict[tag] + =20 def need_pkt_has_multi_cof(tag): - return 'A_COF' in attribdict[tag] + return "A_COF" in attribdict[tag] + =20 def need_condexec_reg(tag, regs): - if 'A_CONDEXEC' in attribdict[tag]: + if "A_CONDEXEC" in attribdict[tag]: for regtype, regid, toss, numregs in regs: if is_writeonly(regid) and not is_hvx_reg(regtype): return True return False =20 + def skip_qemu_helper(tag): return tag in overrides.keys() =20 + def is_tmp_result(tag): - return ('A_CVI_TMP' in attribdict[tag] or - 'A_CVI_TMP_DST' in attribdict[tag]) + return "A_CVI_TMP" in attribdict[tag] or "A_CVI_TMP_DST" in attribdict= [tag] + =20 def is_new_result(tag): - return ('A_CVI_NEW' in attribdict[tag]) + return "A_CVI_NEW" in attribdict[tag] + =20 def is_idef_parser_enabled(tag): return tag in idef_parser_enabled =20 + def imm_name(immlett): return f"{immlett}iV" =20 + def read_semantics_file(name): eval_line =3D "" - for line in open(name, 'rt').readlines(): + for line in open(name, "rt").readlines(): if not line.startswith("#"): eval_line +=3D line if line.endswith("\\\n"): @@ -271,24 +309,29 @@ def read_semantics_file(name): eval(eval_line.strip()) eval_line =3D "" =20 + def read_attribs_file(name): - attribre =3D re.compile(r'DEF_ATTRIB\(([A-Za-z0-9_]+), ([^,]*), ' + - r'"([A-Za-z0-9_\.]*)", "([A-Za-z0-9_\.]*)"\)') - for line in open(name, 'rt').readlines(): + attribre =3D re.compile( + r"DEF_ATTRIB\(([A-Za-z0-9_]+), ([^,]*), " + + r'"([A-Za-z0-9_\.]*)", "([A-Za-z0-9_\.]*)"\)' + ) + for line in open(name, "rt").readlines(): if not attribre.match(line): continue - (attrib_base,descr,rreg,wreg) =3D attribre.findall(line)[0] - attrib_base =3D 'A_' + attrib_base - attribinfo[attrib_base] =3D {'rreg':rreg, 'wreg':wreg, 'descr':des= cr} + (attrib_base, descr, rreg, wreg) =3D attribre.findall(line)[0] + attrib_base =3D "A_" + attrib_base + attribinfo[attrib_base] =3D {"rreg": rreg, "wreg": wreg, "descr": = descr} + =20 def read_overrides_file(name): overridere =3D re.compile("#define fGEN_TCG_([A-Za-z0-9_]+)\(.*") - for line in open(name, 'rt').readlines(): + for line in open(name, "rt").readlines(): if not overridere.match(line): continue tag =3D overridere.findall(line)[0] overrides[tag] =3D True =20 + def read_idef_parser_enabled_file(name): global idef_parser_enabled with open(name, "r") as idef_parser_enabled_file: --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961298; cv=none; d=zohomail.com; s=zohoarc; b=Jwry4rTwDAYZ8ufqdK+Ywka3AZnCSf6ghhm6eFpOzFChRiFdQxnACY4XIQ88DwAVkby35nPFMKiWDaqlXnalSTLoOQjQwb+AXKO1hYEfXJ/5xnwcU7gEIIbDUWmWTCZgJaKSptevZy7Iny2ia/DswydCoSMA/byEWnPf43YLTQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961298; h=Content-Type: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=pKSrlFYRbLdxYJGeJk4mWIGB6tb1tgJms1So1hTf/Vg=; b=nlIuZbOC+P3XnZw+CIpGNcSecv2E1ulOQfR7793aC0CNi13Ee56OasfEfSZ3iX5tUxF7Uzdkm2teV6V9TGpyild49ZyjIah6eTARZk2qLhCPiZFp6FdohEA2SC9Pq/5QKC8VNrPbrvCIQjgg3Du2zmVQU1eRgHU/U7rUGIxMhwQ= 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 1681961298572164.67121330037003; Wed, 19 Apr 2023 20:28:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwr-0003gz-SG; Wed, 19 Apr 2023 23:27:05 -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 1ppKwl-0003g1-5p for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:59 -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 1ppKwh-0000Ia-A7 for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -0400 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K0sgfI006637; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2p4v8ss3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: from pps.filterd (NALASPPMTA01.qualcomm.com [127.0.0.1]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3QU23003841; Thu, 20 Apr 2023 03:26:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA01.qualcomm.com (PPS) with ESMTPS id 3q2ax2nv0u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: from NALASPPMTA01.qualcomm.com (NALASPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3QlQV004392; Thu, 20 Apr 2023 03:26:47 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA01.qualcomm.com (PPS) with ESMTPS id 33K3QlIj004387 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:47 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 047C868E; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=pKSrlFYRbLdxYJGeJk4mWIGB6tb1tgJms1So1hTf/Vg=; b=Y+U5PAEqLtRQJ5e2RG57pss8a8B2dSVcAiAy6ng6uMwobGZuWT37acRU3a+HYbi7W13L eoM771dUDI+7hdOeZ6SMBkrXl3tz9anVCTTaRkp5SU4mI5fm0WmVEl+0LtFrETu8u44t sabV/ZMAyEimcCu+bbXoUWuPkBblgaZfX3EVFO8NFr7sykuzIhvbXtyvPmB063EBhoqS kLylA8jXYEof90ZQ/9BMZGBCvaO8LpJSkuAyQMfz0J+tTZ/mPgCnwJIJUm5+gAAKHdLA RX8o8JwENrnNZYVPEFWRswJw4RyXm2MZ1XOW3Do86giCtoSguje4TRbA6a3yueub1bgZ Rg== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 04/11] Hexagon (target/hexagon) Remove redundant/unused macros Date: Wed, 19 Apr 2023 20:26:27 -0700 Message-Id: <20230420032634.105311-5-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: JTKmZlzSzNlgayYN3hhlmVec0QuejQ4B X-Proofpoint-ORIG-GUID: JTKmZlzSzNlgayYN3hhlmVec0QuejQ4B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 mlxlogscore=423 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961299425100013 Remove the following macros (remnants of the old generator design) READ_REG READ_PREG WRITE_RREG WRITE_PREG Modify macros that rely on the above The following are unused READ_IREG fGET_FIELD fSET_FIELD fREAD_P3 fREAD_NPC fWRITE_LC0 fWRITE_LC1 Signed-off-by: Taylor Simpson Reviewed-by: Richard Henderson Message-Id: <20230405183048.147767-1-tsimpson@quicinc.com> --- target/hexagon/macros.h | 65 ++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index 482a9c787f..f5f31b6930 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -22,16 +22,6 @@ #include "hex_regs.h" #include "reg_fields.h" =20 -#ifdef QEMU_GENERATE -#define READ_REG(dest, NUM) gen_read_reg(dest, NUM) -#else -#define READ_REG(NUM) (env->gpr[(NUM)]) -#define READ_PREG(NUM) (env->pred[NUM]) - -#define WRITE_RREG(NUM, VAL) log_reg_write(env, NUM, VAL, slot) -#define WRITE_PREG(NUM, VAL) log_pred_write(env, NUM, VAL) -#endif - #define PCALIGN 4 #define PCALIGN_MASK (PCALIGN - 1) =20 @@ -361,37 +351,30 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv va= l, int shift) tcg_gen_shli_tl(result, result, shift); return result; } -#define fREAD_IREG(VAL, SHIFT) gen_read_ireg(ireg, (VAL), (SHIFT)) -#else -#define fREAD_IREG(VAL) \ - (fSXTN(11, 64, (((VAL) & 0xf0000000) >> 21) | ((VAL >> 17) & 0x7f))) #endif =20 -#define fREAD_LR() (READ_REG(HEX_REG_LR)) +#define fREAD_LR() (env->gpr[HEX_REG_LR]) =20 -#define fWRITE_LR(A) WRITE_RREG(HEX_REG_LR, A) -#define fWRITE_FP(A) WRITE_RREG(HEX_REG_FP, A) -#define fWRITE_SP(A) WRITE_RREG(HEX_REG_SP, A) +#define fWRITE_LR(A) log_reg_write(env, HEX_REG_LR, A, slot) +#define fWRITE_FP(A) log_reg_write(env, HEX_REG_FP, A, slot) +#define fWRITE_SP(A) log_reg_write(env, HEX_REG_SP, A, slot) =20 -#define fREAD_SP() (READ_REG(HEX_REG_SP)) -#define fREAD_LC0 (READ_REG(HEX_REG_LC0)) -#define fREAD_LC1 (READ_REG(HEX_REG_LC1)) -#define fREAD_SA0 (READ_REG(HEX_REG_SA0)) -#define fREAD_SA1 (READ_REG(HEX_REG_SA1)) -#define fREAD_FP() (READ_REG(HEX_REG_FP)) +#define fREAD_SP() (env->gpr[HEX_REG_SP]) +#define fREAD_LC0 (env->gpr[HEX_REG_LC0]) +#define fREAD_LC1 (env->gpr[HEX_REG_LC1]) +#define fREAD_SA0 (env->gpr[HEX_REG_SA0]) +#define fREAD_SA1 (env->gpr[HEX_REG_SA1]) +#define fREAD_FP() (env->gpr[HEX_REG_FP]) #ifdef FIXME /* Figure out how to get insn->extension_valid to helper */ #define fREAD_GP() \ - (insn->extension_valid ? 0 : READ_REG(HEX_REG_GP)) + (insn->extension_valid ? 0 : env->gpr[HEX_REG_GP]) #else -#define fREAD_GP() READ_REG(HEX_REG_GP) +#define fREAD_GP() (env->gpr[HEX_REG_GP]) #endif #define fREAD_PC() (PC) =20 -#define fREAD_NPC() (next_PC & (0xfffffffe)) - -#define fREAD_P0() (READ_PREG(0)) -#define fREAD_P3() (READ_PREG(3)) +#define fREAD_P0() (env->pred[0]) =20 #define fCHECK_PCALIGN(A) =20 @@ -402,24 +385,22 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv va= l, int shift) #define fHINTJR(TARGET) { /* Not modelled in qemu */} #define fWRITE_LOOP_REGS0(START, COUNT) \ do { \ - WRITE_RREG(HEX_REG_LC0, COUNT); \ - WRITE_RREG(HEX_REG_SA0, START); \ + log_reg_write(env, HEX_REG_LC0, COUNT, slot); \ + log_reg_write(env, HEX_REG_SA0, START, slot); \ } while (0) #define fWRITE_LOOP_REGS1(START, COUNT) \ do { \ - WRITE_RREG(HEX_REG_LC1, COUNT); \ - WRITE_RREG(HEX_REG_SA1, START);\ + log_reg_write(env, HEX_REG_LC1, COUNT, slot); \ + log_reg_write(env, HEX_REG_SA1, START, slot);\ } while (0) -#define fWRITE_LC0(VAL) WRITE_RREG(HEX_REG_LC0, VAL) -#define fWRITE_LC1(VAL) WRITE_RREG(HEX_REG_LC1, VAL) =20 #define fSET_OVERFLOW() SET_USR_FIELD(USR_OVF, 1) #define fSET_LPCFG(VAL) SET_USR_FIELD(USR_LPCFG, (VAL)) #define fGET_LPCFG (GET_USR_FIELD(USR_LPCFG)) -#define fWRITE_P0(VAL) WRITE_PREG(0, VAL) -#define fWRITE_P1(VAL) WRITE_PREG(1, VAL) -#define fWRITE_P2(VAL) WRITE_PREG(2, VAL) -#define fWRITE_P3(VAL) WRITE_PREG(3, VAL) +#define fWRITE_P0(VAL) log_pred_write(env, 0, VAL) +#define fWRITE_P1(VAL) log_pred_write(env, 1, VAL) +#define fWRITE_P2(VAL) log_pred_write(env, 2, VAL) +#define fWRITE_P3(VAL) log_pred_write(env, 3, VAL) #define fPART1(WORK) if (part1) { WORK; return; } #define fCAST4u(A) ((uint32_t)(A)) #define fCAST4s(A) ((int32_t)(A)) @@ -576,7 +557,7 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val,= int shift) =20 #define fMEMOP(NUM, SIZE, SIGN, EA, FNTYPE, VALUE) =20 -#define fGET_FRAMEKEY() READ_REG(HEX_REG_FRAMEKEY) +#define fGET_FRAMEKEY() (env->gpr[HEX_REG_FRAMEKEY]) #define fFRAME_SCRAMBLE(VAL) ((VAL) ^ (fCAST8u(fGET_FRAMEKEY()) << 32)) #define fFRAME_UNSCRAMBLE(VAL) fFRAME_SCRAMBLE(VAL) =20 @@ -686,8 +667,6 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val,= int shift) fEXTRACTU_BITS(env->gpr[HEX_REG_##REG], \ reg_field_info[FIELD].width, \ reg_field_info[FIELD].offset) -#define fGET_FIELD(VAL, FIELD) -#define fSET_FIELD(VAL, FIELD, NEWVAL) #define fBARRIER() #define fSYNCH() #define fISYNC() --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961296; cv=none; d=zohomail.com; s=zohoarc; b=A3lQeTEpYaVhQ/G739KzHrNPM6d25ZaMJn29mk2Dx5c0ks9RnosvBE/QYznj1CRtHemoENobtkUP0N1up3NCBJnIHMqJWktu33OW0enTmLh2fXicgOCX3oANvjwwN/tJRuVGuW8cDKYq6QmbiClm7BTz5GNRD8JwH1+NEbxVv/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961296; h=Content-Type: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=FHe3f44LkutvmBXvMJkNPAZxuo0lFYUsVll1B1Hg3HA=; b=CNDvy1EPQBJVOqwhyMnR2mDgtkXZMsOJQPxf4vVAOqHahnnavMdiTqRpzVpv6G26ifbw0S9Xlee6nZBV+O6f1Z1/vhNwkJcgY1YExkfd4xw5szNalGQt6b4T1Y1A6l4pt4DRutP0+IDhS/08EgEMXzMsjuJOLvWTawBtiko1vus= 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 1681961296869330.0911893078379; Wed, 19 Apr 2023 20:28:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwk-0003fQ-K7; Wed, 19 Apr 2023 23:26: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 1ppKwi-0003fG-5R for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26: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 1ppKwf-0000Ie-Ev for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:55 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K2xpbt030151; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2ryq0equ-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +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 33K3QmIb010564; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 3q1ubj2gva-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +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 33K3P0WF008749; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 33K3QlT0010550 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 0716568F; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-type : content-transfer-encoding; s=qcppdkim1; bh=FHe3f44LkutvmBXvMJkNPAZxuo0lFYUsVll1B1Hg3HA=; b=B8HojqSpVKeqwB56VMyIP8/U2cncqCJvseIG3CWYxA3l0MOEckoqlt+nhwmGbDm92onO MVZAkaSuT63hyFs67REZwY3YoO+APmBlBiXq/syNtacrWRd0FWhw7hTEVWYYDns1o5KW oXKzHcJJBfg7GbtAFgHyFPWrgaSUMqRQ9ca718kar3FAAuTCWbxIcqoJWs7UTrVlgR0+ /6AccvySFN3w77cPNO9jOM6T976aqOLm17Lw162FmSDVGuP3vBkIf6uVaGl8QE+Y+Syb QV/IQsLtPoTq5CCwcuMkuiN+4z8IB2F/RwYtoL4DVwQ23NeKmslChT4TjRfxGsO6eiGh DA== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 05/11] Hexagon (target/hexagon) Merge arguments to probe_pkt_scalar_hvx_stores Date: Wed, 19 Apr 2023 20:26:28 -0700 Message-Id: <20230420032634.105311-6-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> 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: qU_g8N0upaL4Ue2D73LmnolFXR2SOfLo X-Proofpoint-GUID: qU_g8N0upaL4Ue2D73LmnolFXR2SOfLo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=518 lowpriorityscore=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961298172100011 Content-Type: text/plain; charset="utf-8" Reducing the number of arguments reduces the overhead of the helper call Signed-off-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230405164211.30015-2-tsimpson@quicinc.com> --- target/hexagon/helper.h | 4 ++-- target/hexagon/translate.h | 1 + target/hexagon/op_helper.c | 4 ++-- target/hexagon/translate.c | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h index 368f0b5708..ed7f9842f6 100644 --- a/target/hexagon/helper.h +++ b/target/hexagon/helper.h @@ -1,5 +1,5 @@ /* - * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,4 +107,4 @@ DEF_HELPER_2(vwhist128qm, void, env, s32) DEF_HELPER_4(probe_noshuf_load, void, env, i32, int, int) DEF_HELPER_2(probe_pkt_scalar_store_s0, void, env, int) DEF_HELPER_2(probe_hvx_stores, void, env, int) -DEF_HELPER_3(probe_pkt_scalar_hvx_stores, void, env, int, int) +DEF_HELPER_2(probe_pkt_scalar_hvx_stores, void, env, int) diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h index db832b0f88..4b9f21c41d 100644 --- a/target/hexagon/translate.h +++ b/target/hexagon/translate.h @@ -178,5 +178,6 @@ FIELD(PROBE_PKT_SCALAR_HVX_STORES, HAS_ST1, 1, 1) FIELD(PROBE_PKT_SCALAR_HVX_STORES, HAS_HVX_STORES, 2, 1) FIELD(PROBE_PKT_SCALAR_HVX_STORES, S0_IS_PRED, 3, 1) FIELD(PROBE_PKT_SCALAR_HVX_STORES, S1_IS_PRED, 4, 1) +FIELD(PROBE_PKT_SCALAR_HVX_STORES, MMU_IDX, 5, 2) =20 #endif diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index c9a156030e..099c111a8c 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -488,8 +488,7 @@ void HELPER(probe_hvx_stores)(CPUHexagonState *env, int= mmu_idx) } } =20 -void HELPER(probe_pkt_scalar_hvx_stores)(CPUHexagonState *env, int mask, - int mmu_idx) +void HELPER(probe_pkt_scalar_hvx_stores)(CPUHexagonState *env, int mask) { bool has_st0 =3D FIELD_EX32(mask, PROBE_PKT_SCALAR_HVX_STORES, HAS_ST0= ); bool has_st1 =3D FIELD_EX32(mask, PROBE_PKT_SCALAR_HVX_STORES, HAS_ST1= ); @@ -497,6 +496,7 @@ void HELPER(probe_pkt_scalar_hvx_stores)(CPUHexagonStat= e *env, int mask, FIELD_EX32(mask, PROBE_PKT_SCALAR_HVX_STORES, HAS_HVX_STORES); bool s0_is_pred =3D FIELD_EX32(mask, PROBE_PKT_SCALAR_HVX_STORES, S0_I= S_PRED); bool s1_is_pred =3D FIELD_EX32(mask, PROBE_PKT_SCALAR_HVX_STORES, S1_I= S_PRED); + int mmu_idx =3D FIELD_EX32(mask, PROBE_PKT_SCALAR_HVX_STORES, MMU_IDX); =20 if (has_st0) { probe_store(env, 0, mmu_idx, s0_is_pred); diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 58d638f734..c087f183d0 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -808,13 +808,11 @@ static void gen_commit_packet(DisasContext *ctx) g_assert(!has_store_s1 && !has_hvx_store); process_dczeroa(ctx); } else if (has_hvx_store) { - TCGv mem_idx =3D tcg_constant_tl(ctx->mem_idx); - if (!has_store_s0 && !has_store_s1) { + TCGv mem_idx =3D tcg_constant_tl(ctx->mem_idx); gen_helper_probe_hvx_stores(cpu_env, mem_idx); } else { int mask =3D 0; - TCGv mask_tcgv; =20 if (has_store_s0) { mask =3D @@ -839,8 +837,10 @@ static void gen_commit_packet(DisasContext *ctx) FIELD_DP32(mask, PROBE_PKT_SCALAR_HVX_STORES, S1_IS_PRED, 1); } - mask_tcgv =3D tcg_constant_tl(mask); - gen_helper_probe_pkt_scalar_hvx_stores(cpu_env, mask_tcgv, mem= _idx); + mask =3D FIELD_DP32(mask, PROBE_PKT_SCALAR_HVX_STORES, MMU_IDX, + ctx->mem_idx); + gen_helper_probe_pkt_scalar_hvx_stores(cpu_env, + tcg_constant_tl(mask)); } } else if (has_store_s0 && has_store_s1) { /* --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961310; cv=none; d=zohomail.com; s=zohoarc; b=dzkGBs4JyCIJtT6BACn3Xb5IlMneLxM9JVz2IhtiDCoTZNF2uHGtMoI5Q2JRBjAHgm3JQQXMs7Bxfjgd92pb28BiVNA+MWAX8riSl/PduDkoi2ICaT8tfepRgAGBGFuyjkTm9cvMgPW0fQuifIuFMlbMB6AxuQO2Z+SeGjrgVKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961310; h=Content-Type: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=1b2O+qmlKf9WjWr8GTX3jBAtGg4oeFE29CaycHt1tLo=; b=Zvy9FrWE9DepGm3Xoisckm/Dxs4a6fimeX3gP7Dl80hZf4eEqg183rMor5Ukc92qMpNLymxfo1VjvfJ4YLZ2vDr2UkUoY7N/9zVQaOrAHAADUQim34+XyQUr02W1z3frTRWE+VBPvcz/3u0Uy5ZVl6FEXsRMm2P3zOdWUQPu4lg= 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 168196131079661.84478641500425; Wed, 19 Apr 2023 20:28:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwr-0003gy-Gx; Wed, 19 Apr 2023 23:27:05 -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 1ppKwl-0003fz-59 for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:59 -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 1ppKwh-0000Ig-AL for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -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 33K2GTVp020259; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2qv3gjvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +0000 Received: from pps.filterd (NALASPPMTA03.qualcomm.com [127.0.0.1]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3QmEn006589; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 3pyn0mbucj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: from NALASPPMTA03.qualcomm.com (NALASPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3QmOJ006571; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 33K3QlEV006558 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 09A70690; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=1b2O+qmlKf9WjWr8GTX3jBAtGg4oeFE29CaycHt1tLo=; b=QN3xz62hDbL/8lNKSbPCNYNzS7rAVvB8rFQFHDZXKOAkj0KTOPLcvtMCUCzP5P0mndZw cqpJPpnflSlMjptu9+ulneIaocNUW03Ckle2C5sqOBi2ht8aNQlVSf60HH+OH7hd9j0P E3U/Nzo09WWsc/1wcoRASj5zN/ms3wOWaxBJmw/ivM8JyhpxKWL1tZOvSU0ShpSPns2h TU1OcM6TD1CdbqeNCcG+XFWOjxa0JbCfJzK5etQkeojTheHVWtK1WayW4wmBj97G+/e8 zDn5yrSD6bCKGORk/wvSeyvB67qVWoEqv3ZYZTW2EhYtRZstvv+WDQnljogq0vK3MWaw ng== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 06/11] Hexagon (target/hexagon) Add overrides for count trailing zeros/ones Date: Wed, 19 Apr 2023 20:26:29 -0700 Message-Id: <20230420032634.105311-7-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: MNscqv5hPO5Z6HfdZTFwQFaFiSRJZ-wV X-Proofpoint-ORIG-GUID: MNscqv5hPO5Z6HfdZTFwQFaFiSRJZ-wV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=609 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961312662100003 The following instructions are overriden S2_ct0 Count trailing zeros S2_ct1 Count trailing ones S2_ct0p Count trailing zeros (register pair) S2_ct1p Count trailing ones (register pair) These instructions are not handled by idef-parser because the imported semantics uses bit-reverse. However, they are straightforward to implement in TCG with tcg_gen_ctzi_* Test cases added to tests/tcg/hexagon/misc.c Signed-off-by: Taylor Simpson Reviewed-by: Richard Henderson Message-Id: <20230405164211.30015-1-tsimpson@quicinc.com> --- target/hexagon/gen_tcg.h | 24 +++++++++++++++++ tests/tcg/hexagon/misc.c | 56 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h index bcf0cf466a..45f92adf6c 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -1058,6 +1058,30 @@ #define fGEN_TCG_SL2_jumpr31_fnew(SHORTCODE) \ gen_cond_jumpr31(ctx, TCG_COND_NE, hex_new_pred_value[0]) =20 +/* Count trailing zeros/ones */ +#define fGEN_TCG_S2_ct0(SHORTCODE) \ + do { \ + tcg_gen_ctzi_tl(RdV, RsV, 32); \ + } while (0) +#define fGEN_TCG_S2_ct1(SHORTCODE) \ + do { \ + tcg_gen_not_tl(RdV, RsV); \ + tcg_gen_ctzi_tl(RdV, RdV, 32); \ + } while (0) +#define fGEN_TCG_S2_ct0p(SHORTCODE) \ + do { \ + TCGv_i64 tmp =3D tcg_temp_new_i64(); \ + tcg_gen_ctzi_i64(tmp, RssV, 64); \ + tcg_gen_extrl_i64_i32(RdV, tmp); \ + } while (0) +#define fGEN_TCG_S2_ct1p(SHORTCODE) \ + do { \ + TCGv_i64 tmp =3D tcg_temp_new_i64(); \ + tcg_gen_not_i64(tmp, RssV); \ + tcg_gen_ctzi_i64(tmp, tmp, 64); \ + tcg_gen_extrl_i64_i32(RdV, tmp); \ + } while (0) + /* Floating point */ #define fGEN_TCG_F2_conv_sf2df(SHORTCODE) \ gen_helper_conv_sf2df(RddV, cpu_env, RsV) diff --git a/tests/tcg/hexagon/misc.c b/tests/tcg/hexagon/misc.c index e73ab57334..e126751e3a 100644 --- a/tests/tcg/hexagon/misc.c +++ b/tests/tcg/hexagon/misc.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; =20 =20 static inline void S4_storerhnew_rr(void *p, int index, uint16_t v) @@ -333,6 +334,57 @@ void test_l2fetch(void) "l2fetch(r0, r3:2)\n\t"); } =20 +static inline int ct0(uint32_t x) +{ + int res; + asm("%0 =3D ct0(%1)\n\t" : "=3Dr"(res) : "r"(x)); + return res; +} + +static inline int ct1(uint32_t x) +{ + int res; + asm("%0 =3D ct1(%1)\n\t" : "=3Dr"(res) : "r"(x)); + return res; +} + +static inline int ct0p(uint64_t x) +{ + int res; + asm("%0 =3D ct0(%1)\n\t" : "=3Dr"(res) : "r"(x)); + return res; +} + +static inline int ct1p(uint64_t x) +{ + int res; + asm("%0 =3D ct1(%1)\n\t" : "=3Dr"(res) : "r"(x)); + return res; +} + +void test_count_trailing_zeros_ones(void) +{ + check(ct0(0x0000000f), 0); + check(ct0(0x00000000), 32); + check(ct0(0x000000f0), 4); + + check(ct1(0x000000f0), 0); + check(ct1(0x0000000f), 4); + check(ct1(0x00000000), 0); + check(ct1(0xffffffff), 32); + + check(ct0p(0x000000000000000fULL), 0); + check(ct0p(0x0000000000000000ULL), 64); + check(ct0p(0x00000000000000f0ULL), 4); + + check(ct1p(0x00000000000000f0ULL), 0); + check(ct1p(0x000000000000000fULL), 4); + check(ct1p(0x0000000000000000ULL), 0); + check(ct1p(0xffffffffffffffffULL), 64); + check(ct1p(0xffffffffff0fffffULL), 20); + check(ct1p(0xffffff0fffffffffULL), 36); +} + int main() { int res; @@ -468,6 +520,8 @@ int main() =20 test_l2fetch(); =20 + test_count_trailing_zeros_ones(); + puts(err ? "FAIL" : "PASS"); return err; } --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961311; cv=none; d=zohomail.com; s=zohoarc; b=Prv421smin8HmMopy2Sf9IENrWosu94tEMtRPZdja/uFDnDslmd+6cqhsww6+JMczCK0fkkPSGijk/JHOulkT0hFuBXWMvUbvzJZR6t9nmLI8E3FrciIAq4DOhq6plzwJm04qnu/FXzBTJIOdE1yUfOdHkv42FCeaRizabZL03w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961311; h=Content-Type: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=RZoM6gjNQ8qqLwdBWoCT1Eczc/BszQVSDXPoNeXK/UA=; b=EF1IvIlEFEg6NV0Xscoc6PuSfZilAKrV2V6ANemiyr4/KVJbI8tEDEM2vSoGEI0v/PReMH7FMhqaFj/buBpzElzfyo3SpszF9X7h2f55PXfFGblic2/ujIvHokyk7oQ81U/JE24hMGVP49TWRsmbS5UP8CHJpJYvK5e5QytSWUw= 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 1681961311332504.01241709374983; Wed, 19 Apr 2023 20:28:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwo-0003gl-3M; Wed, 19 Apr 2023 23:27:04 -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 1ppKwj-0003fP-ES for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -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 1ppKwh-0000It-Aw for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:57 -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 33K0sC4V008406; Thu, 20 Apr 2023 03:26:50 GMT Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2qv3gjvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +0000 Received: from pps.filterd (NALASPPMTA01.qualcomm.com [127.0.0.1]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3PWXi002990; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA01.qualcomm.com (PPS) with ESMTPS id 3q2ax2nv11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: from NALASPPMTA01.qualcomm.com (NALASPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3PZKJ003351; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA01.qualcomm.com (PPS) with ESMTPS id 33K3QlnQ004397 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 0C295692; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=RZoM6gjNQ8qqLwdBWoCT1Eczc/BszQVSDXPoNeXK/UA=; b=Dkjvw3m2dnKsv3YoL5/oCk6LWKHjuNKeCaEMHKIUh581jjYSU6nSd8odpn0cF/s+ZUdk qplUce8qfAAgLwHXeuXDxy9BWCYw6nAgyZjo0VtjcAlJlKT9OROBQwqAi/bokatY0gtE 4v8Fo+IDaHxe2FYXZ8rpJugpNTffj6DblfGoYH71AGHM0lg9j05ZUb0QbQRKmrRizOhL 8OymYkfJoPKJKLYPNFn615M3BO6dpOgQjpm5rFBJxYz6xm5o8H0M9Hlsmdr7XCqEPZSj nblswXL1Hydaw5WKcLycos8J5Kpr1hBqdFzs/He0qbjKIqdogwtyezonIFaSdSHSgXF1 TQ== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 07/11] Hexagon (target/hexagon) Updates to USR should use get_result_gpr Date: Wed, 19 Apr 2023 20:26:30 -0700 Message-Id: <20230420032634.105311-8-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: YVf-FQ8lFRjW5E_w4nZbux8v1xEHW5Lr X-Proofpoint-ORIG-GUID: YVf-FQ8lFRjW5E_w4nZbux8v1xEHW5Lr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961312267100001 Signed-off-by: Taylor Simpson Reviewed-by: Anton Johansson Message-Id: <20230405164211.30015-3-tsimpson@quicinc.com> --- target/hexagon/gen_tcg.h | 4 +- target/hexagon/genptr.h | 10 ++--- target/hexagon/macros.h | 8 ---- target/hexagon/genptr.c | 49 ++++++++++----------- target/hexagon/idef-parser/parser-helpers.c | 5 ++- target/hexagon/idef-parser/idef-parser.y | 2 +- 6 files changed, 34 insertions(+), 44 deletions(-) diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h index 45f92adf6c..b189f725d7 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -1039,11 +1039,11 @@ =20 /* r0 =3D asr(r1, r2):sat */ #define fGEN_TCG_S2_asr_r_r_sat(SHORTCODE) \ - gen_asr_r_r_sat(RdV, RsV, RtV) + gen_asr_r_r_sat(ctx, RdV, RsV, RtV) =20 /* r0 =3D asl(r1, r2):sat */ #define fGEN_TCG_S2_asl_r_r_sat(SHORTCODE) \ - gen_asl_r_r_sat(RdV, RsV, RtV) + gen_asl_r_r_sat(ctx, RdV, RsV, RtV) =20 #define fGEN_TCG_SL2_jumpr31(SHORTCODE) \ gen_jumpr(ctx, hex_gpr[HEX_REG_LR]) diff --git a/target/hexagon/genptr.h b/target/hexagon/genptr.h index 591b059698..76e497aa48 100644 --- a/target/hexagon/genptr.h +++ b/target/hexagon/genptr.h @@ -1,5 +1,5 @@ /* - * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,9 +37,9 @@ TCGv gen_read_reg(TCGv result, int num); TCGv gen_read_preg(TCGv pred, uint8_t num); void gen_log_reg_write(int rnum, TCGv val); void gen_log_pred_write(DisasContext *ctx, int pnum, TCGv val); -void gen_set_usr_field(int field, TCGv val); -void gen_set_usr_fieldi(int field, int x); -void gen_set_usr_field_if(int field, TCGv val); +void gen_set_usr_field(DisasContext *ctx, int field, TCGv val); +void gen_set_usr_fieldi(DisasContext *ctx, int field, int x); +void gen_set_usr_field_if(DisasContext *ctx, int field, TCGv val); void gen_sat_i32(TCGv dest, TCGv source, int width); void gen_sat_i32_ovfl(TCGv ovfl, TCGv dest, TCGv source, int width); void gen_satu_i32(TCGv dest, TCGv source, int width); @@ -48,7 +48,7 @@ void gen_sat_i64(TCGv_i64 dest, TCGv_i64 source, int widt= h); void gen_sat_i64_ovfl(TCGv ovfl, TCGv_i64 dest, TCGv_i64 source, int width= ); void gen_satu_i64(TCGv_i64 dest, TCGv_i64 source, int width); void gen_satu_i64_ovfl(TCGv ovfl, TCGv_i64 dest, TCGv_i64 source, int widt= h); -void gen_add_sat_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b); +void gen_add_sat_i64(DisasContext *ctx, TCGv_i64 ret, TCGv_i64 a, TCGv_i64= b); TCGv gen_8bitsof(TCGv result, TCGv value); void gen_set_byte_i64(int N, TCGv_i64 result, TCGv src); TCGv gen_get_byte(TCGv result, int N, TCGv src, bool sign); diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index f5f31b6930..21b5b5a06c 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -38,14 +38,6 @@ #define TYPE_INT(X) __builtin_types_compatible_p(typeof(X), int) #define TYPE_TCGV(X) __builtin_types_compatible_p(typeof(X), TCGv) #define TYPE_TCGV_I64(X) __builtin_types_compatible_p(typeof(X), TCGv_= i64) - -#define SET_USR_FIELD_FUNC(X) \ - __builtin_choose_expr(TYPE_INT(X), \ - gen_set_usr_fieldi, \ - __builtin_choose_expr(TYPE_TCGV(X), \ - gen_set_usr_field, (void)0)) -#define SET_USR_FIELD(FIELD, VAL) \ - SET_USR_FIELD_FUNC(VAL)(FIELD, VAL) #else #define GET_USR_FIELD(FIELD) \ fEXTRACTU_BITS(env->gpr[HEX_REG_USR], reg_field_info[FIELD].width, \ diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index bb274d4a71..502c85ae35 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -486,30 +486,27 @@ static void gen_write_new_pc_pcrel(DisasContext *ctx,= int pc_off, } } =20 -void gen_set_usr_field(int field, TCGv val) +void gen_set_usr_field(DisasContext *ctx, int field, TCGv val) { - tcg_gen_deposit_tl(hex_new_value[HEX_REG_USR], hex_new_value[HEX_REG_U= SR], - val, + TCGv usr =3D get_result_gpr(ctx, HEX_REG_USR); + tcg_gen_deposit_tl(usr, usr, val, reg_field_info[field].offset, reg_field_info[field].width); } =20 -void gen_set_usr_fieldi(int field, int x) +void gen_set_usr_fieldi(DisasContext *ctx, int field, int x) { if (reg_field_info[field].width =3D=3D 1) { + TCGv usr =3D get_result_gpr(ctx, HEX_REG_USR); target_ulong bit =3D 1 << reg_field_info[field].offset; if ((x & 1) =3D=3D 1) { - tcg_gen_ori_tl(hex_new_value[HEX_REG_USR], - hex_new_value[HEX_REG_USR], - bit); + tcg_gen_ori_tl(usr, usr, bit); } else { - tcg_gen_andi_tl(hex_new_value[HEX_REG_USR], - hex_new_value[HEX_REG_USR], - ~bit); + tcg_gen_andi_tl(usr, usr, ~bit); } } else { TCGv val =3D tcg_constant_tl(x); - gen_set_usr_field(field, val); + gen_set_usr_field(ctx, field, val); } } =20 @@ -754,7 +751,7 @@ static void gen_endloop0(DisasContext *ctx) tcg_gen_brcondi_tl(TCG_COND_EQ, lpcfg, 0, label2); { tcg_gen_subi_tl(lpcfg, lpcfg, 1); - SET_USR_FIELD(USR_LPCFG, lpcfg); + gen_set_usr_field(ctx, USR_LPCFG, lpcfg); } gen_set_label(label2); =20 @@ -829,7 +826,7 @@ static void gen_endloop01(DisasContext *ctx) tcg_gen_brcondi_tl(TCG_COND_EQ, lpcfg, 0, label2); { tcg_gen_subi_tl(lpcfg, lpcfg, 1); - SET_USR_FIELD(USR_LPCFG, lpcfg); + gen_set_usr_field(ctx, USR_LPCFG, lpcfg); } gen_set_label(label2); =20 @@ -878,8 +875,9 @@ static void gen_cmpi_jumpnv(DisasContext *ctx, } =20 /* Shift left with saturation */ -static void gen_shl_sat(TCGv dst, TCGv src, TCGv shift_amt) +static void gen_shl_sat(DisasContext *ctx, TCGv dst, TCGv src, TCGv shift_= amt) { + TCGv usr =3D get_result_gpr(ctx, HEX_REG_USR); TCGv sh32 =3D tcg_temp_new(); TCGv dst_sar =3D tcg_temp_new(); TCGv ovf =3D tcg_temp_new(); @@ -911,7 +909,7 @@ static void gen_shl_sat(TCGv dst, TCGv src, TCGv shift_= amt) =20 tcg_gen_setcond_tl(TCG_COND_NE, ovf, dst_sar, src); tcg_gen_shli_tl(ovf, ovf, reg_field_info[USR_OVF].offset); - tcg_gen_or_tl(hex_new_value[HEX_REG_USR], hex_new_value[HEX_REG_USR], = ovf); + tcg_gen_or_tl(usr, usr, ovf); =20 tcg_gen_movcond_tl(TCG_COND_EQ, dst, dst_sar, src, dst, satval); } @@ -928,7 +926,7 @@ static void gen_sar(TCGv dst, TCGv src, TCGv shift_amt) } =20 /* Bidirectional shift right with saturation */ -static void gen_asr_r_r_sat(TCGv RdV, TCGv RsV, TCGv RtV) +static void gen_asr_r_r_sat(DisasContext *ctx, TCGv RdV, TCGv RsV, TCGv Rt= V) { TCGv shift_amt =3D tcg_temp_new(); TCGLabel *positive =3D gen_new_label(); @@ -939,7 +937,7 @@ static void gen_asr_r_r_sat(TCGv RdV, TCGv RsV, TCGv Rt= V) =20 /* Negative shift amount =3D> shift left */ tcg_gen_neg_tl(shift_amt, shift_amt); - gen_shl_sat(RdV, RsV, shift_amt); + gen_shl_sat(ctx, RdV, RsV, shift_amt); tcg_gen_br(done); =20 gen_set_label(positive); @@ -950,7 +948,7 @@ static void gen_asr_r_r_sat(TCGv RdV, TCGv RsV, TCGv Rt= V) } =20 /* Bidirectional shift left with saturation */ -static void gen_asl_r_r_sat(TCGv RdV, TCGv RsV, TCGv RtV) +static void gen_asl_r_r_sat(DisasContext *ctx, TCGv RdV, TCGv RsV, TCGv Rt= V) { TCGv shift_amt =3D tcg_temp_new(); TCGLabel *positive =3D gen_new_label(); @@ -966,7 +964,7 @@ static void gen_asl_r_r_sat(TCGv RdV, TCGv RsV, TCGv Rt= V) =20 gen_set_label(positive); /* Positive shift amount =3D> shift left */ - gen_shl_sat(RdV, RsV, shift_amt); + gen_shl_sat(ctx, RdV, RsV, shift_amt); =20 gen_set_label(done); } @@ -1109,20 +1107,19 @@ void probe_noshuf_load(TCGv va, int s, int mi) * Note: Since this function might branch, `val` is * required to be a `tcg_temp_local`. */ -void gen_set_usr_field_if(int field, TCGv val) +void gen_set_usr_field_if(DisasContext *ctx, int field, TCGv val) { /* Sets the USR field if `val` is non-zero */ if (reg_field_info[field].width =3D=3D 1) { + TCGv usr =3D get_result_gpr(ctx, HEX_REG_USR); TCGv tmp =3D tcg_temp_new(); tcg_gen_extract_tl(tmp, val, 0, reg_field_info[field].width); tcg_gen_shli_tl(tmp, tmp, reg_field_info[field].offset); - tcg_gen_or_tl(hex_new_value[HEX_REG_USR], - hex_new_value[HEX_REG_USR], - tmp); + tcg_gen_or_tl(usr, usr, tmp); } else { TCGLabel *skip_label =3D gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_EQ, val, 0, skip_label); - gen_set_usr_field(field, val); + gen_set_usr_field(ctx, field, val); gen_set_label(skip_label); } } @@ -1190,7 +1187,7 @@ void gen_satu_i64_ovfl(TCGv ovfl, TCGv_i64 dest, TCGv= _i64 source, int width) } =20 /* Implements the fADDSAT64 macro in TCG */ -void gen_add_sat_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b) +void gen_add_sat_i64(DisasContext *ctx, TCGv_i64 ret, TCGv_i64 a, TCGv_i64= b) { TCGv_i64 sum =3D tcg_temp_new_i64(); TCGv_i64 xor =3D tcg_temp_new_i64(); @@ -1227,7 +1224,7 @@ void gen_add_sat_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i= 64 b) gen_set_label(ovfl_label); tcg_gen_and_i64(cond3, sum, mask); tcg_gen_movcond_i64(TCG_COND_NE, ret, cond3, zero, max_pos, max_neg); - SET_USR_FIELD(USR_OVF, 1); + gen_set_usr_fieldi(ctx, USR_OVF, 1); =20 gen_set_label(ret_label); } diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/i= def-parser/parser-helpers.c index 18cde6a1be..86511efb62 100644 --- a/target/hexagon/idef-parser/parser-helpers.c +++ b/target/hexagon/idef-parser/parser-helpers.c @@ -1640,7 +1640,8 @@ void gen_addsat64(Context *c, { HexValue op1_m =3D rvalue_materialize(c, locp, op1); HexValue op2_m =3D rvalue_materialize(c, locp, op2); - OUT(c, locp, "gen_add_sat_i64(", dst, ", ", &op1_m, ", ", &op2_m, ");\= n"); + OUT(c, locp, "gen_add_sat_i64(ctx, ", dst, ", ", &op1_m, ", ", + &op2_m, ");\n"); } =20 void gen_inst(Context *c, GString *iname) @@ -1971,7 +1972,7 @@ HexValue gen_rvalue_sat(Context *c, YYLTYPE *locp, He= xSat *sat, OUT(c, locp, "gen_sat", unsigned_str, "_", bit_suffix, "_ovfl("); OUT(c, locp, &ovfl, ", ", &res, ", ", value, ", ", &width->imm.value, ");\n"); - OUT(c, locp, "gen_set_usr_field_if(USR_OVF,", &ovfl, ");\n"); + OUT(c, locp, "gen_set_usr_field_if(ctx, USR_OVF,", &ovfl, ");\n"); =20 return res; } diff --git a/target/hexagon/idef-parser/idef-parser.y b/target/hexagon/idef= -parser/idef-parser.y index 7d05773b67..5444fd4749 100644 --- a/target/hexagon/idef-parser/idef-parser.y +++ b/target/hexagon/idef-parser/idef-parser.y @@ -362,7 +362,7 @@ assign_statement : lvalue '=3D' rvalue "Assignment side-effect not modeled!"); $3 =3D gen_rvalue_truncate(c, &@1, &$3); $3 =3D rvalue_materialize(c, &@1, &$3); - OUT(c, &@1, "SET_USR_FIELD(USR_LPCFG, ", &$3, ");\n= "); + OUT(c, &@1, "gen_set_usr_field(ctx, USR_LPCFG, ", &= $3, ");\n"); } | DEPOSIT '(' rvalue ',' rvalue ',' rvalue ')' { --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961307; cv=none; d=zohomail.com; s=zohoarc; b=BGenWyd/ozAFMEVVMB00m3+FmmEQuQZ0hFNyRUL2XJcV9OB/bKP77yHI8nRrSr3rv7NnCyp8iyQYI1PJH6CCGY2DFQ3MJI4W7JX4oAKL6z3LeNZ8uRpbKXWqBtUj14AbwFZAj+8QFfvmnb1I1mepeMiW6JXI48KtI3l9C9SCwcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961307; h=Content-Type: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=Qajnm72zP71Te8iZJpG8IkMxJNDj0lHzCVNlJQolY/Y=; b=Sa+CIqdfxuszSsJ2DuvGyKQ+Y+p6l+CEzwKF+7l2Vc2TOq+5v128y7//eZDvFv1ys4ezBSyULnYEUNwYsFHOfEZHSth+IUBWLBT7w7fjjFHmlQ/iGjl9rgJC7eLXc6Wt0jA9bk9AMvVDhzCr+nIxQ0h2FvNGmpKrVm2QDlG+GOI= 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 1681961307099563.0044323849871; Wed, 19 Apr 2023 20:28:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwu-0003jB-NJ; Wed, 19 Apr 2023 23:27:08 -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 1ppKwl-0003g3-62 for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:59 -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 1ppKwf-0000Iq-Et for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -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 33K2Q4Ba032494; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2p7arsj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +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 33K3PIap009024; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 3q1ubj2gvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +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 33K3Qm5M010555; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 33K3Ql1I010551 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 0ECE2694; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-type : content-transfer-encoding; s=qcppdkim1; bh=Qajnm72zP71Te8iZJpG8IkMxJNDj0lHzCVNlJQolY/Y=; b=LaMI3o1eVTpiRwWuo6Nj6xT67mnrpOXis7XU8zMBG0mYB/h4iSemfzNLWvS1qFGJcYIX OniMNuL/zTuKpuisNjICw1E4fQHRFQv0LIxfOZ5KyHEoblLaFS1ySTrD2XjVtFtFv64g zHnwcQazFzbRHsFwms1zRee4iBroz8BRi52LkWFPxrblJHC5Ah5w0M8uoJ++flvSSArz F45vxSCnWeG2Lc1xXo99bgjhdPPZ9qTcVzNw156IWcoFlS/BwxZtXZz0MINRXDIAEecb xNTezoUehxJG1SGnCJlwo6iAwlQzeqoXEKGosDbsSvacUwmXOCuMIMd3LYr/tP1YvZYm qw== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 08/11] Hexagon (tests/tcg/hexagon) Move HVX test infra to header file Date: Wed, 19 Apr 2023 20:26:31 -0700 Message-Id: <20230420032634.105311-9-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> 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: qkL7t4EFZ9vHG11qfn-JHLCh_Ok5etOI X-Proofpoint-ORIG-GUID: qkL7t4EFZ9vHG11qfn-JHLCh_Ok5etOI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961307493100002 Content-Type: text/plain; charset="utf-8" This will facilitate adding additional tests in separate .c files Signed-off-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230406174241.853296-1-tsimpson@quicinc.com> --- tests/tcg/hexagon/hvx_misc.h | 178 ++++++++++++++++++++++++++++++ tests/tcg/hexagon/hvx_misc.c | 160 +-------------------------- tests/tcg/hexagon/Makefile.target | 1 + 3 files changed, 181 insertions(+), 158 deletions(-) create mode 100644 tests/tcg/hexagon/hvx_misc.h diff --git a/tests/tcg/hexagon/hvx_misc.h b/tests/tcg/hexagon/hvx_misc.h new file mode 100644 index 0000000000..2e868340fd --- /dev/null +++ b/tests/tcg/hexagon/hvx_misc.h @@ -0,0 +1,178 @@ +/* + * Copyright(c) 2021-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef HVX_MISC_H +#define HVX_MISC_H + +static inline void check(int line, int i, int j, + uint64_t result, uint64_t expect) +{ + if (result !=3D expect) { + printf("ERROR at line %d: [%d][%d] 0x%016llx !=3D 0x%016llx\n", + line, i, j, result, expect); + err++; + } +} + +#define MAX_VEC_SIZE_BYTES 128 + +typedef union { + uint64_t ud[MAX_VEC_SIZE_BYTES / 8]; + int64_t d[MAX_VEC_SIZE_BYTES / 8]; + uint32_t uw[MAX_VEC_SIZE_BYTES / 4]; + int32_t w[MAX_VEC_SIZE_BYTES / 4]; + uint16_t uh[MAX_VEC_SIZE_BYTES / 2]; + int16_t h[MAX_VEC_SIZE_BYTES / 2]; + uint8_t ub[MAX_VEC_SIZE_BYTES / 1]; + int8_t b[MAX_VEC_SIZE_BYTES / 1]; +} MMVector; + +#define BUFSIZE 16 +#define OUTSIZE 16 +#define MASKMOD 3 + +MMVector buffer0[BUFSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); +MMVector buffer1[BUFSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); +MMVector mask[BUFSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); +MMVector output[OUTSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); +MMVector expect[OUTSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); + +#define CHECK_OUTPUT_FUNC(FIELD, FIELDSZ) \ +static inline void check_output_##FIELD(int line, size_t num_vectors) \ +{ \ + for (int i =3D 0; i < num_vectors; i++) { \ + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ + check(line, i, j, output[i].FIELD[j], expect[i].FIELD[j]); \ + } \ + } \ +} + +CHECK_OUTPUT_FUNC(d, 8) +CHECK_OUTPUT_FUNC(w, 4) +CHECK_OUTPUT_FUNC(h, 2) +CHECK_OUTPUT_FUNC(b, 1) + +static inline void init_buffers(void) +{ + int counter0 =3D 0; + int counter1 =3D 17; + for (int i =3D 0; i < BUFSIZE; i++) { + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES; j++) { + buffer0[i].b[j] =3D counter0++; + buffer1[i].b[j] =3D counter1++; + } + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 4; j++) { + mask[i].w[j] =3D (i + j % MASKMOD =3D=3D 0) ? 0 : 1; + } + } +} + +#define VEC_OP1(ASM, EL, IN, OUT) \ + asm("v2 =3D vmem(%0 + #0)\n\t" \ + "v2" #EL " =3D " #ASM "(v2" #EL ")\n\t" \ + "vmem(%1 + #0) =3D v2\n\t" \ + : : "r"(IN), "r"(OUT) : "v2", "memory") + +#define VEC_OP2(ASM, EL, IN0, IN1, OUT) \ + asm("v2 =3D vmem(%0 + #0)\n\t" \ + "v3 =3D vmem(%1 + #0)\n\t" \ + "v2" #EL " =3D " #ASM "(v2" #EL ", v3" #EL ")\n\t" \ + "vmem(%2 + #0) =3D v2\n\t" \ + : : "r"(IN0), "r"(IN1), "r"(OUT) : "v2", "v3", "memory") + +#define TEST_VEC_OP1(NAME, ASM, EL, FIELD, FIELDSZ, OP) \ +static inline void test_##NAME(void) \ +{ \ + void *pin =3D buffer0; \ + void *pout =3D output; \ + for (int i =3D 0; i < BUFSIZE; i++) { \ + VEC_OP1(ASM, EL, pin, pout); \ + pin +=3D sizeof(MMVector); \ + pout +=3D sizeof(MMVector); \ + } \ + for (int i =3D 0; i < BUFSIZE; i++) { \ + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ + expect[i].FIELD[j] =3D OP buffer0[i].FIELD[j]; \ + } \ + } \ + check_output_##FIELD(__LINE__, BUFSIZE); \ +} + +#define TEST_VEC_OP2(NAME, ASM, EL, FIELD, FIELDSZ, OP) \ +static inline void test_##NAME(void) \ +{ \ + void *p0 =3D buffer0; \ + void *p1 =3D buffer1; \ + void *pout =3D output; \ + for (int i =3D 0; i < BUFSIZE; i++) { \ + VEC_OP2(ASM, EL, p0, p1, pout); \ + p0 +=3D sizeof(MMVector); \ + p1 +=3D sizeof(MMVector); \ + pout +=3D sizeof(MMVector); \ + } \ + for (int i =3D 0; i < BUFSIZE; i++) { \ + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ + expect[i].FIELD[j] =3D buffer0[i].FIELD[j] OP buffer1[i].FIELD= [j]; \ + } \ + } \ + check_output_##FIELD(__LINE__, BUFSIZE); \ +} + +#define THRESHOLD 31 + +#define PRED_OP2(ASM, IN0, IN1, OUT, INV) \ + asm("r4 =3D #%3\n\t" \ + "v1.b =3D vsplat(r4)\n\t" \ + "v2 =3D vmem(%0 + #0)\n\t" \ + "q0 =3D vcmp.gt(v2.b, v1.b)\n\t" \ + "v3 =3D vmem(%1 + #0)\n\t" \ + "q1 =3D vcmp.gt(v3.b, v1.b)\n\t" \ + "q2 =3D " #ASM "(q0, " INV "q1)\n\t" \ + "r4 =3D #0xff\n\t" \ + "v1.b =3D vsplat(r4)\n\t" \ + "if (q2) vmem(%2 + #0) =3D v1\n\t" \ + : : "r"(IN0), "r"(IN1), "r"(OUT), "i"(THRESHOLD) \ + : "r4", "v1", "v2", "v3", "q0", "q1", "q2", "memory") + +#define TEST_PRED_OP2(NAME, ASM, OP, INV) \ +static inline void test_##NAME(bool invert) \ +{ \ + void *p0 =3D buffer0; \ + void *p1 =3D buffer1; \ + void *pout =3D output; \ + memset(output, 0, sizeof(expect)); \ + for (int i =3D 0; i < BUFSIZE; i++) { \ + PRED_OP2(ASM, p0, p1, pout, INV); \ + p0 +=3D sizeof(MMVector); \ + p1 +=3D sizeof(MMVector); \ + pout +=3D sizeof(MMVector); \ + } \ + for (int i =3D 0; i < BUFSIZE; i++) { \ + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES; j++) { \ + bool p0 =3D (buffer0[i].b[j] > THRESHOLD); \ + bool p1 =3D (buffer1[i].b[j] > THRESHOLD); \ + if (invert) { \ + expect[i].b[j] =3D (p0 OP !p1) ? 0xff : 0x00; \ + } else { \ + expect[i].b[j] =3D (p0 OP p1) ? 0xff : 0x00; \ + } \ + } \ + } \ + check_output_b(__LINE__, BUFSIZE); \ +} + +#endif diff --git a/tests/tcg/hexagon/hvx_misc.c b/tests/tcg/hexagon/hvx_misc.c index 53d5c9b44f..d0e64e035f 100644 --- a/tests/tcg/hexagon/hvx_misc.c +++ b/tests/tcg/hexagon/hvx_misc.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2021-2022 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * Copyright(c) 2021-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,69 +23,7 @@ =20 int err; =20 -static void __check(int line, int i, int j, uint64_t result, uint64_t expe= ct) -{ - if (result !=3D expect) { - printf("ERROR at line %d: [%d][%d] 0x%016llx !=3D 0x%016llx\n", - line, i, j, result, expect); - err++; - } -} - -#define check(RES, EXP) __check(__LINE__, RES, EXP) - -#define MAX_VEC_SIZE_BYTES 128 - -typedef union { - uint64_t ud[MAX_VEC_SIZE_BYTES / 8]; - int64_t d[MAX_VEC_SIZE_BYTES / 8]; - uint32_t uw[MAX_VEC_SIZE_BYTES / 4]; - int32_t w[MAX_VEC_SIZE_BYTES / 4]; - uint16_t uh[MAX_VEC_SIZE_BYTES / 2]; - int16_t h[MAX_VEC_SIZE_BYTES / 2]; - uint8_t ub[MAX_VEC_SIZE_BYTES / 1]; - int8_t b[MAX_VEC_SIZE_BYTES / 1]; -} MMVector; - -#define BUFSIZE 16 -#define OUTSIZE 16 -#define MASKMOD 3 - -MMVector buffer0[BUFSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); -MMVector buffer1[BUFSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); -MMVector mask[BUFSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); -MMVector output[OUTSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); -MMVector expect[OUTSIZE] __attribute__((aligned(MAX_VEC_SIZE_BYTES))); - -#define CHECK_OUTPUT_FUNC(FIELD, FIELDSZ) \ -static void check_output_##FIELD(int line, size_t num_vectors) \ -{ \ - for (int i =3D 0; i < num_vectors; i++) { \ - for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ - __check(line, i, j, output[i].FIELD[j], expect[i].FIELD[j]); \ - } \ - } \ -} - -CHECK_OUTPUT_FUNC(d, 8) -CHECK_OUTPUT_FUNC(w, 4) -CHECK_OUTPUT_FUNC(h, 2) -CHECK_OUTPUT_FUNC(b, 1) - -static void init_buffers(void) -{ - int counter0 =3D 0; - int counter1 =3D 17; - for (int i =3D 0; i < BUFSIZE; i++) { - for (int j =3D 0; j < MAX_VEC_SIZE_BYTES; j++) { - buffer0[i].b[j] =3D counter0++; - buffer1[i].b[j] =3D counter1++; - } - for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / 4; j++) { - mask[i].w[j] =3D (i + j % MASKMOD =3D=3D 0) ? 0 : 1; - } - } -} +#include "hvx_misc.h" =20 static void test_load_tmp(void) { @@ -322,100 +260,6 @@ static void test_max_temps() check_output_b(__LINE__, 5); } =20 -#define VEC_OP1(ASM, EL, IN, OUT) \ - asm("v2 =3D vmem(%0 + #0)\n\t" \ - "v2" #EL " =3D " #ASM "(v2" #EL ")\n\t" \ - "vmem(%1 + #0) =3D v2\n\t" \ - : : "r"(IN), "r"(OUT) : "v2", "memory") - -#define VEC_OP2(ASM, EL, IN0, IN1, OUT) \ - asm("v2 =3D vmem(%0 + #0)\n\t" \ - "v3 =3D vmem(%1 + #0)\n\t" \ - "v2" #EL " =3D " #ASM "(v2" #EL ", v3" #EL ")\n\t" \ - "vmem(%2 + #0) =3D v2\n\t" \ - : : "r"(IN0), "r"(IN1), "r"(OUT) : "v2", "v3", "memory") - -#define TEST_VEC_OP1(NAME, ASM, EL, FIELD, FIELDSZ, OP) \ -static void test_##NAME(void) \ -{ \ - void *pin =3D buffer0; \ - void *pout =3D output; \ - for (int i =3D 0; i < BUFSIZE; i++) { \ - VEC_OP1(ASM, EL, pin, pout); \ - pin +=3D sizeof(MMVector); \ - pout +=3D sizeof(MMVector); \ - } \ - for (int i =3D 0; i < BUFSIZE; i++) { \ - for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ - expect[i].FIELD[j] =3D OP buffer0[i].FIELD[j]; \ - } \ - } \ - check_output_##FIELD(__LINE__, BUFSIZE); \ -} - -#define TEST_VEC_OP2(NAME, ASM, EL, FIELD, FIELDSZ, OP) \ -static void test_##NAME(void) \ -{ \ - void *p0 =3D buffer0; \ - void *p1 =3D buffer1; \ - void *pout =3D output; \ - for (int i =3D 0; i < BUFSIZE; i++) { \ - VEC_OP2(ASM, EL, p0, p1, pout); \ - p0 +=3D sizeof(MMVector); \ - p1 +=3D sizeof(MMVector); \ - pout +=3D sizeof(MMVector); \ - } \ - for (int i =3D 0; i < BUFSIZE; i++) { \ - for (int j =3D 0; j < MAX_VEC_SIZE_BYTES / FIELDSZ; j++) { \ - expect[i].FIELD[j] =3D buffer0[i].FIELD[j] OP buffer1[i].FIELD= [j]; \ - } \ - } \ - check_output_##FIELD(__LINE__, BUFSIZE); \ -} - -#define THRESHOLD 31 - -#define PRED_OP2(ASM, IN0, IN1, OUT, INV) \ - asm("r4 =3D #%3\n\t" \ - "v1.b =3D vsplat(r4)\n\t" \ - "v2 =3D vmem(%0 + #0)\n\t" \ - "q0 =3D vcmp.gt(v2.b, v1.b)\n\t" \ - "v3 =3D vmem(%1 + #0)\n\t" \ - "q1 =3D vcmp.gt(v3.b, v1.b)\n\t" \ - "q2 =3D " #ASM "(q0, " INV "q1)\n\t" \ - "r4 =3D #0xff\n\t" \ - "v1.b =3D vsplat(r4)\n\t" \ - "if (q2) vmem(%2 + #0) =3D v1\n\t" \ - : : "r"(IN0), "r"(IN1), "r"(OUT), "i"(THRESHOLD) \ - : "r4", "v1", "v2", "v3", "q0", "q1", "q2", "memory") - -#define TEST_PRED_OP2(NAME, ASM, OP, INV) \ -static void test_##NAME(bool invert) \ -{ \ - void *p0 =3D buffer0; \ - void *p1 =3D buffer1; \ - void *pout =3D output; \ - memset(output, 0, sizeof(expect)); \ - for (int i =3D 0; i < BUFSIZE; i++) { \ - PRED_OP2(ASM, p0, p1, pout, INV); \ - p0 +=3D sizeof(MMVector); \ - p1 +=3D sizeof(MMVector); \ - pout +=3D sizeof(MMVector); \ - } \ - for (int i =3D 0; i < BUFSIZE; i++) { \ - for (int j =3D 0; j < MAX_VEC_SIZE_BYTES; j++) { \ - bool p0 =3D (buffer0[i].b[j] > THRESHOLD); \ - bool p1 =3D (buffer1[i].b[j] > THRESHOLD); \ - if (invert) { \ - expect[i].b[j] =3D (p0 OP !p1) ? 0xff : 0x00; \ - } else { \ - expect[i].b[j] =3D (p0 OP p1) ? 0xff : 0x00; \ - } \ - } \ - } \ - check_output_b(__LINE__, BUFSIZE); \ -} - TEST_VEC_OP2(vadd_w, vadd, .w, w, 4, +) TEST_VEC_OP2(vadd_h, vadd, .h, h, 2, +) TEST_VEC_OP2(vadd_b, vadd, .b, b, 1, +) diff --git a/tests/tcg/hexagon/Makefile.target b/tests/tcg/hexagon/Makefile= .target index 0d82dfa76e..7c94db4bc4 100644 --- a/tests/tcg/hexagon/Makefile.target +++ b/tests/tcg/hexagon/Makefile.target @@ -84,6 +84,7 @@ usr: usr.c =20 scatter_gather: CFLAGS +=3D -mhvx vector_add_int: CFLAGS +=3D -mhvx -fvectorize +hvx_misc: hvx_misc.c hvx_misc.h hvx_misc: CFLAGS +=3D -mhvx hvx_histogram: CFLAGS +=3D -mhvx -Wno-gnu-folding-constant =20 --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961373; cv=none; d=zohomail.com; s=zohoarc; b=YipXfafIDu2oYj2j4oNgwM+HmhASxOyUGy4okvK+9rUTYeywLNqjSwcZgu9j3YeVXCOjZZQzqGtKqbyBHv0IiWEZfjGLZ7xhPwV3Xkte7BYoTCsfxnaqVoTm5URnxc7OUZx0tN3sAzgBln2T0GI/AUEC0irZzweom89yXVaK47k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961373; h=Content-Type: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=50OsvpRrBPJdukAjztDTtCcoxO+thbRN3RSNqie1GkA=; b=av7XfRRfvNZqqQqcPs0PVw8lQpNpvMWP4CY57uiD48tu1n3+QHybTez4X0b5ZFcZk+a/xW794Jgq3LVxlJWx0QbrlYKVPi+X85USfygd2l4p5tosPiDhaEXz1YmHTHhOY//rKWGeW57cSyK6Mn0JSChQDn4ikiMY8ytjL6bscPo= 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 1681961373659984.0066063058962; Wed, 19 Apr 2023 20:29:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKws-0003hB-Av; Wed, 19 Apr 2023 23:27:06 -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 1ppKwl-0003g0-5p for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:59 -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 1ppKwh-0000Io-AL for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -0400 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K37evo013870; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2p520t7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +0000 Received: from pps.filterd (NALASPPMTA03.qualcomm.com [127.0.0.1]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3QmY3006594; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 3pyn0mbucn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: from NALASPPMTA03.qualcomm.com (NALASPPMTA03.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3Qm3S006580; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTPS id 33K3Ql4f006569 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 1165F6A2; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=50OsvpRrBPJdukAjztDTtCcoxO+thbRN3RSNqie1GkA=; b=dquF7gRGzhE5q8kic1aMnWzgS9I4VVucTlpXLV4iNmkP7flm70JnbadDxR6e+9VsF+Yx +wYYFZBpDQbqVz3M7WjQwg18MVwnXE7QfXqlsggVDy8orT4mbCh+3oiWVD5TfU5mB8qG EKrY8kCFirH4HrBDi68HP5PtvZ9Intx1v9AqOna7SpnsWDWNGdazQ7Tdjw47ilTFZtk7 L6DRlpJLHD5rM5eI7tTfNR4ZQygoFWBvjG+ucYCPht269kNpUnRN4zmLn4qZC/BQkBD0 XhvbyeMCbkkbfr9Z7z26Rdzk3405F8MpnF2MWvTZleVAKtGuy4NqzXbs9vTtnWQ5DdRr 8A== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 09/11] Hexagon (target/hexagon) Remove unused slot variable in helpers Date: Wed, 19 Apr 2023 20:26:32 -0700 Message-Id: <20230420032634.105311-10-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 9TZ_cMq1q4hl4T6B4OSDmj7ELk6Dp3Nz X-Proofpoint-GUID: 9TZ_cMq1q4hl4T6B4OSDmj7ELk6Dp3Nz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 bulkscore=0 spamscore=0 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=531 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961374742100001 The slot variable in helpers was only passed to log_reg_write function where the argument is unused. - Remove declaration from generated helper functions - Remove slot argument from log_reg_write Signed-off-by: Taylor Simpson Reviewed-by: Richard Henderson Message-Id: <20230407204521.357244-1-tsimpson@quicinc.com> --- target/hexagon/macros.h | 14 +++++++------- target/hexagon/op_helper.h | 2 +- target/hexagon/op_helper.c | 2 +- target/hexagon/gen_helper_funcs.py | 2 -- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index 21b5b5a06c..9ddfc91b1d 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -347,9 +347,9 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv val,= int shift) =20 #define fREAD_LR() (env->gpr[HEX_REG_LR]) =20 -#define fWRITE_LR(A) log_reg_write(env, HEX_REG_LR, A, slot) -#define fWRITE_FP(A) log_reg_write(env, HEX_REG_FP, A, slot) -#define fWRITE_SP(A) log_reg_write(env, HEX_REG_SP, A, slot) +#define fWRITE_LR(A) log_reg_write(env, HEX_REG_LR, A) +#define fWRITE_FP(A) log_reg_write(env, HEX_REG_FP, A) +#define fWRITE_SP(A) log_reg_write(env, HEX_REG_SP, A) =20 #define fREAD_SP() (env->gpr[HEX_REG_SP]) #define fREAD_LC0 (env->gpr[HEX_REG_LC0]) @@ -377,13 +377,13 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv va= l, int shift) #define fHINTJR(TARGET) { /* Not modelled in qemu */} #define fWRITE_LOOP_REGS0(START, COUNT) \ do { \ - log_reg_write(env, HEX_REG_LC0, COUNT, slot); \ - log_reg_write(env, HEX_REG_SA0, START, slot); \ + log_reg_write(env, HEX_REG_LC0, COUNT); \ + log_reg_write(env, HEX_REG_SA0, START); \ } while (0) #define fWRITE_LOOP_REGS1(START, COUNT) \ do { \ - log_reg_write(env, HEX_REG_LC1, COUNT, slot); \ - log_reg_write(env, HEX_REG_SA1, START, slot);\ + log_reg_write(env, HEX_REG_LC1, COUNT); \ + log_reg_write(env, HEX_REG_SA1, START);\ } while (0) =20 #define fSET_OVERFLOW() SET_USR_FIELD(USR_OVF, 1) diff --git a/target/hexagon/op_helper.h b/target/hexagon/op_helper.h index 34b3a53975..db22b54401 100644 --- a/target/hexagon/op_helper.h +++ b/target/hexagon/op_helper.h @@ -27,7 +27,7 @@ uint32_t mem_load4(CPUHexagonState *env, uint32_t slot, t= arget_ulong vaddr); uint64_t mem_load8(CPUHexagonState *env, uint32_t slot, target_ulong vaddr= ); =20 void log_reg_write(CPUHexagonState *env, int rnum, - target_ulong val, uint32_t slot); + target_ulong val); void log_store64(CPUHexagonState *env, target_ulong addr, int64_t val, int width, int slot); void log_store32(CPUHexagonState *env, target_ulong addr, diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 099c111a8c..3cc71b69d9 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -53,7 +53,7 @@ G_NORETURN void HELPER(raise_exception)(CPUHexagonState *= env, uint32_t excp) } =20 void log_reg_write(CPUHexagonState *env, int rnum, - target_ulong val, uint32_t slot) + target_ulong val) { HEX_DEBUG_LOG("log_reg_write[%d] =3D " TARGET_FMT_ld " (0x" TARGET_FMT= _lx ")", rnum, val, val); diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper= _funcs.py index c4e04508f8..c73d792580 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -308,8 +308,6 @@ def gen_helper_function(f, tag, tagregs, tagimms): f.write(", ") f.write("uint32_t part1") f.write(")\n{\n") - if not hex_common.need_slot(tag): - f.write(" uint32_t slot __attribute__((unused)) =3D 4;\n") if hex_common.need_ea(tag): gen_decl_ea(f) ## Declare the return variable --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961295; cv=none; d=zohomail.com; s=zohoarc; b=R49w/ySHaKM9e0JtAYkwh11e6OGlrJv+pwVHvDbPl1lbRwK/UtzsQtdBPLucaJ9l/y20+chtuqeu7bdY9CXSqmjZfTg7Y2DqZoI/52HmWd/UeVj7ZRGeok7rCMHhMhmN8OBQtE6TKzsBQ5+94uBRDpj0lJGSuovrkL1YTJ7pv5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961295; h=Content-Type: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=GNT3n1LNNI426JlEIBdjoxcxegLBDnBG+9UqA/QTjeU=; b=fA5EZzRQv2Mvp3wJK9mfAz/eY/wZTonlhfMhSA9daVV3DpjsbHnO2RwtoA/jS2k8XTC2WTZUJ5D1QMxb83Dr+CqnqF9b3QAGZrPA8w1LDZMs/7yT4AevdNgjuL9xZqhoUE9YFLa18X0CaWzBbETKMVd1/KtpIIaquH5X5pll/xw= 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 1681961295194236.15826029313791; Wed, 19 Apr 2023 20:28:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwz-0003la-RA; Wed, 19 Apr 2023 23:27:13 -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 1ppKwt-0003hi-5B for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:27:07 -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 1ppKwn-0000Iw-T4 for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:27:06 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K2etsJ021003; Thu, 20 Apr 2023 03:26:50 GMT Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2ryq0eqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +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 33K3MDPY014084; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 3pyn0mktbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +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 33K3QmKI018921; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 33K3Qlk7018902 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 13EDC6A5; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=GNT3n1LNNI426JlEIBdjoxcxegLBDnBG+9UqA/QTjeU=; b=Sc9W24hIjMRZZwoiG4OY9Y13zVMfJZBXteBiUjXiwyh1T/ScZPkPukliclusd2QPVLdK D8aIWmS/HpE3LXV8wvrfW2OPqhDBotCdWaEpx8cFPPIL+P+EshTshC/pMyynK4b1xq0I X3lujCTZCZBooUkPrjcYZJtZiA3Azbdh7EdaevowDm9TqYb+eNjcvI/OMHCfXW46Mzet ICzfzWgxgxMHkFL1Jp91LYymj0YnErlTov3O5nSlflfNYP4tgRRGlGfEBrNMj61jEDFP ZG5S4S0y71AEZvhq4smCM44r3BBH01qBycsN9d80dKFa0arSBO3eUaTQttXoHO/2pD7S sw== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 10/11] Hexagon (target/hexagon) Add overrides for cache/sync/barrier instructions Date: Wed, 19 Apr 2023 20:26:33 -0700 Message-Id: <20230420032634.105311-11-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: x0yltJvNiDVZVKYoKKWod2bSHoVJHwW- X-Proofpoint-GUID: x0yltJvNiDVZVKYoKKWod2bSHoVJHwW- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=425 lowpriorityscore=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961295408100001 Most of these are not modelled in QEMU, so save the overhead of calling a helper. The only exception is dczeroa. It assigns to hex_dczero_addr, which is handled during packet commit. Signed-off-by: Taylor Simpson Reviewed-by: Richard Henderson Message-Id: <20230410202402.2856852-1-tsimpson@quicinc.com> --- target/hexagon/gen_tcg.h | 24 ++++++++++++++++++++++++ target/hexagon/macros.h | 18 ++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h index b189f725d7..329e7a1024 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -487,6 +487,19 @@ #define fGEN_TCG_S2_storerinew_pcr(SHORTCODE) \ fGEN_TCG_STORE_pcr(2, fSTORE(1, 4, EA, NtN)) =20 +/* dczeroa clears the 32 byte cache line at the address given */ +#define fGEN_TCG_Y2_dczeroa(SHORTCODE) SHORTCODE + +/* In linux-user mode, these are not modelled, suppress compiler warning */ +#define fGEN_TCG_Y2_dcinva(SHORTCODE) \ + do { RsV =3D RsV; } while (0) +#define fGEN_TCG_Y2_dccleaninva(SHORTCODE) \ + do { RsV =3D RsV; } while (0) +#define fGEN_TCG_Y2_dccleana(SHORTCODE) \ + do { RsV =3D RsV; } while (0) +#define fGEN_TCG_Y2_icinva(SHORTCODE) \ + do { RsV =3D RsV; } while (0) + /* * dealloc_return * Assembler mapped to @@ -1211,6 +1224,17 @@ do { \ RsV =3D RsV; \ } while (0) +#define fGEN_TCG_Y2_isync(SHORTCODE) \ + do { } while (0) +#define fGEN_TCG_Y2_barrier(SHORTCODE) \ + do { } while (0) +#define fGEN_TCG_Y2_syncht(SHORTCODE) \ + do { } while (0) +#define fGEN_TCG_Y2_dcfetchbo(SHORTCODE) \ + do { \ + RsV =3D RsV; \ + uiV =3D uiV; \ + } while (0) =20 #define fGEN_TCG_J2_trap0(SHORTCODE) \ do { \ diff --git a/target/hexagon/macros.h b/target/hexagon/macros.h index 9ddfc91b1d..3e162de3a7 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -659,20 +659,10 @@ static inline TCGv gen_read_ireg(TCGv result, TCGv va= l, int shift) fEXTRACTU_BITS(env->gpr[HEX_REG_##REG], \ reg_field_info[FIELD].width, \ reg_field_info[FIELD].offset) -#define fBARRIER() -#define fSYNCH() -#define fISYNC() -#define fDCFETCH(REG) \ - do { (void)REG; } while (0) /* Nothing to do in qemu */ -#define fICINVA(REG) \ - do { (void)REG; } while (0) /* Nothing to do in qemu */ -#define fL2FETCH(ADDR, HEIGHT, WIDTH, STRIDE, FLAGS) -#define fDCCLEANA(REG) \ - do { (void)REG; } while (0) /* Nothing to do in qemu */ -#define fDCCLEANINVA(REG) \ - do { (void)REG; } while (0) /* Nothing to do in qemu */ - -#define fDCZEROA(REG) do { env->dczero_addr =3D (REG); } while (0) + +#ifdef QEMU_GENERATE +#define fDCZEROA(REG) tcg_gen_mov_tl(hex_dczero_addr, (REG)) +#endif =20 #define fBRANCH_SPECULATE_STALL(DOTNEWVAL, JUMP_COND, SPEC_DIR, HINTBITNUM= , \ STRBITNUM) /* Nothing */ --=20 2.25.1 From nobody Fri May 17 10:13:45 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=1681961295; cv=none; d=zohomail.com; s=zohoarc; b=JgTifSx3AGfw92pcdsmanmttzZ1JOsLUc9e8CSNkHHKW/8HyqFj6ZuUMKSK3wdHhdmgCzLCwSZWMfBFfvxnEvEeue8k3XaGF/K0CMfR6N79SD+iQ5IDnaBGib35ymxsYAErl/8c1H8Nh6HIDXFbhfrJG0NUszgwn75maDbf4MPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681961295; h=Content-Type: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=P8DlNKJ5yX9HIqgCcrGCYPtfx/s1D5RT2UHcWHueBBE=; b=mt7N5pae6whZL5Fb74sbu9/OpRqgt8E8QysYb97Dfk8Qgs78wIiBu9daxPgpeqmYRfxbK/MJn2gsR1P8RIcbfers1km6D4rAX2sZpd8gNbsAqDdZhnSmuQzzF6lUk6eZJq4zUBoev2OaRtV8G4dTb9tHlF7y5nYfUpCwxkkrYsc= 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 1681961295111137.76812524846366; Wed, 19 Apr 2023 20:28:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppKwq-0003gq-JH; Wed, 19 Apr 2023 23:27:04 -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 1ppKwj-0003fO-ES for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:58 -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 1ppKwf-0000Ij-Eg for qemu-devel@nongnu.org; Wed, 19 Apr 2023 23:26:56 -0400 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33K2QKJm023407; Thu, 20 Apr 2023 03:26:49 GMT Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q2p4v8ss5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:49 +0000 Received: from pps.filterd (NALASPPMTA05.qualcomm.com [127.0.0.1]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 33K3Qmer021094; Thu, 20 Apr 2023 03:26:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 3q2e95vg1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: from NALASPPMTA05.qualcomm.com (NALASPPMTA05.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 33K3Qm4S021086; Thu, 20 Apr 2023 03:26:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 33K3QlIm021082 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Apr 2023 03:26:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 16A036A9; Wed, 19 Apr 2023 20:26:47 -0700 (PDT) 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-type : content-transfer-encoding; s=qcppdkim1; bh=P8DlNKJ5yX9HIqgCcrGCYPtfx/s1D5RT2UHcWHueBBE=; b=QDWJk/+fvhOUBqBsq4CBU4gNk0D8aGCEwhgMoOXeClOH26CWLmAvR8OzyF4MlR969FaP GXUB1eDXdyOJkryXLx7dA/jELrlxq62vco4+9CS/WiiOFTsrHa6JrUGZ8QyRSIcDRnBa WOdrkXdglTFmI1BXSiZ3RYf5WqEFhlDzpzP1KCT98VUhmyCGza98IyNJ+JgNzvKFtsCl FkS4opkJMAnu3rZxHtx6O7lclzWPKMD8XDCktJgUbkNEyxBLVbk1p6pMWQs5DzFmZmg0 EFFhTG3A3BS3PWplvKIsM/qYIQntABI5y++2nHX3r11o6nsiQE7IPngjVZx0bJHLlLda wQ== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, peter.maydell@linaro.org, bcain@quicinc.com, quic_mathbern@quicinc.com, stefanha@redhat.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com Subject: [PULL 11/11] Hexagon (target/hexagon) Additional instructions handled by idef-parser Date: Wed, 19 Apr 2023 20:26:34 -0700 Message-Id: <20230420032634.105311-12-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230420032634.105311-1-tsimpson@quicinc.com> References: <20230420032634.105311-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: MzkgWN0FzJDC0eawq4hJTm6KwKYu51ho X-Proofpoint-ORIG-GUID: MzkgWN0FzJDC0eawq4hJTm6KwKYu51ho X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-19_16,2023-04-18_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 mlxlogscore=777 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304200025 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=tsimpson@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, 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: 1681961296689100005 Currently, idef-parser skips all floating point instructions. However, there are some floating point instructions that can be handled. The following instructions are now parsed F2_sfimm_p F2_sfimm_n F2_dfimm_p F2_dfimm_n F2_dfmpyll F2_dfmpylh To make these instructions work, we fix some bugs in parser-helpers.c gen_rvalue_extend gen_cast_op Test cases added to tests/tcg/hexagon/fpstuff.c Signed-off-by: Taylor Simpson Reviewed-by: Anton Johansson Tested-by: Anton Johansson Message-Id: <20230407205246.395196-1-tsimpson@quicinc.com> --- target/hexagon/idef-parser/parser-helpers.c | 16 +++--- tests/tcg/hexagon/fpstuff.c | 54 +++++++++++++++++++++ target/hexagon/gen_idef_parser_funcs.py | 10 +++- 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/i= def-parser/parser-helpers.c index 86511efb62..fd4d196a79 100644 --- a/target/hexagon/idef-parser/parser-helpers.c +++ b/target/hexagon/idef-parser/parser-helpers.c @@ -386,13 +386,10 @@ HexValue gen_rvalue_extend(Context *c, YYLTYPE *locp,= HexValue *rvalue) =20 if (rvalue->type =3D=3D IMMEDIATE) { HexValue res =3D gen_imm_qemu_tmp(c, locp, 64, rvalue->signedness); - bool is_unsigned =3D (rvalue->signedness =3D=3D UNSIGNED); - const char *sign_suffix =3D is_unsigned ? "u" : ""; gen_c_int_type(c, locp, 64, rvalue->signedness); - OUT(c, locp, " ", &res, " =3D "); - OUT(c, locp, "(", sign_suffix, "int64_t) "); - OUT(c, locp, "(", sign_suffix, "int32_t) "); - OUT(c, locp, rvalue, ";\n"); + OUT(c, locp, " ", &res, " =3D ("); + gen_c_int_type(c, locp, 64, rvalue->signedness); + OUT(c, locp, ")", rvalue, ";\n"); return res; } else { HexValue res =3D gen_tmp(c, locp, 64, rvalue->signedness); @@ -963,7 +960,12 @@ HexValue gen_cast_op(Context *c, if (src->bit_width =3D=3D target_width) { return *src; } else if (src->type =3D=3D IMMEDIATE) { - HexValue res =3D *src; + HexValue res; + if (src->bit_width < target_width) { + res =3D gen_rvalue_extend(c, locp, src); + } else { + res =3D *src; + } res.bit_width =3D target_width; res.signedness =3D signedness; return res; diff --git a/tests/tcg/hexagon/fpstuff.c b/tests/tcg/hexagon/fpstuff.c index 90ce9a6ef3..28f9397155 100644 --- a/tests/tcg/hexagon/fpstuff.c +++ b/tests/tcg/hexagon/fpstuff.c @@ -20,6 +20,7 @@ */ =20 #include +#include =20 const int FPINVF_BIT =3D 1; /* Invalid */ const int FPINVF =3D 1 << FPINVF_BIT; @@ -706,6 +707,57 @@ static void check_float2int_convs() check_fpstatus(usr, FPINVF); } =20 +static void check_float_consts(void) +{ + int res32; + unsigned long long res64; + + asm("%0 =3D sfmake(#%1):neg\n\t" : "=3Dr"(res32) : "i"(0xf)); + check32(res32, 0xbc9e0000); + + asm("%0 =3D sfmake(#%1):pos\n\t" : "=3Dr"(res32) : "i"(0xf)); + check32(res32, 0x3c9e0000); + + asm("%0 =3D dfmake(#%1):neg\n\t" : "=3Dr"(res64) : "i"(0xf)); + check64(res64, 0xbf93c00000000000ULL); + + asm("%0 =3D dfmake(#%1):pos\n\t" : "=3Dr"(res64) : "i"(0xf)); + check64(res64, 0x3f93c00000000000ULL); +} + +static inline unsigned long long dfmpyll(double x, double y) +{ + unsigned long long res64; + asm("%0 =3D dfmpyll(%1, %2)" : "=3Dr"(res64) : "r"(x), "r"(y)); + return res64; +} + +static inline unsigned long long dfmpylh(double acc, double x, double y) +{ + unsigned long long res64 =3D *(unsigned long long *)&acc; + asm("%0 +=3D dfmpylh(%1, %2)" : "+r"(res64) : "r"(x), "r"(y)); + return res64; +} + +static void check_dfmpyxx(void) +{ + unsigned long long res64; + + res64 =3D dfmpyll(DBL_MIN, DBL_MIN); + check64(res64, 0ULL); + res64 =3D dfmpyll(-1.0, DBL_MIN); + check64(res64, 0ULL); + res64 =3D dfmpyll(DBL_MAX, DBL_MAX); + check64(res64, 0x1fffffffdULL); + + res64 =3D dfmpylh(DBL_MIN, DBL_MIN, DBL_MIN); + check64(res64, 0x10000000000000ULL); + res64 =3D dfmpylh(-1.0, DBL_MAX, DBL_MIN); + check64(res64, 0xc00fffffffe00000ULL); + res64 =3D dfmpylh(DBL_MAX, 0.0, -1.0); + check64(res64, 0x7fefffffffffffffULL); +} + int main() { check_compare_exception(); @@ -718,6 +770,8 @@ int main() check_sffixupd(); check_sffms(); check_float2int_convs(); + check_float_consts(); + check_dfmpyxx(); =20 puts(err ? "FAIL" : "PASS"); return err ? 1 : 0; diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_i= def_parser_funcs.py index afe68bdb6f..b766798ad5 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -103,7 +103,15 @@ def main(): continue if tag.startswith("V6_"): continue - if tag.startswith("F"): + if ( tag.startswith("F") and + tag not in { + "F2_sfimm_p", + "F2_sfimm_n", + "F2_dfimm_p", + "F2_dfimm_n", + "F2_dfmpyll", + "F2_dfmpylh" + }): continue if tag.endswith("_locked"): continue --=20 2.25.1