From patchwork Wed Apr 5 16:42:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 1765673 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=gQMXYbiR; 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 4Ps9Sw15qPz1yY8 for ; Thu, 6 Apr 2023 02:44:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pk6Ec-0005fm-VX; Wed, 05 Apr 2023 12:43:47 -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 1pk6Ec-0005fb-B6 for qemu-devel@nongnu.org; Wed, 05 Apr 2023 12:43:46 -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 1pk6Ea-0005Zi-6X for qemu-devel@nongnu.org; Wed, 05 Apr 2023 12:43:46 -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 335GJkLL003919; Wed, 5 Apr 2023 16:43:43 GMT 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=MNjh0v3sqXBFH6TdAE1xyyYHYP3lmU9n5Di7EJLFstA=; b=gQMXYbiRXNxjZoU6Dwg4e8c/pyHMOjdIO1RiSPZC4O5IPnNGGoYWgmjcOk4NuY8enflW gI6Pgoh3llycgYJhFcwQiD4iZoZ1jseyLTtqwIBRvNPbAN0FRusB3TyeqJrNdzqBbBHH mKATMqPHTifbuVw7a9OuVUjHi+Pi/Jd9E8berqxptvFqlFXXawoTnklsjtl7hHB2Dcxo VTdF1vjO2LZ42FN+iTDiEfmhh7CoeMecG4e8d3d6NP3Zjpn80ST+mwsBJ6I+Bp5QGO4M 0DuVMSt4HlF6rmKfSBuSYq0qGLs7f3wHeVlDO25c6vEe8sAXCzIoT3+tAnKGv3eeaAtS sA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3prn7qkg6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Apr 2023 16:43:42 +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 335Ghfce009213; Wed, 5 Apr 2023 16:43:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 3ppdpm87xk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Apr 2023 16:43:41 +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 335GheUb009205; Wed, 5 Apr 2023 16:43:40 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 335GheoI009198 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Apr 2023 16:43:40 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id BE2B4594; Wed, 5 Apr 2023 09:43:40 -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] Hexagon (target/hexagon) Updates to USR should use get_result_gpr Date: Wed, 5 Apr 2023 09:42:11 -0700 Message-Id: <20230405164211.30015-3-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405164211.30015-1-tsimpson@quicinc.com> References: <20230405164211.30015-1-tsimpson@quicinc.com> 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: OmJ5J2yXtBXgD3fCGe402ile0F-V55g4 X-Proofpoint-GUID: OmJ5J2yXtBXgD3fCGe402ile0F-V55g4 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-05_09,2023-04-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304050150 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Taylor Simpson --- 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 bcf0cf466a..c71df90577 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -1039,11 +1039,11 @@ /* r0 = 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) /* r0 = 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) #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 Reserved. + * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. 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 @@ -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 width); 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 width); -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 482a9c787f..687a289f17 100644 --- a/target/hexagon/macros.h +++ b/target/hexagon/macros.h @@ -48,14 +48,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, } } -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_USR], - val, + TCGv usr = get_result_gpr(ctx, HEX_REG_USR); + tcg_gen_deposit_tl(usr, usr, val, reg_field_info[field].offset, reg_field_info[field].width); } -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 == 1) { + TCGv usr = get_result_gpr(ctx, HEX_REG_USR); target_ulong bit = 1 << reg_field_info[field].offset; if ((x & 1) == 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 = tcg_constant_tl(x); - gen_set_usr_field(field, val); + gen_set_usr_field(ctx, field, val); } } @@ -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); @@ -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); @@ -878,8 +875,9 @@ static void gen_cmpi_jumpnv(DisasContext *ctx, } /* 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 = get_result_gpr(ctx, HEX_REG_USR); TCGv sh32 = tcg_temp_new(); TCGv dst_sar = tcg_temp_new(); TCGv ovf = tcg_temp_new(); @@ -911,7 +909,7 @@ static void gen_shl_sat(TCGv dst, TCGv src, TCGv shift_amt) 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); 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) } /* 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 RtV) { TCGv shift_amt = tcg_temp_new(); TCGLabel *positive = gen_new_label(); @@ -939,7 +937,7 @@ static void gen_asr_r_r_sat(TCGv RdV, TCGv RsV, TCGv RtV) /* Negative shift amount => 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); gen_set_label(positive); @@ -950,7 +948,7 @@ static void gen_asr_r_r_sat(TCGv RdV, TCGv RsV, TCGv RtV) } /* 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 RtV) { TCGv shift_amt = tcg_temp_new(); TCGLabel *positive = gen_new_label(); @@ -966,7 +964,7 @@ static void gen_asl_r_r_sat(TCGv RdV, TCGv RsV, TCGv RtV) gen_set_label(positive); /* Positive shift amount => shift left */ - gen_shl_sat(RdV, RsV, shift_amt); + gen_shl_sat(ctx, RdV, RsV, shift_amt); 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 == 1) { + TCGv usr = get_result_gpr(ctx, HEX_REG_USR); TCGv tmp = 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 = 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) } /* 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 = tcg_temp_new_i64(); TCGv_i64 xor = tcg_temp_new_i64(); @@ -1227,7 +1224,7 @@ void gen_add_sat_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 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); gen_set_label(ret_label); } diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/idef-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 = rvalue_materialize(c, locp, op1); HexValue op2_m = 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"); } void gen_inst(Context *c, GString *iname) @@ -1971,7 +1972,7 @@ HexValue gen_rvalue_sat(Context *c, YYLTYPE *locp, HexSat *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"); 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 '=' rvalue "Assignment side-effect not modeled!"); $3 = gen_rvalue_truncate(c, &@1, &$3); $3 = 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 ')' {