From patchwork Tue Nov 8 04:05:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 13035799 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 E07ACC4321E for ; Tue, 8 Nov 2022 04:07:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osFsG-000702-TT; Mon, 07 Nov 2022 23:06:08 -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 1osFsA-0006y2-NC for qemu-devel@nongnu.org; Mon, 07 Nov 2022 23:06:04 -0500 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 1osFs8-00073k-FM for qemu-devel@nongnu.org; Mon, 07 Nov 2022 23:06:02 -0500 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 2A834woC009015; Tue, 8 Nov 2022 04:05:56 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=wEd3MNQONA2FwkvbbSc7ibV6oIfSjgkNDStKjW2cALg=; b=FiqLotuJG8R9VfDYcZBRmABsvhLbnTFOBWitVK7EwpBXUd1zGtO6iMAIcAbzBNn8MppK Lb4u2HXXR08dMNbH0GEe6OmHlo0C/3oR4e83fBLULM/muzZn5rmPNZhQ5r60mAucXW56 /p8pOMKMHaUAMLI4ZnWlxPp4EQUCvYOOBW0Idk62EIXDdaM3dh3ME8Rw7PtxC/roj+dX 3/7NlZdvobcxxumguZUUprSoX51tdTiWttyG1ihuNasPXVDg66l0lldJcUQh+snkXQnk ZwAO+nYmER0re/o0s4VsKK9j4EJf8G0JF7kJ3GVbAfiOQ6/WMS6Zy7wWqyAL31zNMPDn fQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3kq5yq98qg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Nov 2022 04:05:56 +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 2A83wPmn017368; Tue, 8 Nov 2022 04:05:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 3kngwm1v8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 08 Nov 2022 04:05:55 +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 2A841wMk022039; Tue, 8 Nov 2022 04:05:54 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 2A845sO3025731; Tue, 08 Nov 2022 04:05:54 +0000 Received: by hu-devc-lv-u18-c.qualcomm.com (Postfix, from userid 47164) id 11DA35000A7; Mon, 7 Nov 2022 20:05:54 -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 v4 00/11] Hexagon (target/hexagon) performance and bug fixes Date: Mon, 7 Nov 2022 20:05:41 -0800 Message-Id: <20221108040552.22175-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: pmhmOQjrigLzfErnsOdNS9Op_HXieU-B X-Proofpoint-ORIG-GUID: pmhmOQjrigLzfErnsOdNS9Op_HXieU-B 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-07_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 mlxlogscore=671 malwarescore=0 spamscore=0 suspectscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211080020 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.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 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 | 30 +- 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, 1207 insertions(+), 138 deletions(-)