From nobody Tue Feb 10 05:45:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1666219423; cv=none; d=zohomail.com; s=zohoarc; b=B6Hs46VYnU05+mpqHNJU+iuXAr7587Tr9C8oQyH4IKVZR8U2bwIuwNvYiw6OcT+4H0NT6JvF1slosbyIej4D4rvLSg7f29Noffdypsk0en7mAtbNj8mwyd2b1XHvTFHUVhW+weD02ElxnMGeh2z4RqK1OWNfu+rpWxYH/QEB4+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666219423; 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=4DTUFPONS7mCcCdC7LBzEnEQ0eZqxeJWfwGgc4iR6cg=; b=YSn4y7HbXJz4b7r3f/kopAImuL9F3HPojgfqG/q2zaf57NfxGjdn3e1VbslZLQJpuKXOsYRYA53V58ImQXsvLqaikf0Q2PQhyKJEBlm9pKqas0pNIhDWzxaTcc/0b62P15yaTM+OdQRpuwetvKvZX3kZJwboIJf7Er1G+QzQazs= 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 1666219423455687.981899157394; Wed, 19 Oct 2022 15:43:43 -0700 (PDT) Received: from localhost ([::1]:50440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olHmm-0000LW-5V for importer@patchew.org; Wed, 19 Oct 2022 18:43:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olHhP-0002LZ-C2 for qemu-devel@nongnu.org; Wed, 19 Oct 2022 18:38:08 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]:45838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olHh8-00029k-Qe for qemu-devel@nongnu.org; Wed, 19 Oct 2022 18:38:07 -0400 Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29JBr80Q000949; Wed, 19 Oct 2022 22:37:43 GMT Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ka5emmaf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 22:37:43 +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 29JMbhVI030406; Wed, 19 Oct 2022 22:37:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTP id 3k7nxkwatw-1; Wed, 19 Oct 2022 22:37:43 +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 29JMbgT2030401; Wed, 19 Oct 2022 22:37:42 GMT Received: from hu-devc-lv-u18-c.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.235.220]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTP id 29JMbggL030397; Wed, 19 Oct 2022 22:37:42 +0000 Received: by hu-devc-lv-u18-c.qualcomm.com (Postfix, from userid 47164) id C3D04500102; Wed, 19 Oct 2022 15:37:41 -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=4DTUFPONS7mCcCdC7LBzEnEQ0eZqxeJWfwGgc4iR6cg=; b=NBHdLLlfA9r8Gff8YsoSPDI0FVhQgQywWmioAd5T/mBrnzqaLKPwOV/zHiK1m7OQoGHo R+U/p6f0R+iquFVM7zUJXCYo6+eTWAVBRIZZtdNlvSWIDkJrbN10CU/j3tMpc7Famiza uA38RiRIjPICG4Wqf0WelIZxPxoHkg+NX/OJGAyuAr1i0MGTTxPWd9zrwyyKfFNdVrsA GBOR2JZcwJwRipORmTxeoIFRTtwJk6dDzIANMGnWQTThtvtFmloYuXEFEursHdQRWi3I zP0GRqKzCe/2T9U6VYLNP+mj/1R9/S/ufLv/slgnSG0vkpgLCKU06wFZ1WQOfnNUv7IK GA== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, ale@rev.ng, anjo@rev.ng, bcain@quicinc.com, quic_mathbern@quicinc.com Subject: [PATCH 7/8] Hexagon (target/hexagon) Use direct block chaining for direct jump/branch Date: Wed, 19 Oct 2022 15:37:38 -0700 Message-Id: <20221019223739.3868-8-tsimpson@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221019223739.3868-1-tsimpson@quicinc.com> References: <20221019223739.3868-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: 0tii88ODWwxRxK7jqe5xBPoGAKSnp7-k X-Proofpoint-GUID: 0tii88ODWwxRxK7jqe5xBPoGAKSnp7-k X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-19_12,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=881 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210190125 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.168.131; envelope-from=tsimpson@qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=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" X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1666219424975100001 Direct block chaining is documented here https://qemu.readthedocs.io/en/latest/devel/tcg.html#direct-block-chaining Recall that Hexagon allows packets with multiple jumps where only the first one with a true predicate will actually jump. So, we can only use direct block chaining when the packet contains a single PC-relative jump. We add the following to DisasContext in order to perform direct block chaining at the end of packet commit (in gen_end_tb) has_single_direct_branch Indicates that we can use direct block chaining branch_cond The condition under which the branch is taken branch_dest The destination of the branch Signed-off-by: Taylor Simpson --- target/hexagon/translate.h | 3 +++ target/hexagon/genptr.c | 13 ++++++------- target/hexagon/translate.c | 39 +++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h index eae358cf33..e60dbf0e7a 100644 --- a/target/hexagon/translate.h +++ b/target/hexagon/translate.h @@ -54,6 +54,9 @@ typedef struct DisasContext { bool qreg_is_predicated[NUM_QREGS]; int qreg_log_idx; bool pre_commit; + bool has_single_direct_branch; + TCGv branch_cond; + target_ulong branch_dest; } DisasContext; =20 static inline void ctx_log_reg_write(DisasContext *ctx, int rnum) diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index fba76d3b38..07b4326e56 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -505,15 +505,14 @@ static void gen_write_new_pc_pcrel(DisasContext *ctx,= Packet *pkt, gen_set_label(pred_false); } } else { - TCGLabel *pred_false =3D NULL; + /* Defer this jump to the end of the TB */ + g_assert(ctx->branch_cond =3D=3D NULL); + ctx->has_single_direct_branch =3D true; if (pred !=3D NULL) { - pred_false =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, pred, 0, pred_false); - } - tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest); - if (pred !=3D NULL) { - gen_set_label(pred_false); + ctx->branch_cond =3D tcg_temp_local_new(); + tcg_gen_mov_tl(ctx->branch_cond, pred); } + ctx->branch_dest =3D dest; } } =20 diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 71ad2da682..29e2caaf0f 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -116,10 +116,44 @@ static void gen_exec_counters(DisasContext *ctx) hex_gpr[HEX_REG_QEMU_HVX_CNT], ctx->num_hvx_insns); } =20 +static bool use_goto_tb(DisasContext *ctx, target_ulong dest) +{ + return translator_use_goto_tb(&ctx->base, dest); +} + +static void gen_goto_tb(DisasContext *ctx, int idx, target_ulong dest) +{ + if (use_goto_tb(ctx, dest)) { + tcg_gen_goto_tb(idx); + 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); + tcg_gen_lookup_and_goto_ptr(); + } +} + static void gen_end_tb(DisasContext *ctx) { gen_exec_counters(ctx); - tcg_gen_exit_tb(NULL, 0); + + if (ctx->has_single_direct_branch) { + if (ctx->branch_cond !=3D NULL) { + TCGLabel *skip =3D gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_EQ, ctx->branch_cond, 0, skip); + gen_goto_tb(ctx, 0, ctx->branch_dest); + gen_set_label(skip); + gen_goto_tb(ctx, 1, ctx->next_PC); + tcg_temp_free(ctx->branch_cond); + ctx->branch_cond =3D NULL; + } else { + gen_goto_tb(ctx, 0, ctx->branch_dest); + } + } else { + tcg_gen_lookup_and_goto_ptr(); + } + + g_assert(ctx->branch_cond =3D=3D NULL); ctx->base.is_jmp =3D DISAS_NORETURN; } =20 @@ -803,6 +837,9 @@ static void hexagon_tr_init_disas_context(DisasContextB= ase *dcbase, =20 static void hexagon_tr_tb_start(DisasContextBase *db, CPUState *cpu) { + DisasContext *ctx =3D container_of(db, DisasContext, base); + ctx->has_single_direct_branch =3D false; + ctx->branch_cond =3D NULL; } =20 static void hexagon_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) --=20 2.17.1