From patchwork Mon Oct 24 23:51:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 1694071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quicinc.com header.i=@quicinc.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=A9BXTadb; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MxBjp3fT5z23kR for ; Tue, 25 Oct 2022 10:53:49 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on7Ez-00033K-GM; Mon, 24 Oct 2022 19:52:21 -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 1on7E8-0000kT-Iv for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:51:29 -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 1on7E4-0005Cd-Up for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:51:28 -0400 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29ONbQCs029786; Mon, 24 Oct 2022 23:51:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=QfJupkI4lG4o5CWsNViyCgAEm1gEaa2bQvibQgZ7s/U=; b=A9BXTadb3u7ucWuMzfIG2VhDZxeksCRW03i3f1QFrBDbOUWiD6/5Uw4hT90gdDq8c12N JuUCgIQPppdvHJUOqp0lGRD9TYaQgVrywRddfWeuw7Mspu8q7KSfYTUz1jrq17cYDJxJ iBQJXV76nsfIze3zXfGOUbg9q3f8uAGH5u5pK0/AAJQgMPZ9GlCRxqY7h4+RRhCObJ5/ pt2u4UHJ/gRtH7TroPkgUW5wxT1LZkRourpOG77p7CMHFBkRKoKPua9FtoxhYfAzxlgA YULeuQwHCbsAYl9dCDt0glM828YrgLrar8ID1Jkyw9w7dlF5shFfDP2HMDfuU4GAbg25 cQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3kc7utcr4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 24 Oct 2022 23:51:21 +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 29ONpJso021251; Mon, 24 Oct 2022 23:51:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA03.qualcomm.com (PPS) with ESMTP id 3kc9kkr1y2-1; Mon, 24 Oct 2022 23:51:19 +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 29ONpJfd021246; Mon, 24 Oct 2022 23:51:19 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 29ONpJrh021244; Mon, 24 Oct 2022 23:51:19 +0000 Received: by hu-devc-lv-u18-c.qualcomm.com (Postfix, from userid 47164) id 3523B5000A7; Mon, 24 Oct 2022 16:51:19 -0700 (PDT) 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 v2 0/8] Hexagon (target/hexagon) Improve change-of-flow Date: Mon, 24 Oct 2022 16:51:09 -0700 Message-Id: <20221024235117.3663-1-tsimpson@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 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: 7Mi6cDa0UIYh-p4v0pQBAepGVvMji71U X-Proofpoint-GUID: 7Mi6cDa0UIYh-p4v0pQBAepGVvMji71U 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-24_07,2022-10-21_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=5 priorityscore=1501 impostorscore=0 mlxscore=5 malwarescore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 spamscore=5 bulkscore=0 mlxlogscore=125 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210240142 Received-SPF: pass client-ip=205.220.180.131; envelope-from=tsimpson@qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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.249, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch series improves change-of-flow handling. Currently, we set the PC to a new address before exiting a TB. The ultimate goal is to use direct block chaining. However, several steps are needed along the way. 1) When a packet has more than one change-of-flow (COF) instruction, only the first one taken is considered. The runtime bookkeeping is only needed when there is more than one COF instruction in a packet. 2, 3) Remove PC and next_PC from the runtime state and always use a translation-time constant. Note that next_PC is used by call instructions to set LR and by conditional COF instructions to set the fall-through address. 4, 5, 6) Add helper overrides for COF instructions. In particular, we must distinguish those that use a PC-relative address for the destination. These are candidates for direct block chaining later. 7) Use direct block chaining for packets that have a single PC-relative COF instruction. Instead of generating the code while processing the instruction, we record the effect in DisasContext and generate the code during gen_end_tb. 8) Use direct block chaining for tight loops. We look for TBs that end with an endloop0 that will branch back to the TB start address. **** Changes in V2 **** Simplify test in need_pkt_has_multi_cof Address feedback from Matheus Tavares Bernardino Rearrange new-value-jump overrides Simplify gen_write_new_pc_addr Taylor Simpson (8): Hexagon (target/hexagon) Only use branch_taken when packet has multi cof Hexagon (target/hexagon) Remove PC from the runtime state Hexagon (target/hexagon) Remove next_PC from runtime state Hexagon (target/hexagon) Add overrides for direct call instructions Hexagon (target/hexagon) Add overrides for compound compare and jump Hexagon (target/hexagon) Add overrides for various forms of jump Hexagon (target/hexagon) Use direct block chaining for direct jump/branch Hexagon (target/hexagon) Use direct block chaining for tight loops target/hexagon/cpu.h | 18 +- target/hexagon/gen_tcg.h | 390 ++++++++++++++++++++++++++++ target/hexagon/insn.h | 2 + target/hexagon/macros.h | 6 +- target/hexagon/translate.h | 6 +- target/hexagon/decode.c | 15 +- target/hexagon/genptr.c | 260 +++++++++++++++++++ target/hexagon/op_helper.c | 28 +- target/hexagon/translate.c | 120 +++++++-- target/hexagon/gen_helper_funcs.py | 11 + target/hexagon/gen_helper_protos.py | 12 +- target/hexagon/gen_tcg_funcs.py | 11 + target/hexagon/hex_common.py | 29 ++- 13 files changed, 863 insertions(+), 45 deletions(-)