From nobody Fri May 17 03:00:50 2024 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=1680900810; cv=none; d=zohomail.com; s=zohoarc; b=mNGGZ1Q+Cb263uvFzdzNE1TAuT2dmiR1V9HmpIrZhUhNtanZ6guydd1B2lpY0rr2ELMF7KPTGwGy+yPWdCjz4clKXeTuHoH/XLEQTjO5jatQE16OzpmPpFJOKeVfoTQ6w2pUXga/MwPbN0CqvdMC4S3Y5Fy1C4c7Ve7tx7MdsyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680900810; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=28TCsG3mfEAT8KlGZLgJjsOLHmK2t1ay63syPe92THk=; b=VGInixVFld4kxu7MoHsqHH7NldNfmW6OmnkhQq1tY5ORakvZxuDsUNdm3boHBCxEAHBWGoUeiTRbb7vOGexkdpihsp7TyXlrxq6o1k/MwK0jztGN2OlDLIMJjTIsOLBXkJ1HsVLcXeL/ZvgBv6qfanYjsb9GOY1tC8+MzeS1cNo= 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 168090081035212.555055680847772; Fri, 7 Apr 2023 13:53:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkt4r-0007pl-Fo; Fri, 07 Apr 2023 16:52:57 -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 1pkt4p-0007pO-B6 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 16:52:55 -0400 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 1pkt4n-000737-7k for qemu-devel@nongnu.org; Fri, 07 Apr 2023 16:52:55 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 337KX0x8019606; Fri, 7 Apr 2023 20:52:50 GMT Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pth8bsagg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 20:52:49 +0000 Received: from pps.filterd (NALASPPMTA04.qualcomm.com [127.0.0.1]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 337Kqnid016968; Fri, 7 Apr 2023 20:52:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 3ppdpmdhwn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 20:52:49 +0000 Received: from NALASPPMTA04.qualcomm.com (NALASPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 337KnWaQ014089; Fri, 7 Apr 2023 20:52:48 GMT Received: from hu-devc-sd-u20-a-1.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.204.221]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 337KqmBE016960 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 20:52:48 +0000 Received: by hu-devc-sd-u20-a-1.qualcomm.com (Postfix, from userid 47164) id 58B36666; Fri, 7 Apr 2023 13:52:48 -0700 (PDT) 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=28TCsG3mfEAT8KlGZLgJjsOLHmK2t1ay63syPe92THk=; b=F6M49zCWVZGmpvQAUkMDtDYQ+RT8lecvoXz0mf9VdxrZ5IEUOr8GUr2fOy0zPKpZKWjz upalAsw/A6r8oOBTJ1H2KIA3SCw7246ISfTESZEUtMtMLIbISqEcIRmO8Kj9P7+6VjFP zWOIDAakwHqNMpEk2CwIyQ61KRk0NYXg+fhPMLCwjSuhevli5wodicJvv+/Bcz60qEqa jalkSGyAcVSoXkzktnJTDR7iEIOEnf2cXtwas3L7SU0KHQXYts87fSWN8USHfQBFDY84 cS+J/3O2DcXR/UUgjASr1smwxdwvK5Z1TUFki2zm9vGDKFBCBsgAT5pEHP2Xv8IwdKdz vA== 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) Additional instructions handled by idef-parser Date: Fri, 7 Apr 2023 13:52:46 -0700 Message-Id: <20230407205246.395196-1-tsimpson@quicinc.com> X-Mailer: git-send-email 2.25.1 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-GUID: 1jPaybTEyswYsTHT17GxaM3_ZGdUWxXB X-Proofpoint-ORIG-GUID: 1jPaybTEyswYsTHT17GxaM3_ZGdUWxXB 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-07_13,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=754 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304070188 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: -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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1680900811771100001 Currently, idef-parser skips all floating point instructions. However, there are some floating point instructions that can be handled. The following instructions are now parsed F2_sfimm_p F2_sfimm_n F2_dfimm_p F2_dfimm_n F2_dfmpyll F2_dfmpylh To make these instructions work, we fix some bugs in parser-helpers.c gen_rvalue_extend gen_cast_op Test cases added to tests/tcg/hexagon/fpstuff.c Signed-off-by: Taylor Simpson Reviewed-by: Anton Johansson Tested-by: Anton Johansson --- target/hexagon/idef-parser/parser-helpers.c | 16 +++--- tests/tcg/hexagon/fpstuff.c | 54 +++++++++++++++++++++ target/hexagon/gen_idef_parser_funcs.py | 10 +++- 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/i= def-parser/parser-helpers.c index 18cde6a1be..0b160e6f58 100644 --- a/target/hexagon/idef-parser/parser-helpers.c +++ b/target/hexagon/idef-parser/parser-helpers.c @@ -386,13 +386,10 @@ HexValue gen_rvalue_extend(Context *c, YYLTYPE *locp,= HexValue *rvalue) =20 if (rvalue->type =3D=3D IMMEDIATE) { HexValue res =3D gen_imm_qemu_tmp(c, locp, 64, rvalue->signedness); - bool is_unsigned =3D (rvalue->signedness =3D=3D UNSIGNED); - const char *sign_suffix =3D is_unsigned ? "u" : ""; gen_c_int_type(c, locp, 64, rvalue->signedness); - OUT(c, locp, " ", &res, " =3D "); - OUT(c, locp, "(", sign_suffix, "int64_t) "); - OUT(c, locp, "(", sign_suffix, "int32_t) "); - OUT(c, locp, rvalue, ";\n"); + OUT(c, locp, " ", &res, " =3D ("); + gen_c_int_type(c, locp, 64, rvalue->signedness); + OUT(c, locp, ")", rvalue, ";\n"); return res; } else { HexValue res =3D gen_tmp(c, locp, 64, rvalue->signedness); @@ -963,7 +960,12 @@ HexValue gen_cast_op(Context *c, if (src->bit_width =3D=3D target_width) { return *src; } else if (src->type =3D=3D IMMEDIATE) { - HexValue res =3D *src; + HexValue res; + if (src->bit_width < target_width) { + res =3D gen_rvalue_extend(c, locp, src); + } else { + res =3D *src; + } res.bit_width =3D target_width; res.signedness =3D signedness; return res; diff --git a/tests/tcg/hexagon/fpstuff.c b/tests/tcg/hexagon/fpstuff.c index 90ce9a6ef3..28f9397155 100644 --- a/tests/tcg/hexagon/fpstuff.c +++ b/tests/tcg/hexagon/fpstuff.c @@ -20,6 +20,7 @@ */ =20 #include +#include =20 const int FPINVF_BIT =3D 1; /* Invalid */ const int FPINVF =3D 1 << FPINVF_BIT; @@ -706,6 +707,57 @@ static void check_float2int_convs() check_fpstatus(usr, FPINVF); } =20 +static void check_float_consts(void) +{ + int res32; + unsigned long long res64; + + asm("%0 =3D sfmake(#%1):neg\n\t" : "=3Dr"(res32) : "i"(0xf)); + check32(res32, 0xbc9e0000); + + asm("%0 =3D sfmake(#%1):pos\n\t" : "=3Dr"(res32) : "i"(0xf)); + check32(res32, 0x3c9e0000); + + asm("%0 =3D dfmake(#%1):neg\n\t" : "=3Dr"(res64) : "i"(0xf)); + check64(res64, 0xbf93c00000000000ULL); + + asm("%0 =3D dfmake(#%1):pos\n\t" : "=3Dr"(res64) : "i"(0xf)); + check64(res64, 0x3f93c00000000000ULL); +} + +static inline unsigned long long dfmpyll(double x, double y) +{ + unsigned long long res64; + asm("%0 =3D dfmpyll(%1, %2)" : "=3Dr"(res64) : "r"(x), "r"(y)); + return res64; +} + +static inline unsigned long long dfmpylh(double acc, double x, double y) +{ + unsigned long long res64 =3D *(unsigned long long *)&acc; + asm("%0 +=3D dfmpylh(%1, %2)" : "+r"(res64) : "r"(x), "r"(y)); + return res64; +} + +static void check_dfmpyxx(void) +{ + unsigned long long res64; + + res64 =3D dfmpyll(DBL_MIN, DBL_MIN); + check64(res64, 0ULL); + res64 =3D dfmpyll(-1.0, DBL_MIN); + check64(res64, 0ULL); + res64 =3D dfmpyll(DBL_MAX, DBL_MAX); + check64(res64, 0x1fffffffdULL); + + res64 =3D dfmpylh(DBL_MIN, DBL_MIN, DBL_MIN); + check64(res64, 0x10000000000000ULL); + res64 =3D dfmpylh(-1.0, DBL_MAX, DBL_MIN); + check64(res64, 0xc00fffffffe00000ULL); + res64 =3D dfmpylh(DBL_MAX, 0.0, -1.0); + check64(res64, 0x7fefffffffffffffULL); +} + int main() { check_compare_exception(); @@ -718,6 +770,8 @@ int main() check_sffixupd(); check_sffms(); check_float2int_convs(); + check_float_consts(); + check_dfmpyxx(); =20 puts(err ? "FAIL" : "PASS"); return err ? 1 : 0; diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_i= def_parser_funcs.py index 917753d6d8..9bed7ee55e 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -89,7 +89,15 @@ def main(): continue if ( tag.startswith('V6_') ) : continue - if ( tag.startswith('F') ) : + if ( tag.startswith('F') and + tag not in { + 'F2_sfimm_p', + 'F2_sfimm_n', + 'F2_dfimm_p', + 'F2_dfimm_n', + 'F2_dfmpyll', + 'F2_dfmpylh' + }): continue if ( tag.endswith('_locked') ) : continue --=20 2.25.1