From nobody Wed Nov 27 15:44:17 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698279921; cv=none; d=zohomail.com; s=zohoarc; b=HEu785xjTQ+htem/Qs0E6hB1epGwkZO1IU8COJxhO40A67Q5/g3u/woAaAGZqjDCluG/IqkxzWxS51oxrL0Ba2XXOnHbWpWSZd16kM2+ZZEfp3bOe3+50/REgPWMaAOWemSRvL5dSRZy0ONQ1cLEOfk4jLzDwi1fHF1YkUaKO+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698279921; h=Content-Transfer-Encoding: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:Cc; bh=Dcov+EvgUKOcstVsIicTu1476ZKJilrV5KBfm5f0U0k=; b=TGSRbo8gDn/+KLktrGqNaNSjxDl3PiRIL47f6XAZ9mc0rpda2Nc1CoilHZ7/oUIiMduWHERHKMNVIycNi+N43Q88wqSecT1U5RDOOORiZ7cGgyzCsTnsCbh+tXdmUO5Z2ElfqxvEYk75lTj9UdkgNMuDi8fqwGHSIXMxRfKSrww= 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 1698279921591866.685429368685; Wed, 25 Oct 2023 17:25:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvo2n-000723-6H; Wed, 25 Oct 2023 20:16:13 -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 1qvo2S-0006y2-As for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:16:06 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvo2N-0004pH-J2 for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:15:49 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ca215cc713so2016735ad.3 for ; Wed, 25 Oct 2023 17:15:46 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ij23-20020a170902ab5700b001c582de968dsm10038433plb.72.2023.10.25.17.15.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 17:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698279345; x=1698884145; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Dcov+EvgUKOcstVsIicTu1476ZKJilrV5KBfm5f0U0k=; b=WPKowjfQJWVwFKPYucglTywmHO+jpyGzh+BvfOrShZZ93jzZ2D03wfNOMs83uMlfir GwZxnM5Vku2giu1Dzck/qpsMFT6UJcopOfFmE7huTIExzwwNHy+nVOePc5ZfAtx30/V8 ljCrQkQsq0W2iMjnkfjkpfvU5Zoh+Lf1EIb68GLg8biOyzYCv630vsMdpusjfr2rtwwV JBII6O3WPS/i2s1pUTqlB3IR+0zHQCRuIY2C1kfp1OPyQdaHwSpEjrHSkDVFj7Q2+Wb5 SuzAS9/lYQia4euvT/ixeeMsNJL02+QUtP0Z/feQR4uTnligjrFlzW99TvQtSlduuqHV DuQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698279345; x=1698884145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dcov+EvgUKOcstVsIicTu1476ZKJilrV5KBfm5f0U0k=; b=Ot+AbY4+S5Xsn/3r+H/RXok+WD752UDLzHZAp2NE4WXLuNLSgmydK5M9jYK8l7fHS+ aqgGFFt/ev6cbq1HFZcjrALCfBUIeGmbvI2EEA5iwoqNy4o5kkMM8KII0yzQbFbYaQ3u YFZ20co5eaZ0SPbQB0yMmmDj9murqxqQlLoK7tXIezC++CuzcTvI5ROrmfl+mbyL0ktC 3mOAgloiFGjoxpuNYnJLDbaA55XxQy+FmShuUPmFg5K5Rz/dFXnmL08Dm6V3GmSTe9dp JxNxWEEHe4bEHxEuE3Q8nE7UtgVQLaQyHinQlfK6qABS0By0pxzoz4se5h0c0ufrrKNh C1wQ== X-Gm-Message-State: AOJu0YzNzAARkrceEY51C6Q+/+BzyVlbhGCwdhRK43XGVHYLLvMz/jln Sw6HWSZDPG4fmzlirhUVPuW3AMPKBlxaRKH7f6I= X-Google-Smtp-Source: AGHT+IH6eA5Blzb8w9nLZvQNNdBr488p2pnsdRzjIk3TXJiLVNNFsk9v/mBwWaGTu5VfX4pWKHkeXg== X-Received: by 2002:a17:903:2450:b0:1ca:2ec4:7f3f with SMTP id l16-20020a170903245000b001ca2ec47f3fmr16268257pls.45.1698279345552; Wed, 25 Oct 2023 17:15:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 01/29] tcg: Introduce TCG_COND_TST{EQ,NE} Date: Wed, 25 Oct 2023 17:13:41 -0700 Message-Id: <20231026001542.1141412-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026001542.1141412-1-richard.henderson@linaro.org> References: <20231026001542.1141412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1698279922960100003 Content-Type: text/plain; charset="utf-8" Add the enumerators, adjust the helpers to match, and dump. Not supported anywhere else just yet. Signed-off-by: Richard Henderson --- include/tcg/tcg-cond.h | 49 ++++++++++++++++++++++++++++++++---------- tcg/tcg.c | 4 +++- docs/devel/tcg-ops.rst | 2 ++ 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/include/tcg/tcg-cond.h b/include/tcg/tcg-cond.h index 2a38a386d4..bf3fcf5968 100644 --- a/include/tcg/tcg-cond.h +++ b/include/tcg/tcg-cond.h @@ -49,6 +49,9 @@ typedef enum { TCG_COND_GEU =3D 0 | 4 | 0 | 1, TCG_COND_LEU =3D 8 | 4 | 0 | 0, TCG_COND_GTU =3D 8 | 4 | 0 | 1, + /* "test" i.e. and then compare vs 0 */ + TCG_COND_TSTEQ =3D 8 | 4 | 2 | 0, + TCG_COND_TSTNE =3D 8 | 4 | 2 | 1, } TCGCond; =20 /* Invert the sense of the comparison. */ @@ -60,25 +63,49 @@ static inline TCGCond tcg_invert_cond(TCGCond c) /* Swap the operands in a comparison. */ static inline TCGCond tcg_swap_cond(TCGCond c) { - return c & 6 ? (TCGCond)(c ^ 9) : c; + return (c + 2) & 4 ? (TCGCond)(c ^ 9) : c; } =20 -/* Create an "unsigned" version of a "signed" comparison. */ -static inline TCGCond tcg_unsigned_cond(TCGCond c) +/* Must a comparison be considered signed? */ +static inline bool is_signed_cond(TCGCond c) { - return c & 2 ? (TCGCond)(c ^ 6) : c; -} - -/* Create a "signed" version of an "unsigned" comparison. */ -static inline TCGCond tcg_signed_cond(TCGCond c) -{ - return c & 4 ? (TCGCond)(c ^ 6) : c; + return (c & 6) =3D=3D 2; } =20 /* Must a comparison be considered unsigned? */ static inline bool is_unsigned_cond(TCGCond c) { - return (c & 4) !=3D 0; + return (c & 6) =3D=3D 4; +} + +/* Must a comparison be considered a test? */ +static inline bool is_tst_cond(TCGCond c) +{ + return (c | 1) =3D=3D 0xf; +} + +/* Create an "unsigned" version of a "signed" comparison. */ +static inline TCGCond tcg_unsigned_cond(TCGCond c) +{ + return is_signed_cond(c) ? (TCGCond)(c ^ 6) : c; +} + +/* Create a "signed" version of an "unsigned" comparison. */ +static inline TCGCond tcg_signed_cond(TCGCond c) +{ + return is_unsigned_cond(c) ? (TCGCond)(c ^ 6) : c; +} + +/* Create the eq/ne version of a tsteq/tstne comparison. */ +static inline TCGCond tcg_tst_eqne_cond(TCGCond c) +{ + return is_tst_cond(c) ? (TCGCond)(c ^ 6) : c; +} + +/* Create the lt/ge version of a tstne/tsteq comparison of the sign. */ +static inline TCGCond tcg_tst_ltge_cond(TCGCond c) +{ + return is_tst_cond(c) ? (TCGCond)(c ^ (8 | 4 | 1)) : c; } =20 /* diff --git a/tcg/tcg.c b/tcg/tcg.c index 35158a0846..57d0583fe7 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2378,7 +2378,9 @@ static const char * const cond_name[] =3D [TCG_COND_LTU] =3D "ltu", [TCG_COND_GEU] =3D "geu", [TCG_COND_LEU] =3D "leu", - [TCG_COND_GTU] =3D "gtu" + [TCG_COND_GTU] =3D "gtu", + [TCG_COND_TSTEQ] =3D "tsteq", + [TCG_COND_TSTNE] =3D "tstne", }; =20 static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] =3D diff --git a/docs/devel/tcg-ops.rst b/docs/devel/tcg-ops.rst index 8ae59ea02b..d46b625e0e 100644 --- a/docs/devel/tcg-ops.rst +++ b/docs/devel/tcg-ops.rst @@ -253,6 +253,8 @@ Jumps/Labels | ``TCG_COND_GEU /* unsigned */`` | ``TCG_COND_LEU /* unsigned */`` | ``TCG_COND_GTU /* unsigned */`` + | ``TCG_COND_TSTEQ /* t1 & t2 =3D=3D 0 */`` + | ``TCG_COND_TSTNE /* t1 & t2 !=3D 0 */`` =20 Arithmetic ---------- --=20 2.34.1