From patchwork Tue Nov 8 16:28:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 13036512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4E42C433FE for ; Tue, 8 Nov 2022 16:36:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osRTU-0006lH-8c; Tue, 08 Nov 2022 11:29:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osRTT-0006kF-4o for qemu-devel@nongnu.org; Tue, 08 Nov 2022 11:29:19 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osRTM-0008TT-BL for qemu-devel@nongnu.org; Tue, 08 Nov 2022 11:29:18 -0500 Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A8Fqo0E006645; Tue, 8 Nov 2022 16:29:09 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=/MqguGudskmNGFlrwPgqdOLFkvpRO/BPoQoE2qTznJ4=; b=hQiD9kCaOYZQDxOz1COsFuxhk6tuDLpExQ/hcbIYbULvX7327rNGY8iepLbG+QSifc6a XXdSu3W0+O4LD/yBqIg/1sJv4bSyCEEaLdUDv+DGMdnLXclr5xLIUK/EJzW1IYiDSMfG 0WO7a5pPGUua9WOr+KWhbNe8l2fH778CzhXBvyqydsZAvCCUgbuop6Q2H19Q4VNa8Zn9 KqZzN4iKG2CkVdoSvAPdCFB/yh3X+GO2Ak4vDgepmDjcC8savRnaELqjFVel0PYDomKU g0tlxfAmydiXHPhXnwR3EsDGRooTgWfyDy3JYV9xCGAPKESReGYBQ/Fm4HlUZOWGxUYF zA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3kqhktsgmt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Nov 2022 16:29:09 +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 2A8GT8hn017350; Tue, 8 Nov 2022 16:29:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 3kngwm4ds9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 08 Nov 2022 16:29:08 +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 2A8GR3xI015085; Tue, 8 Nov 2022 16:29:08 GMT Received: from hu-devc-lv-u18-c.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.235.220]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTP id 2A8GT7rR017329; Tue, 08 Nov 2022 16:29:08 +0000 Received: by hu-devc-lv-u18-c.qualcomm.com (Postfix, from userid 47164) id 985965000A7; Tue, 8 Nov 2022 08:29:07 -0800 (PST) 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 v5 00/11] Hexagon (target/hexagon) performance and bug fixes Date: Tue, 8 Nov 2022 08:28:55 -0800 Message-Id: <20221108162906.3166-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-GUID: 1Qc9u2bbFqD2-PaGInISFlJA6gjMzm_y X-Proofpoint-ORIG-GUID: 1Qc9u2bbFqD2-PaGInISFlJA6gjMzm_y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-07_11,2022-11-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 phishscore=0 mlxlogscore=645 spamscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 bulkscore=0 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211080101 Received-SPF: pass client-ip=205.220.168.131; envelope-from=tsimpson@qualcomm.com; helo=mx0a-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.25, 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 1) Performance improvement Add pkt and insn to DisasContext Many functions need information from all 3 structures, so merge them together. 2) Bug fix Fix predicated assignment to .tmp and .cur 3) Performance improvement Add overrides for S2_asr_r_r_sat/S2_asl_r_r_sat These functions will not be handled by idef-parser 4-11) The final 8 patches improve 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. 4) 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. 5, 6) 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. 7, 8, 9) 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. 10) 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. 11) 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 V5 **** Address feedback from Richard Henderson Handle out-of-range shifts in gen_shl_sat **** Changes in V4 **** Address feedback from Richard Henderson Rewrite gen_sat_i64 to be branchless Rewrite gen_sar to be branchless Rewrite gen_shl_sat to be branchless Pass branch condition instead of doing xor when false Use hex_branch_taken to hold the predicate for direct branches Remove HexStateFlags and use "hw/registerfields.h" macros instead **** Changes in V3 **** Merge previously emailed patches into single series Merge functions that check if vreg is preloaded **** Changes in V2 **** Update test case to use both true and false predicates Add fix for .cur 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 (11): Hexagon (target/hexagon) Add pkt and insn to DisasContext Hexagon (target/hexagon) Fix predicated assignment to .tmp and .cur Hexagon (target/hexagon) Add overrides for S2_asr_r_r_sat/S2_asl_r_r_sat 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 | 14 +- target/hexagon/gen_tcg.h | 414 +++++++++++++++++++++++++++- target/hexagon/gen_tcg_hvx.h | 6 +- target/hexagon/insn.h | 9 +- target/hexagon/macros.h | 16 +- target/hexagon/mmvec/macros.h | 4 +- target/hexagon/translate.h | 20 +- target/hexagon/decode.c | 15 +- target/hexagon/genptr.c | 392 +++++++++++++++++++++++++- target/hexagon/op_helper.c | 28 +- target/hexagon/translate.c | 231 +++++++++++----- tests/tcg/hexagon/hvx_misc.c | 72 +++++ tests/tcg/hexagon/usr.c | 34 ++- target/hexagon/gen_helper_funcs.py | 13 +- target/hexagon/gen_helper_protos.py | 14 +- target/hexagon/gen_tcg_funcs.py | 38 ++- target/hexagon/hex_common.py | 29 +- 17 files changed, 1211 insertions(+), 138 deletions(-)