From nobody Tue Nov 26 14:28:39 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1706742671; cv=none; d=zohomail.com; s=zohoarc; b=CGeVW6e3AWvmAFUuwXOGIOcUPwfE2ntoM8DnyFRAU6Y2rhTu3ZIFynKI6M2Bz7MLQZ39v4TSA9rx2YbvyneCymGKpD2CWIsEyLvFfQFG/3HSBbmhkvZkobm+WcqOKCkF1bDUMUf5U7d058iFYe4TKOjYh7pylEGAnrSzTGIBGmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706742671; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TWaAYzedoDmwSo+VdLBPaFxuqPcfOVTInVXJb7c9NXw=; b=hl8Fs1NsPXkVQWYs/5MBlF6WONoSWsn43Ajd3eexbTwXGg7fvb+nvJDb9h5Xm2wv8w4v7YJsGbaHR4YJlseEhRqY+PipAPUvVkgEYLz4OSNNS4nXv8Qcvkt/W1W+yyXzOYa79tRzRaLlqyFqWJ0DvgZl+fKJItXtKZYj0g6riZQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706742671949310.7787207786225; Wed, 31 Jan 2024 15:11:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVJiW-00077z-0h; Wed, 31 Jan 2024 18:10:04 -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 1rVJiP-000768-0t; Wed, 31 Jan 2024 18:09:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVJiM-0000Jh-FQ; Wed, 31 Jan 2024 18:09:56 -0500 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40VN5oga022585; Wed, 31 Jan 2024 23:09:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vyujp5w65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:47 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40VN5vQD023042; Wed, 31 Jan 2024 23:09:46 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vyujp5w5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:46 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40VMjYfm007196; Wed, 31 Jan 2024 23:09:45 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vwev2g0yk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:45 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40VN9huC26215044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2024 23:09:43 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7D5520043; Wed, 31 Jan 2024 23:09:43 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B03920040; Wed, 31 Jan 2024 23:09:43 +0000 (GMT) Received: from localhost.localdomain (unknown [9.171.74.74]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 31 Jan 2024 23:09:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=TWaAYzedoDmwSo+VdLBPaFxuqPcfOVTInVXJb7c9NXw=; b=aPgPAp8hQUy3WkkNGXfSxX4Z/80evWvPI7BDIZYlsg0FohA9G4rHbYCxKSty9gJvpYkk myXTnDZWgfeRAwE/cw5nG2KuKAE0z+NRvP7x9YhjmXU7C+PWJxLIMqn7HF2mPT0s/5+a +FZVpRmyo5vhoQQBqXBZPT9BPaHlsjL0Zf3XalrOki39slIrn36iIT9E3xCuJpSGdI7C m5+XwnSlX6IqOX5hKghP6GgUohWfl3B2bE+YpHEa/IbKjnP3DPCGvSqk7aVkoN4oDWPS TGu5M+IAKQQ/TLOSeDyj5A+IbX3i0Vt3k62u17UMo6sQwvorfMKmVqsypVBG/AiKHCfk vA== From: Ilya Leoshkevich To: Richard Henderson , David Hildenbrand , Thomas Huth Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich , Ido Plat Subject: [PATCH v3 1/4] target/s390x: Emulate CVDG Date: Thu, 1 Feb 2024 00:07:10 +0100 Message-ID: <20240131230938.325919-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131230938.325919-1-iii@linux.ibm.com> References: <20240131230938.325919-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eG1TaE58bA7TwylZKne4BviTNz9hXhy8 X-Proofpoint-GUID: KpCFBC9rp0PWPhTuqmWcPDtR9UyzFe_s X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=567 phishscore=0 spamscore=0 malwarescore=0 mlxscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 adultscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401310178 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=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1706742673692100005 Content-Type: text/plain; charset="utf-8" CVDG is the same as CVD, except that it converts 64 bits into 128, rather than 32 into 64. Create a new helper, which uses Int128 wrappers. Reported-by: Ido Plat Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich --- target/s390x/helper.h | 1 + target/s390x/tcg/insn-data.h.inc | 1 + target/s390x/tcg/int_helper.c | 21 +++++++++++++++++++++ target/s390x/tcg/translate.c | 8 ++++++++ 4 files changed, 31 insertions(+) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 05102578fc9..332a9a9c632 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -89,6 +89,7 @@ DEF_HELPER_FLAGS_2(sqeb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(sqdb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(sqxb, TCG_CALL_NO_WG, i128, env, i128) DEF_HELPER_FLAGS_1(cvd, TCG_CALL_NO_RWG_SE, i64, s32) +DEF_HELPER_FLAGS_1(cvdg, TCG_CALL_NO_RWG_SE, i128, s64) DEF_HELPER_FLAGS_4(pack, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(pka, TCG_CALL_NO_WG, void, env, i64, i64, i32) DEF_HELPER_FLAGS_4(pku, TCG_CALL_NO_WG, void, env, i64, i64, i32) diff --git a/target/s390x/tcg/insn-data.h.inc b/target/s390x/tcg/insn-data.= h.inc index 2f07f39d9cb..388dcb8dbbc 100644 --- a/target/s390x/tcg/insn-data.h.inc +++ b/target/s390x/tcg/insn-data.h.inc @@ -296,6 +296,7 @@ /* CONVERT TO DECIMAL */ C(0x4e00, CVD, RX_a, Z, r1_o, a2, 0, 0, cvd, 0) C(0xe326, CVDY, RXY_a, LD, r1_o, a2, 0, 0, cvd, 0) + C(0xe32e, CVDG, RXY_a, Z, r1_o, a2, 0, 0, cvdg, 0) /* CONVERT TO FIXED */ F(0xb398, CFEBR, RRF_e, Z, 0, e2, new, r1_32, cfeb, 0, IF_BFP) F(0xb399, CFDBR, RRF_e, Z, 0, f2, new, r1_32, cfdb, 0, IF_BFP) diff --git a/target/s390x/tcg/int_helper.c b/target/s390x/tcg/int_helper.c index eb8e6dd1b57..121e3006a65 100644 --- a/target/s390x/tcg/int_helper.c +++ b/target/s390x/tcg/int_helper.c @@ -118,6 +118,27 @@ uint64_t HELPER(cvd)(int32_t reg) return dec; } =20 +Int128 HELPER(cvdg)(int64_t reg) +{ + /* positive 0 */ + Int128 dec =3D int128_make64(0x0c); + Int128 bin =3D int128_makes64(reg); + Int128 base =3D int128_make64(10); + int shift; + + if (!int128_nonneg(bin)) { + bin =3D int128_neg(bin); + dec =3D int128_make64(0x0d); + } + + for (shift =3D 4; (shift < 128) && int128_nz(bin); shift +=3D 4) { + dec =3D int128_or(dec, int128_lshift(int128_remu(bin, base), shift= )); + bin =3D int128_divu(bin, base); + } + + return dec; +} + uint64_t HELPER(popcnt)(uint64_t val) { /* Note that we don't fold past bytes. */ diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index a5fd9cccaa5..c2fdc920a50 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -2233,6 +2233,14 @@ static DisasJumpType op_cvd(DisasContext *s, DisasOp= s *o) return DISAS_NEXT; } =20 +static DisasJumpType op_cvdg(DisasContext *s, DisasOps *o) +{ + TCGv_i128 t =3D tcg_temp_new_i128(); + gen_helper_cvdg(t, o->in1); + tcg_gen_qemu_st_i128(t, o->in2, get_mem_index(s), MO_TE | MO_128); + return DISAS_NEXT; +} + static DisasJumpType op_ct(DisasContext *s, DisasOps *o) { int m3 =3D get_field(s, m3); --=20 2.43.0 From nobody Tue Nov 26 14:28:39 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1706742635; cv=none; d=zohomail.com; s=zohoarc; b=IfkerMAG0EUkJeeAeotClcCc9G9ajIJoRh2bVV3ZsxR5ztvDDzruqvCs0rG6I3Wsy9B6DxKX149V6vgUja4Efy/6Eloqlo8vqD5CVhsuQAoUUSZdAnWyXOxCmEV6LGWwgAZwFDGlW9g9HlHfvBp2VON9SrccwlH9/2ONpGZahKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706742635; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fFYdDA+mo71xop/vxKRLti7cnXSGCoC0cCmX4QN1fzU=; b=HiMUuK9u+fhPi+Qw/FM65psvIF2JrynGJa0/atuVFPrFKPIS9rdP4WHQTCCJAziauLXW2tQU6BVreMaDW7hWjhHVoXQ3Eacd45TmttEcfAcX0egwc8oQe4QQc1dWIyqVB3XSxTSKPpyhu8MqAGSNKUQ66QKsqt/GvnkiHWY6Z8M= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706742635570149.35641556047938; Wed, 31 Jan 2024 15:10:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVJiY-00079I-Da; Wed, 31 Jan 2024 18:10:06 -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 1rVJiP-000769-1D; Wed, 31 Jan 2024 18:09:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVJiM-0000KE-G3; Wed, 31 Jan 2024 18:09:55 -0500 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40VMLIMY013401; Wed, 31 Jan 2024 23:09:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vyxqehewn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:50 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40VMtWIe023335; Wed, 31 Jan 2024 23:09:49 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vyxqehewe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:49 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40VK5tvs002319; Wed, 31 Jan 2024 23:09:49 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vwc5tgq6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:48 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40VN9lhj11862560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2024 23:09:47 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31B9820043; Wed, 31 Jan 2024 23:09:47 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6E1220040; Wed, 31 Jan 2024 23:09:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.171.74.74]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 31 Jan 2024 23:09:46 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=fFYdDA+mo71xop/vxKRLti7cnXSGCoC0cCmX4QN1fzU=; b=EsWGqzvEqdrcIzwGiA2Tcfdf4JmRPgcn1OnZkYr7o4ejMzNmtZY6nHEX+6TLXaUmdD2X zoWFg8UxBHA9I9lBzoU98GnWfOvTb2oB2C3xiBAKfB8uunROiL/PpyX8ZOpvGpAVybkI KgUJTI4ATvEHOPiJRv9CTaJ+xoeajtpnXe+eoup4EOJD37jS/yuqwSHGeNGlyoGa0jJC fP48hLKZRw6WtXSgH9odFF8UW8X+iecM3esoYH7twyisZ1qPELTavZlk/XkvQ3WQLMQ5 kiVhxgp6w/GAa+WOkOVxprHafNjjDNNNIJxzDCAh4NYby1cM4U/qK4mqKcrO5Og6cn0G JQ== From: Ilya Leoshkevich To: Richard Henderson , David Hildenbrand , Thomas Huth Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH v3 2/4] tests/tcg/s390x: Test CONVERT TO DECIMAL Date: Thu, 1 Feb 2024 00:07:11 +0100 Message-ID: <20240131230938.325919-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131230938.325919-1-iii@linux.ibm.com> References: <20240131230938.325919-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: rrNGjXFiLSbgz5IguHTWHTWQlYTpViga X-Proofpoint-GUID: cOTSQpjV8YdkDOSBh0a4fCVPvo8BMh48 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 priorityscore=1501 phishscore=0 suspectscore=0 malwarescore=0 mlxlogscore=791 adultscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401310178 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=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1706742637510100011 Content-Type: text/plain; charset="utf-8" Check the CVD's and CVDG's corner cases. Signed-off-by: Ilya Leoshkevich Reviewed-by: Thomas Huth --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvd.c | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/tcg/s390x/cvd.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 30994dcf9c2..04e4bddd83d 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -45,6 +45,7 @@ TESTS+=3Dclc TESTS+=3Dlaalg TESTS+=3Dadd-logical-with-carry TESTS+=3Dlae +TESTS+=3Dcvd =20 cdsg: CFLAGS+=3D-pthread cdsg: LDFLAGS+=3D-pthread diff --git a/tests/tcg/s390x/cvd.c b/tests/tcg/s390x/cvd.c new file mode 100644 index 00000000000..c1fb63ca9a6 --- /dev/null +++ b/tests/tcg/s390x/cvd.c @@ -0,0 +1,45 @@ +/* + * Test the CONVERT TO DECIMAL instruction. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include + +static uint64_t cvd(int32_t x) +{ + uint64_t ret; + + asm("cvd %[x],%[ret]" : [ret] "=3DR" (ret) : [x] "r" (x)); + + return ret; +} + +static __uint128_t cvdg(int64_t x) +{ + __uint128_t ret; + + asm("cvdg %[x],%[ret]" : [ret] "=3DT" (ret) : [x] "r" (x)); + + return ret; +} + +int main(void) +{ + __uint128_t m =3D (((__uint128_t)0x9223372036854775) << 16) | 0x8070; + + assert(cvd(0) =3D=3D 0xc); + assert(cvd(1) =3D=3D 0x1c); + assert(cvd(-1) =3D=3D 0x1d); + assert(cvd(0x7fffffff) =3D=3D 0x2147483647c); + assert(cvd(-0x7fffffff) =3D=3D 0x2147483647d); + + assert(cvdg(0) =3D=3D 0xc); + assert(cvdg(1) =3D=3D 0x1c); + assert(cvdg(-1) =3D=3D 0x1d); + assert(cvdg(0x7fffffffffffffff) =3D=3D (m | 0xc)); + assert(cvdg(-0x7fffffffffffffff) =3D=3D (m | 0xd)); + + return EXIT_SUCCESS; +} --=20 2.43.0 From nobody Tue Nov 26 14:28:39 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1706742631; cv=none; d=zohomail.com; s=zohoarc; b=FBC6qh7rnDYzNth+xQ/SX/lEQ96nQFVpFrD0Sw+dnUMXbx6vEyyAlu5Zk6JFQeduzrNW3qb/5vM1iMsk0Tf3kCeWhKs8crQQVYXYb/iheyoTFQyv+hyxezpllRD5kWGR7iy3VkiyAFcMybKTj188yrJkKztvCdl+20A4fbIDLtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706742631; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PDs9WcuQA2Fn9a9vifWCDcrigVwLNQp3r4uZwvf7LJY=; b=VvjYn/AJFc0M4X/Ec6EGHOS9BuHnHNS3KWDh3wvj6Y7KgbY1qrLD0pyfqtr16+h4ZGVKQ4o4SeaN3jw+54xA/8kqxk8Hh2O1P5rsj9bdi7eRSNLhnrJ6vbLR9GWQTD3xsJNc/I0BW8VAAboK4QCHcPM7ITkskN9yAosAB5/ogf0= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706742631606778.5798118028576; Wed, 31 Jan 2024 15:10:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVJiY-00079J-Nn; Wed, 31 Jan 2024 18:10:06 -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 1rVJiP-00076A-1r; Wed, 31 Jan 2024 18:09:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVJiM-0000KQ-Sc; Wed, 31 Jan 2024 18:09:56 -0500 Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40VMCggF022216; Wed, 31 Jan 2024 23:09:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vytwmy7mr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:52 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40VN0erL003175; Wed, 31 Jan 2024 23:09:51 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vytwmy7mg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:51 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40VK1wBV002256; Wed, 31 Jan 2024 23:09:50 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vwc5tgq6y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:50 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40VN9nO716974554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2024 23:09:49 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0CF8A20040; Wed, 31 Jan 2024 23:09:49 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9045E2004B; Wed, 31 Jan 2024 23:09:48 +0000 (GMT) Received: from localhost.localdomain (unknown [9.171.74.74]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 31 Jan 2024 23:09:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=PDs9WcuQA2Fn9a9vifWCDcrigVwLNQp3r4uZwvf7LJY=; b=lqGhBighAFMlFZqg+vr7PLkzGvPZBQZDJuU+k9MoUDotZ5/lPDsudEYLNulAqinzERdi UzQNsv6YL5rsieJqcGuqnxtCvheIbs/bruLEZ34jRJ2HVlBoU2d29YGcIrtVIGoXQpth 4b5e60DyOFmW+QgU1QvnQWoLUAwImNclrjxZXGJInmrSXYtNOorbdLKo6JCxim5qDd4X 9BpPxbVZNcYkr8r1AzUJ4oORF07Z02TJmtl6iG37dIzGJzT1sSuB+BjFECPJAHYGWQMp 7/RACvTxWxEbZ8Gr31pyT+Boy97UfNcdak7fEVd8BVM3piLOYwwvH2YqwHjItCkqBLE6 wQ== From: Ilya Leoshkevich To: Richard Henderson , David Hildenbrand , Thomas Huth Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Pavel Zbitskiy Subject: [PATCH v3 3/4] target/s390x: implement CVB, CVBY and CVBG Date: Thu, 1 Feb 2024 00:07:12 +0100 Message-ID: <20240131230938.325919-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131230938.325919-1-iii@linux.ibm.com> References: <20240131230938.325919-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wLUVu3BzEkjLVHTFEnZdq_t_lp4UyCSN X-Proofpoint-ORIG-GUID: zCnvGO16RUAM3MeYOw-z-5kptm1c6rx9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=886 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401310178 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=148.163.156.1; envelope-from=iii@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1706742633656100003 Content-Type: text/plain; charset="utf-8" From: Pavel Zbitskiy Convert to Binary - counterparts of the already implemented Convert to Decimal (CVD*) instructions. Example from the Principles of Operation: 25594C becomes 63FA. [iii: Use separate functions for CVB and CVBG for simplicity]. Signed-off-by: Pavel Zbitskiy --- target/s390x/helper.h | 1 + target/s390x/tcg/insn-data.h.inc | 4 ++++ target/s390x/tcg/int_helper.c | 40 ++++++++++++++++++++++++++++++++ target/s390x/tcg/translate.c | 12 ++++++++++ 4 files changed, 57 insertions(+) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 332a9a9c632..3c607f4e437 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -88,6 +88,7 @@ DEF_HELPER_FLAGS_3(tcxb, TCG_CALL_NO_RWG_SE, i32, env, i1= 28, i64) DEF_HELPER_FLAGS_2(sqeb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(sqdb, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(sqxb, TCG_CALL_NO_WG, i128, env, i128) +DEF_HELPER_FLAGS_3(cvb, TCG_CALL_NO_WG, i64, env, i64, i32) DEF_HELPER_FLAGS_1(cvd, TCG_CALL_NO_RWG_SE, i64, s32) DEF_HELPER_FLAGS_1(cvdg, TCG_CALL_NO_RWG_SE, i128, s64) DEF_HELPER_FLAGS_4(pack, TCG_CALL_NO_WG, void, env, i32, i64, i64) diff --git a/target/s390x/tcg/insn-data.h.inc b/target/s390x/tcg/insn-data.= h.inc index 388dcb8dbbc..9eb998d4c25 100644 --- a/target/s390x/tcg/insn-data.h.inc +++ b/target/s390x/tcg/insn-data.h.inc @@ -293,6 +293,10 @@ D(0xec73, CLFIT, RIE_a, GIE, r1_32u, i2_16u, 0, 0, ct, 0, 1) D(0xec71, CLGIT, RIE_a, GIE, r1_o, i2_16u, 0, 0, ct, 0, 1) =20 +/* CONVERT TO BINARY */ + C(0x4f00, CVB, RX_a, Z, la2, 0, new, r1_32, cvb, 0) + C(0xe306, CVBY, RXY_a, LD, la2, 0, new, r1_32, cvb, 0) + C(0xe30e, CVBG, RXY_a, Z, la2, 0, r1, 0, cvbg, 0) /* CONVERT TO DECIMAL */ C(0x4e00, CVD, RX_a, Z, r1_o, a2, 0, 0, cvd, 0) C(0xe326, CVDY, RXY_a, LD, r1_o, a2, 0, 0, cvd, 0) diff --git a/target/s390x/tcg/int_helper.c b/target/s390x/tcg/int_helper.c index 121e3006a65..002d4b52dda 100644 --- a/target/s390x/tcg/int_helper.c +++ b/target/s390x/tcg/int_helper.c @@ -25,6 +25,7 @@ #include "exec/exec-all.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" +#include "exec/cpu_ldst.h" =20 /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER @@ -98,6 +99,45 @@ Int128 HELPER(divu64)(CPUS390XState *env, uint64_t ah, u= int64_t al, uint64_t b) tcg_s390_program_interrupt(env, PGM_FIXPT_DIVIDE, GETPC()); } =20 +uint64_t HELPER(cvb)(CPUS390XState *env, uint64_t src, uint32_t n) +{ + int64_t dec, sign =3D 0, digit, val =3D 0, pow10 =3D 0; + const uintptr_t ra =3D GETPC(); + uint64_t tmpsrc; + int i, j; + + for (i =3D 0; i < n; i++) { + tmpsrc =3D wrap_address(env, src + (n - i - 1) * 8); + dec =3D cpu_ldq_data_ra(env, tmpsrc, ra); + for (j =3D 0; j < 16; j++, dec >>=3D 4) { + if (i =3D=3D 0 && j =3D=3D 0) { + sign =3D dec & 0xf; + if (sign < 0xa) { + tcg_s390_data_exception(env, 0, ra); + } + continue; + } + digit =3D dec & 0xf; + if (digit > 0x9) { + tcg_s390_data_exception(env, 0, ra); + } + if (i =3D=3D 0 && j =3D=3D 1) { + if (sign =3D=3D 0xb || sign =3D=3D 0xd) { + val =3D -digit; + pow10 =3D -10; + } else { + val =3D digit; + pow10 =3D 10; + } + } else { + val +=3D digit * pow10; + pow10 *=3D 10; + } + } + } + return val; +} + uint64_t HELPER(cvd)(int32_t reg) { /* positive 0 */ diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index c2fdc920a50..43216571b44 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -2223,6 +2223,18 @@ static DisasJumpType op_csp(DisasContext *s, DisasOp= s *o) } #endif =20 +static DisasJumpType op_cvb(DisasContext *s, DisasOps *o) +{ + gen_helper_cvb(o->out, tcg_env, o->addr1, tcg_constant_i32(1)); + return DISAS_NEXT; +} + +static DisasJumpType op_cvbg(DisasContext *s, DisasOps *o) +{ + gen_helper_cvb(o->out, tcg_env, o->addr1, tcg_constant_i32(2)); + return DISAS_NEXT; +} + static DisasJumpType op_cvd(DisasContext *s, DisasOps *o) { TCGv_i64 t1 =3D tcg_temp_new_i64(); --=20 2.43.0 From nobody Tue Nov 26 14:28:39 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1706742672; cv=none; d=zohomail.com; s=zohoarc; b=lhKqURIqy3qXH6oPEb/YiSvdwp/7KNuuGj2pwd5MwFppdaoHdTGZnF5ciVlqeXY/Dv1HxWAwnnNADozHNb7F1lHKvTfEIhBeoul9dy+5rA7BJVJzQD9xH4zpBXQlLLbyRjZZ+QSfX9f5liXeR8vmJVa6f0mW8dQ2X7mZT4aDEo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706742672; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2QPGWHq4+h1+zRL0qablFV0HHBXadUmRLKNwT+Njx+U=; b=D6bmEHKjf25mpiuKiq5CBgRVgwDEmgx0aCl/LZWK2EjpBL29jYNkjh7FGivRsdkO9+1N8gwKi1VtOoSsR7PTCW/ZVziPPuFz2en/XBc1lEwSu3gLXE3dOjzzqnar8PLbBhcsLbv0QkVEO/tTrjsvh3FEnw1gyFNs21lBmz68qGg= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706742672048451.7637196979057; Wed, 31 Jan 2024 15:11:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVJim-0007AV-TT; Wed, 31 Jan 2024 18:10:22 -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 1rVJiQ-00076b-C7; Wed, 31 Jan 2024 18:10:00 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVJiO-0000Kx-OZ; Wed, 31 Jan 2024 18:09:58 -0500 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40VMILbQ006744; Wed, 31 Jan 2024 23:09:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vyxvq8yhu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:53 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40VMIMYw006789; Wed, 31 Jan 2024 23:09:53 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vyxvq8yhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:53 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40VLBspg010535; Wed, 31 Jan 2024 23:09:52 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vwd5p0e4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 23:09:52 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40VN9ovX15139428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jan 2024 23:09:50 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 981EF20043; Wed, 31 Jan 2024 23:09:50 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A24120040; Wed, 31 Jan 2024 23:09:50 +0000 (GMT) Received: from localhost.localdomain (unknown [9.171.74.74]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 31 Jan 2024 23:09:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=2QPGWHq4+h1+zRL0qablFV0HHBXadUmRLKNwT+Njx+U=; b=SsbSNzH4+swbt44drKDIYXrVyYFUI4v/TkduLsgR4+y+gtRgqVPAfMTwF0Z6WwxlaN0h JKrSm3vob81PyuU7r7e14rLMzKHwDK+wRsvUuDhMlLPqNkN7XweXeYApYzShcgXF37z/ 2WsUvkXaaF8e+chJYTWIMSzH4N4iMvEAXNOyWhGesCOXRLJ7EDqrkDy8kXwvoq0XBwS8 OrVFS0beXHRZ9TDuK1bECRJjKhiAt/A4NtPKFQvzHeLMoxRBihIGgr76m+MCeUo0j9EV wgcjdI7vBMjl5Sc0eNO/jUIHOFtRJwLmX7L+7BpuLxJrlub5je6+9oWnr6Oi9HKx2Uiw KQ== From: Ilya Leoshkevich To: Richard Henderson , David Hildenbrand , Thomas Huth Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Ilya Leoshkevich , Pavel Zbitskiy Subject: [PATCH v3 4/4] tests/tcg/s390x: Test CONVERT TO BINARY Date: Thu, 1 Feb 2024 00:07:13 +0100 Message-ID: <20240131230938.325919-5-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131230938.325919-1-iii@linux.ibm.com> References: <20240131230938.325919-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: muIeQsakNJlalcv1Y9XQOvaqAPRkF9_x X-Proofpoint-ORIG-GUID: m47RkaQjCvDSq8iHvOHJzWJW6b6xpeMK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=785 spamscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401310178 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=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @ibm.com) X-ZM-MESSAGEID: 1706742673696100006 Content-Type: text/plain; charset="utf-8" Check the CVB's and CVBG's corner cases. Co-developed-by: Pavel Zbitskiy Signed-off-by: Ilya Leoshkevich Reviewed-by: Thomas Huth --- tests/tcg/s390x/Makefile.target | 1 + tests/tcg/s390x/cvb.c | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/tcg/s390x/cvb.c diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 04e4bddd83d..e2aba2ec274 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -46,6 +46,7 @@ TESTS+=3Dlaalg TESTS+=3Dadd-logical-with-carry TESTS+=3Dlae TESTS+=3Dcvd +TESTS+=3Dcvb =20 cdsg: CFLAGS+=3D-pthread cdsg: LDFLAGS+=3D-pthread diff --git a/tests/tcg/s390x/cvb.c b/tests/tcg/s390x/cvb.c new file mode 100644 index 00000000000..47b7a7965f4 --- /dev/null +++ b/tests/tcg/s390x/cvb.c @@ -0,0 +1,47 @@ +/* + * Test the CONVERT TO DECIMAL instruction. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include + +static int32_t cvb(uint64_t x) +{ + uint32_t ret; + + asm("cvb %[ret],%[x]" : [ret] "=3Dr" (ret) : [x] "R" (x)); + + return ret; +} + +static int64_t cvbg(__uint128_t x) +{ + int64_t ret; + + asm("cvbg %[ret],%[x]" : [ret] "=3Dr" (ret) : [x] "T" (x)); + + return ret; +} + +int main(void) +{ + __uint128_t m =3D (((__uint128_t)0x9223372036854775) << 16) | 0x8070; + + assert(cvb(0xc) =3D=3D 0); + assert(cvb(0x1c) =3D=3D 1); + assert(cvb(0x25594c) =3D=3D 25594); + assert(cvb(0x1d) =3D=3D -1); + assert(cvb(0x2147483647c) =3D=3D 0x7fffffff); + assert(cvb(0x2147483647d) =3D=3D -0x7fffffff); + + assert(cvbg(0xc) =3D=3D 0); + assert(cvbg(0x1c) =3D=3D 1); + assert(cvbg(0x25594c) =3D=3D 25594); + assert(cvbg(0x1d) =3D=3D -1); + assert(cvbg(m | 0xc) =3D=3D 0x7fffffffffffffff); + assert(cvbg(m | 0xd) =3D=3D -0x7fffffffffffffff); + + return EXIT_SUCCESS; +} --=20 2.43.0